feat(pbom): 添加导入SAP失败的数量显示和列表

This commit is contained in:
曹鹏飞 2024-06-07 15:25:53 +08:00
parent b0bc503239
commit e1367525e5
4 changed files with 77 additions and 0 deletions

View File

@ -339,4 +339,24 @@ public class PBomApi extends BaseApi {
public ResultVO<List<OperationErrorMsgVO>> importToSAP(@Valid @RequestBody @NotNull PbomImportToSAPQuery query) { public ResultVO<List<OperationErrorMsgVO>> importToSAP(@Valid @RequestBody @NotNull PbomImportToSAPQuery query) {
return ResultVO.success(bomNewPbomParentService.importToSAP2(query)); return ResultVO.success(bomNewPbomParentService.importToSAP2(query));
} }
/**
* 获取导入sap失败的bom数量
* @return 导入sap失败的bom数量
*/
@GetMapping("getSapErrorNum")
@ApiOperation("获取导入sap失败的bom数量")
public ResultVO<Integer> getSapErrorNum() {
return ResultVO.success(bomNewPbomParentService.getSapErrorNum());
}
/**
* 获取导入sap失败的bom
* @return 导入sap失败的bom
*/
@GetMapping("getSapError")
@ApiOperation("获取导入sap失败错误信息")
public ResultVO<List<OperationErrorMsgVO>> getSapError(@Valid @RequestParam("rowId") @NotNull Long rowId) {
return ResultVO.success(bomNewPbomParentService.getSapError(rowId));
}
} }

View File

@ -6,6 +6,9 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.*; 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.ImportSapParamDTO;
@ -13,6 +16,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import nflg.product.common.constant.STATE; import nflg.product.common.constant.STATE;
@ -44,6 +48,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
private final BomNewPbomParentService bomNewPbomParentService = SpringUtil.getBean(BomNewPbomParentService.class); private final BomNewPbomParentService bomNewPbomParentService = SpringUtil.getBean(BomNewPbomParentService.class);
private final BomNewPbomChildService bomNewPbomChildService = SpringUtil.getBean(BomNewPbomChildService.class); private final BomNewPbomChildService bomNewPbomChildService = SpringUtil.getBean(BomNewPbomChildService.class);
private final BomNewSapErrorMsgService bomNewSapErrorMsgService = SpringUtil.getBean(BomNewSapErrorMsgService.class);
public BomNewPbomExportToSAPImpl(boolean isForSale) { public BomNewPbomExportToSAPImpl(boolean isForSale) {
this.isForSale = isForSale; this.isForSale = isForSale;
@ -110,12 +115,34 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
} else if (sapDto.getT1().size() != liErrMsg.size()) { } else if (sapDto.getT1().size() != liErrMsg.size()) {
state = SapStatusEnum.PUB_ERROR; state = SapStatusEnum.PUB_ERROR;
} }
saveSapErrorMsg(rootBomRowId, liErrMsg);
} catch (Exception ex) {
LOGGER.error("导入SAP失败", ex);
liErrMsg = new ArrayList<>();
liErrMsg.add(OperationErrorMsgVO.create("", "未知异常,请联系管理员"));
saveSapErrorMsg(rootBomRowId, liErrMsg);
throw new NflgBusinessException(STATE.BusinessError, "导入SAP失败请联系管理员");
} finally { } finally {
updateSapState(rootBomRowId, state); updateSapState(rootBomRowId, state);
} }
return liErrMsg; return liErrMsg;
} }
private void saveSapErrorMsg(Long rootBomRowId, List<OperationErrorMsgVO> liErrMsg) {
bomNewSapErrorMsgService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewSapErrorMsgEntity.class)
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
if (CollUtil.isNotEmpty(liErrMsg)) {
BomNewSapErrorMsgEntity sapErrorMsgEntity = new BomNewSapErrorMsgEntity();
sapErrorMsgEntity.setTargetRowId(rootBomRowId);
sapErrorMsgEntity.setType(0);
sapErrorMsgEntity.setData(JSON.toJSONString(liErrMsg));
sapErrorMsgEntity.setCreatedName(SessionUtil.getRealName());
sapErrorMsgEntity.setCreatedTime(LocalDateTime.now());
bomNewSapErrorMsgService.saveOrUpdate(sapErrorMsgEntity);
}
}
private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) { private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) {
bomNewPbomParentService.lambdaUpdate() bomNewPbomParentService.lambdaUpdate()
.in(BomNewPbomParentEntity::getRowId, rootBomRowId) .in(BomNewPbomParentEntity::getRowId, rootBomRowId)

View File

@ -8,6 +8,7 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -105,6 +106,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource @Resource
SapOpUtilService sapOpUtilService; SapOpUtilService sapOpUtilService;
@Resource
private BomNewSapErrorMsgService bomNewSapErrorMsgService;
/** /**
* pbom-工作列表 * pbom-工作列表
* *
@ -1456,4 +1460,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
newP.setDeviseUserCode(""); newP.setDeviseUserCode("");
return newP; return newP;
} }
public Integer getSapErrorNum() {
return this.getBaseMapper().getSapErrorNum(SessionUtil.getUserCode());
}
public List<OperationErrorMsgVO> getSapError(Long rowId) {
BomNewSapErrorMsgEntity sapErrorMsgEntity = bomNewSapErrorMsgService.lambdaQuery()
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rowId)
.one();
if (Objects.isNull(sapErrorMsgEntity)) return Collections.emptyList();
return JSON.parseArray(sapErrorMsgEntity.getData(), OperationErrorMsgVO.class);
}
} }

View File

@ -263,6 +263,20 @@
#{item} #{item}
</foreach>; </foreach>;
</select> </select>
<select id="getSapErrorWorksheet" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT *, row_id AS bomRowId
FROM t_bom_new_pbom_parent
WHERE status > 4
AND (root_is = 1 OR user_root_is = 1 OR root_state = 1)
AND sap_state > 3
AND created_by = #{userCode}
</select>
<select id="getSapErrorNum" resultType="java.lang.Integer">
SELECT COUNT(1)
FROM t_bom_new_ebom_parent p
INNER JOIN t_bom_new_sap_error_msg e ON p.row_id = e.target_row_id AND e.type = 1
WHERE p.created_by = #{userCode}
</select>
<sql id="upRootStateWhr"> <sql id="upRootStateWhr">
<foreach collection="materialNoList" item="item" open="(" separator="," close=")"> <foreach collection="materialNoList" item="item" open="(" separator="," close=")">