结构树查询接口 #9
+31
@@ -0,0 +1,31 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.controller;
|
||||
|
||||
import com.zzsmart.qomo.kn.cost.manage.service.BomTreeService;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "结构树查询")
|
||||
@RestController
|
||||
@RequestMapping("//bomTree")
|
||||
@Slf4j
|
||||
public class BomTreeController {
|
||||
@Autowired
|
||||
BomTreeService bomTreeService;
|
||||
|
||||
@ApiOperation(value = "结构树查询", notes = "结构树查询")
|
||||
@GetMapping(value = "/queryBomTree")
|
||||
public Result queryBomTree(@RequestParam(name = "materialNumber", required = false) String materialNumber, @RequestParam(name = "versionNumber", required = false) String versionNumber) {
|
||||
List<BomTreeInfoVO> bomTreeInfoVOS = bomTreeService.getBomTreeByMaterialNumber(materialNumber, versionNumber);
|
||||
return Result.OK(bomTreeInfoVOS);
|
||||
}
|
||||
}
|
||||
+41
-1
@@ -1,10 +1,25 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
|
||||
import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardService;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 标准成本明细表 前端控制器
|
||||
@@ -13,8 +28,33 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author cost_purchase_price
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Api(tags="标准成本单行查询")
|
||||
@RestController
|
||||
@RequestMapping("/cost-standard-detail")
|
||||
@RequestMapping("//costStandardDetail")
|
||||
@Slf4j
|
||||
public class CostStandardDetailController {
|
||||
@Autowired
|
||||
private CostStandardDetailService costStandardDetailService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param costStandard
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "cost_standard-分页列表查询")
|
||||
@ApiOperation(value="cost_standard_detail-分页列表查询", notes="cost_standard_detail-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<CostStandardDetailVO>> queryPageList(CostStandardDetailVO costStandard,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
|
||||
Page<CostStandardDetailVO> page = new Page<CostStandardDetailVO>(pageNo, pageSize);
|
||||
IPage<CostStandardDetailVO> pageList = costStandardDetailService.pageList(page, costStandard);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
}
|
||||
|
||||
+28
-63
@@ -7,6 +7,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -16,11 +20,10 @@ import lombok.experimental.Accessors;
|
||||
* 标准成本明细表
|
||||
* </p>
|
||||
*
|
||||
* @author cost_purchase_price
|
||||
* @since 2024-06-19
|
||||
* @author
|
||||
* @since 2024-06-20
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("cost_standard_detail")
|
||||
public class CostStandardDetail implements Serializable {
|
||||
@@ -34,11 +37,24 @@ public class CostStandardDetail implements Serializable {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 子物料号,关联kn_new_sap_mara表matnr字段
|
||||
* 物料号,关联kn_new_sap_mara表matnr字段
|
||||
*/
|
||||
@TableField("material_number")
|
||||
@ApiModelProperty(value = "物料号,关联kn_new_sap_mara表matnr字段")
|
||||
private String materialNumber;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@TableField("material_name")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 父类物料号
|
||||
*/
|
||||
@TableField("parent_material_number")
|
||||
private String parentMaterialNumber;
|
||||
|
||||
/**
|
||||
* 版本号id
|
||||
*/
|
||||
@@ -49,7 +65,7 @@ public class CostStandardDetail implements Serializable {
|
||||
* 层级
|
||||
*/
|
||||
@TableField("level")
|
||||
private String level;
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
@@ -61,7 +77,7 @@ public class CostStandardDetail implements Serializable {
|
||||
* 用量
|
||||
*/
|
||||
@TableField("dosage")
|
||||
private String dosage;
|
||||
private Double dosage;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
@@ -195,61 +211,10 @@ public class CostStandardDetail implements Serializable {
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
public static final String ID = "id";
|
||||
|
||||
public static final String MATERIAL_NUMBER = "material_number";
|
||||
|
||||
public static final String VERSION_NUMBER_ID = "version_number_id";
|
||||
|
||||
public static final String LEVEL = "level";
|
||||
|
||||
public static final String FIGURE_NUMBER = "figure_number";
|
||||
|
||||
public static final String DOSAGE = "dosage";
|
||||
|
||||
public static final String UNIT = "unit";
|
||||
|
||||
public static final String SPECIFICATION = "specification";
|
||||
|
||||
public static final String BOM_COST = "bom_cost";
|
||||
|
||||
public static final String PACKING_COST = "packing_cost";
|
||||
|
||||
public static final String AUXILIARY_COST = "auxiliary_cost";
|
||||
|
||||
public static final String LABOR_COST = "labor_cost";
|
||||
|
||||
public static final String EUIP_DEPRECIATION_COST = "euip_depreciation_cost";
|
||||
|
||||
public static final String EQUIP_CONSUME_COST = "equip_consume_cost";
|
||||
|
||||
public static final String HYDROELECTRICITY_COST = "hydroelectricity_cost";
|
||||
|
||||
public static final String OTHER_COST = "other_cost";
|
||||
|
||||
public static final String TRAIL_COST = "trail_cost";
|
||||
|
||||
public static final String MANUFACTURE_COST = "manufacture_cost";
|
||||
|
||||
public static final String TOTAL_LABOR_COST = "total_labor_cost";
|
||||
|
||||
public static final String TOTAL_EQUIP_CONSUME_COST = "total_equip_consume_cost";
|
||||
|
||||
public static final String TOTAL_EUIP_DEPRECIATION_COST = "total_euip_depreciation_cost";
|
||||
|
||||
public static final String TOTAL_HYDROELECTRICITY_COST = "total_hydroelectricity_cost";
|
||||
|
||||
public static final String TOTAL_OTHER_COST = "total_other_cost";
|
||||
|
||||
public static final String CREATE_BY = "create_by";
|
||||
|
||||
public static final String CREATE_TIME = "create_time";
|
||||
|
||||
public static final String UPDATE_BY = "update_by";
|
||||
|
||||
public static final String UPDATE_TIME = "update_time";
|
||||
|
||||
public static final String REMARK = "remark";
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
@TableField("sort")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
||||
+23
-2
@@ -1,18 +1,39 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 标准成本明细表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cost_purchase_price
|
||||
* @since 2024-06-19
|
||||
* @author
|
||||
* @since 2024-06-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface CostStandardDetailMapper extends BaseMapper<CostStandardDetail> {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page
|
||||
* @param wrapper
|
||||
* @return
|
||||
*/
|
||||
IPage<CostStandardDetailVO> pageList(@Param("page") Page<CostStandardDetailVO> page , @Param(Constants.WRAPPER) Wrapper<CostStandardDetailVO> wrapper);
|
||||
/**
|
||||
* 查询列表
|
||||
* @param wrapper
|
||||
* @return
|
||||
*/
|
||||
List<CostStandardDetailVO> queryListResult(@Param(Constants.WRAPPER) Wrapper<CostStandardDetailVO> wrapper);
|
||||
|
||||
}
|
||||
|
||||
+22
-5
@@ -3,10 +3,13 @@
|
||||
<mapper namespace="com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardDetailMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail">
|
||||
<resultMap id="CostStandardDetailVOResultMap" type="com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO">
|
||||
<id column="id" property="id" />
|
||||
<result column="material_number" property="materialNumber" />
|
||||
<result column="material_name" property="materialName" />
|
||||
<result column="parent_material_number" property="parentMaterialNumber" />
|
||||
<result column="version_number_id" property="versionNumberId" />
|
||||
<result column="version_number" property="versionNumber" />
|
||||
<result column="level" property="level" />
|
||||
<result column="figure_number" property="figureNumber" />
|
||||
<result column="dosage" property="dosage" />
|
||||
@@ -32,11 +35,25 @@
|
||||
<result column="update_by" property="updateBy" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="remark" property="remark" />
|
||||
<result column="sort" property="sort" />
|
||||
</resultMap>
|
||||
<select id="pageList" resultMap="CostStandardDetailVOResultMap">
|
||||
select c1.*, c2.version_number, c2.version_status, c2.stage,c2.version_year
|
||||
from
|
||||
cost_standard_detail c1
|
||||
left join cost_standard_version c2 on c1.version_number_id = c2.id
|
||||
${ew.customSqlSegment}
|
||||
ORDER BY c1.create_time desc
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, material_number, version_number_id, level, figure_number, dosage, unit, specification, bom_cost, packing_cost, auxiliary_cost, labor_cost, euip_depreciation_cost, equip_consume_cost, hydroelectricity_cost, other_cost, trail_cost, manufacture_cost, total_labor_cost, total_equip_consume_cost, total_euip_depreciation_cost, total_hydroelectricity_cost, total_other_cost, create_by, create_time, update_by, update_time, remark
|
||||
</sql>
|
||||
</select>
|
||||
<select id="queryListResult" resultMap="CostStandardDetailVOResultMap">
|
||||
select c1.*, c2.version_number, c2.version_status, c2.stage,c2.version_year
|
||||
from
|
||||
cost_standard_detail c1
|
||||
left join cost_standard_version c2 on c1.version_number_id = c2.id
|
||||
${ew.customSqlSegment}
|
||||
ORDER BY c1.create_time desc
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.service;
|
||||
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BomTreeService {
|
||||
/**
|
||||
* 根据物料号查询物料树
|
||||
* @param materialNumber
|
||||
* @return
|
||||
*/
|
||||
List<BomTreeInfoVO> getBomTreeByMaterialNumber(String materialNumber, String version_number);
|
||||
}
|
||||
+11
@@ -1,7 +1,11 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -12,5 +16,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
public interface CostStandardDetailService extends IService<CostStandardDetail> {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
IPage<CostStandardDetailVO> pageList(Page<CostStandardDetailVO> page, CostStandardDetailVO costStandard);
|
||||
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
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.CostStandardDetail;
|
||||
import com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardDetailMapper;
|
||||
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;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BomTreeServiceImpl implements BomTreeService {
|
||||
@Autowired
|
||||
CostStandardDetailMapper costStandardDetailMapper;
|
||||
|
||||
/**
|
||||
* 根据物料号查询物料树
|
||||
*
|
||||
* @param materialNumber
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BomTreeInfoVO> getBomTreeByMaterialNumber(String materialNumber, String version_number) {
|
||||
QueryWrapper<CostStandardDetailVO> wrapper = new QueryWrapper<>();
|
||||
//设置条件
|
||||
if (StrUtil.isNotEmpty(materialNumber)) {
|
||||
// 物料号
|
||||
wrapper.like("c1.material_number", materialNumber);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(version_number)) {
|
||||
// 版本号
|
||||
wrapper.like("c2.version_number", version_number);
|
||||
}
|
||||
List<CostStandardDetailVO> costStandardDetailVOS = costStandardDetailMapper.queryListResult(wrapper);
|
||||
List<BomTreeInfoVO> bomTreeInfoVOS = BomTreeBuilder.buildBomTree(costStandardDetailVOS);
|
||||
return bomTreeInfoVOS;
|
||||
}
|
||||
}
|
||||
+35
@@ -1,9 +1,16 @@
|
||||
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.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||
import com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardDetailMapper;
|
||||
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -17,4 +24,32 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class CostStandardDetailServiceImpl extends ServiceImpl<CostStandardDetailMapper, CostStandardDetail> implements CostStandardDetailService {
|
||||
|
||||
@Autowired
|
||||
CostStandardDetailMapper costStandardDetailMapper;
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param costStandard
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<CostStandardDetailVO> pageList(Page<CostStandardDetailVO> page, CostStandardDetailVO costStandard) {
|
||||
// 查询条件组装
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
|
||||
if(costStandard != null){
|
||||
|
||||
if(StrUtil.isNotEmpty(costStandard.getMaterialNumber()) ){
|
||||
// 物料号
|
||||
queryWrapper.like("c1.material_number",costStandard.getMaterialNumber());
|
||||
}
|
||||
if(StrUtil.isNotEmpty(costStandard.getVersionNumber()) ){
|
||||
// 版本号
|
||||
queryWrapper.like("c2.version_number",costStandard.getVersionNumber());
|
||||
}
|
||||
|
||||
}
|
||||
return (IPage<CostStandardDetailVO>) costStandardDetailMapper.pageList(page,queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -49,8 +49,6 @@ import java.util.Map;
|
||||
public class CostStandardVersionServiceImpl extends ServiceImpl<CostStandardVersionMapper, CostStandardVersion> implements ICostStandardVersionService {
|
||||
@Autowired
|
||||
private CostStandardMapper costStandardMapper;
|
||||
@Autowired
|
||||
private ICostStandardVersionService costStandardVersionService;
|
||||
private static final Logger log = LoggerFactory.getLogger(CostStandardVersionServiceImpl.class);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -171,7 +169,7 @@ public class CostStandardVersionServiceImpl extends ServiceImpl<CostStandardVers
|
||||
standardVersion.setVersionYear(String.valueOf(createDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear()));
|
||||
// 调用保存方法
|
||||
try {
|
||||
costStandardVersionService.save(standardVersion);
|
||||
save(standardVersion);
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>第 " + (i + 2) + " 行数据导入失败;";
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.util;
|
||||
|
||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.BomTreeInfoVO;
|
||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BomTreeBuilder {
|
||||
public static List<BomTreeInfoVO> buildBomTree(List<CostStandardDetailVO> sourceData) {
|
||||
List<BomTreeInfoVO> result = new ArrayList<>();
|
||||
if (sourceData == null || (sourceData != null && sourceData.size() < 1)) {
|
||||
return result;
|
||||
}
|
||||
//1.把BOM信息分成按照物料号分组
|
||||
Map<String, CostStandardDetailVO> materialMap = sourceData.stream().filter(s -> s.getMaterialNumber() != null).collect(Collectors.toMap(CostStandardDetailVO::getMaterialNumber, vo -> vo));
|
||||
//查找最顶端的父类节点
|
||||
Map<String, CostStandardDetailVO> parentDataMap = sourceData.stream().filter(s -> s.getParentMaterialNumber() == null).collect(Collectors.toMap(CostStandardDetailVO::getMaterialNumber, vo -> vo));
|
||||
//查找有父节点的子节点
|
||||
Map<String, List<CostStandardDetailVO>> childDataMap = sourceData.stream().filter(s -> s.getParentMaterialNumber() != null).collect(Collectors.groupingBy(CostStandardDetailVO::getParentMaterialNumber));
|
||||
//查找有父节点的子节点
|
||||
// //1.把BOM信息分成按照层级分组
|
||||
// Map<Integer, List<CostStandardDetailVO>> levelMap = sourceData.stream().filter(s -> s.getLevel() != null).collect(Collectors.groupingBy(CostStandardDetail::getLevel));
|
||||
// //2.对每层进行排序
|
||||
// for (Integer level : levelMap.keySet()) {
|
||||
// List<CostStandardDetailVO> levelList = levelMap.get(level);
|
||||
// List<CostStandardDetailVO> sortedCostDetails = levelList.stream().sorted(Comparator.comparing(CostStandardDetailVO::getSort)).collect(Collectors.toList());
|
||||
// levelMap.put(level, sortedCostDetails);
|
||||
// }
|
||||
// TreeMap<Integer, List<CostStandardDetailVO>> levelTreeMap = new TreeMap<>(levelMap);
|
||||
//3.构建BOM树
|
||||
if (parentDataMap.size() > 0) {
|
||||
for (CostStandardDetailVO parent : parentDataMap.values()) {
|
||||
BomTreeInfoVO parentBomTreeInfoVO = costStandardDetailChangeToBomTreeInfoVO(parent);
|
||||
parentBomTreeInfoVO = loopFindChildrenBuild(parentBomTreeInfoVO, materialMap, childDataMap, result);
|
||||
if (parentBomTreeInfoVO != null) {
|
||||
result.add(parentBomTreeInfoVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
materialMap = null;
|
||||
parentDataMap = null;
|
||||
childDataMap = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
private static BomTreeInfoVO loopFindChildrenBuild(BomTreeInfoVO parentBomTreeInfoVO, Map<String, CostStandardDetailVO> materialMap, Map<String, List<CostStandardDetailVO>> childDataMap, List<BomTreeInfoVO> result) {
|
||||
if (parentBomTreeInfoVO != null) {
|
||||
//4.根据物料号查找子节点
|
||||
List<CostStandardDetailVO> childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber());
|
||||
//构造父节点下的bomtree结构数据
|
||||
List<BomTreeInfoVO> children = new ArrayList<>();
|
||||
for (int j = 0; childs != null && childs.size() > 0 && j < childs.size(); j++) {
|
||||
CostStandardDetailVO child = childs.get(j);
|
||||
BomTreeInfoVO childBomTreeInfoVO = costStandardDetailChangeToBomTreeInfoVO(child);
|
||||
childBomTreeInfoVO = loopFindChildrenBuild(childBomTreeInfoVO, materialMap, childDataMap, result);
|
||||
children.add(childBomTreeInfoVO);
|
||||
}
|
||||
//对象的子节点进行排序(升序)
|
||||
children = children.stream().sorted(Comparator.comparing(BomTreeInfoVO::getSort, Comparator.nullsLast(Comparator.naturalOrder()))).collect(Collectors.toList());
|
||||
parentBomTreeInfoVO.setChildren(children);
|
||||
}
|
||||
return parentBomTreeInfoVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把单行查询的数据转换为BomTreeInfoVO
|
||||
*
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
static BomTreeInfoVO costStandardDetailChangeToBomTreeInfoVO(CostStandardDetail 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.getAuxiliaryCost()).equipCost(parent.getEquipConsumeCost()).otherCost(parent.getOtherCost()).laborCost(parent.getLaborCost()).accumulatedEquipCost(parent.getTotalEquipConsumeCost()).accumulatedOtherCost(parent.getTotalOtherCost()).accumulatedLaborCost(parent.getTotalLaborCost()).accumulatedMaterialCost(parent.getAuxiliaryCost()).accumulatedFuelCost(parent.getTotalEuipDepreciationCost()).sort(parent.getSort()).build();
|
||||
return bomTreeInfoVO;
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.vo;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class BomTreeInfoVO {
|
||||
/**
|
||||
* 物料号
|
||||
*/
|
||||
private String materialNumber;
|
||||
/**
|
||||
* 父类物料号
|
||||
*/
|
||||
private String parentMaterialNumber;
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
private String materialName;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private double quantity;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
private Integer level;
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 本阶标准成本
|
||||
*/
|
||||
private BigDecimal standardCost;
|
||||
/**
|
||||
* 本阶物料成本
|
||||
*/
|
||||
private BigDecimal materialCost;
|
||||
/**
|
||||
* 本阶人工成本
|
||||
*/
|
||||
private BigDecimal laborCost;
|
||||
/**
|
||||
* 本阶设备成本
|
||||
*/
|
||||
private BigDecimal equipCost;
|
||||
/**
|
||||
* 本阶燃动成本
|
||||
*/
|
||||
private BigDecimal fuelCost;
|
||||
/**
|
||||
* 本阶辅料成本
|
||||
*/
|
||||
private BigDecimal auxiliaryCost;
|
||||
/**
|
||||
* 本阶其他成本
|
||||
*/
|
||||
private BigDecimal otherCost;
|
||||
/**
|
||||
* 累计标准成本
|
||||
*/
|
||||
private BigDecimal accumulatedStandardCost;
|
||||
/**
|
||||
* 累计物料成本
|
||||
*/
|
||||
private BigDecimal accumulatedMaterialCost;
|
||||
/**
|
||||
* 累计人工成本
|
||||
*/
|
||||
private BigDecimal accumulatedLaborCost;
|
||||
/**
|
||||
* 累计设备成本
|
||||
*/
|
||||
private BigDecimal accumulatedEquipCost;
|
||||
/**
|
||||
* 累计燃动成本
|
||||
*/
|
||||
private BigDecimal accumulatedFuelCost;
|
||||
|
||||
/**
|
||||
* 累计辅料成本
|
||||
*/
|
||||
private BigDecimal accumulatedAuxiliaryCost;
|
||||
/**
|
||||
* 累计其他成本
|
||||
*/
|
||||
private BigDecimal accumulatedOtherCost;
|
||||
/**
|
||||
* 节点父类所有的物料编码
|
||||
*/
|
||||
private List<String> parentMaterialNumbers;
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<BomTreeInfoVO> children;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.zzsmart.qomo.kn.cost.manage.vo;
|
||||
|
||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 标准成本明细表
|
||||
* </p>
|
||||
*
|
||||
* @author cost_purchase_price
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CostStandardDetailVO extends CostStandardDetail implements Serializable {
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private String versionNumber;
|
||||
}
|
||||
+6
-6
@@ -42,7 +42,7 @@ public class ApplicationTests {
|
||||
.pathInfo(Collections.singletonMap(OutputFile.mapperXml,System.getProperty("user.dir")+"/src/main/java/com/zzsmart/qomo/kn/cost/manage/mapper/xml"));
|
||||
})
|
||||
.strategyConfig(builder -> {
|
||||
builder.addInclude("cost_material_bom")// todo 设置需要生成的表名
|
||||
builder.addInclude("cost_standard_detail")// todo 设置需要生成的表名
|
||||
//.addTablePrefix("sys_")//设置表前缀过滤
|
||||
.entityBuilder()
|
||||
.enableLombok()
|
||||
@@ -66,11 +66,11 @@ public class ApplicationTests {
|
||||
.enableRestStyle();
|
||||
})
|
||||
// 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
||||
// .templateConfig(builder -> {
|
||||
// builder.disable(TemplateType.CONTROLLER)
|
||||
// .disable(TemplateType.SERVICE)
|
||||
// .disable(TemplateType.SERVICEIMPL);
|
||||
// })
|
||||
.templateConfig(builder -> {
|
||||
builder.disable(TemplateType.CONTROLLER)
|
||||
.disable(TemplateType.SERVICE)
|
||||
.disable(TemplateType.SERVICEIMPL);
|
||||
})
|
||||
.templateEngine(new FreemarkerTemplateEngine())
|
||||
.execute();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user