From b070f6b55b99c78a8a399e117fad4451e128503d Mon Sep 17 00:00:00 2001 From: wangqiong <1322446236@qq.com> Date: Tue, 30 Jul 2024 17:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B4=B9=E7=94=A8=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E7=BB=9F=E8=AE=A1=E7=9A=84=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 5 +- .../AppSceneCostCountController.java | 15 ++-- .../cost/manage/entity/AppSceneCostCount.java | 4 +- .../entity/AppSceneCostResultValue.java | 6 ++ .../manage/entity/CostPartMissingInfo.java | 2 + .../kn/cost/manage/enums/FeeTypeEnum.java | 26 ++++--- .../manage/plugin/StandardCostService.java | 71 +++++++++++++++++-- .../service/IAppSceneCostCountService.java | 5 +- .../IAppSceneCostResultValueService.java | 14 +++- .../impl/AppSceneCostCountServiceImpl.java | 35 ++++++++- .../AppSceneCostResultValueServiceImpl.java | 23 +++++- .../kn/cost/manage/vo/MissingComponentVO.java | 30 ++++++++ 12 files changed, 196 insertions(+), 40 deletions(-) create mode 100644 qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/MissingComponentVO.java diff --git a/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml b/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml index ffffd3c..839dcd4 100644 --- a/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml +++ b/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml @@ -282,9 +282,8 @@ jeecg: #webapp文件路径 webapp: /opt/webapp shiro: -# excludeUrls: /api/**,/api/internalService/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo,/sys/sysDepart/**,/taskSocket/**,/flowSocket/**,/dataCheck/** -# excludeUrls: /api/internalService/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo,/sys/sysDepart/**,/taskSocket/**,/flowSocket/**,/dataCheck/** - excludeUrls: /**/**,/**/**/** + excludeUrls: /api/internalService/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo,/sys/sysDepart/**,/taskSocket/**,/flowSocket/**,/dataCheck/** +# excludeUrls: /**/**,/**/**/** #阿里云oss存储和大鱼短信秘钥配置 oss: diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java index 7078a5c..c30a3e5 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount; import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService; +import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -20,6 +21,7 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; +import java.util.List; /** * @Description: app_scene_cost_count @@ -47,10 +49,7 @@ public class AppSceneCostCountController extends JeecgController> queryPageList(AppSceneCostCount appSceneCostCount, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { + public Result> queryPageList(AppSceneCostCount appSceneCostCount, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostCount, req.getParameterMap()); Page page = new Page(pageNo, pageSize); IPage pageList = appSceneCostCountService.page(page, queryWrapper); @@ -129,12 +128,12 @@ public class AppSceneCostCountController extends JeecgController queryMissingComponentById(@RequestParam(name = "id", required = true) String id) { - AppSceneCostCount appSceneCostCount = appSceneCostCountService.queryMissingComponentById(id); - if (appSceneCostCount == null) { + public Result> queryMissingComponentById(@RequestParam(name = "id", required = true) String id) { + List result = appSceneCostCountService.queryMissingComponentById(id); + if (result == null) { return Result.error("未找到对应数据"); } - return Result.OK(appSceneCostCount); + return Result.OK(result); } /** diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostCount.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostCount.java index 60707fb..2a00bc3 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostCount.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostCount.java @@ -63,8 +63,8 @@ public class AppSceneCostCount implements Serializable { @ApiModelProperty(value = "状态") private Integer status; /**模型版本*/ - @Excel(name = "模型版本", width = 15) - @ApiModelProperty(value = "模型版本") + @Excel(name = "标准成本版本", width = 15) + @ApiModelProperty(value = "标准成本版本") private String costVersion; /**创建人*/ @ApiModelProperty(value = "创建人") diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java index b431044..99b2454 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java @@ -115,4 +115,10 @@ public class AppSceneCostResultValue implements Serializable { @Excel(name = "成本类别", width = 15) @ApiModelProperty(value = "成本类别") private String costType; + /** + * 成本明细 + */ + @Excel(name = "成本明细", width = 15) + @ApiModelProperty(value = "成本明细") + private String costDetail; } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/CostPartMissingInfo.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/CostPartMissingInfo.java index dfeb6f2..a167b45 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/CostPartMissingInfo.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/CostPartMissingInfo.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableLogic; +import lombok.Builder; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; @@ -25,6 +26,7 @@ import lombok.experimental.Accessors; * @Version: V1.0 */ @Data +@Builder @TableName("app_scene_cost_part_missing_info") @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/enums/FeeTypeEnum.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/enums/FeeTypeEnum.java index 2d22189..a1ad269 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/enums/FeeTypeEnum.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/enums/FeeTypeEnum.java @@ -9,24 +9,22 @@ package com.zzsmart.qomo.kn.cost.manage.enums; */ public enum FeeTypeEnum { - LaborCost("LaborCost", "人工成本"), - MaterialCost("MaterialCost", "物料成本"), - EquipmentFee("EquipmentFee", "设备费"), SupplyMaterialFee("SupplyMaterialFee", "辅料费"), DriverFee("DriverFee", "水电费"), OtherFee("OtherFee", "其他费用"), LogisticsFee("LogisticsFee", "物流费"); + LaborCost("LaborCost", "人工成本"), MaterialCost("MaterialCost", "物料成本"), EquipmentFee("EquipmentFee", "设备费"), SupplyMaterialFee("SupplyMaterialFee", "辅料费"), DriverFee("DriverFee", "水电费"), OtherFee("OtherFee", "其他费用"), LogisticsFee("LogisticsFee", "物流费"), StandardCost("StandardCost", "标准成本"); private final String code; - private final String text; + private final String name; - FeeTypeEnum(String code, String text) { + FeeTypeEnum(String code, String name) { this.code = code; - this.text = text; + this.name = name; } public String getCode() { return code; } - public String getText() { - return text; + public String getName() { + return name; } /** @@ -38,7 +36,7 @@ public enum FeeTypeEnum { public static String getTextByCode(String codeNo) { for (FeeTypeEnum value : FeeTypeEnum.values()) { if (value.getCode().equals(codeNo)) { - return value.getText(); + return value.name(); } } return codeNo.toString(); @@ -47,15 +45,15 @@ public enum FeeTypeEnum { /** * 根据text获取code * - * @param textStr + * @param name * @return */ - public static String getCodeByText(String textStr) { + public static String getCodeByName(String name) { for (FeeTypeEnum value : FeeTypeEnum.values()) { - if (value.getText().equals(textStr)) { - return value.getText(); + if (value.name().equals(name)) { + return value.name(); } } - return textStr; + return name; } } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java index d09caca..5c16008 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java @@ -220,7 +220,7 @@ public class StandardCostService { //单价乘以数量 BigDecimal totalCost = price.multiply(number); //2.2计算出人工成本并存储到成本结果数据表中 - AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build(); + AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).costType(feeType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } @@ -459,23 +459,74 @@ public class StandardCostService { String taskCode = flowTaskInfoVO.getTaskCode(); //获取流程id String flowInstanceId = flowTaskInfoVO.getFlowInstanceId(); - //1.查询出物料编号对应的下所有的BOM信息 - List list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, null, flowInstanceId); + String costType = FeeTypeEnum.StandardCost.getCode(); + //1.查询出根物料编号对应的下所有的BOM信息结果值 + List list = standardCostService.iAppSceneCostResultValueService.getAllResultValueByTopMaterialNo(topMaterialCode, flowInstanceId); //2.计算出所有的单个物料的本阶的标准成本(标准成本=物料成本+人工成本+制造费用) //按照物料编号进行分组 Map> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo)); for (String key : materialNoMap.keySet()) { List appSceneCostResultValues = materialNoMap.get(key); - //本阶成本 + //按照费用类别进行分组 + Map> costTypeMap = appSceneCostResultValues.stream().filter(s -> s.getCostType() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getCostType)); + //本阶标准成本 BigDecimal currentCost = new BigDecimal("0.0"); + //1.本阶物料成本 + BigDecimal materialCost = new BigDecimal("0.0"); + //2.本阶人工成本 + BigDecimal laborCost = new BigDecimal("0.0"); + //3.本阶制造费(设备费) + BigDecimal equipmentCost = new BigDecimal("0.0"); + //4.本阶制造费(辅料费用) + BigDecimal supplyMaterialCost = new BigDecimal("0.0"); + //5.本阶制造费(水电费、燃动费) + BigDecimal driveCost = new BigDecimal("0.0"); + //6.本阶制造费(其他制造费用) + BigDecimal otherCost = new BigDecimal("0.0"); + //7.本阶制造费(物流费) + BigDecimal logisticsCost = new BigDecimal("0.0"); + AppSceneCostResultValue currentMaterialCost = null; + //遍历所有费用类别计算本阶标准成本 for (int j = 0; j < appSceneCostResultValues.size(); j++) { + if (j == 0) { + currentMaterialCost = appSceneCostResultValues.get(0); + } AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j); String countValue = appSceneCostResultValue.getCountValue(); if (countValue != null) { currentCost = currentCost.add(new BigDecimal(countValue)); } } - AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(appSceneCostResultValues.get(0).getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(currentCost.toString()).build(); + //计算本阶各个费用类别费用 + for (String feeType : costTypeMap.keySet()) { + List appSceneCostResultValues1 = costTypeMap.get(feeType); + for (int m = 0; m < appSceneCostResultValues1.size(); m++) { + if (FeeTypeEnum.MaterialCost.getCode().equals(feeType)) { + materialCost = materialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } else if (FeeTypeEnum.LaborCost.getCode().equals(feeType)) { + laborCost = laborCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } else if (FeeTypeEnum.EquipmentFee.getCode().equals(feeType)) { + equipmentCost = equipmentCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } else if (FeeTypeEnum.SupplyMaterialFee.getCode().equals(feeType)) { + supplyMaterialCost = supplyMaterialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } else if (FeeTypeEnum.DriverFee.getCode().equals(feeType)) { + driveCost = driveCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) { + logisticsCost = logisticsCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } else if (FeeTypeEnum.OtherFee.getCode().equals(feeType)) { + otherCost = otherCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); + } + } + } + JSONObject costTypeDetail = new JSONObject(); + costTypeDetail.put(FeeTypeEnum.MaterialCost.getCode(), materialCost.toString()); + costTypeDetail.put(FeeTypeEnum.LaborCost.getCode(), laborCost.toString()); + costTypeDetail.put(FeeTypeEnum.EquipmentFee.getCode(), equipmentCost.toString()); + costTypeDetail.put(FeeTypeEnum.SupplyMaterialFee.getCode(), supplyMaterialCost.toString()); + costTypeDetail.put(FeeTypeEnum.DriverFee.getCode(), driveCost.toString()); + costTypeDetail.put(FeeTypeEnum.LogisticsFee.getCode(), logisticsCost.toString()); + costTypeDetail.put(FeeTypeEnum.OtherFee.getCode(), otherCost.toString()); + AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(currentMaterialCost.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(currentCost.toString()).costDetail(JSON.toJSONString(costTypeDetail)).costType(costType).build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } //3.计算出所有的单个物料的累计标准成本 @@ -494,10 +545,13 @@ public class StandardCostService { * @param flowInstanceId */ private static void totalCountCost(List standardCostList, String topMaterialCode, String taskType, String taskCode, String flowInstanceId) { + //父类对应的子节点(除了最上层节点) Map> parentMaterialNoMap = standardCostList.stream().filter(appSceneCostResultValue -> appSceneCostResultValue.getParentMarterialNo() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getParentMarterialNo)); for (int i = 0; i < standardCostList.size(); i++) { + //当前节点及其对应的本阶成本 AppSceneCostResultValue oldAppSceneCostResultValue = standardCostList.get(i); BigDecimal totalCost = new BigDecimal(oldAppSceneCostResultValue.getCountValue()); + //循环计算出当前节点的累计成本 totalCost = loopCount(oldAppSceneCostResultValue, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost); oldAppSceneCostResultValue.setTotalValue(totalCost.toString()); standardCostService.iAppSceneCostResultValueService.updateById(oldAppSceneCostResultValue); @@ -519,6 +573,7 @@ public class StandardCostService { private static BigDecimal loopCount(AppSceneCostResultValue appSceneCostResultValue, Map> parentMaterialNoMap, String topMaterialCode, String taskType, String taskCode, String flowInstanceId, BigDecimal totalCost) { String marterialNo = appSceneCostResultValue.getMarterialNo(); if (parentMaterialNoMap.containsKey(marterialNo)) { + //获取当前节点的子节点并遍历 List appSceneCostResultValues = parentMaterialNoMap.get(marterialNo); for (int j = 0; j < appSceneCostResultValues.size(); j++) { AppSceneCostResultValue appSceneCostResultValue1 = appSceneCostResultValues.get(j); @@ -526,7 +581,11 @@ public class StandardCostService { if (countValue != null) { totalCost = totalCost.add(new BigDecimal(countValue)); } - loopCount(appSceneCostResultValue1, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost); + //判断当前子节点是否还有子节点 + if (parentMaterialNoMap.containsKey(appSceneCostResultValue1.getMarterialNo())) { + //如果还有子节点则继续递归 + loopCount(appSceneCostResultValue1, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost); + } } } return totalCost; diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostCountService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostCountService.java index 865605e..c986fef 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostCountService.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostCountService.java @@ -2,6 +2,9 @@ package com.zzsmart.qomo.kn.cost.manage.service; import com.baomidou.mybatisplus.extension.service.IService; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount; +import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO; + +import java.util.List; /** * @Description: app_scene_cost_count @@ -15,7 +18,7 @@ public interface IAppSceneCostCountService extends IService { * @param id * @return */ - AppSceneCostCount queryMissingComponentById(String id); + List queryMissingComponentById(String id); /** * 重新计算 diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostResultValueService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostResultValueService.java index b2474e3..131a529 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostResultValueService.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostResultValueService.java @@ -8,14 +8,24 @@ import java.util.List; /** * @Description: app_scene_cost_result_value * @Author: jeecg-boot - * @Date: 2024-07-22 + * @Date: 2024-07-22 * @Version: V1.0 */ public interface IAppSceneCostResultValueService extends IService { /** * 根据顶级物料编码查询满足条件的结果值 + * * @param topMaterialCode * @return */ - List getResultValueByTopMaterialNo(String topMaterialCode,String taskType,String flowInstanceId); + List getResultValueByTopMaterialNo(String topMaterialCode, String taskType, String flowInstanceId); + + /** + * 查询根物料的某次成本计算流程下的所有结果值 + * + * @param topMaterialCode + * @param flowInstanceId + * @return + */ + List getAllResultValueByTopMaterialNo(String topMaterialCode, String flowInstanceId); } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java index b05627b..4da1102 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java @@ -1,16 +1,22 @@ package com.zzsmart.qomo.kn.cost.manage.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount; +import com.zzsmart.qomo.kn.cost.manage.entity.CostPartMissingInfo; import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardVersion; import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper; +import com.zzsmart.qomo.kn.cost.manage.mapper.CostPartMissingInfoMapper; import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService; import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardVersionService; +import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO; import com.zzsmart.qomo.service.IDataFlowInstanceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @Description: app_scene_cost_count @@ -24,6 +30,8 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl queryMissingComponentById(String id) { + List list = new ArrayList<>(); + if (id != null) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("costStandardId", id); + List costPartMissingInfos = costPartMissingInfoMapper.selectList(queryWrapper); + if (costPartMissingInfos != null && costPartMissingInfos.size() > 0) { + for (int i = 0; i < costPartMissingInfos.size(); i++) { + CostPartMissingInfo costPartMissingInfo = costPartMissingInfos.get(i); + if (costPartMissingInfo.getMissingInfo() != null) { + String[] split = costPartMissingInfo.getMissingInfo().split(";"); + for (int j = 0; j < split.length; j++) { + MissingComponentVO temp = MissingComponentVO.builder().materialNumber(costPartMissingInfo.getMaterialNumber()).missingInfo(split[j]).versionNumber(costPartMissingInfo.getVersionNumber()).build(); + list.add(temp); + } + } + } + } + } + return list; } /** @@ -77,11 +103,14 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl result = new ArrayList<>(); QueryWrapper queryWrapper = new QueryWrapper<>(); if (topMaterialCode != null && !topMaterialCode.equals("") && lastTaskType != null && !lastTaskType.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) { + //查询某个流程节点(即执行任务)的结果值 queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("task_type", lastTaskType).eq("flow_instance_id", flowInstanceId); result = appSceneCostResultValueMapper.selectList(queryWrapper); - } else if (topMaterialCode != null && !topMaterialCode.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) { + } else if (topMaterialCode != null && !topMaterialCode.equals("") && flowInstanceId != null && !flowInstanceId.equals("") && lastTaskType == null) { + //查询BOM物料所有的树节点信息 + queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("flow_instance_id", flowInstanceId).isNull("task_type"); + result = appSceneCostResultValueMapper.selectList(queryWrapper); + } + return result; + } + + /** + * 查询根物料的某次成本计算流程下的所有结果值 + * + * @param topMaterialCode + * @param flowInstanceId + * @return + */ + @Override + public List getAllResultValueByTopMaterialNo(String topMaterialCode, String flowInstanceId) { + List result = new ArrayList<>(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (topMaterialCode != null && !topMaterialCode.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) { + //查询某个流程节点(即执行任务)的结果值 queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("flow_instance_id", flowInstanceId); result = appSceneCostResultValueMapper.selectList(queryWrapper); } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/MissingComponentVO.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/MissingComponentVO.java new file mode 100644 index 0000000..c874e3f --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/MissingComponentVO.java @@ -0,0 +1,30 @@ +package com.zzsmart.qomo.kn.cost.manage.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MissingComponentVO { + /** + * 物料编号 + */ + + private String materialNumber; + + /** + * 版本号 + */ + + private String versionNumber; + /** + * 缺失信息 + */ + + private String missingInfo; + +}