feat: 电气专用bom功能
This commit is contained in:
parent
f12a19cba4
commit
2f88516812
|
|
@ -6,6 +6,7 @@ import com.mzt.logapi.context.LogRecordContext;
|
|||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewDQbomQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomDQbomEditDetailVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
||||
|
|
@ -25,6 +26,7 @@ import org.ttzero.excel.entity.Workbook;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
|
@ -85,7 +87,7 @@ public class DQBomApi extends BaseApi {
|
|||
@PostMapping("importBomSave")
|
||||
@LogRecord(success = "电气BOM-确认导入,操作结果:{{#_ret}}", bizNo = "", type = "电气BOM导入")
|
||||
public ResultVO importBomSave() {
|
||||
dQBomService.checkException(dqBomImportService.save());
|
||||
dqBomImportService.save();
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
|
|
@ -125,56 +127,56 @@ public class DQBomApi extends BaseApi {
|
|||
|
||||
/**
|
||||
* 异常检查
|
||||
* @param rootRowIds 顶级rowId
|
||||
* @param bomRowIds bomRowId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("checkException")
|
||||
@ApiOperation("异常检查")
|
||||
public ResultVO<String> checkException(@RequestBody List<Long> rootRowIds) {
|
||||
dQBomService.checkException(rootRowIds);
|
||||
public ResultVO<String> checkException(@Valid @RequestBody @NotEmpty List<Long> bomRowIds) {
|
||||
dQBomService.checkException(bomRowIds.get(0));
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除bom
|
||||
* @param rowId rowId
|
||||
* @param rootBomRowIds 顶级bom
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("deleteBom")
|
||||
@ApiOperation("删除bom")
|
||||
public ResultVO<String> deleteBom(@Valid @RequestBody @NotNull Long rowId) {
|
||||
dQBomService.deleteBom(rowId);
|
||||
public ResultVO<String> deleteBom(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
||||
dQBomService.deleteBom(rootBomRowIds.get(0));
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出bom
|
||||
* @param rootBomRowId 顶级bom的rowId
|
||||
* @param rootBomRowIds 顶级bom
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("exportBom")
|
||||
@ApiOperation("导出bom")
|
||||
public ResultVO exportBom(@Valid @RequestBody @NotNull Long rootBomRowId) throws IOException {
|
||||
List<DQbomExcelVO> data = dQBomService.exportBom(rootBomRowId);
|
||||
public ResultVO exportBom(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) throws IOException {
|
||||
List<DQbomExcelVO> data = dQBomService.exportBom(rootBomRowIds.get(0));
|
||||
EecExcelUtil.export(response, data, DQbomExcelVO.class, "专用bom正式表");
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成pbom
|
||||
* @param rootBomRowId 顶级bom的rowId
|
||||
* @param rootBomRowIds 顶级bom
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("convertToPbom")
|
||||
@ApiOperation("生成pbom")
|
||||
public ResultVO convertToPbom(@Valid @RequestBody @NotNull Long rootBomRowId) {
|
||||
//TODO 生成pbom
|
||||
return ResultVO.error("暂未实现");
|
||||
public ResultVO convertToPbom(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
||||
dQBomService.convertToPbom(rootBomRowIds.get(0));
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交
|
||||
* @param bomRowId 顶级bom的rowId
|
||||
* @param query 保存的数据
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("submit")
|
||||
|
|
@ -186,25 +188,25 @@ public class DQBomApi extends BaseApi {
|
|||
|
||||
/**
|
||||
* 更新物料行
|
||||
* @param bomRowId bom的rowId
|
||||
* @param query 要更新的数据
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("changeMaterial")
|
||||
@ApiOperation("更新物料行")
|
||||
public ResultVO changeMaterial(@Valid @RequestBody @NotNull Long bomRowId) {
|
||||
//TODO 更新物料行
|
||||
return ResultVO.error("暂未实现");
|
||||
public ResultVO<List<BomNewDQbomVO>> changeMaterial(@Valid @RequestBody @NotNull BomNewDQbomQuery query) {
|
||||
//return ResultVO.error("暂未实现");
|
||||
return ResultVO.success(dQBomService.changeMaterial(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入到SAP
|
||||
* @param rootBomRowId 顶级bom的rowId
|
||||
* @param rootBomRowIds 顶级bom的rowId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("importToSAP")
|
||||
@ApiOperation("导入到SAP")
|
||||
public ResultVO importToSAP(@Valid @RequestBody @NotNull Long rootBomRowId) {
|
||||
dQBomService.importToSAP(rootBomRowId);
|
||||
public ResultVO importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
||||
dQBomService.importToSAP(rootBomRowIds.get(0));
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public interface BomNewDQbomParentMapper extends BaseMapper<BomNewDQbomParentEnt
|
|||
|
||||
List<BomNewDQbomVO> getChildren(Long bomRowId);
|
||||
|
||||
List<BomNewDQbomVO> getBom(String materialNo, String drawingNo, String materialName);
|
||||
List<BomNewDQbomVO> getBom(int status, String materialNo, String drawingNo, String materialName);
|
||||
|
||||
List<BomNewDQbomVO> getVOById(Long parentRowId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package com.nflg.product.bomnew.pojo.query;
|
||||
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 曹鹏飞
|
||||
* @date 2024/4/21 14:10:19
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-query-BomNewDQbomQuery")
|
||||
public class BomNewDQbomQuery implements Serializable {
|
||||
|
||||
/**
|
||||
* 父级
|
||||
*/
|
||||
@ApiModelProperty(value = "父级")
|
||||
@NotNull
|
||||
private BomNewDQbomVO parent;
|
||||
|
||||
/**
|
||||
* 子级数据
|
||||
*/
|
||||
@ApiModelProperty(value = "子级数据")
|
||||
private List<BomNewDQbomVO> datas;
|
||||
}
|
||||
|
|
@ -31,6 +31,12 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
|||
@ApiModelProperty(value = "bom的创建人编号")
|
||||
private String bomCreateBy;
|
||||
|
||||
/**
|
||||
* 物料信息表中的物料rowId
|
||||
*/
|
||||
@ApiModelProperty(value = "主物料行id")
|
||||
private Long materialRowId;
|
||||
|
||||
/**
|
||||
* 物料信息表中的物料名称
|
||||
*/
|
||||
|
|
@ -40,22 +46,39 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
|||
/**
|
||||
* 物料类别
|
||||
*/
|
||||
@ApiModelProperty(value = "物料类别")
|
||||
@ApiModelProperty(value = "物料类别(系统)")
|
||||
private String systemMaterialCategoryName;
|
||||
|
||||
/**
|
||||
* 物料状态 1:激活 2:禁止采购 3:售后专用 4:冻结 5:完全弃用
|
||||
*/
|
||||
@ApiModelProperty(value = "物料状态")
|
||||
private Integer systemMaterialState;
|
||||
@ApiModelProperty(value = "物料状态(系统)")
|
||||
private Integer materialState;
|
||||
|
||||
/**
|
||||
* 物料信息表中的物料单位
|
||||
*/
|
||||
@ApiModelProperty(value = "物料单位(系统)")
|
||||
private String systemMaterialUnit;
|
||||
|
||||
/**
|
||||
* 物料大类别
|
||||
*/
|
||||
@ApiModelProperty(value = "物料大类别")
|
||||
private String relCategoryCode;
|
||||
|
||||
/**
|
||||
* 是否跟节点 0-否 1-是
|
||||
*/
|
||||
@TableField(value = "root_is")
|
||||
@ApiModelProperty(value = "是否跟节点")
|
||||
private Integer rootIs;
|
||||
|
||||
/**
|
||||
* 是否用户跟节点 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否用户跟节点")
|
||||
private Integer userRootIs;
|
||||
|
||||
/**
|
||||
* 子级bom
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class BomNewDQbomExceptionCheckService {
|
|||
List<BomNewDQbomChildEntity> cc = children.stream()
|
||||
.filter(c -> Objects.equals(c.getParentRowId(), parent.getRowId()))
|
||||
.collect(Collectors.toList());
|
||||
Set<String> cm = cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).distinct().collect(Collectors.toSet());
|
||||
Set<String> cm = cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet());
|
||||
List<BomNewDQbomParentEntity> pp = parents.stream().filter(p -> cm.contains(p.getMaterialNo())).collect(Collectors.toList());
|
||||
|
||||
boolean hasError;
|
||||
|
|
@ -123,34 +123,34 @@ public class BomNewDQbomExceptionCheckService {
|
|||
|
||||
private void checkParent(BomNewDQbomParentEntity parent) {
|
||||
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
||||
if ("T".equals(parent.getProjectType())) {
|
||||
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
} else if (parent.getMaterialNo().startsWith(BomConstant.MATERIAL_NO_TEMPORARY_PREFIX)) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||
} else {
|
||||
BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(parent.getMaterialNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (materialVO == null) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_7;
|
||||
} else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_2;
|
||||
} else if (!materialVO.getMaterialName().equals(parent.getMaterialName())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_15;
|
||||
} else if (Objects.isNull(parent.getNum()) || parent.getNum().equals(BigDecimal.ZERO)) {
|
||||
if (parent.getRootIs() == 1 || parent.getUserRootIs() == 1) {
|
||||
if ("T".equals(parent.getProjectType())) {
|
||||
parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||
} else if (parent.getMaterialNo().startsWith(BomConstant.MATERIAL_NO_TEMPORARY_PREFIX)) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||
} else if (!Objects.equals(materialVO.getMaterialUnit(), parent.getMaterialUnit())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_16;
|
||||
} else {
|
||||
BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(parent.getMaterialNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (materialVO == null) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_7;
|
||||
} else if (materialVO.getMaterialState().equals(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_2;
|
||||
} else if (!materialVO.getMaterialName().equals(parent.getMaterialName())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_15;
|
||||
} else if (Objects.isNull(parent.getNum()) || parent.getNum().equals(BigDecimal.ZERO)) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||
} else if (!Objects.equals(materialVO.getMaterialUnit(), parent.getMaterialUnit())) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//检查下级节点
|
||||
boolean hasError = children.stream().anyMatch(c -> c.getParentRowId().equals(parent.getRowId())
|
||||
&& !Objects.equals(c.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue()));
|
||||
if (status == EBomExceptionStatusEnum.OK && hasError) {
|
||||
status = EBomExceptionStatusEnum.EXCEPT_NO_14;
|
||||
}
|
||||
|
||||
parent.setExceptionStatus(status.getValue());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Struct;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
|
@ -330,7 +329,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
//排除项目类别的赋值
|
||||
materialMainService.intiMaterialInfoInPattern(parentChild, "^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||
if (CollUtil.isNotEmpty(parentChild)) {
|
||||
List<String> materialNos = parentChild.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(materialNos)) {
|
||||
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos)
|
||||
.eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getLastVersionIs, 1)
|
||||
|
|
@ -373,7 +372,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
child.setNoticeNums(parentEntity.getNoticeNums());
|
||||
child.setSuperMaterialStatus(parentEntity.getSuperMaterialStatus());
|
||||
|
||||
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
|
||||
if (!Objects.equals(child.getStatus(), EBomStatusEnum.PUBLISHED.getValue())
|
||||
&& parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue())) {
|
||||
child.setStatus(EBomStatusEnum.BORROWED_PARTS.getValue());
|
||||
}
|
||||
// //非本人则为借用件
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
|
|
@ -54,8 +55,11 @@ public class DQBomImportService {
|
|||
@Resource
|
||||
UserRoleService userRoleService;
|
||||
|
||||
// @Resource
|
||||
// MaterialMainService materialMainService;
|
||||
|
||||
@Resource
|
||||
MaterialMainService materialMainService;
|
||||
DQBomService dQBomService;
|
||||
|
||||
public List<OperationErrorMsgVO> importBom(MultipartFile file) throws IOException {
|
||||
try {
|
||||
|
|
@ -72,6 +76,7 @@ public class DQBomImportService {
|
|||
}
|
||||
|
||||
Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>> pcs = convertToBom(datas);
|
||||
VUtils.isTure(CollUtil.isEmpty(pcs.getLeft())).throwMessage("所有数据都已经导入过了,请勿重复导入");
|
||||
try {
|
||||
checkInconsistentData(pcs.getLeft().get(0), pcs.getLeft(), pcs.getRight());
|
||||
} catch (NflgBusinessException ex) {
|
||||
|
|
@ -87,21 +92,21 @@ public class DQBomImportService {
|
|||
}
|
||||
}
|
||||
|
||||
public Long save() {
|
||||
public void save() {
|
||||
Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>> pcs = BOMMAP.get(SessionUtil.getUserCode());
|
||||
VUtils.isTure(pcs == null).throwMessage("数据已丢失,请重新导入");
|
||||
BOMMAP.remove(SessionUtil.getUserCode());
|
||||
return save(pcs.getLeft(), pcs.getRight());
|
||||
save(pcs.getLeft(), pcs.getRight());
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||
public void save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||
// checkExceptionStatus(parents, children);
|
||||
dQBomParentService.setLastVersionIs0(parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList()));
|
||||
dQBomParentService.saveBatch(parents);
|
||||
dQBomChildService.saveBatch(children);
|
||||
BomNewDQbomParentEntity root = parents.stream().filter(p -> p.getRootIs() == 1).findFirst().orElseThrow(() -> new NflgBusinessException(STATE.BusinessError, "根节点不存在"));
|
||||
return root.getRowId();
|
||||
dQBomService.checkException(root.getRowId());
|
||||
}
|
||||
|
||||
// private void checkExceptionStatus(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||
|
|
@ -186,7 +191,8 @@ public class DQBomImportService {
|
|||
.list()
|
||||
.stream().findFirst().orElse(null)
|
||||
);
|
||||
if (parent == null && (count - 1 != index || datas.get(index + 1).getLevel() > data.getLevel())) {
|
||||
//if (parent == null && (count - 1 != index || datas.get(index + 1).getLevel() > data.getLevel())) {
|
||||
if (parent == null && count - 1 > index && datas.get(index + 1).getLevel() > data.getLevel()) {
|
||||
parent = new BomNewDQbomParentEntity();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setLevel(data.getLevel());
|
||||
|
|
@ -200,8 +206,8 @@ public class DQBomImportService {
|
|||
parent.setTotalWeight(BomUtil.calculateTotalWeight(data.getNum(), data.getUnitWeight()));
|
||||
parent.setProjectType(data.getProjectType());
|
||||
parent.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||
parent.setRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1);
|
||||
parent.setUserRootIs(parentRowIdMap.containsKey(data.getLevel() - 1) ? 0 : 1);
|
||||
parent.setRootIs(index == 0 ? 1 : 0);
|
||||
parent.setUserRootIs(index == 0 ? 1 : 0);
|
||||
parent.setLastVersionIs(1);
|
||||
parent.setEditStatus(1);
|
||||
parent.setStatus(1);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ public class DQBomParentService extends ServiceImpl<BomNewDQbomParentMapper, Bom
|
|||
.list();
|
||||
}
|
||||
|
||||
public List<BomNewDQbomVO> getBom(String materialNo, String drawingNo, String materialName) {
|
||||
return this.getBaseMapper().getBom(materialNo, drawingNo, materialName);
|
||||
public List<BomNewDQbomVO> getBom(int status, String materialNo, String drawingNo, String materialName) {
|
||||
return this.getBaseMapper().getBom(status, materialNo, drawingNo, materialName);
|
||||
}
|
||||
|
||||
public List<BomNewDQbomVO> getVOById(Long parentRowId) {
|
||||
|
|
|
|||
|
|
@ -5,23 +5,31 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewDQbomPageQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewDQbomQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewDQbomSaveQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomDQbomEditDetailVO;
|
||||
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.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
|
|
@ -53,6 +61,12 @@ public class DQBomService {
|
|||
@Resource
|
||||
UserRoleService userRoleService;
|
||||
|
||||
@Resource
|
||||
private BomNewPbomParentService bomNewPbomParentService;
|
||||
|
||||
@Resource
|
||||
private BomNewPbomChildService bomNewPbomChildService;
|
||||
|
||||
public Page<BomNewDQbomVO> getPageList(BomNewDQbomPageQuery query) {
|
||||
Page<BomNewDQbomVO> result = dQBomParentService.getBaseMapper().getPageList(new Page<>(query.getPage(), query.getPageSize()), query, SessionUtil.getUserCode());
|
||||
initMaterialInfo(result.getRecords());
|
||||
|
|
@ -69,12 +83,25 @@ public class DQBomService {
|
|||
.collect(Collectors.toList());
|
||||
roots.forEach(this::buildChildren);
|
||||
//从子级开始查找
|
||||
List<BomNewDQbomVO> boms = dQBomParentService.getBom(query.getMaterialNo(), query.getDrawingNo(), query.getMaterialName());
|
||||
List<BomNewDQbomVO> boms = dQBomParentService.getBom(query.getStatus(), query.getMaterialNo(), query.getDrawingNo(), query.getMaterialName());
|
||||
boms.removeIf(c -> Objects.equals(c.getLastVersionIs(), 0));
|
||||
boms.forEach(this::buildChildren);
|
||||
roots.addAll(boms.stream().filter(b -> b.getRootIs() == 0).map(this::buildParent).flatMap(List::stream).collect(Collectors.toList()));
|
||||
|
||||
Map<String, List<BomNewDQbomVO>> map = roots.stream().collect(Collectors.groupingBy(BomNewDQbomVO::getMaterialNo));
|
||||
List<BomNewDQbomVO> results = mergeTree(roots);
|
||||
|
||||
results.sort((r1, r2) -> r1.getBomRowId() >= r2.getBomRowId() ? r1.getBomRowId() > r2.getBomRowId() ? 1 : 0 : -1);
|
||||
|
||||
Page<BomNewDQbomVO> pageResult = new Page<>();
|
||||
pageResult.setPages(1);
|
||||
pageResult.setCurrent(1);
|
||||
pageResult.setTotal(results.size());
|
||||
pageResult.setRecords(results);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
private List<BomNewDQbomVO> mergeTree(List<BomNewDQbomVO> list) {
|
||||
Map<Long, List<BomNewDQbomVO>> map = list.stream().collect(Collectors.groupingBy(BomNewDQbomVO::getRowId));
|
||||
List<BomNewDQbomVO> results = new ArrayList<>();
|
||||
map.forEach((k, v) -> {
|
||||
if (v.size() == 1) {
|
||||
|
|
@ -87,19 +114,25 @@ public class DQBomService {
|
|||
results.add(f1);
|
||||
}
|
||||
});
|
||||
|
||||
results.sort((r1, r2) -> r1.getBomRowId() >= r2.getBomRowId() ? r1.getBomRowId() > r2.getBomRowId() ? 1 : 0 : -1);
|
||||
|
||||
Page<BomNewDQbomVO> pageResult = new Page<>();
|
||||
pageResult.setPages(1);
|
||||
pageResult.setCurrent(1);
|
||||
pageResult.setTotal(results.size());
|
||||
pageResult.setRecords(results);
|
||||
return pageResult;
|
||||
return results;
|
||||
}
|
||||
|
||||
private void merge(BomNewDQbomVO v1, BomNewDQbomVO v2) {
|
||||
v1.getChildNodes().addAll(v2.getChildNodes());
|
||||
Map<Long, List<BomNewDQbomVO>> map = v1.getChildNodes().stream().collect(Collectors.groupingBy(BomNewDQbomVO::getRowId));
|
||||
v1.getChildNodes().clear();
|
||||
map.forEach((k, v) -> {
|
||||
if (v.size() == 1) {
|
||||
v1.getChildNodes().add(v.get(0));
|
||||
} else {
|
||||
BomNewDQbomVO f1 = v.get(0);
|
||||
for (int i = 1; i < v.size(); i++) {
|
||||
merge(f1, v.get(i));
|
||||
}
|
||||
v1.getChildNodes().add(f1);
|
||||
}
|
||||
});
|
||||
v1.getChildNodes().sort(Comparator.comparingInt(c -> Integer.parseInt(c.getOrderNumber())));
|
||||
}
|
||||
|
||||
private List<BomNewDQbomVO> buildParent(BomNewDQbomVO vo) {
|
||||
|
|
@ -142,7 +175,7 @@ public class DQBomService {
|
|||
}
|
||||
|
||||
public List<BomNewDQbomVO> getChild(Long bomRowId) {
|
||||
VUtils.isTure(bomRowId == 0).throwMessage("无效的参数");
|
||||
if (bomRowId == 0) return Collections.emptyList();
|
||||
List<BomNewDQbomVO> data = dQBomParentService.getBaseMapper().getChild(bomRowId);
|
||||
initMaterialInfo(data);
|
||||
return data;
|
||||
|
|
@ -155,9 +188,12 @@ public class DQBomService {
|
|||
data.forEach(d -> {
|
||||
BaseMaterialVO bm = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(d.getMaterialNo())).findFirst().orElse(null);
|
||||
if (bm != null) {
|
||||
d.setSystemMaterialState(bm.getMaterialState());
|
||||
d.setMaterialState(bm.getMaterialState());
|
||||
d.setSystemMaterialName(bm.getMaterialName());
|
||||
d.setSystemMaterialCategoryName(bm.getCategoryName());
|
||||
d.setSystemMaterialUnit(bm.getMaterialUnit());
|
||||
d.setMaterialRowId(bm.getMaterialRowId());
|
||||
d.setRelCategoryCode(bm.getRelCategoryCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -187,7 +223,7 @@ public class DQBomService {
|
|||
public void save(BomNewDQbomSaveQuery query) {
|
||||
BomNewDQbomParentEntity parent = new BomNewDQbomParentEntity();
|
||||
BeanUtil.copyProperties(query.getParent(), parent);
|
||||
BomNewDQbomChildEntity child;
|
||||
//BomNewDQbomChildEntity child;
|
||||
|
||||
List<BomNewDQbomParentEntity> liParents = new ArrayList<>();
|
||||
|
||||
|
|
@ -221,55 +257,65 @@ public class DQBomService {
|
|||
return;
|
||||
}
|
||||
//删除
|
||||
dQBomChildService.deleteNotIn(parent.getRowId(), query.getChildren().stream().map(BomNewDQbomSaveVO::getRowId)
|
||||
.filter(d -> ObjectUtil.isNotNull(d) && d > 0L)
|
||||
.collect(Collectors.toList()));
|
||||
// dQBomChildService.deleteNotIn(parent.getRowId(),
|
||||
// query.getChildren().stream()
|
||||
// .map(BomNewDQbomSaveVO::getRowId)
|
||||
// .filter(d -> ObjectUtil.isNotNull(d) && d > 0L)
|
||||
// .collect(Collectors.toList()));
|
||||
dQBomChildService.deleteAllChildren(parent.getRowId());
|
||||
parent.setBomExist(1);
|
||||
parent.setModifyTime(LocalDateTime.now());
|
||||
|
||||
child = dQBomChildService.getById(query.getParent().getBomChildRowId());
|
||||
//child = dQBomChildService.getById(query.getParent().getBomChildRowId());
|
||||
}
|
||||
//处理child
|
||||
List<BomNewDQbomChildEntity> children = Convert.toList(BomNewDQbomChildEntity.class, query.getChildren());
|
||||
for (int index = 0, count = children.size(); index < count; index++) {
|
||||
BomNewDQbomChildEntity c = children.get(index);
|
||||
c.setRowId(IdWorker.getId());
|
||||
if (Objects.isNull(c.getRowId()) || c.getRowId() == 0) {
|
||||
c.setRowId(IdWorker.getId());
|
||||
c.setCreatedBy(SessionUtil.getUserCode());
|
||||
c.setCreatedName(SessionUtil.getRealName());
|
||||
} else {
|
||||
c.setModifyTime(LocalDateTime.now());
|
||||
}
|
||||
c.setLevel(parent.getLevel() + 1);
|
||||
c.setParentRowId(parent.getRowId());
|
||||
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
|
||||
c.setOrderNumber(StrUtil.padPre(String.valueOf(index + 1), 3, '0'));
|
||||
c.setTotalWeight(BomUtil.calculateTotalWeight(c.getNum(), query.getChildren().get(index).getUnitWeight()));
|
||||
c.setCreatedBy(SessionUtil.getUserCode());
|
||||
c.setCreatedName(SessionUtil.getRealName());
|
||||
}
|
||||
dQBomChildService.saveBatch(children);
|
||||
//处理parent
|
||||
List<BomNewDQbomParentEntity> parents = Convert.toList(BomNewDQbomParentEntity.class, query.getChildren());
|
||||
List<String> materialNos = dQBomParentService.lambdaQuery()
|
||||
.in(BomNewDQbomParentEntity::getMaterialNo, parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList()))
|
||||
.eq(BomNewDQbomParentEntity::getStatus, DQBomStatusEnum.WAIT_CONVERT.getValue())
|
||||
.list()
|
||||
.stream()
|
||||
.map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
parents.removeIf(p -> materialNos.contains(p.getMaterialNo()));
|
||||
dQBomParentService.lambdaUpdate().in(BomNewDQbomParentEntity::getMaterialNo, parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList()))
|
||||
.set(BomNewDQbomParentEntity::getLastVersionIs, 0)
|
||||
.set(BomNewDQbomParentEntity::getModifyTime, LocalDateTime.now())
|
||||
.update();
|
||||
parents.stream().filter(p -> Objects.isNull(p.getRowId())).forEach(p -> {
|
||||
p.setRowId(IdWorker.getId());
|
||||
p.setCreatedBy(SessionUtil.getUserCode());
|
||||
p.setStatus(DQBomStatusEnum.WAIT_CONVERT.getValue());
|
||||
p.setRootIs(0);
|
||||
p.setUserRootIs(0);
|
||||
p.setBomExist(0);
|
||||
p.setEditStatus(1);
|
||||
p.setCreatedName(SessionUtil.getRealName());
|
||||
p.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
p.setSource(2);
|
||||
});
|
||||
liParents.addAll(parents);
|
||||
dQBomParentService.saveOrUpdateBatch(liParents);
|
||||
// //处理parent
|
||||
// List<BomNewDQbomParentEntity> parents = Convert.toList(BomNewDQbomParentEntity.class, query.getChildren());
|
||||
// List<String> materialNos = dQBomParentService.lambdaQuery()
|
||||
// .in(BomNewDQbomParentEntity::getMaterialNo, parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList()))
|
||||
// .eq(BomNewDQbomParentEntity::getStatus, DQBomStatusEnum.WAIT_CONVERT.getValue())
|
||||
// .list()
|
||||
// .stream()
|
||||
// .map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
// parents.removeIf(p -> materialNos.contains(p.getMaterialNo()));
|
||||
// List<String> materialNos1 = parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toList());
|
||||
// if (CollUtil.isNotEmpty(materialNos1)) {
|
||||
// dQBomParentService.lambdaUpdate().in(BomNewDQbomParentEntity::getMaterialNo, materialNos1)
|
||||
// .set(BomNewDQbomParentEntity::getLastVersionIs, 0)
|
||||
// .set(BomNewDQbomParentEntity::getModifyTime, LocalDateTime.now())
|
||||
// .update();
|
||||
// }
|
||||
// parents.stream().filter(p -> Objects.isNull(p.getRowId())).forEach(p -> {
|
||||
// p.setRowId(IdWorker.getId());
|
||||
// p.setCreatedBy(SessionUtil.getUserCode());
|
||||
// p.setStatus(DQBomStatusEnum.WAIT_CONVERT.getValue());
|
||||
// p.setRootIs(0);
|
||||
// p.setUserRootIs(0);
|
||||
// p.setBomExist(0);
|
||||
// p.setEditStatus(1);
|
||||
// p.setCreatedName(SessionUtil.getRealName());
|
||||
// p.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||
// p.setSource(2);
|
||||
// });
|
||||
// liParents.addAll(parents);
|
||||
// dQBomParentService.saveOrUpdateBatch(liParents);
|
||||
}
|
||||
|
||||
public void deleteBom(Long rowId) {
|
||||
|
|
@ -326,7 +372,7 @@ public class DQBomService {
|
|||
}
|
||||
|
||||
private void getChildren(List<BomNewDQbomVO> datas, BomNewDQbomVO parent) {
|
||||
if (parent.getBomRowId() == 0) return;
|
||||
if (Objects.isNull(parent) || parent.getBomRowId() == 0) return;
|
||||
List<BomNewDQbomVO> cc = dQBomParentService.getBaseMapper().getChildren(parent.getBomRowId());
|
||||
if (CollUtil.isNotEmpty(cc)) {
|
||||
cc.forEach(c -> {
|
||||
|
|
@ -338,11 +384,17 @@ public class DQBomService {
|
|||
}
|
||||
|
||||
public void importToSAP(Long rootBomRowId) {
|
||||
BomNewDQbomParentEntity root = dQBomParentService.getById(rootBomRowId);
|
||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||
VUtils.isTure(root.getRootIs() == 0).throwMessage("请选择根节点");
|
||||
VUtils.isTure(root.getSapState() == 3).throwMessage("已导入过了,请勿重复操作");
|
||||
|
||||
List<BomNewDQbomVO> datas = getAll(rootBomRowId);
|
||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||
sapDto.setI_WERKS(FactoryCodeEnum.FACTORY_1010.getValue());
|
||||
sapDto.setI_STLAN("2");
|
||||
List<T1DTO> t1s = new ArrayList<>();
|
||||
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||
datas.forEach(d -> {
|
||||
T1DTO t1 = new T1DTO();
|
||||
|
|
@ -353,8 +405,9 @@ public class DQBomService {
|
|||
t1.setMENGE("1");
|
||||
t1.setPOSTP(d.getProjectType());
|
||||
t1.setDATUM(dateYMD);
|
||||
sapDto.getT1().add(t1);
|
||||
t1s.add(t1);
|
||||
});
|
||||
sapDto.setT1(t1s);
|
||||
ResultVO<Boolean> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
||||
if (resultVO.getState().equals(STATE.Success.getState())) {
|
||||
BomNewDQbomParentEntity parentEntity = new BomNewDQbomParentEntity();
|
||||
|
|
@ -378,4 +431,145 @@ public class DQBomService {
|
|||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
public List<BomNewDQbomVO> changeMaterial(BomNewDQbomQuery query) {
|
||||
VUtils.isTure(Objects.isNull(query.getParent())).throwMessage("父级节点不能为空");
|
||||
if (CollUtil.isNotEmpty(query.getDatas())) return query.getDatas();
|
||||
|
||||
List<String> materialNos = query.getDatas().stream()
|
||||
.map(BomNewDQbomVO::getMaterialNo)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
|
||||
query.getDatas().forEach(c -> {
|
||||
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||
.filter(m -> m.getMaterialNo().equals(c.getMaterialNo()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (vo != null) {
|
||||
c.setUnitWeight(vo.getMaterialWeight());
|
||||
c.setTotalWeight(BomUtil.calculateTotalWeight(c.getNum(), c.getUnitWeight()));
|
||||
c.setMaterialName(vo.getMaterialName());
|
||||
c.setMaterialUnit(vo.getMaterialUnit());
|
||||
c.setMaterialTexture(vo.getMaterialTexture());
|
||||
}
|
||||
});
|
||||
return query.getDatas();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void convertToPbom(Long rootBomRowId) {
|
||||
VUtils.isTure(rootBomRowId == 0).throwMessage("无效的编号");
|
||||
|
||||
BomNewDQbomParentEntity root = dQBomParentService.getById(rootBomRowId);
|
||||
VUtils.isTure(Objects.isNull(root)).throwMessage("未找到数据");
|
||||
VUtils.isTure(!Objects.equals(root.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue()))
|
||||
.throwMessage("异常状态不能转pbom");
|
||||
VUtils.isTure(root.getStatus() == 2).throwMessage("已转pbom不能再次转换");
|
||||
|
||||
List<BomNewDQbomParentEntity> parents = new ArrayList<>();
|
||||
List<BomNewDQbomChildEntity> children = new ArrayList<>();
|
||||
buildPbom(root, parents, children);
|
||||
dQBomParentService.updateBatchById(parents);
|
||||
dQBomChildService.updateBatchById(children);
|
||||
savePbomParents(parents);
|
||||
savePbomChildren(children, parents);
|
||||
importToSAP(root.getRowId());
|
||||
}
|
||||
|
||||
private void savePbomChildren(List<BomNewDQbomChildEntity> children, List<BomNewDQbomParentEntity> parents) {
|
||||
List<BomNewPbomChildEntity> pchildren = Convert.toList(BomNewPbomChildEntity.class, children);
|
||||
List<String> materialNos = pchildren.stream().map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toList());
|
||||
List<BaseMaterialVO> materialBaseInfos = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(materialNos)) {
|
||||
materialBaseInfos.addAll(materialMainService.getMaterialBaseInfo(materialNos));
|
||||
}
|
||||
pchildren.forEach(c -> {
|
||||
c.setCreatedTime(LocalDateTime.now());
|
||||
c.setModifyTime(null);
|
||||
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
|
||||
if (CollUtil.isNotEmpty(materialBaseInfos)) {
|
||||
BaseMaterialVO materialVO = materialBaseInfos.stream().filter(m -> m.getMaterialNo().equals(c.getMaterialNo())).findFirst().orElse(null);
|
||||
if (!Objects.isNull(materialVO)) {
|
||||
c.setMaterialCategoryCode(materialVO.getMaterialCategoryCode());
|
||||
}
|
||||
}
|
||||
BomNewDQbomParentEntity parent = parents.stream().filter(p -> p.getMaterialNo().equals(c.getMaterialNo())).findFirst().orElse(null);
|
||||
if (!Objects.isNull(parent)) {
|
||||
c.setBomVersionRowId(parent.getRowId());
|
||||
}
|
||||
});
|
||||
bomNewPbomChildService.saveBatch(pchildren);
|
||||
}
|
||||
|
||||
private void savePbomParents(List<BomNewDQbomParentEntity> parents) {
|
||||
List<BomNewPbomParentEntity> pparents = Convert.toList(BomNewPbomParentEntity.class, parents);
|
||||
pparents.forEach(p -> {
|
||||
p.setCreatedTime(LocalDateTime.now());
|
||||
p.setModifyTime(null);
|
||||
p.setEditStatus(PBomEditStatusEnum.HANDLER_FINISHED.getValue());
|
||||
p.setStatus(PBomStatusEnum.WAIT_FACTORY.getValue());
|
||||
p.setFacCode(FactoryCodeEnum.FACTORY_1010.getValue());
|
||||
p.setSourceRowId(p.getRowId());
|
||||
p.setLevelNum(parents.stream().filter(ps -> Objects.equals(ps.getRowId(), p.getRowId())).findFirst().get().getLevel());
|
||||
});
|
||||
bomNewPbomParentService.saveBatch(pparents);
|
||||
}
|
||||
|
||||
private void buildPbom(BomNewDQbomParentEntity parent, List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||
parent.setStatus(2);
|
||||
parent.setConvertToPbomTime(LocalDateTime.now());
|
||||
parents.add(parent);
|
||||
LambdaQueryWrapper<BomNewDQbomParentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo());
|
||||
wrapper.ne(BomNewDQbomParentEntity::getRowId, parent.getRowId());
|
||||
dQBomParentService.getBaseMapper().delete(wrapper);
|
||||
List<BomNewDQbomChildEntity> cc = dQBomChildService.getByParentRowId(parent.getRowId());
|
||||
children.addAll(cc);
|
||||
|
||||
BomNewPbomParentEntity pp = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||
.orderByDesc(BomNewPbomParentEntity::getRowId)
|
||||
.last(" limit 1")
|
||||
.one();
|
||||
if (!Objects.isNull(pp)) {
|
||||
if (versionCompare(parent.getCurrentVersion(), pp.getCurrentVersion()) < 0) {
|
||||
VUtils.isTure(true).throwMessage(StrUtil.format("{}的当前版本为{},比pbom中版本{}低", parent.getMaterialNo()
|
||||
, parent.getCurrentVersion(), pp.getCurrentVersion()));
|
||||
} else {
|
||||
if (pp.getStatus() == 4) {
|
||||
List<BomNewDQbomVO> dqChildren = getChild(parent.getRowId());
|
||||
Set<String> pChildren = bomNewPbomChildService.lambdaQuery()
|
||||
.select(BomNewPbomChildEntity::getMaterialNo)
|
||||
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId())
|
||||
.list()
|
||||
.stream()
|
||||
.map(BomNewPbomChildEntity::getMaterialNo)
|
||||
.collect(Collectors.toSet());
|
||||
if (dqChildren.size() != pChildren.size()
|
||||
|| !Sets.difference(dqChildren.stream().map(BomNewDQbomVO::getMaterialNo).collect(Collectors.toSet()), pChildren).isEmpty()) {
|
||||
parent.setCurrentVersion(VersionUtil.getNextVersion(parent.getCurrentVersion()));
|
||||
pp.setLastVersionIs(0);
|
||||
bomNewPbomParentService.updateById(pp);
|
||||
}
|
||||
} else {
|
||||
bomNewPbomParentService.getBaseMapper().deleteById(pp.getRowId());
|
||||
bomNewPbomChildService.getBaseMapper().delete(new LambdaQueryWrapper<BomNewPbomChildEntity>()
|
||||
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId()));
|
||||
}
|
||||
//处理子级
|
||||
dQBomParentService.lambdaQuery()
|
||||
.in(BomNewDQbomParentEntity::getMaterialNo, cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toList()))
|
||||
.eq(BomNewDQbomParentEntity::getStatus, 1)
|
||||
.list()
|
||||
.forEach(p -> buildPbom(p, parents, children));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int versionCompare(String version1, String version2) {
|
||||
if (StrUtil.isBlank(version1)) return 1;
|
||||
if (StrUtil.isBlank(version2)) return -1;
|
||||
return Integer.parseInt(version1.substring(1)) - Integer.parseInt(version2.substring(1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
AND p.material_no = #{query.materialNo}
|
||||
</if>
|
||||
<if test="query.materialName != null and query.materialName!=''">
|
||||
AND p.material_name like concat('%', ${query.materialName}, '%')
|
||||
AND c.project_type='T' AND p.material_name like concat('%', #{query.materialName}, '%')
|
||||
</if>
|
||||
<if test="query.startDate != null and query.startDate!=''">
|
||||
AND p.created_time <![CDATA[ >= ]]> #{query.startDate}
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
<select id="getChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
||||
SELECT ifnull(p.row_id, 0) bomRowId,
|
||||
ifnull(p.created_by, c.created_by) bomCreateBy,
|
||||
ifnull(p.exception_status, c.exception_status) exception_status,
|
||||
if(c.exception_status = 1, ifnull(p.exception_status, 1), c.exception_status) exception_status,
|
||||
ifnull(p.exception_tag, c.exception_tag) exception_tag,
|
||||
ifnull(p.bom_exist, 0) bom_exist,
|
||||
c.*
|
||||
|
|
@ -79,17 +79,7 @@
|
|||
</select>
|
||||
|
||||
<select id="getRootBomByRowId" resultType="com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO">
|
||||
SELECT level,
|
||||
material_no,
|
||||
drawing_no,
|
||||
material_name,
|
||||
material_texture,
|
||||
num,
|
||||
material_unit,
|
||||
project_type,
|
||||
current_version,
|
||||
unit_weight,
|
||||
remark
|
||||
SELECT *, row_id bomRowId
|
||||
FROM t_bom_new_dqbom_parent
|
||||
WHERE row_id = #{rootBomRowId}
|
||||
</select>
|
||||
|
|
@ -109,8 +99,9 @@
|
|||
ifnull(p.unit_weight, c.unit_weight) 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 p.last_version_is = 1
|
||||
WHERE c.parent_row_id = #{rootBomRowId}
|
||||
INNER JOIN t_bom_new_dqbom_parent p2 ON p2.row_id = c.parent_row_id
|
||||
LEFT JOIN t_bom_new_dqbom_parent p ON c.material_no = p.material_no AND (p2.status = 1 OR p.status = 2)
|
||||
WHERE p2.row_id = #{rootBomRowId}
|
||||
order by c.order_number
|
||||
</select>
|
||||
|
||||
|
|
@ -123,21 +114,15 @@
|
|||
c.*
|
||||
FROM t_bom_new_dqbom_parent p
|
||||
RIGHT JOIN t_bom_new_dqbom_child c ON p.material_no = c.material_no
|
||||
WHERE c.status = #{query.status}
|
||||
<if test="query.drawingNo != null and query.drawingNo!=''">
|
||||
AND c.drawing_no = #{query.drawingNo}
|
||||
WHERE c.status = #{status}
|
||||
<if test="drawingNo != null and drawingNo!=''">
|
||||
AND c.drawing_no = #{drawingNo}
|
||||
</if>
|
||||
<if test="query.materialNo != null and query.materialNo!=''">
|
||||
AND c.material_no = #{query.materialNo}
|
||||
<if test="materialNo != null and materialNo!=''">
|
||||
AND c.material_no = #{materialNo}
|
||||
</if>
|
||||
<if test="query.materialName != null and query.materialName!=''">
|
||||
AND c.material_name like concat('%', ${query.materialName}, '%')
|
||||
</if>
|
||||
<if test="query.startDate != null and query.startDate!=''">
|
||||
AND c.created_time <![CDATA[ >= ]]> #{query.startDate}
|
||||
</if>
|
||||
<if test="query.endDate != null and query.endDate!=''">
|
||||
AND c.created_time <![CDATA[ <= ]]> #{query.endDate}
|
||||
<if test="materialName != null and materialName!=''">
|
||||
AND c.project_type='T' AND c.material_name like concat('%', #{materialName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
|
@ -152,6 +137,7 @@
|
|||
, IFNULL(b.modify_time, a.modify_time) modify_time
|
||||
, IFNULL(b.parent_row_id, 0) parent_row_id
|
||||
, a.row_id bomRowId
|
||||
, b.order_number
|
||||
, a.*
|
||||
FROM t_bom_new_dqbom_parent a
|
||||
LEFT JOIN t_bom_new_dqbom_child b ON a.material_no = b.material_no
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.nflg.product.bomnew.constant.EBomStatusEnum;
|
|||
import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
|
||||
import com.nflg.product.bomnew.util.BomUtil;
|
||||
import com.nflg.product.bomnew.util.StringUtil;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -136,4 +137,9 @@ public class OtherTest {
|
|||
System.out.println("显示结果:" + BomUtil.totalWeightToDisplay(totalWeight));
|
||||
Assert.assertEquals("70.6577", Objects.requireNonNull(BomUtil.totalWeightToDisplay(totalWeight)).toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test16() {
|
||||
System.out.println("下一个版本:" + VersionUtil.getNextVersionForSmallVersion("A00"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public enum STATE {
|
|||
PageError(114, "页面异常"),
|
||||
BusinessError(115, "业务异常"),
|
||||
RequestMethodError(116, "请求方式错误"),
|
||||
InconsistentDataError(117, "数据不一致")
|
||||
InconsistentDataError(117, "需要用户确认")
|
||||
;
|
||||
@Getter
|
||||
private final Integer state;
|
||||
|
|
|
|||
Loading…
Reference in New Issue