feat(pbom): 重写复制功能
This commit is contained in:
parent
997d81dc1b
commit
048ac55706
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.nflg.product.bomnew.api.user;
|
||||||
|
|
||||||
|
import com.nflg.product.base.core.api.BaseApi;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query;
|
||||||
|
import com.nflg.product.bomnew.service.BomNewPbomParentService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import nflg.product.common.vo.ResultVO;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/6/5 13:35:15
|
||||||
|
*/
|
||||||
|
@Api(tags = "PBom接口V2")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("pbom/v2")
|
||||||
|
public class PBomV2Api extends BaseApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BomNewPbomParentService bomNewPbomParentService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("copyFrom")
|
||||||
|
@ApiOperation("复制从")
|
||||||
|
public ResultVO<Void> copyFrom(@Valid @RequestBody CopyPBomV2Query param) {
|
||||||
|
bomNewPbomParentService.copyFromV2(param);
|
||||||
|
return ResultVO.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* t_bom_new_pbom_parent 表数据库访问层
|
* t_bom_new_pbom_parent 表数据库访问层
|
||||||
|
|
@ -64,4 +65,5 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
|
||||||
void delPBom(@Param("bomRowIds") List<Long> bomRowIds);
|
void delPBom(@Param("bomRowIds") List<Long> bomRowIds);
|
||||||
|
|
||||||
|
|
||||||
|
List<BomNewPbomParentEntity> getLatestParents(Set<String> materialNos, String facCode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/6/5 14:28:04
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PbomSaveDTO<T> {
|
||||||
|
|
||||||
|
private Set<Long> rowIdsForDelete = new HashSet<>();
|
||||||
|
|
||||||
|
private List<T> dataForAdd = new ArrayList<>();
|
||||||
|
|
||||||
|
private List<T> dataForUpdate = new ArrayList<>();
|
||||||
|
|
||||||
|
public void addToDelete(Long rowId) {
|
||||||
|
rowIdsForDelete.add(rowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToDelete(Collection<Long> rowId) {
|
||||||
|
rowIdsForDelete.addAll(rowId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToAdd(T data) {
|
||||||
|
dataForAdd.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToAdd(Collection<T> data) {
|
||||||
|
dataForAdd.addAll(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToUpdate(T data) {
|
||||||
|
dataForUpdate.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -174,11 +174,11 @@ public class BomNewPbomParentEntity implements Serializable {
|
||||||
private Integer editStatus;
|
private Integer editStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BOM状态:1=待发布 2=待分配工厂 3=已分配工厂 4=已发布
|
* BOM状态:1=待发布 2-借用件 4=已发布 8=待分配工厂 16=已分配工厂
|
||||||
* @see com.nflg.product.bomnew.constant.PBomStatusEnum
|
* @see com.nflg.product.bomnew.constant.PBomStatusEnum
|
||||||
*/
|
*/
|
||||||
@TableField(value = "status")
|
@TableField(value = "status")
|
||||||
@ApiModelProperty(value = "BOM状态:1=待发布 4=已发布 8=待分配工厂 16=已分配工厂")
|
@ApiModelProperty(value = "BOM状态:1=待发布 2-借用件 4=已发布 8=待分配工厂 16=已分配工厂")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -366,7 +366,7 @@ public class BomNewPbomParentEntity implements Serializable {
|
||||||
* 来源 1-ebom转换 2-dqbom转换 3-从SAP导入
|
* 来源 1-ebom转换 2-dqbom转换 3-从SAP导入
|
||||||
*/
|
*/
|
||||||
@TableField(value = "source")
|
@TableField(value = "source")
|
||||||
@ApiModelProperty(value = "来源 1-ebom转换 2-dqbom转换 3-从SAP导入")
|
@ApiModelProperty(value = "来源 1-ebom转换 2-dqbom转换 3-从SAP导入 4-复制")
|
||||||
private Integer source;
|
private Integer source;
|
||||||
|
|
||||||
private static final long serialVersionUID = -31999878274445137L;
|
private static final long serialVersionUID = -31999878274445137L;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.query;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/6/5 13:38:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-query-CopyPBomV2Query")
|
||||||
|
public class CopyPBomV2Query {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 源Bom行ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("源Bom行ID")
|
||||||
|
@NotNull(message = "源Bom行ID不能为空")
|
||||||
|
private Long sourceBomRowId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标工厂编码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("目标工厂编码")
|
||||||
|
@NotNull(message = "目标工厂编码不能为空")
|
||||||
|
private String targetFacCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复制模式 0-单层;1-多层
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("复制模式 0-单层;1-多层")
|
||||||
|
@NotNull(message = "复制模式不能为空")
|
||||||
|
private Integer copyType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果存在于工作表是否覆盖
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("如果存在于工作表是否覆盖")
|
||||||
|
private Boolean replaceIfExistDraft;
|
||||||
|
}
|
||||||
|
|
@ -48,6 +48,7 @@ import java.io.OutputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,13 @@ 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.dto.sap.impart2.T1DTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.*;
|
import com.nflg.product.bomnew.pojo.entity.*;
|
||||||
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query;
|
||||||
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
|
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.*;
|
import com.nflg.product.bomnew.pojo.vo.*;
|
||||||
import com.nflg.product.bomnew.service.domain.PBom.*;
|
import com.nflg.product.bomnew.service.domain.PBom.*;
|
||||||
import com.nflg.product.bomnew.service.domain.Sap;
|
import com.nflg.product.bomnew.service.domain.Sap;
|
||||||
import com.nflg.product.bomnew.util.*;
|
import com.nflg.product.bomnew.util.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
|
@ -60,6 +62,7 @@ import java.util.stream.Collectors;
|
||||||
* @since 2024-01-01 10:39:57
|
* @since 2024-01-01 10:39:57
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper, BomNewPbomParentEntity> {
|
public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper, BomNewPbomParentEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1231,4 +1234,190 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void copyFromV2(CopyPBomV2Query param) {
|
||||||
|
BomNewPbomParentEntity source = getById(param.getSourceBomRowId());
|
||||||
|
VUtils.isTure(Objects.isNull(source)).throwMessage("来源bom不存在");
|
||||||
|
VUtils.isTure(source.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("此bom未发布正式版");
|
||||||
|
|
||||||
|
PbomSaveDTO<BomNewPbomParentEntity> dtoParent = new PbomSaveDTO<>();
|
||||||
|
PbomSaveDTO<BomNewPbomChildEntity> dtoChild = new PbomSaveDTO<>();
|
||||||
|
BomNewPbomParentEntity old = lambdaQuery()
|
||||||
|
.eq(BomNewPbomParentEntity::getMaterialNo, source.getMaterialNo())
|
||||||
|
.ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||||
|
.eq(BomNewPbomParentEntity::getFacCode, param.getTargetFacCode())
|
||||||
|
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
|
||||||
|
.last(" limit 1")
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(old)) {
|
||||||
|
//正式表不已存在记录,检查工作表是否存在记录
|
||||||
|
old = lambdaQuery()
|
||||||
|
.eq(BomNewPbomParentEntity::getMaterialNo, source.getMaterialNo())
|
||||||
|
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||||
|
.eq(BomNewPbomParentEntity::getFacCode, param.getTargetFacCode())
|
||||||
|
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
|
||||||
|
.last(" limit 1")
|
||||||
|
.one();
|
||||||
|
if (Objects.nonNull(old)) {
|
||||||
|
VUtils.isTure(!StrUtil.equals(SessionUtil.getUserCode(), old.getCreatedBy()))
|
||||||
|
.throwMessage(StrUtil.format("该bom已被{}创建", old.getCreatedBy()));
|
||||||
|
|
||||||
|
if (Objects.isNull(param.getReplaceIfExistDraft())) {
|
||||||
|
throw new NflgBusinessException(STATE.InconsistentDataError, "你已在工作表创建了该记录,请选择是否覆盖?");
|
||||||
|
} else if (param.getReplaceIfExistDraft()) {
|
||||||
|
dtoParent.addToDelete(old.getRowId());
|
||||||
|
BomNewPbomParentEntity top = buildPbomParent(source, param.getTargetFacCode(), old.getCurrentVersion());
|
||||||
|
dtoParent.addToAdd(top);
|
||||||
|
//删除原数据的下级
|
||||||
|
dtoChild.addToDelete(pbomChildService.lambdaQuery()
|
||||||
|
.select(BomNewPbomChildEntity::getRowId)
|
||||||
|
.eq(BomNewPbomChildEntity::getParentRowId, old.getRowId())
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(BomNewPbomChildEntity::getRowId)
|
||||||
|
.collect(Collectors.toSet()));
|
||||||
|
//复制子级
|
||||||
|
List<BomNewPbomChildEntity> cs = copyChildren(source.getRowId(), param.getTargetFacCode(), top.getRowId());
|
||||||
|
if (CollUtil.isNotEmpty(cs)) {
|
||||||
|
dtoChild.addToAdd(cs);
|
||||||
|
if (param.getCopyType() == 1) {
|
||||||
|
//多层复制模式
|
||||||
|
copy(cs, param.getTargetFacCode(), dtoParent, dtoChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//正式表已存在记录
|
||||||
|
BomNewPbomParentEntity top = buildPbomParent(source, param.getTargetFacCode(), VersionUtil.getNextVersion(old.getCurrentVersion()));
|
||||||
|
dtoParent.addToAdd(top);
|
||||||
|
//复制子级
|
||||||
|
List<BomNewPbomChildEntity> cs = copyChildren(source.getRowId(), param.getTargetFacCode(), top.getRowId());
|
||||||
|
if (CollUtil.isNotEmpty(cs)) {
|
||||||
|
dtoChild.addToAdd(cs);
|
||||||
|
if (param.getCopyType() == 1) {
|
||||||
|
//多层复制模式
|
||||||
|
copy(cs, param.getTargetFacCode(), dtoParent, dtoChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(dtoParent.getRowIdsForDelete())) {
|
||||||
|
Integer count = this.getBaseMapper().deleteBatchIds(dtoParent.getRowIdsForDelete());
|
||||||
|
log.debug("copyFromV2 删除parent{}个", count);
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(dtoParent.getDataForAdd())) {
|
||||||
|
this.saveBatch(dtoParent.getDataForAdd());
|
||||||
|
log.debug("copyFromV2 添加parent{}个", dtoParent.getDataForAdd().size());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(dtoParent.getDataForUpdate())) {
|
||||||
|
this.updateBatchById(dtoParent.getDataForUpdate());
|
||||||
|
log.debug("copyFromV2 更新parent{}个", dtoParent.getDataForUpdate().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(dtoChild.getRowIdsForDelete())) {
|
||||||
|
Integer count = pbomChildService.getBaseMapper().deleteBatchIds(dtoChild.getRowIdsForDelete());
|
||||||
|
log.debug("copyFromV2 删除child{}个", count);
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(dtoChild.getDataForAdd())) {
|
||||||
|
pbomChildService.saveBatch(dtoChild.getDataForAdd());
|
||||||
|
log.debug("copyFromV2 添加child{}个", dtoChild.getDataForAdd().size());
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(dtoChild.getDataForUpdate())) {
|
||||||
|
pbomChildService.updateBatchById(dtoChild.getDataForUpdate());
|
||||||
|
log.debug("copyFromV2 更新child{}个", dtoChild.getDataForUpdate().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copy(List<BomNewPbomChildEntity> cs, String targetFacCode
|
||||||
|
, PbomSaveDTO<BomNewPbomParentEntity> dtoParent, PbomSaveDTO<BomNewPbomChildEntity> dtoChild) {
|
||||||
|
List<BomNewPbomParentEntity> ps = getLatestParents(cs.stream().map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toSet())
|
||||||
|
, targetFacCode);
|
||||||
|
if (CollUtil.isNotEmpty(ps)) {
|
||||||
|
ps.forEach(p -> {
|
||||||
|
BomNewPbomParentEntity np = copyParent(p, targetFacCode);
|
||||||
|
if (Objects.nonNull(np)) {
|
||||||
|
dtoParent.addToAdd(np);
|
||||||
|
List<BomNewPbomChildEntity> ccs = copyChildren(p.getRowId(), targetFacCode, np.getRowId());
|
||||||
|
if (CollUtil.isNotEmpty(ccs)) {
|
||||||
|
dtoChild.addToAdd(ccs);
|
||||||
|
copy(ccs, targetFacCode, dtoParent, dtoChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BomNewPbomParentEntity copyParent(BomNewPbomParentEntity parent, String targetFacCode) {
|
||||||
|
if (lambdaQuery()
|
||||||
|
.eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||||
|
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.WAIT_PUBLISH.getValue())
|
||||||
|
.exists()) {
|
||||||
|
//工作表不存在记录,则添加
|
||||||
|
return buildPbomParent(parent, targetFacCode, parent.getCurrentVersion());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<BomNewPbomParentEntity> getLatestParents(Set<String> materialNos, String facCode) {
|
||||||
|
return this.getBaseMapper().getLatestParents(materialNos, facCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<BomNewPbomChildEntity> copyChildren(Long parentRowId, String targetFacCode, Long newParentRowId) {
|
||||||
|
List<BomNewPbomChildEntity> cc = pbomChildService.lambdaQuery()
|
||||||
|
.eq(BomNewPbomChildEntity::getParentRowId, parentRowId)
|
||||||
|
.list();
|
||||||
|
cc.forEach(it -> {
|
||||||
|
it.setRowId(IdWorker.getId());
|
||||||
|
it.setParentRowId(newParentRowId);
|
||||||
|
it.setSource(4);
|
||||||
|
it.setCreatedBy(SessionUtil.getUserCode());
|
||||||
|
it.setCreatedTime(LocalDateTime.now());
|
||||||
|
it.setFacCode(targetFacCode);
|
||||||
|
it.setSourceRowId(0L);
|
||||||
|
it.setIdentityNo(newParentRowId + "_" + it.getRowId());
|
||||||
|
it.setModifyTime(null);
|
||||||
|
});
|
||||||
|
return cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BomNewPbomParentEntity buildPbomParent(BomNewPbomParentEntity source, String targetFacCode, String currentVersion) {
|
||||||
|
BomNewPbomParentEntity newP = Convert.convert(BomNewPbomParentEntity.class, source);
|
||||||
|
newP.setRowId(IdWorker.getId());
|
||||||
|
newP.setExpireEndTime(null);
|
||||||
|
newP.setLastConvertMbomTime(null);
|
||||||
|
newP.setLastConvertMbomUserName("");
|
||||||
|
newP.setNoticeNums("");
|
||||||
|
newP.setOrderNo("");
|
||||||
|
newP.setRemark("");
|
||||||
|
newP.setSapState(1);
|
||||||
|
newP.setSapTime(null);
|
||||||
|
newP.setSuperMaterialStatus(0);
|
||||||
|
newP.setCreatedBy(SessionUtil.getUserCode());
|
||||||
|
newP.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
|
||||||
|
newP.setDeptName(SessionUtil.getDepartName());
|
||||||
|
newP.setDeptRowId(SessionUtil.getDepartRowId());
|
||||||
|
newP.setTechnologyUserCode(SessionUtil.getUserCode());
|
||||||
|
newP.setTechnologyUserName(SessionUtil.getRealName());
|
||||||
|
newP.setBatchNo("");
|
||||||
|
newP.setCreatedTime(LocalDateTime.now());
|
||||||
|
newP.setSource(4);
|
||||||
|
newP.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||||
|
newP.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
|
||||||
|
newP.setUserRootIs(1);
|
||||||
|
newP.setRootIs(newP.getMaterialNo().startsWith("31") ? 1 : 0);
|
||||||
|
newP.setReleaseUserName("");
|
||||||
|
newP.setReleaseTime(null);
|
||||||
|
newP.setSourceRowId(0L);
|
||||||
|
newP.setFacCode(targetFacCode);
|
||||||
|
newP.setModifyTime(null);
|
||||||
|
newP.setChangeDesc("");
|
||||||
|
newP.setLastVersionIs(0);
|
||||||
|
newP.setBomExist(1);
|
||||||
|
newP.setCurrentVersion(currentVersion);
|
||||||
|
newP.setDeviseName("");
|
||||||
|
newP.setDeviseUserCode("");
|
||||||
|
return newP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -242,6 +242,23 @@
|
||||||
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_pbom_child WHERE parent_row_id = p.row_id), 1, 0))
|
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_pbom_child WHERE parent_row_id = p.row_id), 1, 0))
|
||||||
WHERE p.row_id = #{rowId};
|
WHERE p.row_id = #{rowId};
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getLatestParents" resultType="com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity">
|
||||||
|
SELECT p1.*
|
||||||
|
FROM t_bom_new_pbom_parent p1
|
||||||
|
INNER JOIN (SELECT material_no, MAX(current_version) current_version
|
||||||
|
FROM t_bom_new_pbom_parent
|
||||||
|
WHERE fac_code = #{facCode} AND material_no IN
|
||||||
|
<foreach collection="materialNos" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
GROUP BY material_no) p2
|
||||||
|
ON p1.material_no = p2.material_no AND p1.current_version = p2.current_version
|
||||||
|
WHERE p1.fac_code = #{facCode}
|
||||||
|
AND p1.material_no IN
|
||||||
|
<foreach collection="materialNos" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>;
|
||||||
|
</select>
|
||||||
|
|
||||||
<sql id="upRootStateWhr">
|
<sql id="upRootStateWhr">
|
||||||
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
|
<foreach collection="materialNoList" item="item" open="(" separator="," close=")">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue