Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom
This commit is contained in:
commit
d94a6653d8
|
|
@ -171,19 +171,28 @@ public class EbomApi extends BaseApi {
|
|||
new Workbook("eBom-create-template", "").addSheet(new ListSheet<>("sheet1", ImmutableList.of(new BomNewEBomImportExcelDTO()))).writeTo(response.getOutputStream());
|
||||
}
|
||||
|
||||
@GetMapping("createBomImport")
|
||||
// @PostMapping("createBomImport")
|
||||
// @ApiOperation("创建EBOM-导入")
|
||||
// public ResultVO<List<BomNewEBomImportExcelDTO>> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException {
|
||||
// if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
|
||||
// return ResultVO.error("请上传Excel文件");
|
||||
// }
|
||||
// List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(dto.getFile().getInputStream(), BomNewEBomImportExcelDTO.class);
|
||||
//
|
||||
//
|
||||
// materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo);
|
||||
// return ResultVO.success(result);
|
||||
// }
|
||||
@PostMapping("createBomImport")
|
||||
@ApiOperation("创建EBOM-导入")
|
||||
public ResultVO<List<BomNewEBomImportExcelDTO>> createBomImport(@RequestParam(value = "file") MultipartFile file) throws IOException {
|
||||
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
|
||||
public ResultVO<Boolean> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException {
|
||||
if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
|
||||
return ResultVO.error("请上传Excel文件");
|
||||
}
|
||||
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(file.getInputStream(), BomNewEBomImportExcelDTO.class);
|
||||
|
||||
materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo);
|
||||
return ResultVO.success(result);
|
||||
bomNewEbomParentService.createBomImport(dto,dto.getFile().getInputStream());
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("createBom")
|
||||
@ApiOperation("创建BOM")
|
||||
public ResultVO<Boolean> createBom(@RequestBody BomNewEBomCreateDTO createDTO) {
|
||||
|
|
@ -232,6 +241,19 @@ public class EbomApi extends BaseApi {
|
|||
return resultVO;
|
||||
}
|
||||
|
||||
@PostMapping("updateProjectType")
|
||||
@ApiOperation("更新项目类型")
|
||||
public ResultVO<Boolean> updateProjectType(@RequestBody BomNewEbomProjectTypeDTO dto) {
|
||||
|
||||
VUtils.isTure(StrUtil.isEmpty(dto.getProjectType())).throwMessage("项目类型不能为空");
|
||||
|
||||
VUtils.isTure(CollUtil.isEmpty(dto.getRowIdList())).throwMessage("选择要修改的数据");
|
||||
bomNewEbomParentService.updateProjectType(dto);
|
||||
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("queryMaterial")
|
||||
@ApiOperation("查询物料信息")
|
||||
|
|
|
|||
|
|
@ -25,4 +25,18 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum<Integer> {
|
|||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProjectTypeEnum implements ValueEnum<String> {
|
||||
TYPE_Q("Q", "Q"),
|
||||
TYPE_F("F", "F");
|
||||
|
||||
private final String value;
|
||||
private final String description;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Data
|
||||
public class BomNewEbomImportDTO {
|
||||
|
||||
@ApiModelProperty("excel文件")
|
||||
private MultipartFile file;
|
||||
@ApiModelProperty("物料数据")
|
||||
private BomNewEbomParentVO parent;
|
||||
@ApiModelProperty("操作类型(1:删除 2:追加)")
|
||||
private Integer opType;
|
||||
|
||||
@ApiModelProperty("忽略")
|
||||
private Integer source= EBomSourceEnum.FROM_EXCE.getValue();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-dto-BomNewEbomProjectTypeDTO")
|
||||
public class BomNewEbomProjectTypeDTO {
|
||||
|
||||
@ApiModelProperty("行rowId")
|
||||
private List<Long> rowIdList;
|
||||
|
||||
@ApiModelProperty("项目类型")
|
||||
private String projectType;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -7,9 +7,11 @@ import cn.hutool.core.convert.Convert;
|
|||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -40,6 +42,7 @@ import org.ttzero.excel.entity.ListSheet;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
|
@ -145,8 +148,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取物料所有父节点
|
||||
*
|
||||
|
|
@ -352,6 +353,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 初始化bom 异常信息
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
public void initBomException(List<BomNewEbomParentVO> list) {
|
||||
|
|
@ -362,6 +364,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 初始化bom 异常信息
|
||||
*
|
||||
* @param bomRowId bom行ID
|
||||
*/
|
||||
public void initBomException(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
|
|
@ -406,7 +409,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -478,6 +480,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 发起变更
|
||||
*
|
||||
* @param bomRowIds
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
@ -532,6 +535,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
};
|
||||
EecExcelUtil.eecExcel("bom列表", listSheet, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算BOM树高度
|
||||
*
|
||||
|
|
@ -574,6 +578,24 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException {
|
||||
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
|
||||
|
||||
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
|
||||
}, result);
|
||||
|
||||
materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo);
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
|
||||
|
||||
BomNewEBomParentEditDTO bomNewEBomParentEditDTO=new BomNewEBomParentEditDTO();
|
||||
bomNewEBomParentEditDTO.setParent(dto.getParent());
|
||||
bomNewEBomParentEditDTO.setDatas(datas);
|
||||
eBomEdit.temporary(bomNewEBomParentEditDTO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -846,16 +868,43 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新项目类型
|
||||
* @return
|
||||
*/
|
||||
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto ){
|
||||
|
||||
|
||||
List<BomNewEbomChildEntity> childEntity=new ArrayList<>();
|
||||
dto.getRowIdList().forEach(rowid->{
|
||||
BomNewEbomChildEntity entity=new BomNewEbomChildEntity();
|
||||
entity.setRowId(rowid);
|
||||
entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||
entity.setProjectType(dto.getProjectType());
|
||||
entity.setModifyTime(LocalDateTime.now());
|
||||
});
|
||||
|
||||
SpringUtil.getBean(BomNewEbomChildService.class).updateBatchById(childEntity);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public BomNewEbomEditDetailVO editDetail(Long bomRowId) {
|
||||
|
||||
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
|
||||
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
|
||||
|
||||
|
||||
BomNewEbomParentEntity parent= this.getById(bomRowId);
|
||||
|
||||
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent);
|
||||
List<BomNewEbomParentVO> parentList = new ArrayList<>();
|
||||
parentList.add(parentVO);
|
||||
materialMainService.intiMaterialInfo(parentList);
|
||||
parentVO.setBomRowId(parentVO.getRowId());
|
||||
// List<BomNewEbomParentVO> parentList = new ArrayList<>();
|
||||
// parentList.add(parentVO);
|
||||
// materialMainService.intiMaterialInfo(parentList);
|
||||
//
|
||||
|
||||
vo.setDatas(getChild(bomRowId));
|
||||
vo.setParent(parentList.get(0));
|
||||
vo.setParent(parentVO);
|
||||
return vo;
|
||||
|
||||
}
|
||||
|
|
@ -897,10 +946,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Boolean deleteMaterial(Long bomRowId) throws ExecutionException, InterruptedException {
|
||||
|
||||
BomNewEbomParentEntity parentEntity = this.getBaseMapper().selectById(bomRowId);
|
||||
|
|
@ -937,13 +982,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 暂存
|
||||
*
|
||||
* <p>
|
||||
* 用户临时处理数据,数据的处理状态为“待处理”,当用户单击暂存的时候,所有的数据都不需要校验,直接保存即可。
|
||||
*/
|
||||
|
||||
public Boolean temporary(BomNewEBomParentEditDTO dto) {
|
||||
|
||||
EBomEdit eBomEdit=new EBomEdit();
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
|
||||
eBomEdit.temporary(dto);
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities);
|
||||
|
|
@ -970,7 +1015,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
*/
|
||||
public Boolean submit(BomNewEBomParentEditDTO dto) {
|
||||
|
||||
EBomEdit eBomEdit=new EBomEdit();
|
||||
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
|
||||
eBomEdit.temporary(dto);
|
||||
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
|
||||
this.saveOrUpdateBatch(eBomEdit.parentEntities);
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ import cn.hutool.core.util.NumberUtil;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||
import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.EbomEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
|
|
@ -23,8 +21,10 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
|||
import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.UserRoleService;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import io.swagger.models.auth.In;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -37,8 +37,16 @@ public class EBomEdit {
|
|||
|
||||
public List<BomNewEbomChildEntity> childEntities;
|
||||
|
||||
Integer source;
|
||||
|
||||
public EBomEdit(Integer source){
|
||||
this.source=source;
|
||||
}
|
||||
|
||||
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
|
||||
|
||||
|
||||
|
||||
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
|
||||
BeanUtil.copyProperties(parent, vo);
|
||||
|
||||
|
|
@ -51,20 +59,26 @@ public class EBomEdit {
|
|||
// parent.setMaterialName(material.getMaterialName());
|
||||
// parent.setMaterialDesc(material.getMaterialDesc());
|
||||
// parent.setMaterialTexture(material.getMaterial());
|
||||
parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum());
|
||||
// parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum());
|
||||
|
||||
parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
|
||||
parent.setDeviseUserCode(SessionUtil.getUserCode());
|
||||
parent.setCurrentVersion("A00");
|
||||
parent.setDeviseName(SessionUtil.getRealName());
|
||||
parent.setDeptName(SessionUtil.getDepartName());
|
||||
|
||||
parent.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||
parent.setSourceRowId(0l);
|
||||
parent.setSource(source);
|
||||
parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
|
||||
parent.setBomExist(1);
|
||||
parent.setLastVersionIs(1);
|
||||
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
if(StrUtil.isEmpty(parent.getProjectType())){
|
||||
parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
|
||||
}
|
||||
|
||||
parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician()? EBomStatusEnum.CHECKED.getValue():EBomStatusEnum.WAIT_CHECK.getValue());
|
||||
parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician()?UserJobEnum.ENGINEER.getValue():UserJobEnum.DESIGNER.getValue());
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
|
@ -114,24 +128,40 @@ public class EBomEdit {
|
|||
|
||||
for (BomNewEbomChildEntity child :
|
||||
childEntities) {
|
||||
child.setRowId(IdWorker.getId());
|
||||
|
||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||
|
||||
//child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
|
||||
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
|
||||
|
||||
//新增数据
|
||||
if(child.getRowId()==null || child.getRowId().longValue()==0){
|
||||
child.setRowId(IdWorker.getId());
|
||||
child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId()));
|
||||
|
||||
child.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||
child.setSource(source);
|
||||
child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
child.setCreatedTime(LocalDateTime.now());
|
||||
child.setCreatedBy(SessionUtil.getUserCode());
|
||||
child.setSourceRowId(0l);
|
||||
}
|
||||
|
||||
parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
|
||||
|
||||
child.setParentRowId(parent.getRowId());
|
||||
VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");
|
||||
if(StrUtil.isEmpty(child.getProjectType())){
|
||||
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
|
||||
}
|
||||
|
||||
if(StrUtil.isNotEmpty(parent.getProjectType()) && StrUtil.containsAny(parent.getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
|
||||
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
|
||||
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
|
||||
}
|
||||
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
|
||||
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue