Преглед на файлове

优化成本计算逻辑进行中

bgy преди 1 година
родител
ревизия
1eb6e5915e

+ 2
- 10
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java Целия файл

110
             //1.查询出所有满足物料编号的物料(BOM物料)
110
             //1.查询出所有满足物料编号的物料(BOM物料)
111
             String sql = flowTaskInfoVO.getSqlString();
111
             String sql = flowTaskInfoVO.getSqlString();
112
             log.info("传递过来的SQL语句:" + sql);
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
         } catch (Exception e) {
114
         } catch (Exception e) {
123
             throw new RuntimeException(e);
115
             throw new RuntimeException(e);
124
         }
116
         }
478
             //获取最上层的物料号
470
             //获取最上层的物料号
479
             String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
471
             String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
480
             //获取任务类型
472
             //获取任务类型
481
-            String taskType = parameters.getTaksType();
473
+            String taskType = parameters.getTaskType();
482
             //获取任务代码
474
             //获取任务代码
483
             String taskCode = flowTaskInfoVO.getTaskCode();
475
             String taskCode = flowTaskInfoVO.getTaskCode();
484
             //获取流程id
476
             //获取流程id

+ 55
- 14
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java Целия файл

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.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.JSONObject;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
9
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
7
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPartMissingInfo;
10
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPartMissingInfo;
8
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardVersion;
11
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardVersion;
9
 import com.zzsmart.qomo.kn.cost.manage.enums.CostCountStatusEnum;
12
 import com.zzsmart.qomo.kn.cost.manage.enums.CostCountStatusEnum;
10
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
13
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
11
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPartMissingInfoMapper;
14
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPartMissingInfoMapper;
15
+import com.zzsmart.qomo.kn.cost.manage.plugin.StandardCostService;
12
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
16
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostCountService;
13
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostStandardVersionService;
17
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostStandardVersionService;
14
 import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
18
 import com.zzsmart.qomo.kn.cost.manage.vo.MissingComponentVO;
15
-import com.zzsmart.qomo.service.IDataFlowDefinitionService;
16
 import com.zzsmart.qomo.service.IDataFlowInstanceService;
19
 import com.zzsmart.qomo.service.IDataFlowInstanceService;
20
+import com.zzsmart.qomo.service.IFlowInstanceParameterService;
17
 import org.springframework.beans.factory.annotation.Autowired;
21
 import org.springframework.beans.factory.annotation.Autowired;
18
 import org.springframework.stereotype.Service;
22
 import org.springframework.stereotype.Service;
19
 
23
 
34
     @Autowired
38
     @Autowired
35
     private IDataFlowInstanceService flowInstanceService;
39
     private IDataFlowInstanceService flowInstanceService;
36
     @Autowired
40
     @Autowired
41
+    private IFlowInstanceParameterService flowInstanceParameterService;
42
+    @Autowired
37
     private AppSceneCostPartMissingInfoMapper costPartMissingInfoMapper;
43
     private AppSceneCostPartMissingInfoMapper costPartMissingInfoMapper;
44
+    @Autowired
45
+    StandardCostService standardCostService;
38
 
46
 
39
     /**
47
     /**
40
      * 查看关键缺失部件
48
      * 查看关键缺失部件
77
             AppSceneCostCount appSceneCostCount = getById(id);
85
             AppSceneCostCount appSceneCostCount = getById(id);
78
             if (appSceneCostCount != null) {
86
             if (appSceneCostCount != null) {
79
                 //执行标准成本计算
87
                 //执行标准成本计算
80
-                executeStandardCost(id, appSceneCostCount.getFlowDefinitionId());
88
+                executeStandardCost(id, appSceneCostCount.getFlowDefinitionId(), appSceneCostCount.getMaterialNo());
81
             }
89
             }
82
         }
90
         }
83
         return null;
91
         return null;
89
      * @param id
97
      * @param id
90
      * @param flowDefinitionId
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
         if (save) {
130
         if (save) {
109
             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();
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
             boolean flag = save(appSceneCostCount1);
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
 }