Browse Source

新增费用分类统计的计算逻辑

wangqiong 1 year ago
parent
commit
b070f6b55b

+ 2
- 3
qomo-kn-cost-manage-start/src/main/resources/application-dev.yml View File

282
     #webapp文件路径
282
     #webapp文件路径
283
     webapp: /opt/webapp
283
     webapp: /opt/webapp
284
   shiro:
284
   shiro:
285
-#    excludeUrls: /api/**,/api/internalService/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo,/sys/sysDepart/**,/taskSocket/**,/flowSocket/**,/dataCheck/**
286
-#    excludeUrls: /api/internalService/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo,/sys/sysDepart/**,/taskSocket/**,/flowSocket/**,/dataCheck/**
287
-    excludeUrls: /**/**,/**/**/**
285
+    excludeUrls: /api/internalService/**,/test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**,/api/getUserInfo,/sys/sysDepart/**,/taskSocket/**,/flowSocket/**,/dataCheck/**
286
+#    excludeUrls: /**/**,/**/**/**
288
 
287
 
289
   #阿里云oss存储和大鱼短信秘钥配置
288
   #阿里云oss存储和大鱼短信秘钥配置
290
   oss:
289
   oss:

+ 7
- 8
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java View File

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
6
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
7
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
7
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
8
+import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
8
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiOperation;
10
 import lombok.extern.slf4j.Slf4j;
11
 import lombok.extern.slf4j.Slf4j;
20
 import javax.servlet.http.HttpServletRequest;
21
 import javax.servlet.http.HttpServletRequest;
21
 import javax.servlet.http.HttpServletResponse;
22
 import javax.servlet.http.HttpServletResponse;
22
 import java.util.Arrays;
23
 import java.util.Arrays;
24
+import java.util.List;
23
 
25
 
24
 /**
26
 /**
25
  * @Description: app_scene_cost_count
27
  * @Description: app_scene_cost_count
47
     //@AutoLog(value = "app_scene_cost_count-分页列表查询")
49
     //@AutoLog(value = "app_scene_cost_count-分页列表查询")
48
     @ApiOperation(value = "标准成本计算-分页列表查询", notes = "标准成本计算-分页列表查询")
50
     @ApiOperation(value = "标准成本计算-分页列表查询", notes = "标准成本计算-分页列表查询")
49
     @GetMapping(value = "/list")
51
     @GetMapping(value = "/list")
50
-    public Result<IPage<AppSceneCostCount>> queryPageList(AppSceneCostCount appSceneCostCount,
51
-                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
52
-                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
53
-                                                          HttpServletRequest req) {
52
+    public Result<IPage<AppSceneCostCount>> queryPageList(AppSceneCostCount appSceneCostCount, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
54
         QueryWrapper<AppSceneCostCount> queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostCount, req.getParameterMap());
53
         QueryWrapper<AppSceneCostCount> queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostCount, req.getParameterMap());
55
         Page<AppSceneCostCount> page = new Page<AppSceneCostCount>(pageNo, pageSize);
54
         Page<AppSceneCostCount> page = new Page<AppSceneCostCount>(pageNo, pageSize);
56
         IPage<AppSceneCostCount> pageList = appSceneCostCountService.page(page, queryWrapper);
55
         IPage<AppSceneCostCount> pageList = appSceneCostCountService.page(page, queryWrapper);
129
     //@AutoLog(value = "app_scene_cost_count-通过id查询")
128
     //@AutoLog(value = "app_scene_cost_count-通过id查询")
130
     @ApiOperation(value = "标准成本计算-查看关键缺失部件", notes = "标准成本计算-查看关键缺失部件")
129
     @ApiOperation(value = "标准成本计算-查看关键缺失部件", notes = "标准成本计算-查看关键缺失部件")
131
     @GetMapping(value = "/queryMissingComponentById")
130
     @GetMapping(value = "/queryMissingComponentById")
132
-    public Result<AppSceneCostCount> queryMissingComponentById(@RequestParam(name = "id", required = true) String id) {
133
-        AppSceneCostCount appSceneCostCount = appSceneCostCountService.queryMissingComponentById(id);
134
-        if (appSceneCostCount == null) {
131
+    public Result<List<MissingComponentVO>> queryMissingComponentById(@RequestParam(name = "id", required = true) String id) {
132
+        List<MissingComponentVO> result = appSceneCostCountService.queryMissingComponentById(id);
133
+        if (result == null) {
135
             return Result.error("未找到对应数据");
134
             return Result.error("未找到对应数据");
136
         }
135
         }
137
-        return Result.OK(appSceneCostCount);
136
+        return Result.OK(result);
138
     }
137
     }
139
 
138
 
140
     /**
139
     /**

+ 2
- 2
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostCount.java View File

63
     @ApiModelProperty(value = "状态")
63
     @ApiModelProperty(value = "状态")
64
     private Integer status;
64
     private Integer status;
65
 	/**模型版本*/
65
 	/**模型版本*/
66
-	@Excel(name = "模型版本", width = 15)
67
-    @ApiModelProperty(value = "模型版本")
66
+	@Excel(name = "标准成本版本", width = 15)
67
+    @ApiModelProperty(value = "标准成本版本")
68
     private String costVersion;
68
     private String costVersion;
69
 	/**创建人*/
69
 	/**创建人*/
70
     @ApiModelProperty(value = "创建人")
70
     @ApiModelProperty(value = "创建人")

+ 6
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java View File

115
     @Excel(name = "成本类别", width = 15)
115
     @Excel(name = "成本类别", width = 15)
116
     @ApiModelProperty(value = "成本类别")
116
     @ApiModelProperty(value = "成本类别")
117
     private String costType;
117
     private String costType;
118
+    /**
119
+     * 成本明细
120
+     */
121
+    @Excel(name = "成本明细", width = 15)
122
+    @ApiModelProperty(value = "成本明细")
123
+    private String costDetail;
118
 }
124
 }

+ 2
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/CostPartMissingInfo.java View File

8
 import com.baomidou.mybatisplus.annotation.TableId;
8
 import com.baomidou.mybatisplus.annotation.TableId;
9
 import com.baomidou.mybatisplus.annotation.TableName;
9
 import com.baomidou.mybatisplus.annotation.TableName;
10
 import com.baomidou.mybatisplus.annotation.TableLogic;
10
 import com.baomidou.mybatisplus.annotation.TableLogic;
11
+import lombok.Builder;
11
 import lombok.Data;
12
 import lombok.Data;
12
 import com.fasterxml.jackson.annotation.JsonFormat;
13
 import com.fasterxml.jackson.annotation.JsonFormat;
13
 import org.springframework.format.annotation.DateTimeFormat;
14
 import org.springframework.format.annotation.DateTimeFormat;
25
  * @Version: V1.0
26
  * @Version: V1.0
26
  */
27
  */
27
 @Data
28
 @Data
29
+@Builder
28
 @TableName("app_scene_cost_part_missing_info")
30
 @TableName("app_scene_cost_part_missing_info")
29
 @Accessors(chain = true)
31
 @Accessors(chain = true)
30
 @EqualsAndHashCode(callSuper = false)
32
 @EqualsAndHashCode(callSuper = false)

+ 12
- 14
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/enums/FeeTypeEnum.java View File

9
  */
9
  */
10
 public enum FeeTypeEnum {
10
 public enum FeeTypeEnum {
11
 
11
 
12
-    LaborCost("LaborCost", "人工成本"),
13
-    MaterialCost("MaterialCost", "物料成本"),
14
-    EquipmentFee("EquipmentFee", "设备费"), SupplyMaterialFee("SupplyMaterialFee", "辅料费"), DriverFee("DriverFee", "水电费"), OtherFee("OtherFee", "其他费用"), LogisticsFee("LogisticsFee", "物流费");
12
+    LaborCost("LaborCost", "人工成本"), MaterialCost("MaterialCost", "物料成本"), EquipmentFee("EquipmentFee", "设备费"), SupplyMaterialFee("SupplyMaterialFee", "辅料费"), DriverFee("DriverFee", "水电费"), OtherFee("OtherFee", "其他费用"), LogisticsFee("LogisticsFee", "物流费"), StandardCost("StandardCost", "标准成本");
15
 
13
 
16
     private final String code;
14
     private final String code;
17
-    private final String text;
15
+    private final String name;
18
 
16
 
19
-    FeeTypeEnum(String code, String text) {
17
+    FeeTypeEnum(String code, String name) {
20
         this.code = code;
18
         this.code = code;
21
-        this.text = text;
19
+        this.name = name;
22
     }
20
     }
23
 
21
 
24
     public String getCode() {
22
     public String getCode() {
25
         return code;
23
         return code;
26
     }
24
     }
27
 
25
 
28
-    public String getText() {
29
-        return text;
26
+    public String getName() {
27
+        return name;
30
     }
28
     }
31
 
29
 
32
     /**
30
     /**
38
     public static String getTextByCode(String codeNo) {
36
     public static String getTextByCode(String codeNo) {
39
         for (FeeTypeEnum value : FeeTypeEnum.values()) {
37
         for (FeeTypeEnum value : FeeTypeEnum.values()) {
40
             if (value.getCode().equals(codeNo)) {
38
             if (value.getCode().equals(codeNo)) {
41
-                return value.getText();
39
+                return value.name();
42
             }
40
             }
43
         }
41
         }
44
         return codeNo.toString();
42
         return codeNo.toString();
47
     /**
45
     /**
48
      * 根据text获取code
46
      * 根据text获取code
49
      *
47
      *
50
-     * @param textStr
48
+     * @param name
51
      * @return
49
      * @return
52
      */
50
      */
53
-    public static String getCodeByText(String textStr) {
51
+    public static String getCodeByName(String name) {
54
         for (FeeTypeEnum value : FeeTypeEnum.values()) {
52
         for (FeeTypeEnum value : FeeTypeEnum.values()) {
55
-            if (value.getText().equals(textStr)) {
56
-                return value.getText();
53
+            if (value.name().equals(name)) {
54
+                return value.name();
57
             }
55
             }
58
         }
56
         }
59
-        return textStr;
57
+        return name;
60
     }
58
     }
61
 }
59
 }

+ 65
- 6
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java View File

220
                     //单价乘以数量
220
                     //单价乘以数量
221
                     BigDecimal totalCost = price.multiply(number);
221
                     BigDecimal totalCost = price.multiply(number);
222
                     //2.2计算出人工成本并存储到成本结果数据表中
222
                     //2.2计算出人工成本并存储到成本结果数据表中
223
-                    AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
223
+                    AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).costType(feeType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
224
                     standardCostService.iAppSceneCostResultValueService.save(resultValue);
224
                     standardCostService.iAppSceneCostResultValueService.save(resultValue);
225
                 }
225
                 }
226
             }
226
             }
459
         String taskCode = flowTaskInfoVO.getTaskCode();
459
         String taskCode = flowTaskInfoVO.getTaskCode();
460
         //获取流程id
460
         //获取流程id
461
         String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
461
         String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
462
-        //1.查询出物料编号对应的下所有的BOM信息
463
-        List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, null, flowInstanceId);
462
+        String costType = FeeTypeEnum.StandardCost.getCode();
463
+        //1.查询出根物料编号对应的下所有的BOM信息结果值
464
+        List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getAllResultValueByTopMaterialNo(topMaterialCode, flowInstanceId);
464
         //2.计算出所有的单个物料的本阶的标准成本(标准成本=物料成本+人工成本+制造费用)
465
         //2.计算出所有的单个物料的本阶的标准成本(标准成本=物料成本+人工成本+制造费用)
465
         //按照物料编号进行分组
466
         //按照物料编号进行分组
466
         Map<String, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo));
467
         Map<String, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo));
467
         for (String key : materialNoMap.keySet()) {
468
         for (String key : materialNoMap.keySet()) {
468
             List<AppSceneCostResultValue> appSceneCostResultValues = materialNoMap.get(key);
469
             List<AppSceneCostResultValue> appSceneCostResultValues = materialNoMap.get(key);
469
-            //本阶成本
470
+            //按照费用类别进行分组
471
+            Map<String, List<AppSceneCostResultValue>> costTypeMap = appSceneCostResultValues.stream().filter(s -> s.getCostType() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getCostType));
472
+            //本阶标准成本
470
             BigDecimal currentCost = new BigDecimal("0.0");
473
             BigDecimal currentCost = new BigDecimal("0.0");
474
+            //1.本阶物料成本
475
+            BigDecimal materialCost = new BigDecimal("0.0");
476
+            //2.本阶人工成本
477
+            BigDecimal laborCost = new BigDecimal("0.0");
478
+            //3.本阶制造费(设备费)
479
+            BigDecimal equipmentCost = new BigDecimal("0.0");
480
+            //4.本阶制造费(辅料费用)
481
+            BigDecimal supplyMaterialCost = new BigDecimal("0.0");
482
+            //5.本阶制造费(水电费、燃动费)
483
+            BigDecimal driveCost = new BigDecimal("0.0");
484
+            //6.本阶制造费(其他制造费用)
485
+            BigDecimal otherCost = new BigDecimal("0.0");
486
+            //7.本阶制造费(物流费)
487
+            BigDecimal logisticsCost = new BigDecimal("0.0");
488
+            AppSceneCostResultValue currentMaterialCost = null;
489
+            //遍历所有费用类别计算本阶标准成本
471
             for (int j = 0; j < appSceneCostResultValues.size(); j++) {
490
             for (int j = 0; j < appSceneCostResultValues.size(); j++) {
491
+                if (j == 0) {
492
+                    currentMaterialCost = appSceneCostResultValues.get(0);
493
+                }
472
                 AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j);
494
                 AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j);
473
                 String countValue = appSceneCostResultValue.getCountValue();
495
                 String countValue = appSceneCostResultValue.getCountValue();
474
                 if (countValue != null) {
496
                 if (countValue != null) {
475
                     currentCost = currentCost.add(new BigDecimal(countValue));
497
                     currentCost = currentCost.add(new BigDecimal(countValue));
476
                 }
498
                 }
477
             }
499
             }
478
-            AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(appSceneCostResultValues.get(0).getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(currentCost.toString()).build();
500
+            //计算本阶各个费用类别费用
501
+            for (String feeType : costTypeMap.keySet()) {
502
+                List<AppSceneCostResultValue> appSceneCostResultValues1 = costTypeMap.get(feeType);
503
+                for (int m = 0; m < appSceneCostResultValues1.size(); m++) {
504
+                    if (FeeTypeEnum.MaterialCost.getCode().equals(feeType)) {
505
+                        materialCost = materialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
506
+                    } else if (FeeTypeEnum.LaborCost.getCode().equals(feeType)) {
507
+                        laborCost = laborCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
508
+                    } else if (FeeTypeEnum.EquipmentFee.getCode().equals(feeType)) {
509
+                        equipmentCost = equipmentCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
510
+                    } else if (FeeTypeEnum.SupplyMaterialFee.getCode().equals(feeType)) {
511
+                        supplyMaterialCost = supplyMaterialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
512
+                    } else if (FeeTypeEnum.DriverFee.getCode().equals(feeType)) {
513
+                        driveCost = driveCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
514
+                    } else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) {
515
+                        logisticsCost = logisticsCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
516
+                    } else if (FeeTypeEnum.OtherFee.getCode().equals(feeType)) {
517
+                        otherCost = otherCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
518
+                    }
519
+                }
520
+            }
521
+            JSONObject costTypeDetail = new JSONObject();
522
+            costTypeDetail.put(FeeTypeEnum.MaterialCost.getCode(), materialCost.toString());
523
+            costTypeDetail.put(FeeTypeEnum.LaborCost.getCode(), laborCost.toString());
524
+            costTypeDetail.put(FeeTypeEnum.EquipmentFee.getCode(), equipmentCost.toString());
525
+            costTypeDetail.put(FeeTypeEnum.SupplyMaterialFee.getCode(), supplyMaterialCost.toString());
526
+            costTypeDetail.put(FeeTypeEnum.DriverFee.getCode(), driveCost.toString());
527
+            costTypeDetail.put(FeeTypeEnum.LogisticsFee.getCode(), logisticsCost.toString());
528
+            costTypeDetail.put(FeeTypeEnum.OtherFee.getCode(), otherCost.toString());
529
+            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();
479
             standardCostService.iAppSceneCostResultValueService.save(resultValue);
530
             standardCostService.iAppSceneCostResultValueService.save(resultValue);
480
         }
531
         }
481
         //3.计算出所有的单个物料的累计标准成本
532
         //3.计算出所有的单个物料的累计标准成本
494
      * @param flowInstanceId
545
      * @param flowInstanceId
495
      */
546
      */
496
     private static void totalCountCost(List<AppSceneCostResultValue> standardCostList, String topMaterialCode, String taskType, String taskCode, String flowInstanceId) {
547
     private static void totalCountCost(List<AppSceneCostResultValue> standardCostList, String topMaterialCode, String taskType, String taskCode, String flowInstanceId) {
548
+        //父类对应的子节点(除了最上层节点)
497
         Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap = standardCostList.stream().filter(appSceneCostResultValue -> appSceneCostResultValue.getParentMarterialNo() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getParentMarterialNo));
549
         Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap = standardCostList.stream().filter(appSceneCostResultValue -> appSceneCostResultValue.getParentMarterialNo() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getParentMarterialNo));
498
         for (int i = 0; i < standardCostList.size(); i++) {
550
         for (int i = 0; i < standardCostList.size(); i++) {
551
+            //当前节点及其对应的本阶成本
499
             AppSceneCostResultValue oldAppSceneCostResultValue = standardCostList.get(i);
552
             AppSceneCostResultValue oldAppSceneCostResultValue = standardCostList.get(i);
500
             BigDecimal totalCost = new BigDecimal(oldAppSceneCostResultValue.getCountValue());
553
             BigDecimal totalCost = new BigDecimal(oldAppSceneCostResultValue.getCountValue());
554
+            //循环计算出当前节点的累计成本
501
             totalCost = loopCount(oldAppSceneCostResultValue, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
555
             totalCost = loopCount(oldAppSceneCostResultValue, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
502
             oldAppSceneCostResultValue.setTotalValue(totalCost.toString());
556
             oldAppSceneCostResultValue.setTotalValue(totalCost.toString());
503
             standardCostService.iAppSceneCostResultValueService.updateById(oldAppSceneCostResultValue);
557
             standardCostService.iAppSceneCostResultValueService.updateById(oldAppSceneCostResultValue);
519
     private static BigDecimal loopCount(AppSceneCostResultValue appSceneCostResultValue, Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap, String topMaterialCode, String taskType, String taskCode, String flowInstanceId, BigDecimal totalCost) {
573
     private static BigDecimal loopCount(AppSceneCostResultValue appSceneCostResultValue, Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap, String topMaterialCode, String taskType, String taskCode, String flowInstanceId, BigDecimal totalCost) {
520
         String marterialNo = appSceneCostResultValue.getMarterialNo();
574
         String marterialNo = appSceneCostResultValue.getMarterialNo();
521
         if (parentMaterialNoMap.containsKey(marterialNo)) {
575
         if (parentMaterialNoMap.containsKey(marterialNo)) {
576
+            //获取当前节点的子节点并遍历
522
             List<AppSceneCostResultValue> appSceneCostResultValues = parentMaterialNoMap.get(marterialNo);
577
             List<AppSceneCostResultValue> appSceneCostResultValues = parentMaterialNoMap.get(marterialNo);
523
             for (int j = 0; j < appSceneCostResultValues.size(); j++) {
578
             for (int j = 0; j < appSceneCostResultValues.size(); j++) {
524
                 AppSceneCostResultValue appSceneCostResultValue1 = appSceneCostResultValues.get(j);
579
                 AppSceneCostResultValue appSceneCostResultValue1 = appSceneCostResultValues.get(j);
526
                 if (countValue != null) {
581
                 if (countValue != null) {
527
                     totalCost = totalCost.add(new BigDecimal(countValue));
582
                     totalCost = totalCost.add(new BigDecimal(countValue));
528
                 }
583
                 }
529
-                loopCount(appSceneCostResultValue1, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
584
+                //判断当前子节点是否还有子节点
585
+                if (parentMaterialNoMap.containsKey(appSceneCostResultValue1.getMarterialNo())) {
586
+                    //如果还有子节点则继续递归
587
+                    loopCount(appSceneCostResultValue1, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
588
+                }
530
             }
589
             }
531
         }
590
         }
532
         return totalCost;
591
         return totalCost;

+ 4
- 1
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostCountService.java View File

2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
4
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
5
+import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
6
+
7
+import java.util.List;
5
 
8
 
6
 /**
9
 /**
7
  * @Description: app_scene_cost_count
10
  * @Description: app_scene_cost_count
15
      * @param id
18
      * @param id
16
      * @return
19
      * @return
17
      */
20
      */
18
-    AppSceneCostCount queryMissingComponentById(String id);
21
+    List<MissingComponentVO> queryMissingComponentById(String id);
19
 
22
 
20
     /**
23
     /**
21
      * 重新计算
24
      * 重新计算

+ 12
- 2
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostResultValueService.java View File

8
 /**
8
 /**
9
  * @Description: app_scene_cost_result_value
9
  * @Description: app_scene_cost_result_value
10
  * @Author: jeecg-boot
10
  * @Author: jeecg-boot
11
- * @Date:   2024-07-22
11
+ * @Date: 2024-07-22
12
  * @Version: V1.0
12
  * @Version: V1.0
13
  */
13
  */
14
 public interface IAppSceneCostResultValueService extends IService<AppSceneCostResultValue> {
14
 public interface IAppSceneCostResultValueService extends IService<AppSceneCostResultValue> {
15
     /**
15
     /**
16
      * 根据顶级物料编码查询满足条件的结果值
16
      * 根据顶级物料编码查询满足条件的结果值
17
+     *
17
      * @param topMaterialCode
18
      * @param topMaterialCode
18
      * @return
19
      * @return
19
      */
20
      */
20
-    List<AppSceneCostResultValue> getResultValueByTopMaterialNo(String topMaterialCode,String taskType,String flowInstanceId);
21
+    List<AppSceneCostResultValue> getResultValueByTopMaterialNo(String topMaterialCode, String taskType, String flowInstanceId);
22
+
23
+    /**
24
+     * 查询根物料的某次成本计算流程下的所有结果值
25
+     *
26
+     * @param topMaterialCode
27
+     * @param flowInstanceId
28
+     * @return
29
+     */
30
+    List<AppSceneCostResultValue> getAllResultValueByTopMaterialNo(String topMaterialCode, String flowInstanceId);
21
 }
31
 }

+ 32
- 3
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java View File

1
 package com.zzsmart.qomo.kn.cost.manage.service.impl;
1
 package com.zzsmart.qomo.kn.cost.manage.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
5
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
6
+import com.zzsmart.qomo.kn.cost.manage.entity.CostPartMissingInfo;
5
 import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardVersion;
7
 import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardVersion;
6
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
8
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
9
+import com.zzsmart.qomo.kn.cost.manage.mapper.CostPartMissingInfoMapper;
7
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
10
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
8
 import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardVersionService;
11
 import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardVersionService;
12
+import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
9
 import com.zzsmart.qomo.service.IDataFlowInstanceService;
13
 import com.zzsmart.qomo.service.IDataFlowInstanceService;
10
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.stereotype.Service;
15
 import org.springframework.stereotype.Service;
12
 
16
 
17
+import java.util.ArrayList;
13
 import java.util.Date;
18
 import java.util.Date;
19
+import java.util.List;
14
 
20
 
15
 /**
21
 /**
16
  * @Description: app_scene_cost_count
22
  * @Description: app_scene_cost_count
24
     private ICostStandardVersionService costStandardVersionService;
30
     private ICostStandardVersionService costStandardVersionService;
25
     @Autowired
31
     @Autowired
26
     private IDataFlowInstanceService flowInstanceService;
32
     private IDataFlowInstanceService flowInstanceService;
33
+    @Autowired
34
+    private CostPartMissingInfoMapper costPartMissingInfoMapper;
27
 
35
 
28
     /**
36
     /**
29
      * 查看关键缺失部件
37
      * 查看关键缺失部件
32
      * @return
40
      * @return
33
      */
41
      */
34
     @Override
42
     @Override
35
-    public AppSceneCostCount queryMissingComponentById(String id) {
36
-        return null;
43
+    public List<MissingComponentVO> queryMissingComponentById(String id) {
44
+        List<MissingComponentVO> list = new ArrayList<>();
45
+        if (id != null) {
46
+            QueryWrapper<CostPartMissingInfo> queryWrapper = new QueryWrapper<>();
47
+            queryWrapper.eq("costStandardId", id);
48
+            List<CostPartMissingInfo> costPartMissingInfos = costPartMissingInfoMapper.selectList(queryWrapper);
49
+            if (costPartMissingInfos != null && costPartMissingInfos.size() > 0) {
50
+                for (int i = 0; i < costPartMissingInfos.size(); i++) {
51
+                    CostPartMissingInfo costPartMissingInfo = costPartMissingInfos.get(i);
52
+                    if (costPartMissingInfo.getMissingInfo() != null) {
53
+                        String[] split = costPartMissingInfo.getMissingInfo().split(";");
54
+                        for (int j = 0; j < split.length; j++) {
55
+                            MissingComponentVO temp = MissingComponentVO.builder().materialNumber(costPartMissingInfo.getMaterialNumber()).missingInfo(split[j]).versionNumber(costPartMissingInfo.getVersionNumber()).build();
56
+                            list.add(temp);
57
+                        }
58
+                    }
59
+                }
60
+            }
61
+        }
62
+        return list;
37
     }
63
     }
38
 
64
 
39
     /**
65
     /**
77
         boolean save = costStandardVersionService.save(costStandardVersion);
103
         boolean save = costStandardVersionService.save(costStandardVersion);
78
         //2.新增标准成本计算任务,并立即执行标准成本计算
104
         //2.新增标准成本计算任务,并立即执行标准成本计算
79
         if (save) {
105
         if (save) {
80
-            AppSceneCostCount appSceneCostCount1 = AppSceneCostCount.builder().materialNo(appSceneCostCount.getMaterialNo()).drawingNo(appSceneCostCount.getDrawingNo()).stage(appSceneCostCount.getStage()).flowDefinitionId(appSceneCostCount.getFlowDefinitionId()).year(appSceneCostCount.getYear()).costVersion(appSceneCostCount.getCostVersion()).status(0).createTime(new Date()).build();
106
+            AppSceneCostCount appSceneCostCount1 = AppSceneCostCount.builder().materialNo(appSceneCostCount.getMaterialNo()).drawingNo(appSceneCostCount.getDrawingNo()).stage(appSceneCostCount.getStage()).flowDefinitionId(appSceneCostCount.getFlowDefinitionId()).year(appSceneCostCount.getYear()).costVersion(costStandardVersion.getVersionNumber()).status(0).createTime(new Date()).build();
81
             boolean flag = save(appSceneCostCount1);
107
             boolean flag = save(appSceneCostCount1);
82
             if (flag) {
108
             if (flag) {
83
                 //执行标准成本计算
109
                 //执行标准成本计算
84
                 executeStandardCost(appSceneCostCount1.getId(), appSceneCostCount1.getFlowDefinitionId());
110
                 executeStandardCost(appSceneCostCount1.getId(), appSceneCostCount1.getFlowDefinitionId());
111
+                //TODO 新增部件缺失信息记录
112
+                CostPartMissingInfo costPartMissingInfo = CostPartMissingInfo.builder().costStandardId(appSceneCostCount1.getId().toString()).materialNumber(appSceneCostCount1.getMaterialNo()).versionNumber(appSceneCostCount1.getCostVersion()).missingInfo("电源线;绝缘层涂料").build();
113
+                costPartMissingInfoMapper.insert(costPartMissingInfo);
85
             }
114
             }
86
         }
115
         }
87
     }
116
     }

+ 22
- 1
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostResultValueServiceImpl.java View File

37
         List<AppSceneCostResultValue> result = new ArrayList<>();
37
         List<AppSceneCostResultValue> result = new ArrayList<>();
38
         QueryWrapper<AppSceneCostResultValue> queryWrapper = new QueryWrapper<>();
38
         QueryWrapper<AppSceneCostResultValue> queryWrapper = new QueryWrapper<>();
39
         if (topMaterialCode != null && !topMaterialCode.equals("") && lastTaskType != null && !lastTaskType.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) {
39
         if (topMaterialCode != null && !topMaterialCode.equals("") && lastTaskType != null && !lastTaskType.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) {
40
+            //查询某个流程节点(即执行任务)的结果值
40
             queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("task_type", lastTaskType).eq("flow_instance_id", flowInstanceId);
41
             queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("task_type", lastTaskType).eq("flow_instance_id", flowInstanceId);
41
             result = appSceneCostResultValueMapper.selectList(queryWrapper);
42
             result = appSceneCostResultValueMapper.selectList(queryWrapper);
42
-        } else if (topMaterialCode != null && !topMaterialCode.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) {
43
+        } else if (topMaterialCode != null && !topMaterialCode.equals("") && flowInstanceId != null && !flowInstanceId.equals("") && lastTaskType == null) {
44
+            //查询BOM物料所有的树节点信息
45
+            queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("flow_instance_id", flowInstanceId).isNull("task_type");
46
+            result = appSceneCostResultValueMapper.selectList(queryWrapper);
47
+        }
48
+        return result;
49
+    }
50
+
51
+    /**
52
+     * 查询根物料的某次成本计算流程下的所有结果值
53
+     *
54
+     * @param topMaterialCode
55
+     * @param flowInstanceId
56
+     * @return
57
+     */
58
+    @Override
59
+    public List<AppSceneCostResultValue> getAllResultValueByTopMaterialNo(String topMaterialCode, String flowInstanceId) {
60
+        List<AppSceneCostResultValue> result = new ArrayList<>();
61
+        QueryWrapper<AppSceneCostResultValue> queryWrapper = new QueryWrapper<>();
62
+        if (topMaterialCode != null && !topMaterialCode.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) {
63
+            //查询某个流程节点(即执行任务)的结果值
43
             queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("flow_instance_id", flowInstanceId);
64
             queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("flow_instance_id", flowInstanceId);
44
             result = appSceneCostResultValueMapper.selectList(queryWrapper);
65
             result = appSceneCostResultValueMapper.selectList(queryWrapper);
45
         }
66
         }

+ 30
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/MissingComponentVO.java View File

1
+package com.zzsmart.qomo.kn.cost.manage.vo;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Builder;
5
+import lombok.Data;
6
+import lombok.NoArgsConstructor;
7
+
8
+@Data
9
+@Builder
10
+@NoArgsConstructor
11
+@AllArgsConstructor
12
+public class MissingComponentVO {
13
+    /**
14
+     * 物料编号
15
+     */
16
+
17
+    private String materialNumber;
18
+
19
+    /**
20
+     * 版本号
21
+     */
22
+
23
+    private String versionNumber;
24
+    /**
25
+     * 缺失信息
26
+     */
27
+
28
+    private String missingInfo;
29
+
30
+}