Merge branch 'refs/heads/feature/DM/nflg-bom-dq' into dev
This commit is contained in:
commit
e932f0ff8e
|
|
@ -14,10 +14,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
|||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewTechnologyPackageTypeEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomCopyCheckResultVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomWorkExcelVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.service.*;
|
||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
|
|
@ -29,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -330,27 +328,15 @@ public class PBomApi extends BaseApi {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导入到SAP
|
||||
* @param rootBomRowIds 顶级bom的rowId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("importToSAP")
|
||||
@ApiOperation("导入到SAP")
|
||||
public ResultVO<List<OperationErrorMsgVO>> importToSAP(@Valid @RequestBody @NotEmpty List<Long> rootBomRowIds) {
|
||||
VUtils.isTure(rootBomRowIds.size() > 1).throwMessage("每次只能导入1条");
|
||||
return bomNewPbomParentService.importToSAP(rootBomRowIds.get(0));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,6 +341,20 @@ public class BomNewPbomParentEntity implements Serializable {
|
|||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
/**
|
||||
* 导入SAP状态,1-未导入;3-已导入
|
||||
*/
|
||||
@TableField(value = "sap_state")
|
||||
@ApiModelProperty(value = "导入SAP状态,1-未导入;3-已导入")
|
||||
private Integer sapState;
|
||||
|
||||
/**
|
||||
* 导入SAP时间
|
||||
*/
|
||||
@TableField(value = "sap_time")
|
||||
@ApiModelProperty(value = "导入SAP时间")
|
||||
private LocalDateTime sapTime;
|
||||
|
||||
private static final long serialVersionUID = -31999878274445137L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import lombok.Data;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_parent
|
||||
|
|
@ -33,8 +31,6 @@ public class BomNewEbomParentQuery extends BasePageQuery implements Serializabl
|
|||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialNo;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 设计人员名称
|
||||
*/
|
||||
|
|
@ -50,9 +46,11 @@ public class BomNewEbomParentQuery extends BasePageQuery implements Serializabl
|
|||
@ApiModelProperty("数据类型 0-EBOM工作列表数据 1-EBOM正式工作表明细 2-变更影响")
|
||||
private Integer dataType=0;
|
||||
|
||||
/*
|
||||
* 是否仅显示自己的数据:0=所有人的数据;1=仅自己的数据,默认为0
|
||||
*/
|
||||
@ApiModelProperty(value = "是否仅显示自己的数据:0=所有人的数据;1=仅自己的数据,默认为0")
|
||||
private Integer showMySelfOnly = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class DQbomExcelVO extends BaseImportExcelDTO {
|
|||
private String drawingNo;
|
||||
|
||||
@ExcelColumn("名称")
|
||||
private String materialName;
|
||||
private String materialDesc;
|
||||
|
||||
@ExcelColumn("材料")
|
||||
private String materialTexture;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ package com.nflg.product.bomnew.service;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
|
|
@ -20,6 +22,7 @@ import com.nflg.product.bomnew.constant.*;
|
|||
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.*;
|
||||
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.*;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
|
|
@ -40,6 +43,7 @@ import java.io.IOException;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
|
|
@ -1024,6 +1028,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
}
|
||||
|
||||
SpringUtil.getBean(BomNewPbomParentFormalService.class).copyPbomFormal(bomRowId);
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
importToSAP(bomRowId);
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:" + ex.getMessage());
|
||||
}
|
||||
|
|
@ -1090,4 +1098,60 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
private void resetBomExist(Long rowId) {
|
||||
this.getBaseMapper().resetBomExist(rowId);
|
||||
}
|
||||
|
||||
public ResultVO<List<OperationErrorMsgVO>> importToSAP(Long rootRowId) {
|
||||
BomNewPbomParentEntity root = this.getById(rootRowId);
|
||||
VUtils.isTure(Objects.isNull(root)).throwMessage("数据不存在");
|
||||
VUtils.isTure(root.getRootIs() != 1).throwMessage("请选择根节点");
|
||||
|
||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||
sapDto.setI_WERKS("1");
|
||||
sapDto.setI_STLAN("1");
|
||||
List<T1DTO> t1s = new ArrayList<>();
|
||||
buildChildrenForSap(root, t1s);
|
||||
sapDto.setT1(t1s);
|
||||
ResultVO<List<OperationErrorMsgVO>> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
||||
boolean update = lambdaUpdate().eq(BomNewPbomParentEntity::getRowId, rootRowId)
|
||||
.set(BomNewPbomParentEntity::getSapTime, LocalDateTime.now())
|
||||
.set(Objects.equals(resultVO.getState(), STATE.Success.getState())
|
||||
, BomNewPbomParentEntity::getSapState, MBomConstantEnum.MBomStatusEnum.PUB_SAP.getValue())
|
||||
.set(!Objects.equals(resultVO.getState(), STATE.Success.getState()) && t1s.size() == resultVO.getData().size()
|
||||
, BomNewPbomParentEntity::getSapState, MBomConstantEnum.MBomStatusEnum.PUB_ERROR_ALL.getValue())
|
||||
.set(!Objects.equals(resultVO.getState(), STATE.Success.getState()) && t1s.size() != resultVO.getData().size()
|
||||
, BomNewPbomParentEntity::getSapState, MBomConstantEnum.MBomStatusEnum.PUB_ERROR.getValue())
|
||||
.update();
|
||||
return update ? resultVO : ResultVO.error("更新数据失败");
|
||||
}
|
||||
|
||||
private void buildChildrenForSap(BomNewPbomParentEntity parent, List<T1DTO> t1s) {
|
||||
List<BomNewPbomChildEntity> children = pbomChildService.lambdaQuery()
|
||||
.eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId())
|
||||
.list();
|
||||
if (CollUtil.isNotEmpty(children)) {
|
||||
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||
children.forEach(c -> {
|
||||
T1DTO t1 = new T1DTO();
|
||||
t1.setID(RandomUtil.randomNumbers(5));
|
||||
t1.setMATNR(parent.getMaterialNo());
|
||||
t1.setIDNRK(c.getMaterialNo());
|
||||
t1.setMEINS(c.getMaterialUnit());
|
||||
t1.setMENGE(c.getNum().toString());
|
||||
t1.setPOSTP(c.getProjectType());
|
||||
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(c.getProjectType())) {
|
||||
t1.setIDNRK("");
|
||||
t1.setPOTX1(c.getMaterialName());
|
||||
}
|
||||
t1.setDATUM(dateYMD);
|
||||
t1s.add(t1);
|
||||
BomNewPbomParentEntity cp = lambdaQuery()
|
||||
.eq(BomNewPbomParentEntity::getMaterialNo, c.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||
.one();
|
||||
if (!Objects.isNull(cp)) {
|
||||
buildChildrenForSap(cp, t1s);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,6 +282,10 @@ public class DQBomService {
|
|||
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()));
|
||||
if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, c.getProjectType())
|
||||
&& (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO))) {
|
||||
c.setNum(BigDecimal.ONE);
|
||||
}
|
||||
//处理parent
|
||||
BomNewDQbomParentEntity cp = dQBomParentService.lambdaQuery()
|
||||
.eq(BomNewDQbomParentEntity::getMaterialNo, c.getMaterialNo())
|
||||
|
|
|
|||
|
|
@ -187,11 +187,19 @@
|
|||
|
||||
<!--BOM-正式工作表-->
|
||||
<select id="formalWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO">
|
||||
select * , row_id as bomRowId from t_bom_new_ebom_parent a
|
||||
select * , row_id as bomRowId
|
||||
from t_bom_new_ebom_parent a
|
||||
join (select material_no, max(current_version) current_version from t_bom_new_ebom_parent
|
||||
where status=4 <include refid="whr"/>
|
||||
where status=4
|
||||
<if test="query.showMySelfOnly == 1">
|
||||
AND created_by = #{userCode}
|
||||
</if>
|
||||
<include refid="whr"/>
|
||||
group by material_no) b on a.material_no=b.material_no and a.current_version=b.current_version
|
||||
where a.status=4
|
||||
<if test="query.showMySelfOnly == 1">
|
||||
AND a.created_by = #{userCode}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<sql id="getUpgradeChangeListWhr">
|
||||
|
|
@ -385,6 +393,9 @@
|
|||
SELECT *,row_id as bomRowId
|
||||
FROM t_bom_new_ebom_parent
|
||||
<!-- WHERE (root_is=1 OR ((user_root_is=1 OR root_is_for_wait_review=1) AND created_by=#{userCode}))-->
|
||||
<if test="query.showMySelfOnly == 1">
|
||||
AND created_by = #{userCode}
|
||||
</if>
|
||||
<if test="userJob==0">
|
||||
WHERE status IN (1,3) AND (user_root_is=1 OR root_is_for_wait_review=1) AND created_by=#{userCode}
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue