销售订单取消审批后推送高压MES-删除接口
This commit is contained in:
		
							parent
							
								
									8380c2a43c
								
							
						
					
					
						commit
						128e1f541f
					
				|  | @ -6,6 +6,7 @@ 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.InvocationInfoProxy; | ||||
| import nc.bs.logging.Log; | ||||
| import nc.bs.trade.business.HYPubBO; | ||||
| import nc.bs.uapbd.util.MyHelper; | ||||
|  | @ -68,10 +69,11 @@ public class AfterApproveCancelSyncHighpressureMesRule implements IRule<PMOAggVO | |||
|             if (checkIfOrg(orgCode, configParams)) { | ||||
|                 continue; | ||||
|             } | ||||
| //            JSONObject singleObj = new JSONObject(); | ||||
|             String sql1 = " select user_name from sm_user where cuserid = '" + pmoHeadVO.getModifier() + "' "; | ||||
|             String bipCreateBy = (String) baseDAO.executeQuery(sql1, new ColumnProcessor()); | ||||
|             list.put("bipUpdateBy", bipCreateBy); // ÐÞ¸ÄÈËID | ||||
|             // 取消审批人 | ||||
|             String bipUpdateId = InvocationInfoProxy.getInstance().getUserId();//当前登录人 | ||||
|             String userSql = " select user_name from sm_user where dr = 0 and cuserid = '" + bipUpdateId + "' "; | ||||
|             String bipUpdateBy = (String) baseDAO.executeQuery(userSql, new ColumnProcessor()); | ||||
|             list.put("bipUpdateBy", bipUpdateBy); // 修改人ID | ||||
| 
 | ||||
|             // 创建子项数组 | ||||
|             JSONArray contentArray = new JSONArray(); | ||||
|  |  | |||
|  | @ -0,0 +1,182 @@ | |||
| package nc.bs.so.m30.rule.approve; | ||||
| 
 | ||||
| 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.InvocationInfoProxy; | ||||
| 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.impl.pubapp.pattern.rule.IRule; | ||||
| import nc.jdbc.framework.processor.ColumnProcessor; | ||||
| import nc.jdbc.framework.processor.MapProcessor; | ||||
| import nc.vo.bd.defdoc.DefdocVO; | ||||
| import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; | ||||
| import nc.vo.org.OrgVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.so.m30.entity.SaleOrderBVO; | ||||
| import nc.vo.so.m30.entity.SaleOrderHVO; | ||||
| import nc.vo.so.m30.entity.SaleOrderVO; | ||||
| import nccloud.baseapp.core.log.NCCForUAPLogger; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| /** | ||||
|  * 销售订单取消审批后推送高压MES-删除接口 | ||||
|  * | ||||
|  * @author houyi | ||||
|  */ | ||||
| public class AfterSoCancelSyncRuleGyMes implements IRule<SaleOrderVO> { | ||||
|     private static final String LOG_INFO_NAME = "gymeslog"; | ||||
|     private static final Log logger = Log.getInstance(LOG_INFO_NAME); | ||||
|     private static final String reqUrl = "/bip/order/saleOrderCancel"; | ||||
|     private Map<String, String> configParams; | ||||
| 
 | ||||
|     @Override | ||||
|     public void process(SaleOrderVO[] saleOrderVOs) { | ||||
|         try { | ||||
|             if (saleOrderVOs == null || saleOrderVOs.length == 0) { | ||||
|                 return; | ||||
|             } | ||||
|             configParams = MyHelper.getConfigParams("gy-config", null); | ||||
|             if (configParams.isEmpty()) { | ||||
|                 throw new BusinessException("高压的接口缺少配置"); | ||||
|             } | ||||
|             buildSyncData(saleOrderVOs); | ||||
|         } catch (Exception e) { | ||||
|             ExceptionUtils.wrappException(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 构建同步数据 | ||||
|      */ | ||||
|     private void buildSyncData(SaleOrderVO[] useVOs) throws BusinessException { | ||||
|         BaseDAO baseDAO = new BaseDAO(); | ||||
|         HYPubBO hybo = new HYPubBO(); | ||||
|         JSONArray cmoidArray = new JSONArray(); | ||||
|         JSONObject list = new JSONObject(); | ||||
|         for (SaleOrderVO vo : useVOs) { | ||||
|             // 判断物料的业务单元是否是高压公司,不是则跳过 | ||||
|             String pkOrg = vo.getParentVO().getPk_org(); | ||||
|             String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg); | ||||
|             if (checkIfOrg(orgCode, configParams)) { | ||||
|                 continue; | ||||
|             } | ||||
|             SaleOrderHVO hvo = vo.getParentVO(); | ||||
| //            SaleOrderBVO[] itemVOS = vo.getChildrenVO(); | ||||
|             String cmoid = hvo.getVbillcode();// 销售订单号 | ||||
|             cmoidArray.add(cmoid); | ||||
|         } | ||||
|         if (cmoidArray.size() > 0) { | ||||
|             ArrayList<Object> cmoidObj = new ArrayList<>(Arrays.asList(cmoidArray.toArray())); | ||||
|             // 使用 String.join 进行字符串拼接 | ||||
|             String result = ""; | ||||
|             StringBuilder sb = new StringBuilder(); | ||||
|             if (cmoidObj.size() > 1) { | ||||
|                 for (int i = 0; i < cmoidObj.size(); i++) { | ||||
|                     sb.append("'").append(cmoidObj.get(i)).append("'"); | ||||
|                     if (i < cmoidObj.size() - 1) { | ||||
|                         sb.append(","); | ||||
|                     } | ||||
|                 } | ||||
|                 result = sb.toString(); | ||||
|             } else { | ||||
|                 result = "'" + (String) cmoidObj.get(0) + "'"; | ||||
|             } | ||||
| 
 | ||||
|             // 取消审批人 | ||||
|             String bipUpdateId = InvocationInfoProxy.getInstance().getUserId();//当前登录人 | ||||
|             String userSql = " select user_name from sm_user where dr = 0 and cuserid = '" + bipUpdateId + "' "; | ||||
|             String bipUpdateBy = (String) baseDAO.executeQuery(userSql, new ColumnProcessor()); | ||||
| 
 | ||||
|             list.put("bipOrderId", result); // 主键ID | ||||
|             list.put("bipUpdateBy", bipUpdateBy);// 取消审批人 | ||||
|             pushData(list); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 推送同步数据 | ||||
|      */ | ||||
|     private void pushData(JSONObject param) throws BusinessException { | ||||
|         // String jsonString = param.toJSONString(); | ||||
|         // 转json字符串的时候保留null值 | ||||
|         String jsonStr = JSON.toJSONString(param, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty); | ||||
|         logger.error("gyMes-SaleOrder-param = " + jsonStr); | ||||
|         NCCForUAPLogger.debug("gyMes-SaleOrder-param = " + jsonStr); | ||||
|         String baseUrl = configParams.get("mesBaseUrl"); | ||||
|         String requestUrl = baseUrl + reqUrl; | ||||
|         logger.error("gyMes-SaleOrder-url = " + requestUrl); | ||||
|         String result = ThirdPartyPostRequestUtil.sendPostRequest(requestUrl, jsonStr); | ||||
|         JSONObject resultObj = JSONObject.parseObject(result); | ||||
|         logger.error("gyMes-SaleOrder-res = " + result); | ||||
| 
 | ||||
|         if (!"200".equals(resultObj.getString("code"))) { | ||||
|             logger.error("gyMes-SaleOrder-error,result[" + resultObj.toJSONString() + "]"); | ||||
|             throw new BusinessException("销售订单推送高压MES错误:" + resultObj.getString("msg")); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException { | ||||
|         String targetCode = configParams.get("gyOrg"); | ||||
|         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; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 获取自定义项信息 | ||||
|      */ | ||||
|     private String getDefCode(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].getCode().trim(); | ||||
|             } | ||||
|         } catch (DAOException e) { | ||||
|             logger.error("gyMes-SaleOrder-error,getDefCode[" + e.getMessage() + "]"); | ||||
|         } | ||||
|         return res; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 获取自定义项信息 | ||||
|      */ | ||||
|     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,getDefCode[" + e.getMessage() + "]"); | ||||
|         } | ||||
|         return res; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
|  | @ -13,6 +13,7 @@ import nc.bs.pub.action.N_30_UNAPPROVE; | |||
| import nc.bs.scmpub.rule.VOSagaFrozenValidateRule; | ||||
| import nc.bs.so.m30.maintain.rule.insert.RewritePromotePriceInsertRule; | ||||
| import nc.bs.so.m30.plugin.Action30PlugInPoint; | ||||
| import nc.bs.so.m30.rule.approve.AfterSoCancelSyncRuleGyMes; | ||||
| import nc.bs.so.m30.rule.approve.CheckPush5Aor20Rule; | ||||
| import nc.bs.so.m30.rule.approve.SaleOrderDeleteRmBeforeRule; | ||||
| import nc.bs.so.m30.rule.atp.SaleOrderVOATPAfterRule; | ||||
|  | @ -154,6 +155,8 @@ public class UnApproveSaleOrderAction { | |||
|         IRule<SaleOrderVO> var11 = new MobAfterUnApproveMessageRule(); | ||||
|         processer.addAfterRule(var11); | ||||
|         processer.addAfterRule(new SaleOrderDeleteRmBeforeRule()); | ||||
|         // 销售订单取消审批后推送高压MES | ||||
|         processer.addAfterRule(new AfterSoCancelSyncRuleGyMes()); | ||||
|     } | ||||
| 
 | ||||
|     private void addBeforeRule(AroundProcesser<SaleOrderVO> processer, Integer oldbillstatus) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue