|
|
|
|
|
|
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
|
}
|