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,9 +282,8 @@ jeecg:
282 282
     #webapp文件路径
283 283
     webapp: /opt/webapp
284 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 288
   #阿里云oss存储和大鱼短信秘钥配置
290 289
   oss:

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
7 7
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
8
+import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiOperation;
10 11
 import lombok.extern.slf4j.Slf4j;
@@ -20,6 +21,7 @@ import org.springframework.web.servlet.ModelAndView;
20 21
 import javax.servlet.http.HttpServletRequest;
21 22
 import javax.servlet.http.HttpServletResponse;
22 23
 import java.util.Arrays;
24
+import java.util.List;
23 25
 
24 26
 /**
25 27
  * @Description: app_scene_cost_count
@@ -47,10 +49,7 @@ public class AppSceneCostCountController extends JeecgController<AppSceneCostCou
47 49
     //@AutoLog(value = "app_scene_cost_count-分页列表查询")
48 50
     @ApiOperation(value = "标准成本计算-分页列表查询", notes = "标准成本计算-分页列表查询")
49 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 53
         QueryWrapper<AppSceneCostCount> queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostCount, req.getParameterMap());
55 54
         Page<AppSceneCostCount> page = new Page<AppSceneCostCount>(pageNo, pageSize);
56 55
         IPage<AppSceneCostCount> pageList = appSceneCostCountService.page(page, queryWrapper);
@@ -129,12 +128,12 @@ public class AppSceneCostCountController extends JeecgController<AppSceneCostCou
129 128
     //@AutoLog(value = "app_scene_cost_count-通过id查询")
130 129
     @ApiOperation(value = "标准成本计算-查看关键缺失部件", notes = "标准成本计算-查看关键缺失部件")
131 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 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,8 +63,8 @@ public class AppSceneCostCount implements Serializable {
63 63
     @ApiModelProperty(value = "状态")
64 64
     private Integer status;
65 65
 	/**模型版本*/
66
-	@Excel(name = "模型版本", width = 15)
67
-    @ApiModelProperty(value = "模型版本")
66
+	@Excel(name = "标准成本版本", width = 15)
67
+    @ApiModelProperty(value = "标准成本版本")
68 68
     private String costVersion;
69 69
 	/**创建人*/
70 70
     @ApiModelProperty(value = "创建人")

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

@@ -115,4 +115,10 @@ public class AppSceneCostResultValue implements Serializable {
115 115
     @Excel(name = "成本类别", width = 15)
116 116
     @ApiModelProperty(value = "成本类别")
117 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,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
8 8
 import com.baomidou.mybatisplus.annotation.TableId;
9 9
 import com.baomidou.mybatisplus.annotation.TableName;
10 10
 import com.baomidou.mybatisplus.annotation.TableLogic;
11
+import lombok.Builder;
11 12
 import lombok.Data;
12 13
 import com.fasterxml.jackson.annotation.JsonFormat;
13 14
 import org.springframework.format.annotation.DateTimeFormat;
@@ -25,6 +26,7 @@ import lombok.experimental.Accessors;
25 26
  * @Version: V1.0
26 27
  */
27 28
 @Data
29
+@Builder
28 30
 @TableName("app_scene_cost_part_missing_info")
29 31
 @Accessors(chain = true)
30 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,24 +9,22 @@ package com.zzsmart.qomo.kn.cost.manage.enums;
9 9
  */
10 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 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 18
         this.code = code;
21
-        this.text = text;
19
+        this.name = name;
22 20
     }
23 21
 
24 22
     public String getCode() {
25 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,7 +36,7 @@ public enum FeeTypeEnum {
38 36
     public static String getTextByCode(String codeNo) {
39 37
         for (FeeTypeEnum value : FeeTypeEnum.values()) {
40 38
             if (value.getCode().equals(codeNo)) {
41
-                return value.getText();
39
+                return value.name();
42 40
             }
43 41
         }
44 42
         return codeNo.toString();
@@ -47,15 +45,15 @@ public enum FeeTypeEnum {
47 45
     /**
48 46
      * 根据text获取code
49 47
      *
50
-     * @param textStr
48
+     * @param name
51 49
      * @return
52 50
      */
53
-    public static String getCodeByText(String textStr) {
51
+    public static String getCodeByName(String name) {
54 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,7 +220,7 @@ public class StandardCostService {
220 220
                     //单价乘以数量
221 221
                     BigDecimal totalCost = price.multiply(number);
222 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 224
                     standardCostService.iAppSceneCostResultValueService.save(resultValue);
225 225
                 }
226 226
             }
@@ -459,23 +459,74 @@ public class StandardCostService {
459 459
         String taskCode = flowTaskInfoVO.getTaskCode();
460 460
         //获取流程id
461 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 465
         //2.计算出所有的单个物料的本阶的标准成本(标准成本=物料成本+人工成本+制造费用)
465 466
         //按照物料编号进行分组
466 467
         Map<String, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo));
467 468
         for (String key : materialNoMap.keySet()) {
468 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 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 490
             for (int j = 0; j < appSceneCostResultValues.size(); j++) {
491
+                if (j == 0) {
492
+                    currentMaterialCost = appSceneCostResultValues.get(0);
493
+                }
472 494
                 AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j);
473 495
                 String countValue = appSceneCostResultValue.getCountValue();
474 496
                 if (countValue != null) {
475 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 530
             standardCostService.iAppSceneCostResultValueService.save(resultValue);
480 531
         }
481 532
         //3.计算出所有的单个物料的累计标准成本
@@ -494,10 +545,13 @@ public class StandardCostService {
494 545
      * @param flowInstanceId
495 546
      */
496 547
     private static void totalCountCost(List<AppSceneCostResultValue> standardCostList, String topMaterialCode, String taskType, String taskCode, String flowInstanceId) {
548
+        //父类对应的子节点(除了最上层节点)
497 549
         Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap = standardCostList.stream().filter(appSceneCostResultValue -> appSceneCostResultValue.getParentMarterialNo() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getParentMarterialNo));
498 550
         for (int i = 0; i < standardCostList.size(); i++) {
551
+            //当前节点及其对应的本阶成本
499 552
             AppSceneCostResultValue oldAppSceneCostResultValue = standardCostList.get(i);
500 553
             BigDecimal totalCost = new BigDecimal(oldAppSceneCostResultValue.getCountValue());
554
+            //循环计算出当前节点的累计成本
501 555
             totalCost = loopCount(oldAppSceneCostResultValue, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
502 556
             oldAppSceneCostResultValue.setTotalValue(totalCost.toString());
503 557
             standardCostService.iAppSceneCostResultValueService.updateById(oldAppSceneCostResultValue);
@@ -519,6 +573,7 @@ public class StandardCostService {
519 573
     private static BigDecimal loopCount(AppSceneCostResultValue appSceneCostResultValue, Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap, String topMaterialCode, String taskType, String taskCode, String flowInstanceId, BigDecimal totalCost) {
520 574
         String marterialNo = appSceneCostResultValue.getMarterialNo();
521 575
         if (parentMaterialNoMap.containsKey(marterialNo)) {
576
+            //获取当前节点的子节点并遍历
522 577
             List<AppSceneCostResultValue> appSceneCostResultValues = parentMaterialNoMap.get(marterialNo);
523 578
             for (int j = 0; j < appSceneCostResultValues.size(); j++) {
524 579
                 AppSceneCostResultValue appSceneCostResultValue1 = appSceneCostResultValues.get(j);
@@ -526,7 +581,11 @@ public class StandardCostService {
526 581
                 if (countValue != null) {
527 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 591
         return totalCost;

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

@@ -2,6 +2,9 @@ package com.zzsmart.qomo.kn.cost.manage.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 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 10
  * @Description: app_scene_cost_count
@@ -15,7 +18,7 @@ public interface IAppSceneCostCountService extends IService<AppSceneCostCount> {
15 18
      * @param id
16 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,14 +8,24 @@ import java.util.List;
8 8
 /**
9 9
  * @Description: app_scene_cost_result_value
10 10
  * @Author: jeecg-boot
11
- * @Date:   2024-07-22
11
+ * @Date: 2024-07-22
12 12
  * @Version: V1.0
13 13
  */
14 14
 public interface IAppSceneCostResultValueService extends IService<AppSceneCostResultValue> {
15 15
     /**
16 16
      * 根据顶级物料编码查询满足条件的结果值
17
+     *
17 18
      * @param topMaterialCode
18 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,16 +1,22 @@
1 1
 package com.zzsmart.qomo.kn.cost.manage.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 5
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
6
+import com.zzsmart.qomo.kn.cost.manage.entity.CostPartMissingInfo;
5 7
 import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardVersion;
6 8
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
9
+import com.zzsmart.qomo.kn.cost.manage.mapper.CostPartMissingInfoMapper;
7 10
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
8 11
 import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardVersionService;
12
+import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
9 13
 import com.zzsmart.qomo.service.IDataFlowInstanceService;
10 14
 import org.springframework.beans.factory.annotation.Autowired;
11 15
 import org.springframework.stereotype.Service;
12 16
 
17
+import java.util.ArrayList;
13 18
 import java.util.Date;
19
+import java.util.List;
14 20
 
15 21
 /**
16 22
  * @Description: app_scene_cost_count
@@ -24,6 +30,8 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
24 30
     private ICostStandardVersionService costStandardVersionService;
25 31
     @Autowired
26 32
     private IDataFlowInstanceService flowInstanceService;
33
+    @Autowired
34
+    private CostPartMissingInfoMapper costPartMissingInfoMapper;
27 35
 
28 36
     /**
29 37
      * 查看关键缺失部件
@@ -32,8 +40,26 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
32 40
      * @return
33 41
      */
34 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,11 +103,14 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
77 103
         boolean save = costStandardVersionService.save(costStandardVersion);
78 104
         //2.新增标准成本计算任务,并立即执行标准成本计算
79 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 107
             boolean flag = save(appSceneCostCount1);
82 108
             if (flag) {
83 109
                 //执行标准成本计算
84 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,9 +37,30 @@ public class AppSceneCostResultValueServiceImpl extends ServiceImpl<AppSceneCost
37 37
         List<AppSceneCostResultValue> result = new ArrayList<>();
38 38
         QueryWrapper<AppSceneCostResultValue> queryWrapper = new QueryWrapper<>();
39 39
         if (topMaterialCode != null && !topMaterialCode.equals("") && lastTaskType != null && !lastTaskType.equals("") && flowInstanceId != null && !flowInstanceId.equals("")) {
40
+            //查询某个流程节点(即执行任务)的结果值
40 41
             queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("task_type", lastTaskType).eq("flow_instance_id", flowInstanceId);
41 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 64
             queryWrapper.eq("belong_top_material_no", topMaterialCode).eq("flow_instance_id", flowInstanceId);
44 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

@@ -0,0 +1,30 @@
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
+}