Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						734b0d7aac
					
				|  | @ -1,13 +1,21 @@ | |||
| package nccloud.api.impl.ic.m4d; | ||||
| 
 | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import nc.bs.dao.BaseDAO; | ||||
| import nc.bs.dao.DAOException; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.logging.Log; | ||||
| import nc.bs.scmpub.query.SCMBillQuery; | ||||
| import nc.itf.ic.m4d.IMaterialOutMaintain; | ||||
| import nc.itf.mmpac.pickm.IPickmQueryService; | ||||
| import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil; | ||||
| import nc.itf.uap.pf.busiflow.PfButtonClickContext; | ||||
| import nc.jdbc.framework.processor.ColumnListProcessor; | ||||
| import nc.pubimpl.ic.api.maintain.BillMaintainTool; | ||||
| import nc.pubitf.ic.m4d.api.IMaterialOutMaintainAPI; | ||||
| import nc.util.mmf.busi.service.PFPubService; | ||||
| import nc.util.mmf.framework.base.MMValueCheck; | ||||
| import nc.vo.ic.general.define.ICBillFlag; | ||||
| import nc.vo.ic.general.define.ICBillHeadVO; | ||||
| import nc.vo.ic.general.util.ICLocationUtil; | ||||
|  | @ -16,8 +24,12 @@ import nc.vo.ic.m4d.entity.MaterialOutBodyVO; | |||
| import nc.vo.ic.m4d.entity.MaterialOutHeadVO; | ||||
| import nc.vo.ic.m4d.entity.MaterialOutVO; | ||||
| import nc.vo.ic.pub.define.ICPubMetaNameConst; | ||||
| import nc.vo.mmpac.pickm.entity.AggPickmVO; | ||||
| import nc.vo.mmpac.pickm.entity.PickmItemVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.ISuperVO; | ||||
| import nc.vo.pub.VOStatus; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule; | ||||
| import nc.vo.scmpub.res.billtype.ICBillType; | ||||
| import nc.vo.scmpub.util.ArrayUtil; | ||||
|  | @ -27,6 +39,7 @@ import nccloud.api.impl.ic.m4d.fill.MaterialOutSaveFillValue; | |||
| import nccloud.api.impl.ic.m4d.fill.MaterialOutUpdateFillValue; | ||||
| import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields; | ||||
| import nccloud.api.uapbd.wms.utils.IWmsSyncUtils; | ||||
| import nccloud.baseapp.core.log.NCCForUAPLogger; | ||||
| import nccloud.openapi.ic.util.ICAPILocationVOUtils; | ||||
| import nccloud.openapi.scmpub.pub.TransferCodeToPKTool; | ||||
| import nccloud.openapi.scmpub.pub.TransferMapToVOTool; | ||||
|  | @ -43,8 +56,15 @@ import java.util.*; | |||
|  */ | ||||
| 
 | ||||
| public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain { | ||||
|     private BaseDAO baseDAO = null; | ||||
| 
 | ||||
|     private BaseDAO getDao() { | ||||
|         if (this.baseDAO == null) { | ||||
|             this.baseDAO = new BaseDAO(); | ||||
|         } | ||||
|         return this.baseDAO; | ||||
|     } | ||||
| 
 | ||||
|     //    private static final BaseDAO DAO = new BaseDAO(); | ||||
|     private static final Log log = Log.getInstance("wmslog"); | ||||
| //    private static final IHttpPostOtherSys HTTP_POST_OTHER_SYS = NCLocator.getInstance().lookup(IHttpPostOtherSys.class); | ||||
| 
 | ||||
|  | @ -71,7 +91,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain { | |||
| //        if (isSpecialCase) { | ||||
| //            processPickingPlanSpecialLogic(vos); | ||||
| //        } | ||||
|         //其他数据填充 | ||||
|         // 其他数据填充 | ||||
|         new MaterialOutSaveFillValue().setDefaultValue(vos); | ||||
| 
 | ||||
|         IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class); | ||||
|  | @ -103,7 +123,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain { | |||
| //        if (isSpecialCase) { | ||||
| //            processPickingPlanSpecialLogic(vos); | ||||
| //        } | ||||
|         //其他数据填充 | ||||
|         // 其他数据填充 | ||||
|         new MaterialOutSaveFillValue().setDefaultValue(vos); | ||||
| 
 | ||||
|         IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class); | ||||
|  | @ -227,7 +247,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain { | |||
|                         roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr)); | ||||
|                         bfields.add(battr); | ||||
|                     } | ||||
|                     //设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增 | ||||
|                     // 设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增 | ||||
|                     if (null != newBvo.getLocationVOs()) { | ||||
|                         List<ICLocationVO> allloc = new ArrayList<ICLocationVO>(); | ||||
|                         if (null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) { | ||||
|  | @ -244,7 +264,7 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain { | |||
|                     } | ||||
|                     // 翻译货位 | ||||
|                     ICAPILocationVOUtils.translate(materialOutVOs); | ||||
|                     //其他数据填充 | ||||
|                     // 其他数据填充 | ||||
|                     new MaterialOutUpdateFillValue().setDefaultValue(materialOutVOs, bfields); | ||||
|                 } | ||||
|             } | ||||
|  | @ -337,6 +357,95 @@ public class APIMaterialOutMaintainImpl implements IAPIMaterialOutMaintain { | |||
|         return materialOut.insertBills(vos); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public JSONObject destIssue(Map<String, Object> paramMap) throws BusinessException { | ||||
|         // 启源领料 | ||||
|         /* | ||||
|           1、传入数据基本非空校验 | ||||
|           2、根据传入的生产订单主键获取流程备料计划 | ||||
|           3、调用单据转换规则,备料计划VO转为材料出库VO | ||||
|           4、处理材料出库VO部分字段的赋值(行数量 = 本次领料套数(启源传入)*单位主用量(备料计划)) | ||||
|           5、调用材料出库的保存方法 | ||||
|          */ | ||||
|         List<String> mids; | ||||
|         try { | ||||
|             String sql = "SELECT cpickmid from mm_pickm WHERE dr = 0 AND fbillstatus = 1 AND csourcebillid = '[csourcebillid]'"; | ||||
|             sql = sql.replace("[csourcebillid]", paramMap.get("cpmohid").toString()); | ||||
|             mids = (List<String>) getDao().executeQuery(sql, new ColumnListProcessor()); | ||||
|         } catch (DAOException e) { | ||||
|             throw new BusinessException(e); | ||||
|         } | ||||
|         if (MMValueCheck.isEmpty(mids)) { | ||||
|             throw new BusinessException("没有关联审核通过的流程备料计划,无法领料!"); | ||||
|         } | ||||
|         String[] cpickmids = mids.toArray(new String[0]); | ||||
|         IPickmQueryService queryService = NCLocator.getInstance().lookup(IPickmQueryService.class); | ||||
|         AggPickmVO[] pickmVOS = queryService.queryBillsByPks(cpickmids); | ||||
|         if (MMValueCheck.isEmpty(pickmVOS)) { | ||||
|             throw new BusinessException("没有关联审核通过的流程备料计划,无法领料!"); | ||||
|         } | ||||
|         List<AggPickmVO> newVos = new ArrayList<>(); | ||||
|         for (AggPickmVO vo : pickmVOS) { | ||||
|             if (vo.getChildrenVO() == null || vo.getChildrenVO().length == 0) { | ||||
|                 continue; | ||||
|             } | ||||
|             newVos.add(vo); | ||||
|         } | ||||
|         if (MMValueCheck.isEmpty(newVos)) { | ||||
|             throw new BusinessException("关联的流程备料计划都没有明细行,无法领料!"); | ||||
|         } | ||||
|         Map<String, PickmItemVO> pickmItemVOMap = new HashMap<>(); | ||||
|         for (AggPickmVO pickmVO : pickmVOS) { | ||||
|             PickmItemVO[] pickmItemVOS = (PickmItemVO[]) pickmVO.getChildren(PickmItemVO.class); | ||||
|             for (PickmItemVO pickmItemVO : pickmItemVOS) { | ||||
|                 pickmItemVOMap.put(pickmItemVO.getCpickm_bid(), pickmItemVO); | ||||
|             } | ||||
|         } | ||||
|         // 调用单据转换规则转换出材料出库的VO | ||||
|         MaterialOutVO[] vos = (MaterialOutVO[]) PFPubService.runChangeData("55A3", ICBillType.MaterialOut.getCode(), | ||||
|                 newVos.toArray(new AggPickmVO[0]), null, PfButtonClickContext.ClassifyByItfdef); | ||||
|         // 设置行号 | ||||
|         setMaterialOutRowNum(vos); | ||||
|         UFDouble num = new UFDouble(paramMap.get("num").toString()); | ||||
|         for (MaterialOutVO vo : vos) { | ||||
|             // 处理行数量,行数量 = 本次领料套数(启源传入)*单位主用量(备料计划) | ||||
|             MaterialOutBodyVO[] bodys = vo.getBodys(); | ||||
|             for (MaterialOutBodyVO body : bodys) { | ||||
|                 UFDouble num1 = num; | ||||
|                 // 查询上游备料计划的单位主用量 | ||||
|                 String csourcebillbid = body.getCsourcebillbid(); | ||||
|                 PickmItemVO pickmItemVO = pickmItemVOMap.get(csourcebillbid); | ||||
|                 if (pickmItemVO != null) { | ||||
|                     num1 = num.multiply(pickmItemVO.getNunitusenum()); | ||||
|                 } | ||||
|                 // nshouldnum 应发主数量	nshouldassistnum 应发数量 | ||||
|                 // NCCForUAPLogger.debug("nshouldnum = " + body.getNshouldnum().toString()); | ||||
|                 // NCCForUAPLogger.debug("nshouldassistnum = " + body.getNshouldassistnum().toString()); | ||||
|                 body.setNshouldnum(num1); | ||||
|                 body.setNshouldassistnum(num1); | ||||
|             } | ||||
|         } | ||||
|         IMaterialOutMaintainAPI materialOut = NCLocator.getInstance().lookup(IMaterialOutMaintainAPI.class); | ||||
|         MaterialOutVO[] outVOS = materialOut.insertBills(vos); | ||||
|         // 查询备料计划行上的成套套数 nbsetpartsnum | ||||
|         List<JSONObject> numList = new ArrayList<>(); | ||||
|         AggPickmVO[] newPickmVOS = queryService.queryBillsByPks(cpickmids); | ||||
|         for (AggPickmVO newPickmVO : newPickmVOS) { | ||||
|             PickmItemVO[] pickmItemVOS = (PickmItemVO[]) newPickmVO.getChildren(PickmItemVO.class); | ||||
|             for (PickmItemVO pickmItemVO : pickmItemVOS) { | ||||
|                 JSONObject numJson = new JSONObject(); | ||||
|                 String nbsetpartsnum = pickmItemVO.getNbsetpartsnum().toString(); | ||||
|                 numJson.put("nbsetpartsnum", nbsetpartsnum); | ||||
|                 numJson.put("cbmaterialvid", pickmItemVO.getCbmaterialvid()); | ||||
|                 numList.add(numJson); | ||||
|             } | ||||
|         } | ||||
|         JSONObject result = new JSONObject(); | ||||
|         result.put("outVOS", outVOS); | ||||
|         result.put("numList", numList); | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 检查是否满足特殊条件:需要同步的组织 | ||||
|  |  | |||
|  | @ -7,6 +7,8 @@ package nccloud.api.ic.m4d; | |||
| 
 | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import nc.vo.ic.m4d.entity.MaterialOutVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| 
 | ||||
|  | @ -24,4 +26,6 @@ public interface IAPIMaterialOutMaintain { | |||
|     MaterialOutVO[] saveByRef(List<Map<String, Object>> var1) throws BusinessException; | ||||
| 
 | ||||
|     MaterialOutVO[] batchsave(List<Map<String, Object>> var1) throws BusinessException; | ||||
| 
 | ||||
|     JSONObject destIssue(Map<String, Object> paramMap) throws BusinessException; | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package nccloud.openapi.ic.m4d; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.logging.Log; | ||||
| import nc.bs.scmpub.query.SCMBillQuery; | ||||
|  | @ -184,15 +185,16 @@ public class MaterialOutResource extends NCCPubRestResource { | |||
|             return ResultMessageUtil.exceptionToJSON(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @POST | ||||
|     @Path("operation/delete") | ||||
|     @Consumes({"application/json"}) | ||||
|     @Produces({"application/json"}) | ||||
|     public JSONString delete(Map<String, Object> param) { | ||||
|         Object[] paramArray = ((ArrayList)param.get("cgeneralhid")).toArray(); | ||||
|         Object[] paramArray = ((ArrayList) param.get("cgeneralhid")).toArray(); | ||||
|         String[] paramStrings = new String[paramArray.length]; | ||||
| 
 | ||||
|         for(int i = 0; i < paramArray.length; ++i) { | ||||
|         for (int i = 0; i < paramArray.length; ++i) { | ||||
|             paramStrings[i] = paramArray[i].toString(); | ||||
|         } | ||||
| 
 | ||||
|  | @ -342,6 +344,25 @@ public class MaterialOutResource extends NCCPubRestResource { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @POST | ||||
|     @Path("saveByQyMes") | ||||
|     @Consumes("application/json") | ||||
|     @Produces("application/json") | ||||
|     public JSONString saveByQyMes(Map<String, Object> paramMap) { | ||||
|         try { | ||||
|             if (!paramMap.containsKey("num") || !paramMap.containsKey("cpmohid")) { | ||||
|                 return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含流程生产订单信息和领料数量信息", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); | ||||
|             } | ||||
|             IAPIMaterialOutMaintain materialOut = | ||||
|                     NCLocator.getInstance().lookup(IAPIMaterialOutMaintain.class); | ||||
|             JSONObject result = materialOut.destIssue(paramMap); | ||||
|             return ResultMessageUtil.toJSON(result, nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() | ||||
|                     .getStrByID("4008027_0", "04008027-0472")/* @res "材料出库单保存成功" */); | ||||
|         } catch (Exception e) { | ||||
|             return ResultMessageUtil.exceptionToJSON(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getModule() { | ||||
|         // TODO Auto-generated method stub | ||||
|  |  | |||
|  | @ -77,6 +77,7 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> { | |||
|             String billmakerName = (String) baseDAO.executeQuery(sql, new ColumnProcessor()); | ||||
| 
 | ||||
|             singleObj.put("batchid", System.currentTimeMillis()); | ||||
|             singleObj.put("bipzyid", pmoHeadVO.getCpmohid());// BIP订单主键 | ||||
|             singleObj.put("scdh", pmoHeadVO.getVbillcode()); | ||||
|             singleObj.put("xdrq", pmoHeadVO.getDbilldate().toString()); | ||||
|             singleObj.put("jhy", billmakerName); | ||||
|  | @ -98,12 +99,14 @@ public class AfterPmoSyncJmQMSRule implements IRule<PMOAggVO> { | |||
|                 Integer fitemstatus = item.getFitemstatus(); | ||||
| 
 | ||||
|                 JSONObject itemObj = new JSONObject(); | ||||
|                 itemObj.put("bipqdid", item.getCmoid());// BIP行id | ||||
|                 itemObj.put("sgdh", projectCode);// 施工单号-BIP项目编码 | ||||
|                 itemObj.put("xshth", item.getVfirstcode());// 销售合同号-BIP源头单据号 | ||||
|                 itemObj.put("htqdxh", item.getVfirstrowno());// 合同清单序号-BIP源头单据行号 | ||||
|                 itemObj.put("wlbh", mrlmap.get("code"));// 产品编号 | ||||
|                 itemObj.put("wlmc", mrlmap.get("name"));// 产品名称 | ||||
|                 itemObj.put("wlxhgg", mrlmap.get("materialspec") + (String) mrlmap.get("materialtype"));// ²úÆ·ÐͺŹæ¸ñ | ||||
|                 String wlxhgg = MyHelper.skipNull(mrlmap.get("materialspec")) + MyHelper.skipNull(mrlmap.get("materialtype")); | ||||
|                 itemObj.put("wlxhgg", wlxhgg);// 产品型号规格 | ||||
|                 itemObj.put("jhsl", item.getNastnum().toString());// 计划数量,该产品的生产计划数量 | ||||
|                 UFDateTime tplanendtime = item.getTplanendtime(); | ||||
|                 String tplanendtimeStr = ""; | ||||
|  |  | |||
|  | @ -7,22 +7,32 @@ package nc.bs.mmpac.pmo.pac0002.pluginpoint; | |||
| 
 | ||||
| import nc.bs.dao.BaseDAO; | ||||
| import nc.bs.framework.common.InvocationInfoProxy; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.mmpac.pmo.pac0002.bp.util.PMOBPUtil; | ||||
| import nc.bs.trade.business.HYPubBO; | ||||
| import nc.impl.pubapp.pattern.data.bill.BillQuery; | ||||
| import nc.jdbc.framework.processor.MapProcessor; | ||||
| import nc.pubitf.sn.doc.ISnService; | ||||
| import nc.pubitf.sn.doc.param.SnDocParam; | ||||
| import nc.vo.ml.NCLangRes4VoTransl; | ||||
| import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; | ||||
| import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO; | ||||
| import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; | ||||
| import nc.vo.mmpac.pmo.pac0002.entity.PMOSerialNoVO; | ||||
| import nc.vo.mmpac.pmo.parameter.PMOMaterlKey; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.VOStatus; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.pubapp.pattern.pub.MathTool; | ||||
| import nccloud.baseapp.core.log.NCCForUAPLogger; | ||||
| import nccloud.bs.excel.IXChangeContext; | ||||
| import nccloud.bs.excel.plugin.AbstractImportProceeWithContext; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| /** | ||||
|  * 导入流程生产订单-序列号 | ||||
|  | @ -46,13 +56,16 @@ public class PmoSerialNoImportProcess extends AbstractImportProceeWithContext { | |||
|             String cpmohid = pmoSerialNoVO.getVsndef1();// 订单号 | ||||
|             String vsncode = pmoSerialNoVO.getVsncode();// 序列号 | ||||
|             UFDouble nsnastnum = pmoSerialNoVO.getNsnastnum();// 数量 | ||||
|             if (!MathTool.equals(nsnastnum, UFDouble.ONE_DBL)) { | ||||
|                 throw new BusinessException("数量应该等于1,请检查数据,单号:" + cpmohid + ",行号:" + cmoid); | ||||
|             } | ||||
|             // 查询生产订单的主键 | ||||
|             String selSql = " SELECT a.cpmohid,b.cmoid" + | ||||
|                     " FROM mm_mo b" + | ||||
|                     " LEFT JOIN mm_pmo a ON a.cpmohid = b.cpmohid" + | ||||
|                     // " LEFT JOIN org_factory c ON c.pk_factory = b.pk_org " + | ||||
|                     " WHERE" + | ||||
|                     "  a.vbillcode = '[cpmohid]'" + | ||||
|                     " WHERE b.dr = 0" + | ||||
|                     "  AND a.vbillcode = '[cpmohid]'" + | ||||
|                     "  AND b.vrowno = '[cmoid]'" + | ||||
|                     "  AND b.pk_org = '[pk_org]'"; | ||||
|             selSql = selSql.replace("[cpmohid]", cpmohid); | ||||
|  | @ -69,6 +82,15 @@ public class PmoSerialNoImportProcess extends AbstractImportProceeWithContext { | |||
|             BillQuery<PMOAggVO> query = new BillQuery(PMOAggVO.class); | ||||
|             PMOAggVO[] vos = query.query(new String[]{cpmohid1}); | ||||
|             for (PMOAggVO pmoAggVO : vos) { | ||||
|                 PMOHeadVO headVO = pmoAggVO.getParentVO(); | ||||
|                 // 交易类型编码 | ||||
|                 String vtrantypecode = headVO.getVtrantypecode(); | ||||
|                 Set<String> billTypeCodes = Set.of( | ||||
|                         "55A2-Cxx-01", "55A2-Cxx-18" | ||||
|                 ); | ||||
|                 if (!billTypeCodes.contains(vtrantypecode)) { | ||||
|                     throw new BusinessException("订单类型不符合要求,请检查数据,单号:" + cpmohid + ",行号:" + cmoid); | ||||
|                 } | ||||
|                 PMOItemVO[] pmoItemVOS = pmoAggVO.getChildrenVO(); | ||||
|                 for (PMOItemVO pmoItemVO : pmoItemVOS) { | ||||
|                     if (cmoid1.equals(pmoItemVO.getCmoid())) { | ||||
|  | @ -77,14 +99,14 @@ public class PmoSerialNoImportProcess extends AbstractImportProceeWithContext { | |||
|                         pmoSerialNoVO1.setPk_group(pmoItemVO.getPk_group()); | ||||
|                         pmoSerialNoVO1.setPk_org(pmoItemVO.getPk_org()); | ||||
|                         pmoSerialNoVO1.setPk_org_v(pmoItemVO.getPk_org_v()); | ||||
|                         pmoSerialNoVO1.setCsnunitid(pmoItemVO.getCunitid());// 主单位 | ||||
|                         pmoSerialNoVO1.setCsnastunitid(pmoItemVO.getCastunitid());// 单位 | ||||
|                         pmoSerialNoVO1.setVsncode(vsncode); | ||||
|                         pmoSerialNoVO1.setNsnnum(nsnastnum); | ||||
|                         pmoSerialNoVO1.setNsnastnum(nsnastnum); | ||||
|                         // pmoItemVO.setStatus(VOStatus.UPDATED); | ||||
|                         pmoSerialNoVO1.setStatus(VOStatus.NEW); | ||||
|                         pmoSerialNoVO1.setDr(0); | ||||
|                         this.doAddSave(pmoSerialNoVO1); | ||||
|                         // pmoItemVO.setSerialnos(new PMOSerialNoVO[]{pmoSerialNoVO1}); | ||||
|                         this.doAddSave(pmoSerialNoVO1, headVO, pmoItemVO); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | @ -93,15 +115,30 @@ public class PmoSerialNoImportProcess extends AbstractImportProceeWithContext { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void doAddSave(PMOSerialNoVO vo) { | ||||
|     private void doAddSave(PMOSerialNoVO vo, PMOHeadVO headvo, PMOItemVO itemvo) { | ||||
|         try { | ||||
|             HYPubBO hy = new HYPubBO(); | ||||
|             // 之前序列号全部设置为删除状态 | ||||
|             // int num = dao.executeUpdate("update mm_pmo_serialno set dr = 1 where cmoid = '" + itemvo.getCmoid() + "'"); | ||||
|             // NCCForUAPLogger.debug("PmoSerialNoImportProcess-num = " + num); | ||||
|             String insert = hy.insert(vo); | ||||
|             NCCForUAPLogger.debug(insert); | ||||
|             NCCForUAPLogger.debug("PmoSerialNoImportProcess-insert = " + insert); | ||||
|             if (insert != null && !insert.isEmpty()) { | ||||
|                 PMOSerialNoVO pmoSerialNoVO = (PMOSerialNoVO) hy.queryByPrimaryKey(PMOSerialNoVO.class, insert); | ||||
|                 // 新增序列号档案 | ||||
|                 List<SnDocParam> saveParams = new ArrayList<>(); | ||||
|                 this.construcParams(saveParams, headvo, itemvo, pmoSerialNoVO, null); | ||||
|                 ISnService service = NCLocator.getInstance().lookup(ISnService.class); | ||||
|                 service.saveSerialnos(saveParams.toArray(new SnDocParam[0])); | ||||
|             } | ||||
|             // NCLocator.getInstance().lookup(IPMOMaintainService.class).insert(resvo); | ||||
|         } catch (BusinessException e) { | ||||
|             ExceptionUtils.wrappException(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private void construcParams(List<SnDocParam> params, PMOHeadVO headvo, PMOItemVO itemvo, PMOSerialNoVO snvo, Map<PMOMaterlKey, String> snUint) { | ||||
|         SnDocParam docParam = PMOBPUtil.getSnDocParam(headvo, itemvo, snvo, snUint); | ||||
|         params.add(docParam); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -10,22 +10,24 @@ import nc.bs.businessevent.IBusinessEvent; | |||
| import nc.bs.businessevent.IBusinessListener; | ||||
| import nc.bs.businessevent.bd.BDCommonEvent; | ||||
| 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.trade.business.HYSuperDMO; | ||||
| import nc.bs.uapbd.util.MyHelper; | ||||
| import nc.bs.uapbd.util.ThirdPartyPostRequestUtil; | ||||
| import nc.jdbc.framework.processor.MapProcessor; | ||||
| import nc.pubitf.uapbd.IMaterialPubService; | ||||
| import nc.util.mmf.framework.base.MMValueCheck; | ||||
| import nc.vo.bd.defdoc.DefdocVO; | ||||
| import nc.vo.bd.material.MaterialVO; | ||||
| import nc.vo.bd.material.marbasclass.MarBasClassVO; | ||||
| import nc.vo.bd.material.plan.MaterialPlanVO; | ||||
| import nc.vo.bd.material.stock.MaterialStockVO; | ||||
| import nc.vo.org.OrgVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| 
 | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
| import java.util.stream.Stream; | ||||
| 
 | ||||
| /** | ||||
|  | @ -47,14 +49,7 @@ public class MaterialToJmQmsListener implements IBusinessListener { | |||
|         Object[] objs = e.getObjs(); | ||||
| 
 | ||||
|         // EventType是事件编码 1002-新增后 1004-修改后 1071-状态由停用变为启用后 1069-状态由启用变为停用后 | ||||
|         if ("1004".equals(eventType)) { | ||||
|             MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class); | ||||
|             configParams = MyHelper.getConfigParams("jm-config", null); | ||||
|             if (configParams.isEmpty()) { | ||||
|                 throw new BusinessException("精密的QMS接口缺少配置"); | ||||
|             } | ||||
|             buildSyncData(useVOs, eventType); | ||||
|         } else if ("1071".equals(eventType) || "1069".equals(eventType)) { | ||||
|         if ("1004".equals(eventType) || "1071".equals(eventType) || "1069".equals(eventType)) { | ||||
|             MaterialVO[] useVOs = ArrayClassConvertUtil.convert(objs, MaterialVO.class); | ||||
|             configParams = MyHelper.getConfigParams("jm-config", null); | ||||
|             if (configParams.isEmpty()) { | ||||
|  | @ -96,16 +91,18 @@ public class MaterialToJmQmsListener implements IBusinessListener { | |||
|         for (MaterialVO vo : useVOs) { | ||||
|             // 判断物料的业务单元是否是精密公司,不是则跳过 | ||||
|             String pkOrg = vo.getPk_org(); | ||||
|             String pkMaterial = vo.getPk_material(); | ||||
|             String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); | ||||
|             if (!"1009".equals(eventType) && checkIfOrg(orgCode, configParams)) { | ||||
|             String pkOrg1 = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.PK_ORG, OrgVO.CODE, "C038"); | ||||
|             Integer num = MyHelper.checkIfOrg(configParams, pkMaterial, "jmOrg"); | ||||
|             if (!"1009".equals(eventType) && ((num <= 0))) { | ||||
|                 continue; | ||||
|             } | ||||
|             // 字段值翻译 | ||||
|             String pk_marbasclass = vo.getPk_marbasclass(); | ||||
|             String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.NAME, | ||||
|                     "pk_marbasclass = '" + pk_marbasclass + "'"); | ||||
|             // String pk_marbasclass = vo.getPk_marbasclass(); | ||||
|             // String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.NAME, | ||||
|             //         "pk_marbasclass = '" + pk_marbasclass + "'"); | ||||
|             // 计量单位 | ||||
|             String pkMaterial = vo.getPk_material(); | ||||
|             Map unitMap = getGoodsInfo(pkMaterial); | ||||
|             Map<String, MaterialPlanVO> planMap = queryMaterialPlanInfoByPks(new String[]{pkMaterial}, pkOrg, | ||||
|                     new String[]{MaterialPlanVO.DEF2}); | ||||
|  | @ -117,6 +114,10 @@ public class MaterialToJmQmsListener implements IBusinessListener { | |||
|             // 1=未启用;2=已启用;3=已停用; | ||||
|             Integer enablestate = vo.getEnablestate(); | ||||
|             String statusCode = (3 == enablestate) ? "1" : "0"; | ||||
|             // 物料标志 | ||||
|             String wlbzId = MyHelper.getStrValByCondition(MaterialStockVO.getDefaultTableName(), MaterialStockVO.DEF3, | ||||
|                     MaterialStockVO.PK_MATERIAL + " = '" + pkMaterial + "' and pk_org = '" + pkOrg1 + "'"); | ||||
|             String wlbz = getDefName("zdy-jmzz001", wlbzId); | ||||
|             // 组装数据 | ||||
|             JSONObject singleObj = new JSONObject(); | ||||
|             // 批次编号,用于唯一标识当前传输的物料数据批次,便于追溯和批量处理 | ||||
|  | @ -128,7 +129,8 @@ public class MaterialToJmQmsListener implements IBusinessListener { | |||
|             contentObj.put("bipwlbh", vo.getCode()); // BIP物料编码 | ||||
|             contentObj.put("wlmc", vo.getName()); // 物料名称 | ||||
|             contentObj.put("wlxhgg", vo.getMaterialtype() + vo.getMaterialspec()); // 物料型号规格 | ||||
|             contentObj.put("wlfl", mrlTypeName); // 物料分类 | ||||
|             contentObj.put("wlfl", ""); // 物料分类 | ||||
|             contentObj.put("wlbz", wlbz); // 物料标志 | ||||
|             contentObj.put("sjjldw", unitMap.get("unitname")); // 设计计量单位 | ||||
|             contentObj.put("cgjldw", unitMap.get("deputy_unitname")); // 采购计量单位 | ||||
|             contentObj.put("zhxs", unitMap.getOrDefault("convertRate", "1.00")); // 转换系数 | ||||
|  | @ -211,8 +213,8 @@ public class MaterialToJmQmsListener implements IBusinessListener { | |||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     public static Map<String, MaterialPlanVO> queryMaterialPlanInfoByPks(String[] pks, String pk_stockorg, | ||||
|                                                                          String[] fields) throws BusinessException { | ||||
|     public Map<String, MaterialPlanVO> queryMaterialPlanInfoByPks(String[] pks, String pk_stockorg, | ||||
|                                                                   String[] fields) throws BusinessException { | ||||
|         Map<String, MaterialPlanVO> map = null; | ||||
|         List<String> vids = Stream.of(pks).filter(Objects::nonNull).distinct().toList(); | ||||
|         if (vids.isEmpty()) { | ||||
|  | @ -225,4 +227,22 @@ public class MaterialToJmQmsListener implements IBusinessListener { | |||
|         return map; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 获取自定义项信息 | ||||
|      */ | ||||
|     private String getDefName(String code, String pk_defdoc) { | ||||
|         String res = ""; | ||||
|         String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='" + code + "' and dr=0 )  and dr = 0 and pk_defdoc = '" + pk_defdoc + "'"; | ||||
|         try { | ||||
|             DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere); | ||||
|             if (defdocVOs != null && defdocVOs.length > 0) { | ||||
|                 res = defdocVOs[0].getName().trim(); | ||||
|             } | ||||
|         } catch (DAOException e) { | ||||
|             logger.error("gyMes-SaleOrder-error,getDefName[" + e.getMessage() + "]"); | ||||
|         } | ||||
|         return res; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -184,4 +184,12 @@ public class MyHelper { | |||
|         // NCCForUAPLogger.debug(countSql); | ||||
|         return (Integer) dao.executeQuery(countSql, new ColumnProcessor()); | ||||
|     } | ||||
| 
 | ||||
|     public static String skipNull(Object value) { | ||||
|         if ((value == null) || (value.toString().trim().length() == 0)) { | ||||
|             return ""; | ||||
|         } | ||||
|         return value.toString().trim(); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -13,7 +13,6 @@ import nc.itf.bd.bom.bom0202.IBomBillQueryService; | |||
| import nc.jdbc.framework.generator.IdGenerator; | ||||
| import nc.mmbd.utils.factoryparam.MMBDFactoryParameter; | ||||
| import nc.uif.pub.exception.UifException; | ||||
| import nc.util.mmf.framework.base.MMArrayUtil; | ||||
| import nc.util.mmf.framework.base.MMStringUtil; | ||||
| import nc.util.mmf.framework.base.MMValueCheck; | ||||
| import nc.vo.bd.bom.bom0202.entity.AggBomVO; | ||||
|  | @ -24,6 +23,7 @@ import nc.vo.pub.BusinessException; | |||
| import nc.vo.pub.VOStatus; | ||||
| import nc.vo.pub.lang.UFBoolean; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.ws.opm.pub.utils.result.APIErrCodeEnum; | ||||
| import nccloud.api.mmbd.bom.IAPIBomBusinessService; | ||||
| import nccloud.api.rest.utils.ResultMessageUtil; | ||||
| import nccloud.framework.core.exception.ExceptionUtils; | ||||
|  | @ -96,7 +96,7 @@ public class BomResource extends AbstractNCCRestResource { | |||
|         if (MMValueCheck.isEmpty(paramList)) { | ||||
|             return ResultMessageUtil.exceptionToJSON("传入数据异常,参数要包含表头信息和表体信息", "1"); | ||||
|         } else { | ||||
|             IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class); | ||||
|             IAPIBomBusinessService service = (IAPIBomBusinessService) NCLocator.getInstance().lookup(IAPIBomBusinessService.class); | ||||
|             JSONString result = service.update(paramList); | ||||
|             return result; | ||||
|         } | ||||
|  | @ -110,7 +110,7 @@ public class BomResource extends AbstractNCCRestResource { | |||
|         if (MMValueCheck.isEmpty(paramMap)) { | ||||
|             return ResultMessageUtil.exceptionToJSON("传入数据异常,未传入查询条件", "1"); | ||||
|         } else { | ||||
|             IAPIBomBusinessService service = (IAPIBomBusinessService)NCLocator.getInstance().lookup(IAPIBomBusinessService.class); | ||||
|             IAPIBomBusinessService service = (IAPIBomBusinessService) NCLocator.getInstance().lookup(IAPIBomBusinessService.class); | ||||
|             JSONString result = service.query(paramMap); | ||||
|             return result; | ||||
|         } | ||||
|  | @ -124,9 +124,7 @@ public class BomResource extends AbstractNCCRestResource { | |||
|         if (MMValueCheck.isEmpty(paramMap)) { | ||||
|             return ResultMessageUtil.exceptionToJSON("传入数据异常,未传入更新数据", "1"); | ||||
|         } else { | ||||
|             try{ | ||||
| 
 | ||||
| 
 | ||||
|             try { | ||||
|                 IAPIBomBusinessService service = (IAPIBomBusinessService) NCLocator.getInstance().lookup(IAPIBomBusinessService.class); | ||||
|                 IBomBillQueryService qry = (IBomBillQueryService) NCLocator.getInstance().lookup(IBomBillQueryService.class); | ||||
|                 IBomBillMaintainService bomBillMaintainService = (IBomBillMaintainService) NCLocator.getInstance().lookup(IBomBillMaintainService.class); | ||||
|  | @ -136,10 +134,15 @@ public class BomResource extends AbstractNCCRestResource { | |||
|                     String cbomid = (String) param.get("cbomid"); | ||||
|                     String targetCbomReplaceId = (String) param.get("cbom_replaceid"); // 目标替代ID | ||||
|                     String targetCbomBid = (String) param.get("cbombid"); // 目标物料项ID | ||||
|                     String freplacetype = param.get("freplacetype") + ""; // 替代类型 | ||||
| 
 | ||||
|                     // 校验必要参数 | ||||
|                     if (MMValueCheck.isEmpty(cbomid) || MMValueCheck.isEmpty(targetCbomBid)) { | ||||
|                         ExceptionUtils.wrapBusinessException("cbomidºÍcbombidΪ±Ø´«²ÎÊý"); | ||||
|                         return ResultMessageUtil.exceptionToJSON("cbomid和cbombid为必传参数", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); | ||||
|                     } | ||||
| 
 | ||||
|                     if (MMValueCheck.isEmpty(freplacetype) || !Arrays.asList("1", "2").contains(freplacetype)) { | ||||
|                         return ResultMessageUtil.exceptionToJSON("传入替代类型为空或者值范围错误", APIErrCodeEnum.BUSINESSEXCCODE.getCode()); | ||||
|                     } | ||||
| 
 | ||||
|                     // 查询BOM数据 | ||||
|  | @ -157,6 +160,11 @@ public class BomResource extends AbstractNCCRestResource { | |||
|                         for (BomItemVO bomItemVO : bomItemVOS) { | ||||
|                             // 匹配目标物料项 | ||||
|                             if (targetCbomBid.equals(bomItemVO.getCbom_bid())) { | ||||
|                                 bomItemVO.setStatus(VOStatus.UPDATED); | ||||
|                                 // bcanreplace 可替代 | ||||
|                                 bomItemVO.setBcanreplace(UFBoolean.TRUE); | ||||
|                                 // freplacetype 替代类型 1=全部替代;2=部分替代; | ||||
|                                 bomItemVO.setFreplacetype(Integer.valueOf(freplacetype)); | ||||
|                                 BomReplVO[] replVOS = bomItemVO.getRepl(); | ||||
|                                 List<BomReplVO> replList = MMValueCheck.isEmpty(replVOS) | ||||
|                                         ? new ArrayList<>() | ||||
|  | @ -216,27 +224,27 @@ public class BomResource extends AbstractNCCRestResource { | |||
|                         bomReplVOS.addAll(Arrays.asList(result)); | ||||
|                     } | ||||
|                 } | ||||
|                 List<Map<String,Object>> bomReplVOList = new ArrayList<>(); | ||||
|                 List<Map<String, Object>> bomReplVOList = new ArrayList<>(); | ||||
|                 HYPubBO hybo = new HYPubBO(); | ||||
|                 for (Map<String, Object> param : paramMap) { | ||||
|                     String cbomid = (String) param.get("cbomid"); | ||||
|                     String targetCbomReplaceId = (String) param.get("cbom_replaceid"); // 目标替代ID | ||||
|                     String targetCbomBid = (String) param.get("cbombid"); // 目标物料项ID | ||||
|                     if(!MMStringUtil.isEmpty(targetCbomReplaceId)){ | ||||
|                     if (!MMStringUtil.isEmpty(targetCbomReplaceId)) { | ||||
|                         bomReplVOList.add(param); | ||||
|                         continue; | ||||
|                     }else{ | ||||
|                     } else { | ||||
|                         if (param.containsKey("creplmaterialvid")) { | ||||
| 
 | ||||
|                             String mrlCode= (String) param.get("creplmaterialvid"); | ||||
|                             String mrlid=(String) hybo.findColValue("bd_material","pk_material"," code  = '" + mrlCode + "' "); | ||||
|                             String mrlCode = (String) param.get("creplmaterialvid"); | ||||
|                             String mrlid = (String) hybo.findColValue("bd_material", "pk_material", " code  = '" + mrlCode + "' "); | ||||
|                             for (AggBomVO aggBomVO : bomReplVOS) { | ||||
|                                 for (BomItemVO bomItemVO : aggBomVO.getChildrenVO()) { | ||||
| 
 | ||||
|                                     if (targetCbomBid.equals(bomItemVO.getCbom_bid())) { | ||||
|                                         for (BomReplVO replVO : bomItemVO.getRepl()) { | ||||
|                                             if(replVO.getCreplmaterialvid().equals(mrlid)){ | ||||
|                                                 param.put("cbom_replaceid",replVO.getCbom_replaceid()); | ||||
|                                             if (replVO.getCreplmaterialvid().equals(mrlid)) { | ||||
|                                                 param.put("cbom_replaceid", replVO.getCbom_replaceid()); | ||||
|                                                 bomReplVOList.add(param); | ||||
|                                                 continue; | ||||
|                                             } | ||||
|  | @ -261,6 +269,8 @@ public class BomResource extends AbstractNCCRestResource { | |||
| 
 | ||||
|     // 提取属性设置为工具方法,减少冗余 | ||||
|     private void setReplVOProperties(BomReplVO replVO, Map<String, Object> param) throws UifException { | ||||
|         // bisdisplace 取代 | ||||
|         replVO.setBisdisplace(UFBoolean.TRUE); | ||||
|         HYPubBO hybo = new HYPubBO(); | ||||
| //        if (param.containsKey("pk_group")) { | ||||
| //            replVO.setPk_group((String) param.get("pk_group")); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue