Merge remote-tracking branch 'origin/main'

This commit is contained in:
lihao 2025-10-26 16:38:28 +08:00
commit 6626db733c
5 changed files with 126 additions and 263 deletions

View File

@ -1,19 +1,10 @@
package nccloud.web.mmpac.pickm.query;
import nc.bs.dao.BaseDAO;
import nc.bs.trade.business.HYPubBO;
import nc.itf.mmpac.pickm.IPickmQueryService;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.material.MaterialVO;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.mmpac.pickm.entity.AggPickmVO;
import nc.vo.mmpac.pickm.entity.PickmHeadVO;
import nc.vo.mmpac.pickm.entity.PickmItemVO;
import nc.vo.mmpac.pickm.enumeration.FbillstatusEnum;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import nccloud.commons.lang.StringUtils;
import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson;
@ -21,13 +12,17 @@ import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory;
import nccloud.framework.web.ui.model.GridModel;
import nccloud.framework.web.ui.model.row.Cell;
import nccloud.framework.web.ui.model.row.Row;
import nccloud.framework.web.ui.pattern.billcard.BillCard;
import nccloud.framework.web.ui.pattern.billcard.BillCardOperator;
import nccloud.framework.web.ui.pattern.grid.Grid;
import nccloud.framework.web.ui.pattern.grid.GridOperator;
import nccloud.web.mmpub.pub.action.NCCTempletQueryAction;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 备料计划列表-借料入库弹窗-查询
@ -41,124 +36,77 @@ public class PickmByIdsQueryAction implements ICommonAction {
IJson json = JsonFactory.create();
PickmQueryInfoDTO query = json.fromJson(read, PickmQueryInfoDTO.class);
try {
String pageid = query.getPageid();
String appcode = query.getAppcode();
String pageid ="50080102_card";
String[] pks = query.getPks();
IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class);
AggPickmVO[] vos = service.queryBillsByPks(pks);
if (null == vos || vos.length == 0) {
ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("5008100_0", "05008100-0005"));
}
List<PickmItemVO> bids = new ArrayList<>();
Map<String, PickmHeadVO> pickmHeadMap = new HashMap<>();
List<Row> list=new ArrayList<>();
List<Grid> bodyList = new ArrayList<>();
for (AggPickmVO vo : vos) {
PickmHeadVO headVO = vo.getParentVO();
if (FbillstatusEnum.AUDIT_STATE.equalsValue(headVO.getFbillstatus())) {
PickmItemVO[] itemVOS = (PickmItemVO[]) vo.getChildren(PickmItemVO.class);
if (itemVOS == null || itemVOS.length == 0) {
if(vo.getParentVO().getFbillstatus()!=-1){
BillCardOperator operator = new BillCardOperator(pageid);
BillCard billCard = operator.toCard(vo);
if(billCard.getBody()==null){
continue;
}
Set<String> codeSet = new HashSet<>();
for (PickmItemVO itemVO : itemVOS) {
String cpickmbid = itemVO.getCpickm_bid();
String countSql = "SELECT h.vbillcode" +
" FROM ic_generalin_b b" +
" LEFT JOIN ic_generalin_h h ON b.cgeneralhid = h.cgeneralhid" +
" WHERE b.dr = 0" +
" AND b.csourcebillbid = '" + cpickmbid + "'";
String vbillcode = (String) new BaseDAO().executeQuery(countSql, new ColumnProcessor());
if (StringUtils.isNotEmpty(vbillcode) &&
!"~".equals(vbillcode) && !"null".equals(vbillcode)) {
codeSet.add(vbillcode);
} else {
bids.add(itemVO);
}
}
if (!MMValueCheck.isEmpty(codeSet)) {
String codeStr = String.join(",", codeSet);
ExceptionUtils.wrapBusinessException("存在有关联的其它入库,单号:" + codeStr);
}
// 备料计划主表
pickmHeadMap.put(headVO.getCpickmid(), headVO);
}
}
if (MMValueCheck.isEmpty(bids)) {
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("data", null);
returnMap.put("success", false);
return returnMap;
}
GridOperator operator = new GridOperator(pageid);
if (MMValueCheck.isNotEmpty(appcode)) {
String templetid = NCCTempletQueryAction.getTempletIdByAppCode(appcode, pageid);
operator = new GridOperator(templetid, pageid);
}
Grid grid = operator.toGrid(bids.toArray(new PickmItemVO[0]));
Row[] rows = grid.getModel().getRows();
List<Row> rows = List.of(billCard.getBody().getModel().getRows());
for (Row row : rows) {
Map<String, Cell> rowValues = row.getValues();
String cpickmid = (String) rowValues.get("cpickmid").getValue();
PickmHeadVO hvo = pickmHeadMap.get(cpickmid);
UFDouble nplanoutastnum = (UFDouble) rowValues.get("nplanoutastnum").getValue();
UFDouble naccoutastnum = rowValues.get("naccoutastnum").getValue() != null ? (UFDouble) rowValues.get("naccoutastnum").getValue() : UFDouble.ZERO_DBL;
UFDouble nshouldastnum = rowValues.get("nshouldastnum").getValue() != null ? (UFDouble) rowValues.get("nshouldastnum").getValue() : UFDouble.ZERO_DBL;
UFDouble npscastnum = rowValues.get("npscastnum").getValue() != null ? (UFDouble) rowValues.get("npscastnum").getValue() : UFDouble.ZERO_DBL;
UFDouble nplanoutastnum = (UFDouble) row.getValues().get("nplanoutastnum").getValue();
UFDouble naccoutastnum = (UFDouble) row.getValues().get("naccoutastnum").getValue()!=null? (UFDouble)row.getValues().get("naccoutastnum").getValue():UFDouble.ZERO_DBL;
UFDouble nshouldastnum = (UFDouble) row.getValues().get("nshouldastnum").getValue()!=null? (UFDouble)row.getValues().get("nshouldastnum").getValue():UFDouble.ZERO_DBL;
UFDouble npscastnum = (UFDouble) row.getValues().get("npscastnum").getValue()!=null? (UFDouble)row.getValues().get("npscastnum").getValue():UFDouble.ZERO_DBL;
UFDouble borrowedQty = nplanoutastnum.sub(naccoutastnum).sub(nshouldastnum).sub(npscastnum);
// 新增备料数量字段取值为计划出库数量-累计出库数量-累计发货数量-累计委外数量
if (borrowedQty.doubleValue() <= 0) {
continue;
}
// 新增借料数量字段
Cell<UFDouble> borrowedQtyCell = new Cell<>();
Cell borrowedQtyCell = new Cell();
borrowedQtyCell.setValue(borrowedQty);
rowValues.put("borrowedQty", borrowedQtyCell);
if (hvo != null) {
// 产品编码
String cmaterialvid = hvo.getCmaterialvid();
Cell<String> cmaterialvidCell = new Cell<>();
cmaterialvidCell.setValue(cmaterialvid);
if (cmaterialvid != null && !cmaterialvid.isEmpty()) {
Map<String, Object> materialMap = getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,def26",
MaterialVO.PK_MATERIAL + " = '" + cmaterialvid + "' ");
if (materialMap != null) {
cmaterialvidCell.setValue(cmaterialvid);
cmaterialvidCell.setDisplay((materialMap.getOrDefault(MaterialVO.CODE, "") + ""));
rowValues.put("cmaterialvid", cmaterialvidCell);
// 物料名称
Cell<String> materialCell = new Cell<>();
materialCell.setDisplay(materialMap.getOrDefault(MaterialVO.NAME, "") + "");
materialCell.setValue(materialMap.getOrDefault(MaterialVO.NAME, ""));
rowValues.put("cmaterialvid.name", materialCell);
row.getValues().put("borrowedQty", borrowedQtyCell);
// 产品编码 取备料计划表头产品编码
Cell cmaterialvid = new Cell();
cmaterialvid.setValue(vo.getParentVO().getCmaterialvid());
row.getValues().put("cmaterialvid", borrowedQtyCell);
// 产品名称 取备料计划表头产品名称
Cell cmaterialvidName = new Cell();
HYPubBO hybo = new HYPubBO();
Object cmaterialvidName1 = hybo.findColValue("bd_material", "name", "pk_material = '"+vo.getParentVO().getCmaterialvid()+"' ");
cmaterialvidName.setValue(cmaterialvidName1);
row.getValues().put("cmaterialvidName", cmaterialvidName);
// 生产序号 取备料计划表头物料档案对应表头自定义项26
materialCell = new Cell<>();
Object def26 = "";
if (materialMap.getOrDefault(MaterialVO.DEF26, "") != null) {
def26 = materialMap.getOrDefault(MaterialVO.DEF26, "");
}
materialCell.setDisplay(def26 + "");
materialCell.setValue(def26);
rowValues.put("cmaterialvid.def26", materialCell);
}
}
Cell cmaterialvidDef26 = new Cell();
Object cmaterialvidDef261 = hybo.findColValue("bd_material", "def26", "pk_material = '"+vo.getParentVO().getCmaterialvid()+"' ");
cmaterialvidDef26.setValue(cmaterialvidDef261);
row.getValues().put("cmaterialvidDef26", cmaterialvidDef26);
list.add(row);
// 备料计划单号 取备料计划表头
Cell vbillcode = new Cell();
vbillcode.setValue(hvo.getVbillcode());
vbillcode.setDisplay(hvo.getVbillcode());
rowValues.put("vbillcode", vbillcode);
vbillcode.setValue(vo.getParentVO().getVbillcode());
row.getValues().put("vbillcode", vbillcode);
list.add(row);
// 来源计划单号 取备料计划表头
Cell vsourcebillcode = new Cell();
vsourcebillcode.setValue(hvo.getVsourcebillcode());
vsourcebillcode.setDisplay(hvo.getVsourcebillcode());
rowValues.put("vsourcebillcode", vsourcebillcode);
vsourcebillcode.setValue(vo.getParentVO().getVsourcebillcode());
row.getValues().put("vsourcebillcode", vsourcebillcode);
list.add(row);
}
}
// bodyList.add(billCard.getBody());
}
}
Grid grid = new Grid();
GridModel model = new GridModel();
model.add(list);
grid.setModel(model);
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("data", grid);
Map<String, Object> list1 = new HashMap<>();
list1.put("rows",list);
returnMap.put("data", list1);
returnMap.put("success", true);
return returnMap;
} catch (Exception ex) {
@ -169,16 +117,4 @@ public class PickmByIdsQueryAction implements ICommonAction {
return returnMap;
}
}
public Map<String, Object> getMapValByCondition(String tableName, String fieldName, String condition) throws BusinessException {
String sql = " SELECT " + fieldName + " FROM " + tableName + " " +
" WHERE nvl(" + tableName + " .dr,0)= 0 " +
" and " + condition + " ";
Map<String, Object> result = (Map<String, Object>) new BaseDAO().executeQuery(sql, new MapProcessor());
if (result == null || result.isEmpty()) {
result = new HashMap<>();
}
return result;
}
}

View File

@ -1,29 +1,15 @@
package nccloud.web.mmpac.pickm.query;
import nc.bs.dao.BaseDAO;
import nc.itf.mmpac.pickm.IPickmQueryService;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.vo.bd.material.MaterialVO;
import nc.vo.mmpac.pickm.consts.PickmLangConsts;
import nc.vo.mmpac.pickm.entity.PickmHeadVO;
import nc.vo.mmpac.pickm.entity.PickmItemVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import nccloud.commons.lang.StringUtils;
import nccloud.dto.mmpac.pickm.pub.entity.PickmQueryInfoDTO;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory;
import nccloud.framework.web.ui.model.row.Cell;
import nccloud.framework.web.ui.model.row.Row;
import nccloud.framework.web.ui.pattern.grid.Grid;
import nccloud.framework.web.ui.pattern.grid.GridOperator;
import nccloud.web.mmpub.pub.action.NCCTempletQueryAction;
import java.util.*;
@ -63,106 +49,9 @@ public class PickmItemsQuery implements ICommonAction {
String codeStr = String.join(",", codeSet);
ExceptionUtils.wrapBusinessException("存在有关联的其它入库,单号:" + codeStr);
}
IPickmQueryService service = ServiceLocator.find(IPickmQueryService.class);
PickmItemVO[] itemVOS = service.queryItemsByIds(bids.toArray(new String[0]));
if (MMValueCheck.isEmpty(itemVOS)) {
ExceptionUtils.wrapBusinessException(PickmLangConsts.getHIT_BODYNOTNULL());
}
GridOperator operator = new GridOperator(queryInfo.getPageid());
if (MMValueCheck.isNotEmpty(queryInfo.getAppcode())) {
String templetid = NCCTempletQueryAction.getTempletIdByAppCode(queryInfo.getAppcode(), queryInfo.getPageid());
operator = new GridOperator(templetid, queryInfo.getPageid());
}
// HYPubBO hybo = new HYPubBO();
Grid grid = operator.toGrid(itemVOS);
Row[] rows = grid.getModel().getRows();
// 收集所有唯一的cpickmid
Set<String> pickmIdSet = new HashSet<>();
for (Row row : rows) {
Map<String, Cell> rowValues = row.getValues();
String cpickmid = (String) rowValues.get("cpickmid").getValue();
if (cpickmid != null && !cpickmid.isEmpty()) {
pickmIdSet.add(cpickmid);
}
}
// 批量查询所有需要的PickmHeadVO
Map<String, PickmHeadVO> pickmHeadMap = new HashMap<>();
if (!pickmIdSet.isEmpty()) {
String[] pickmIds = pickmIdSet.toArray(new String[0]);
PickmHeadVO[] headVOs = service.queryHeadByIds(pickmIds);
if (headVOs != null) {
for (PickmHeadVO headVO : headVOs) {
if (headVO != null && headVO.getCpickmid() != null) {
pickmHeadMap.put(headVO.getCpickmid(), headVO);
}
}
}
}
for (Row row : rows) {
Map<String, Cell> rowValues = row.getValues();
String cpickmid = (String) rowValues.get("cpickmid").getValue();
PickmHeadVO hvo = pickmHeadMap.get(cpickmid);
UFDouble nplanoutastnum = (UFDouble) rowValues.get("nplanoutastnum").getValue();
UFDouble naccoutastnum = rowValues.get("naccoutastnum").getValue() != null ? (UFDouble) rowValues.get("naccoutastnum").getValue() : UFDouble.ZERO_DBL;
UFDouble nshouldastnum = rowValues.get("nshouldastnum").getValue() != null ? (UFDouble) rowValues.get("nshouldastnum").getValue() : UFDouble.ZERO_DBL;
UFDouble npscastnum = rowValues.get("npscastnum").getValue() != null ? (UFDouble) rowValues.get("npscastnum").getValue() : UFDouble.ZERO_DBL;
UFDouble borrowedQty = nplanoutastnum.sub(naccoutastnum).sub(nshouldastnum).sub(npscastnum);
// 新增备料数量字段取值为计划出库数量-累计出库数量-累计发货数量-累计委外数量
if (borrowedQty.doubleValue() <= 0) {
continue;
}
// 新增借料数量字段
Cell<UFDouble> borrowedQtyCell = new Cell<>();
borrowedQtyCell.setValue(borrowedQty);
rowValues.put("borrowedQty", borrowedQtyCell);
if (hvo != null) {
// 产品编码
String cmaterialvid = hvo.getCmaterialvid();
Cell<String> cmaterialvidCell = new Cell<>();
cmaterialvidCell.setValue(cmaterialvid);
if (cmaterialvid != null && !cmaterialvid.isEmpty()) {
Map<String, Object> materialMap = getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,def26",
MaterialVO.PK_MATERIAL + " = '" + cmaterialvid + "' ");
if (materialMap != null) {
cmaterialvidCell.setValue(cmaterialvid);
cmaterialvidCell.setDisplay((materialMap.getOrDefault(MaterialVO.CODE, "") + ""));
rowValues.put("cmaterialvid", cmaterialvidCell);
// 物料名称
Cell<String> materialCell = new Cell<>();
materialCell.setDisplay(materialMap.getOrDefault(MaterialVO.NAME, "") + "");
materialCell.setValue(materialMap.getOrDefault(MaterialVO.NAME, ""));
rowValues.put("cmaterialvid.name", materialCell);
// 生产序号 取备料计划表头物料档案对应表头自定义项26
materialCell = new Cell<>();
Object def26 = "";
if (materialMap.getOrDefault(MaterialVO.DEF26, "") != null) {
def26 = materialMap.getOrDefault(MaterialVO.DEF26, "");
}
materialCell.setDisplay(def26 + "");
materialCell.setValue(def26);
rowValues.put("cmaterialvid.def26", materialCell);
}
}
// 备料计划单号 取备料计划表头
Cell vbillcode = new Cell();
vbillcode.setValue(hvo.getVbillcode());
vbillcode.setDisplay(hvo.getVbillcode());
rowValues.put("vbillcode", vbillcode);
// 来源计划单号 取备料计划表头
Cell vsourcebillcode = new Cell();
vsourcebillcode.setValue(hvo.getVsourcebillcode());
vsourcebillcode.setDisplay(hvo.getVsourcebillcode());
rowValues.put("vsourcebillcode", vsourcebillcode);
}
}
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("data", grid);
returnMap.put("data", bids);
returnMap.put("success", true);
return returnMap;
} else {
@ -179,15 +68,4 @@ public class PickmItemsQuery implements ICommonAction {
return returnMap;
}
}
public Map<String, Object> getMapValByCondition(String tableName, String fieldName, String condition) throws BusinessException {
String sql = " SELECT " + fieldName + " FROM " + tableName + " " +
" WHERE nvl(" + tableName + " .dr,0)= 0 " +
" and " + condition + " ";
Map<String, Object> result = (Map<String, Object>) new BaseDAO().executeQuery(sql, new MapProcessor());
if (result == null || result.isEmpty()) {
result = new HashMap<>();
}
return result;
}
}

View File

@ -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();
}
}

View File

@ -1,6 +1,5 @@
package nc.bs.mmpac.pmo.pac0002.bp;
import nc.bs.mmpac.pickm.bp.rule.AfterApproveRuleHighpressureIms;
import nc.bs.mmpac.pmo.pac0002.bp.rule.*;
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
import nc.bs.mmpac.pmo.pac0002.rule.*;
@ -54,9 +53,9 @@ public class PMOApproveBP {
processer.addAfterRule(new AfterApprovingSynchronizeRuleRZ(true));
// 审批后推送流程生产订单到MES
processer.addAfterRule(new AfterApproveRuleSyncMes());
// 审批后推送流程生产订单到艾普MES
// 审批后推送流程生产订单到艾普MES-电力电子
processer.addAfterRule(new AfterApproveSyncEpicMesRule());
// 审批后推送流程生产订单到启源qms
// 审批后推送流程生产订单到启源qms-箱变
processer.addAfterRule(new AfterApproveSyncQMSRule());
// 流程生产订单审批后推送高压MES
processer.addAfterRule(new AfterApproveSyncHighpressureMesRule());

View File

@ -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();
}
}