diff --git a/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml b/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml index 26d00f7..32617fa 100644 --- a/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml +++ b/qomo-kn-cost-manage-start/src/main/resources/application-dev.yml @@ -226,19 +226,19 @@ spring: # database: 5 # host: 121.40.189.20 # port: 6389 - redis: - database: 9 - host: 192.168.50.9 - port: 7379 - password: 'zzboard' - main: - allow-circular-references: true # redis: -# database: 10 -# host: localhost -# port: 6379 +# database: 9 +# host: 192.168.50.9 +# port: 7379 +# password: 'zzboard' # main: # allow-circular-references: true + redis: + database: 10 + host: localhost + port: 6379 + main: + allow-circular-references: true #rabbitmq 配置 rabbitmq: @@ -268,7 +268,7 @@ mybatis-plus: table-underline: true configuration: # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl # 返回类型为Map,显示null对应的字段 call-setters-on-nulls: true diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java index 86b6ec5..701abbf 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostCountController.java @@ -55,6 +55,7 @@ public class AppSceneCostCountController extends JeecgController> queryPageList(AppSceneCostCount appSceneCostCount, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostCount, req.getParameterMap()); + queryWrapper.orderByDesc("create_time"); Page page = new Page(pageNo, pageSize); IPage pageList = appSceneCostCountService.page(page, queryWrapper); IPage pageList1 = new Page<>(); diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostStandardResultController.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostStandardResultController.java index f8b5a2c..3caab25 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostStandardResultController.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostStandardResultController.java @@ -51,47 +51,49 @@ public class AppSceneCostStandardResultController extends JeecgController> queryPageList(AppSceneCostStandardResult appSceneCostStandardResult, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { + public Result> queryPageList(AppSceneCostStandardResult appSceneCostStandardResult, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { + if(appSceneCostStandardResult.getVersionNumber()==null){ + appSceneCostStandardResult.setVersionNumber(" "); + } QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(appSceneCostStandardResult, req.getParameterMap()); + queryWrapper.orderByAsc("layer"); Page page = new Page(pageNo, pageSize); IPage pageList = appSceneCostStandardResultService.page(page, queryWrapper); - IPage newpageList = new Page<>(); - BeanUtils.copyProperties(pageList, newpageList); - List list = pageList.getRecords(); - List newList = new ArrayList<>(); - for (int i = 0; i < list.size(); i++) { - AppSceneCostStandardResult result = list.get(i); - AppSceneCostStandardResultVO costStandardDetail = AppSceneCostStandardResultVO.builder() - .materialNumber(result.getMaterialNumber()) -// .materialName(oldAppSceneCostResultValue.getMarterialNo()) - .parentMaterialNumber(result.getParentMatnr()) - .versionNumber(result.getVersionNumber()) -// .level() -// .sort() -// .figureNumber() -// .dosage(oldAppSceneCostResultValue.getNum() != null ? new Double(oldAppSceneCostResultValue.getNum()) : 0) -// .unit(oldAppSceneCostResultValue.getUnit()) - .materialCost(result.getMaterialCostStage()) - .laborCost(result.getLaborCostStage()) - .equipmentCost(result.getEquipCostStage()) - .supplyMaterialCost(result.getAuxiliaryCostStage()) - .driveCost(result.getBurningCostStage()) - .logisticsCost(result.getStageLogisticsCost()) - .otherCost(result.getOtherCostStage()) - .currentStandardCost(result.getTotalStandardCostInter()) - .totalMaterialCost(result.getMaterialCostAccumulated()) - .totalLaborCost(result.getLaborCostAccumulated()) - .totalEquipmentCost(result.getEquipCostAccumulated()) - .totalSupplyMaterialCost(result.getAuxiliaryCostAccumulated()) - .totalDriveCost(result.getBurningCostAccumulated()) - .totalLogisticsCost(result.getTotalLogisticsCost()) - .totalOtherCost(result.getOtherCostAccumulated()) - .totalStandardCost(result.getTotalStandardCost()) - .createTime(result.getCreatedTime()).build(); - newList.add(costStandardDetail); - } - newpageList.setRecords(newList); - return Result.OK(newpageList); +// IPage newpageList = new Page<>(); +// BeanUtils.copyProperties(pageList, newpageList); +// List list = pageList.getRecords(); +// List newList = new ArrayList<>(); +// for (int i = 0; i < list.size(); i++) { +// AppSceneCostStandardResult result = list.get(i); +// AppSceneCostStandardResultVO costStandardDetail = AppSceneCostStandardResultVO.builder() +// .materialNumber(result.getMaterialNumber()) +//// .materialName(oldAppSceneCostResultValue.getMarterialNo()) +// .parentMaterialNumber(result.getParentMatnr()) +// .versionNumber(result.getVersionNumber()) +//// .level() +//// .sort() +//// .figureNumber() +//// .dosage(oldAppSceneCostResultValue.getNum() != null ? new Double(oldAppSceneCostResultValue.getNum()) : 0) +//// .unit(oldAppSceneCostResultValue.getUnit()) +// .materialCost(result.getMaterialCostStage()) +// .laborCost(result.getLaborCostStage()) +// .equipmentCost(result.getEquipCostStage()) +// .supplyMaterialCost(result.getAuxiliaryCostStage()) +// .driveCost(result.getBurningCostStage()) +// .otherCost(result.getOtherCostStage()) +// .currentStandardCost(result.getTotalStandardCost()) +// .totalMaterialCost(result.getMaterialCostAccumulated()) +// .totalLaborCost(result.getLaborCostAccumulated()) +// .totalEquipmentCost(result.getEquipCostAccumulated()) +// .totalSupplyMaterialCost(result.getAuxiliaryCostAccumulated()) +// .totalDriveCost(result.getBurningCostAccumulated()) +// .totalOtherCost(result.getOtherCostAccumulated()) +// .totalStandardCost(result.getTotalStandardCost()) +// .createTime(result.getCreatedTime()).build(); +// newList.add(costStandardDetail); +// } +// newpageList.setRecords(newList); + return Result.OK(pageList); } // // /** diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostMaterial.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostMaterial.java new file mode 100644 index 0000000..2aa1a27 --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostMaterial.java @@ -0,0 +1,111 @@ +package com.zzsmart.qomo.kn.cost.manage.entity; + +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.TableLogic; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: app_scene_cost_material + * @Author: jeecg-boot + * @Date: 2024-09-17 + * @Version: V1.0 + */ +@Data +@TableName("app_scene_cost_material") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="app_scene_cost_material对象", description="app_scene_cost_material") +public class AppSceneCostMaterial implements Serializable { + private static final long serialVersionUID = 1L; + + /**工厂*/ + @Excel(name = "工厂", width = 15) + @ApiModelProperty(value = "工厂") + private String factory; + /**物料号*/ + @Excel(name = "物料号", width = 15) + @ApiModelProperty(value = "物料号") + private String materialNumber; + /**materialType*/ + @Excel(name = "materialType", width = 15) + @ApiModelProperty(value = "materialType") + private String materialType; + /**productCategory*/ + @Excel(name = "productCategory", width = 15) + @ApiModelProperty(value = "productCategory") + private String productCategory; + /**物料名称*/ + @Excel(name = "物料名称", width = 15) + @ApiModelProperty(value = "物料名称") + private String productName; + /**norms*/ + @Excel(name = "norms", width = 15) + @ApiModelProperty(value = "norms") + private String norms; + /**生产类型*/ + @Excel(name = "生产类型", width = 15) + @ApiModelProperty(value = "生产类型") + private String manufacturingType; + /**inventoryUnit*/ + @Excel(name = "inventoryUnit", width = 15) + @ApiModelProperty(value = "inventoryUnit") + private String inventoryUnit; + /**purchasingUnit*/ + @Excel(name = "purchasingUnit", width = 15) + @ApiModelProperty(value = "purchasingUnit") + private String purchasingUnit; + /**老物料组*/ + @Excel(name = "老物料组", width = 15) + @ApiModelProperty(value = "老物料组") + private String oldMaterialGroup; + /**standardCost*/ + @Excel(name = "standardCost", width = 15) + @ApiModelProperty(value = "standardCost") + private String standardCost; + /**abcLevel*/ + @Excel(name = "abcLevel", width = 15) + @ApiModelProperty(value = "abcLevel") + private String abcLevel; + /**effectiveState*/ + @Excel(name = "effectiveState", width = 15) + @ApiModelProperty(value = "effectiveState") + private String effectiveState; + /**profitCenter*/ + @Excel(name = "profitCenter", width = 15) + @ApiModelProperty(value = "profitCenter") + private String profitCenter; + /**iswbs*/ + @Excel(name = "iswbs", width = 15) + @ApiModelProperty(value = "iswbs") + private String iswbs; + /**图号*/ + @Excel(name = "图号", width = 15) + @ApiModelProperty(value = "图号") + private String graphNumber; + /**mtbez*/ + @Excel(name = "mtbez", width = 15) + @ApiModelProperty(value = "mtbez") + private String mtbez; + /**wgbez*/ + @Excel(name = "wgbez", width = 15) + @ApiModelProperty(value = "wgbez") + private String wgbez; + /**sobsl*/ + @Excel(name = "sobsl", width = 15) + @ApiModelProperty(value = "sobsl") + private String sobsl; +} diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java index 7dfdcac..b20c614 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostResultValue.java @@ -134,4 +134,74 @@ public class AppSceneCostResultValue implements Serializable { @Excel(name = "工时", width = 15) @ApiModelProperty(value = "工时") private BigDecimal hour; + /** + * 工时 + */ + @Excel(name = "BOM深度", width = 15) + @ApiModelProperty(value = "BOM深度") + private int depth; + /** + * 工时 + */ + @Excel(name = "父物料数量", width = 15) + @ApiModelProperty(value = "父物料数量") + private BigDecimal pnum; + /** + * 工时 + */ + @Excel(name = "基于最上层物料的用量", width = 15) + @ApiModelProperty(value = "基于最上层物料的用量") + private BigDecimal topnum; + /** + * 工时 + */ + @Excel(name = "价格类型", width = 15) + @ApiModelProperty(value = "价格类型") + private String priceType; + /** + * 工时 + */ + @Excel(name = "制造类型", width = 15) + @ApiModelProperty(value = "制造类型") + private String manuType; + /** + * 工时 + */ + @Excel(name = "材料", width = 15) + @ApiModelProperty(value = "材料") + private BigDecimal material; + /** + * 工时 + */ + @Excel(name = "人工", width = 15) + @ApiModelProperty(value = "人工") + private BigDecimal labor; + /** + * 工时 + */ + @Excel(name = "设备", width = 15) + @ApiModelProperty(value = "设备") + private BigDecimal equip; + /** + * 工时 + */ + @Excel(name = "燃动", width = 15) + @ApiModelProperty(value = "燃动") + private BigDecimal fuel; + /** + * 工时 + */ + @Excel(name = "辅料", width = 15) + @ApiModelProperty(value = "辅料") + private BigDecimal auxi; + /** + * 工时 + */ + @Excel(name = "其他", width = 15) + @ApiModelProperty(value = "其他") + private BigDecimal other; + + @Excel(name = "层级", width = 15) + @ApiModelProperty(value = "层级") + private String layer; } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostStandardResult.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostStandardResult.java index aea9d75..c7e775a 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostStandardResult.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostStandardResult.java @@ -10,6 +10,7 @@ import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.jeecgframework.poi.excel.annotation.Excel; import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.Column; @@ -18,348 +19,173 @@ import java.math.BigDecimal; import java.util.Date; +/** + * @Description: app_scene_cost_standard_result + * @Author: jeecg-boot + * @Date: 2024-09-17 + * @Version: V1.0 + */ @Data @Builder @TableName("app_scene_cost_standard_result") @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) -@ApiModel(value = "标准成本单行", description = "标准成本单行") +@ApiModel(value="app_scene_cost_standard_result对象", description="app_scene_cost_standard_result") public class AppSceneCostStandardResult implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * 主键 - */ - @TableId(type = IdType.AUTO) - @ApiModelProperty(value = "id") - private Integer id; - - /** - * 工厂 - */ - @Column(name = "factory") - private String factory; - - /** - * 物料号 - */ - @Column(name = "material_number") - private String materialNumber; - - /** - * 父物料号 - */ - @Column(name = "parent_matnr") - private String parentMatnr; - - /** - * 阶段 - */ - @Column(name = "stage") - private String stage; - - /** - * 版本号 - */ - @Column(name = "version_number") - private String versionNumber; - - /** - * 层级 - */ - @Column(name = "layer") - private String layer; - - /** - * 价格类型 - */ - @Column(name = "pricetype") - private String pricetype; - - /** - * 会计期间 - */ - @Column(name = "ymonth") - private String ymonth; - - /** - * 本阶标准成本 - */ - @Column(name = "total_standard_cost_inter") - private BigDecimal totalStandardCostInter; - - /** - * 累计标准成本 - */ - @Column(name = "total_standard_cost") - private BigDecimal totalStandardCost; - - /** - * material_cost_stage_inter - */ - @Column(name = "material_cost_stage_inter") - private BigDecimal materialCostStageInter; - - /** - * 本阶物料成本 - */ - @Column(name = "material_cost_stage") - private BigDecimal materialCostStage; - - /** - * 本阶人工成本 - */ - @Column(name = "labor_cost_stage") - private BigDecimal laborCostStage; - - /** - * 本阶设备费 - */ - @Column(name = "equip_cost_stage") - private BigDecimal equipCostStage; - - /** - * 本阶燃动费 - */ - @Column(name = "burning_cost_stage") - private BigDecimal burningCostStage; - - /** - * 本阶辅料费 - */ - @Column(name = "auxiliary_cost_stage") - private BigDecimal auxiliaryCostStage; - - /** - * 本阶其他费 - */ - @Column(name = "other_cost_stage") - private BigDecimal otherCostStage; - - /** - * 本阶物流费 - */ - @Column(name = "stage_logistics_cost") - private BigDecimal stageLogisticsCost; - - /** - * material_cost_accumulated_inter - */ - @Column(name = "material_cost_accumulated_inter") - private BigDecimal materialCostAccumulatedInter; - - /** - * 累计物料 - */ - @Column(name = "material_cost_accumulated") - private BigDecimal materialCostAccumulated; - - /** - * 累计人工成本 - */ - @Column(name = "labor_cost_accumulated") - private BigDecimal laborCostAccumulated; - - /** - * 累计设备费 - */ - @Column(name = "equip_cost_accumulated") - private BigDecimal equipCostAccumulated; - - /** - * 累计燃动费 - */ - @Column(name = "burning_cost_accumulated") - private BigDecimal burningCostAccumulated; - - /** - * 累计辅料费 - */ - @Column(name = "auxiliary_cost_accumulated") - private BigDecimal auxiliaryCostAccumulated; - - /** - * 累计其他费 - */ - @Column(name = "other_cost_accumulated") - private BigDecimal otherCostAccumulated; - - /** - * 累计物流费 - */ - @Column(name = "total_logistics_cost") - private BigDecimal totalLogisticsCost; - - /** - * material_cost_total_inter - */ - @Column(name = "material_cost_total_inter") - private BigDecimal materialCostTotalInter; - - /** - * material_cost_total - */ - @Column(name = "material_cost_total") - private BigDecimal materialCostTotal; - - /** - * labor_cost_total - */ - @Column(name = "labor_cost_total") - private BigDecimal laborCostTotal; - - /** - * equip_cost_total - */ - @Column(name = "equip_cost_total") - private BigDecimal equipCostTotal; - - /** - * burning_cost_total - */ - @Column(name = "burning_cost_total") - private BigDecimal burningCostTotal; - - /** - * auxiliary_cost_total - */ - @Column(name = "auxiliary_cost_total") - private BigDecimal auxiliaryCostTotal; - - /** - * other_cost_total - */ - @Column(name = "other_cost_total") - private BigDecimal otherCostTotal; - - /** - * low_order_code - */ - @Column(name = "low_order_code") - private String lowOrderCode; - - /** - * relative_dosage - */ - @Column(name = "relative_dosage") - private BigDecimal relativeDosage; - - /** - * material_cost_relative - */ - @Column(name = "material_cost_relative") - private BigDecimal materialCostRelative; - - /** - * material_cost_relative_inter - */ - @Column(name = "material_cost_relative_inter") - private BigDecimal materialCostRelativeInter; - - /** - * labor_cost_relative - */ - @Column(name = "labor_cost_relative") - private BigDecimal laborCostRelative; - - /** - * manufacture_cost_relative - */ - @Column(name = "manufacture_cost_relative") - private BigDecimal manufactureCostRelative; - - /** - * total_cost_relative - */ - @Column(name = "total_cost_relative") - private BigDecimal totalCostRelative; - - /** - * total_cost_relative_inter - */ - @Column(name = "total_cost_relative_inter") - private BigDecimal totalCostRelativeInter; - - /** - * material_cost_stage_material - */ - @Column(name = "material_cost_stage_material") - private BigDecimal materialCostStageMaterial; - - /** - * material_cost_stage_edcu - */ - @Column(name = "material_cost_stage_edcu") - private BigDecimal materialCostStageEdcu; - - /** - * material_cost_stage_em - */ - @Column(name = "material_cost_stage_em") - private BigDecimal materialCostStageEm; - - /** - * material_cost_stage_inter_material - */ - @Column(name = "material_cost_stage_inter_material") - private BigDecimal materialCostStageInterMaterial; - - /** - * material_cost_stage_inter_edcu - */ - @Column(name = "material_cost_stage_inter_edcu") - private BigDecimal materialCostStageInterEdcu; - - /** - * material_cost_stage_inter_em - */ - @Column(name = "material_cost_stage_inter_em") - private BigDecimal materialCostStageInterEm; - - /** - * material_cost_accumulated_material - */ - @Column(name = "material_cost_accumulated_material") - private BigDecimal materialCostAccumulatedMaterial; - - /** - * material_cost_accumulated_edcu - */ - @Column(name = "material_cost_accumulated_edcu") - private BigDecimal materialCostAccumulatedEdcu; - - /** - * material_cost_accumulated_em - */ - @Column(name = "material_cost_accumulated_em") - private BigDecimal materialCostAccumulatedEm; - - /** - * material_cost_accumulated_inter_material - */ - @Column(name = "material_cost_accumulated_inter_material") - private BigDecimal materialCostAccumulatedInterMaterial; - - /** - * material_cost_accumulated_inter_edcu - */ - @Column(name = "material_cost_accumulated_inter_edcu") - private BigDecimal materialCostAccumulatedInterEdcu; - - /** - * material_cost_accumulated_inter_em - */ - @Column(name = "material_cost_accumulated_inter_em") - private BigDecimal materialCostAccumulatedInterEm; - - /** - * 创建时间 - */ - @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "修改日期") - private Date createdTime; - + /**主键*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private java.lang.Integer id; + /**工厂*/ + @Excel(name = "工厂", width = 15) + @ApiModelProperty(value = "工厂") + private java.lang.String factory; + /**物料号*/ + @Excel(name = "物料号", width = 15) + @ApiModelProperty(value = "物料号") + private java.lang.String materialNumber; + /**父物料号*/ + @Excel(name = "父物料号", width = 15) + @ApiModelProperty(value = "父物料号") + private java.lang.String parentMatnr; + /**阶段*/ + @Excel(name = "阶段", width = 15) + @ApiModelProperty(value = "阶段") + private java.lang.String stage; + /**版本号*/ + @Excel(name = "版本号", width = 15) + @ApiModelProperty(value = "版本号") + private java.lang.String versionNumber; + /**层级*/ + @Excel(name = "层级", width = 15) + @ApiModelProperty(value = "层级") + private java.lang.String layer; + /**价格类型*/ + @Excel(name = "价格类型", width = 15) + @ApiModelProperty(value = "价格类型") + private java.lang.String pricetype; + /**会计期间*/ + @Excel(name = "会计期间", width = 15) + @ApiModelProperty(value = "会计期间") + private java.lang.String ymonth; + /**总标准成本*/ + @Excel(name = "总标准成本", width = 15) + @ApiModelProperty(value = "总标准成本") + private java.math.BigDecimal totalStandardCost; + /**本阶材料成本*/ + @Excel(name = "本阶材料成本", width = 15) + @ApiModelProperty(value = "本阶材料成本") + private java.math.BigDecimal materialCostStage; + /**本阶人工成本*/ + @Excel(name = "本阶人工成本", width = 15) + @ApiModelProperty(value = "本阶人工成本") + private java.math.BigDecimal laborCostStage; + /**本阶设备成本*/ + @Excel(name = "本阶设备成本", width = 15) + @ApiModelProperty(value = "本阶设备成本") + private java.math.BigDecimal equipCostStage; + /**本阶燃动成本*/ + @Excel(name = "本阶燃动成本", width = 15) + @ApiModelProperty(value = "本阶燃动成本") + private java.math.BigDecimal burningCostStage; + /**本阶辅料成本*/ + @Excel(name = "本阶辅料成本", width = 15) + @ApiModelProperty(value = "本阶辅料成本") + private java.math.BigDecimal auxiliaryCostStage; + /**本阶其他成本*/ + @Excel(name = "本阶其他成本", width = 15) + @ApiModelProperty(value = "本阶其他成本") + private java.math.BigDecimal otherCostStage; + /**累计材料成本*/ + @Excel(name = "累计材料成本", width = 15) + @ApiModelProperty(value = "累计材料成本") + private java.math.BigDecimal materialCostAccumulated; + /**累计人工成本*/ + @Excel(name = "累计人工成本", width = 15) + @ApiModelProperty(value = "累计人工成本") + private java.math.BigDecimal laborCostAccumulated; + /**累计设备成本*/ + @Excel(name = "累计设备成本", width = 15) + @ApiModelProperty(value = "累计设备成本") + private java.math.BigDecimal equipCostAccumulated; + /**累计燃动成本*/ + @Excel(name = "累计燃动成本", width = 15) + @ApiModelProperty(value = "累计燃动成本") + private java.math.BigDecimal burningCostAccumulated; + /**累计辅料成本*/ + @Excel(name = "累计辅料成本", width = 15) + @ApiModelProperty(value = "累计辅料成本") + private java.math.BigDecimal auxiliaryCostAccumulated; + /**累计其他成本*/ + @Excel(name = "累计其他成本", width = 15) + @ApiModelProperty(value = "累计其他成本") + private java.math.BigDecimal otherCostAccumulated; + /**总材料成本*/ + @Excel(name = "总材料成本", width = 15) + @ApiModelProperty(value = "总材料成本") + private java.math.BigDecimal materialCostTotal; + /**总人工成本*/ + @Excel(name = "总人工成本", width = 15) + @ApiModelProperty(value = "总人工成本") + private java.math.BigDecimal laborCostTotal; + /**总设备成本*/ + @Excel(name = "总设备成本", width = 15) + @ApiModelProperty(value = "总设备成本") + private java.math.BigDecimal equipCostTotal; + /**总燃动成本*/ + @Excel(name = "总燃动成本", width = 15) + @ApiModelProperty(value = "总燃动成本") + private java.math.BigDecimal burningCostTotal; + /**总辅料成本*/ + @Excel(name = "总辅料成本", width = 15) + @ApiModelProperty(value = "总辅料成本") + private java.math.BigDecimal auxiliaryCostTotal; + /**总其他成本*/ + @Excel(name = "总其他成本", width = 15) + @ApiModelProperty(value = "总其他成本") + private java.math.BigDecimal otherCostTotal; + /**低阶码*/ + @Excel(name = "低阶码", width = 15) + @ApiModelProperty(value = "低阶码") + private java.lang.String lowOrderCode; + /**相对用量*/ + @Excel(name = "相对用量", width = 15) + @ApiModelProperty(value = "相对用量") + private java.math.BigDecimal relativeDosage; + /**相对材料成本*/ + @Excel(name = "相对材料成本", width = 15) + @ApiModelProperty(value = "相对材料成本") + private java.math.BigDecimal materialCostRelative; + /**相对人工成本*/ + @Excel(name = "相对人工成本", width = 15) + @ApiModelProperty(value = "相对人工成本") + private java.math.BigDecimal laborCostRelative; + /**相对制费成本*/ + @Excel(name = "相对制费成本", width = 15) + @ApiModelProperty(value = "相对制费成本") + private java.math.BigDecimal manufactureCostRelative; + /**相对总成本*/ + @Excel(name = "相对总成本", width = 15) + @ApiModelProperty(value = "相对总成本") + private java.math.BigDecimal totalCostRelative; + /**创建时间*/ + @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建时间") + private java.util.Date createdTime; + /**物料描述*/ + @Excel(name = "物料描述", width = 15) + @ApiModelProperty(value = "物料描述") + private java.lang.String maktx; + /**数量*/ + @Excel(name = "数量", width = 15) + @ApiModelProperty(value = "数量") + private java.math.BigDecimal menge; + /**数量*/ + @Excel(name = "制造类型", width = 15) + @ApiModelProperty(value = "制造类型") + private java.lang.String manuType; } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostBomRelevancyMapper.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostBomRelevancyMapper.java index 5626f26..d8e0676 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostBomRelevancyMapper.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostBomRelevancyMapper.java @@ -3,6 +3,7 @@ package com.zzsmart.qomo.kn.cost.manage.mapper; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostBomRelevancy; +import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -16,16 +17,16 @@ import java.util.List; */ public interface AppSceneCostBomRelevancyMapper extends BaseMapper { @Select("WITH RECURSIVE BOM_Tree AS (\n" + - " SELECT matnr, idnrk, meins, 0 AS depth\n" + + " SELECT matnr, idnrk, menge/bmeng as menge,1.000000 as pmenge,1.000000 as topmenge, 1 AS depth\n" + " FROM app_scene_cost_bom_relevancy\n" + " WHERE matnr = #{parentId}\n" + " UNION ALL\n" + - " SELECT b.matnr, b.idnrk, b.meins, BOM_Tree.depth + 1\n" + + " 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" + " FROM app_scene_cost_bom_relevancy b\n" + " JOIN BOM_Tree ON b.matnr = BOM_Tree.idnrk\n" + ")\n" + - "SELECT matnr, idnrk, meins, depth FROM BOM_Tree") - List findChildrenByParentId(String parentId); + "SELECT matnr, idnrk, menge,pmenge,topmenge, depth FROM BOM_Tree") + List findChildrenByParentId(String parentId); @Select("${selectSql}") diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostMaterialMapper.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostMaterialMapper.java new file mode 100644 index 0000000..d7f24eb --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/AppSceneCostMaterialMapper.java @@ -0,0 +1,18 @@ +package com.zzsmart.qomo.kn.cost.manage.mapper; + +import java.util.List; + +import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial; +import org.apache.ibatis.annotations.Param; +//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: app_scene_cost_material + * @Author: jeecg-boot + * @Date: 2024-09-17 + * @Version: V1.0 + */ +public interface AppSceneCostMaterialMapper extends BaseMapper { + +} diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/xml/AppSceneCostMaterialMapper.xml b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/xml/AppSceneCostMaterialMapper.xml new file mode 100644 index 0000000..75c63ad --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/xml/AppSceneCostMaterialMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java index eeb35e2..85d955e 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java @@ -8,9 +8,12 @@ import com.zzsmart.qomo.kn.cost.manage.enums.HourOrRateTypeEnum; import com.zzsmart.qomo.kn.cost.manage.enums.TotalCostEnum; import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostBomRelevancyMapper; import com.zzsmart.qomo.kn.cost.manage.service.*; +import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo; import com.zzsmart.qomo.kn.cost.manage.vo.FlowTaskInfoVO; import com.zzsmart.qomo.kn.cost.manage.vo.TotalResultValue; import com.zzsmart.qomo.plugin.task.api.TaskExecutionContext; +import io.swagger.models.auth.In; +import liquibase.pro.packaged.B; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -18,10 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @Service @@ -71,6 +71,9 @@ public class StandardCostService { @Autowired private IAppSceneCostStandardResultService iAppSceneCostStandardResultService; + @Autowired + private IAppSceneCostMaterialService iAppSceneCostMaterialService; + @PostConstruct public void init() { standardCostService = this; @@ -82,6 +85,7 @@ public class StandardCostService { standardCostService.costMaterialProcessHoursService = this.costMaterialProcessHoursService; standardCostService.iAppSceneCostResultValueService = this.iAppSceneCostResultValueService; standardCostService.iAppSceneCostStandardResultService = this.iAppSceneCostStandardResultService; + standardCostService.iAppSceneCostMaterialService = this.iAppSceneCostMaterialService; } /** @@ -127,16 +131,90 @@ public class StandardCostService { * @param flowInstanceId 流程实例id */ public static void getAllMaterialBomInfoByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId) { - List list = standardCostService.costMaterialBomService.queryAllBomInfoByTopMaterialCode(topMaterialCode); + log.info("getAllMaterialBomInfoByTopMaterialCode"); + List list = standardCostService.costMaterialBomService.queryAllBomInfoByTopMaterialCode(topMaterialCode); + List MarterialNoList = new ArrayList<>(); + if (list != null && list.size() > 0) { + MarterialNoList = list.stream().filter(s -> s.getIdnrk() != null).map(BomTreeVo::getIdnrk).collect(Collectors.toList()); + } + Map manuTypeMap = standardCostService.iAppSceneCostMaterialService.getManuTypeByMaterialNo(MarterialNoList); + + int maxdepth = 0; + List appSceneCostResultValues=new ArrayList<>(); log.info("Full ParamTask list: {}", list); //TODO material.getMeins()领用量??为什么是ST字母 for (int i = 0; list != null && i < list.size(); i++) { - AppSceneCostBomRelevancy material = list.get(i); + BomTreeVo material = list.get(i); + String manutype = ""; + if(manuTypeMap.containsKey(material.getIdnrk())){ + manutype = manuTypeMap.get(material.getIdnrk()); + } //TODO 物料领用数据 - BigDecimal num1 = BigDecimal.ONE; - AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder().belongTopMaterialNo(topMaterialCode).marterialNo(material.getIdnrk()).parentMarterialNo(material.getMatnr()).taskType(taskType).taskCode(taskCode).flowInstanceId(flowInstanceId).num(num1).build(); - standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue); + BigDecimal num1 = material.getMenge(); + AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder() + .belongTopMaterialNo(topMaterialCode) + .marterialNo(material.getIdnrk()) + .parentMarterialNo(material.getMatnr()) + .taskType(taskType) + .taskCode(taskCode) + .flowInstanceId(flowInstanceId) + .num(material.getMenge()) + .pnum(material.getPmenge()) + .topnum(material.getTopmenge()) + .depth(material.depth) + .manuType(manutype) + .build(); + appSceneCostResultValues.add(appSceneCostResultValue); + if(material.depth>maxdepth){ + maxdepth=material.depth; + } + //standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue); } + Map mapIndex = new HashMap<>(); + for (int i=1;i<=maxdepth;++i){ + //int index=1; + for (AppSceneCostResultValue appSceneCostResultValue:appSceneCostResultValues){ + if(appSceneCostResultValue.getDepth()==i){ + String parentlayer = ""; + if(i==1){ + parentlayer="0"; + }else{ + for (AppSceneCostResultValue appSceneCostResultValue1:appSceneCostResultValues){ + if(appSceneCostResultValue1.getMarterialNo().equals(appSceneCostResultValue.getParentMarterialNo())&&(appSceneCostResultValue1.getDepth()+1==appSceneCostResultValue.getDepth())){ + parentlayer=appSceneCostResultValue1.getLayer(); + } + } + } + int index = 1; + if(mapIndex.containsKey(parentlayer)){ + index = mapIndex.get(parentlayer); + }else{ + mapIndex.put(parentlayer,index); + } + String layer = parentlayer+"-"+String.valueOf(index); + index++; + mapIndex.put(parentlayer,index); + appSceneCostResultValue.setLayer(layer); + } + } + } + standardCostService.iAppSceneCostResultValueService.saveBatch(appSceneCostResultValues); + + AppSceneCostResultValue appSceneCostResultValue = AppSceneCostResultValue.builder() + .belongTopMaterialNo(topMaterialCode) + .marterialNo(topMaterialCode) + .parentMarterialNo(topMaterialCode) + .taskType(taskType) + .taskCode(taskCode) + .flowInstanceId(flowInstanceId) + .num(new BigDecimal(1)) + .pnum(new BigDecimal(1)) + .topnum(new BigDecimal(1)) + .depth(0) + .layer("0") + .manuType("E") + .build(); + standardCostService.iAppSceneCostResultValueService.save(appSceneCostResultValue); } /** @@ -148,6 +226,7 @@ public class StandardCostService { * @param flowInstanceId 流程实例id */ public static void countMaterialCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String feeType) { + log.info("countMaterialCostByTopMaterialCode"); //1.查询出物料编号对应的下所有的BOM信息 List list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", String.valueOf(flowInstanceId)); //2.计算出所有的单个物料的物料成本 @@ -163,15 +242,40 @@ public class StandardCostService { String marterialNo = appSceneCostResultValue.getMarterialNo(); BigDecimal num = appSceneCostResultValue.getNum(); if (marterialNo != null && num != null && (new BigDecimal(num.toString()).compareTo(BigDecimal.ZERO)) != 0) { - BigDecimal price = purchasePriceMap.get(marterialNo); - if (price == null) { - price = BigDecimal.ZERO; + BigDecimal price = new BigDecimal(0); + String price_type = ""; + if(appSceneCostResultValue.getManuType()!=null&&appSceneCostResultValue.getManuType().equals("F")){ + price = purchasePriceMap.get(marterialNo); + price_type = "purchase_record"; } + //purchasePriceMap.get(marterialNo); + //if (price == null) { + // price = BigDecimal.ZERO; + //} else { + // price_type = "purchase_record"; + //} BigDecimal number = new BigDecimal(num.toString()); //单价乘以数量 BigDecimal totalCost = price.multiply(number); //2.2计算出人工成本并存储到成本结果数据表中 - 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(); + AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder() + .belongTopMaterialNo(topMaterialCode) + .marterialNo(marterialNo) + .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()) + .taskType(taskType) + .costType(feeType) + .taskCode(taskCode) + .priceType(price_type) + .flowInstanceId(flowInstanceId) + .countValue(totalCost + "") + .material(price) + .num(num) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .depth(appSceneCostResultValue.getDepth()) + .layer(appSceneCostResultValue.getLayer()) + .build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } @@ -186,12 +290,13 @@ public class StandardCostService { * @param flowInstanceId 流程实例id */ public static void countLaborCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String feeType, AppSceneCostHourRate appSceneCostHourRate) { + log.info("countLaborCostByTopMaterialCode"); //1.查询出人员工时费率 - AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(appSceneCostHourRate); + //AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(); BigDecimal hourRate = new BigDecimal("0"); - if (hourRateInfo != null) { - hourRate = hourRateInfo.getLaborHourRate(); - } + //if (hourRateInfo != null) { + // hourRate = hourRateInfo.getLaborHourRate(); + //} //1.查询出物料编号对应的下所有的BOM信息 List list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", String.valueOf(flowInstanceId)); //2.计算出所有的单个物料的人工成本 @@ -218,12 +323,89 @@ public class StandardCostService { } } //2.2计算出人工成本并存储到成本结果数据表中 - 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(); + 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) + .num(appSceneCostResultValue.getNum()) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } } + public static void countManufacturingCost(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId) { + log.info("countManufacturingCost"); + //1.查询出人员工时费率 + Map mapHourRate = standardCostService.iHourRateService.getOneHourRateInfo(); + BigDecimal hourRate = new BigDecimal("0"); + //if (hourRateInfo != null) { + // hourRate = hourRateInfo.getLaborHourRate(); + //} + //1.查询出物料编号对应的下所有的BOM信息 + List list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialCost", String.valueOf(flowInstanceId)); + //2.根据费用类型进行不同的费用计算 + //查询工序工时 + List MarterialNoList = new ArrayList<>(); + if (list != null && list.size() > 0) { + MarterialNoList = list.stream().filter(s -> s.getMarterialNo() != null).map(AppSceneCostResultValue::getMarterialNo).collect(Collectors.toList()); + } + Map> processHoursMap = standardCostService.costMaterialProcessHoursService.getProcessHoursByMaterialNo(MarterialNoList); + for (AppSceneCostResultValue appSceneCostResultValue:list){ + double labor = 0; + double equip = 0; + double fuel = 0; + double auxi = 0; + double other = 0; + if(processHoursMap.containsKey(appSceneCostResultValue.getMarterialNo())){ + List appSceneCostProductProcessMaintenances = processHoursMap.get(appSceneCostResultValue.getMarterialNo()); + for (AppSceneCostProductProcessMaintenance pm:appSceneCostProductProcessMaintenances){ + String costcenter = pm.getCostCenterCode(); + if(mapHourRate.containsKey(costcenter)){ + AppSceneCostHourRate hourrate = mapHourRate.get(costcenter); + labor+=hourrate.getLaborHourRate().doubleValue()*pm.getLaborHour().doubleValue(); + equip+=hourrate.getEquipHourRate().doubleValue()*pm.getMachineHour().doubleValue(); + fuel+=hourrate.getFuelHourRate().doubleValue()*pm.getBurningHour().doubleValue(); + auxi+=hourrate.getAuxiliaryHourRate().doubleValue()*pm.getAuxiliaryHour().doubleValue(); + other+=hourrate.getOtherHourRate().doubleValue()*pm.getOtherHour().doubleValue(); + } + } + } + AppSceneCostResultValue resultValue = AppSceneCostResultValue.builder() + .belongTopMaterialNo(topMaterialCode) + .marterialNo(appSceneCostResultValue.getMarterialNo()) + .parentMarterialNo(appSceneCostResultValue.getParentMarterialNo()) + .taskType(taskType) + .taskCode(taskCode) + .flowInstanceId(Integer.valueOf(flowInstanceId)) + .countValue("") + .material(appSceneCostResultValue.getMaterial()) + .priceType(appSceneCostResultValue.getPriceType()) + .labor(new BigDecimal(labor)) + .equip(new BigDecimal(equip)) + .fuel(new BigDecimal(fuel)) + .auxi(new BigDecimal(auxi)) + .other(new BigDecimal(other)) + .num(appSceneCostResultValue.getNum()) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .depth(appSceneCostResultValue.getDepth()) + .layer(appSceneCostResultValue.getLayer()) + .build(); + standardCostService.iAppSceneCostResultValueService.save(resultValue); + } + } + /** * 【4.制造费用】 * @@ -233,12 +415,13 @@ public class StandardCostService { * @param flowInstanceId 流程实例id */ public static void countManufacturingCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String feeType, AppSceneCostHourRate appSceneCostHourRate) { + log.info("countManufacturingCostByTopMaterialCode"); //1.查询出人员工时费率 - AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(appSceneCostHourRate); + //AppSceneCostHourRate hourRateInfo = standardCostService.iHourRateService.getOneHourRateInfo(appSceneCostHourRate); BigDecimal hourRate = new BigDecimal("0"); - if (hourRateInfo != null) { - hourRate = hourRateInfo.getLaborHourRate(); - } + //if (hourRateInfo != null) { + // hourRate = hourRateInfo.getLaborHourRate(); + //} //1.查询出物料编号对应的下所有的BOM信息 List list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "MaterialInput", String.valueOf(flowInstanceId)); //2.根据费用类型进行不同的费用计算 @@ -266,7 +449,22 @@ public class StandardCostService { } } //2.2计算机器成本并存储到成本结果数据表中 - 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(); + 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) + .num(appSceneCostResultValue.getNum()) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } @@ -289,7 +487,22 @@ public class StandardCostService { } } //2.2计算机物料消耗存储到成本结果数据表中 - 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(); + 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) + .num(appSceneCostResultValue.getNum()) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } @@ -312,7 +525,22 @@ public class StandardCostService { } } //2.2计算机物料消耗存储到成本结果数据表中 - 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(); + 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) + .num(appSceneCostResultValue.getNum()) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } @@ -335,30 +563,55 @@ public class StandardCostService { } } //2.2计算机物料消耗存储到成本结果数据表中 - 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(); + 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) + .num(appSceneCostResultValue.getNum()) + .pnum(appSceneCostResultValue.getPnum()) + .topnum(appSceneCostResultValue.getTopnum()) + .manuType(appSceneCostResultValue.getManuType()) + .build(); standardCostService.iAppSceneCostResultValueService.save(resultValue); } } - } else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) { - //查出所有的机器折旧费、机物料消耗、水电费、其他制费 - list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "ManufacturingCost", String.valueOf(flowInstanceId)); - //2.5物流费((机器折旧+机物料消耗+水电费+其他制费)*10.16%) - //按照物料编号进行分组 - Map> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo)); - for (String key : materialNoMap.keySet()) { - List appSceneCostResultValues = materialNoMap.get(key); - BigDecimal totalCost = new BigDecimal("0.0"); - for (int j = 0; j < appSceneCostResultValues.size(); j++) { - AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j); - String countValue = appSceneCostResultValue.getCountValue(); - if (countValue != null) { - totalCost = totalCost.add(new BigDecimal(countValue)); - } - } - 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(); - standardCostService.iAppSceneCostResultValueService.save(resultValue); - } } +// else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) { +// //查出所有的机器折旧费、机物料消耗、水电费、其他制费 +// list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "ManufacturingCost", String.valueOf(flowInstanceId)); +// //2.5物流费((机器折旧+机物料消耗+水电费+其他制费)*10.16%) +// //按照物料编号进行分组 +// Map> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo)); +// for (String key : materialNoMap.keySet()) { +// List appSceneCostResultValues = materialNoMap.get(key); +// BigDecimal totalCost = new BigDecimal("0.0"); +// for (int j = 0; j < appSceneCostResultValues.size(); j++) { +// AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j); +// String countValue = appSceneCostResultValue.getCountValue(); +// if (countValue != null) { +// totalCost = totalCost.add(new BigDecimal(countValue)); +// } +// } +// 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(); +// standardCostService.iAppSceneCostResultValueService.save(resultValue); +// } +// } } /** @@ -370,138 +623,134 @@ public class StandardCostService { * @param flowInstanceId 流程实例id * @param costType 流程实例id */ - public static void countStandardCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String costType, String versionNumber) { + public static void countStandardCostByTopMaterialCode(String topMaterialCode, String taskType, String taskCode, Integer flowInstanceId, String costType, String stage,String versionNumber) { + log.info("countStandardCostByTopMaterialCode"); //1.查询出根物料编号对应的下所有的BOM信息结果值 - List list = standardCostService.iAppSceneCostResultValueService.getAllResultValueByTopMaterialNo(topMaterialCode, String.valueOf(flowInstanceId)); + //List list = standardCostService.iAppSceneCostResultValueService.getAllResultValueByTopMaterialNo(topMaterialCode, String.valueOf(flowInstanceId)); + List list = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, "ManufacturingCost", String.valueOf(flowInstanceId)); + List MarterialNoList = new ArrayList<>(); + if (list != null && list.size() > 0) { + MarterialNoList = list.stream().filter(s -> s.getMarterialNo() != null).map(AppSceneCostResultValue::getMarterialNo).collect(Collectors.toList()); + } + Map maktxMap = standardCostService.iAppSceneCostMaterialService.getMaktxByMaterialNo(MarterialNoList); //2.计算出所有的单个物料的本阶的标准成本(标准成本=物料成本+人工成本+制造费用) //按照物料编号进行分组 - Map> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getMarterialNo)); + Map> materialNoMap = list.stream().collect(Collectors.groupingBy(AppSceneCostResultValue::getDepth)); + + Set soredDepth = new HashSet<>(); + for (Integer depth : materialNoMap.keySet()) { + soredDepth.add(depth); + } + ArrayList deplist = new ArrayList<>(soredDepth); + Collections.reverse(deplist); + + List appSceneCostStandardResults=new ArrayList<>(); + //遍历根物料下所有的物料进行该物料本阶成本和费用类别的统计 - for (String key : materialNoMap.keySet()) { - List appSceneCostResultValues = materialNoMap.get(key); - //按照费用类别进行分组 - Map> costTypeMap = appSceneCostResultValues.stream().filter(s -> s.getCostType() != null).collect(Collectors.groupingBy(AppSceneCostResultValue::getCostType)); - //【本阶标准成本】 - BigDecimal currentCost = new BigDecimal("0.0"); - //1.本阶物料成本 - BigDecimal materialCost = new BigDecimal("0.0"); - //2.本阶人工成本 - BigDecimal laborCost = new BigDecimal("0.0"); - //3.本阶制造费(设备费) - BigDecimal equipmentCost = new BigDecimal("0.0"); - //4.本阶制造费(辅料费用) - BigDecimal supplyMaterialCost = new BigDecimal("0.0"); - //5.本阶制造费(水电费、燃动费) - BigDecimal driveCost = new BigDecimal("0.0"); - //6.本阶制造费(其他制造费用) - BigDecimal otherCost = new BigDecimal("0.0"); - //7.本阶制造费(物流费) - BigDecimal logisticsCost = new BigDecimal("0.0"); - //物料单价 - BigDecimal materialUnitPrice = new BigDecimal("0.0"); - //人员工时、小时费率 - BigDecimal laborHour = new BigDecimal("0.0"); - BigDecimal laborHourRate = new BigDecimal("0.0"); - //设备工时、小时费率 - BigDecimal equipmentHour = new BigDecimal("0.0"); - BigDecimal equipmentHourRate = new BigDecimal("0.0"); - //辅料工时、小时费率 - BigDecimal supplyMaterialHour = new BigDecimal("0.0"); - BigDecimal supplyMaterialHourRate = new BigDecimal("0.0"); - //燃动工时、小时费率 - BigDecimal driveHour = new BigDecimal("0.0"); - BigDecimal driveHourRate = new BigDecimal("0.0"); - //其他工时、小时费率 - BigDecimal otherHour = new BigDecimal("0.0"); - BigDecimal otherHourRate = new BigDecimal("0.0"); - AppSceneCostResultValue currentMaterialCost = null; - //遍历所有费用类别计算本阶标准成本 - for (int j = 0; j < appSceneCostResultValues.size(); j++) { - if (j == 0) { - //初始化当前物料成本信息 - currentMaterialCost = appSceneCostResultValues.get(0); - } - AppSceneCostResultValue appSceneCostResultValue = appSceneCostResultValues.get(j); - String countValue = appSceneCostResultValue.getCountValue(); - if (countValue != null) { - currentCost = currentCost.add(new BigDecimal(countValue)); - } - } - //计算本阶各个费用类别费用以及记录本阶物料的工时和小时费率 - for (String feeType : costTypeMap.keySet()) { - List appSceneCostResultValues1 = costTypeMap.get(feeType); - for (int m = 0; m < appSceneCostResultValues1.size(); m++) { - if (FeeTypeEnum.MaterialCost.getCode().equals(feeType)) { - //物料成本 - materialCost = materialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - //物料单价 - materialUnitPrice = appSceneCostResultValues1.get(m).getPriceOrRate(); - //TODO 数量 - currentMaterialCost.setNum(appSceneCostResultValues1.get(m).getNum()); - } else if (FeeTypeEnum.LaborCost.getCode().equals(feeType)) { - //人工成本 - laborCost = laborCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - //人工工时、小时费率 - laborHour = laborHour.add(appSceneCostResultValues1.get(m).getHour()); - laborHourRate = laborHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate()); - } else if (FeeTypeEnum.EquipmentFee.getCode().equals(feeType)) { - //设备费用 - equipmentCost = equipmentCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - //设备工时、小时费率 - equipmentHour = equipmentHour.add(appSceneCostResultValues1.get(m).getHour()); - equipmentHourRate = equipmentHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate()); - } else if (FeeTypeEnum.SupplyMaterialFee.getCode().equals(feeType)) { - //辅料费用 - supplyMaterialCost = supplyMaterialCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - //辅料工时、小时费率 - supplyMaterialHour = supplyMaterialHour.add(appSceneCostResultValues1.get(m).getHour()); - supplyMaterialHourRate = supplyMaterialHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate()); - } else if (FeeTypeEnum.DriverFee.getCode().equals(feeType)) { - //燃动费用 - driveCost = driveCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - //燃动工时、小时费率 - driveHour = driveHour.add(appSceneCostResultValues1.get(m).getHour()); - driveHourRate = driveHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate()); - } else if (FeeTypeEnum.LogisticsFee.getCode().equals(feeType)) { - //物流费用 - logisticsCost = logisticsCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - } else if (FeeTypeEnum.OtherFee.getCode().equals(feeType)) { - //其他费用 - otherCost = otherCost.add(new BigDecimal(appSceneCostResultValues1.get(m).getCountValue())); - //其他工时、小时费率 - otherHour = otherHour.add(appSceneCostResultValues1.get(m).getHour()); - otherHourRate = otherHourRate.add(appSceneCostResultValues1.get(m).getPriceOrRate()); + for (Integer depth : deplist) { + List appSceneCostResultValues = materialNoMap.get(depth); + for (AppSceneCostResultValue ascr:appSceneCostResultValues){ + //BigDecimal currentCost = new BigDecimal("0.0"); + //1.本阶物料成本 + double materialCost = 0; + //2.本阶人工成本 + double laborCost = 0; + //3.本阶制造费(设备费) + double equipmentCost = 0; + //4.本阶制造费(辅料费用) + double fuelcost = 0; + //5.本阶制造费(水电费、燃动费) + double auxicost = 0; + //6.本阶制造费(其他制造费用) + double otherCost = 0; + //7.本阶物料成本 + double materialCost_acc = 0; + //8.本阶人工成本 + double laborCost_acc = 0; + //9.本阶制造费(设备费) + double equipmentCost_acc = 0; + //10.本阶制造费(辅料费用) + double fuelcost_acc = 0; + //11.本阶制造费(水电费、燃动费) + double auxicost_acc = 0; + //12.本阶制造费(其他制造费用) + double otherCost_acc = 0; + + if(ascr.getManuType().equals("F")){ + materialCost = ascr.getMaterial().doubleValue()*ascr.getNum().doubleValue(); + }else if(ascr.getManuType().equals("E")){ + double labor = ascr.getLabor().doubleValue(); + double equip = ascr.getEquip().doubleValue(); + double fuel = ascr.getFuel().doubleValue(); + double auxi = ascr.getAuxi().doubleValue(); + double other = ascr.getOther().doubleValue(); + laborCost = labor*ascr.getNum().doubleValue(); + equipmentCost =equip*ascr.getNum().doubleValue(); + fuelcost = fuel*ascr.getNum().doubleValue(); + auxicost = auxi*ascr.getNum().doubleValue(); + otherCost = other*ascr.getNum().doubleValue(); + + for (AppSceneCostStandardResult child:appSceneCostStandardResults){ + if((Integer.parseInt(child.getLowOrderCode())==depth+1)&&child.getParentMatnr().equals(ascr.getMarterialNo())){ + if(child.getManuType().equals("F")){ + materialCost_acc+=child.getMaterialCostStage().doubleValue()*ascr.getNum().doubleValue(); + }else if(child.getManuType().equals("E")){ + materialCost_acc+=child.getMaterialCostStage().doubleValue()*ascr.getNum().doubleValue()+child.getMaterialCostAccumulated().doubleValue()*ascr.getNum().doubleValue(); + laborCost_acc+=(child.getLaborCostStage().doubleValue()+child.getLaborCostAccumulated().doubleValue())*ascr.getNum().doubleValue(); + equipmentCost_acc+=(child.getEquipCostStage().doubleValue()+child.getEquipCostAccumulated().doubleValue())*ascr.getNum().doubleValue(); + fuelcost_acc+=(child.getBurningCostStage().doubleValue()+child.getBurningCostAccumulated().doubleValue())*ascr.getNum().doubleValue(); + auxicost_acc+=(child.getAuxiliaryCostStage().doubleValue()+child.getAuxiliaryCostAccumulated().doubleValue())*ascr.getNum().doubleValue(); + otherCost_acc+=(child.getOtherCostStage().doubleValue()+child.getOtherCostAccumulated().doubleValue())*ascr.getNum().doubleValue(); + } + } } } + String maktx = ""; + if(maktxMap.containsKey(ascr.getMarterialNo())){ + maktx=maktxMap.get(ascr.getMarterialNo()); + } + AppSceneCostStandardResult appSceneCostStandardResult=AppSceneCostStandardResult.builder() + .materialNumber(ascr.getMarterialNo()) + .parentMatnr(ascr.getParentMarterialNo()) + .pricetype(ascr.getPriceType()) + .materialCostStage(new BigDecimal(materialCost)) + .laborCostStage(new BigDecimal(laborCost)) + .equipCostStage(new BigDecimal(equipmentCost)) + .burningCostStage(new BigDecimal(fuelcost)) + .auxiliaryCostStage(new BigDecimal(auxicost)) + .otherCostStage(new BigDecimal(otherCost)) + .materialCostAccumulated(new BigDecimal(materialCost_acc)) + .laborCostAccumulated(new BigDecimal(laborCost_acc)) + .equipCostAccumulated(new BigDecimal(equipmentCost_acc)) + .burningCostAccumulated(new BigDecimal(fuelcost_acc)) + .auxiliaryCostAccumulated(new BigDecimal(auxicost_acc)) + .otherCostAccumulated(new BigDecimal(otherCost_acc)) + .materialCostTotal(new BigDecimal(materialCost+materialCost_acc)) + .laborCostTotal(new BigDecimal(laborCost+laborCost_acc)) + .equipCostTotal(new BigDecimal(equipmentCost+equipmentCost_acc)) + .burningCostTotal(new BigDecimal(fuelcost+fuelcost_acc)) + .auxiliaryCostTotal(new BigDecimal(auxicost+auxicost_acc)) + .otherCostTotal(new BigDecimal(otherCost+otherCost_acc)) + .totalStandardCost(new BigDecimal(materialCost+laborCost+equipmentCost+fuelcost+auxicost+otherCost+materialCost_acc+laborCost_acc+equipmentCost_acc+fuelcost_acc+auxicost_acc+otherCost_acc)) + .lowOrderCode(String.valueOf(depth)) + .relativeDosage(ascr.getNum()) + .createdTime(new Date()) + .menge(ascr.getNum()) + .manuType(ascr.getManuType()) + .versionNumber(versionNumber) + .stage(stage) + .layer(ascr.getLayer()) + .factory("7100") + .maktx(maktx) + .build(); + appSceneCostStandardResults.add(appSceneCostStandardResult); } - //本阶不同费用类别成本统计 - JSONObject currentLevelCostTypeDetail = new JSONObject(); - currentLevelCostTypeDetail.put(FeeTypeEnum.MaterialCost.getCode(), materialCost); - currentLevelCostTypeDetail.put(FeeTypeEnum.LaborCost.getCode(), laborCost); - currentLevelCostTypeDetail.put(FeeTypeEnum.EquipmentFee.getCode(), equipmentCost); - currentLevelCostTypeDetail.put(FeeTypeEnum.SupplyMaterialFee.getCode(), supplyMaterialCost); - currentLevelCostTypeDetail.put(FeeTypeEnum.DriverFee.getCode(), driveCost); - currentLevelCostTypeDetail.put(FeeTypeEnum.LogisticsFee.getCode(), logisticsCost); - currentLevelCostTypeDetail.put(FeeTypeEnum.OtherFee.getCode(), otherCost); - //统计本阶不同费用类别工时、小时费率 - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.MaterialUnitPrice.getCode(), materialUnitPrice); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.LaborHour.getCode(), laborHour); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.LaborHourRate.getCode(), laborHourRate); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.EquipmentHour.getCode(), equipmentHour); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.EquipmentHourRate.getCode(), equipmentHourRate); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.SupplyMaterialHour.getCode(), supplyMaterialHour); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.SupplyMaterialHourRate.getCode(), supplyMaterialHourRate); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.DriverHour.getCode(), driveHour); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.DriverHourRate.getCode(), driveHourRate); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.OtherHour.getCode(), otherHour); - currentLevelCostTypeDetail.put(HourOrRateTypeEnum.OtherHourRate.getCode(), otherHourRate); - 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(); - standardCostService.iAppSceneCostResultValueService.save(resultValue); } + standardCostService.iAppSceneCostStandardResultService.saveBatch(appSceneCostStandardResults); //3.计算出所有的单个物料的累计标准成本 - List standardCostList = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, taskType, String.valueOf(flowInstanceId)); + //List standardCostList = standardCostService.iAppSceneCostResultValueService.getResultValueByTopMaterialNo(topMaterialCode, taskType, String.valueOf(flowInstanceId)); //【累计成本】的计算 - totalCountCost(standardCostList, topMaterialCode, taskType, taskCode, String.valueOf(flowInstanceId), versionNumber); + //totalCountCost(standardCostList, topMaterialCode, taskType, taskCode, String.valueOf(flowInstanceId), versionNumber); } /** @@ -734,7 +983,22 @@ public class StandardCostService { // .sort() // .figureNumber() // .dosage(oldAppSceneCostResultValue.getNum() != null ? oldAppSceneCostResultValue.getNum().doubleValue() : 0).unit(oldAppSceneCostResultValue.getUnit()) - .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(); + .materialCostTotal(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())) + .otherCostStage(costDetailJson.getBigDecimal(FeeTypeEnum.OtherFee.getCode())) + .totalStandardCost(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())) + .otherCostAccumulated(costDetailJson.getBigDecimal(TotalCostEnum.TotalOtherFee.getCode())) + .totalStandardCost(costDetailJson.getBigDecimal(TotalCostEnum.TotalStandardCost.getCode())) + .lowOrderCode(String.valueOf(oldAppSceneCostResultValue.getDepth())) + .createdTime(new Date()).build(); costStandardResults.add(costStandardResultValue); } //更新结果集到标准成本单行查询中去 diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostBomRelevancyService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostBomRelevancyService.java index dc95f4b..64b4f6a 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostBomRelevancyService.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostBomRelevancyService.java @@ -2,6 +2,7 @@ package com.zzsmart.qomo.kn.cost.manage.service; import com.baomidou.mybatisplus.extension.service.IService; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostBomRelevancy; +import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo; import java.util.List; @@ -24,6 +25,6 @@ public interface IAppSceneCostBomRelevancyService extends IService queryAllBomInfoByTopMaterialCode(String topMaterialCode); + List queryAllBomInfoByTopMaterialCode(String topMaterialCode); } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostHourRateService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostHourRateService.java index 8525fb7..d4d1adc 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostHourRateService.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostHourRateService.java @@ -3,6 +3,8 @@ package com.zzsmart.qomo.kn.cost.manage.service; import com.baomidou.mybatisplus.extension.service.IService; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostHourRate; +import java.util.Map; + /** * @Description: app_scene_cost_hour_rate * @Author: jeecg-boot @@ -15,5 +17,5 @@ public interface IAppSceneCostHourRateService extends IService getOneHourRateInfo(); } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostMaterialService.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostMaterialService.java new file mode 100644 index 0000000..8629418 --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/IAppSceneCostMaterialService.java @@ -0,0 +1,21 @@ +package com.zzsmart.qomo.kn.cost.manage.service; + +//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial; +import com.baomidou.mybatisplus.extension.service.IService; +import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial; + +import java.util.List; +import java.util.Map; + +/** + * @Description: app_scene_cost_material + * @Author: jeecg-boot + * @Date: 2024-09-17 + * @Version: V1.0 + */ +public interface IAppSceneCostMaterialService extends IService { + + public Map getManuTypeByMaterialNo(List materialNos) ; + + public Map getMaktxByMaterialNo(List materialNos) ; +} diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostBomRelevancyServiceImpl.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostBomRelevancyServiceImpl.java index 2c9f11d..5fd1324 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostBomRelevancyServiceImpl.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostBomRelevancyServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostBomRelevancy; import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostBomRelevancyMapper; import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostBomRelevancyService; +import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -51,8 +52,8 @@ public class AppSceneCostBomRelevancyServiceImpl extends ServiceImpl queryAllBomInfoByTopMaterialCode(String topMaterialCode) { - List childrens = costMaterialBomMapper.findChildrenByParentId(topMaterialCode); + public List queryAllBomInfoByTopMaterialCode(String topMaterialCode) { + List childrens = costMaterialBomMapper.findChildrenByParentId(topMaterialCode); //TODO 循环遍历查出所有的物料下的物料(包含最上层的物料) //TODO 所有的物料并进行层级排序 return childrens; diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java index 2707195..96be6d7 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostCountServiceImpl.java @@ -127,8 +127,9 @@ public class AppSceneCostCountServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - if(appSceneCostHourRate!=null){ - if(appSceneCostHourRate.getYear()!=null){ - queryWrapper.eq("year",appSceneCostHourRate.getYear()); + public Map getOneHourRateInfo() { + //QueryWrapper queryWrapper = new QueryWrapper<>(); + List appSceneCostHourRateList= this.query().list(); + Map map=new HashMap<>(); + for (AppSceneCostHourRate appSceneCostHourRate:appSceneCostHourRateList){ + if(!map.containsKey(appSceneCostHourRate.getCostCenterCode())){ + map.put(appSceneCostHourRate.getCostCenterCode(),appSceneCostHourRate); } - if(appSceneCostHourRate.getCostCenterCode()!=null){ - queryWrapper.eq("cost_center_code",appSceneCostHourRate.getCostCenterCode()); - } - if(appSceneCostHourRate.getFactory()!=null){ - queryWrapper.eq("factory",appSceneCostHourRate.getFactory()); - } - queryWrapper.last("limit 1"); - return this.getOne(queryWrapper); } - return null; + return map; } } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostMaterialServiceImpl.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostMaterialServiceImpl.java new file mode 100644 index 0000000..9cc8478 --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/AppSceneCostMaterialServiceImpl.java @@ -0,0 +1,62 @@ +package com.zzsmart.qomo.kn.cost.manage.service.impl; + +//import com.zzsmart.qomo.modules.demo..entity.AppSceneCostMaterial; +//import com.zzsmart.qomo.modules.demo..mapper.AppSceneCostMaterialMapper; +//import com.zzsmart.qomo.modules.demo..service.IAppSceneCostMaterialService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostMaterial; +import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostPurchaseRecord; +import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostMaterialMapper; +import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostPurchaseRecordMapper; +import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostMaterialService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Description: app_scene_cost_material + * @Author: jeecg-boot + * @Date: 2024-09-17 + * @Version: V1.0 + */ +@Service +public class AppSceneCostMaterialServiceImpl extends ServiceImpl implements IAppSceneCostMaterialService { + + @Autowired + AppSceneCostMaterialMapper appSceneCostMaterialMapper; + @Override + public Map getManuTypeByMaterialNo(List materialNos) { + Map map = new HashMap<>(); + QueryWrapper queryWrapper = new QueryWrapper(); + if (materialNos != null && materialNos.size() > 0) { + queryWrapper.in("material_number", materialNos); + List costPurchasePrices = appSceneCostMaterialMapper.selectList(queryWrapper); + for (int i = 0; i < costPurchasePrices.size(); i++) { + AppSceneCostMaterial costPurchasePrice = costPurchasePrices.get(i); + map.put(costPurchasePrice.getMaterialNumber(), costPurchasePrice.getManufacturingType()); + } + } + return map; + } + + @Override + public Map getMaktxByMaterialNo(List materialNos) { + Map map = new HashMap<>(); + QueryWrapper queryWrapper = new QueryWrapper(); + if (materialNos != null && materialNos.size() > 0) { + queryWrapper.in("material_number", materialNos); + List costPurchasePrices = appSceneCostMaterialMapper.selectList(queryWrapper); + for (int i = 0; i < costPurchasePrices.size(); i++) { + AppSceneCostMaterial costPurchasePrice = costPurchasePrices.get(i); + map.put(costPurchasePrice.getMaterialNumber(), costPurchasePrice.getProductName()); + } + } + return map; + } +} diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/BomTreeServiceImpl.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/BomTreeServiceImpl.java index e59f926..c9256d1 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/BomTreeServiceImpl.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/service/impl/BomTreeServiceImpl.java @@ -3,7 +3,9 @@ package com.zzsmart.qomo.kn.cost.manage.service.impl; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardDetail; +import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardResult; import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostStandardDetailMapper; +import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostStandardResultMapper; import com.zzsmart.qomo.kn.cost.manage.service.BomTreeService; import com.zzsmart.qomo.kn.cost.manage.util.BomTreeBuilder; import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO; @@ -21,6 +23,9 @@ public class BomTreeServiceImpl implements BomTreeService { @Autowired AppSceneCostStandardDetailMapper costStandardDetailMapper; + @Autowired + AppSceneCostStandardResultMapper appSceneCostStandardResultMapper; + /** * 根据物料号查询物料树 * @@ -29,7 +34,7 @@ public class BomTreeServiceImpl implements BomTreeService { */ @Override public List getBomTreeByMaterialNumber(String materialNumber, String version_number) { - QueryWrapper wrapper = new QueryWrapper<>(); + QueryWrapper wrapper = new QueryWrapper<>(); //设置条件 if (StrUtil.isNotEmpty(materialNumber)) { // 物料号 @@ -40,49 +45,52 @@ public class BomTreeServiceImpl implements BomTreeService { wrapper.like("version_number", version_number); } //查询所有满足条件的父节点 - List parentNodeList = costStandardDetailMapper.selectList(wrapper); + List parentNodeList = appSceneCostStandardResultMapper.selectList(wrapper); //所有子类节点 - List childrenNodeList = new ArrayList<>(); - Map parentDataMap = new TreeMap<>(); + List childrenNodeList = new ArrayList<>(); + Map parentDataMap = new TreeMap<>(); if (parentNodeList.size() > 0) { //父类结果只有1个 if (parentNodeList.size() == 1) { - parentDataMap = parentNodeList.stream().collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo)); + parentDataMap = parentNodeList.stream().collect(Collectors.toMap(AppSceneCostStandardResult::getMaterialNumber, vo -> vo)); } else { //父类结果有多个(找出最上级节点) - Map> levelGroupMap = new HashMap<>(); + Map> levelGroupMap = new HashMap<>(); if (parentNodeList != null && parentNodeList.size() > 0) { - levelGroupMap = parentNodeList.stream().filter(s->s.getLevel()!=null).collect(Collectors.groupingBy(AppSceneCostStandardDetail::getLevel)); - TreeMap> levelTreeMap = new TreeMap<>(levelGroupMap); - parentDataMap = levelTreeMap.firstEntry().getValue().stream().filter(s->s.getMaterialNumber()!=null).collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo)); + levelGroupMap = parentNodeList.stream().filter(s->s.getLowOrderCode()!=null).collect(Collectors.groupingBy(AppSceneCostStandardResult::getLowOrderCode)); + TreeMap> levelTreeMap = new TreeMap<>(levelGroupMap); + parentDataMap = levelTreeMap.firstEntry().getValue().stream().filter(s->s.getMaterialNumber()!=null).collect(Collectors.toMap(AppSceneCostStandardResult::getMaterialNumber, vo -> vo)); } } //查询所有父节点下的子节点(即第二层叶子节点) - List costStandardDetails = new ArrayList<>(); + List costStandardDetails = new ArrayList<>(); if (parentDataMap.size() > 0) { - QueryWrapper wrapper1 = new QueryWrapper<>(); + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq("version_number", version_number); int num = 0; for (String materialNumber1 : parentDataMap.keySet()) { num = num + 1; if (num > 1) { - wrapper1.or().eq("parent_material_number", materialNumber1); + wrapper1.or().eq("parent_matnr", materialNumber1); } else { - wrapper1.eq("parent_material_number", materialNumber1); + wrapper1.eq("parent_matnr", materialNumber1); } } - costStandardDetails = costStandardDetailMapper.selectList(wrapper1); + costStandardDetails = appSceneCostStandardResultMapper.selectList(wrapper1); } //第三层叶子节点 - List threeNodes = new ArrayList<>(); + List threeNodes = new ArrayList<>(); if (costStandardDetails != null && costStandardDetails.size() > 0) { - List materialNoList = costStandardDetails.stream().map(AppSceneCostStandardDetail::getMaterialNumber).collect(Collectors.toList()); - QueryWrapper wrapper2 = new QueryWrapper<>(); - wrapper2.in("parent_material_number", materialNoList); - threeNodes = costStandardDetailMapper.selectList(wrapper2); + List materialNoList = costStandardDetails.stream().map(AppSceneCostStandardResult::getMaterialNumber).collect(Collectors.toList()); + QueryWrapper wrapper2 = new QueryWrapper<>(); + wrapper2.in("parent_matnr", materialNoList); + wrapper2.eq("version_number", version_number); + wrapper2.eq("low_order_code",2); + threeNodes = appSceneCostStandardResultMapper.selectList(wrapper2); } //把第二层叶子节点转化为bomtreeinfoVO对象集合 for (int i = 0; i < costStandardDetails.size(); i++) { - AppSceneCostStandardDetail costStandardDetail = costStandardDetails.get(i); + AppSceneCostStandardResult costStandardDetail = costStandardDetails.get(i); // AppSceneCostStandardDetail vo = new AppSceneCostStandardDetail(); // BeanUtils.copyProperties(costStandardDetail, vo); // childrenNodeList.add(vo); @@ -90,7 +98,7 @@ public class BomTreeServiceImpl implements BomTreeService { } //把第三层叶子节点转化为bomtreeinfoVO对象集合 for (int i = 0; i < threeNodes.size(); i++) { - AppSceneCostStandardDetail costStandardDetail = threeNodes.get(i); + AppSceneCostStandardResult costStandardDetail = threeNodes.get(i); // CostStandardDetailVO vo = new CostStandardDetailVO(); // BeanUtils.copyProperties(costStandardDetail, vo); // childrenNodeList.add(vo); diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/util/BomTreeBuilder.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/util/BomTreeBuilder.java index f43c06c..26c5d67 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/util/BomTreeBuilder.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/util/BomTreeBuilder.java @@ -1,6 +1,7 @@ package com.zzsmart.qomo.kn.cost.manage.util; import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardDetail; +import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostStandardResult; import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO; import java.util.ArrayList; @@ -10,16 +11,16 @@ import java.util.Map; import java.util.stream.Collectors; public class BomTreeBuilder { - public static List buildBomTree(List sourceData, Map parentDataMap) { + public static List buildBomTree(List sourceData, Map parentDataMap) { List result = new ArrayList<>(); if ((sourceData == null || (sourceData != null && sourceData.size() < 1)) && (parentDataMap == null || (parentDataMap != null && parentDataMap.size() < 1))) { return result; } //1.把BOM信息分成按照物料号分组 - Map materialMap = sourceData.stream().filter(s->s.getMaterialNumber()!=null) + Map materialMap = sourceData.stream().filter(s->s.getMaterialNumber()!=null) .collect(Collectors.toMap( // Key extractor - AppSceneCostStandardDetail::getMaterialNumber, + AppSceneCostStandardResult::getMaterialNumber, // Value mapper detail -> detail, // Merger function to handle duplicates @@ -29,10 +30,10 @@ public class BomTreeBuilder { // Map materialMap = sourceData.stream().filter(s -> s.getMaterialNumber() != null).collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo)); //查找最顶端的父类节点 if (parentDataMap == null || (parentDataMap != null && parentDataMap.size() < 1)) { - parentDataMap = sourceData.stream().filter(s -> s.getParentMaterialNumber() == null).collect(Collectors.toMap(AppSceneCostStandardDetail::getMaterialNumber, vo -> vo)); + parentDataMap = sourceData.stream().filter(s -> s.getLayer().equals("0")).collect(Collectors.toMap(AppSceneCostStandardResult::getMaterialNumber, vo -> vo)); } //查找有父节点的子节点 - Map> childDataMap = sourceData.stream().filter(s -> s.getParentMaterialNumber() != null).collect(Collectors.groupingBy(AppSceneCostStandardDetail::getParentMaterialNumber)); + Map> childDataMap = sourceData.stream().filter(s -> s.getParentMatnr() != null).collect(Collectors.groupingBy(AppSceneCostStandardResult::getParentMatnr)); //查找有父节点的子节点 // //1.把BOM信息分成按照层级分组 // Map> levelMap = sourceData.stream().filter(s -> s.getLevel() != null).collect(Collectors.groupingBy(CostStandardDetail::getLevel)); @@ -45,7 +46,7 @@ public class BomTreeBuilder { // TreeMap> levelTreeMap = new TreeMap<>(levelMap); //3.构建BOM树 if (parentDataMap.size() > 0) { - for (AppSceneCostStandardDetail parent : parentDataMap.values()) { + for (AppSceneCostStandardResult parent : parentDataMap.values()) { BomTreeInfoVO parentBomTreeInfoVO = costStandardDetailChangeToBomTreeInfoVO(parent); parentBomTreeInfoVO = loopFindChildrenBuild(parentBomTreeInfoVO, materialMap, childDataMap, result); if (parentBomTreeInfoVO != null) { @@ -59,23 +60,31 @@ public class BomTreeBuilder { return result; } - private static BomTreeInfoVO loopFindChildrenBuild(BomTreeInfoVO parentBomTreeInfoVO, Map materialMap, Map> childDataMap, List result) { + private static BomTreeInfoVO loopFindChildrenBuild(BomTreeInfoVO parentBomTreeInfoVO, Map materialMap, Map> childDataMap, List result) { if (parentBomTreeInfoVO != null) { //4.根据物料号查找子节点 - List childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber()); + List childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber()); if (childs != null && childs.size() > 0) { parentBomTreeInfoVO.setHasChildren(true); } else { parentBomTreeInfoVO.setHasChildren(false); + return parentBomTreeInfoVO; } //构造父节点下的bomtree结构数据 List children = new ArrayList<>(); for (int j = 0; childs != null && childs.size() > 0 && j < childs.size(); j++) { - AppSceneCostStandardDetail child = childs.get(j); + AppSceneCostStandardResult child = childs.get(j); + if(child.getParentMatnr().equals(child.getMaterialNumber())){ + continue; + } BomTreeInfoVO childBomTreeInfoVO = costStandardDetailChangeToBomTreeInfoVO(child); childBomTreeInfoVO = loopFindChildrenBuild(childBomTreeInfoVO, materialMap, childDataMap, result); children.add(childBomTreeInfoVO); } + if(parentBomTreeInfoVO.getLevel()==0){ + int x=0; + x++; + } //对象的子节点进行排序(升序) children = children.stream().sorted(Comparator.comparing(BomTreeInfoVO::getSort, Comparator.nullsLast(Comparator.naturalOrder()))).collect(Collectors.toList()); parentBomTreeInfoVO.setChildren(children); @@ -89,8 +98,39 @@ public class BomTreeBuilder { * @param parent * @return */ - static BomTreeInfoVO costStandardDetailChangeToBomTreeInfoVO(AppSceneCostStandardDetail parent) { - 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(); + static BomTreeInfoVO costStandardDetailChangeToBomTreeInfoVO(AppSceneCostStandardResult parent) { + if(parent.getMenge()==null){ + int x=0; + x++; + } + String layer = parent.getLayer(); + int index = layer.lastIndexOf("-"); + if(index!=-1){ + layer = layer.substring(index+1,layer.length()); + } + //layer = layer.substring(index+1,layer.length()); + BomTreeInfoVO bomTreeInfoVO = BomTreeInfoVO.builder() + .materialNumber(parent.getMaterialNumber()) + .materialName(parent.getMaktx()) + .level(Integer.parseInt(parent.getLowOrderCode())) + .parentMaterialNumber(parent.getParentMatnr()) + .quantity(parent.getMenge().doubleValue()) + .materialCost(parent.getMaterialCostStage()) + .auxiliaryCost(parent.getAuxiliaryCostStage()) + .equipCost(parent.getEquipCostStage()) + .otherCost(parent.getOtherCostStage()) + .laborCost(parent.getLaborCostStage()) + .fuelCost(parent.getBurningCostStage()) + .accumulatedEquipCost(parent.getEquipCostAccumulated()) + .accumulatedOtherCost(parent.getOtherCostAccumulated()) + .accumulatedLaborCost(parent.getLaborCostAccumulated()) + .accumulatedMaterialCost(parent.getMaterialCostAccumulated()) + .accumulatedFuelCost(parent.getBurningCostAccumulated()) + .accumulatedAuxiliaryCost(parent.getAuxiliaryCostAccumulated()) + .standardCost(parent.getTotalStandardCost()) + .layer(parent.getLayer()) + .sort(Integer.parseInt(layer)) + .build(); return bomTreeInfoVO; } } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/AppSceneCostCountVO.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/AppSceneCostCountVO.java index 6546b30..b551adb 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/AppSceneCostCountVO.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/AppSceneCostCountVO.java @@ -6,6 +6,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Date; + @Data @Builder @NoArgsConstructor @@ -63,4 +65,8 @@ public class AppSceneCostCountVO { * 工厂 */ public String factory; + /** + * 创建时间 + */ + public Date createTime; } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeInfoVO.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeInfoVO.java index 3356e57..81a3e62 100644 --- a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeInfoVO.java +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeInfoVO.java @@ -142,4 +142,9 @@ public class BomTreeInfoVO { */ @ApiModelProperty(value = "是否有叶子节点") private boolean hasChildren; + /** + * 是否有叶子节点 + */ + @ApiModelProperty(value = "层级") + private String layer; } diff --git a/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeVo.java b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeVo.java new file mode 100644 index 0000000..b769cbf --- /dev/null +++ b/qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/BomTreeVo.java @@ -0,0 +1,37 @@ +package com.zzsmart.qomo.kn.cost.manage.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BomTreeVo { + public String matnr; + /** + * 成本中心 + */ + public String idnrk; + /** + * 领用数量 + */ + public BigDecimal menge; + /** + * 父物料领用数量 + */ + public BigDecimal pmenge; + /** + * 父物料领用数量 + */ + public BigDecimal topmenge; + /** + * 创建时间 + */ + public int depth; +}