Merge branch 'refs/heads/dev' into feature/excel-132

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomParentMapper.java
#	nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml
This commit is contained in:
曹鹏飞 2024-04-18 08:26:31 +08:00
commit 5956c61075
7 changed files with 153 additions and 21 deletions

View File

@ -79,6 +79,9 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
void resetAllBomExist();
List<BomNewEbomParentEntity> getEBomParentByMaterialNos(@Param("job") Integer job, @Param("createdBy")String createdBy, @Param("materialNos") List<String> materialNos);
Page<BomNewEbomParentVO> workDetailsListByPageNew(Page<Object> objectPage, BomNewEbomParentQuery query, Integer userJob, String userCode);
List<BomNewEbomParentVO> getChildren(Long bomRowId, int type);

View File

@ -533,7 +533,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
*/
public List<BomNewEbomParentVO> getBomTree(Long rowId, Boolean generateLevelNumberFlag) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
// EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
EBomCheckErrorDetailTask detailTask = new EBomCheckErrorDetailTask(bomDetail, SessionUtil.getUserCode(), SpringUtil.getBean(UserRoleService.class).getUserJob());
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewEbomParentVO> result = submit.join();

View File

@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
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.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
@ -61,7 +60,7 @@ public class CheckEBomException {
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId, true);
//只检查待复核和自己的
allBomDetail = allBomDetail.stream().filter(u -> Objects.equals(SessionUtil.getUserCode(), u.getCreatedBy()) && Objects.equals(1, u.getStatus())).collect(Collectors.toList());
//allBomDetail=allBomDetail.stream().filter(u-> SessionUtil.getUserCode().equals(u.getCreatedBy()) && u.getStatus().equals(1) ).collect(Collectors.toList());
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
if (Objects.isNull(parent)){
return;

View File

@ -0,0 +1,114 @@
package com.nflg.product.bomnew.service.domain.EBom;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.util.ListCommonUtil;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RecursiveTask;
import java.util.stream.Collectors;
/**
* @author 大米(异常检查专用)
* @descreption
* @date 2023/7/8 9:18
*/
public class EBomCheckErrorDetailTask extends RecursiveTask<List<BomNewEbomParentVO>> {
private List<BomNewEbomParentVO> bomDetail;
@Getter
@Setter
public static int levelNum=1;
List<BomNewEbomParentVO> result = new ArrayList<>();
private String jobCode;
private Integer userJob;
public EBomCheckErrorDetailTask(List<BomNewEbomParentVO> inBomDetail, String inJobCode, Integer inUserJob) {
bomDetail = inBomDetail;
jobCode=inJobCode;
userJob = inUserJob;
}
/**
* 处理BOM明细中未选择Bom版本的明细使用最新版
*/
public void handlerChildBomVersionDetail() {
List<String> materialNos = bomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) ).map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
// List<BomNewEbomParentEntity> childBomlist = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos).eq(BomNewEbomParentEntity::getLastVersionIs, 1).list();
//Integer userJob = SpringUtil.getBean(UserRoleService.class).getUserJob();
List<BomNewEbomParentEntity> childBomlist=SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().getEBomParentByMaterialNos(userJob, jobCode,materialNos);
Map<String, BomNewEbomParentEntity> stringBomNewOriginalParentEntityMap = ListCommonUtil.listToMap(childBomlist, BomNewEbomParentEntity::getMaterialNo);
for (BomNewEbomParentVO detailVO : bomDetail) {
if (stringBomNewOriginalParentEntityMap.containsKey(detailVO.getMaterialNo())) {
BomNewEbomParentEntity ebomParentEntity = stringBomNewOriginalParentEntityMap.get(detailVO.getMaterialNo());
detailVO.setChildBomRowId(ebomParentEntity.getRowId());
detailVO.setBomRowId(ebomParentEntity.getRowId());
detailVO.setSourceRowId(ebomParentEntity.getSourceRowId());
detailVO.setCurrentVersion(ebomParentEntity.getCurrentVersion());
detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
detailVO.setDeptName(ebomParentEntity.getDeptName());
detailVO.setDeviseName(ebomParentEntity.getDeviseName());
detailVO.setBomExist(ebomParentEntity.getBomExist());
detailVO.setStatus(ebomParentEntity.getStatus());
}
}
}
}
/**
* 递归调用零部件BOM
*
* @return
*/
@Override
protected List<BomNewEbomParentVO> compute() {
handlerChildBomVersionDetail();
// 最新 BOM 版本
result.addAll(bomDetail);
if (CollUtil.isNotEmpty(bomDetail)) {
levelNumAdd();
List<Long> childBowIds = bomDetail.stream().filter(u-> u.getChildBomRowId()!=null && u.getChildBomRowId() > 0).map(u->u.getChildBomRowId()).collect(Collectors.toList());
if(CollUtil.isNotEmpty(childBowIds)) {
List<BomNewEbomParentVO> bom = SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().getParentChildBatch(childBowIds);
EBomCheckErrorDetailTask task = new EBomCheckErrorDetailTask(bom, jobCode, userJob);
task.fork();
bomDetail.addAll(task.join());
return bomDetail;
}
}
return result;
}
public synchronized void levelNumAdd(){
levelNum++;
}
}

View File

@ -42,6 +42,8 @@ public class EBomEdit {
private BomNewEbomParentEntity parentEntity;
@Getter
private boolean isRootForWaitReview=false;
@Getter
private boolean isNewBom=false;
public List<BomNewEbomChildEntity> childEntities;
@ -91,6 +93,7 @@ public class EBomEdit {
isRootForWaitReview=true;
}
isNewBom=true;
parent.setCreatedTime(LocalDateTime.now());
parent.setModifyTime(LocalDateTime.now());
@ -335,6 +338,11 @@ public class EBomEdit {
public void nextVersion(){
if(!isNewBom){
return;
}
//缺bom新建的bom 版本增加
//同一物料且存在一个 lastVersionIs=1
if(ObjectUtil.isNotNull(getParentEntity().getLastVersionIs())
&& ObjectUtil.equal(getParentEntity().getLastVersionIs(),1)) {

View File

@ -362,6 +362,22 @@
WHERE p.status &lt; 4;
</select>
<select id="getEBomParentByMaterialNos" resultType="com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity">
<if test="job==0">
select * from t_bom_new_ebom_parent where created_by=#{createdBy} and last_version_is=1 and status in (1 ,3) and material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="job==1">
select * from t_bom_new_ebom_parent where (created_by=#{createdBy} or status=2) and last_version_is=1
and material_no in
<foreach collection="materialNos" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="workDetailsListByPageNew" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
SELECT *,row_id as bomRowId
FROM t_bom_new_ebom_parent

View File

@ -1,19 +1,15 @@
package com.nflg.product.base.core.api;
import com.nflg.product.base.core.exception.NflgBusinessException;
import nflg.product.common.constant.STATE;
import nflg.product.common.dto.LoginUserInfoDTO;
import nflg.product.common.util.JwtUtil;
import nflg.product.common.vo.ResultVO;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ModelAttribute;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;
import java.util.Optional;
public class BaseApi {
protected HttpServletRequest request;
@ -24,9 +20,8 @@ public class BaseApi {
@ModelAttribute
private void initLoginInfo(HttpServletRequest request) {
try {
String token = request.getHeader("authorization");
String language=Objects.nonNull(request.getHeader("language"))? request.getHeader("language") :"zh_cn";
String language = Objects.nonNull(request.getHeader("language")) ? request.getHeader("language") : "zh_cn";
ResultVO result = JwtUtil.parse(token);
if (result.getState().equals(STATE.Success.getState())) {
LoginUserInfoDTO userInfo = (LoginUserInfoDTO) result.getData();
@ -34,11 +29,6 @@ public class BaseApi {
userInfo.setLanguage(language);
loginUser.set(userInfo);
}
} catch (Exception ex) {
// throw new NflgBusinessException(STATE.SystemErr,"token 解析出错");
}
}