feat(pmo):优化箱变同步启源流程生产订单逻辑-增加物料序列号启用状态检查
This commit is contained in:
parent
7b550e51cc
commit
1dea780a50
|
|
@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.bs.uapbd.util.ThirdPartyPostRequestUtil;
|
||||
|
|
@ -21,6 +20,7 @@ import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
|||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pmpub.project.ProjectHeadVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFBoolean;
|
||||
import nc.vo.pub.lang.UFDateTime;
|
||||
import nccloud.api.rest.utils.ResultMessageUtil;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
|
|
@ -50,7 +50,7 @@ public class PmoToQmsAction implements ICommonAction {
|
|||
@Override
|
||||
public Object doAction(IRequest iRequest) {
|
||||
String json = iRequest.read();
|
||||
logger.error("PmoToQmsAction-Param:" + json);
|
||||
// logger.error("PmoToQmsAction-Param:" + json);
|
||||
Map<String, Object> paraMap = (Map) JsonFactory.create().fromJson(json, Map.class);
|
||||
try {
|
||||
// 获取主键
|
||||
|
|
@ -75,7 +75,7 @@ public class PmoToQmsAction implements ICommonAction {
|
|||
* 构建同步数据
|
||||
*/
|
||||
private void buildSyncData(PMOAggVO[] useVOs) throws BusinessException {
|
||||
IPMOQueryService pmoQuery = NCLocator.getInstance().lookup(IPMOQueryService.class);
|
||||
IPMOQueryService pmoQuery = ServiceLocator.find(IPMOQueryService.class);
|
||||
Set<String> vbatchcodeSet = new HashSet<>();
|
||||
PMOAggVO aggVO = useVOs[0];
|
||||
PMOHeadVO headVO = aggVO.getParentVO();
|
||||
|
|
@ -139,13 +139,18 @@ public class PmoToQmsAction implements ICommonAction {
|
|||
Map<String, Object> mrlmap = (Map<String, Object>) dao.executeQuery(whereSql, new MapProcessor());
|
||||
|
||||
String cprojectid = item.getCprojectid();// 项目id
|
||||
String projectCode = MyHelper.getStrValByCondition(nc.vo.pmpub.project.ProjectHeadVO.getDefaultTableName(), nc.vo.pmpub.project.ProjectHeadVO.PROJECT_CODE,
|
||||
String projectCode = MyHelper.getStrValByCondition(ProjectHeadVO.getDefaultTableName(), ProjectHeadVO.PROJECT_CODE,
|
||||
ProjectHeadVO.PK_PROJECT + " = '" + cprojectid + "'");
|
||||
// 序列号
|
||||
String vsnCodeSql = " select vsncode from mm_pmo_serialno where cmoid = '" + cmoid + "' and dr = 0 ";
|
||||
List<Map<String, String>> vsnCodeList = (List<Map<String, String>>) dao.executeQuery(vsnCodeSql, new MapListProcessor());
|
||||
if (vsnCodeList == null || vsnCodeList.isEmpty()) {
|
||||
throw new BusinessException("箱变同步启源流程生产订单失败,请检查是否存在序列号");
|
||||
// 检查物料是否开启序列号,开启查不到序列号则提示异常,未开启直接跳过
|
||||
if (checkMaterialSn(cmaterialvid, item.getPk_org())) {
|
||||
if (MMValueCheck.isEmpty(vsnCodeList)) {
|
||||
throw new BusinessException("箱变同步启源流程生产订单失败,请检查是否存在序列号");
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("箱变推启源流程生产订单,物料的序列号未启用");
|
||||
}
|
||||
for (Map<String, String> vsnMap : vsnCodeList) {
|
||||
JSONObject itemObj = new JSONObject();
|
||||
|
|
@ -211,8 +216,12 @@ public class PmoToQmsAction implements ICommonAction {
|
|||
singleObj.put("jhy", billmakerName);
|
||||
singleObj.put("bz", headVO.getVnote());
|
||||
singleObj.put("Content", contentArray);
|
||||
pushData(singleObj);
|
||||
updatePmo(hidSet);
|
||||
if (MMValueCheck.isNotEmpty(contentArray)) {
|
||||
pushData(singleObj);
|
||||
updatePmo(hidSet);
|
||||
} else {
|
||||
logger.error("QMS-PMO-XB-无同步数据:" + singleObj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -274,4 +283,19 @@ public class PmoToQmsAction implements ICommonAction {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查物料是否开启序列号
|
||||
*/
|
||||
private boolean checkMaterialSn(String pk_material, String pk_org) throws BusinessException {
|
||||
String sql = "SELECT DISTINCT bd_materialstock.serialmanaflag" +
|
||||
" FROM bd_materialstock" +
|
||||
" WHERE bd_materialstock.pk_material = '[pk_material]' AND bd_materialstock.pk_org = '[pk_org]'";
|
||||
sql = sql.replace("[pk_material]", pk_material);
|
||||
sql = sql.replace("[pk_org]", pk_org);
|
||||
String flag = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
UFBoolean serialmanaflag = UFBoolean.valueOf(flag);
|
||||
return serialmanaflag.booleanValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
|||
import nc.vo.org.OrgVO;
|
||||
import nc.vo.pmpub.project.ProjectHeadVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.lang.UFBoolean;
|
||||
import nc.vo.pub.lang.UFDateTime;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
|
@ -82,7 +83,7 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
for (PMOItemVO itemVO : nowItemVOS) {
|
||||
String vbatchcode = itemVO.getVbatchcode();
|
||||
if(null == vbatchcode){
|
||||
if (null == vbatchcode) {
|
||||
continue;
|
||||
}
|
||||
vbatchcodeSet.add(vbatchcode);
|
||||
|
|
@ -128,14 +129,23 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
|
|||
Map<String, Object> mrlmap = (Map<String, Object>) dao.executeQuery(whereSql, new MapProcessor());
|
||||
|
||||
String cprojectid = item.getCprojectid();// 项目id
|
||||
String projectCode = MyHelper.getStrValByCondition(ProjectHeadVO.getDefaultTableName(), ProjectHeadVO.PROJECT_CODE,
|
||||
ProjectHeadVO.PK_PROJECT + " = '" + cprojectid + "'");
|
||||
String projectCode = MyHelper.getStrValByCondition(ProjectHeadVO.getDefaultTableName(), ProjectHeadVO.PROJECT_CODE, ProjectHeadVO.PK_PROJECT + " = '" + cprojectid + "'");
|
||||
// 序列号
|
||||
String vsnCodeSql = " select vsncode from mm_pmo_serialno where cmoid = '" + cmoid + "' and dr = 0 ";
|
||||
List<Map<String, String>> vsnCodeList = (List<Map<String, String>>) dao.executeQuery(vsnCodeSql, new MapListProcessor());
|
||||
if (vsnCodeList == null || vsnCodeList.isEmpty()) {
|
||||
throw new BusinessException("箱变同步启源流程生产订单失败,请检查是否存在序列号");
|
||||
// 检查物料是否开启序列号,开启查不到序列号则提示异常,未开启直接跳过
|
||||
if (checkMaterialSn(cmaterialvid, item.getPk_org())) {
|
||||
if (MMValueCheck.isEmpty(vsnCodeList)) {
|
||||
throw new BusinessException("箱变同步启源流程生产订单失败,请检查是否存在序列号");
|
||||
}
|
||||
} else {
|
||||
logger.error(String.format(
|
||||
"箱变推启源流程生产订单,物料的序列号未启用,物料id = [%S], 单号 = [%S], 行号 = [%S]",
|
||||
cmaterialvid, vbillcode, item.getVrowno()
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Map<String, String> vsnMap : vsnCodeList) {
|
||||
JSONObject itemObj = new JSONObject();
|
||||
itemObj.put("sgdh", vsnMap.get("vsncode"));// QMS施工单号-BIP的序列号
|
||||
|
|
@ -200,8 +210,12 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
|
|||
singleObj.put("jhy", billmakerName);
|
||||
singleObj.put("bz", headVO.getVnote());
|
||||
singleObj.put("Content", contentArray);
|
||||
pushData(singleObj);
|
||||
updatePmo(hidSet);
|
||||
if (MMValueCheck.isNotEmpty(contentArray)) {
|
||||
pushData(singleObj);
|
||||
updatePmo(hidSet);
|
||||
} else {
|
||||
logger.error("QMS-PMO-XB-无同步数据:" + singleObj.toJSONString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -218,10 +232,7 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
|
|||
private void pushData(JSONObject param) throws BusinessException {
|
||||
// String jsonString = param.toJSONString();
|
||||
// 转json字符串的时候保留null值
|
||||
String jsonStr = JSON.toJSONString(param,
|
||||
SerializerFeature.WriteMapNullValue,
|
||||
SerializerFeature.WriteNullStringAsEmpty
|
||||
);
|
||||
String jsonStr = JSON.toJSONString(param, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty);
|
||||
logger.error("QMS-PMO-XB-param = " + jsonStr);
|
||||
// NCCForUAPLogger.debug("QMS-PMO-XB-param = " + jsonStr);
|
||||
String baseUrl = configParams.get("qmsBaseUrl");
|
||||
|
|
@ -264,4 +275,19 @@ public class AfterApproveSyncQMSRule implements IRule<PMOAggVO> {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查物料是否开启序列号
|
||||
*/
|
||||
private boolean checkMaterialSn(String pk_material, String pk_org) throws BusinessException {
|
||||
String sql = "SELECT DISTINCT bd_materialstock.serialmanaflag" +
|
||||
" FROM bd_materialstock" +
|
||||
" WHERE bd_materialstock.pk_material = '[pk_material]' AND bd_materialstock.pk_org = '[pk_org]'";
|
||||
sql = sql.replace("[pk_material]", pk_material);
|
||||
sql = sql.replace("[pk_org]", pk_org);
|
||||
String flag = (String) dao.executeQuery(sql, new ColumnProcessor());
|
||||
UFBoolean serialmanaflag = UFBoolean.valueOf(flag);
|
||||
return serialmanaflag.booleanValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue