|
|
|
|
|
|
2
|
|
2
|
|
|
3
|
import com.alibaba.fastjson.JSON;
|
3
|
import com.alibaba.fastjson.JSON;
|
|
4
|
import com.alibaba.fastjson.JSONObject;
|
4
|
import com.alibaba.fastjson.JSONObject;
|
|
5
|
-import com.zzsmart.qomo.dao.entity.FlowDefinition;
|
|
|
|
6
|
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostResultValue;
|
5
|
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostResultValue;
|
|
7
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostMaterialBom;
|
6
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostMaterialBom;
|
|
8
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostMaterialProcessHours;
|
7
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostMaterialProcessHours;
|
|
9
|
import com.zzsmart.qomo.kn.cost.manage.entity.HourRate;
|
8
|
import com.zzsmart.qomo.kn.cost.manage.entity.HourRate;
|
|
10
|
import com.zzsmart.qomo.kn.cost.manage.enums.FeeTypeEnum;
|
9
|
import com.zzsmart.qomo.kn.cost.manage.enums.FeeTypeEnum;
|
|
11
|
import com.zzsmart.qomo.kn.cost.manage.mapper.CostMaterialBomMapper;
|
10
|
import com.zzsmart.qomo.kn.cost.manage.mapper.CostMaterialBomMapper;
|
|
12
|
-import com.zzsmart.qomo.kn.cost.manage.service.CostMaterialProcessHoursService;
|
|
|
|
13
|
-import com.zzsmart.qomo.kn.cost.manage.service.CostPurchasePriceService;
|
|
|
|
14
|
-import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostResultValueService;
|
|
|
|
15
|
-import com.zzsmart.qomo.kn.cost.manage.service.IHourRateService;
|
|
|
|
|
|
11
|
+import com.zzsmart.qomo.kn.cost.manage.service.*;
|
|
16
|
import com.zzsmart.qomo.kn.cost.manage.vo.FlowTaskInfoVO;
|
12
|
import com.zzsmart.qomo.kn.cost.manage.vo.FlowTaskInfoVO;
|
|
17
|
import com.zzsmart.qomo.plugin.task.api.TaskExecutionContext;
|
13
|
import com.zzsmart.qomo.plugin.task.api.TaskExecutionContext;
|
|
18
|
import lombok.extern.slf4j.Slf4j;
|
14
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
34
|
*/
|
30
|
*/
|
|
35
|
@Autowired
|
31
|
@Autowired
|
|
36
|
CostMaterialBomMapper costMaterialBomMapper;
|
32
|
CostMaterialBomMapper costMaterialBomMapper;
|
|
|
|
33
|
+ @Autowired
|
|
|
|
34
|
+ CostMaterialBomService costMaterialBomService;
|
|
37
|
|
35
|
|
|
38
|
/**
|
36
|
/**
|
|
39
|
* 小时费率
|
37
|
* 小时费率
|
|
|
|
|
|
|
61
|
public void init() {
|
59
|
public void init() {
|
|
62
|
standardCostService = this;
|
60
|
standardCostService = this;
|
|
63
|
standardCostService.costMaterialBomMapper = this.costMaterialBomMapper;
|
61
|
standardCostService.costMaterialBomMapper = this.costMaterialBomMapper;
|
|
|
|
62
|
+ standardCostService.costMaterialBomService = this.costMaterialBomService;
|
|
64
|
standardCostService.costPurchasePriceService = this.costPurchasePriceService;
|
63
|
standardCostService.costPurchasePriceService = this.costPurchasePriceService;
|
|
65
|
standardCostService.iHourRateService = this.iHourRateService;
|
64
|
standardCostService.iHourRateService = this.iHourRateService;
|
|
66
|
standardCostService.costMaterialProcessHoursService = this.costMaterialProcessHoursService;
|
65
|
standardCostService.costMaterialProcessHoursService = this.costMaterialProcessHoursService;
|
|
|
|
|
|
|
85
|
String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
|
84
|
String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
|
|
86
|
//1.查询出所有满足物料编号的物料(BOM物料)
|
85
|
//1.查询出所有满足物料编号的物料(BOM物料)
|
|
87
|
String sql = flowTaskInfoVO.getSqlString();
|
86
|
String sql = flowTaskInfoVO.getSqlString();
|
|
88
|
- List<CostMaterialBom> list = standardCostService.costMaterialBomMapper.customSelect(sql);
|
|
|
|
|
|
87
|
+ log.info("传递过来的SQL语句:" + sql);
|
|
|
|
88
|
+ List<CostMaterialBom> list = standardCostService.costMaterialBomService.queryAllBomInfoBytopMaterialCode(topMaterialCode);
|
|
89
|
log.info("Full EmptyTask list: {}", list);
|
89
|
log.info("Full EmptyTask list: {}", list);
|
|
90
|
//2.把查询的结果存放在临时表里(表命名规则:前缀_流程id_组件code)
|
90
|
//2.把查询的结果存放在临时表里(表命名规则:前缀_流程id_组件code)
|
|
91
|
for (int i = 0; list != null && i < list.size(); i++) {
|
91
|
for (int i = 0; list != null && i < list.size(); i++) {
|
|
92
|
CostMaterialBom material = list.get(i);
|
92
|
CostMaterialBom material = list.get(i);
|
|
93
|
- AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(material.getMaterialCode()).parentMarterialNo(material.getParentMaterialCode()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).build();
|
|
|
|
|
|
93
|
+ AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(material.getMaterialCode()).parentMarterialNo(material.getParentMaterialCode()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).num(material.getNumber()).build();
|
|
94
|
standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
|
94
|
standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
|
|
95
|
}
|
95
|
}
|
|
96
|
} catch (Exception e) {
|
96
|
} catch (Exception e) {
|
|
|
|
|
|
|
113
|
String s1 = split[i];
|
113
|
String s1 = split[i];
|
|
114
|
if (s1.contains("taskType")) {
|
114
|
if (s1.contains("taskType")) {
|
|
115
|
String[] split1 = s1.split("=");
|
115
|
String[] split1 = s1.split("=");
|
|
116
|
- flowTaskInfoVO.setTaskType(split1[1]);
|
|
|
|
|
|
116
|
+ if (split1[1].contains("\"")) {
|
|
|
|
117
|
+ split1[1] = split1[1].replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
118
|
+ flowTaskInfoVO.setTaskType(split1[1]);
|
|
|
|
119
|
+ } else {
|
|
|
|
120
|
+ flowTaskInfoVO.setTaskType(split1[1]);
|
|
|
|
121
|
+ }
|
|
117
|
} else if (s1.contains("taskCode")) {
|
122
|
} else if (s1.contains("taskCode")) {
|
|
118
|
String[] split1 = s1.split(":");
|
123
|
String[] split1 = s1.split(":");
|
|
119
|
- flowTaskInfoVO.setTaskCode(split1[1]);
|
|
|
|
|
|
124
|
+ if (split1[1].contains("\"")) {
|
|
|
|
125
|
+ split1[1] = split1[1].replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
126
|
+ flowTaskInfoVO.setTaskCode(split1[1]);
|
|
|
|
127
|
+ } else {
|
|
|
|
128
|
+ flowTaskInfoVO.setTaskCode(split1[1]);
|
|
|
|
129
|
+ }
|
|
120
|
} else if (s1.contains("flowInstanceId")) {
|
130
|
} else if (s1.contains("flowInstanceId")) {
|
|
121
|
String[] split1 = s1.split("=");
|
131
|
String[] split1 = s1.split("=");
|
|
122
|
- flowTaskInfoVO.setFlowInstanceId(split1[1]);
|
|
|
|
|
|
132
|
+ if (split1[1].contains("\"")) {
|
|
|
|
133
|
+ split1[1] = split1[1].replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
134
|
+ flowTaskInfoVO.setFlowInstanceId(split1[1]);
|
|
|
|
135
|
+ } else {
|
|
|
|
136
|
+ flowTaskInfoVO.setFlowInstanceId(split1[1]);
|
|
|
|
137
|
+ }
|
|
123
|
} else if (s1.contains("sqlString")) {
|
138
|
} else if (s1.contains("sqlString")) {
|
|
124
|
String[] split1 = s1.split(":");
|
139
|
String[] split1 = s1.split(":");
|
|
125
|
- flowTaskInfoVO.setSqlString(split1[1]);
|
|
|
|
|
|
140
|
+ if (split1[1].contains("\"")) {
|
|
|
|
141
|
+ split1[1] = split1[1].replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
142
|
+ flowTaskInfoVO.setSqlString(split1[1]);
|
|
|
|
143
|
+ } else {
|
|
|
|
144
|
+ flowTaskInfoVO.setSqlString(split1[1]);
|
|
|
|
145
|
+ }
|
|
|
|
146
|
+ } else if (s.contains("feeType") && s1.contains("feeType")) {
|
|
|
|
147
|
+ String[] split1 = s1.split(":");
|
|
|
|
148
|
+ if (split1[1].contains("\"")) {
|
|
|
|
149
|
+ split1[1] = split1[1].replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
150
|
+ flowTaskInfoVO.setFeeType(split1[1]);
|
|
|
|
151
|
+ } else {
|
|
|
|
152
|
+ flowTaskInfoVO.setFeeType(split1[1]);
|
|
|
|
153
|
+ }
|
|
126
|
}
|
154
|
}
|
|
127
|
}
|
155
|
}
|
|
128
|
}
|
156
|
}
|
|
|
|
|
|
|
135
|
* @param flowTaskInfoVO
|
163
|
* @param flowTaskInfoVO
|
|
136
|
*/
|
164
|
*/
|
|
137
|
private static FlowTaskInfoVO queryFlowDefinitionByFlowInstanceId(FlowTaskInfoVO flowTaskInfoVO) {
|
165
|
private static FlowTaskInfoVO queryFlowDefinitionByFlowInstanceId(FlowTaskInfoVO flowTaskInfoVO) {
|
|
138
|
- String sql = "SELECT A.id,A.`code`,A.`name`,A.version,A.release_state,A.model_json from qomo_flow_definition as A LEFT JOIN qomo_flow_instance AS B ON A.`code`=B.flow_definition_code WHERE B.id=" + flowTaskInfoVO.getFlowInstanceId() + " limit 1";
|
|
|
|
139
|
- JSONObject jsonObject = standardCostService.costMaterialBomMapper.customSelectOne(sql);
|
|
|
|
140
|
- FlowDefinition flowDefinition = JSON.toJavaObject(jsonObject, FlowDefinition.class);
|
|
|
|
141
|
- if (flowDefinition != null) {
|
|
|
|
142
|
- log.info("flowDefinition: {}", flowDefinition);
|
|
|
|
143
|
- String modelJson = flowDefinition.getModelJson();
|
|
|
|
144
|
- JSONObject jsonObject1 = JSON.parseObject(modelJson);
|
|
|
|
145
|
- if (jsonObject1 != null) {
|
|
|
|
|
|
166
|
+ String sql = "SELECT A.model_json from qomo_flow_definition as A LEFT JOIN qomo_flow_instance AS B ON A.`code`=B.flow_definition_code WHERE B.id=" + flowTaskInfoVO.getFlowInstanceId() + " limit 1";
|
|
|
|
167
|
+ String blob = standardCostService.costMaterialBomMapper.customSelectBlobModelJson(sql);
|
|
|
|
168
|
+ if (blob != null) {
|
|
|
|
169
|
+ if (blob != null && blob.contains("topMaterialCode")) {
|
|
|
|
170
|
+ JSONObject jsonObject1 = JSON.parseObject(blob);
|
|
146
|
String topMaterialCode = jsonObject1.getString("topMaterialCode");
|
171
|
String topMaterialCode = jsonObject1.getString("topMaterialCode");
|
|
147
|
flowTaskInfoVO.setTopMaterialCode(topMaterialCode);
|
172
|
flowTaskInfoVO.setTopMaterialCode(topMaterialCode);
|
|
148
|
}
|
173
|
}
|
|
|
|
|
|
|
165
|
String taskCode = flowTaskInfoVO.getTaskCode();
|
190
|
String taskCode = flowTaskInfoVO.getTaskCode();
|
|
166
|
//获取流程id
|
191
|
//获取流程id
|
|
167
|
String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
|
192
|
String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
|
|
|
|
193
|
+ //成本类型
|
|
|
|
194
|
+ String feeType = FeeTypeEnum.MaterialCost.getCode();
|
|
168
|
//1.查询出物料编号对应的下所有的BOM信息
|
195
|
//1.查询出物料编号对应的下所有的BOM信息
|
|
169
|
List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", flowInstanceId);
|
196
|
List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", flowInstanceId);
|
|
170
|
//2.计算出所有的单个物料的物料成本
|
197
|
//2.计算出所有的单个物料的物料成本
|
|
|
|
|
|
|
179
|
AppSceneCostResultValue appSceneCostResultValue = list.get(i);
|
206
|
AppSceneCostResultValue appSceneCostResultValue = list.get(i);
|
|
180
|
String marterialNo = appSceneCostResultValue.getMarterialNo();
|
207
|
String marterialNo = appSceneCostResultValue.getMarterialNo();
|
|
181
|
Integer num = appSceneCostResultValue.getNum();
|
208
|
Integer num = appSceneCostResultValue.getNum();
|
|
182
|
- if (marterialNo != null) {
|
|
|
|
|
|
209
|
+ if (marterialNo != null && num != null) {
|
|
183
|
BigDecimal price = purchasePriceMap.get(marterialNo);
|
210
|
BigDecimal price = purchasePriceMap.get(marterialNo);
|
|
184
|
BigDecimal number = new BigDecimal(num.toString());
|
211
|
BigDecimal number = new BigDecimal(num.toString());
|
|
185
|
//单价乘以数量
|
212
|
//单价乘以数量
|
|
|
|
|
|
|
209
|
String taskCode = flowTaskInfoVO.getTaskCode();
|
236
|
String taskCode = flowTaskInfoVO.getTaskCode();
|
|
210
|
//获取流程id
|
237
|
//获取流程id
|
|
211
|
String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
|
238
|
String flowInstanceId = flowTaskInfoVO.getFlowInstanceId();
|
|
212
|
- String sql = flowTaskInfoVO.getSqlString();
|
|
|
|
|
|
239
|
+ //成本类型
|
|
|
|
240
|
+ String feeType = FeeTypeEnum.LaborCost.getCode();
|
|
|
|
241
|
+ String sql1 = flowTaskInfoVO.getSqlString();
|
|
|
|
242
|
+ log.info("sql1:" + sql1);
|
|
|
|
243
|
+ String sql = sql1.replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
244
|
+ log.info("sql:" + sql);
|
|
213
|
JSONObject jsonObject = standardCostService.costMaterialBomMapper.customSelectOne(sql);
|
245
|
JSONObject jsonObject = standardCostService.costMaterialBomMapper.customSelectOne(sql);
|
|
214
|
BigDecimal hourRate = new BigDecimal("0");
|
246
|
BigDecimal hourRate = new BigDecimal("0");
|
|
215
|
if (jsonObject != null) {
|
247
|
if (jsonObject != null) {
|
|
|
|
|
|
|
241
|
}
|
273
|
}
|
|
242
|
}
|
274
|
}
|
|
243
|
//2.2计算出人工成本并存储到成本结果数据表中
|
275
|
//2.2计算出人工成本并存储到成本结果数据表中
|
|
244
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
|
|
|
|
|
|
276
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").costType(feeType).build();
|
|
245
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
277
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
246
|
}
|
278
|
}
|
|
247
|
}
|
279
|
}
|
|
|
|
|
|
|
273
|
/**
|
305
|
/**
|
|
274
|
* 小时费率
|
306
|
* 小时费率
|
|
275
|
*/
|
307
|
*/
|
|
276
|
- String sql = flowTaskInfoVO.getSqlString();
|
|
|
|
|
|
308
|
+ String sql1 = flowTaskInfoVO.getSqlString();
|
|
|
|
309
|
+ log.info("sql1:" + sql1);
|
|
|
|
310
|
+ String sql = sql1.replaceAll("^\"|\"$", ""); // 去除首尾引号
|
|
|
|
311
|
+ log.info("sql:" + sql);
|
|
277
|
JSONObject jsonObject = standardCostService.costMaterialBomMapper.customSelectOne(sql);
|
312
|
JSONObject jsonObject = standardCostService.costMaterialBomMapper.customSelectOne(sql);
|
|
278
|
BigDecimal hourRate = new BigDecimal("0");
|
313
|
BigDecimal hourRate = new BigDecimal("0");
|
|
279
|
if (jsonObject != null) {
|
314
|
if (jsonObject != null) {
|
|
|
|
|
|
|
306
|
}
|
341
|
}
|
|
307
|
}
|
342
|
}
|
|
308
|
//2.2计算机器成本并存储到成本结果数据表中
|
343
|
//2.2计算机器成本并存储到成本结果数据表中
|
|
309
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
|
|
|
|
|
|
344
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").costType(feeType).build();
|
|
310
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
345
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
311
|
}
|
346
|
}
|
|
312
|
}
|
347
|
}
|
|
|
|
|
|
|
328
|
}
|
363
|
}
|
|
329
|
}
|
364
|
}
|
|
330
|
//2.2计算机物料消耗存储到成本结果数据表中
|
365
|
//2.2计算机物料消耗存储到成本结果数据表中
|
|
331
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
|
|
|
|
|
|
366
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").costType(feeType).build();
|
|
332
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
367
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
333
|
}
|
368
|
}
|
|
334
|
}
|
369
|
}
|
|
|
|
|
|
|
350
|
}
|
385
|
}
|
|
351
|
}
|
386
|
}
|
|
352
|
//2.2计算机物料消耗存储到成本结果数据表中
|
387
|
//2.2计算机物料消耗存储到成本结果数据表中
|
|
353
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
|
|
|
|
|
|
388
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").costType(feeType).build();
|
|
354
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
389
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
355
|
}
|
390
|
}
|
|
356
|
}
|
391
|
}
|
|
|
|
|
|
|
372
|
}
|
407
|
}
|
|
373
|
}
|
408
|
}
|
|
374
|
//2.2计算机物料消耗存储到成本结果数据表中
|
409
|
//2.2计算机物料消耗存储到成本结果数据表中
|
|
375
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").build();
|
|
|
|
|
|
410
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").costType(feeType).build();
|
|
376
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
411
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
377
|
}
|
412
|
}
|
|
378
|
}
|
413
|
}
|
|
|
|
|
|
|
392
|
totalCost = totalCost.add(new BigDecimal(countValue));
|
427
|
totalCost = totalCost.add(new BigDecimal(countValue));
|
|
393
|
}
|
428
|
}
|
|
394
|
}
|
429
|
}
|
|
395
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(appSceneCostResultValues.get(0).getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost.multiply(new BigDecimal("0.1016")).toString()).build();
|
|
|
|
|
|
430
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(appSceneCostResultValues.get(0).getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost.multiply(new BigDecimal("0.1016")).toString()).costType(feeType).build();
|
|
396
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
431
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
397
|
}
|
432
|
}
|
|
398
|
}
|
433
|
}
|
|
|
|
|
|
|
437
|
}
|
472
|
}
|
|
438
|
//3.计算出所有的单个物料的累计标准成本
|
473
|
//3.计算出所有的单个物料的累计标准成本
|
|
439
|
List<AppSceneCostResultValue> standardCostList = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, taskType, flowInstanceId);
|
474
|
List<AppSceneCostResultValue> standardCostList = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, taskType, flowInstanceId);
|
|
440
|
- //循环算出各个物料的累计成本
|
|
|
|
|
|
475
|
+ //TODO 优化累计成本的计算
|
|
441
|
totalCountCost(standardCostList, topMaterialCode, taskType, taskCode, flowInstanceId);
|
476
|
totalCountCost(standardCostList, topMaterialCode, taskType, taskCode, flowInstanceId);
|
|
442
|
}
|
477
|
}
|
|
443
|
|
478
|
|
|
|
|
|
|
|
453
|
private static void totalCountCost(List<AppSceneCostResultValue> standardCostList, String topMaterialCode, String taskType, String taskCode, String flowInstanceId) {
|
488
|
private static void totalCountCost(List<AppSceneCostResultValue> standardCostList, String topMaterialCode, String taskType, String taskCode, String flowInstanceId) {
|
|
454
|
Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap = standardCostList.stream().filter(appSceneCostResultValue -> appSceneCostResultValue.getParentMarterialNo() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getParentMarterialNo));
|
489
|
Map<String, List<AppSceneCostResultValue>> parentMaterialNoMap = standardCostList.stream().filter(appSceneCostResultValue -> appSceneCostResultValue.getParentMarterialNo() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getParentMarterialNo));
|
|
455
|
for (int i = 0; i < standardCostList.size(); i++) {
|
490
|
for (int i = 0; i < standardCostList.size(); i++) {
|
|
456
|
- AppSceneCostResultValue appSceneCostResultValue = standardCostList.get(i);
|
|
|
|
457
|
- BigDecimal totalCost = new BigDecimal("0.0");
|
|
|
|
458
|
- totalCost = loopCount(appSceneCostResultValue, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
|
|
|
|
459
|
- appSceneCostResultValue.setTotalValue(totalCost.toString());
|
|
|
|
460
|
- standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
|
|
|
|
|
|
491
|
+ AppSceneCostResultValue oldAppSceneCostResultValue = standardCostList.get(i);
|
|
|
|
492
|
+ BigDecimal totalCost = new BigDecimal(oldAppSceneCostResultValue.getCountValue());
|
|
|
|
493
|
+ totalCost = loopCount(oldAppSceneCostResultValue, parentMaterialNoMap, topMaterialCode, taskType, taskCode, flowInstanceId, totalCost);
|
|
|
|
494
|
+ oldAppSceneCostResultValue.setTotalValue(totalCost.toString());
|
|
|
|
495
|
+ standardCostService.iAppSceneCostResultValueService.updateById(oldAppSceneCostResultValue);
|
|
|
|
496
|
+ //TODO 更新结果集到标准成本单行查询中去
|
|
461
|
}
|
497
|
}
|
|
462
|
}
|
498
|
}
|
|
463
|
|
499
|
|
|
464
|
/**
|
500
|
/**
|
|
|
|
501
|
+ * //循环算出各个物料的累计成本
|
|
465
|
* 递归计算出累计成本
|
502
|
* 递归计算出累计成本
|
|
466
|
*
|
503
|
*
|
|
467
|
* @param appSceneCostResultValue
|
504
|
* @param appSceneCostResultValue
|