diff --git a/qc/src/client/nccloud/web/qc/qcconclusion/action/QCRptDataPushtoQmsAction.java b/qc/src/client/nccloud/web/qc/qcconclusion/action/QCRptDataPushtoQmsAction.java new file mode 100644 index 00000000..79502026 --- /dev/null +++ b/qc/src/client/nccloud/web/qc/qcconclusion/action/QCRptDataPushtoQmsAction.java @@ -0,0 +1,347 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.web.qc.qcconclusion.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.impl.pubapp.pattern.data.bill.BillQuery; +import nc.itf.bd.supplier.baseinfo.ISupplierBaseInfoQryService; +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.qc.c003.entity.ReportHeaderVO; +import nc.vo.qc.c003.entity.ReportItemVO; +import nc.vo.qc.c003.entity.ReportVO; +import nc.vo.scmpub.res.billtype.QCBillType; +import nc.vo.scmpub.util.ArrayUtil; +import nc.vo.sm.UserVO; +import nccloud.base.exception.ExceptionUtils; +import nccloud.baseapp.core.log.NCCForUAPLogger; +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.pubitf.scmpub.pub.service.ISCMPubQueryService; +import nccloud.web.qc.pub.entity.BatchInfo; +import nccloud.web.scmpub.pub.action.DataPermissionAction; +import nccloud.web.scmpub.vocheck.VOSagaFrozenCheck; + +import java.util.*; + +public class QCRptDataPushtoQmsAction 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 QCRptDataPushtoQmsAction() { + } + + public Object doAction(IRequest request) { + String str = request.read(); + IJson json = JsonFactory.create(); + Map info = json.fromJson(str, Map.class); + + try { + String pks = (String) info.get("pks"); // 获取所有物料编码 + if (pks == null ) { + nccloud.framework.core.exception.ExceptionUtils.wrapBusinessException("采购到货单不能为空"); + } + String[] pk =new String[]{pks}; + // 上游到货单 + // 查询上游到货单数据 + BillQuery billquery = new BillQuery(ArriveVO.class); + ArriveVO[] arriveVOS = billquery.query(pk); + +// 过滤需要推送的ArriveVO(排除BVO中存在vbdef23为"Y"或"y"的记录) + List validArriveList = new ArrayList<>(); + for (ArriveVO arriveVO : arriveVOS) { + ArriveItemVO[] bvos = arriveVO.getBVO(); + boolean needSkip = false; // 标记是否需要跳过当前ArriveVO + + // 检查当前到货单的所有明细,只要有一个明细的vbdef23为Y/y,就跳过整个到货单 + if (bvos != null && bvos.length > 0) { + for (ArriveItemVO itemVO : bvos) { + // 获取vbdef23字段值,处理null情况 + String vbdef23 = (String) itemVO.getAttributeValue("vbdef23"); + if (vbdef23 != null && "Y".equalsIgnoreCase(vbdef23)) { + needSkip = true; + break; // 只要有一个明细符合,直接跳出明细循环 + } + } + } + + // 不需要跳过的,加入有效列表 + if (!needSkip) { + validArriveList.add(arriveVO); + } + } + buildSyncData(arriveVOS); + + } catch (BusinessException e) { + ExceptionUtils.wrapException(e); + } + + return "success"; + } + /** + * 构建同步数据 + * + * @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", reportItemVO.getVbdef1()); // 明细备注,用于填写该送检物料的补充说明 + 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 void updateArrveOrder(String pkArriveorder) throws DAOException { + BaseDAO dao = new BaseDAO(); + String sql = "update po_arriveorder_b set vbdef23='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 buildSyncData1(ReportVO[] useVOs) throws BusinessException { + for (ReportVO vo : useVOs) { + ReportHeaderVO hvo = vo.getHVO(); + ReportItemVO[] bvo = vo.getBVO(); + // 判断物料的业务单元是否是箱变公司,不是则跳过 + 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 pkApplyer = hvo.getPk_applyer(); + String applyerName = MyHelper.getStrValByCondition(PsndocVO.getDefaultTableName(), PsndocVO.NAME, + PsndocVO.PK_PSNDOC + " = '" + pkApplyer + "'"); + String bz = "", cghth = ""; + if (bvo != null && bvo.length > 0) { + bz = bvo[0].getVbdef1(); // BOM备注 + cghth = bvo[0].getVbdef2(); // 采购单号 + } + // 组装数据 + JSONObject singleObj = new JSONObject(); + long cts = System.currentTimeMillis(); + singleObj.put("batchid", cts); + singleObj.put("csdh", hvo.getVapplybillcode());// 送检单号,采购送检单的唯一标识编号 + singleObj.put("sjrq", hvo.getDapplydate().toString());// 送检日期,格式建议为 yyyy-MM-dd + singleObj.put("wlgysid", supplierVersionVO.getCode());// 供应商编码 + singleObj.put("wlgysmc", supplierVersionVO.getName());// 供应商名称 + singleObj.put("sjr", applyerName);// 送检人,负责提交送检单的人员姓名 + singleObj.put("cghth", cghth);// 采购合同号,关联对应的采购合同 + singleObj.put("bz", hvo.getVmemo());// 摘要备注,用于填写送检单的补充说明信息 + + String pkMaterial = hvo.getPk_material(); + Map materialMap = MyHelper.getMapValByCondition(MaterialVO.getDefaultTableName(), "code,name,materialspec,materialtype", + "pk_material = '" + pkMaterial + "'"); + String cunitid = hvo.getCunitid();// 主单位 + String cunitname = MyHelper.getStrValByCondition(MeasdocVO.getDefaultTableName(), MeasdocVO.NAME, + MeasdocVO.PK_MEASDOC + " = '" + cunitid + "'"); + // 处理Content数组 + JSONArray contentArray = new JSONArray(); + 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", hvo.getNapplynum().toString()); // 送检数量(设计单位),按设计计量单位统计的送检数量 + itemObj.put("jldw", cunitname); // 计量单位 + itemObj.put("bz", bz); // 明细备注,用于填写该送检物料的补充说明 + contentArray.add(itemObj); + + singleObj.put("Content", contentArray); +/* { + "batchid": "10002", + "csdh": "SJ202405001", + "sjrq": "2024-05-20", + "wlgysid": "GY001", + "wlgysmc": "XX 金属材料有限公司", + "sjr": "张三", + "cghth": "HT202405003", + "bz": "紧急送检,需优先检测", + "Content": [ + { + "wlbh": "ACC26711", + "wlmc": "铜排", + "wlxhgg": "15558190831", + "jldw": "米", + "sjsl": "50", + "bz": "无特殊要求" + } + ] + }*/ + pushData(singleObj); + } + } + + /** + * 推送同步数据 + */ + 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("xbOrg"); + if (targetCode == null || StringUtils.isEmpty(targetCode)) { + throw new BusinessException("未配置组织参数"); + } + 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/qc/src/client/yyconfig/modules/qc/qcconclusion/config/action/qcconclusion.xml b/qc/src/client/yyconfig/modules/qc/qcconclusion/config/action/qcconclusion.xml new file mode 100644 index 00000000..afd1298f --- /dev/null +++ b/qc/src/client/yyconfig/modules/qc/qcconclusion/config/action/qcconclusion.xml @@ -0,0 +1,183 @@ + + + + qc.qcconclusion.query + + nccloud.web.qc.qcconclusion.action.QueryAction + + + qc.qcconclusion.pagequery + + nccloud.web.qc.qcconclusion.action.PageQueryAction + + + qc.qcconclusion.querycard + + nccloud.web.qc.qcconclusion.action.QueryCardAction + + + qc.qcconclusion.queryapply + + nccloud.web.qc.qcconclusion.transfer.QueryApplayAction + + + qc.qcconclusion.transfer + + nccloud.web.qc.qcconclusion.transfer.TransApplyToReportAction + + + + qc.qcconclusion.save + + nccloud.web.qc.qcconclusion.action.SaveAction + + + qc.qcconclusion.delete + + nccloud.web.qc.qcconclusion.action.QCRptDeleteAction + Delete + + + qc.qcconclusion.commit + + nccloud.web.qc.qcconclusion.action.QCRptCommitAction + Commit + + + qc.qcconclusion.uncommit + + nccloud.web.qc.qcconclusion.action.QCRptUnCommitAction + UnCommit + + + qc.qcconclusion.createRejectbill + + nccloud.web.qc.qcconclusion.action.CreateRejectBillAction + + GenerateRejectGoodHandingForm + + + qc.qcconclusion.queryFakeCheckBill + + nccloud.web.qc.qcconclusion.action.QCRptQueryFakeCheckBills + + + + qc.qcconclusion.saveFakeCheckBill + + nccloud.web.qc.qcconclusion.action.QCRptFakeCheckBillSaveAction + + + + qc.qcconclusion.rechecEnableCheck + + nccloud.web.qc.qcconclusion.action.QCRptRecheckEnableCheckAction + + Reinspection + + + qc.qcconclusion.recheckInit + + nccloud.web.qc.qcconclusion.action.QCRptRecheckInitAction + + + + qc.qcconclusion.recheck + + nccloud.web.qc.qcconclusion.action.QCRptRecheckAction + Reinspection + + + qc.qcconclusion.checkHistory + + nccloud.web.qc.qcconclusion.action.QCRptQueryHistory + + + qc.qcconclusion.checkHistoryBody + + nccloud.web.qc.qcconclusion.action.QCRptQueryHistoryBodyAction + + + + qc.qcconclusion.print + + nccloud.web.qc.qcconclusion.action.QCRptPrintAction + + Print + + + qc.qcconclusion.qualityTrace + + nccloud.web.qc.qcconclusion.action.QCRptQualityTraceAction + + + + qc.qcconclusion.printcheckDataPermission + + nccloud.web.qc.qcconclusion.action.QCRptDataPermissionAction + + Print + + + qc.qcconclusion.editcheckDataPermission + + nccloud.web.qc.qcconclusion.action.QCRptDataPermissionAction + + Edit + + + qc.qcconclusion.maintainCheckInfoCheckDataPermission + + nccloud.web.qc.qcconclusion.action.QCRptDataPermissionAction + + MaintainInspectInfo + + + qc.qcconclusion.headBeforeEdit + + nccloud.web.qc.qcconclusion.event.QCRptHeadBeforeAction + + + + qc.qcconclusion.bodyBeforeEdit + + nccloud.web.qc.qcconclusion.event.QCRptBodyBeforeAction + + + + qc.qcconclusion.headAfterEdit + + nccloud.web.qc.qcconclusion.event.QCRptHeadAfterAction + + + + qc.qcconclusion.bodyAfterEdit + + nccloud.web.qc.qcconclusion.event.QCRptBodyAfterAction + + + + qc.qcconclusion.queryCheckInfo + + nccloud.web.qc.qcconclusion.transfer.QueryCheckInfoAction + + + + qc.qcconclusion.queryTransTypeExtInfo + + nccloud.web.qc.qcconclusion.transtype.QueryTransTypeExtInfo + + + + qc.qcconclusion.getServerTime + + nccloud.web.qc.qcconclusion.action.GetServerTimeAction + + + + qc.qcconclusion.pushtoQms + + nccloud.web.qc.qcconclusion.action.QCRptDataPushtoQmsAction + + + \ No newline at end of file diff --git a/qc/src/client/yyconfig/modules/qc/qcconclusion/config/authorize/qcconclusion_authorize.xml b/qc/src/client/yyconfig/modules/qc/qcconclusion/config/authorize/qcconclusion_authorize.xml new file mode 100644 index 00000000..b769834d --- /dev/null +++ b/qc/src/client/yyconfig/modules/qc/qcconclusion/config/authorize/qcconclusion_authorize.xml @@ -0,0 +1,55 @@ + + + + C01002000,C01002006 + + qc.qcconclusion.query + qc.qcconclusion.pagequery + qc.qcconclusion.querycard + qc.qcconclusion.queryapply + qc.qcconclusion.transfer + qc.qcconclusion.save + qc.qcconclusion.delete + qc.qcconclusion.commit + qc.qcconclusion.uncommit + qc.qcconclusion.createRejectbill + qc.qcconclusion.queryFakeCheckBill + qc.qcconclusion.saveFakeCheckBill + qc.qcconclusion.rechecEnableCheck + qc.qcconclusion.recheckInit + qc.qcconclusion.recheck + qc.qcconclusion.checkHistory + qc.qcconclusion.checkHistoryBody + qc.qcconclusion.print + qc.qcconclusion.headBeforeEdit + qc.qcconclusion.bodyBeforeEdit + qc.qcconclusion.headAfterEdit + qc.qcconclusion.bodyAfterEdit + qc.qcconclusion.qualityTrace + qc.qcconclusion.printcheckDataPermission + qc.qcconclusion.editcheckDataPermission + qc.qcconclusion.maintainCheckInfoCheckDataPermission + qc.qcconclusion.queryCheckInfo + qc.qcconclusion.getServerTime + qc.qcconclusion.pushtoQms + + + + 101613,C01002000,C01002006 + + qc.qcconclusion.queryTransTypeExtInfo + + + + C01002000,C01002006 + + qc.checkbill.bodyAfterEvent + + + + 400401200,400401204,400401206 + + qc.checkbill.pushtoQms + + + \ No newline at end of file