Pārlūkot izejas kodu

标准成本计算、单行查询、结构树查询优化

xieke 1 gadu atpakaļ
vecāks
revīzija
b169b641de
22 mainītis faili ar 1107 papildinājumiem un 621 dzēšanām
  1. 11
    11
      qomo-kn-cost-manage-start/src/main/resources/application-dev.yml
  2. 1
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java
  3. 40
    38
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostStandardResultController.java
  4. 111
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostMaterial.java
  5. 70
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java
  6. 162
    336
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostStandardResult.java
  7. 5
    4
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostBomRelevancyMapper.java
  8. 18
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostMaterialMapper.java
  9. 5
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/xml/AppSceneCostMaterialMapper.xml
  10. 432
    168
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java
  11. 2
    1
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostBomRelevancyService.java
  12. 3
    1
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostHourRateService.java
  13. 21
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostMaterialService.java
  14. 3
    2
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostBomRelevancyServiceImpl.java
  15. 20
    14
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java
  16. 13
    14
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostHourRateServiceImpl.java
  17. 62
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostMaterialServiceImpl.java
  18. 29
    21
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/BomTreeServiceImpl.java
  19. 51
    11
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/util/BomTreeBuilder.java
  20. 6
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/AppSceneCostCountVO.java
  21. 5
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeInfoVO.java
  22. 37
    0
      qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeVo.java

+ 11
- 11
qomo-kn-cost-manage-start/src/main/resources/application-dev.yml Parādīt failu

@@ -226,19 +226,19 @@ spring:
226 226
 #    database: 5
227 227
 #      host: 121.40.189.20
228 228
 #      port: 6389
229
-  redis:
230
-    database: 9
231
-    host: 192.168.50.9
232
-    port: 7379
233
-    password: 'zzboard'
234
-    main:
235
-      allow-circular-references: true
236 229
 #  redis:
237
-#    database: 10
238
-#    host: localhost
239
-#    port: 6379
230
+#    database: 9
231
+#    host: 192.168.50.9
232
+#    port: 7379
233
+#    password: 'zzboard'
240 234
 #    main:
241 235
 #      allow-circular-references: true
236
+  redis:
237
+    database: 10
238
+    host: localhost
239
+    port: 6379
240
+    main:
241
+      allow-circular-references: true
242 242
 
243 243
   #rabbitmq 配置
244 244
   rabbitmq:
@@ -268,7 +268,7 @@ mybatis-plus:
268 268
       table-underline: true
269 269
   configuration:
270 270
     # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
271
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
271
+    #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
272 272
     #    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
273 273
     # 返回类型为Map,显示null对应的字段
274 274
     call-setters-on-nulls: true

+ 1
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java Parādīt failu

@@ -55,6 +55,7 @@ public class AppSceneCostCountController extends JeecgController<AppSceneCostCou
55 55
     @GetMapping(value = "/list")
56 56
     public Result<IPage<AppSceneCostCountVO>> queryPageList(AppSceneCostCount appSceneCostCount, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
57 57
         QueryWrapper<AppSceneCostCount> queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostCount, req.getParameterMap());
58
+        queryWrapper.orderByDesc("create_time");
58 59
         Page<AppSceneCostCount> page = new Page<AppSceneCostCount>(pageNo, pageSize);
59 60
         IPage<AppSceneCostCount> pageList = appSceneCostCountService.page(page, queryWrapper);
60 61
         IPage<AppSceneCostCountVO> pageList1 = new Page<>();

+ 40
- 38
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostStandardResultController.java Parādīt failu

@@ -51,47 +51,49 @@ public class AppSceneCostStandardResultController extends JeecgController<AppSce
51 51
     //@AutoLog(value = "app_scene_cost_standard_detail-分页列表查询")
52 52
     @ApiOperation(value = "app_scene_cost_standard_detail-分页列表查询", notes = "app_scene_cost_standard_detail-分页列表查询")
53 53
     @GetMapping(value = "/list")
54
-    public Result<IPage<AppSceneCostStandardResultVO>> queryPageList(AppSceneCostStandardResult appSceneCostStandardResult, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
54
+    public Result<IPage<AppSceneCostStandardResult>> queryPageList(AppSceneCostStandardResult appSceneCostStandardResult, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
55
+        if(appSceneCostStandardResult.getVersionNumber()==null){
56
+            appSceneCostStandardResult.setVersionNumber(" ");
57
+        }
55 58
         QueryWrapper<AppSceneCostStandardResult> queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostStandardResult, req.getParameterMap());
59
+        queryWrapper.orderByAsc("layer");
56 60
         Page<AppSceneCostStandardResult> page = new Page<AppSceneCostStandardResult>(pageNo, pageSize);
57 61
         IPage<AppSceneCostStandardResult> pageList = appSceneCostStandardResultService.page(page, queryWrapper);
58
-        IPage<AppSceneCostStandardResultVO> newpageList = new Page<>();
59
-        BeanUtils.copyProperties(pageList, newpageList);
60
-        List<AppSceneCostStandardResult> list = pageList.getRecords();
61
-        List<AppSceneCostStandardResultVO> newList = new ArrayList<>();
62
-        for (int i = 0; i < list.size(); i++) {
63
-            AppSceneCostStandardResult result = list.get(i);
64
-            AppSceneCostStandardResultVO costStandardDetail = AppSceneCostStandardResultVO.builder()
65
-                    .materialNumber(result.getMaterialNumber())
66
-//                    .materialName(oldAppSceneCostResultValue.getMarterialNo())
67
-                    .parentMaterialNumber(result.getParentMatnr())
68
-                    .versionNumber(result.getVersionNumber())
69
-//                    .level()
70
-//                    .sort()
71
-//                    .figureNumber()
72
-//                    .dosage(oldAppSceneCostResultValue.getNum() != null ? new Double(oldAppSceneCostResultValue.getNum()) : 0)
73
-//                    .unit(oldAppSceneCostResultValue.getUnit())
74
-                    .materialCost(result.getMaterialCostStage())
75
-                    .laborCost(result.getLaborCostStage())
76
-                    .equipmentCost(result.getEquipCostStage())
77
-                    .supplyMaterialCost(result.getAuxiliaryCostStage())
78
-                    .driveCost(result.getBurningCostStage())
79
-                    .logisticsCost(result.getStageLogisticsCost())
80
-                    .otherCost(result.getOtherCostStage())
81
-                    .currentStandardCost(result.getTotalStandardCostInter())
82
-                    .totalMaterialCost(result.getMaterialCostAccumulated())
83
-                    .totalLaborCost(result.getLaborCostAccumulated())
84
-                    .totalEquipmentCost(result.getEquipCostAccumulated())
85
-                    .totalSupplyMaterialCost(result.getAuxiliaryCostAccumulated())
86
-                    .totalDriveCost(result.getBurningCostAccumulated())
87
-                    .totalLogisticsCost(result.getTotalLogisticsCost())
88
-                    .totalOtherCost(result.getOtherCostAccumulated())
89
-                    .totalStandardCost(result.getTotalStandardCost())
90
-                    .createTime(result.getCreatedTime()).build();
91
-            newList.add(costStandardDetail);
92
-        }
93
-        newpageList.setRecords(newList);
94
-        return Result.OK(newpageList);
62
+//        IPage<AppSceneCostStandardResultVO> newpageList = new Page<>();
63
+//        BeanUtils.copyProperties(pageList, newpageList);
64
+//        List<AppSceneCostStandardResult> list = pageList.getRecords();
65
+//        List<AppSceneCostStandardResultVO> newList = new ArrayList<>();
66
+//        for (int i = 0; i < list.size(); i++) {
67
+//            AppSceneCostStandardResult result = list.get(i);
68
+//            AppSceneCostStandardResultVO costStandardDetail = AppSceneCostStandardResultVO.builder()
69
+//                    .materialNumber(result.getMaterialNumber())
70
+////                    .materialName(oldAppSceneCostResultValue.getMarterialNo())
71
+//                    .parentMaterialNumber(result.getParentMatnr())
72
+//                    .versionNumber(result.getVersionNumber())
73
+////                    .level()
74
+////                    .sort()
75
+////                    .figureNumber()
76
+////                    .dosage(oldAppSceneCostResultValue.getNum() != null ? new Double(oldAppSceneCostResultValue.getNum()) : 0)
77
+////                    .unit(oldAppSceneCostResultValue.getUnit())
78
+//                    .materialCost(result.getMaterialCostStage())
79
+//                    .laborCost(result.getLaborCostStage())
80
+//                    .equipmentCost(result.getEquipCostStage())
81
+//                    .supplyMaterialCost(result.getAuxiliaryCostStage())
82
+//                    .driveCost(result.getBurningCostStage())
83
+//                    .otherCost(result.getOtherCostStage())
84
+//                    .currentStandardCost(result.getTotalStandardCost())
85
+//                    .totalMaterialCost(result.getMaterialCostAccumulated())
86
+//                    .totalLaborCost(result.getLaborCostAccumulated())
87
+//                    .totalEquipmentCost(result.getEquipCostAccumulated())
88
+//                    .totalSupplyMaterialCost(result.getAuxiliaryCostAccumulated())
89
+//                    .totalDriveCost(result.getBurningCostAccumulated())
90
+//                    .totalOtherCost(result.getOtherCostAccumulated())
91
+//                    .totalStandardCost(result.getTotalStandardCost())
92
+//                    .createTime(result.getCreatedTime()).build();
93
+//            newList.add(costStandardDetail);
94
+//        }
95
+//        newpageList.setRecords(newList);
96
+        return Result.OK(pageList);
95 97
     }
96 98
 //
97 99
 //    /**

+ 111
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostMaterial.java Parādīt failu

@@ -0,0 +1,111 @@
1
+package com.zzsmart.qomo.kn.cost.manage.entity;
2
+
3
+import java.io.Serializable;
4
+import java.io.UnsupportedEncodingException;
5
+import java.util.Date;
6
+import java.math.BigDecimal;
7
+import com.baomidou.mybatisplus.annotation.IdType;
8
+import com.baomidou.mybatisplus.annotation.TableId;
9
+import com.baomidou.mybatisplus.annotation.TableName;
10
+import com.baomidou.mybatisplus.annotation.TableLogic;
11
+import lombok.Data;
12
+import com.fasterxml.jackson.annotation.JsonFormat;
13
+import org.springframework.format.annotation.DateTimeFormat;
14
+import org.jeecgframework.poi.excel.annotation.Excel;
15
+import org.jeecg.common.aspect.annotation.Dict;
16
+import io.swagger.annotations.ApiModel;
17
+import io.swagger.annotations.ApiModelProperty;
18
+import lombok.EqualsAndHashCode;
19
+import lombok.experimental.Accessors;
20
+
21
+/**
22
+ * @Description: app_scene_cost_material
23
+ * @Author: jeecg-boot
24
+ * @Date:   2024-09-17
25
+ * @Version: V1.0
26
+ */
27
+@Data
28
+@TableName("app_scene_cost_material")
29
+@Accessors(chain = true)
30
+@EqualsAndHashCode(callSuper = false)
31
+@ApiModel(value="app_scene_cost_material对象", description="app_scene_cost_material")
32
+public class AppSceneCostMaterial implements Serializable {
33
+    private static final long serialVersionUID = 1L;
34
+
35
+	/**工厂*/
36
+	@Excel(name = "工厂", width = 15)
37
+    @ApiModelProperty(value = "工厂")
38
+    private String factory;
39
+	/**物料号*/
40
+	@Excel(name = "物料号", width = 15)
41
+    @ApiModelProperty(value = "物料号")
42
+    private String materialNumber;
43
+	/**materialType*/
44
+	@Excel(name = "materialType", width = 15)
45
+    @ApiModelProperty(value = "materialType")
46
+    private String materialType;
47
+	/**productCategory*/
48
+	@Excel(name = "productCategory", width = 15)
49
+    @ApiModelProperty(value = "productCategory")
50
+    private String productCategory;
51
+	/**物料名称*/
52
+	@Excel(name = "物料名称", width = 15)
53
+    @ApiModelProperty(value = "物料名称")
54
+    private String productName;
55
+	/**norms*/
56
+	@Excel(name = "norms", width = 15)
57
+    @ApiModelProperty(value = "norms")
58
+    private String norms;
59
+	/**生产类型*/
60
+	@Excel(name = "生产类型", width = 15)
61
+    @ApiModelProperty(value = "生产类型")
62
+    private String manufacturingType;
63
+	/**inventoryUnit*/
64
+	@Excel(name = "inventoryUnit", width = 15)
65
+    @ApiModelProperty(value = "inventoryUnit")
66
+    private String inventoryUnit;
67
+	/**purchasingUnit*/
68
+	@Excel(name = "purchasingUnit", width = 15)
69
+    @ApiModelProperty(value = "purchasingUnit")
70
+    private String purchasingUnit;
71
+	/**老物料组*/
72
+	@Excel(name = "老物料组", width = 15)
73
+    @ApiModelProperty(value = "老物料组")
74
+    private String oldMaterialGroup;
75
+	/**standardCost*/
76
+	@Excel(name = "standardCost", width = 15)
77
+    @ApiModelProperty(value = "standardCost")
78
+    private String standardCost;
79
+	/**abcLevel*/
80
+	@Excel(name = "abcLevel", width = 15)
81
+    @ApiModelProperty(value = "abcLevel")
82
+    private String abcLevel;
83
+	/**effectiveState*/
84
+	@Excel(name = "effectiveState", width = 15)
85
+    @ApiModelProperty(value = "effectiveState")
86
+    private String effectiveState;
87
+	/**profitCenter*/
88
+	@Excel(name = "profitCenter", width = 15)
89
+    @ApiModelProperty(value = "profitCenter")
90
+    private String profitCenter;
91
+	/**iswbs*/
92
+	@Excel(name = "iswbs", width = 15)
93
+    @ApiModelProperty(value = "iswbs")
94
+    private String iswbs;
95
+	/**图号*/
96
+	@Excel(name = "图号", width = 15)
97
+    @ApiModelProperty(value = "图号")
98
+    private String graphNumber;
99
+	/**mtbez*/
100
+	@Excel(name = "mtbez", width = 15)
101
+    @ApiModelProperty(value = "mtbez")
102
+    private String mtbez;
103
+	/**wgbez*/
104
+	@Excel(name = "wgbez", width = 15)
105
+    @ApiModelProperty(value = "wgbez")
106
+    private String wgbez;
107
+	/**sobsl*/
108
+	@Excel(name = "sobsl", width = 15)
109
+    @ApiModelProperty(value = "sobsl")
110
+    private String sobsl;
111
+}

+ 70
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java Parādīt failu

@@ -134,4 +134,74 @@ public class AppSceneCostResultValue implements Serializable {
134 134
     @Excel(name = "工时", width = 15)
135 135
     @ApiModelProperty(value = "工时")
136 136
     private BigDecimal hour;
137
+    /**
138
+     * 工时
139
+     */
140
+    @Excel(name = "BOM深度", width = 15)
141
+    @ApiModelProperty(value = "BOM深度")
142
+    private int depth;
143
+    /**
144
+     * 工时
145
+     */
146
+    @Excel(name = "父物料数量", width = 15)
147
+    @ApiModelProperty(value = "父物料数量")
148
+    private BigDecimal pnum;
149
+    /**
150
+     * 工时
151
+     */
152
+    @Excel(name = "基于最上层物料的用量", width = 15)
153
+    @ApiModelProperty(value = "基于最上层物料的用量")
154
+    private BigDecimal topnum;
155
+    /**
156
+     * 工时
157
+     */
158
+    @Excel(name = "价格类型", width = 15)
159
+    @ApiModelProperty(value = "价格类型")
160
+    private String priceType;
161
+    /**
162
+     * 工时
163
+     */
164
+    @Excel(name = "制造类型", width = 15)
165
+    @ApiModelProperty(value = "制造类型")
166
+    private String manuType;
167
+    /**
168
+     * 工时
169
+     */
170
+    @Excel(name = "材料", width = 15)
171
+    @ApiModelProperty(value = "材料")
172
+    private BigDecimal material;
173
+    /**
174
+     * 工时
175
+     */
176
+    @Excel(name = "人工", width = 15)
177
+    @ApiModelProperty(value = "人工")
178
+    private BigDecimal labor;
179
+    /**
180
+     * 工时
181
+     */
182
+    @Excel(name = "设备", width = 15)
183
+    @ApiModelProperty(value = "设备")
184
+    private BigDecimal equip;
185
+    /**
186
+     * 工时
187
+     */
188
+    @Excel(name = "燃动", width = 15)
189
+    @ApiModelProperty(value = "燃动")
190
+    private BigDecimal fuel;
191
+    /**
192
+     * 工时
193
+     */
194
+    @Excel(name = "辅料", width = 15)
195
+    @ApiModelProperty(value = "辅料")
196
+    private BigDecimal auxi;
197
+    /**
198
+     * 工时
199
+     */
200
+    @Excel(name = "其他", width = 15)
201
+    @ApiModelProperty(value = "其他")
202
+    private BigDecimal other;
203
+
204
+    @Excel(name = "层级", width = 15)
205
+    @ApiModelProperty(value = "层级")
206
+    private String layer;
137 207
 }

+ 162
- 336
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostStandardResult.java Parādīt failu

@@ -10,6 +10,7 @@ import lombok.Builder;
10 10
 import lombok.Data;
11 11
 import lombok.EqualsAndHashCode;
12 12
 import lombok.experimental.Accessors;
13
+import org.jeecgframework.poi.excel.annotation.Excel;
13 14
 import org.springframework.format.annotation.DateTimeFormat;
14 15
 
15 16
 import javax.persistence.Column;
@@ -18,348 +19,173 @@ import java.math.BigDecimal;
18 19
 import java.util.Date;
19 20
 
20 21
 
22
+/**
23
+ * @Description: app_scene_cost_standard_result
24
+ * @Author: jeecg-boot
25
+ * @Date:   2024-09-17
26
+ * @Version: V1.0
27
+ */
21 28
 @Data
22 29
 @Builder
23 30
 @TableName("app_scene_cost_standard_result")
24 31
 @Accessors(chain = true)
25 32
 @EqualsAndHashCode(callSuper = false)
26
-@ApiModel(value = "标准成本单行", description = "标准成本单行")
33
+@ApiModel(value="app_scene_cost_standard_result对象", description="app_scene_cost_standard_result")
27 34
 public class AppSceneCostStandardResult implements Serializable {
28
-
29 35
     private static final long serialVersionUID = 1L;
30 36
 
31
-
32
-    /**
33
-     * 主键
34
-     */
35
-    @TableId(type = IdType.AUTO)
36
-    @ApiModelProperty(value = "id")
37
-    private Integer id;
38
-
39
-    /**
40
-     * 工厂
41
-     */
42
-    @Column(name = "factory")
43
-    private String factory;
44
-
45
-    /**
46
-     * 物料号
47
-     */
48
-    @Column(name = "material_number")
49
-    private String materialNumber;
50
-
51
-    /**
52
-     * 父物料号
53
-     */
54
-    @Column(name = "parent_matnr")
55
-    private String parentMatnr;
56
-
57
-    /**
58
-     * 阶段
59
-     */
60
-    @Column(name = "stage")
61
-    private String stage;
62
-
63
-    /**
64
-     * 版本号
65
-     */
66
-    @Column(name = "version_number")
67
-    private String versionNumber;
68
-
69
-    /**
70
-     * 层级
71
-     */
72
-    @Column(name = "layer")
73
-    private String layer;
74
-
75
-    /**
76
-     * 价格类型
77
-     */
78
-    @Column(name = "pricetype")
79
-    private String pricetype;
80
-
81
-    /**
82
-     * 会计期间
83
-     */
84
-    @Column(name = "ymonth")
85
-    private String ymonth;
86
-
87
-    /**
88
-     * 本阶标准成本
89
-     */
90
-    @Column(name = "total_standard_cost_inter")
91
-    private BigDecimal totalStandardCostInter;
92
-
93
-    /**
94
-     * 累计标准成本
95
-     */
96
-    @Column(name = "total_standard_cost")
97
-    private BigDecimal totalStandardCost;
98
-
99
-    /**
100
-     * material_cost_stage_inter
101
-     */
102
-    @Column(name = "material_cost_stage_inter")
103
-    private BigDecimal materialCostStageInter;
104
-
105
-    /**
106
-     * 本阶物料成本
107
-     */
108
-    @Column(name = "material_cost_stage")
109
-    private BigDecimal materialCostStage;
110
-
111
-    /**
112
-     * 本阶人工成本
113
-     */
114
-    @Column(name = "labor_cost_stage")
115
-    private BigDecimal laborCostStage;
116
-
117
-    /**
118
-     * 本阶设备费
119
-     */
120
-    @Column(name = "equip_cost_stage")
121
-    private BigDecimal equipCostStage;
122
-
123
-    /**
124
-     * 本阶燃动费
125
-     */
126
-    @Column(name = "burning_cost_stage")
127
-    private BigDecimal burningCostStage;
128
-
129
-    /**
130
-     * 本阶辅料费
131
-     */
132
-    @Column(name = "auxiliary_cost_stage")
133
-    private BigDecimal auxiliaryCostStage;
134
-
135
-    /**
136
-     * 本阶其他费
137
-     */
138
-    @Column(name = "other_cost_stage")
139
-    private BigDecimal otherCostStage;
140
-
141
-    /**
142
-     * 本阶物流费
143
-     */
144
-    @Column(name = "stage_logistics_cost")
145
-    private BigDecimal stageLogisticsCost;
146
-
147
-    /**
148
-     * material_cost_accumulated_inter
149
-     */
150
-    @Column(name = "material_cost_accumulated_inter")
151
-    private BigDecimal materialCostAccumulatedInter;
152
-
153
-    /**
154
-     * 累计物料
155
-     */
156
-    @Column(name = "material_cost_accumulated")
157
-    private BigDecimal materialCostAccumulated;
158
-
159
-    /**
160
-     * 累计人工成本
161
-     */
162
-    @Column(name = "labor_cost_accumulated")
163
-    private BigDecimal laborCostAccumulated;
164
-
165
-    /**
166
-     * 累计设备费
167
-     */
168
-    @Column(name = "equip_cost_accumulated")
169
-    private BigDecimal equipCostAccumulated;
170
-
171
-    /**
172
-     * 累计燃动费
173
-     */
174
-    @Column(name = "burning_cost_accumulated")
175
-    private BigDecimal burningCostAccumulated;
176
-
177
-    /**
178
-     * 累计辅料费
179
-     */
180
-    @Column(name = "auxiliary_cost_accumulated")
181
-    private BigDecimal auxiliaryCostAccumulated;
182
-
183
-    /**
184
-     * 累计其他费
185
-     */
186
-    @Column(name = "other_cost_accumulated")
187
-    private BigDecimal otherCostAccumulated;
188
-
189
-    /**
190
-     * 累计物流费
191
-     */
192
-    @Column(name = "total_logistics_cost")
193
-    private BigDecimal totalLogisticsCost;
194
-
195
-    /**
196
-     * material_cost_total_inter
197
-     */
198
-    @Column(name = "material_cost_total_inter")
199
-    private BigDecimal materialCostTotalInter;
200
-
201
-    /**
202
-     * material_cost_total
203
-     */
204
-    @Column(name = "material_cost_total")
205
-    private BigDecimal materialCostTotal;
206
-
207
-    /**
208
-     * labor_cost_total
209
-     */
210
-    @Column(name = "labor_cost_total")
211
-    private BigDecimal laborCostTotal;
212
-
213
-    /**
214
-     * equip_cost_total
215
-     */
216
-    @Column(name = "equip_cost_total")
217
-    private BigDecimal equipCostTotal;
218
-
219
-    /**
220
-     * burning_cost_total
221
-     */
222
-    @Column(name = "burning_cost_total")
223
-    private BigDecimal burningCostTotal;
224
-
225
-    /**
226
-     * auxiliary_cost_total
227
-     */
228
-    @Column(name = "auxiliary_cost_total")
229
-    private BigDecimal auxiliaryCostTotal;
230
-
231
-    /**
232
-     * other_cost_total
233
-     */
234
-    @Column(name = "other_cost_total")
235
-    private BigDecimal otherCostTotal;
236
-
237
-    /**
238
-     * low_order_code
239
-     */
240
-    @Column(name = "low_order_code")
241
-    private String lowOrderCode;
242
-
243
-    /**
244
-     * relative_dosage
245
-     */
246
-    @Column(name = "relative_dosage")
247
-    private BigDecimal relativeDosage;
248
-
249
-    /**
250
-     * material_cost_relative
251
-     */
252
-    @Column(name = "material_cost_relative")
253
-    private BigDecimal materialCostRelative;
254
-
255
-    /**
256
-     * material_cost_relative_inter
257
-     */
258
-    @Column(name = "material_cost_relative_inter")
259
-    private BigDecimal materialCostRelativeInter;
260
-
261
-    /**
262
-     * labor_cost_relative
263
-     */
264
-    @Column(name = "labor_cost_relative")
265
-    private BigDecimal laborCostRelative;
266
-
267
-    /**
268
-     * manufacture_cost_relative
269
-     */
270
-    @Column(name = "manufacture_cost_relative")
271
-    private BigDecimal manufactureCostRelative;
272
-
273
-    /**
274
-     * total_cost_relative
275
-     */
276
-    @Column(name = "total_cost_relative")
277
-    private BigDecimal totalCostRelative;
278
-
279
-    /**
280
-     * total_cost_relative_inter
281
-     */
282
-    @Column(name = "total_cost_relative_inter")
283
-    private BigDecimal totalCostRelativeInter;
284
-
285
-    /**
286
-     * material_cost_stage_material
287
-     */
288
-    @Column(name = "material_cost_stage_material")
289
-    private BigDecimal materialCostStageMaterial;
290
-
291
-    /**
292
-     * material_cost_stage_edcu
293
-     */
294
-    @Column(name = "material_cost_stage_edcu")
295
-    private BigDecimal materialCostStageEdcu;
296
-
297
-    /**
298
-     * material_cost_stage_em
299
-     */
300
-    @Column(name = "material_cost_stage_em")
301
-    private BigDecimal materialCostStageEm;
302
-
303
-    /**
304
-     * material_cost_stage_inter_material
305
-     */
306
-    @Column(name = "material_cost_stage_inter_material")
307
-    private BigDecimal materialCostStageInterMaterial;
308
-
309
-    /**
310
-     * material_cost_stage_inter_edcu
311
-     */
312
-    @Column(name = "material_cost_stage_inter_edcu")
313
-    private BigDecimal materialCostStageInterEdcu;
314
-
315
-    /**
316
-     * material_cost_stage_inter_em
317
-     */
318
-    @Column(name = "material_cost_stage_inter_em")
319
-    private BigDecimal materialCostStageInterEm;
320
-
321
-    /**
322
-     * material_cost_accumulated_material
323
-     */
324
-    @Column(name = "material_cost_accumulated_material")
325
-    private BigDecimal materialCostAccumulatedMaterial;
326
-
327
-    /**
328
-     * material_cost_accumulated_edcu
329
-     */
330
-    @Column(name = "material_cost_accumulated_edcu")
331
-    private BigDecimal materialCostAccumulatedEdcu;
332
-
333
-    /**
334
-     * material_cost_accumulated_em
335
-     */
336
-    @Column(name = "material_cost_accumulated_em")
337
-    private BigDecimal materialCostAccumulatedEm;
338
-
339
-    /**
340
-     * material_cost_accumulated_inter_material
341
-     */
342
-    @Column(name = "material_cost_accumulated_inter_material")
343
-    private BigDecimal materialCostAccumulatedInterMaterial;
344
-
345
-    /**
346
-     * material_cost_accumulated_inter_edcu
347
-     */
348
-    @Column(name = "material_cost_accumulated_inter_edcu")
349
-    private BigDecimal materialCostAccumulatedInterEdcu;
350
-
351
-    /**
352
-     * material_cost_accumulated_inter_em
353
-     */
354
-    @Column(name = "material_cost_accumulated_inter_em")
355
-    private BigDecimal materialCostAccumulatedInterEm;
356
-
357
-    /**
358
-     * 创建时间
359
-     */
360
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
361
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
362
-    @ApiModelProperty(value = "修改日期")
363
-    private Date createdTime;
364
-
37
+    /**主键*/
38
+    @TableId(type = IdType.ASSIGN_ID)
39
+    @ApiModelProperty(value = "主键")
40
+    private java.lang.Integer id;
41
+    /**工厂*/
42
+    @Excel(name = "工厂", width = 15)
43
+    @ApiModelProperty(value = "工厂")
44
+    private java.lang.String factory;
45
+    /**物料号*/
46
+    @Excel(name = "物料号", width = 15)
47
+    @ApiModelProperty(value = "物料号")
48
+    private java.lang.String materialNumber;
49
+    /**父物料号*/
50
+    @Excel(name = "父物料号", width = 15)
51
+    @ApiModelProperty(value = "父物料号")
52
+    private java.lang.String parentMatnr;
53
+    /**阶段*/
54
+    @Excel(name = "阶段", width = 15)
55
+    @ApiModelProperty(value = "阶段")
56
+    private java.lang.String stage;
57
+    /**版本号*/
58
+    @Excel(name = "版本号", width = 15)
59
+    @ApiModelProperty(value = "版本号")
60
+    private java.lang.String versionNumber;
61
+    /**层级*/
62
+    @Excel(name = "层级", width = 15)
63
+    @ApiModelProperty(value = "层级")
64
+    private java.lang.String layer;
65
+    /**价格类型*/
66
+    @Excel(name = "价格类型", width = 15)
67
+    @ApiModelProperty(value = "价格类型")
68
+    private java.lang.String pricetype;
69
+    /**会计期间*/
70
+    @Excel(name = "会计期间", width = 15)
71
+    @ApiModelProperty(value = "会计期间")
72
+    private java.lang.String ymonth;
73
+    /**总标准成本*/
74
+    @Excel(name = "总标准成本", width = 15)
75
+    @ApiModelProperty(value = "总标准成本")
76
+    private java.math.BigDecimal totalStandardCost;
77
+    /**本阶材料成本*/
78
+    @Excel(name = "本阶材料成本", width = 15)
79
+    @ApiModelProperty(value = "本阶材料成本")
80
+    private java.math.BigDecimal materialCostStage;
81
+    /**本阶人工成本*/
82
+    @Excel(name = "本阶人工成本", width = 15)
83
+    @ApiModelProperty(value = "本阶人工成本")
84
+    private java.math.BigDecimal laborCostStage;
85
+    /**本阶设备成本*/
86
+    @Excel(name = "本阶设备成本", width = 15)
87
+    @ApiModelProperty(value = "本阶设备成本")
88
+    private java.math.BigDecimal equipCostStage;
89
+    /**本阶燃动成本*/
90
+    @Excel(name = "本阶燃动成本", width = 15)
91
+    @ApiModelProperty(value = "本阶燃动成本")
92
+    private java.math.BigDecimal burningCostStage;
93
+    /**本阶辅料成本*/
94
+    @Excel(name = "本阶辅料成本", width = 15)
95
+    @ApiModelProperty(value = "本阶辅料成本")
96
+    private java.math.BigDecimal auxiliaryCostStage;
97
+    /**本阶其他成本*/
98
+    @Excel(name = "本阶其他成本", width = 15)
99
+    @ApiModelProperty(value = "本阶其他成本")
100
+    private java.math.BigDecimal otherCostStage;
101
+    /**累计材料成本*/
102
+    @Excel(name = "累计材料成本", width = 15)
103
+    @ApiModelProperty(value = "累计材料成本")
104
+    private java.math.BigDecimal materialCostAccumulated;
105
+    /**累计人工成本*/
106
+    @Excel(name = "累计人工成本", width = 15)
107
+    @ApiModelProperty(value = "累计人工成本")
108
+    private java.math.BigDecimal laborCostAccumulated;
109
+    /**累计设备成本*/
110
+    @Excel(name = "累计设备成本", width = 15)
111
+    @ApiModelProperty(value = "累计设备成本")
112
+    private java.math.BigDecimal equipCostAccumulated;
113
+    /**累计燃动成本*/
114
+    @Excel(name = "累计燃动成本", width = 15)
115
+    @ApiModelProperty(value = "累计燃动成本")
116
+    private java.math.BigDecimal burningCostAccumulated;
117
+    /**累计辅料成本*/
118
+    @Excel(name = "累计辅料成本", width = 15)
119
+    @ApiModelProperty(value = "累计辅料成本")
120
+    private java.math.BigDecimal auxiliaryCostAccumulated;
121
+    /**累计其他成本*/
122
+    @Excel(name = "累计其他成本", width = 15)
123
+    @ApiModelProperty(value = "累计其他成本")
124
+    private java.math.BigDecimal otherCostAccumulated;
125
+    /**总材料成本*/
126
+    @Excel(name = "总材料成本", width = 15)
127
+    @ApiModelProperty(value = "总材料成本")
128
+    private java.math.BigDecimal materialCostTotal;
129
+    /**总人工成本*/
130
+    @Excel(name = "总人工成本", width = 15)
131
+    @ApiModelProperty(value = "总人工成本")
132
+    private java.math.BigDecimal laborCostTotal;
133
+    /**总设备成本*/
134
+    @Excel(name = "总设备成本", width = 15)
135
+    @ApiModelProperty(value = "总设备成本")
136
+    private java.math.BigDecimal equipCostTotal;
137
+    /**总燃动成本*/
138
+    @Excel(name = "总燃动成本", width = 15)
139
+    @ApiModelProperty(value = "总燃动成本")
140
+    private java.math.BigDecimal burningCostTotal;
141
+    /**总辅料成本*/
142
+    @Excel(name = "总辅料成本", width = 15)
143
+    @ApiModelProperty(value = "总辅料成本")
144
+    private java.math.BigDecimal auxiliaryCostTotal;
145
+    /**总其他成本*/
146
+    @Excel(name = "总其他成本", width = 15)
147
+    @ApiModelProperty(value = "总其他成本")
148
+    private java.math.BigDecimal otherCostTotal;
149
+    /**低阶码*/
150
+    @Excel(name = "低阶码", width = 15)
151
+    @ApiModelProperty(value = "低阶码")
152
+    private java.lang.String lowOrderCode;
153
+    /**相对用量*/
154
+    @Excel(name = "相对用量", width = 15)
155
+    @ApiModelProperty(value = "相对用量")
156
+    private java.math.BigDecimal relativeDosage;
157
+    /**相对材料成本*/
158
+    @Excel(name = "相对材料成本", width = 15)
159
+    @ApiModelProperty(value = "相对材料成本")
160
+    private java.math.BigDecimal materialCostRelative;
161
+    /**相对人工成本*/
162
+    @Excel(name = "相对人工成本", width = 15)
163
+    @ApiModelProperty(value = "相对人工成本")
164
+    private java.math.BigDecimal laborCostRelative;
165
+    /**相对制费成本*/
166
+    @Excel(name = "相对制费成本", width = 15)
167
+    @ApiModelProperty(value = "相对制费成本")
168
+    private java.math.BigDecimal manufactureCostRelative;
169
+    /**相对总成本*/
170
+    @Excel(name = "相对总成本", width = 15)
171
+    @ApiModelProperty(value = "相对总成本")
172
+    private java.math.BigDecimal totalCostRelative;
173
+    /**创建时间*/
174
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
175
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
176
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
177
+    @ApiModelProperty(value = "创建时间")
178
+    private java.util.Date createdTime;
179
+    /**物料描述*/
180
+    @Excel(name = "物料描述", width = 15)
181
+    @ApiModelProperty(value = "物料描述")
182
+    private java.lang.String maktx;
183
+    /**数量*/
184
+    @Excel(name = "数量", width = 15)
185
+    @ApiModelProperty(value = "数量")
186
+    private java.math.BigDecimal menge;
187
+    /**数量*/
188
+    @Excel(name = "制造类型", width = 15)
189
+    @ApiModelProperty(value = "制造类型")
190
+    private java.lang.String manuType;
365 191
 }

+ 5
- 4
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostBomRelevancyMapper.java Parādīt failu

@@ -3,6 +3,7 @@ package com.zzsmart.qomo.kn.cost.manage.mapper;
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostBomRelevancy;
6
+import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo;
6 7
 import org.apache.ibatis.annotations.Param;
7 8
 import org.apache.ibatis.annotations.Select;
8 9
 
@@ -16,16 +17,16 @@ import java.util.List;
16 17
  */
17 18
 public interface AppSceneCostBomRelevancyMapper extends BaseMapper<AppSceneCostBomRelevancy> {
18 19
     @Select("WITH RECURSIVE BOM_Tree AS (\n" +
19
-            "    SELECT  matnr, idnrk, meins, 0 AS depth\n" +
20
+            "    SELECT  matnr, idnrk, menge/bmeng as menge,1.000000 as pmenge,1.000000 as topmenge, 1 AS depth\n" +
20 21
                     "    FROM app_scene_cost_bom_relevancy\n" +
21 22
                     "    WHERE matnr = #{parentId}\n" +
22 23
                     "    UNION ALL\n" +
23
-                    "    SELECT b.matnr, b.idnrk, b.meins, BOM_Tree.depth + 1\n" +
24
+                    "    SELECT b.matnr, b.idnrk, b.menge/b.bmeng as menge, BOM_Tree.menge as pmenge,BOM_Tree.menge*(b.menge/b.bmeng) AS topmenge,BOM_Tree.depth + 1\n" +
24 25
                     "    FROM app_scene_cost_bom_relevancy b\n" +
25 26
                     "    JOIN BOM_Tree ON b.matnr = BOM_Tree.idnrk\n" +
26 27
                     ")\n" +
27
-                    "SELECT matnr, idnrk, meins, depth FROM BOM_Tree")
28
-    List<AppSceneCostBomRelevancy> findChildrenByParentId(String parentId);
28
+                    "SELECT matnr, idnrk, menge,pmenge,topmenge, depth FROM BOM_Tree")
29
+    List<BomTreeVo> findChildrenByParentId(String parentId);
29 30
 
30 31
 
31 32
     @Select("${selectSql}")

+ 18
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostMaterialMapper.java Parādīt failu

@@ -0,0 +1,18 @@
1
+package com.zzsmart.qomo.kn.cost.manage.mapper;
2
+
3
+import java.util.List;
4
+
5
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial;
6
+import org.apache.ibatis.annotations.Param;
7
+//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial;
8
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
9
+
10
+/**
11
+ * @Description: app_scene_cost_material
12
+ * @Author: jeecg-boot
13
+ * @Date:   2024-09-17
14
+ * @Version: V1.0
15
+ */
16
+public interface AppSceneCostMaterialMapper extends BaseMapper<AppSceneCostMaterial> {
17
+
18
+}

+ 5
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/xml/AppSceneCostMaterialMapper.xml Parādīt failu

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.zzsmart.qomo.modules.demo..mapper.AppSceneCostMaterialMapper">
4
+
5
+</mapper>

+ 432
- 168
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java Parādīt failu

@@ -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
             //更新结果集到标准成本单行查询中去

+ 2
- 1
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostBomRelevancyService.java Parādīt failu

@@ -2,6 +2,7 @@ package com.zzsmart.qomo.kn.cost.manage.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostBomRelevancy;
5
+import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo;
5 6
 
6 7
 import java.util.List;
7 8
 
@@ -24,6 +25,6 @@ public interface IAppSceneCostBomRelevancyService extends IService<AppSceneCostB
24 25
      * @param topMaterialCode
25 26
      * @return
26 27
      */
27
-    List<AppSceneCostBomRelevancy> queryAllBomInfoByTopMaterialCode(String topMaterialCode);
28
+    List<BomTreeVo> queryAllBomInfoByTopMaterialCode(String topMaterialCode);
28 29
 
29 30
 }

+ 3
- 1
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostHourRateService.java Parādīt failu

@@ -3,6 +3,8 @@ package com.zzsmart.qomo.kn.cost.manage.service;
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostHourRate;
5 5
 
6
+import java.util.Map;
7
+
6 8
 /**
7 9
  * @Description: app_scene_cost_hour_rate
8 10
  * @Author: jeecg-boot
@@ -15,5 +17,5 @@ public interface IAppSceneCostHourRateService extends IService<AppSceneCostHourR
15 17
      * @param appSceneCostHourRate
16 18
      * @return
17 19
      */
18
-    AppSceneCostHourRate getOneHourRateInfo(AppSceneCostHourRate appSceneCostHourRate);
20
+    Map<String,AppSceneCostHourRate> getOneHourRateInfo();
19 21
 }

+ 21
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostMaterialService.java Parādīt failu

@@ -0,0 +1,21 @@
1
+package com.zzsmart.qomo.kn.cost.manage.service;
2
+
3
+//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+/**
11
+ * @Description: app_scene_cost_material
12
+ * @Author: jeecg-boot
13
+ * @Date:   2024-09-17
14
+ * @Version: V1.0
15
+ */
16
+public interface IAppSceneCostMaterialService extends IService<AppSceneCostMaterial> {
17
+
18
+    public Map<String, String> getManuTypeByMaterialNo(List<String> materialNos) ;
19
+
20
+    public Map<String, String> getMaktxByMaterialNo(List<String> materialNos) ;
21
+}

+ 3
- 2
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostBomRelevancyServiceImpl.java Parādīt failu

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostBomRelevancy;
6 6
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostBomRelevancyMapper;
7 7
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostBomRelevancyService;
8
+import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo;
8 9
 import org.springframework.beans.factory.annotation.Autowired;
9 10
 import org.springframework.stereotype.Service;
10 11
 
@@ -51,8 +52,8 @@ public class AppSceneCostBomRelevancyServiceImpl extends ServiceImpl<AppSceneCos
51 52
      * @return
52 53
      */
53 54
     @Override
54
-    public List<AppSceneCostBomRelevancy> queryAllBomInfoByTopMaterialCode(String topMaterialCode) {
55
-        List<AppSceneCostBomRelevancy> childrens = costMaterialBomMapper.findChildrenByParentId(topMaterialCode);
55
+    public List<BomTreeVo> queryAllBomInfoByTopMaterialCode(String topMaterialCode) {
56
+        List<BomTreeVo> childrens = costMaterialBomMapper.findChildrenByParentId(topMaterialCode);
56 57
         //TODO 循环遍历查出所有的物料下的物料(包含最上层的物料)
57 58
         //TODO 所有的物料并进行层级排序
58 59
         return childrens;

+ 20
- 14
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java Parādīt failu

@@ -127,8 +127,9 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
127 127
     @Override
128 128
     public void addCostCountTask(AppSceneCostCountVO appSceneCostCount) {
129 129
         //1.新增版本号记录成功后
130
-        appSceneCostCount.setCostVersion("Version"+String.valueOf(new Random().nextInt(100000)));
130
+        //appSceneCostCount.setCostVersion("Version"+String.valueOf(new Random().nextInt(100000)));
131 131
         AppSceneCostStandardVersion costStandardVersion = AppSceneCostStandardVersion.builder().graphicnumber(appSceneCostCount.getDrawingNo()).matnr(appSceneCostCount.getMaterialNo()).stage(appSceneCostCount.getStage()).version(appSceneCostCount.getCostVersion()).versionYear(appSceneCostCount.getYear()).build();
132
+        costStandardVersion.setCreatedtime(new Date());
132 133
         boolean save = costStandardVersionService.save(costStandardVersion);
133 134
         //2.新增标准成本计算任务,并立即执行标准成本计算
134 135
         if (save) {
@@ -146,7 +147,7 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
146 147
 //            }
147 148
 
148 149
             // 方案二:直接执行标准成本计算
149
-            countStandardCost(appSceneCostCount, (new Random().nextInt(1000)) + (new Random().nextInt(100)));
150
+            countStandardCost(appSceneCostCount1, (new Random().nextInt(1000)) + (new Random().nextInt(100)));
150 151
         }
151 152
     }
152 153
 
@@ -155,29 +156,34 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl<AppSceneCostCountM
155 156
      *
156 157
      * @param appSceneCostCount1
157 158
      */
158
-    private void countStandardCost(AppSceneCostCountVO appSceneCostCount1, Integer flowInstanceId) {
159
+    private void countStandardCost(AppSceneCostCount appSceneCostCount1, Integer flowInstanceId) {
159 160
         //0.获取物料下所有的子物料
160 161
         StandardCostService.getAllMaterialBomInfoByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "MaterialInput", "MaterialInput001", flowInstanceId);
161 162
         //1.物料成本计算
162 163
         StandardCostService.countMaterialCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "MaterialCost", "MaterialCost002", flowInstanceId, FeeTypeEnum.MaterialCost.getCode());
163 164
         //2.人工成本计算
164
-        AppSceneCostHourRate hourRate = new AppSceneCostHourRate();
165
-        hourRate.setYear(appSceneCostCount1.getYear());
166
-        hourRate.setCostCenterCode(appSceneCostCount1.getCostCenter());
167
-        hourRate.setFactory(appSceneCostCount1.getFactory()==null?"8100":appSceneCostCount1.getFactory());
168
-        StandardCostService.countLaborCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "LaborCost", "LaborCost003", flowInstanceId, FeeTypeEnum.LaborCost.getCode(), hourRate);
165
+        //AppSceneCostHourRate hourRate = new AppSceneCostHourRate();
166
+        //hourRate.setYear(appSceneCostCount1.getYear());
167
+        //hourRate.setCostCenterCode(appSceneCostCount1.getCostCenter());
168
+        //hourRate.setFactory(appSceneCostCount1.getFactory()==null?"7100":appSceneCostCount1.getFactory());
169
+        //StandardCostService.countLaborCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "LaborCost", "LaborCost003", flowInstanceId, FeeTypeEnum.LaborCost.getCode(), hourRate);
169 170
         //3.制造计算(各种费用)MaterialCost("MaterialCost", "物料成本"), EquipmentFee("EquipmentFee", "设备费"), SupplyMaterialFee("SupplyMaterialFee", "辅料费"), DriverFee("DriverFee", "水电费"), OtherFee("OtherFee", "其他费用"), LogisticsFee("LogisticsFee", "物流费")
170 171
        //3.1设备费计算
171
-        StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost004", flowInstanceId, FeeTypeEnum.EquipmentFee.getCode(), hourRate);
172
+        //.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost004", flowInstanceId, FeeTypeEnum.EquipmentFee.getCode(), hourRate);
172 173
        //3.2辅料费计算
173
-        StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost005", flowInstanceId, FeeTypeEnum.SupplyMaterialFee.getCode(), hourRate);
174
+        //StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost005", flowInstanceId, FeeTypeEnum.SupplyMaterialFee.getCode(), hourRate);
174 175
         //3.3水电费
175
-        StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost006", flowInstanceId, FeeTypeEnum.DriverFee.getCode(), hourRate);
176
+        //StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost006", flowInstanceId, FeeTypeEnum.DriverFee.getCode(), hourRate);
176 177
        //3.4其他费用
177
-        StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost007", flowInstanceId, FeeTypeEnum.OtherFee.getCode(), hourRate);
178
+        //StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost007", flowInstanceId, FeeTypeEnum.OtherFee.getCode(), hourRate);
179
+        StandardCostService.countManufacturingCost(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost007", flowInstanceId);
178 180
         //3.5物流费
179
-        StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost008", flowInstanceId, FeeTypeEnum.LogisticsFee.getCode(), hourRate);
181
+        //StandardCostService.countManufacturingCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "ManufacturingCost", "ManufacturingCost008", flowInstanceId, FeeTypeEnum.LogisticsFee.getCode(), hourRate);
180 182
         //4.标准成本本计算
181
-        StandardCostService.countStandardCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "StandardCost", "StandardCost009", flowInstanceId, FeeTypeEnum.StandardCost.getCode(),appSceneCostCount1.getCostVersion());
183
+        StandardCostService.countStandardCostByTopMaterialCode(appSceneCostCount1.getMaterialNo(), "StandardCost", "StandardCost009", flowInstanceId, FeeTypeEnum.StandardCost.getCode(),appSceneCostCount1.getStage(),appSceneCostCount1.getCostVersion());
184
+
185
+        appSceneCostCount1.setStatus(2);
186
+        saveOrUpdate(appSceneCostCount1);
187
+        //upda(AppSceneCostCount.builder().id(appSceneCostCount1.getId()).status(2).build());
182 188
     }
183 189
 }

+ 13
- 14
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostHourRateServiceImpl.java Parādīt failu

@@ -8,6 +8,11 @@ import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostHourRateMapper;
8 8
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostHourRateService;
9 9
 import org.jeecg.common.system.query.QueryGenerator;
10 10
 import org.springframework.stereotype.Service;
11
+import org.ttzero.excel.manager.docProps.App;
12
+
13
+import java.util.HashMap;
14
+import java.util.List;
15
+import java.util.Map;
11 16
 
12 17
 /**
13 18
  * @Description: app_scene_cost_hour_rate
@@ -25,21 +30,15 @@ public class AppSceneCostHourRateServiceImpl extends ServiceImpl<AppSceneCostHou
25 30
      * @return
26 31
      */
27 32
     @Override
28
-    public AppSceneCostHourRate getOneHourRateInfo(AppSceneCostHourRate appSceneCostHourRate) {
29
-        QueryWrapper<AppSceneCostHourRate> queryWrapper = new QueryWrapper<>();
30
-        if(appSceneCostHourRate!=null){
31
-            if(appSceneCostHourRate.getYear()!=null){
32
-                queryWrapper.eq("year",appSceneCostHourRate.getYear());
33
-            }
34
-            if(appSceneCostHourRate.getCostCenterCode()!=null){
35
-                queryWrapper.eq("cost_center_code",appSceneCostHourRate.getCostCenterCode());
36
-            }
37
-            if(appSceneCostHourRate.getFactory()!=null){
38
-                queryWrapper.eq("factory",appSceneCostHourRate.getFactory());
33
+    public Map<String,AppSceneCostHourRate> getOneHourRateInfo() {
34
+        //QueryWrapper<AppSceneCostHourRate> queryWrapper = new QueryWrapper<>();
35
+        List<AppSceneCostHourRate> appSceneCostHourRateList= this.query().list();
36
+        Map<String, AppSceneCostHourRate> map=new HashMap<>();
37
+        for (AppSceneCostHourRate appSceneCostHourRate:appSceneCostHourRateList){
38
+            if(!map.containsKey(appSceneCostHourRate.getCostCenterCode())){
39
+                map.put(appSceneCostHourRate.getCostCenterCode(),appSceneCostHourRate);
39 40
             }
40
-            queryWrapper.last("limit 1");
41
-            return this.getOne(queryWrapper);
42 41
         }
43
-        return null;
42
+        return map;
44 43
     }
45 44
 }

+ 62
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostMaterialServiceImpl.java Parādīt failu

@@ -0,0 +1,62 @@
1
+package com.zzsmart.qomo.kn.cost.manage.service.impl;
2
+
3
+//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial;
4
+//import com.zzsmart.qomo.modules.demo..mapper.AppSceneCostMaterialMapper;
5
+//import com.zzsmart.qomo.modules.demo..service.IAppSceneCostMaterialService;
6
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial;
8
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPurchaseRecord;
9
+import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostMaterialMapper;
10
+import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPurchaseRecordMapper;
11
+import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostMaterialService;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.stereotype.Service;
14
+
15
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
16
+
17
+import java.math.BigDecimal;
18
+import java.util.HashMap;
19
+import java.util.List;
20
+import java.util.Map;
21
+
22
+/**
23
+ * @Description: app_scene_cost_material
24
+ * @Author: jeecg-boot
25
+ * @Date:   2024-09-17
26
+ * @Version: V1.0
27
+ */
28
+@Service
29
+public class AppSceneCostMaterialServiceImpl extends ServiceImpl<AppSceneCostMaterialMapper, AppSceneCostMaterial> implements IAppSceneCostMaterialService {
30
+
31
+    @Autowired
32
+    AppSceneCostMaterialMapper appSceneCostMaterialMapper;
33
+    @Override
34
+    public Map<String, String> getManuTypeByMaterialNo(List<String> materialNos) {
35
+        Map<String, String> map = new HashMap<>();
36
+        QueryWrapper<AppSceneCostMaterial> queryWrapper = new QueryWrapper();
37
+        if (materialNos != null && materialNos.size() > 0) {
38
+            queryWrapper.in("material_number", materialNos);
39
+            List<AppSceneCostMaterial> costPurchasePrices = appSceneCostMaterialMapper.selectList(queryWrapper);
40
+            for (int i = 0; i < costPurchasePrices.size(); i++) {
41
+                AppSceneCostMaterial costPurchasePrice = costPurchasePrices.get(i);
42
+                map.put(costPurchasePrice.getMaterialNumber(), costPurchasePrice.getManufacturingType());
43
+            }
44
+        }
45
+        return map;
46
+    }
47
+
48
+    @Override
49
+    public Map<String, String> getMaktxByMaterialNo(List<String> materialNos) {
50
+        Map<String, String> map = new HashMap<>();
51
+        QueryWrapper<AppSceneCostMaterial> queryWrapper = new QueryWrapper();
52
+        if (materialNos != null && materialNos.size() > 0) {
53
+            queryWrapper.in("material_number", materialNos);
54
+            List<AppSceneCostMaterial> costPurchasePrices = appSceneCostMaterialMapper.selectList(queryWrapper);
55
+            for (int i = 0; i < costPurchasePrices.size(); i++) {
56
+                AppSceneCostMaterial costPurchasePrice = costPurchasePrices.get(i);
57
+                map.put(costPurchasePrice.getMaterialNumber(), costPurchasePrice.getProductName());
58
+            }
59
+        }
60
+        return map;
61
+    }
62
+}

+ 29
- 21
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/BomTreeServiceImpl.java Parādīt failu

@@ -3,7 +3,9 @@ package com.zzsmart.qomo.kn.cost.manage.service.impl;
3 3
 import cn.hutool.core.util.StrUtil;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardDetail;
6
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardResult;
6 7
 import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostStandardDetailMapper;
8
+import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostStandardResultMapper;
7 9
 import com.zzsmart.qomo.kn.cost.manage.service.BomTreeService;
8 10
 import com.zzsmart.qomo.kn.cost.manage.util.BomTreeBuilder;
9 11
 import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO;
@@ -21,6 +23,9 @@ public class BomTreeServiceImpl implements BomTreeService {
21 23
     @Autowired
22 24
     AppSceneCostStandardDetailMapper costStandardDetailMapper;
23 25
 
26
+    @Autowired
27
+    AppSceneCostStandardResultMapper appSceneCostStandardResultMapper;
28
+
24 29
     /**
25 30
      * 根据物料号查询物料树
26 31
      *
@@ -29,7 +34,7 @@ public class BomTreeServiceImpl implements BomTreeService {
29 34
      */
30 35
     @Override
31 36
     public List<BomTreeInfoVO> getBomTreeByMaterialNumber(String materialNumber, String version_number) {
32
-        QueryWrapper<AppSceneCostStandardDetail> wrapper = new QueryWrapper<>();
37
+        QueryWrapper<AppSceneCostStandardResult> wrapper = new QueryWrapper<>();
33 38
         //设置条件
34 39
         if (StrUtil.isNotEmpty(materialNumber)) {
35 40
             // 物料号
@@ -40,49 +45,52 @@ public class BomTreeServiceImpl implements BomTreeService {
40 45
             wrapper.like("version_number", version_number);
41 46
         }
42 47
         //查询所有满足条件的父节点
43
-        List<AppSceneCostStandardDetail> parentNodeList = costStandardDetailMapper.selectList(wrapper);
48
+        List<AppSceneCostStandardResult> parentNodeList = appSceneCostStandardResultMapper.selectList(wrapper);
44 49
         //所有子类节点
45
-        List<AppSceneCostStandardDetail> childrenNodeList = new ArrayList<>();
46
-        Map<String, AppSceneCostStandardDetail> parentDataMap = new TreeMap<>();
50
+        List<AppSceneCostStandardResult> childrenNodeList = new ArrayList<>();
51
+        Map<String, AppSceneCostStandardResult> parentDataMap = new TreeMap<>();
47 52
         if (parentNodeList.size() > 0) {
48 53
             //父类结果只有1个
49 54
             if (parentNodeList.size() == 1) {
50
-                parentDataMap = parentNodeList.stream().collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo));
55
+                parentDataMap = parentNodeList.stream().collect(Collectors.toMap(AppSceneCostStandardResult::getMaterialNumber, vo -> vo));
51 56
             } else {
52 57
                 //父类结果有多个(找出最上级节点)
53
-                Map<Integer, List<AppSceneCostStandardDetail>> levelGroupMap = new HashMap<>();
58
+                Map<String, List<AppSceneCostStandardResult>> levelGroupMap = new HashMap<>();
54 59
                 if (parentNodeList != null && parentNodeList.size() > 0) {
55
-                    levelGroupMap = parentNodeList.stream().filter(s->s.getLevel()!=null).collect(Collectors.groupingBy(AppSceneCostStandardDetail::getLevel));
56
-                    TreeMap<Integer, List<AppSceneCostStandardDetail>> levelTreeMap = new TreeMap<>(levelGroupMap);
57
-                    parentDataMap = levelTreeMap.firstEntry().getValue().stream().filter(s->s.getMaterialNumber()!=null).collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo));
60
+                    levelGroupMap = parentNodeList.stream().filter(s->s.getLowOrderCode()!=null).collect(Collectors.groupingBy(AppSceneCostStandardResult::getLowOrderCode));
61
+                    TreeMap<String, List<AppSceneCostStandardResult>> levelTreeMap = new TreeMap<>(levelGroupMap);
62
+                    parentDataMap = levelTreeMap.firstEntry().getValue().stream().filter(s->s.getMaterialNumber()!=null).collect(Collectors.toMap(AppSceneCostStandardResult::getMaterialNumber, vo -> vo));
58 63
                 }
59 64
             }
60 65
             //查询所有父节点下的子节点(即第二层叶子节点)
61
-            List<AppSceneCostStandardDetail> costStandardDetails = new ArrayList<>();
66
+            List<AppSceneCostStandardResult> costStandardDetails = new ArrayList<>();
62 67
             if (parentDataMap.size() > 0) {
63
-                QueryWrapper<AppSceneCostStandardDetail> wrapper1 = new QueryWrapper<>();
68
+                QueryWrapper<AppSceneCostStandardResult> wrapper1 = new QueryWrapper<>();
69
+                wrapper1.eq("version_number", version_number);
64 70
                 int num = 0;
65 71
                 for (String materialNumber1 : parentDataMap.keySet()) {
66 72
                     num = num + 1;
67 73
                     if (num > 1) {
68
-                        wrapper1.or().eq("parent_material_number", materialNumber1);
74
+                        wrapper1.or().eq("parent_matnr", materialNumber1);
69 75
                     } else {
70
-                        wrapper1.eq("parent_material_number", materialNumber1);
76
+                        wrapper1.eq("parent_matnr", materialNumber1);
71 77
                     }
72 78
                 }
73
-                costStandardDetails = costStandardDetailMapper.selectList(wrapper1);
79
+                costStandardDetails = appSceneCostStandardResultMapper.selectList(wrapper1);
74 80
             }
75 81
             //第三层叶子节点
76
-            List<AppSceneCostStandardDetail> threeNodes = new ArrayList<>();
82
+            List<AppSceneCostStandardResult> threeNodes = new ArrayList<>();
77 83
             if (costStandardDetails != null && costStandardDetails.size() > 0) {
78
-                List<String> materialNoList = costStandardDetails.stream().map(AppSceneCostStandardDetail::getMaterialNumber).collect(Collectors.toList());
79
-                QueryWrapper<AppSceneCostStandardDetail> wrapper2 = new QueryWrapper<>();
80
-                wrapper2.in("parent_material_number", materialNoList);
81
-                threeNodes = costStandardDetailMapper.selectList(wrapper2);
84
+                List<String> materialNoList = costStandardDetails.stream().map(AppSceneCostStandardResult::getMaterialNumber).collect(Collectors.toList());
85
+                QueryWrapper<AppSceneCostStandardResult> wrapper2 = new QueryWrapper<>();
86
+                wrapper2.in("parent_matnr", materialNoList);
87
+                wrapper2.eq("version_number", version_number);
88
+                wrapper2.eq("low_order_code",2);
89
+                threeNodes = appSceneCostStandardResultMapper.selectList(wrapper2);
82 90
             }
83 91
             //把第二层叶子节点转化为bomtreeinfoVO对象集合
84 92
             for (int i = 0; i < costStandardDetails.size(); i++) {
85
-                AppSceneCostStandardDetail costStandardDetail = costStandardDetails.get(i);
93
+                AppSceneCostStandardResult costStandardDetail = costStandardDetails.get(i);
86 94
 //                AppSceneCostStandardDetail vo = new AppSceneCostStandardDetail();
87 95
 //                BeanUtils.copyProperties(costStandardDetail, vo);
88 96
 //                childrenNodeList.add(vo);
@@ -90,7 +98,7 @@ public class BomTreeServiceImpl implements BomTreeService {
90 98
             }
91 99
             //把第三层叶子节点转化为bomtreeinfoVO对象集合
92 100
             for (int i = 0; i < threeNodes.size(); i++) {
93
-                AppSceneCostStandardDetail costStandardDetail = threeNodes.get(i);
101
+                AppSceneCostStandardResult costStandardDetail = threeNodes.get(i);
94 102
 //                CostStandardDetailVO vo = new CostStandardDetailVO();
95 103
 //                BeanUtils.copyProperties(costStandardDetail, vo);
96 104
 //                childrenNodeList.add(vo);

+ 51
- 11
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/util/BomTreeBuilder.java Parādīt failu

@@ -1,6 +1,7 @@
1 1
 package com.zzsmart.qomo.kn.cost.manage.util;
2 2
 
3 3
 import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardDetail;
4
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardResult;
4 5
 import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO;
5 6
 
6 7
 import java.util.ArrayList;
@@ -10,16 +11,16 @@ import java.util.Map;
10 11
 import java.util.stream.Collectors;
11 12
 
12 13
 public class BomTreeBuilder {
13
-    public static List<BomTreeInfoVO> buildBomTree(List<AppSceneCostStandardDetail> sourceData, Map<String, AppSceneCostStandardDetail> parentDataMap) {
14
+    public static List<BomTreeInfoVO> buildBomTree(List<AppSceneCostStandardResult> sourceData, Map<String, AppSceneCostStandardResult> parentDataMap) {
14 15
         List<BomTreeInfoVO> result = new ArrayList<>();
15 16
         if ((sourceData == null || (sourceData != null && sourceData.size() < 1)) && (parentDataMap == null || (parentDataMap != null && parentDataMap.size() < 1))) {
16 17
             return result;
17 18
         }
18 19
         //1.把BOM信息分成按照物料号分组
19
-        Map<String, AppSceneCostStandardDetail> materialMap = sourceData.stream().filter(s->s.getMaterialNumber()!=null)
20
+        Map<String, AppSceneCostStandardResult> materialMap = sourceData.stream().filter(s->s.getMaterialNumber()!=null)
20 21
                 .collect(Collectors.toMap(
21 22
                         // Key extractor
22
-                        AppSceneCostStandardDetail::getMaterialNumber,
23
+                        AppSceneCostStandardResult::getMaterialNumber,
23 24
                         // Value mapper
24 25
                         detail -> detail,
25 26
                         // Merger function to handle duplicates
@@ -29,10 +30,10 @@ public class BomTreeBuilder {
29 30
 //        Map<String, AppSceneCostStandardDetail> materialMap = sourceData.stream().filter(s -> s.getMaterialNumber() != null).collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo));
30 31
         //查找最顶端的父类节点
31 32
         if (parentDataMap == null || (parentDataMap != null && parentDataMap.size() < 1)) {
32
-            parentDataMap = sourceData.stream().filter(s -> s.getParentMaterialNumber() == null).collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo));
33
+            parentDataMap = sourceData.stream().filter(s -> s.getLayer().equals("0")).collect(Collectors.toMap(AppSceneCostStandardResult::getMaterialNumber, vo -> vo));
33 34
         }
34 35
         //查找有父节点的子节点
35
-        Map<String, List<AppSceneCostStandardDetail>> childDataMap = sourceData.stream().filter(s -> s.getParentMaterialNumber() != null).collect(Collectors.groupingBy(AppSceneCostStandardDetail::getParentMaterialNumber));
36
+        Map<String, List<AppSceneCostStandardResult>> childDataMap = sourceData.stream().filter(s -> s.getParentMatnr() != null).collect(Collectors.groupingBy(AppSceneCostStandardResult::getParentMatnr));
36 37
         //查找有父节点的子节点
37 38
 //        //1.把BOM信息分成按照层级分组
38 39
 //        Map<Integer, List<AppSceneCostStandardDetail>> levelMap = sourceData.stream().filter(s -> s.getLevel() != null).collect(Collectors.groupingBy(CostStandardDetail::getLevel));
@@ -45,7 +46,7 @@ public class BomTreeBuilder {
45 46
 //        TreeMap<Integer, List<AppSceneCostStandardDetail>> levelTreeMap = new TreeMap<>(levelMap);
46 47
         //3.构建BOM树
47 48
         if (parentDataMap.size() > 0) {
48
-            for (AppSceneCostStandardDetail parent : parentDataMap.values()) {
49
+            for (AppSceneCostStandardResult parent : parentDataMap.values()) {
49 50
                 BomTreeInfoVO parentBomTreeInfoVO = costStandardDetailChangeToBomTreeInfoVO(parent);
50 51
                 parentBomTreeInfoVO = loopFindChildrenBuild(parentBomTreeInfoVO, materialMap, childDataMap, result);
51 52
                 if (parentBomTreeInfoVO != null) {
@@ -59,23 +60,31 @@ public class BomTreeBuilder {
59 60
         return result;
60 61
     }
61 62
 
62
-    private static BomTreeInfoVO loopFindChildrenBuild(BomTreeInfoVO parentBomTreeInfoVO, Map<String, AppSceneCostStandardDetail> materialMap, Map<String, List<AppSceneCostStandardDetail>> childDataMap, List<BomTreeInfoVO> result) {
63
+    private static BomTreeInfoVO loopFindChildrenBuild(BomTreeInfoVO parentBomTreeInfoVO, Map<String, AppSceneCostStandardResult> materialMap, Map<String, List<AppSceneCostStandardResult>> childDataMap, List<BomTreeInfoVO> result) {
63 64
         if (parentBomTreeInfoVO != null) {
64 65
             //4.根据物料号查找子节点
65
-            List<AppSceneCostStandardDetail> childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber());
66
+            List<AppSceneCostStandardResult> childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber());
66 67
             if (childs != null && childs.size() > 0) {
67 68
                 parentBomTreeInfoVO.setHasChildren(true);
68 69
             } else {
69 70
                 parentBomTreeInfoVO.setHasChildren(false);
71
+                return parentBomTreeInfoVO;
70 72
             }
71 73
             //构造父节点下的bomtree结构数据
72 74
             List<BomTreeInfoVO> children = new ArrayList<>();
73 75
             for (int j = 0; childs != null && childs.size() > 0 && j < childs.size(); j++) {
74
-                AppSceneCostStandardDetail child = childs.get(j);
76
+                AppSceneCostStandardResult child = childs.get(j);
77
+                if(child.getParentMatnr().equals(child.getMaterialNumber())){
78
+                    continue;
79
+                }
75 80
                 BomTreeInfoVO childBomTreeInfoVO = costStandardDetailChangeToBomTreeInfoVO(child);
76 81
                 childBomTreeInfoVO = loopFindChildrenBuild(childBomTreeInfoVO, materialMap, childDataMap, result);
77 82
                 children.add(childBomTreeInfoVO);
78 83
             }
84
+            if(parentBomTreeInfoVO.getLevel()==0){
85
+                int x=0;
86
+                x++;
87
+            }
79 88
             //对象的子节点进行排序(升序)
80 89
             children = children.stream().sorted(Comparator.comparing(BomTreeInfoVO::getSort, Comparator.nullsLast(Comparator.naturalOrder()))).collect(Collectors.toList());
81 90
             parentBomTreeInfoVO.setChildren(children);
@@ -89,8 +98,39 @@ public class BomTreeBuilder {
89 98
      * @param parent
90 99
      * @return
91 100
      */
92
-    static BomTreeInfoVO costStandardDetailChangeToBomTreeInfoVO(AppSceneCostStandardDetail parent) {
93
-        BomTreeInfoVO bomTreeInfoVO = BomTreeInfoVO.builder().materialNumber(parent.getMaterialNumber()).materialName(parent.getMaterialName()).level(parent.getLevel()).parentMaterialNumber(parent.getParentMaterialNumber()).quantity(parent.getDosage()).unit(parent.getUnit()).auxiliaryCost(parent.getSupplyMaterialCost()).equipCost(parent.getEquipmentCost()).otherCost(parent.getOtherCost()).laborCost(parent.getLaborCost()).accumulatedEquipCost(parent.getTotalEquipmentCost()).accumulatedOtherCost(parent.getTotalOtherCost()).accumulatedLaborCost(parent.getTotalLaborCost()).accumulatedMaterialCost(parent.getTotalMaterialCost()).accumulatedFuelCost(parent.getTotalDriveCost()).sort(parent.getSort()).build();
101
+    static BomTreeInfoVO costStandardDetailChangeToBomTreeInfoVO(AppSceneCostStandardResult parent) {
102
+        if(parent.getMenge()==null){
103
+            int x=0;
104
+            x++;
105
+        }
106
+        String layer = parent.getLayer();
107
+        int index = layer.lastIndexOf("-");
108
+        if(index!=-1){
109
+            layer = layer.substring(index+1,layer.length());
110
+        }
111
+        //layer = layer.substring(index+1,layer.length());
112
+        BomTreeInfoVO bomTreeInfoVO = BomTreeInfoVO.builder()
113
+                .materialNumber(parent.getMaterialNumber())
114
+                .materialName(parent.getMaktx())
115
+                .level(Integer.parseInt(parent.getLowOrderCode()))
116
+                .parentMaterialNumber(parent.getParentMatnr())
117
+                .quantity(parent.getMenge().doubleValue())
118
+                .materialCost(parent.getMaterialCostStage())
119
+                .auxiliaryCost(parent.getAuxiliaryCostStage())
120
+                .equipCost(parent.getEquipCostStage())
121
+                .otherCost(parent.getOtherCostStage())
122
+                .laborCost(parent.getLaborCostStage())
123
+                .fuelCost(parent.getBurningCostStage())
124
+                .accumulatedEquipCost(parent.getEquipCostAccumulated())
125
+                .accumulatedOtherCost(parent.getOtherCostAccumulated())
126
+                .accumulatedLaborCost(parent.getLaborCostAccumulated())
127
+                .accumulatedMaterialCost(parent.getMaterialCostAccumulated())
128
+                .accumulatedFuelCost(parent.getBurningCostAccumulated())
129
+                .accumulatedAuxiliaryCost(parent.getAuxiliaryCostAccumulated())
130
+                .standardCost(parent.getTotalStandardCost())
131
+                .layer(parent.getLayer())
132
+                .sort(Integer.parseInt(layer))
133
+                .build();
94 134
         return bomTreeInfoVO;
95 135
     }
96 136
 }

+ 6
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/AppSceneCostCountVO.java Parādīt failu

@@ -6,6 +6,8 @@ import lombok.Builder;
6 6
 import lombok.Data;
7 7
 import lombok.NoArgsConstructor;
8 8
 
9
+import java.util.Date;
10
+
9 11
 @Data
10 12
 @Builder
11 13
 @NoArgsConstructor
@@ -63,4 +65,8 @@ public class AppSceneCostCountVO {
63 65
      * 工厂
64 66
      */
65 67
     public String factory;
68
+    /**
69
+     * 创建时间
70
+     */
71
+    public Date createTime;
66 72
 }

+ 5
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeInfoVO.java Parādīt failu

@@ -142,4 +142,9 @@ public class BomTreeInfoVO {
142 142
      */
143 143
     @ApiModelProperty(value = "是否有叶子节点")
144 144
     private boolean hasChildren;
145
+    /**
146
+     * 是否有叶子节点
147
+     */
148
+    @ApiModelProperty(value = "层级")
149
+    private String layer;
145 150
 }

+ 37
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeVo.java Parādīt failu

@@ -0,0 +1,37 @@
1
+package com.zzsmart.qomo.kn.cost.manage.vo;
2
+
3
+import lombok.AllArgsConstructor;
4
+import lombok.Builder;
5
+import lombok.Data;
6
+import lombok.NoArgsConstructor;
7
+
8
+import java.math.BigDecimal;
9
+import java.util.Date;
10
+
11
+@Data
12
+@Builder
13
+@NoArgsConstructor
14
+@AllArgsConstructor
15
+public class BomTreeVo {
16
+    public String matnr;
17
+    /**
18
+     * 成本中心
19
+     */
20
+    public String idnrk;
21
+    /**
22
+     * 领用数量
23
+     */
24
+    public BigDecimal menge;
25
+    /**
26
+     * 父物料领用数量
27
+     */
28
+    public BigDecimal pmenge;
29
+    /**
30
+     * 父物料领用数量
31
+     */
32
+    public BigDecimal topmenge;
33
+    /**
34
+     * 创建时间
35
+     */
36
+    public int depth;
37
+}