Просмотр исходного кода

优化成本计算逻辑进行中

bgy 1 год назад
Родитель
Сommit
1eb6e5915e

+ 2
- 10
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java Просмотреть файл

@@ -110,15 +110,7 @@ public class StandardCostService {
110 110
             //1.查询出所有满足物料编号的物料(BOM物料)
111 111
             String sql = flowTaskInfoVO.getSqlString();
112 112
             log.info("传递过来的SQL语句:" + sql);
113
-            //TODO 查询最顶部的BOM物料编号下所有的物料并进行层级排序
114
-            List<AppSceneCostMaterialBom> list = standardCostService.costMaterialBomService.queryAllBomInfoBytopMaterialCode(topMaterialCode);
115
-            log.info("Full EmptyTask list: {}", list);
116
-            //2.把查询的结果存放在临时表里(表命名规则:前缀_流程id_组件code)
117
-            for (int i = 0; list != null && i < list.size(); i++) {
118
-                AppSceneCostMaterialBom material = list.get(i);
119
-                AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(material.getMaterialCode()).parentMarterialNo(material.getParentMaterialCode()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).num(material.getNumber()).build();
120
-                standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
121
-            }
113
+
122 114
         } catch (Exception e) {
123 115
             throw new RuntimeException(e);
124 116
         }
@@ -478,7 +470,7 @@ public class StandardCostService {
478 470
             //获取最上层的物料号
479 471
             String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
480 472
             //获取任务类型
481
-            String taskType = parameters.getTaksType();
473
+            String taskType = parameters.getTaskType();
482 474
             //获取任务代码
483 475
             String taskCode = flowTaskInfoVO.getTaskCode();
484 476
             //获取流程id

+ 55
- 14
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java Просмотреть файл

@@ -1,19 +1,23 @@
1 1
 package com.zzsmart.qomo.kn.cost.manage.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.JSONObject;
3 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
-import com.zzsmart.qomo.dao.entity.FlowDefinition;
7
+import com.zzsmart.qomo.dao.entity.FlowInstance;
8
+import com.zzsmart.qomo.dao.entity.FlowInstanceParameter;
6 9
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
7 10
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPartMissingInfo;
8 11
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardVersion;
9 12
 import com.zzsmart.qomo.kn.cost.manage.enums.CostCountStatusEnum;
10 13
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
11 14
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPartMissingInfoMapper;
15
+import com.zzsmart.qomo.kn.cost.manage.plugin.StandardCostService;
12 16
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
13 17
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostStandardVersionService;
14 18
 import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
15
-import com.zzsmart.qomo.service.IDataFlowDefinitionService;
16 19
 import com.zzsmart.qomo.service.IDataFlowInstanceService;
20
+import com.zzsmart.qomo.service.IFlowInstanceParameterService;
17 21
 import org.springframework.beans.factory.annotation.Autowired;
18 22
 import org.springframework.stereotype.Service;
19 23
 
@@ -34,7 +38,11 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
34 38
     @Autowired
35 39
     private IDataFlowInstanceService flowInstanceService;
36 40
     @Autowired
41
+    private IFlowInstanceParameterService flowInstanceParameterService;
42
+    @Autowired
37 43
     private AppSceneCostPartMissingInfoMapper costPartMissingInfoMapper;
44
+    @Autowired
45
+    StandardCostService standardCostService;
38 46
 
39 47
     /**
40 48
      * 查看关键缺失部件
@@ -77,7 +85,7 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
77 85
             AppSceneCostCount appSceneCostCount = getById(id);
78 86
             if (appSceneCostCount != null) {
79 87
                 //执行标准成本计算
80
-                executeStandardCost(id, appSceneCostCount.getFlowDefinitionId());
88
+                executeStandardCost(id, appSceneCostCount.getFlowDefinitionId(), appSceneCostCount.getMaterialNo());
81 89
             }
82 90
         }
83 91
         return null;
@@ -89,9 +97,23 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
89 97
      * @param id
90 98
      * @param flowDefinitionId
91 99
      */
92
-    private void executeStandardCost(Integer id, Integer flowDefinitionId) {
93
-        //TODO 执行标准成本计算(参数传递)
94
-        flowInstanceService.execute(flowDefinitionId, null, null);
100
+    private void executeStandardCost(Integer id, Integer flowDefinitionId, String meterialNo) {
101
+        boolean isSuccess = false;
102
+        JSONObject parameter = new JSONObject();
103
+        parameter.put("materialNo", meterialNo);
104
+        String parameters = JSON.toJSONString(parameter);
105
+        //执行标准成本计算(参数传递)
106
+        FlowInstance flowInstance = ((IDataFlowInstanceService) flowInstanceService).execute(flowDefinitionId, (String) null, (String) null);
107
+        if (flowInstance != null) {
108
+            FlowInstanceParameter flowInstanceParameter = new FlowInstanceParameter();
109
+            flowInstanceParameter.setFlowInstanceId(flowInstance.getId());
110
+            flowInstanceParameter.setParameters(parameters);
111
+            boolean save = flowInstanceParameterService.save(flowInstanceParameter);
112
+            if (save) {
113
+                isSuccess = true;
114
+            }
115
+        }
116
+//        flowInstanceService.execute(flowDefinitionId, null, null);
95 117
     }
96 118
 
97 119
     /**
@@ -108,15 +130,34 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
108 130
         if (save) {
109 131
             AppSceneCostCount appSceneCostCount1 = AppSceneCostCount.builder().materialNo(appSceneCostCount.getMaterialNo()).drawingNo(appSceneCostCount.getDrawingNo()).stage(appSceneCostCount.getStage()).flowDefinitionId(appSceneCostCount.getFlowDefinitionId()).year(appSceneCostCount.getYear()).costVersion(costStandardVersion.getVersion()).status(CostCountStatusEnum.Executing.getValue()).createTime(new Date()).build();
110 132
             boolean flag = save(appSceneCostCount1);
111
-            if (flag) {
112
-                //发送更新成本计算状态的队列消息(队列名:updateCostCountStatus)
133
+            //方案一:模型组件运行
134
+//            if (flag) {
135
+//                //发送更新成本计算状态的队列消息(队列名:updateCostCountStatus)
136
+//
137
+//                //执行标准成本计算
138
+//                executeStandardCost(appSceneCostCount1.getId(), appSceneCostCount1.getFlowDefinitionId(), appSceneCostCount.getMaterialNo());
139
+//                //TODO 新增部件缺失信息记录
140
+//                AppSceneCostPartMissingInfo costPartMissingInfo = AppSceneCostPartMissingInfo.builder().costStandardId(appSceneCostCount1.getId().toString()).materialNumber(appSceneCostCount1.getMaterialNo()).versionNumber(appSceneCostCount1.getCostVersion()).missingInfo("电源线;绝缘层涂料").build();
141
+//                costPartMissingInfoMapper.insert(costPartMissingInfo);
142
+//            }
113 143
 
114
-                //执行标准成本计算
115
-                executeStandardCost(appSceneCostCount1.getId(), appSceneCostCount1.getFlowDefinitionId());
116
-                //TODO 新增部件缺失信息记录
117
-                AppSceneCostPartMissingInfo costPartMissingInfo = AppSceneCostPartMissingInfo.builder().costStandardId(appSceneCostCount1.getId().toString()).materialNumber(appSceneCostCount1.getMaterialNo()).versionNumber(appSceneCostCount1.getCostVersion()).missingInfo("电源线;绝缘层涂料").build();
118
-                costPartMissingInfoMapper.insert(costPartMissingInfo);
119
-            }
144
+            // 方案二:直接执行标准成本计算
145
+            countStandardCost(appSceneCostCount1);
120 146
         }
121 147
     }
148
+
149
+    /**
150
+     * 执行标准成本计算
151
+     *
152
+     * @param appSceneCostCount1
153
+     */
154
+    private void countStandardCost(AppSceneCostCount appSceneCostCount1) {
155
+        //0.获取物料下所有的子物料
156
+
157
+        //1.物料成本计算
158
+
159
+        //2.人工成本计算
160
+        //3.制造计算(各种费用)
161
+        //4.标准成本本计算
162
+    }
122 163
 }