Merge branch 'refs/heads/feature/DM/nflg-bom-dq' into sit
This commit is contained in:
commit
ed975b6d2c
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.nflg.product.bomnew.api.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
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.service.SapOpUtilService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import nflg.product.common.vo.ResultVO;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/4/26 09:54:06
|
||||||
|
*/
|
||||||
|
@Api(tags = "测试功能用的接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("test")
|
||||||
|
public class TestApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
SapOpUtilService sapOpUtilService;
|
||||||
|
|
||||||
|
@GetMapping("sap")
|
||||||
|
@ApiOperation("sap接口测试")
|
||||||
|
public ResultVO<Boolean> workDetailsListByPage() {
|
||||||
|
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||||
|
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||||
|
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||||
|
sapDto.setI_WERKS("1");
|
||||||
|
sapDto.setI_STLAN("1");
|
||||||
|
List<T1DTO> t1s = new ArrayList<>();
|
||||||
|
T1DTO t1 = new T1DTO();
|
||||||
|
t1.setID(RandomUtil.randomNumbers(5));
|
||||||
|
t1.setMATNR("2100677191");
|
||||||
|
t1.setIDNRK("1100002498");
|
||||||
|
t1.setMEINS("PC");
|
||||||
|
t1.setMENGE("3.00");
|
||||||
|
t1.setPOSTP("L");
|
||||||
|
t1.setDATUM(dateYMD);
|
||||||
|
t1s.add(t1);
|
||||||
|
sapDto.setT1(t1s);
|
||||||
|
return sapOpUtilService.importToSapV2(sapDto, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,5 +9,7 @@ public class BomConstant {
|
||||||
|
|
||||||
public static final String SAP_YDBOM="1";
|
public static final String SAP_YDBOM="1";
|
||||||
|
|
||||||
public static final String NO_TEMPORARY_PREFIX = "T";
|
public static final String PROJECT_TYPE_TEMPORARY = "T";
|
||||||
|
|
||||||
|
public static final String PROJECT_TYPE_TEMPORARY_MATERIAL_NO = "9000000000";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.product.bomnew.pojo.vo;
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.nflg.product.bomnew.constant.BomConstant;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -90,6 +91,11 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
||||||
*/
|
*/
|
||||||
private String parentMaterialNo;
|
private String parentMaterialNo;
|
||||||
|
|
||||||
|
public String getParentMaterialNo() {
|
||||||
|
if (StrUtil.isBlank(parentMaterialNo)) return "";
|
||||||
|
return parentMaterialNo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否有子节点: 0-否 1-是
|
* 是否有子节点: 0-否 1-是
|
||||||
*/
|
*/
|
||||||
|
|
@ -115,7 +121,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
||||||
private String drawingNoDesc;
|
private String drawingNoDesc;
|
||||||
|
|
||||||
public String getDrawingNoDesc() {
|
public String getDrawingNoDesc() {
|
||||||
if (StrUtil.equals(getProjectType(), "T")) {
|
if (StrUtil.equals(getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getDrawingNo();
|
return getDrawingNo();
|
||||||
|
|
@ -128,7 +134,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl
|
||||||
private String materialNoDesc;
|
private String materialNoDesc;
|
||||||
|
|
||||||
public String getMaterialNoDesc() {
|
public String getMaterialNoDesc() {
|
||||||
if (StrUtil.equals(getProjectType(), "T")) {
|
if (StrUtil.equals(getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getMaterialNo();
|
return getMaterialNo();
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,22 @@ public class DQbomExcelVO extends BaseImportExcelDTO {
|
||||||
@ExcelColumn("单位")
|
@ExcelColumn("单位")
|
||||||
private String materialUnit;
|
private String materialUnit;
|
||||||
|
|
||||||
|
@ExcelColumn("重量")
|
||||||
|
private BigDecimal unitWeight;
|
||||||
|
|
||||||
@ExcelColumn("项目类别")
|
@ExcelColumn("项目类别")
|
||||||
private String projectType;
|
private String projectType;
|
||||||
|
|
||||||
|
public String getProjectType() {
|
||||||
|
if (StrUtil.isBlank(projectType)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return projectType;
|
||||||
|
}
|
||||||
|
|
||||||
@ExcelColumn("版本")
|
@ExcelColumn("版本")
|
||||||
private String currentVersion;
|
private String currentVersion;
|
||||||
|
|
||||||
@ExcelColumn("单重")
|
|
||||||
private BigDecimal unitWeight;
|
|
||||||
|
|
||||||
@ExcelColumn("备注")
|
@ExcelColumn("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/4/26 13:44:01
|
||||||
|
*/
|
||||||
|
public class OperationErrorMsgBaseVO implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("错误描述")
|
||||||
|
public String msg;
|
||||||
|
|
||||||
|
public OperationErrorMsgBaseVO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationErrorMsgBaseVO(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationErrorMsgBaseVO create(String msg) {
|
||||||
|
return new OperationErrorMsgBaseVO(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,26 @@
|
||||||
package com.nflg.product.bomnew.pojo.vo;
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹鹏飞
|
* @author 曹鹏飞
|
||||||
* @date 2024-03-21 14:49:05
|
* @date 2024-03-21 14:49:05
|
||||||
*/
|
*/
|
||||||
@Data
|
public class OperationErrorMsgVO extends OperationErrorMsgBaseVO implements Serializable {
|
||||||
@AllArgsConstructor
|
|
||||||
public class OperationErrorMsgVO {
|
|
||||||
|
|
||||||
@ApiModelProperty("主键数据")
|
@ApiModelProperty("主键数据")
|
||||||
private String primaryKey;
|
public String primaryKey;
|
||||||
|
|
||||||
@ApiModelProperty("错误描述")
|
public OperationErrorMsgVO() {
|
||||||
private String msg;
|
}
|
||||||
|
|
||||||
|
public OperationErrorMsgVO(String primaryKey, String msg) {
|
||||||
|
super(msg);
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
public static OperationErrorMsgVO create(String primaryKey, String msg) {
|
public static OperationErrorMsgVO create(String primaryKey, String msg) {
|
||||||
return new OperationErrorMsgVO(primaryKey, msg);
|
return new OperationErrorMsgVO(primaryKey, msg);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.product.bomnew.service;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.nflg.product.bomnew.constant.BomConstant;
|
||||||
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
|
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
|
||||||
import com.nflg.product.bomnew.constant.MaterialGetEnum;
|
import com.nflg.product.bomnew.constant.MaterialGetEnum;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||||
|
|
@ -123,7 +124,7 @@ public class BomNewDQbomExceptionCheckService {
|
||||||
private void checkParent(BomNewDQbomParentEntity parent) {
|
private void checkParent(BomNewDQbomParentEntity parent) {
|
||||||
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
||||||
if (parent.getRootIs() == 1 || parent.getUserRootIs() == 1) {
|
if (parent.getRootIs() == 1 || parent.getUserRootIs() == 1) {
|
||||||
if ("T".equals(parent.getProjectType())) {
|
if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, parent.getProjectType())) {
|
||||||
if (StrUtil.isBlank(parent.getMaterialName())) {
|
if (StrUtil.isBlank(parent.getMaterialName())) {
|
||||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||||
}
|
}
|
||||||
|
|
@ -162,12 +163,12 @@ public class BomNewDQbomExceptionCheckService {
|
||||||
|
|
||||||
private void checkChild(BomNewDQbomChildEntity child) {
|
private void checkChild(BomNewDQbomChildEntity child) {
|
||||||
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
EBomExceptionStatusEnum status = EBomExceptionStatusEnum.OK;
|
||||||
if ("T".equals(child.getProjectType())) {
|
if (StrUtil.isBlank(child.getProjectType())) {
|
||||||
|
status = EBomExceptionStatusEnum.EXCEPT_NO_8;
|
||||||
|
} else if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, child.getProjectType())) {
|
||||||
if (StrUtil.isBlank(child.getMaterialName())) {
|
if (StrUtil.isBlank(child.getMaterialName())) {
|
||||||
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
||||||
}
|
}
|
||||||
// } else if (child.getMaterialNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) {
|
|
||||||
// status = EBomExceptionStatusEnum.EXCEPT_NO_4;
|
|
||||||
} else {
|
} else {
|
||||||
BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(child.getMaterialNo()))
|
BaseMaterialVO materialVO = materialVOS.stream().filter(v -> v.getMaterialNo().equals(child.getMaterialNo()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|
|
||||||
|
|
@ -934,19 +934,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
|
|
||||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||||
sapDto.setI_WERKS(FactoryCodeEnum.FACTORY_1010.getValue());
|
sapDto.setI_WERKS("1");
|
||||||
sapDto.setI_STLAN("2");
|
sapDto.setI_STLAN("2");
|
||||||
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
|
||||||
List<T1DTO> t1s = new ArrayList<>();
|
List<T1DTO> t1s = new ArrayList<>();
|
||||||
T1DTO troot = new T1DTO();
|
|
||||||
troot.setID(RandomUtil.randomNumbers(5));
|
|
||||||
troot.setMATNR("");
|
|
||||||
troot.setIDNRK(root.getMaterialNo());
|
|
||||||
troot.setMEINS(root.getMaterialUnit());
|
|
||||||
troot.setMENGE("1");
|
|
||||||
troot.setPOSTP("");
|
|
||||||
troot.setDATUM(dateYMD);
|
|
||||||
t1s.add(troot);
|
|
||||||
buildChildrenForSap(root, t1s);
|
buildChildrenForSap(root, t1s);
|
||||||
sapDto.setT1(t1s);
|
sapDto.setT1(t1s);
|
||||||
ResultVO<Boolean> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
ResultVO<Boolean> resultVO = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.nflg.product.bomnew.constant.UserJobEnum;
|
||||||
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
|
import com.nflg.product.bomnew.pojo.dto.BaseImportExcelDTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewDQbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
import com.nflg.product.bomnew.pojo.vo.BomNewDQbomVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
|
import com.nflg.product.bomnew.pojo.vo.DQbomExcelVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
|
||||||
|
|
@ -46,7 +47,7 @@ public class DQBomImportService {
|
||||||
|
|
||||||
public static final ThreadLocal<List<DQbomExcelVO>> excelContextTL = new ThreadLocal<>();
|
public static final ThreadLocal<List<DQbomExcelVO>> excelContextTL = new ThreadLocal<>();
|
||||||
|
|
||||||
private static final List<String> TYPES = Arrays.asList("T", "L");
|
// private static final List<String> TYPES = Arrays.asList("T", "L");
|
||||||
|
|
||||||
private static final Map<String, Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>>> BOMMAP = new HashMap<>();
|
private static final Map<String, Pair<List<BomNewDQbomParentEntity>, List<BomNewDQbomChildEntity>>> BOMMAP = new HashMap<>();
|
||||||
|
|
||||||
|
|
@ -59,8 +60,8 @@ public class DQBomImportService {
|
||||||
@Resource
|
@Resource
|
||||||
UserRoleService userRoleService;
|
UserRoleService userRoleService;
|
||||||
|
|
||||||
// @Resource
|
@Resource
|
||||||
// MaterialMainService materialMainService;
|
MaterialMainService materialMainService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
DQBomService dQBomService;
|
DQBomService dQBomService;
|
||||||
|
|
@ -108,19 +109,26 @@ public class DQBomImportService {
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
public void save(List<BomNewDQbomParentEntity> parents, List<BomNewDQbomChildEntity> children) {
|
||||||
Set<String> materialNos = parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toSet());
|
//将导入图号重设为主物料图号
|
||||||
List<BomNewDQbomParentEntity> oldParents = dQBomParentService.getLatestByMaterialNo(materialNos);
|
Set<String> pMaterialNos = parents.stream().map(BomNewDQbomParentEntity::getMaterialNo).collect(Collectors.toSet());
|
||||||
|
List<BomNewDQbomParentEntity> oldParents = dQBomParentService.getLatestByMaterialNo(pMaterialNos);
|
||||||
parents.forEach(p -> {
|
parents.forEach(p -> {
|
||||||
BomNewDQbomParentEntity oldParent = oldParents.stream().filter(op -> op.getMaterialNo().equals(p.getMaterialNo())).findFirst().orElse(null);
|
BomNewDQbomParentEntity oldParent = oldParents.stream()
|
||||||
|
.filter(op -> op.getMaterialNo().equals(p.getMaterialNo()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
if (!Objects.isNull(oldParent) && Objects.equals(oldParent.getStatus(), DQBomStatusEnum.WAIT_CONVERT.getValue())) {
|
if (!Objects.isNull(oldParent) && Objects.equals(oldParent.getStatus(), DQBomStatusEnum.WAIT_CONVERT.getValue())) {
|
||||||
dQBomParentService.getBaseMapper().deleteById(oldParent.getRowId());
|
dQBomParentService.getBaseMapper().deleteById(oldParent.getRowId());
|
||||||
dQBomChildService.deleteAllChildren(oldParent.getRowId());
|
dQBomChildService.deleteAllChildren(oldParent.getRowId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dQBomParentService.setLastVersionIs0(materialNos);
|
dQBomParentService.setLastVersionIs0(pMaterialNos);
|
||||||
dQBomParentService.saveBatch(parents);
|
dQBomParentService.saveBatch(parents);
|
||||||
dQBomChildService.saveBatch(children);
|
dQBomChildService.saveBatch(children);
|
||||||
BomNewDQbomParentEntity root = parents.stream().filter(p -> p.getRootIs() == 1).findFirst().orElseThrow(() -> new NflgBusinessException(STATE.BusinessError, "根节点不存在"));
|
BomNewDQbomParentEntity root = parents.stream()
|
||||||
|
.filter(p -> p.getRootIs() == 1)
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new NflgBusinessException(STATE.BusinessError, "根节点不存在"));
|
||||||
dQBomService.checkException(root.getRowId());
|
dQBomService.checkException(root.getRowId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,15 +136,6 @@ public class DQBomImportService {
|
||||||
List<BomNewDQbomChildEntity> children) throws JsonProcessingException {
|
List<BomNewDQbomChildEntity> children) throws JsonProcessingException {
|
||||||
log.debug("checkInconsistentData,entity:" + JsonUtil.toJson(parent));
|
log.debug("checkInconsistentData,entity:" + JsonUtil.toJson(parent));
|
||||||
BomNewDQbomParentEntity oldParent = dQBomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
BomNewDQbomParentEntity oldParent = dQBomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
||||||
// if (parent.getRowId() > 0) {
|
|
||||||
// old = dQBomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
|
||||||
// } else {
|
|
||||||
// old = dQBomChildService.lambdaQuery()
|
|
||||||
// .eq(BomNewDQbomChildEntity::getParentRowId, parent.getRowId())
|
|
||||||
// .eq(BomNewDQbomChildEntity::getMaterialNo, parent.getMaterialNo())
|
|
||||||
// .one();
|
|
||||||
// }
|
|
||||||
//BomNewDQbomParentEntity oldParent = dQBomParentService.getLatestByMaterialNo(parent.getMaterialNo());
|
|
||||||
boolean isSame = true;
|
boolean isSame = true;
|
||||||
if (Objects.isNull(oldParent)) {
|
if (Objects.isNull(oldParent)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -154,10 +153,8 @@ public class DQBomImportService {
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
isSame = cc.size() == oc.size()
|
isSame = cc.size() == oc.size()
|
||||||
&& cc.stream().filter(c -> c.getProjectType().equals("T")).count() == oc.stream().filter(c -> c.getProjectType().equals("T")).count()
|
&& cc.stream().filter(c -> c.getProjectType().equals(BomConstant.PROJECT_TYPE_TEMPORARY)).count() == oc.stream().filter(c -> c.getProjectType().equals(BomConstant.PROJECT_TYPE_TEMPORARY)).count()
|
||||||
&& Sets.difference(cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet()), oc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet())).isEmpty();
|
&& Sets.difference(cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet()), oc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet())).isEmpty();
|
||||||
//VUtils.isTure(isSame).throwMessage("导入的数据已存在,请勿重复导入");
|
|
||||||
|
|
||||||
for (BomNewDQbomChildEntity ccc : cc) {
|
for (BomNewDQbomChildEntity ccc : cc) {
|
||||||
if (!checkInconsistentData(parent.getRowId(), ccc, parents, children)) {
|
if (!checkInconsistentData(parent.getRowId(), ccc, parents, children)) {
|
||||||
isSame = false;
|
isSame = false;
|
||||||
|
|
@ -203,7 +200,7 @@ public class DQBomImportService {
|
||||||
Set<String> ccm = cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet());
|
Set<String> ccm = cc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet());
|
||||||
|
|
||||||
isSame = cc.size() == oc.size()
|
isSame = cc.size() == oc.size()
|
||||||
&& cc.stream().filter(c -> c.getProjectType().equals("T")).count() == oc.stream().filter(c -> c.getProjectType().equals("T")).count()
|
&& cc.stream().filter(c -> c.getProjectType().equals(BomConstant.PROJECT_TYPE_TEMPORARY)).count() == oc.stream().filter(c -> c.getProjectType().equals(BomConstant.PROJECT_TYPE_TEMPORARY)).count()
|
||||||
&& Sets.difference(ccm, oc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet())).isEmpty();
|
&& Sets.difference(ccm, oc.stream().map(BomNewDQbomChildEntity::getMaterialNo).collect(Collectors.toSet())).isEmpty();
|
||||||
//VUtils.isTure(isSame).throwMessage("导入的数据已存在,请勿重复导入");
|
//VUtils.isTure(isSame).throwMessage("导入的数据已存在,请勿重复导入");
|
||||||
|
|
||||||
|
|
@ -234,15 +231,6 @@ public class DQBomImportService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Integer> noProjectType = datas.stream().filter(u -> !TYPES.contains(u.getProjectType()))
|
|
||||||
.map(BaseImportExcelDTO::getRowNum)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (!noProjectType.isEmpty()) {
|
|
||||||
errorMsg.addAll(noProjectType.stream().map(n -> OperationErrorMsgVO.create("第" + n + "行", "项目类别不正确"))
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Integer> remarkTooLong = datas.stream().filter(u -> StringUtil.CountForMysql(u.getRemark()) > 200)
|
List<Integer> remarkTooLong = datas.stream().filter(u -> StringUtil.CountForMysql(u.getRemark()) > 200)
|
||||||
.map(BaseImportExcelDTO::getRowNum)
|
.map(BaseImportExcelDTO::getRowNum)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
@ -252,6 +240,18 @@ public class DQBomImportService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> materialNos = datas.stream().map(DQbomExcelVO::getMaterialNo).distinct().collect(Collectors.toList());
|
||||||
|
List<BaseMaterialVO> materialBaseInfos = materialMainService.getMaterialBaseInfo(materialNos);
|
||||||
|
datas.forEach(d -> {
|
||||||
|
BaseMaterialVO vo = materialBaseInfos.stream()
|
||||||
|
.filter(m -> m.getMaterialNo().equals(d.getMaterialNo()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (!Objects.isNull(vo)) {
|
||||||
|
d.setDrawingNo(vo.getDrawingNo());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return errorMsg;
|
return errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -364,10 +364,10 @@ public class DQBomImportService {
|
||||||
log.debug("电气bom导入excel,第{}行,处理前:{}", rowNum.get(), JSON.toJSONString(dQbomExcelVO));
|
log.debug("电气bom导入excel,第{}行,处理前:{}", rowNum.get(), JSON.toJSONString(dQbomExcelVO));
|
||||||
|
|
||||||
dQbomExcelVO.setRowNum(rowNum.get());
|
dQbomExcelVO.setRowNum(rowNum.get());
|
||||||
if (dQbomExcelVO.getProjectType().equals("T")) {
|
if (dQbomExcelVO.getProjectType().equals(BomConstant.PROJECT_TYPE_TEMPORARY)) {
|
||||||
String id = RandomUtil.randomNumbers(9);
|
String id = RandomUtil.randomNumbers(9);
|
||||||
dQbomExcelVO.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id);
|
dQbomExcelVO.setMaterialNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
||||||
dQbomExcelVO.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id);
|
dQbomExcelVO.setDrawingNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
||||||
if (StrUtil.isBlank(dQbomExcelVO.getMaterialUnit())) {
|
if (StrUtil.isBlank(dQbomExcelVO.getMaterialUnit())) {
|
||||||
dQbomExcelVO.setMaterialUnit("PC");
|
dQbomExcelVO.setMaterialUnit("PC");
|
||||||
}
|
}
|
||||||
|
|
@ -375,8 +375,8 @@ public class DQBomImportService {
|
||||||
dQbomExcelVO.setNum(BigDecimal.ONE);
|
dQbomExcelVO.setNum(BigDecimal.ONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StrUtil.equals(dQbomExcelVO.getMaterialNo(), "9000000000")) {
|
if (StrUtil.equals(dQbomExcelVO.getMaterialNo(), BomConstant.PROJECT_TYPE_TEMPORARY_MATERIAL_NO)) {
|
||||||
dQbomExcelVO.setProjectType("T");
|
dQbomExcelVO.setProjectType(BomConstant.PROJECT_TYPE_TEMPORARY);
|
||||||
}
|
}
|
||||||
dQbomExcelVO.setCurrentVersion("");
|
dQbomExcelVO.setCurrentVersion("");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -257,16 +257,17 @@ public class DQBomService {
|
||||||
}
|
}
|
||||||
//处理child
|
//处理child
|
||||||
List<BomNewDQbomChildEntity> children = Convert.toList(BomNewDQbomChildEntity.class, query.getChildren());
|
List<BomNewDQbomChildEntity> children = Convert.toList(BomNewDQbomChildEntity.class, query.getChildren());
|
||||||
|
List<BomNewDQbomParentEntity> cps = new ArrayList<>();
|
||||||
for (int index = 0, count = children.size(); index < count; index++) {
|
for (int index = 0, count = children.size(); index < count; index++) {
|
||||||
BomNewDQbomChildEntity c = children.get(index);
|
BomNewDQbomChildEntity c = children.get(index);
|
||||||
if (Objects.isNull(c.getRowId()) || c.getRowId() == 0) {
|
if (Objects.isNull(c.getRowId()) || c.getRowId() == 0) {
|
||||||
c.setRowId(IdWorker.getId());
|
c.setRowId(IdWorker.getId());
|
||||||
c.setCreatedBy(SessionUtil.getUserCode());
|
c.setCreatedBy(SessionUtil.getUserCode());
|
||||||
c.setCreatedName(SessionUtil.getRealName());
|
c.setCreatedName(SessionUtil.getRealName());
|
||||||
if (StrUtil.equals(c.getProjectType(), "T")) {
|
if (StrUtil.equals(c.getProjectType(), BomConstant.PROJECT_TYPE_TEMPORARY)) {
|
||||||
String id = RandomUtil.randomNumbers(9);
|
String id = RandomUtil.randomNumbers(9);
|
||||||
c.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id);
|
c.setMaterialNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
||||||
c.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id);
|
c.setDrawingNo(BomConstant.PROJECT_TYPE_TEMPORARY + id);
|
||||||
if (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO)) {
|
if (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO)) {
|
||||||
c.setNum(BigDecimal.ONE);
|
c.setNum(BigDecimal.ONE);
|
||||||
}
|
}
|
||||||
|
|
@ -282,8 +283,21 @@ public class DQBomService {
|
||||||
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
|
c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId());
|
||||||
c.setOrderNumber(StrUtil.padPre(String.valueOf(index + 1), 3, '0'));
|
c.setOrderNumber(StrUtil.padPre(String.valueOf(index + 1), 3, '0'));
|
||||||
c.setTotalWeight(BomUtil.calculateTotalWeight(c.getNum(), query.getChildren().get(index).getUnitWeight()));
|
c.setTotalWeight(BomUtil.calculateTotalWeight(c.getNum(), query.getChildren().get(index).getUnitWeight()));
|
||||||
|
//处理parent
|
||||||
|
BomNewDQbomParentEntity cp = dQBomParentService.lambdaQuery()
|
||||||
|
.eq(BomNewDQbomParentEntity::getMaterialNo, c.getMaterialNo())
|
||||||
|
.eq(BomNewDQbomParentEntity::getStatus, DQBomStatusEnum.WAIT_CONVERT.getValue())
|
||||||
|
.one();
|
||||||
|
if (!Objects.isNull(cp)) {
|
||||||
|
cp.setMaterialName(c.getMaterialName());
|
||||||
|
cp.setUnitWeight(c.getUnitWeight());
|
||||||
|
cp.setTotalWeight(BomUtil.calculateTotalWeight(cp.getNum(), cp.getUnitWeight()));
|
||||||
|
cp.setModifyTime(LocalDateTime.now());
|
||||||
|
cps.add(cp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dQBomChildService.saveBatch(children);
|
dQBomChildService.saveBatch(children);
|
||||||
|
dQBomParentService.updateBatchById(cps);
|
||||||
query.setChildren(Convert.toList(BomNewDQbomVO.class, children));
|
query.setChildren(Convert.toList(BomNewDQbomVO.class, children));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
@ -294,8 +308,8 @@ public class DQBomService {
|
||||||
VUtils.isTure(!SessionUtil.getUserCode().equals(root.getCreatedBy())).throwMessage("不能删除他人创建的bom");
|
VUtils.isTure(!SessionUtil.getUserCode().equals(root.getCreatedBy())).throwMessage("不能删除他人创建的bom");
|
||||||
VUtils.isTure(root.getStatus().equals(DQBomStatusEnum.PUBLISHED.getValue())).throwMessage("不能删除已发布的bom");
|
VUtils.isTure(root.getStatus().equals(DQBomStatusEnum.PUBLISHED.getValue())).throwMessage("不能删除已发布的bom");
|
||||||
|
|
||||||
List<Long> liChildren = new ArrayList<>();
|
Set<Long> liChildren = new HashSet<>();
|
||||||
List<Long> liParents = new ArrayList<>();
|
Set<Long> liParents = new HashSet<>();
|
||||||
liParents.add(root.getRowId());
|
liParents.add(root.getRowId());
|
||||||
List<BomNewDQbomVO> children = dQBomChildService.getBomsByParentRowId(rowId);
|
List<BomNewDQbomVO> children = dQBomChildService.getBomsByParentRowId(rowId);
|
||||||
children.forEach(c -> {
|
children.forEach(c -> {
|
||||||
|
|
@ -305,7 +319,7 @@ public class DQBomService {
|
||||||
dQBomChildService.getBaseMapper().deleteBatchIds(liChildren);
|
dQBomChildService.getBaseMapper().deleteBatchIds(liChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete(List<Long> parents, List<Long> children, BomNewDQbomVO bom) {
|
private void delete(Set<Long> parents, Set<Long> children, BomNewDQbomVO bom) {
|
||||||
children.add(bom.getRowId());
|
children.add(bom.getRowId());
|
||||||
if (!Objects.isNull(bom.getBomRowId()) && bom.getBomCreateBy().equals(SessionUtil.getUserCode())) {
|
if (!Objects.isNull(bom.getBomRowId()) && bom.getBomCreateBy().equals(SessionUtil.getUserCode())) {
|
||||||
parents.add(bom.getBomRowId());
|
parents.add(bom.getBomRowId());
|
||||||
|
|
@ -333,7 +347,14 @@ public class DQBomService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DQbomExcelVO> exportBom(Long rootBomRowId) {
|
public List<DQbomExcelVO> exportBom(Long rootBomRowId) {
|
||||||
return Convert.toList(DQbomExcelVO.class, getAll(rootBomRowId));
|
List<BomNewDQbomVO> datas = getAll(rootBomRowId);
|
||||||
|
datas.forEach(d -> {
|
||||||
|
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(d.getProjectType())) {
|
||||||
|
d.setMaterialNo(BomConstant.PROJECT_TYPE_TEMPORARY_MATERIAL_NO);
|
||||||
|
d.setDrawingNo(BomConstant.PROJECT_TYPE_TEMPORARY_MATERIAL_NO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Convert.toList(DQbomExcelVO.class, datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BomNewDQbomVO> getAll(Long rootBomRowId) {
|
private List<BomNewDQbomVO> getAll(Long rootBomRowId) {
|
||||||
|
|
@ -365,20 +386,26 @@ public class DQBomService {
|
||||||
VUtils.isTure(root.getSapState() == 3).throwMessage("已导入过了,请勿重复操作");
|
VUtils.isTure(root.getSapState() == 3).throwMessage("已导入过了,请勿重复操作");
|
||||||
|
|
||||||
List<BomNewDQbomVO> datas = getAll(rootBomRowId);
|
List<BomNewDQbomVO> datas = getAll(rootBomRowId);
|
||||||
|
datas.remove(0);
|
||||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||||
sapDto.setI_WERKS(FactoryCodeEnum.FACTORY_1010.getValue());
|
sapDto.setI_WERKS("1");
|
||||||
sapDto.setI_STLAN("2");
|
sapDto.setI_STLAN("1");
|
||||||
List<T1DTO> t1s = new ArrayList<>();
|
List<T1DTO> t1s = new ArrayList<>();
|
||||||
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||||
datas.forEach(d -> {
|
datas.forEach(d -> {
|
||||||
T1DTO t1 = new T1DTO();
|
T1DTO t1 = new T1DTO();
|
||||||
t1.setID(RandomUtil.randomNumbers(5));
|
t1.setID(RandomUtil.randomNumbers(5));
|
||||||
t1.setMATNR(d.getParentMaterialNo());
|
t1.setMATNR(d.getParentMaterialNo());
|
||||||
t1.setIDNRK(d.getMaterialNo());
|
|
||||||
t1.setMEINS(d.getMaterialUnit());
|
t1.setMEINS(d.getMaterialUnit());
|
||||||
t1.setMENGE(d.getNum().toString());
|
t1.setMENGE(d.getNum().toString());
|
||||||
t1.setPOSTP(d.getProjectType());
|
t1.setPOSTP(d.getProjectType());
|
||||||
|
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(d.getProjectType())) {
|
||||||
|
t1.setIDNRK("");
|
||||||
|
t1.setPOTX1(d.getMaterialName());
|
||||||
|
} else {
|
||||||
|
t1.setIDNRK(d.getMaterialNo());
|
||||||
|
}
|
||||||
t1.setDATUM(dateYMD);
|
t1.setDATUM(dateYMD);
|
||||||
t1s.add(t1);
|
t1s.add(t1);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,18 @@ package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.TypeReference;
|
import cn.hutool.core.lang.TypeReference;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.nflg.product.base.core.exception.ErrorMsgException;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.ImportToSapDTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.ImportToSapDTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
|
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
|
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParam2DTO;
|
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParam2DTO;
|
||||||
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
|
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.vo.OperationErrorMsgBaseVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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;
|
||||||
|
|
@ -20,10 +21,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -143,18 +141,16 @@ public class SapOpUtilService {
|
||||||
if (CollUtil.isEmpty(impartSapParamDTO.getT1())) {
|
if (CollUtil.isEmpty(impartSapParamDTO.getT1())) {
|
||||||
return ResultVO.error("同步SAP 参数错误");
|
return ResultVO.error("同步SAP 参数错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SapReqParams params = new SapReqParams();
|
SapReqParams params = new SapReqParams();
|
||||||
// 接口名
|
// 接口名
|
||||||
params.setFunName("ZRFC_PP_003");
|
params.setFunName("ZRFC_PP_003");
|
||||||
|
|
||||||
Map<String, Map<String, Object>> inputStructure = new HashMap<>();
|
//Map<String, Map<String, Object>> inputStructure = new HashMap<>();
|
||||||
|
|
||||||
ImportSapParam2DTO pp=Convert.convert(ImportSapParam2DTO.class ,impartSapParamDTO);
|
ImportSapParam2DTO pp=Convert.convert(ImportSapParam2DTO.class ,impartSapParamDTO);
|
||||||
Map<String, Object> parentMap = Convert.convert(new TypeReference<Map<String, Object>>() {
|
Map<String, Object> parentMap = Convert.convert(new TypeReference<Map<String, Object>>() {
|
||||||
}, pp);
|
}, pp);
|
||||||
inputStructure.put("I_STKO", parentMap);
|
//inputStructure.put("I_STKO", parentMap);
|
||||||
params.setInputParams(parentMap);
|
params.setInputParams(parentMap);
|
||||||
|
|
||||||
Map<String, List<Map<String, String>>> inputTables = new HashMap<>();
|
Map<String, List<Map<String, String>>> inputTables = new HashMap<>();
|
||||||
|
|
@ -182,44 +178,36 @@ public class SapOpUtilService {
|
||||||
}
|
}
|
||||||
log.info("导入到SAP--返回值:" + JSON.toJSONString(outTablesMap));
|
log.info("导入到SAP--返回值:" + JSON.toJSONString(outTablesMap));
|
||||||
|
|
||||||
if(CollectionUtil.isNotEmpty(list)){
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
//StringBuffer errBuf=new StringBuffer();
|
||||||
StringBuffer errBuf=new StringBuffer();
|
List<OperationErrorMsgBaseVO> liError = new ArrayList<>();
|
||||||
AtomicInteger errCount= new AtomicInteger();
|
AtomicInteger errCount= new AtomicInteger();
|
||||||
AtomicInteger succCount= new AtomicInteger();
|
AtomicInteger succCount= new AtomicInteger();
|
||||||
for (T1DTO item:
|
for (T1DTO item : list) {
|
||||||
list) {
|
|
||||||
|
|
||||||
|
|
||||||
if (backList != null) {
|
if (backList != null) {
|
||||||
backList.add(item);
|
backList.add(item);
|
||||||
}
|
}
|
||||||
//"FLAG": "1" -- 0 失败;1 成功
|
//"FLAG": "1" -- 0 失败;1 成功
|
||||||
if (item.getFLAG().equals("0")) {
|
if (item.getFLAG().equals("0")) {
|
||||||
errCount.getAndIncrement();
|
errCount.getAndIncrement();
|
||||||
errBuf.append(item.getSTATUS()+",");
|
//errBuf.append(item.getSTATUS() + ",");
|
||||||
|
liError.add(OperationErrorMsgBaseVO.create(item.getSTATUS()));
|
||||||
} else if (item.getFLAG().equals("1")) {
|
} else if (item.getFLAG().equals("1")) {
|
||||||
succCount.getAndIncrement();
|
succCount.getAndIncrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (errCount.get() > 0) {
|
if (errCount.get() > 0) {
|
||||||
throw new Exception(errBuf.toString());
|
//throw new Exception(errBuf.toString());
|
||||||
|
throw new ErrorMsgException(STATE.Success, "导入到SAP出错", liError);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
throw new Exception("获取sap返回数据转换异常");
|
throw new Exception("获取sap返回数据转换异常");
|
||||||
}
|
}
|
||||||
|
} catch (ErrorMsgException e) {
|
||||||
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResultVO.error(STATE.Error, e.getMessage());
|
return ResultVO.error(STATE.Error, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ResultVO.success();
|
return ResultVO.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ public class SapService implements ApplicationContextAware {
|
||||||
res.setOutTablesMap(outTablesMap);
|
res.setOutTablesMap(outTablesMap);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("导入SAP出错", e);
|
||||||
res.setCode(500);
|
res.setCode(500);
|
||||||
res.setSuccess(false);
|
res.setSuccess(false);
|
||||||
res.setMsg(e.getMessage());
|
res.setMsg(e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@
|
||||||
ifnull(p.exception_tag, c.exception_tag) exception_tag,
|
ifnull(p.exception_tag, c.exception_tag) exception_tag,
|
||||||
ifnull(p.bom_exist, 0) bom_exist,
|
ifnull(p.bom_exist, 0) bom_exist,
|
||||||
ifnull(p.sap_state, 1) sap_state,
|
ifnull(p.sap_state, 1) sap_state,
|
||||||
|
ifnull(p.current_version, if(c.status = 1, 'A00', p2.current_version)) current_version,
|
||||||
c.*
|
c.*
|
||||||
FROM t_bom_new_dqbom_child c
|
FROM t_bom_new_dqbom_child c
|
||||||
INNER JOIN t_bom_new_dqbom_parent p2 ON p2.row_id = c.parent_row_id
|
INNER JOIN t_bom_new_dqbom_parent p2 ON p2.row_id = c.parent_row_id
|
||||||
|
|
|
||||||
|
|
@ -152,4 +152,12 @@ public class BaseGlobalExceptionHandle {
|
||||||
log.error(ex.getMessage(),ex);
|
log.error(ex.getMessage(),ex);
|
||||||
return ResultVO.error(STATE.ParamErr, ex.getParameterName()+"参数不能为空");
|
return ResultVO.error(STATE.ParamErr, ex.getParameterName()+"参数不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = ErrorMsgException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public ResultVO handleErrorMsgException(ErrorMsgException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
//return ResultVO.error(e.getState(), e.getMessage());
|
||||||
|
return ResultVO.error(e.getState(), e.getMessage(), e.getData());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.nflg.product.base.core.exception;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import nflg.product.common.constant.STATE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 曹鹏飞
|
||||||
|
* @date 2024/4/26 14:18:09
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Slf4j
|
||||||
|
public class ErrorMsgException extends RuntimeException {
|
||||||
|
private final STATE state;
|
||||||
|
private final String msg;
|
||||||
|
private final Object data;
|
||||||
|
|
||||||
|
public ErrorMsgException(STATE state, String msg, Object data) {
|
||||||
|
super(msg);
|
||||||
|
this.state = state;
|
||||||
|
this.msg = msg;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package nflg.product.common.vo;
|
package nflg.product.common.vo;
|
||||||
|
|
||||||
import cn.hutool.core.text.StrBuilder;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
|
|
@ -44,6 +43,7 @@ public class ResultVO<T> implements Serializable {
|
||||||
vo.msg = msg;
|
vo.msg = msg;
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> ResultVO<T> error(STATE code, String msg) {
|
public static <T> ResultVO<T> error(STATE code, String msg) {
|
||||||
return error(msg, code.getState(), null);
|
return error(msg, code.getState(), null);
|
||||||
}
|
}
|
||||||
|
|
@ -70,6 +70,12 @@ public class ResultVO<T> implements Serializable {
|
||||||
return error(msg ,STATE.PassportErr.getState());
|
return error(msg ,STATE.PassportErr.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResultVO error(STATE state, String msg, Object value) {
|
||||||
|
ResultVO vo = new ResultVO<>();
|
||||||
|
vo.data = value;
|
||||||
|
vo.state = state.getState();
|
||||||
|
vo.msg = msg;
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue