|
|
@@ -8,9 +8,12 @@ import com.zzsmart.qomo.kn.cost.manage.enums.HourOrRateTypeEnum;
|
|
8
|
8
|
import com.zzsmart.qomo.kn.cost.manage.enums.TotalCostEnum;
|
|
9
|
9
|
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostBomRelevancyMapper;
|
|
10
|
10
|
import com.zzsmart.qomo.kn.cost.manage.service.*;
|
|
|
11
|
+import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo;
|
|
11
|
12
|
import com.zzsmart.qomo.kn.cost.manage.vo.FlowTaskInfoVO;
|
|
12
|
13
|
import com.zzsmart.qomo.kn.cost.manage.vo.TotalResultValue;
|
|
13
|
14
|
import com.zzsmart.qomo.plugin.task.api.TaskExecutionContext;
|
|
|
15
|
+import io.swagger.models.auth.In;
|
|
|
16
|
+import liquibase.pro.packaged.B;
|
|
14
|
17
|
import lombok.extern.slf4j.Slf4j;
|
|
15
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
16
|
19
|
import org.springframework.stereotype.Service;
|
|
|
@@ -18,10 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
18
|
21
|
|
|
19
|
22
|
import javax.annotation.PostConstruct;
|
|
20
|
23
|
import java.math.BigDecimal;
|
|
21
|
|
-import java.util.ArrayList;
|
|
22
|
|
-import java.util.Date;
|
|
23
|
|
-import java.util.List;
|
|
24
|
|
-import java.util.Map;
|
|
|
24
|
+import java.util.*;
|
|
25
|
25
|
import java.util.stream.Collectors;
|
|
26
|
26
|
|
|
27
|
27
|
@Service
|
|
|
@@ -71,6 +71,9 @@ public class StandardCostService {
|
|
71
|
71
|
@Autowired
|
|
72
|
72
|
private IAppSceneCostStandardResultService iAppSceneCostStandardResultService;
|
|
73
|
73
|
|
|
|
74
|
+ @Autowired
|
|
|
75
|
+ private IAppSceneCostMaterialService iAppSceneCostMaterialService;
|
|
|
76
|
+
|
|
74
|
77
|
@PostConstruct
|
|
75
|
78
|
public void init() {
|
|
76
|
79
|
standardCostService = this;
|
|
|
@@ -82,6 +85,7 @@ public class StandardCostService {
|
|
82
|
85
|
standardCostService.costMaterialProcessHoursService = this.costMaterialProcessHoursService;
|
|
83
|
86
|
standardCostService.iAppSceneCostResultValueService = this.iAppSceneCostResultValueService;
|
|
84
|
87
|
standardCostService.iAppSceneCostStandardResultService = this.iAppSceneCostStandardResultService;
|
|
|
88
|
+ standardCostService.iAppSceneCostMaterialService = this.iAppSceneCostMaterialService;
|
|
85
|
89
|
}
|
|
86
|
90
|
|
|
87
|
91
|
/**
|
|
|
@@ -127,16 +131,90 @@ public class StandardCostService {
|
|
127
|
131
|
* @param flowInstanceId 流程实例id
|
|
128
|
132
|
*/
|
|
129
|
133
|
public static void getAllMaterialBomInfoByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId) {
|
|
130
|
|
- List<AppSceneCostBomRelevancy> list = standardCostService.costMaterialBomService.queryAllBomInfoByTopMaterialCode(topMaterialCode);
|
|
|
134
|
+ log.info("getAllMaterialBomInfoByTopMaterialCode");
|
|
|
135
|
+ List<BomTreeVo> list = standardCostService.costMaterialBomService.queryAllBomInfoByTopMaterialCode(topMaterialCode);
|
|
|
136
|
+ List<String> MarterialNoList = new ArrayList<>();
|
|
|
137
|
+ if (list != null && list.size() > 0) {
|
|
|
138
|
+ MarterialNoList = list.stream().filter(s -> s.getIdnrk() != null).map(BomTreeVo::getIdnrk).collect(Collectors.toList());
|
|
|
139
|
+ }
|
|
|
140
|
+ Map<String, String> manuTypeMap = standardCostService.iAppSceneCostMaterialService.getManuTypeByMaterialNo(MarterialNoList);
|
|
|
141
|
+
|
|
|
142
|
+ int maxdepth = 0;
|
|
|
143
|
+ List<AppSceneCostResultValue> appSceneCostResultValues=new ArrayList<>();
|
|
131
|
144
|
log.info("Full ParamTask list: {}", list);
|
|
132
|
145
|
//TODO material.getMeins()领用量??为什么是ST字母
|
|
133
|
146
|
for (int i = 0; list != null && i < list.size(); i++) {
|
|
134
|
|
- AppSceneCostBomRelevancy material = list.get(i);
|
|
|
147
|
+ BomTreeVo material = list.get(i);
|
|
|
148
|
+ String manutype = "";
|
|
|
149
|
+ if(manuTypeMap.containsKey(material.getIdnrk())){
|
|
|
150
|
+ manutype = manuTypeMap.get(material.getIdnrk());
|
|
|
151
|
+ }
|
|
135
|
152
|
//TODO 物料领用数据
|
|
136
|
|
- BigDecimal num1 = BigDecimal.ONE;
|
|
137
|
|
- AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(material.getIdnrk()).parentMarterialNo(material.getMatnr()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).num(num1).build();
|
|
138
|
|
- standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
|
|
|
153
|
+ BigDecimal num1 = material.getMenge();
|
|
|
154
|
+ AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder()
|
|
|
155
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
156
|
+ .marterialNo(material.getIdnrk())
|
|
|
157
|
+ .parentMarterialNo(material.getMatnr())
|
|
|
158
|
+ .taskType(taskType)
|
|
|
159
|
+ .taskCode(taskCode)
|
|
|
160
|
+ .flowInstanceId(flowInstanceId)
|
|
|
161
|
+ .num(material.getMenge())
|
|
|
162
|
+ .pnum(material.getPmenge())
|
|
|
163
|
+ .topnum(material.getTopmenge())
|
|
|
164
|
+ .depth(material.depth)
|
|
|
165
|
+ .manuType(manutype)
|
|
|
166
|
+ .build();
|
|
|
167
|
+ appSceneCostResultValues.add(appSceneCostResultValue);
|
|
|
168
|
+ if(material.depth>maxdepth){
|
|
|
169
|
+ maxdepth=material.depth;
|
|
|
170
|
+ }
|
|
|
171
|
+ //standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
|
|
139
|
172
|
}
|
|
|
173
|
+ Map<String,Integer> mapIndex = new HashMap<>();
|
|
|
174
|
+ for (int i=1;i<=maxdepth;++i){
|
|
|
175
|
+ //int index=1;
|
|
|
176
|
+ for (AppSceneCostResultValue appSceneCostResultValue:appSceneCostResultValues){
|
|
|
177
|
+ if(appSceneCostResultValue.getDepth()==i){
|
|
|
178
|
+ String parentlayer = "";
|
|
|
179
|
+ if(i==1){
|
|
|
180
|
+ parentlayer="0";
|
|
|
181
|
+ }else{
|
|
|
182
|
+ for (AppSceneCostResultValue appSceneCostResultValue1:appSceneCostResultValues){
|
|
|
183
|
+ if(appSceneCostResultValue1.getMarterialNo().equals(appSceneCostResultValue.getParentMarterialNo())&&(appSceneCostResultValue1.getDepth()+1==appSceneCostResultValue.getDepth())){
|
|
|
184
|
+ parentlayer=appSceneCostResultValue1.getLayer();
|
|
|
185
|
+ }
|
|
|
186
|
+ }
|
|
|
187
|
+ }
|
|
|
188
|
+ int index = 1;
|
|
|
189
|
+ if(mapIndex.containsKey(parentlayer)){
|
|
|
190
|
+ index = mapIndex.get(parentlayer);
|
|
|
191
|
+ }else{
|
|
|
192
|
+ mapIndex.put(parentlayer,index);
|
|
|
193
|
+ }
|
|
|
194
|
+ String layer = parentlayer+"-"+String.valueOf(index);
|
|
|
195
|
+ index++;
|
|
|
196
|
+ mapIndex.put(parentlayer,index);
|
|
|
197
|
+ appSceneCostResultValue.setLayer(layer);
|
|
|
198
|
+ }
|
|
|
199
|
+ }
|
|
|
200
|
+ }
|
|
|
201
|
+ standardCostService.iAppSceneCostResultValueService.saveBatch(appSceneCostResultValues);
|
|
|
202
|
+
|
|
|
203
|
+ AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder()
|
|
|
204
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
205
|
+ .marterialNo(topMaterialCode)
|
|
|
206
|
+ .parentMarterialNo(topMaterialCode)
|
|
|
207
|
+ .taskType(taskType)
|
|
|
208
|
+ .taskCode(taskCode)
|
|
|
209
|
+ .flowInstanceId(flowInstanceId)
|
|
|
210
|
+ .num(new BigDecimal(1))
|
|
|
211
|
+ .pnum(new BigDecimal(1))
|
|
|
212
|
+ .topnum(new BigDecimal(1))
|
|
|
213
|
+ .depth(0)
|
|
|
214
|
+ .layer("0")
|
|
|
215
|
+ .manuType("E")
|
|
|
216
|
+ .build();
|
|
|
217
|
+ standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue);
|
|
140
|
218
|
}
|
|
141
|
219
|
|
|
142
|
220
|
/**
|
|
|
@@ -148,6 +226,7 @@ public class StandardCostService {
|
|
148
|
226
|
* @param flowInstanceId 流程实例id
|
|
149
|
227
|
*/
|
|
150
|
228
|
public static void countMaterialCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String feeType) {
|
|
|
229
|
+ log.info("countMaterialCostByTopMaterialCode");
|
|
151
|
230
|
//1.查询出物料编号对应的下所有的BOM信息
|
|
152
|
231
|
List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", String.valueOf(flowInstanceId));
|
|
153
|
232
|
//2.计算出所有的单个物料的物料成本
|
|
|
@@ -163,15 +242,40 @@ public class StandardCostService {
|
|
163
|
242
|
String marterialNo = appSceneCostResultValue.getMarterialNo();
|
|
164
|
243
|
BigDecimal num = appSceneCostResultValue.getNum();
|
|
165
|
244
|
if (marterialNo != null && num != null && (new BigDecimal(num.toString()).compareTo(BigDecimal.ZERO)) != 0) {
|
|
166
|
|
- BigDecimal price = purchasePriceMap.get(marterialNo);
|
|
167
|
|
- if (price == null) {
|
|
168
|
|
- price = BigDecimal.ZERO;
|
|
|
245
|
+ BigDecimal price = new BigDecimal(0);
|
|
|
246
|
+ String price_type = "";
|
|
|
247
|
+ if(appSceneCostResultValue.getManuType()!=null&&appSceneCostResultValue.getManuType().equals("F")){
|
|
|
248
|
+ price = purchasePriceMap.get(marterialNo);
|
|
|
249
|
+ price_type = "purchase_record";
|
|
169
|
250
|
}
|
|
|
251
|
+ //purchasePriceMap.get(marterialNo);
|
|
|
252
|
+ //if (price == null) {
|
|
|
253
|
+ // price = BigDecimal.ZERO;
|
|
|
254
|
+ //} else {
|
|
|
255
|
+ // price_type = "purchase_record";
|
|
|
256
|
+ //}
|
|
170
|
257
|
BigDecimal number = new BigDecimal(num.toString());
|
|
171
|
258
|
//单价乘以数量
|
|
172
|
259
|
BigDecimal totalCost = price.multiply(number);
|
|
173
|
260
|
//2.2计算出人工成本并存储到成本结果数据表中
|
|
174
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).costType(feeType).taskCode(taskCode).flowInstanceId(flowInstanceId).countValue(totalCost + "").priceOrRate(price).num(num).build();
|
|
|
261
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
262
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
263
|
+ .marterialNo(marterialNo)
|
|
|
264
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
265
|
+ .taskType(taskType)
|
|
|
266
|
+ .costType(feeType)
|
|
|
267
|
+ .taskCode(taskCode)
|
|
|
268
|
+ .priceType(price_type)
|
|
|
269
|
+ .flowInstanceId(flowInstanceId)
|
|
|
270
|
+ .countValue(totalCost + "")
|
|
|
271
|
+ .material(price)
|
|
|
272
|
+ .num(num)
|
|
|
273
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
274
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
275
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
276
|
+ .depth(appSceneCostResultValue.getDepth())
|
|
|
277
|
+ .layer(appSceneCostResultValue.getLayer())
|
|
|
278
|
+ .build();
|
|
175
|
279
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
176
|
280
|
}
|
|
177
|
281
|
}
|
|
|
@@ -186,12 +290,13 @@ public class StandardCostService {
|
|
186
|
290
|
* @param flowInstanceId 流程实例id
|
|
187
|
291
|
*/
|
|
188
|
292
|
public static void countLaborCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String feeType, AppSceneCostHourRate appSceneCostHourRate) {
|
|
|
293
|
+ log.info("countLaborCostByTopMaterialCode");
|
|
189
|
294
|
//1.查询出人员工时费率
|
|
190
|
|
- AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(appSceneCostHourRate);
|
|
|
295
|
+ //AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo();
|
|
191
|
296
|
BigDecimal hourRate = new BigDecimal("0");
|
|
192
|
|
- if (hourRateInfo != null) {
|
|
193
|
|
- hourRate = hourRateInfo.getLaborHourRate();
|
|
194
|
|
- }
|
|
|
297
|
+ //if (hourRateInfo != null) {
|
|
|
298
|
+ // hourRate = hourRateInfo.getLaborHourRate();
|
|
|
299
|
+ //}
|
|
195
|
300
|
//1.查询出物料编号对应的下所有的BOM信息
|
|
196
|
301
|
List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", String.valueOf(flowInstanceId));
|
|
197
|
302
|
//2.计算出所有的单个物料的人工成本
|
|
|
@@ -218,12 +323,89 @@ public class StandardCostService {
|
|
218
|
323
|
}
|
|
219
|
324
|
}
|
|
220
|
325
|
//2.2计算出人工成本并存储到成本结果数据表中
|
|
221
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(totalCost + "").costType(feeType).priceOrRate(hourRate).hour(laborHours).build();
|
|
|
326
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
327
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
328
|
+ .marterialNo(marterialNo)
|
|
|
329
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
330
|
+ .taskType(taskType).taskCode(taskCode)
|
|
|
331
|
+ .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
332
|
+ .countValue(totalCost + "")
|
|
|
333
|
+ .costType(feeType)
|
|
|
334
|
+ .priceOrRate(hourRate)
|
|
|
335
|
+ .hour(laborHours)
|
|
|
336
|
+ .num(appSceneCostResultValue.getNum())
|
|
|
337
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
338
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
339
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
340
|
+ .build();
|
|
222
|
341
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
223
|
342
|
}
|
|
224
|
343
|
}
|
|
225
|
344
|
}
|
|
226
|
345
|
|
|
|
346
|
+ public static void countManufacturingCost(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId) {
|
|
|
347
|
+ log.info("countManufacturingCost");
|
|
|
348
|
+ //1.查询出人员工时费率
|
|
|
349
|
+ Map<String,AppSceneCostHourRate> mapHourRate = standardCostService.iHourRateService.getOneHourRateInfo();
|
|
|
350
|
+ BigDecimal hourRate = new BigDecimal("0");
|
|
|
351
|
+ //if (hourRateInfo != null) {
|
|
|
352
|
+ // hourRate = hourRateInfo.getLaborHourRate();
|
|
|
353
|
+ //}
|
|
|
354
|
+ //1.查询出物料编号对应的下所有的BOM信息
|
|
|
355
|
+ List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialCost", String.valueOf(flowInstanceId));
|
|
|
356
|
+ //2.根据费用类型进行不同的费用计算
|
|
|
357
|
+ //查询工序工时
|
|
|
358
|
+ List<String> MarterialNoList = new ArrayList<>();
|
|
|
359
|
+ if (list != null && list.size() > 0) {
|
|
|
360
|
+ MarterialNoList = list.stream().filter(s -> s.getMarterialNo() != null).map(AppSceneCostResultValue::getMarterialNo).collect(Collectors.toList());
|
|
|
361
|
+ }
|
|
|
362
|
+ Map<String, List<AppSceneCostProductProcessMaintenance>> processHoursMap = standardCostService.costMaterialProcessHoursService.getProcessHoursByMaterialNo(MarterialNoList);
|
|
|
363
|
+ for (AppSceneCostResultValue appSceneCostResultValue:list){
|
|
|
364
|
+ double labor = 0;
|
|
|
365
|
+ double equip = 0;
|
|
|
366
|
+ double fuel = 0;
|
|
|
367
|
+ double auxi = 0;
|
|
|
368
|
+ double other = 0;
|
|
|
369
|
+ if(processHoursMap.containsKey(appSceneCostResultValue.getMarterialNo())){
|
|
|
370
|
+ List<AppSceneCostProductProcessMaintenance> appSceneCostProductProcessMaintenances = processHoursMap.get(appSceneCostResultValue.getMarterialNo());
|
|
|
371
|
+ for (AppSceneCostProductProcessMaintenance pm:appSceneCostProductProcessMaintenances){
|
|
|
372
|
+ String costcenter = pm.getCostCenterCode();
|
|
|
373
|
+ if(mapHourRate.containsKey(costcenter)){
|
|
|
374
|
+ AppSceneCostHourRate hourrate = mapHourRate.get(costcenter);
|
|
|
375
|
+ labor+=hourrate.getLaborHourRate().doubleValue()*pm.getLaborHour().doubleValue();
|
|
|
376
|
+ equip+=hourrate.getEquipHourRate().doubleValue()*pm.getMachineHour().doubleValue();
|
|
|
377
|
+ fuel+=hourrate.getFuelHourRate().doubleValue()*pm.getBurningHour().doubleValue();
|
|
|
378
|
+ auxi+=hourrate.getAuxiliaryHourRate().doubleValue()*pm.getAuxiliaryHour().doubleValue();
|
|
|
379
|
+ other+=hourrate.getOtherHourRate().doubleValue()*pm.getOtherHour().doubleValue();
|
|
|
380
|
+ }
|
|
|
381
|
+ }
|
|
|
382
|
+ }
|
|
|
383
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
384
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
385
|
+ .marterialNo(appSceneCostResultValue.getMarterialNo())
|
|
|
386
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
387
|
+ .taskType(taskType)
|
|
|
388
|
+ .taskCode(taskCode)
|
|
|
389
|
+ .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
390
|
+ .countValue("")
|
|
|
391
|
+ .material(appSceneCostResultValue.getMaterial())
|
|
|
392
|
+ .priceType(appSceneCostResultValue.getPriceType())
|
|
|
393
|
+ .labor(new BigDecimal(labor))
|
|
|
394
|
+ .equip(new BigDecimal(equip))
|
|
|
395
|
+ .fuel(new BigDecimal(fuel))
|
|
|
396
|
+ .auxi(new BigDecimal(auxi))
|
|
|
397
|
+ .other(new BigDecimal(other))
|
|
|
398
|
+ .num(appSceneCostResultValue.getNum())
|
|
|
399
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
400
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
401
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
402
|
+ .depth(appSceneCostResultValue.getDepth())
|
|
|
403
|
+ .layer(appSceneCostResultValue.getLayer())
|
|
|
404
|
+ .build();
|
|
|
405
|
+ standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
|
406
|
+ }
|
|
|
407
|
+ }
|
|
|
408
|
+
|
|
227
|
409
|
/**
|
|
228
|
410
|
* 【4.制造费用】
|
|
229
|
411
|
*
|
|
|
@@ -233,12 +415,13 @@ public class StandardCostService {
|
|
233
|
415
|
* @param flowInstanceId 流程实例id
|
|
234
|
416
|
*/
|
|
235
|
417
|
public static void countManufacturingCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String feeType, AppSceneCostHourRate appSceneCostHourRate) {
|
|
|
418
|
+ log.info("countManufacturingCostByTopMaterialCode");
|
|
236
|
419
|
//1.查询出人员工时费率
|
|
237
|
|
- AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(appSceneCostHourRate);
|
|
|
420
|
+ //AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(appSceneCostHourRate);
|
|
238
|
421
|
BigDecimal hourRate = new BigDecimal("0");
|
|
239
|
|
- if (hourRateInfo != null) {
|
|
240
|
|
- hourRate = hourRateInfo.getLaborHourRate();
|
|
241
|
|
- }
|
|
|
422
|
+ //if (hourRateInfo != null) {
|
|
|
423
|
+ // hourRate = hourRateInfo.getLaborHourRate();
|
|
|
424
|
+ //}
|
|
242
|
425
|
//1.查询出物料编号对应的下所有的BOM信息
|
|
243
|
426
|
List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", String.valueOf(flowInstanceId));
|
|
244
|
427
|
//2.根据费用类型进行不同的费用计算
|
|
|
@@ -266,7 +449,22 @@ public class StandardCostService {
|
|
266
|
449
|
}
|
|
267
|
450
|
}
|
|
268
|
451
|
//2.2计算机器成本并存储到成本结果数据表中
|
|
269
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(totalCost + "").costType(feeType).priceOrRate(hourRate).hour(laborHours).build();
|
|
|
452
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
453
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
454
|
+ .marterialNo(marterialNo)
|
|
|
455
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
456
|
+ .taskType(taskType)
|
|
|
457
|
+ .taskCode(taskCode)
|
|
|
458
|
+ .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
459
|
+ .countValue(totalCost + "")
|
|
|
460
|
+ .costType(feeType)
|
|
|
461
|
+ .priceOrRate(hourRate)
|
|
|
462
|
+ .hour(laborHours)
|
|
|
463
|
+ .num(appSceneCostResultValue.getNum())
|
|
|
464
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
465
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
466
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
467
|
+ .build();
|
|
270
|
468
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
271
|
469
|
}
|
|
272
|
470
|
}
|
|
|
@@ -289,7 +487,22 @@ public class StandardCostService {
|
|
289
|
487
|
}
|
|
290
|
488
|
}
|
|
291
|
489
|
//2.2计算机物料消耗存储到成本结果数据表中
|
|
292
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(totalCost + "").costType(feeType).priceOrRate(hourRate).hour(laborHours).build();
|
|
|
490
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
491
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
492
|
+ .marterialNo(marterialNo)
|
|
|
493
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
494
|
+ .taskType(taskType)
|
|
|
495
|
+ .taskCode(taskCode)
|
|
|
496
|
+ .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
497
|
+ .countValue(totalCost + "")
|
|
|
498
|
+ .costType(feeType)
|
|
|
499
|
+ .priceOrRate(hourRate)
|
|
|
500
|
+ .hour(laborHours)
|
|
|
501
|
+ .num(appSceneCostResultValue.getNum())
|
|
|
502
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
503
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
504
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
505
|
+ .build();
|
|
293
|
506
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
294
|
507
|
}
|
|
295
|
508
|
}
|
|
|
@@ -312,7 +525,22 @@ public class StandardCostService {
|
|
312
|
525
|
}
|
|
313
|
526
|
}
|
|
314
|
527
|
//2.2计算机物料消耗存储到成本结果数据表中
|
|
315
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(totalCost + "").costType(feeType).priceOrRate(hourRate).hour(laborHours).build();
|
|
|
528
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
529
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
530
|
+ .marterialNo(marterialNo)
|
|
|
531
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
532
|
+ .taskType(taskType)
|
|
|
533
|
+ .taskCode(taskCode)
|
|
|
534
|
+ .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
535
|
+ .countValue(totalCost + "")
|
|
|
536
|
+ .costType(feeType)
|
|
|
537
|
+ .priceOrRate(hourRate)
|
|
|
538
|
+ .hour(laborHours)
|
|
|
539
|
+ .num(appSceneCostResultValue.getNum())
|
|
|
540
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
541
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
542
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
543
|
+ .build();
|
|
316
|
544
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
317
|
545
|
}
|
|
318
|
546
|
}
|
|
|
@@ -335,30 +563,55 @@ public class StandardCostService {
|
|
335
|
563
|
}
|
|
336
|
564
|
}
|
|
337
|
565
|
//2.2计算机物料消耗存储到成本结果数据表中
|
|
338
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(marterialNo).parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(totalCost + "").costType(feeType).priceOrRate(hourRate).hour(laborHours).build();
|
|
|
566
|
+ AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
567
|
+ .belongTopMaterialNo(topMaterialCode)
|
|
|
568
|
+ .marterialNo(marterialNo)
|
|
|
569
|
+ .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo())
|
|
|
570
|
+ .taskType(taskType)
|
|
|
571
|
+ .taskCode(taskCode)
|
|
|
572
|
+ .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
573
|
+ .countValue(totalCost + "")
|
|
|
574
|
+ .costType(feeType)
|
|
|
575
|
+ .priceOrRate(hourRate)
|
|
|
576
|
+ .hour(laborHours)
|
|
|
577
|
+ .num(appSceneCostResultValue.getNum())
|
|
|
578
|
+ .pnum(appSceneCostResultValue.getPnum())
|
|
|
579
|
+ .topnum(appSceneCostResultValue.getTopnum())
|
|
|
580
|
+ .manuType(appSceneCostResultValue.getManuType())
|
|
|
581
|
+ .build();
|
|
339
|
582
|
standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
340
|
583
|
}
|
|
341
|
584
|
}
|
|
342
|
|
- } else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) {
|
|
343
|
|
- //查出所有的机器折旧费、机物料消耗、水电费、其他制费
|
|
344
|
|
- list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "ManufacturingCost", String.valueOf(flowInstanceId));
|
|
345
|
|
- //2.5物流费((机器折旧+机物料消耗+水电费+其他制费)*10.16%)
|
|
346
|
|
- //按照物料编号进行分组
|
|
347
|
|
- Map<String, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo));
|
|
348
|
|
- for (String key : materialNoMap.keySet()) {
|
|
349
|
|
- List<AppSceneCostResultValue> appSceneCostResultValues = materialNoMap.get(key);
|
|
350
|
|
- BigDecimal totalCost = new BigDecimal("0.0");
|
|
351
|
|
- for (int j = 0; j < appSceneCostResultValues.size(); j++) {
|
|
352
|
|
- AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j);
|
|
353
|
|
- String countValue = appSceneCostResultValue.getCountValue();
|
|
354
|
|
- if (countValue != null) {
|
|
355
|
|
- totalCost = totalCost.add(new BigDecimal(countValue));
|
|
356
|
|
- }
|
|
357
|
|
- }
|
|
358
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(appSceneCostResultValues.get(0).getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(totalCost.multiply(new BigDecimal("0.1016")).toString()).costType(feeType).build();
|
|
359
|
|
- standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
360
|
|
- }
|
|
361
|
585
|
}
|
|
|
586
|
+// else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) {
|
|
|
587
|
+// //查出所有的机器折旧费、机物料消耗、水电费、其他制费
|
|
|
588
|
+// list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "ManufacturingCost", String.valueOf(flowInstanceId));
|
|
|
589
|
+// //2.5物流费((机器折旧+机物料消耗+水电费+其他制费)*10.16%)
|
|
|
590
|
+// //按照物料编号进行分组
|
|
|
591
|
+// Map<String, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo));
|
|
|
592
|
+// for (String key : materialNoMap.keySet()) {
|
|
|
593
|
+// List<AppSceneCostResultValue> appSceneCostResultValues = materialNoMap.get(key);
|
|
|
594
|
+// BigDecimal totalCost = new BigDecimal("0.0");
|
|
|
595
|
+// for (int j = 0; j < appSceneCostResultValues.size(); j++) {
|
|
|
596
|
+// AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j);
|
|
|
597
|
+// String countValue = appSceneCostResultValue.getCountValue();
|
|
|
598
|
+// if (countValue != null) {
|
|
|
599
|
+// totalCost = totalCost.add(new BigDecimal(countValue));
|
|
|
600
|
+// }
|
|
|
601
|
+// }
|
|
|
602
|
+// AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder()
|
|
|
603
|
+// .belongTopMaterialNo(topMaterialCode)
|
|
|
604
|
+// .marterialNo(key)
|
|
|
605
|
+// .parentMarterialNo(appSceneCostResultValues.get(0).getParentMarterialNo())
|
|
|
606
|
+// .taskType(taskType)
|
|
|
607
|
+// .taskCode(taskCode)
|
|
|
608
|
+// .flowInstanceId(Integer.valueOf(flowInstanceId))
|
|
|
609
|
+// .countValue(totalCost.multiply(new BigDecimal("0.1016")).toString())
|
|
|
610
|
+// .costType(feeType)
|
|
|
611
|
+// .build();
|
|
|
612
|
+// standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
|
613
|
+// }
|
|
|
614
|
+// }
|
|
362
|
615
|
}
|
|
363
|
616
|
|
|
364
|
617
|
/**
|
|
|
@@ -370,138 +623,134 @@ public class StandardCostService {
|
|
370
|
623
|
* @param flowInstanceId 流程实例id
|
|
371
|
624
|
* @param costType 流程实例id
|
|
372
|
625
|
*/
|
|
373
|
|
- public static void countStandardCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String costType, String versionNumber) {
|
|
|
626
|
+ public static void countStandardCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String costType, String stage,String versionNumber) {
|
|
|
627
|
+ log.info("countStandardCostByTopMaterialCode");
|
|
374
|
628
|
//1.查询出根物料编号对应的下所有的BOM信息结果值
|
|
375
|
|
- List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getAllResultValueByTopMaterialNo(topMaterialCode, String.valueOf(flowInstanceId));
|
|
|
629
|
+ //List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getAllResultValueByTopMaterialNo(topMaterialCode, String.valueOf(flowInstanceId));
|
|
|
630
|
+ List<AppSceneCostResultValue> list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "ManufacturingCost", String.valueOf(flowInstanceId));
|
|
|
631
|
+ List<String> MarterialNoList = new ArrayList<>();
|
|
|
632
|
+ if (list != null && list.size() > 0) {
|
|
|
633
|
+ MarterialNoList = list.stream().filter(s -> s.getMarterialNo() != null).map(AppSceneCostResultValue::getMarterialNo).collect(Collectors.toList());
|
|
|
634
|
+ }
|
|
|
635
|
+ Map<String, String> maktxMap = standardCostService.iAppSceneCostMaterialService.getMaktxByMaterialNo(MarterialNoList);
|
|
376
|
636
|
//2.计算出所有的单个物料的本阶的标准成本(标准成本=物料成本+人工成本+制造费用)
|
|
377
|
637
|
//按照物料编号进行分组
|
|
378
|
|
- Map<String, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo));
|
|
|
638
|
+ Map<Integer, List<AppSceneCostResultValue>> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getDepth));
|
|
|
639
|
+
|
|
|
640
|
+ Set<Integer> soredDepth = new HashSet<>();
|
|
|
641
|
+ for (Integer depth : materialNoMap.keySet()) {
|
|
|
642
|
+ soredDepth.add(depth);
|
|
|
643
|
+ }
|
|
|
644
|
+ ArrayList<Integer> deplist = new ArrayList<>(soredDepth);
|
|
|
645
|
+ Collections.reverse(deplist);
|
|
|
646
|
+
|
|
|
647
|
+ List<AppSceneCostStandardResult> appSceneCostStandardResults=new ArrayList<>();
|
|
|
648
|
+
|
|
379
|
649
|
//遍历根物料下所有的物料进行该物料本阶成本和费用类别的统计
|
|
380
|
|
- for (String key : materialNoMap.keySet()) {
|
|
381
|
|
- List<AppSceneCostResultValue> appSceneCostResultValues = materialNoMap.get(key);
|
|
382
|
|
- //按照费用类别进行分组
|
|
383
|
|
- Map<String, List<AppSceneCostResultValue>> costTypeMap = appSceneCostResultValues.stream().filter(s -> s.getCostType() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getCostType));
|
|
384
|
|
- //【本阶标准成本】
|
|
385
|
|
- BigDecimal currentCost = new BigDecimal("0.0");
|
|
386
|
|
- //1.本阶物料成本
|
|
387
|
|
- BigDecimal materialCost = new BigDecimal("0.0");
|
|
388
|
|
- //2.本阶人工成本
|
|
389
|
|
- BigDecimal laborCost = new BigDecimal("0.0");
|
|
390
|
|
- //3.本阶制造费(设备费)
|
|
391
|
|
- BigDecimal equipmentCost = new BigDecimal("0.0");
|
|
392
|
|
- //4.本阶制造费(辅料费用)
|
|
393
|
|
- BigDecimal supplyMaterialCost = new BigDecimal("0.0");
|
|
394
|
|
- //5.本阶制造费(水电费、燃动费)
|
|
395
|
|
- BigDecimal driveCost = new BigDecimal("0.0");
|
|
396
|
|
- //6.本阶制造费(其他制造费用)
|
|
397
|
|
- BigDecimal otherCost = new BigDecimal("0.0");
|
|
398
|
|
- //7.本阶制造费(物流费)
|
|
399
|
|
- BigDecimal logisticsCost = new BigDecimal("0.0");
|
|
400
|
|
- //物料单价
|
|
401
|
|
- BigDecimal materialUnitPrice = new BigDecimal("0.0");
|
|
402
|
|
- //人员工时、小时费率
|
|
403
|
|
- BigDecimal laborHour = new BigDecimal("0.0");
|
|
404
|
|
- BigDecimal laborHourRate = new BigDecimal("0.0");
|
|
405
|
|
- //设备工时、小时费率
|
|
406
|
|
- BigDecimal equipmentHour = new BigDecimal("0.0");
|
|
407
|
|
- BigDecimal equipmentHourRate = new BigDecimal("0.0");
|
|
408
|
|
- //辅料工时、小时费率
|
|
409
|
|
- BigDecimal supplyMaterialHour = new BigDecimal("0.0");
|
|
410
|
|
- BigDecimal supplyMaterialHourRate = new BigDecimal("0.0");
|
|
411
|
|
- //燃动工时、小时费率
|
|
412
|
|
- BigDecimal driveHour = new BigDecimal("0.0");
|
|
413
|
|
- BigDecimal driveHourRate = new BigDecimal("0.0");
|
|
414
|
|
- //其他工时、小时费率
|
|
415
|
|
- BigDecimal otherHour = new BigDecimal("0.0");
|
|
416
|
|
- BigDecimal otherHourRate = new BigDecimal("0.0");
|
|
417
|
|
- AppSceneCostResultValue currentMaterialCost = null;
|
|
418
|
|
- //遍历所有费用类别计算本阶标准成本
|
|
419
|
|
- for (int j = 0; j < appSceneCostResultValues.size(); j++) {
|
|
420
|
|
- if (j == 0) {
|
|
421
|
|
- //初始化当前物料成本信息
|
|
422
|
|
- currentMaterialCost = appSceneCostResultValues.get(0);
|
|
423
|
|
- }
|
|
424
|
|
- AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j);
|
|
425
|
|
- String countValue = appSceneCostResultValue.getCountValue();
|
|
426
|
|
- if (countValue != null) {
|
|
427
|
|
- currentCost = currentCost.add(new BigDecimal(countValue));
|
|
428
|
|
- }
|
|
429
|
|
- }
|
|
430
|
|
- //计算本阶各个费用类别费用以及记录本阶物料的工时和小时费率
|
|
431
|
|
- for (String feeType : costTypeMap.keySet()) {
|
|
432
|
|
- List<AppSceneCostResultValue> appSceneCostResultValues1 = costTypeMap.get(feeType);
|
|
433
|
|
- for (int m = 0; m < appSceneCostResultValues1.size(); m++) {
|
|
434
|
|
- if (FeeTypeEnum.MaterialCost.getCode().equals(feeType)) {
|
|
435
|
|
- //物料成本
|
|
436
|
|
- materialCost = materialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
437
|
|
- //物料单价
|
|
438
|
|
- materialUnitPrice = appSceneCostResultValues1.get(m).getPriceOrRate();
|
|
439
|
|
- //TODO 数量
|
|
440
|
|
- currentMaterialCost.setNum(appSceneCostResultValues1.get(m).getNum());
|
|
441
|
|
- } else if (FeeTypeEnum.LaborCost.getCode().equals(feeType)) {
|
|
442
|
|
- //人工成本
|
|
443
|
|
- laborCost = laborCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
444
|
|
- //人工工时、小时费率
|
|
445
|
|
- laborHour = laborHour.add(appSceneCostResultValues1.get(m).getHour());
|
|
446
|
|
- laborHourRate = laborHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate());
|
|
447
|
|
- } else if (FeeTypeEnum.EquipmentFee.getCode().equals(feeType)) {
|
|
448
|
|
- //设备费用
|
|
449
|
|
- equipmentCost = equipmentCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
450
|
|
- //设备工时、小时费率
|
|
451
|
|
- equipmentHour = equipmentHour.add(appSceneCostResultValues1.get(m).getHour());
|
|
452
|
|
- equipmentHourRate = equipmentHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate());
|
|
453
|
|
- } else if (FeeTypeEnum.SupplyMaterialFee.getCode().equals(feeType)) {
|
|
454
|
|
- //辅料费用
|
|
455
|
|
- supplyMaterialCost = supplyMaterialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
456
|
|
- //辅料工时、小时费率
|
|
457
|
|
- supplyMaterialHour = supplyMaterialHour.add(appSceneCostResultValues1.get(m).getHour());
|
|
458
|
|
- supplyMaterialHourRate = supplyMaterialHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate());
|
|
459
|
|
- } else if (FeeTypeEnum.DriverFee.getCode().equals(feeType)) {
|
|
460
|
|
- //燃动费用
|
|
461
|
|
- driveCost = driveCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
462
|
|
- //燃动工时、小时费率
|
|
463
|
|
- driveHour = driveHour.add(appSceneCostResultValues1.get(m).getHour());
|
|
464
|
|
- driveHourRate = driveHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate());
|
|
465
|
|
- } else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) {
|
|
466
|
|
- //物流费用
|
|
467
|
|
- logisticsCost = logisticsCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
468
|
|
- } else if (FeeTypeEnum.OtherFee.getCode().equals(feeType)) {
|
|
469
|
|
- //其他费用
|
|
470
|
|
- otherCost = otherCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue()));
|
|
471
|
|
- //其他工时、小时费率
|
|
472
|
|
- otherHour = otherHour.add(appSceneCostResultValues1.get(m).getHour());
|
|
473
|
|
- otherHourRate = otherHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate());
|
|
|
650
|
+ for (Integer depth : deplist) {
|
|
|
651
|
+ List<AppSceneCostResultValue> appSceneCostResultValues = materialNoMap.get(depth);
|
|
|
652
|
+ for (AppSceneCostResultValue ascr:appSceneCostResultValues){
|
|
|
653
|
+ //BigDecimal currentCost = new BigDecimal("0.0");
|
|
|
654
|
+ //1.本阶物料成本
|
|
|
655
|
+ double materialCost = 0;
|
|
|
656
|
+ //2.本阶人工成本
|
|
|
657
|
+ double laborCost = 0;
|
|
|
658
|
+ //3.本阶制造费(设备费)
|
|
|
659
|
+ double equipmentCost = 0;
|
|
|
660
|
+ //4.本阶制造费(辅料费用)
|
|
|
661
|
+ double fuelcost = 0;
|
|
|
662
|
+ //5.本阶制造费(水电费、燃动费)
|
|
|
663
|
+ double auxicost = 0;
|
|
|
664
|
+ //6.本阶制造费(其他制造费用)
|
|
|
665
|
+ double otherCost = 0;
|
|
|
666
|
+ //7.本阶物料成本
|
|
|
667
|
+ double materialCost_acc = 0;
|
|
|
668
|
+ //8.本阶人工成本
|
|
|
669
|
+ double laborCost_acc = 0;
|
|
|
670
|
+ //9.本阶制造费(设备费)
|
|
|
671
|
+ double equipmentCost_acc = 0;
|
|
|
672
|
+ //10.本阶制造费(辅料费用)
|
|
|
673
|
+ double fuelcost_acc = 0;
|
|
|
674
|
+ //11.本阶制造费(水电费、燃动费)
|
|
|
675
|
+ double auxicost_acc = 0;
|
|
|
676
|
+ //12.本阶制造费(其他制造费用)
|
|
|
677
|
+ double otherCost_acc = 0;
|
|
|
678
|
+
|
|
|
679
|
+ if(ascr.getManuType().equals("F")){
|
|
|
680
|
+ materialCost = ascr.getMaterial().doubleValue()*ascr.getNum().doubleValue();
|
|
|
681
|
+ }else if(ascr.getManuType().equals("E")){
|
|
|
682
|
+ double labor = ascr.getLabor().doubleValue();
|
|
|
683
|
+ double equip = ascr.getEquip().doubleValue();
|
|
|
684
|
+ double fuel = ascr.getFuel().doubleValue();
|
|
|
685
|
+ double auxi = ascr.getAuxi().doubleValue();
|
|
|
686
|
+ double other = ascr.getOther().doubleValue();
|
|
|
687
|
+ laborCost = labor*ascr.getNum().doubleValue();
|
|
|
688
|
+ equipmentCost =equip*ascr.getNum().doubleValue();
|
|
|
689
|
+ fuelcost = fuel*ascr.getNum().doubleValue();
|
|
|
690
|
+ auxicost = auxi*ascr.getNum().doubleValue();
|
|
|
691
|
+ otherCost = other*ascr.getNum().doubleValue();
|
|
|
692
|
+
|
|
|
693
|
+ for (AppSceneCostStandardResult child:appSceneCostStandardResults){
|
|
|
694
|
+ if((Integer.parseInt(child.getLowOrderCode())==depth+1)&&child.getParentMatnr().equals(ascr.getMarterialNo())){
|
|
|
695
|
+ if(child.getManuType().equals("F")){
|
|
|
696
|
+ materialCost_acc+=child.getMaterialCostStage().doubleValue()*ascr.getNum().doubleValue();
|
|
|
697
|
+ }else if(child.getManuType().equals("E")){
|
|
|
698
|
+ materialCost_acc+=child.getMaterialCostStage().doubleValue()*ascr.getNum().doubleValue()+child.getMaterialCostAccumulated().doubleValue()*ascr.getNum().doubleValue();
|
|
|
699
|
+ laborCost_acc+=(child.getLaborCostStage().doubleValue()+child.getLaborCostAccumulated().doubleValue())*ascr.getNum().doubleValue();
|
|
|
700
|
+ equipmentCost_acc+=(child.getEquipCostStage().doubleValue()+child.getEquipCostAccumulated().doubleValue())*ascr.getNum().doubleValue();
|
|
|
701
|
+ fuelcost_acc+=(child.getBurningCostStage().doubleValue()+child.getBurningCostAccumulated().doubleValue())*ascr.getNum().doubleValue();
|
|
|
702
|
+ auxicost_acc+=(child.getAuxiliaryCostStage().doubleValue()+child.getAuxiliaryCostAccumulated().doubleValue())*ascr.getNum().doubleValue();
|
|
|
703
|
+ otherCost_acc+=(child.getOtherCostStage().doubleValue()+child.getOtherCostAccumulated().doubleValue())*ascr.getNum().doubleValue();
|
|
|
704
|
+ }
|
|
|
705
|
+ }
|
|
474
|
706
|
}
|
|
475
|
707
|
}
|
|
|
708
|
+ String maktx = "";
|
|
|
709
|
+ if(maktxMap.containsKey(ascr.getMarterialNo())){
|
|
|
710
|
+ maktx=maktxMap.get(ascr.getMarterialNo());
|
|
|
711
|
+ }
|
|
|
712
|
+ AppSceneCostStandardResult appSceneCostStandardResult=AppSceneCostStandardResult.builder()
|
|
|
713
|
+ .materialNumber(ascr.getMarterialNo())
|
|
|
714
|
+ .parentMatnr(ascr.getParentMarterialNo())
|
|
|
715
|
+ .pricetype(ascr.getPriceType())
|
|
|
716
|
+ .materialCostStage(new BigDecimal(materialCost))
|
|
|
717
|
+ .laborCostStage(new BigDecimal(laborCost))
|
|
|
718
|
+ .equipCostStage(new BigDecimal(equipmentCost))
|
|
|
719
|
+ .burningCostStage(new BigDecimal(fuelcost))
|
|
|
720
|
+ .auxiliaryCostStage(new BigDecimal(auxicost))
|
|
|
721
|
+ .otherCostStage(new BigDecimal(otherCost))
|
|
|
722
|
+ .materialCostAccumulated(new BigDecimal(materialCost_acc))
|
|
|
723
|
+ .laborCostAccumulated(new BigDecimal(laborCost_acc))
|
|
|
724
|
+ .equipCostAccumulated(new BigDecimal(equipmentCost_acc))
|
|
|
725
|
+ .burningCostAccumulated(new BigDecimal(fuelcost_acc))
|
|
|
726
|
+ .auxiliaryCostAccumulated(new BigDecimal(auxicost_acc))
|
|
|
727
|
+ .otherCostAccumulated(new BigDecimal(otherCost_acc))
|
|
|
728
|
+ .materialCostTotal(new BigDecimal(materialCost+materialCost_acc))
|
|
|
729
|
+ .laborCostTotal(new BigDecimal(laborCost+laborCost_acc))
|
|
|
730
|
+ .equipCostTotal(new BigDecimal(equipmentCost+equipmentCost_acc))
|
|
|
731
|
+ .burningCostTotal(new BigDecimal(fuelcost+fuelcost_acc))
|
|
|
732
|
+ .auxiliaryCostTotal(new BigDecimal(auxicost+auxicost_acc))
|
|
|
733
|
+ .otherCostTotal(new BigDecimal(otherCost+otherCost_acc))
|
|
|
734
|
+ .totalStandardCost(new BigDecimal(materialCost+laborCost+equipmentCost+fuelcost+auxicost+otherCost+materialCost_acc+laborCost_acc+equipmentCost_acc+fuelcost_acc+auxicost_acc+otherCost_acc))
|
|
|
735
|
+ .lowOrderCode(String.valueOf(depth))
|
|
|
736
|
+ .relativeDosage(ascr.getNum())
|
|
|
737
|
+ .createdTime(new Date())
|
|
|
738
|
+ .menge(ascr.getNum())
|
|
|
739
|
+ .manuType(ascr.getManuType())
|
|
|
740
|
+ .versionNumber(versionNumber)
|
|
|
741
|
+ .stage(stage)
|
|
|
742
|
+ .layer(ascr.getLayer())
|
|
|
743
|
+ .factory("7100")
|
|
|
744
|
+ .maktx(maktx)
|
|
|
745
|
+ .build();
|
|
|
746
|
+ appSceneCostStandardResults.add(appSceneCostStandardResult);
|
|
476
|
747
|
}
|
|
477
|
|
- //本阶不同费用类别成本统计
|
|
478
|
|
- JSONObject currentLevelCostTypeDetail = new JSONObject();
|
|
479
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.MaterialCost.getCode(), materialCost);
|
|
480
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.LaborCost.getCode(), laborCost);
|
|
481
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.EquipmentFee.getCode(), equipmentCost);
|
|
482
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.SupplyMaterialFee.getCode(), supplyMaterialCost);
|
|
483
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.DriverFee.getCode(), driveCost);
|
|
484
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.LogisticsFee.getCode(), logisticsCost);
|
|
485
|
|
- currentLevelCostTypeDetail.put(FeeTypeEnum.OtherFee.getCode(), otherCost);
|
|
486
|
|
- //统计本阶不同费用类别工时、小时费率
|
|
487
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.MaterialUnitPrice.getCode(), materialUnitPrice);
|
|
488
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.LaborHour.getCode(), laborHour);
|
|
489
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.LaborHourRate.getCode(), laborHourRate);
|
|
490
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.EquipmentHour.getCode(), equipmentHour);
|
|
491
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.EquipmentHourRate.getCode(), equipmentHourRate);
|
|
492
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.SupplyMaterialHour.getCode(), supplyMaterialHour);
|
|
493
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.SupplyMaterialHourRate.getCode(), supplyMaterialHourRate);
|
|
494
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.DriverHour.getCode(), driveHour);
|
|
495
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.DriverHourRate.getCode(), driveHourRate);
|
|
496
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.OtherHour.getCode(), otherHour);
|
|
497
|
|
- currentLevelCostTypeDetail.put(HourOrRateTypeEnum.OtherHourRate.getCode(), otherHourRate);
|
|
498
|
|
- AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(key).parentMarterialNo(currentMaterialCost.getParentMarterialNo()).taskType(taskType).taskCode(taskCode).flowInstanceId(Integer.valueOf(flowInstanceId)).countValue(currentCost.toString()).costDetail(JSON.toJSONString(currentLevelCostTypeDetail)).costType(costType).num(currentMaterialCost.getNum()).build();
|
|
499
|
|
- standardCostService.iAppSceneCostResultValueService.save(resultValue);
|
|
500
|
748
|
}
|
|
|
749
|
+ standardCostService.iAppSceneCostStandardResultService.saveBatch(appSceneCostStandardResults);
|
|
501
|
750
|
//3.计算出所有的单个物料的累计标准成本
|
|
502
|
|
- List<AppSceneCostResultValue> standardCostList = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, taskType, String.valueOf(flowInstanceId));
|
|
|
751
|
+ //List<AppSceneCostResultValue> standardCostList = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, taskType, String.valueOf(flowInstanceId));
|
|
503
|
752
|
//【累计成本】的计算
|
|
504
|
|
- totalCountCost(standardCostList, topMaterialCode, taskType, taskCode, String.valueOf(flowInstanceId), versionNumber);
|
|
|
753
|
+ //totalCountCost(standardCostList, topMaterialCode, taskType, taskCode, String.valueOf(flowInstanceId), versionNumber);
|
|
505
|
754
|
}
|
|
506
|
755
|
|
|
507
|
756
|
/**
|
|
|
@@ -734,7 +983,22 @@ public class StandardCostService {
|
|
734
|
983
|
// .sort()
|
|
735
|
984
|
// .figureNumber()
|
|
736
|
985
|
// .dosage(oldAppSceneCostResultValue.getNum() != null ? oldAppSceneCostResultValue.getNum().doubleValue() : 0).unit(oldAppSceneCostResultValue.getUnit())
|
|
737
|
|
- .materialCostStageInter(costDetailJson.getBigDecimal(FeeTypeEnum.MaterialCost.getCode())).laborCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.LaborCost.getCode())).equipCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.EquipmentFee.getCode())).auxiliaryCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.SupplyMaterialFee.getCode())).burningCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.DriverFee.getCode())).stageLogisticsCost(costDetailJson.getBigDecimal(FeeTypeEnum.LogisticsFee.getCode())).otherCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.OtherFee.getCode())).totalStandardCostInter(new BigDecimal(oldAppSceneCostResultValue.getCountValue())).materialCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalMaterialCost.getCode())).laborCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalLaborCost.getCode())).equipCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalEquipmentFee.getCode())).auxiliaryCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalSupplyMaterialFee.getCode())).burningCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalDriverFee.getCode())).totalLogisticsCost(costDetailJson.getBigDecimal(TotalCostEnum.TotalLogisticsFee.getCode())).otherCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalOtherFee.getCode())).totalStandardCost(costDetailJson.getBigDecimal(TotalCostEnum.TotalStandardCost.getCode())).createdTime(new Date()).build();
|
|
|
986
|
+ .materialCostTotal(costDetailJson.getBigDecimal(FeeTypeEnum.MaterialCost.getCode()))
|
|
|
987
|
+ .laborCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.LaborCost.getCode()))
|
|
|
988
|
+ .equipCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.EquipmentFee.getCode()))
|
|
|
989
|
+ .auxiliaryCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.SupplyMaterialFee.getCode()))
|
|
|
990
|
+ .burningCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.DriverFee.getCode()))
|
|
|
991
|
+ .otherCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.OtherFee.getCode()))
|
|
|
992
|
+ .totalStandardCost(new BigDecimal(oldAppSceneCostResultValue.getCountValue()))
|
|
|
993
|
+ .materialCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalMaterialCost.getCode()))
|
|
|
994
|
+ .laborCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalLaborCost.getCode()))
|
|
|
995
|
+ .equipCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalEquipmentFee.getCode()))
|
|
|
996
|
+ .auxiliaryCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalSupplyMaterialFee.getCode()))
|
|
|
997
|
+ .burningCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalDriverFee.getCode()))
|
|
|
998
|
+ .otherCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalOtherFee.getCode()))
|
|
|
999
|
+ .totalStandardCost(costDetailJson.getBigDecimal(TotalCostEnum.TotalStandardCost.getCode()))
|
|
|
1000
|
+ .lowOrderCode(String.valueOf(oldAppSceneCostResultValue.getDepth()))
|
|
|
1001
|
+ .createdTime(new Date()).build();
|
|
738
|
1002
|
costStandardResults.add(costStandardResultValue);
|
|
739
|
1003
|
}
|
|
740
|
1004
|
//更新结果集到标准成本单行查询中去
|