feat: 电气专用bom添加功能

This commit is contained in:
曹鹏飞 2024-04-17 21:08:11 +08:00
parent 3142c807c6
commit c220cbe8bd
8 changed files with 139 additions and 19 deletions

View File

@ -7,9 +7,11 @@ import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO; import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.service.DQBomImportService; import com.nflg.product.bomnew.service.DQBomImportService;
import com.nflg.product.bomnew.service.DQBomService; import com.nflg.product.bomnew.service.DQBomService;
import com.nflg.product.bomnew.util.EecExcelUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import nflg.product.common.vo.ResultVO; import nflg.product.common.vo.ResultVO;
@ -47,7 +49,7 @@ public class DQBomApi extends BaseApi {
@PostMapping("importBom") @PostMapping("importBom")
@LogRecord(success = "电气BOM-导入:文件名:{{#fileNme}},操作结果:{{#_ret}}", bizNo = "", type = "电气BOM导入") @LogRecord(success = "电气BOM-导入:文件名:{{#fileNme}},操作结果:{{#_ret}}", bizNo = "", type = "电气BOM导入")
public ResultVO<List<OperationErrorMsgVO>> importBom(@RequestParam(value = "file") MultipartFile file) throws IOException { public ResultVO<List<OperationErrorMsgVO>> importBom(@RequestParam(value = "file") MultipartFile file) throws IOException {
String type = file.getContentType();//application/vnd.openxmlformats-officedocument.spreadsheetml.sheet String type = file.getContentType();
if (!"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(type) && !"application/vnd.ms-excel".equals(type)) { if (!"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(type) && !"application/vnd.ms-excel".equals(type)) {
return ResultVO.error("请上传Excel文件"); return ResultVO.error("请上传Excel文件");
} }
@ -91,13 +93,13 @@ public class DQBomApi extends BaseApi {
} }
/** /**
* 保存数据 * 暂存
* @param query 保存的数据 * @param query 保存的数据
* @return * @return
*/ */
@GetMapping("save") @GetMapping("temporary")
@ApiOperation("保存数据") @ApiOperation("暂存")
public ResultVO<String> save(@Valid @RequestBody @NotNull BomNewDQbomSaveQuery query) { public ResultVO<String> temporary(@Valid @RequestBody @NotNull BomNewDQbomSaveQuery query) {
dQBomService.save(query); dQBomService.save(query);
return ResultVO.success(); return ResultVO.success();
} }
@ -125,4 +127,60 @@ public class DQBomApi extends BaseApi {
dQBomService.deleteBom(rowId); dQBomService.deleteBom(rowId);
return ResultVO.success(); return ResultVO.success();
} }
/**
* 导出bom
* @param rootBomRowId 顶级bom的rowId
* @return
*/
@PostMapping("exportBom")
@ApiOperation("导出bom")
public ResultVO exportBom(@Valid @RequestBody @NotNull Long rootBomRowId) throws IOException {
List<DQbomExcelVO> data = dQBomService.exportBom(rootBomRowId);
EecExcelUtil.export(response, data, DQbomExcelVO.class, "专用bom正式表");
return ResultVO.success();
}
/**
* 生成pbom
* @param rootBomRowId 顶级bom的rowId
* @return
*/
@PostMapping("convertToPbom")
@ApiOperation("生成pbom")
public ResultVO convertToPbom(@Valid @RequestBody @NotNull Long rootBomRowId) {
//TODO 生成pbom
return ResultVO.error("暂未实现");
}
/**
* 提交
* @param bomRowId 顶级bom的rowId
* @return
*/
@PostMapping("submit")
@ApiOperation("提交")
public ResultVO submit(@Valid @RequestBody @NotNull Long bomRowId) {
dQBomService.submit(bomRowId);
return ResultVO.success();
}
/**
* 更新物料行
* @param bomRowId bom的rowId
* @return
*/
@PostMapping("changeMaterial")
@ApiOperation("更新物料行")
public ResultVO changeMaterial(@Valid @RequestBody @NotNull Long bomRowId) {
//TODO 更新物料行
return ResultVO.error("暂未实现");
}
@PostMapping("convertToSAP")
@ApiOperation("导入SAP")
public ResultVO convertToSAP(@Valid @RequestBody @NotNull Long rootBomRowId) {
//TODO 导入SAP
return ResultVO.error("暂未实现");
}
} }

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery; import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO; import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
import java.util.List; import java.util.List;
@ -19,4 +20,8 @@ public interface BomNewDQbomParentMapper extends BaseMapper<BomNewDQbomParentEnt
List<BomNewDQbomVO> getChild(Long bomRowId); List<BomNewDQbomVO> getChild(Long bomRowId);
void resetBomExist(Long rowId); void resetBomExist(Long rowId);
DQbomExcelVO getRootBomByRowId(Long rootBomRowId);
List<DQbomExcelVO> getChildren(Long bomRowId);
} }

View File

@ -101,6 +101,13 @@ public class BomNewDQbomChildEntity implements Serializable {
@ApiModelProperty(value = "异常标记") @ApiModelProperty(value = "异常标记")
private String exceptionTag; private String exceptionTag;
/**
* 备注
*/
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
private String remark;
/** /**
* 创建人名称 * 创建人名称
*/ */

View File

@ -177,13 +177,6 @@ public class BomNewDQbomParentEntity implements Serializable {
@ApiModelProperty(value = "来源") @ApiModelProperty(value = "来源")
private Integer source; private Integer source;
/**
* 备注
*/
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
private String remark;
/** /**
* 修改时间 * 修改时间
*/ */

View File

@ -32,7 +32,7 @@ public class DQbomExcelVO extends BaseImportExcelDTO {
private BigDecimal num; private BigDecimal num;
@ExcelColumn("单位") @ExcelColumn("单位")
private String unit; private String material_unit;
@ExcelColumn("项目类别") @ExcelColumn("项目类别")
private String projectType; private String projectType;

View File

@ -187,7 +187,7 @@ public class DQBomImportService {
parent.setDrawingNo(data.getDrawingNo()); parent.setDrawingNo(data.getDrawingNo());
parent.setMaterialNo(data.getMaterialNo()); parent.setMaterialNo(data.getMaterialNo());
parent.setMaterialName(data.getMaterialName()); parent.setMaterialName(data.getMaterialName());
parent.setMaterialUnit(data.getUnit()); parent.setMaterialUnit(data.getMaterial_unit());
parent.setUnitWeight(data.getUnitWeight()); parent.setUnitWeight(data.getUnitWeight());
parent.setRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1); parent.setRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1);
parent.setUserRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1); parent.setUserRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1);
@ -195,7 +195,7 @@ public class DQBomImportService {
parent.setCreatedBy(SessionUtil.getUserCode()); parent.setCreatedBy(SessionUtil.getUserCode());
parent.setCreatedName(SessionUtil.getRealName()); parent.setCreatedName(SessionUtil.getRealName());
parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
parent.setRemark(data.getRemark()); //parent.setRemark(data.getRemark());
// if (index == datas.size() - 1 || datas.get(index + 1).getLevel() <= data.getLevel()) { // if (index == datas.size() - 1 || datas.get(index + 1).getLevel() <= data.getLevel()) {
// parent.setBomExist(0); // parent.setBomExist(0);
// } else { // } else {
@ -225,6 +225,7 @@ public class DQBomImportService {
child.setCreatedName(SessionUtil.getRealName()); child.setCreatedName(SessionUtil.getRealName());
child.setCreatedBy(SessionUtil.getUserCode()); child.setCreatedBy(SessionUtil.getUserCode());
child.setProjectType(data.getProjectType()); child.setProjectType(data.getProjectType());
child.setRemark(data.getRemark());
children.add(child); children.add(child);
} }
return Pair.of(parents, children); return Pair.of(parents, children);

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.DQBomStatusEnum; import com.nflg.product.bomnew.constant.DQBomStatusEnum;
import com.nflg.product.bomnew.constant.EbomEditStatusEnum;
import com.nflg.product.bomnew.constant.UserJobEnum; import com.nflg.product.bomnew.constant.UserJobEnum;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
@ -16,6 +17,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomSaveVO; import com.nflg.product.bomnew.pojo.vo.BomNewDQbomSaveVO;
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO; import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
import com.nflg.product.bomnew.util.BomUtil; import com.nflg.product.bomnew.util.BomUtil;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -75,6 +77,10 @@ public class DQBomService {
}); });
} }
/**
* 异常检查
* @param rootRowIds 根节点id列表
*/
public void checkException(List<Long> rootRowIds) { public void checkException(List<Long> rootRowIds) {
BomNewDQbomExceptionCheckService checkService = new BomNewDQbomExceptionCheckService(); BomNewDQbomExceptionCheckService checkService = new BomNewDQbomExceptionCheckService();
rootRowIds.forEach(checkService::check); rootRowIds.forEach(checkService::check);
@ -196,4 +202,24 @@ public class DQBomService {
}); });
} }
} }
public void submit(Long bomRowId) {
dQBomParentService.lambdaUpdate()
.eq(BomNewDQbomParentEntity::getRowId, bomRowId)
.set(BomNewDQbomParentEntity::getEditStatus, EbomEditStatusEnum.HANDLER_FINISHED.getValue())
.set(BomNewDQbomParentEntity::getModifyTime, LocalDateTime.now())
.update();
checkException(CollUtil.toList(bomRowId));
}
public List<DQbomExcelVO> exportBom(Long rootBomRowId) {
DQbomExcelVO root = dQBomParentService.getBaseMapper().getRootBomByRowId(rootBomRowId);
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
List<DQbomExcelVO> datas = new ArrayList<>();
datas.add(root);
List<DQbomExcelVO> children = dQBomParentService.getBaseMapper().getChildren(rootBomRowId);
return datas;
}
} }

View File

@ -13,19 +13,15 @@
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/> <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/> <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
<result column="created_job" jdbcType="INTEGER" property="createdJob"/> <result column="created_job" jdbcType="INTEGER" property="createdJob"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="root_is" jdbcType="INTEGER" property="rootIs"/> <result column="root_is" jdbcType="INTEGER" property="rootIs"/>
<result column="status" jdbcType="INTEGER" property="status"/> <result column="status" jdbcType="INTEGER" property="status"/>
<result column="drawing_no" jdbcType="VARCHAR" property="drawingNo"/> <result column="drawing_no" jdbcType="VARCHAR" property="drawingNo"/>
<result column="project_type" jdbcType="VARCHAR" property="projectType"/>
<result column="current_version" jdbcType="VARCHAR" property="currentVersion"/> <result column="current_version" jdbcType="VARCHAR" property="currentVersion"/>
<result column="user_root_is" jdbcType="INTEGER" property="userRootIs"/> <result column="user_root_is" jdbcType="INTEGER" property="userRootIs"/>
<result column="exception_status" jdbcType="INTEGER" property="exceptionStatus"/>
<result column="last_version_is" jdbcType="INTEGER" property="lastVersionIs"/> <result column="last_version_is" jdbcType="INTEGER" property="lastVersionIs"/>
<result column="bom_exist" jdbcType="INTEGER" property="bomExist"/> <result column="bom_exist" jdbcType="INTEGER" property="bomExist"/>
<result column="convert_to_pbom_time" jdbcType="TIMESTAMP" property="convertToPbomTime"/> <result column="convert_to_pbom_time" jdbcType="TIMESTAMP" property="convertToPbomTime"/>
<result column="level" jdbcType="INTEGER" property="level"/> <result column="level" jdbcType="INTEGER" property="level"/>
<result column="exception_tag" jdbcType="VARCHAR" property="exceptionTag"/>
<result column="edit_status" jdbcType="INTEGER" property="editStatus"/> <result column="edit_status" jdbcType="INTEGER" property="editStatus"/>
<result column="expire_end_time" jdbcType="TIMESTAMP" property="expireEndTime"/> <result column="expire_end_time" jdbcType="TIMESTAMP" property="expireEndTime"/>
</resultMap> </resultMap>
@ -70,4 +66,38 @@
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_dqbom_child WHERE parent_row_id = p.row_id), 1, 0)) SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_dqbom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId}; WHERE p.row_id = #{rowId};
</select> </select>
<select id="getRootBomByRowId" resultType="com.nflg.product.bomnew.pojo.vo.DQbomExcelVO">
SELECT p.level,
p.material_no,
p.drawing_no,
p.material_name,
p.material_texture,
c.num,
p.material_unit,
c.project_type,
p.current_version,
p.unit_weight,
c.remark
FROM t_bom_new_dqbom_child c
JOIN t_bom_new_dqbom_parent p ON c.material_no = p.material_no AND c.parent_row_id = 0
WHERE p.row_id = #{rootBomRowId}
</select>
<select id="getChildren" resultType="com.nflg.product.bomnew.pojo.vo.DQbomExcelVO">
SELECT p.level,
p.material_no,
p.drawing_no,
p.material_name,
p.material_texture,
c.num,
p.material_unit,
c.project_type,
p.current_version,
p.unit_weight,
c.remark
FROM t_bom_new_dqbom_child c
LEFT JOIN t_bom_new_dqbom_parent p ON c.material_no = p.material_no AND c.parent_row_id = 0
WHERE p.row_id = #{rootBomRowId}
</select>
</mapper> </mapper>