Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-api-cloud
This commit is contained in:
commit
b7c3751f68
8 files changed
+107
-5
No files matched your search
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.canteen.vo.erp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Schema(description = "erp选择食材分页vo")
|
||||
public class ErpMaterialPageVo {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Schema(description="食材id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description="食材名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
*/
|
||||
@Schema(description="食材单位")
|
||||
private String unit;
|
||||
|
||||
|
||||
/**
|
||||
* 当前库存数量
|
||||
*/
|
||||
@Schema(description="当前库存数量")
|
||||
private Double stock;
|
||||
}
|
||||
+13
@@ -123,4 +123,17 @@ public class CanteenErpMaterialController {
|
||||
public List<CanteenErpMaterialEntity> export(CanteenErpMaterialEntity canteenErpMaterial,Long[] ids) {
|
||||
return canteenErpMaterialService.list(Wrappers.lambdaQuery(canteenErpMaterial).in(ArrayUtil.isNotEmpty(ids), CanteenErpMaterialEntity::getId, ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* erp选择食材分页数据
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "选择食材分页数据" , description = "选择食材分页数据" )
|
||||
@GetMapping("/erpMaterialPage" )
|
||||
public R getErpMaterialPage(@ParameterObject Page page, @RequestParam("name")String name) {
|
||||
return R.ok(canteenErpMaterialService.getErpMaterialPage(page, name));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -34,7 +34,7 @@ import java.util.Objects;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/canteenInventoryRecords" )
|
||||
@Tag(description = "canteenInventoryRecords" , name = "采购记录表管理" )
|
||||
@Tag(description = "canteenInventoryRecords" , name = "食堂进销管理" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class CanteenInventoryRecordsController {
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import java.util.Objects;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/canteenInventoryRecordsItem" )
|
||||
@Tag(description = "canteenInventoryRecordsItem" , name = "采购记录明细表管理" )
|
||||
@Tag(description = "canteenInventoryRecordsItem" , name = "食堂进销管理明细管理" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class CanteenInventoryRecordsItemController {
|
||||
|
||||
|
||||
+9
@@ -34,4 +34,13 @@ public interface CanteenErpMaterialService extends IService<CanteenErpMaterialEn
|
||||
Page<CanteenErpMaterialVO> pageScope(Page page, CanteenErpMaterialEntity canteenErpMaterial);
|
||||
|
||||
CanteenErpMaterialVO getCanteenErpMaterialVOById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* erp选择分页
|
||||
* @param page
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
Object getErpMaterialPage(Page page, String name);
|
||||
}
|
||||
+44
@@ -11,12 +11,20 @@ import com.bsd.pjcloud.canteen.mapper.CanteenErpMaterialMapper;
|
||||
import com.bsd.pjcloud.canteen.mapper.CanteenStockMapper;
|
||||
import com.bsd.pjcloud.canteen.service.CanteenErpMaterialService;
|
||||
import com.bsd.pjcloud.canteen.vo.erp.CanteenErpMaterialVO;
|
||||
import com.bsd.pjcloud.canteen.vo.erp.ErpMaterialPageVo;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 原料表
|
||||
*
|
||||
@@ -97,4 +105,40 @@ public class CanteenErpMaterialServiceImpl extends ServiceImpl<CanteenErpMateria
|
||||
canteenErpMaterialVO.setCurrentStock(sourceCanteenStockEntity.getCurrentStock());
|
||||
return canteenErpMaterialVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ErpMaterialPageVo> getErpMaterialPage(Page page, String name) {
|
||||
LambdaQueryWrapper<CanteenErpMaterialEntity> smErpUnitEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
smErpUnitEntityLambdaQueryWrapper.like(StringUtils.isNotBlank(name), CanteenErpMaterialEntity::getName, name);
|
||||
Page<CanteenErpMaterialEntity> spuPage = baseMapper.selectPageByScope(page, smErpUnitEntityLambdaQueryWrapper, DataScope.of());
|
||||
|
||||
// 将 SmErpSpuEntity 转换为 SmErpPageScopeVo
|
||||
List<ErpMaterialPageVo> voList = spuPage.getRecords().stream()
|
||||
.map(entity -> BeanUtils.toBean(entity, ErpMaterialPageVo.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Long> materialIds = voList.stream().map(vo -> vo.getId()).collect(Collectors.toList());
|
||||
|
||||
// 批量查询库存信息
|
||||
List<CanteenStockEntity> stocks = canteenStockMapper.selectList(
|
||||
new LambdaQueryWrapper<CanteenStockEntity>()
|
||||
.in(CanteenStockEntity::getItemId, materialIds));
|
||||
|
||||
// 建立SPU ID与库存的映射关系
|
||||
Map<Long,CanteenStockEntity> stockMap = stocks.stream()
|
||||
.collect(Collectors.toMap(CanteenStockEntity::getItemId, smErpStockEntity -> smErpStockEntity));
|
||||
|
||||
|
||||
voList.stream().forEach(vo -> {
|
||||
//库存
|
||||
CanteenStockEntity smErpStockEntity = stockMap.get(vo.getId());
|
||||
vo.setStock(smErpStockEntity != null ? smErpStockEntity.getCurrentStock() : 0);
|
||||
});
|
||||
|
||||
// 创建新的 Page 对象并设置数据
|
||||
Page<ErpMaterialPageVo> resultPage = new Page<>();
|
||||
org.springframework.beans.BeanUtils.copyProperties(spuPage, resultPage);
|
||||
resultPage.setRecords(voList);
|
||||
return resultPage;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -31,7 +31,8 @@
|
||||
</resultMap>
|
||||
<select id="selectPageDataByScope"
|
||||
resultType="com.bsd.pjcloud.canteen.vo.erp.CanteenProductionRecordPageVO">
|
||||
SELECT r.inventory_code,r.inventory_date, COALESCE(GROUP_CONCAT(m.name ORDER BY m.name SEPARATOR ','), '') AS product_name,r.remark,r.total_amount,s.supplier_name FROM `canteen_inventory_records` r
|
||||
SELECT r.inventory_code,r.inventory_date, COALESCE(GROUP_CONCAT(m.name ORDER BY m.name SEPARATOR ','), '') AS product_name,r.remark,r.total_amount,s.supplier_name
|
||||
FROM `canteen_inventory_records` r
|
||||
LEFT JOIN canteen_inventory_records_item i
|
||||
on r.id=i.inventory_id
|
||||
LEFT JOIN canteen_erp_material m
|
||||
@@ -43,7 +44,7 @@
|
||||
<if test="canteenInventoryRecords.inventoryCode != null and canteenInventoryRecords.inventoryCode != ''">
|
||||
and r.inventory_code = #{canteenInventoryRecords.inventoryCode}
|
||||
</if>
|
||||
<if test="inventoryDate != null and inventoryDate != ''">
|
||||
<if test="canteenInventoryRecords.inventoryDate != null and canteenInventoryRecords.inventoryDate != ''">
|
||||
and cpr.production_time = #{inventoryDate}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
-1
@@ -94,7 +94,6 @@ public class SmErpCgPlanController {
|
||||
*/
|
||||
@Operation(summary = "选择商品分页数据" , description = "选择商品分页数据" )
|
||||
@GetMapping("/erpSpuPage" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_smErpInventoryRecords_view')" )
|
||||
public R getErpSpuPage(@ParameterObject Page page, @ParameterObject ErpCgPlanDTO erpCgPlanDTO) {
|
||||
return R.ok(smErpSpuService.getErpSpuPage(page, erpCgPlanDTO));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user