diff --git a/pu/src/client/nccloud/web/pu/arrival/action/QCAction.java b/pu/src/client/nccloud/web/pu/arrival/action/QCAction.java index 02e86d73..ae50531b 100644 --- a/pu/src/client/nccloud/web/pu/arrival/action/QCAction.java +++ b/pu/src/client/nccloud/web/pu/arrival/action/QCAction.java @@ -5,17 +5,40 @@ package nccloud.web.pu.arrival.action; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import nc.bs.dao.BaseDAO; +import nc.bs.dao.DAOException; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Log; +import nc.bs.trade.business.HYPubBO; import nc.bs.uapbd.util.MyHelper; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoQryService; import nc.pubitf.pu.m23.pubquery.IArrivePubQuery; +import nc.vo.am.common.util.StringUtils; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.measdoc.MeasdocVO; +import nc.vo.bd.psn.PsndocVO; +import nc.vo.bd.supplier.SupplierVersionVO; import nc.vo.ml.NCLangRes4VoTransl; import nc.vo.org.OrgVO; +import nc.vo.pu.m23.entity.ArriveHeaderVO; import nc.vo.pu.m23.entity.ArriveItemVO; import nc.vo.pu.m23.entity.ArriveVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDateTime; +import nc.vo.qc.c003.entity.ReportHeaderVO; +import nc.vo.qc.c003.entity.ReportItemVO; +import nc.vo.sm.UserVO; +import nccloud.baseapp.core.log.NCCForUAPLogger; import nccloud.dto.pu.arrival.entity.ExeInfo; import nccloud.dto.pu.arrival.entity.PkTsParamsVO; import nccloud.framework.core.exception.ExceptionUtils; @@ -30,6 +53,10 @@ import nccloud.pubitf.pu.arrival.service.IArrivalExeService; import nccloud.web.pu.arrival.utis.ArrivalScalaSetter; public class QCAction implements ICommonAction { + private static final String LOG_INFO_NAME = "qyMesLog"; + private static final Log logger = Log.getInstance(LOG_INFO_NAME); + private static final String reqUrl = "/IF_QyErpApi.ashx?action=addsjd"; + private Map configParams; public QCAction() { } @@ -49,14 +76,25 @@ public class QCAction implements ICommonAction { if (idTsMap.size() > 0) { IArrivePubQuery query = (IArrivePubQuery)ServiceLocator.find(IArrivePubQuery.class); ArriveVO[] vos = query.queryAggVOByBids((String[])idTsMap.keySet().toArray(new String[idTsMap.keySet().size()])); - Map configParams = MyHelper.getConfigParams("xb-config", null); + configParams = MyHelper.getConfigParams("xb-config", null); if (configParams.isEmpty()) { throw new BusinessException("箱变的QMS接口缺少配置"); } + String rown = ""; + for (ArriveItemVO item : vos[0].getBVO()) { + if (item.getVbdef50()==null || "N".equals(item.getVbdef50())) { + rown=rown+item.getCrowno() +";"; + } + + } + // if(rown.length()>0) { + // nccloud.base.exception.ExceptionUtils.wrapBusinessException("检验的到货单明细行不允许有免检的明细行:"+rown); + // + // } for (ArriveVO vo : vos) { String pkOrg = vo.getHVO().getPk_org(); String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); - if (!checkIfOrg(orgCode, configParams)) { + if (!checkIfOrg1(orgCode, configParams)) { ArriveVO allVo = query.queryAggVOByHid(vo.getPrimaryKey()); if(allVo.getBVO().length != vo.getBVO().length){ throw new BusinessException("箱变的到货单校验必须全体校验!"); @@ -71,6 +109,33 @@ public class QCAction implements ICommonAction { IArrivalExeService service = (IArrivalExeService)ServiceLocator.find(IArrivalExeService.class); ArriveVO[] retVOs = service.qualityCheck(vos); + List validArriveList = new ArrayList<>(); + configParams = MyHelper.getConfigParams("xb-config", null); + if (configParams.isEmpty()) { + throw new BusinessException("箱变的QMS接口缺少配置"); + } + for (ArriveVO arriveVO : retVOs) { + ArriveItemVO[] bvos = arriveVO.getBVO(); + boolean needSkip = false; // 标记是否需要跳过当前ArriveVO + + // 检查当前到货单的所有明细,只要有一个明细的vbdef23为Y/y,就跳过整个到货单 + if (bvos != null && bvos.length > 0) { + for (ArriveItemVO itemVO : bvos) { + // 获取vbdef23字段值,处理null情况 + String vbdef32 = (String) itemVO.getAttributeValue("vbdef32"); + if (vbdef32 != null && "Y".equalsIgnoreCase(vbdef32)) { + needSkip = true; + break; // 只要有一个明细符合,直接跳出明细循环 + } + } + } + + // 不需要跳过的,加入有效列表 + if (!needSkip) { + validArriveList.add(arriveVO); + } + } + buildSyncData(retVOs); BillCardOperator operator = new BillCardOperator(info.getPageid()); card = operator.toCard(retVOs[0]); if (card != null) { @@ -89,7 +154,7 @@ public class QCAction implements ICommonAction { return null; } - private boolean checkIfOrg(String code, Map configParams) throws BusinessException { + private boolean checkIfOrg1(String code, Map configParams) throws BusinessException { String targetCode = configParams.get("xbOrg"); if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) { throw new BusinessException("未配置组织参数"); @@ -102,4 +167,175 @@ public class QCAction implements ICommonAction { } return true; } + + + + + /** + * 构建同步数据 + * + * @param arriveVOS 到货单VO + */ + private void buildSyncData(ArriveVO[] arriveVOS) throws BusinessException { + List update =new ArrayList<>(); + for (ArriveVO arriveVO : arriveVOS) { + ArriveHeaderVO hvo = arriveVO.getHVO(); + ArriveItemVO[] bvo = arriveVO.getBVO(); + String pk_arriveorder = hvo.getPk_arriveorder(); + String pkOrg = hvo.getPk_org(); + // 判断物料的业务单元是否是箱变公司,不是则跳过 + String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if (checkIfOrg(orgCode, configParams)) { + continue; + } + // 查询供应商信息 + String pk_supplier_v = hvo.getPk_supplier_v(); + SupplierVersionVO supplierVersionVO = new SupplierVersionVO(); + if (pk_supplier_v != null && !pk_supplier_v.isEmpty() && !"~".equals(pk_supplier_v)) { + ISupplierBaseInfoQryService baseQryService = NCLocator.getInstance().lookup(ISupplierBaseInfoQryService.class); + supplierVersionVO = baseQryService.querySupplierVersionByVID(pk_supplier_v); + } + // 制单人名称 + String creatorName = MyHelper.getStrValByCondition("sm_user", UserVO.USER_NAME, + UserVO.CUSERID + " = '" + hvo.getBillmaker() + "'"); + JSONObject singleObj = new JSONObject(); + // 采购合同号 + String cghth = getCghthVal(hvo, bvo); + // 启源送检单主表 + long cts = System.currentTimeMillis(); + singleObj.put("batchid", cts); + singleObj.put("csdh", hvo.getVbillcode());// 送检单号,BIP到货单号 + singleObj.put("sjrq", hvo.getDmakedate().toString());// 送检日期,格式建议为 yyyy-MM-dd + singleObj.put("wlgysid", supplierVersionVO.getCode());// 供应商编码 + singleObj.put("wlgysmc", supplierVersionVO.getName());// 供应商名称 + singleObj.put("sjr", creatorName);// 送检人,BIP制单人 + singleObj.put("cghth", cghth);// 采购合同号,关联对应的采购合同 + singleObj.put("bz", hvo.getVmemo());// 摘要备注,用于填写送检单的补充说明信息 + // 查询关联的质检报告-传入启源送检单的明细 + HYPubBO hybo = new HYPubBO(); + ReportItemVO[] reportItemVOS = (ReportItemVO[]) hybo.queryByCondition(ReportItemVO.class, " cfirstid = '" + pk_arriveorder + "'"); + JSONArray contentArray = new JSONArray(); + for (ReportItemVO reportItemVO : reportItemVOS) { + String pkReportbill = reportItemVO.getPk_reportbill(); + ReportHeaderVO reportHeaderVO = (ReportHeaderVO) hybo.queryByPrimaryKey(ReportHeaderVO.class, pkReportbill); + String pkMaterial = reportHeaderVO.getPk_material(); + Map materialMap = MyHelper.getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,materialspec,materialtype", + "pk_material = '" + pkMaterial + "'"); + String cunitid = reportHeaderVO.getCunitid();// 主单位 + String cunitname = MyHelper.getStrValByCondition(MeasdocVO.getDefaultTableName(), MeasdocVO.NAME, + MeasdocVO.PK_MEASDOC + " = '" + cunitid + "'"); + JSONObject itemObj = new JSONObject(); + itemObj.put("wlbh", materialMap.getOrDefault("code", "")); // 物料编码 + itemObj.put("wlmc", materialMap.getOrDefault("name", "")); // 物料名称 + String materialtype = skipNull(materialMap.get("materialtype")); + String materialspec = skipNull(materialMap.get("materialspec")); + itemObj.put("wlxhgg", materialtype + materialspec); // 物料型号规格 + itemObj.put("sjsl", reportHeaderVO.getNapplynum().toString()); // 送检数量(设计单位),按设计计量单位统计的送检数量 + itemObj.put("jldw", cunitname); // 计量单位 + itemObj.put("bz", getBz(bvo,reportItemVO.getCfirstbid())); // 明细备注,用于填写该送检物料的补充说明 + itemObj.put("bipzyid", pkReportbill); // 质检报告ID + itemObj.put("bipqdid", reportItemVO.getPk_reportbill_b()); // 质检报告明细ID + contentArray.add(itemObj); + } + singleObj.put("Content", contentArray); + pushData(singleObj); + update.add(hvo.getPk_arriveorder()); + updateArrveOrder(hvo.getPk_arriveorder()); + } + + } + private Object getBz(ArriveItemVO[] bvo, String cfirstbid) { + for (ArriveItemVO arriveItemVO : bvo) { + if(arriveItemVO.getPk_arriveorder_b().equals(cfirstbid)) { + return arriveItemVO.getVmemob(); + } + } + return null; + } + + private void updateArrveOrder(String pkArriveorder) throws DAOException { + BaseDAO dao = new BaseDAO(); + String sql = "update po_arriveorder_b set vbdef32='Y' where pk_arriveorder='" + + pkArriveorder + "'"; + dao.executeUpdate(sql); + } + + private String getCghthVal(ArriveHeaderVO hvo, ArriveItemVO[] bvo) throws BusinessException { + String cghth = ""; + String pkPupsndoc = hvo.getPk_pupsndoc(); + // 查询采购员名称 + String name = ""; + if (pkPupsndoc != null && !pkPupsndoc.isEmpty() && !"~".equals(pkPupsndoc)) { + name = MyHelper.getStrValByCondition(PsndocVO.getDefaultTableName(), PsndocVO.NAME, + PsndocVO.PK_PSNDOC + " = '" + pkPupsndoc + "'"); + } + if (bvo != null && bvo.length > 0) { + StringBuilder cghthBuilder = new StringBuilder(); + for (int i = 0; i < bvo.length; i++) { + String vsourcecode = bvo[i].getVsourcecode(); + if (vsourcecode == null || vsourcecode.isEmpty() || "~".equals(vsourcecode)) { + continue; + } + if (i > 0) { + cghthBuilder.append(","); + } + cghthBuilder.append(vsourcecode); + if (!name.isEmpty()) { + cghthBuilder.append(name); + } + } + cghth = cghthBuilder.toString(); + } + return cghth; + } + + /** + * 推送同步数据 + */ + private void pushData(JSONObject param) throws BusinessException { + // String jsonString = param.toJSONString(); + // 转json字符串的时候保留null值 + String jsonStr = JSON.toJSONString(param, + SerializerFeature.WriteMapNullValue, + SerializerFeature.WriteNullStringAsEmpty + ); + logger.error("QMS-QC-param = " + jsonStr); + NCCForUAPLogger.debug("QMS-QC-param = " + jsonStr); + String baseUrl = configParams.get("qmsBaseUrl"); + String requestUrl = baseUrl + reqUrl; + logger.error("QMS-QC-url = " + requestUrl); + String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr); + NCCForUAPLogger.debug("QMS-QC-result = " + result); + JSONObject resultObj = JSONObject.parseObject(result); + logger.error("QMS-QC-res = " + result); + + if (!"true".equals(resultObj.getString("success"))) { + logger.error("QMS-QC-error,result[" + resultObj.toJSONString() + "]"); + throw new BusinessException("QMS-QC-error:" + resultObj.getString("message")); + } + } + + private boolean checkIfOrg(String code, Map configParams) throws BusinessException { + String targetCode = configParams.get("xbqcOrg"); + if (targetCode == null || StringUtils.isEmpty(targetCode)) { + throw new BusinessException("未配置组织参数"); + } + if (targetCode.contains("qc-")) { + targetCode = targetCode.replace("qc-", ""); + } + String[] orgItem = targetCode.split(","); + for (String orgCode : orgItem) { + if (!orgCode.isEmpty() && orgCode.equals(code)) { + return false; + } + } + return true; + } + + public String skipNull(Object value) { + if ((value == null) || (value.toString().trim().length() == 0)) { + return ""; + } + return value.toString().trim(); + } } diff --git a/pu/src/client/nccloud/web/pu/arrival/action/QualityCheckAction.java b/pu/src/client/nccloud/web/pu/arrival/action/QualityCheckAction.java index b88bcd3d..ab0f5377 100644 --- a/pu/src/client/nccloud/web/pu/arrival/action/QualityCheckAction.java +++ b/pu/src/client/nccloud/web/pu/arrival/action/QualityCheckAction.java @@ -1,17 +1,40 @@ package nccloud.web.pu.arrival.action; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import nc.bs.dao.BaseDAO; +import nc.bs.dao.DAOException; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Log; +import nc.bs.trade.business.HYPubBO; +import nc.bs.uapbd.util.MyHelper; +import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; +import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoQryService; import nc.itf.pu.m23.qc.IArriveForQC; import nc.pubitf.pu.m23.pubquery.IArrivePubQuery; import nc.pubitf.qc.c001.pu.ReturnObjectFor23; +import nc.vo.am.common.util.StringUtils; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.measdoc.MeasdocVO; +import nc.vo.bd.psn.PsndocVO; +import nc.vo.bd.supplier.SupplierVersionVO; +import nc.vo.org.OrgVO; import nc.vo.pu.m23.entity.ArriveHeaderVO; import nc.vo.pu.m23.entity.ArriveItemVO; import nc.vo.pu.m23.entity.ArriveVO; import nc.vo.pu.m23.entity.ArriveViewVO; import nc.vo.pu.pub.util.AggVOUtil; +import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDouble; import nc.vo.pubapp.pattern.model.entity.view.AbstractDataView; import nc.vo.pubapp.pattern.model.tool.BillComposite; +import nc.vo.qc.c003.entity.ReportHeaderVO; +import nc.vo.qc.c003.entity.ReportItemVO; import nc.vo.qc.pub.enumeration.StrictLevelEnum; +import nc.vo.sm.UserVO; +import nccloud.baseapp.core.log.NCCForUAPLogger; import nccloud.commons.lang.ArrayUtils; import nccloud.dto.pu.puinvoice.entity.DataInfo; import nccloud.framework.core.exception.ExceptionUtils; @@ -39,7 +62,10 @@ import java.util.Set; * @version ncc1.0 */ public class QualityCheckAction implements ICommonAction { - + private static final String LOG_INFO_NAME = "qyMesLog"; + private static final Log logger = Log.getInstance(LOG_INFO_NAME); + private static final String reqUrl = "/IF_QyErpApi.ashx?action=addsjd"; + private Map configParams; @Override public Object doAction(IRequest request) { try { @@ -119,6 +145,34 @@ public class QualityCheckAction implements ICommonAction { nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4004100_0", "04004100-0011")/* @res "到货单检验失败!" */); } + List validArriveList = new ArrayList<>(); + + configParams = MyHelper.getConfigParams("xb-config", null); + if (configParams.isEmpty()) { + throw new BusinessException("箱变的QMS接口缺少配置"); + } + for (ArriveVO arriveVO : returnVos) { + ArriveItemVO[] bvos = arriveVO.getBVO(); + boolean needSkip = false; // 标记是否需要跳过当前ArriveVO + + // 检查当前到货单的所有明细,只要有一个明细的vbdef23为Y/y,就跳过整个到货单 + if (bvos != null && bvos.length > 0) { + for (ArriveItemVO itemVO : bvos) { + // 获取vbdef23字段值,处理null情况 + String vbdef32 = (String) itemVO.getAttributeValue("vbdef32"); + if (vbdef32 != null && "Y".equalsIgnoreCase(vbdef32)) { + needSkip = true; + break; // 只要有一个明细符合,直接跳出明细循环 + } + } + } + + // 不需要跳过的,加入有效列表 + if (!needSkip) { + validArriveList.add(arriveVO); + } + } + buildSyncData(returnVos); ServiceLocator.find(IArriveForQC.class).pushWmsByArriveVOs(vos); // 把后台返回的轻量级聚合VO转换为视图VO // new ClientBillCombinServer().combine(vos, @@ -250,4 +304,174 @@ public class QualityCheckAction implements ICommonAction { return null; } + + + + /** + * 构建同步数据 + * + * @param arriveVOS 到货单VO + */ + private void buildSyncData(ArriveVO[] arriveVOS) throws BusinessException { + List update =new ArrayList<>(); + for (ArriveVO arriveVO : arriveVOS) { + ArriveHeaderVO hvo = arriveVO.getHVO(); + ArriveItemVO[] bvo = arriveVO.getBVO(); + String pk_arriveorder = hvo.getPk_arriveorder(); + String pkOrg = hvo.getPk_org(); + // 判断物料的业务单元是否是箱变公司,不是则跳过 + String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if (checkIfOrg(orgCode, configParams)) { + continue; + } + // 查询供应商信息 + String pk_supplier_v = hvo.getPk_supplier_v(); + SupplierVersionVO supplierVersionVO = new SupplierVersionVO(); + if (pk_supplier_v != null && !pk_supplier_v.isEmpty() && !"~".equals(pk_supplier_v)) { + ISupplierBaseInfoQryService baseQryService = NCLocator.getInstance().lookup(ISupplierBaseInfoQryService.class); + supplierVersionVO = baseQryService.querySupplierVersionByVID(pk_supplier_v); + } + // 制单人名称 + String creatorName = MyHelper.getStrValByCondition("sm_user", UserVO.USER_NAME, + UserVO.CUSERID + " = '" + hvo.getBillmaker() + "'"); + JSONObject singleObj = new JSONObject(); + // 采购合同号 + String cghth = getCghthVal(hvo, bvo); + // 启源送检单主表 + long cts = System.currentTimeMillis(); + singleObj.put("batchid", cts); + singleObj.put("csdh", hvo.getVbillcode());// 送检单号,BIP到货单号 + singleObj.put("sjrq", hvo.getDmakedate().toString());// 送检日期,格式建议为 yyyy-MM-dd + singleObj.put("wlgysid", supplierVersionVO.getCode());// 供应商编码 + singleObj.put("wlgysmc", supplierVersionVO.getName());// 供应商名称 + singleObj.put("sjr", creatorName);// 送检人,BIP制单人 + singleObj.put("cghth", cghth);// 采购合同号,关联对应的采购合同 + singleObj.put("bz", hvo.getVmemo());// 摘要备注,用于填写送检单的补充说明信息 + // 查询关联的质检报告-传入启源送检单的明细 + HYPubBO hybo = new HYPubBO(); + ReportItemVO[] reportItemVOS = (ReportItemVO[]) hybo.queryByCondition(ReportItemVO.class, " cfirstid = '" + pk_arriveorder + "'"); + JSONArray contentArray = new JSONArray(); + for (ReportItemVO reportItemVO : reportItemVOS) { + String pkReportbill = reportItemVO.getPk_reportbill(); + ReportHeaderVO reportHeaderVO = (ReportHeaderVO) hybo.queryByPrimaryKey(ReportHeaderVO.class, pkReportbill); + String pkMaterial = reportHeaderVO.getPk_material(); + Map materialMap = MyHelper.getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,materialspec,materialtype", + "pk_material = '" + pkMaterial + "'"); + String cunitid = reportHeaderVO.getCunitid();// 主单位 + String cunitname = MyHelper.getStrValByCondition(MeasdocVO.getDefaultTableName(), MeasdocVO.NAME, + MeasdocVO.PK_MEASDOC + " = '" + cunitid + "'"); + JSONObject itemObj = new JSONObject(); + itemObj.put("wlbh", materialMap.getOrDefault("code", "")); // 物料编码 + itemObj.put("wlmc", materialMap.getOrDefault("name", "")); // 物料名称 + String materialtype = skipNull(materialMap.get("materialtype")); + String materialspec = skipNull(materialMap.get("materialspec")); + itemObj.put("wlxhgg", materialtype + materialspec); // 物料型号规格 + itemObj.put("sjsl", reportHeaderVO.getNapplynum().toString()); // 送检数量(设计单位),按设计计量单位统计的送检数量 + itemObj.put("jldw", cunitname); // 计量单位 + itemObj.put("bz", getBz(bvo,reportItemVO.getCfirstbid())); // 明细备注,用于填写该送检物料的补充说明 + itemObj.put("bipzyid", pkReportbill); // 质检报告ID + itemObj.put("bipqdid", reportItemVO.getPk_reportbill_b()); // 质检报告明细ID + contentArray.add(itemObj); + } + singleObj.put("Content", contentArray); + pushData(singleObj); + update.add(hvo.getPk_arriveorder()); + updateArrveOrder(hvo.getPk_arriveorder()); + } + + } + private Object getBz(ArriveItemVO[] bvo, String cfirstbid) { + for (ArriveItemVO arriveItemVO : bvo) { + if(arriveItemVO.getPk_arriveorder_b().equals(cfirstbid)) { + return arriveItemVO.getVmemob(); + } + } + return null; + } + + private void updateArrveOrder(String pkArriveorder) throws DAOException { + BaseDAO dao = new BaseDAO(); + String sql = "update po_arriveorder_b set vbdef32='Y' where pk_arriveorder='" + + pkArriveorder + "'"; + dao.executeUpdate(sql); + } + + private String getCghthVal(ArriveHeaderVO hvo, ArriveItemVO[] bvo) throws BusinessException { + String cghth = ""; + String pkPupsndoc = hvo.getPk_pupsndoc(); + // 查询采购员名称 + String name = ""; + if (pkPupsndoc != null && !pkPupsndoc.isEmpty() && !"~".equals(pkPupsndoc)) { + name = MyHelper.getStrValByCondition(PsndocVO.getDefaultTableName(), PsndocVO.NAME, + PsndocVO.PK_PSNDOC + " = '" + pkPupsndoc + "'"); + } + if (bvo != null && bvo.length > 0) { + StringBuilder cghthBuilder = new StringBuilder(); + for (int i = 0; i < bvo.length; i++) { + String vsourcecode = bvo[i].getVsourcecode(); + if (vsourcecode == null || vsourcecode.isEmpty() || "~".equals(vsourcecode)) { + continue; + } + if (i > 0) { + cghthBuilder.append(","); + } + cghthBuilder.append(vsourcecode); + if (!name.isEmpty()) { + cghthBuilder.append(name); + } + } + cghth = cghthBuilder.toString(); + } + return cghth; + } + + /** + * 推送同步数据 + */ + private void pushData(JSONObject param) throws BusinessException { + // String jsonString = param.toJSONString(); + // 转json字符串的时候保留null值 + String jsonStr = JSON.toJSONString(param, + SerializerFeature.WriteMapNullValue, + SerializerFeature.WriteNullStringAsEmpty + ); + logger.error("QMS-QC-param = " + jsonStr); + NCCForUAPLogger.debug("QMS-QC-param = " + jsonStr); + String baseUrl = configParams.get("qmsBaseUrl"); + String requestUrl = baseUrl + reqUrl; + logger.error("QMS-QC-url = " + requestUrl); + // String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr); + // NCCForUAPLogger.debug("QMS-QC-result = " + result); + // JSONObject resultObj = JSONObject.parseObject(result); + // logger.error("QMS-QC-res = " + result); + // + // if (!"true".equals(resultObj.getString("success"))) { + // logger.error("QMS-QC-error,result[" + resultObj.toJSONString() + "]"); + // throw new BusinessException("QMS-QC-error:" + resultObj.getString("message")); + // } + } + + private boolean checkIfOrg(String code, Map configParams) throws BusinessException { + String targetCode = configParams.get("xbqcOrg"); + if (targetCode == null || StringUtils.isEmpty(targetCode)) { + throw new BusinessException("未配置组织参数"); + } + if (targetCode.contains("qc-")) { + targetCode = targetCode.replace("qc-", ""); + } + String[] orgItem = targetCode.split(","); + for (String orgCode : orgItem) { + if (!orgCode.isEmpty() && orgCode.equals(code)) { + return false; + } + } + return true; + } + + public String skipNull(Object value) { + if ((value == null) || (value.toString().trim().length() == 0)) { + return ""; + } + return value.toString().trim(); + } } \ No newline at end of file diff --git a/pu/src/client/nccloud/web/pu/arrivalqc/action/QualityCheckAction.java b/pu/src/client/nccloud/web/pu/arrivalqc/action/QualityCheckAction.java index f879791c..ee2bf0bc 100644 --- a/pu/src/client/nccloud/web/pu/arrivalqc/action/QualityCheckAction.java +++ b/pu/src/client/nccloud/web/pu/arrivalqc/action/QualityCheckAction.java @@ -82,7 +82,11 @@ public class QualityCheckAction implements ICommonAction { GridConvertProcessor processor = new GridConvertProcessor(); views = processor.fromGrid(info.getGrid()); } - + IArrivePubQuery query = (IArrivePubQuery)ServiceLocator.find(IArrivePubQuery.class); + configParams = MyHelper.getConfigParams("xb-config", null); + if (configParams.isEmpty()) { + throw new BusinessException("箱变的QMS接口缺少配置"); + } if (views != null && views.length > 0) { // IPubUtilService pubService = ServiceLocator // .find(IPubUtilService.class); @@ -97,6 +101,17 @@ public class QualityCheckAction implements ICommonAction { // } // } ArriveVO[] vos = this.getArriveVOs(views); + + for (ArriveVO vo : vos) { + String pkOrg = vo.getHVO().getPk_org(); + String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); + if (!checkIfOrg1(orgCode, configParams)) { + ArriveVO allVo = query.queryAggVOByHid(vo.getPrimaryKey()); + if(allVo.getBVO().length != vo.getBVO().length){ + throw new BusinessException("箱变的到货单校验必须全体校验!"); + } + } + } for (ArriveVO vo : vos) { ArriveItemVO[] bvos = vo.getBVO(); for (ArriveItemVO bvo : bvos) { @@ -147,10 +162,7 @@ public class QualityCheckAction implements ICommonAction { } List validArriveList = new ArrayList<>(); - configParams = MyHelper.getConfigParams("xb-config", null); - if (configParams.isEmpty()) { - throw new BusinessException("箱变的QMS接口缺少配置"); - } + for (ArriveVO arriveVO : returnVos) { ArriveItemVO[] bvos = arriveVO.getBVO(); boolean needSkip = false; // 标记是否需要跳过当前ArriveVO @@ -474,4 +486,18 @@ public class QualityCheckAction implements ICommonAction { } return value.toString().trim(); } + + private boolean checkIfOrg1(String code, Map configParams) throws BusinessException { + String targetCode = configParams.get("xbOrg"); + if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) { + throw new BusinessException("未配置组织参数"); + } + String[] orgItem = targetCode.split(","); + for (String orgCode : orgItem) { + if (!orgCode.isEmpty() && orgCode.equals(code)) { + return false; + } + } + return true; + } } \ No newline at end of file