采购订单推送到货单增加最终需求数量校验
This commit is contained in:
		
							parent
							
								
									9ab4bf8bdc
								
							
						
					
					
						commit
						0fabec7da4
					
				|  | @ -0,0 +1,243 @@ | |||
| // | ||||
| // Source code recreated from a .class file by IntelliJ IDEA | ||||
| // (powered by FernFlower decompiler) | ||||
| // | ||||
| 
 | ||||
| package nccloud.web.pu.arrival.transfer.action; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import nc.itf.uap.pf.IPfExchangeService; | ||||
| import nc.pubitf.pu.m21.pu.m23.IOrderQueryFor23; | ||||
| import nc.ui.querytemplate.querytree.IQueryScheme; | ||||
| import nc.vo.ml.NCLangRes4VoTransl; | ||||
| import nc.vo.pu.m20.entity.PraybillItemVO; | ||||
| import nc.vo.pu.m20.entity.PraybillVO; | ||||
| import nc.vo.pu.m21.entity.OrderHeaderVO; | ||||
| import nc.vo.pu.m21.entity.OrderItemVO; | ||||
| import nc.vo.pu.m21.entity.OrderVO; | ||||
| import nc.vo.pu.m23.entity.ArriveHeaderVO; | ||||
| import nc.vo.pu.m23.entity.ArriveMatFeeVO; | ||||
| import nc.vo.pu.m23.entity.ArriveVO; | ||||
| import nc.vo.pu.pub.util.BillHelper; | ||||
| import nc.vo.pub.AggregatedValueObject; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.compiler.PfParameterVO; | ||||
| import nc.vo.pub.lang.UFBoolean; | ||||
| import nc.vo.pub.lang.UFDateTime; | ||||
| import nc.vo.scmpub.util.ArrayUtil; | ||||
| import nc.vo.scmpub.util.BillBodySortUtils; | ||||
| import nc.vo.scmpub.util.TransferSortUtil; | ||||
| import nccloud.dto.baseapp.querytree.dataformat.Condition; | ||||
| import nccloud.dto.baseapp.querytree.dataformat.PageInfo; | ||||
| import nccloud.dto.baseapp.querytree.dataformat.QueryCondition; | ||||
| import nccloud.dto.baseapp.querytree.dataformat.QueryTreeFormatVO; | ||||
| import nccloud.dto.baseapp.querytree.dataformat.Value; | ||||
| import nccloud.dto.pu.arrival.entity.PkTsParamsVO; | ||||
| import nccloud.dto.pu.arrival.entity.TransferData; | ||||
| import nccloud.dto.pu.arrival.entity.TransferInfo; | ||||
| import nccloud.dto.scmpub.pub.utils.SCMRowNoUtils; | ||||
| import nccloud.framework.core.exception.ExceptionUtils; | ||||
| import nccloud.framework.core.json.IJson; | ||||
| import nccloud.framework.service.ServiceLocator; | ||||
| import nccloud.framework.web.action.itf.ICommonAction; | ||||
| import nccloud.framework.web.container.IRequest; | ||||
| import nccloud.framework.web.json.JsonFactory; | ||||
| import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCard; | ||||
| import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCardOperator; | ||||
| import nccloud.pubitf.platform.query.INCCloudQueryService; | ||||
| import nccloud.web.pu.arrival.utis.ArrivalPrecisionHandler; | ||||
| import nccloud.web.pu.arrival.utis.ArrivalScalaSetter; | ||||
| 
 | ||||
| public class TransferOrderAction implements ICommonAction { | ||||
|     public TransferOrderAction() { | ||||
|     } | ||||
| 
 | ||||
|     public Object doAction(IRequest request) { | ||||
|         ExtBillCard[] cards = null; | ||||
| 
 | ||||
|         try { | ||||
|             String read = request.read(); | ||||
|             IJson json = JsonFactory.create(); | ||||
|             TransferInfo info = (TransferInfo)json.fromJson(read, TransferInfo.class); | ||||
|             Map<String, UFDateTime> idTsMap = new HashMap(); | ||||
|             TransferData[] datas = info.getData(); | ||||
|             Set<String> bodyPks = new HashSet(); | ||||
|             Map<String, Set<String>> planPks = new HashMap(); | ||||
|             if (datas != null) { | ||||
|                 for(TransferData data : datas) { | ||||
|                     PkTsParamsVO head = data.getHead(); | ||||
|                     if (head != null) { | ||||
|                         idTsMap.put(head.getPk(), new UFDateTime(head.getTs())); | ||||
|                     } | ||||
| 
 | ||||
|                     PkTsParamsVO[] bodys = data.getBodys(); | ||||
|                     if (bodys != null) { | ||||
|                         for(PkTsParamsVO body : bodys) { | ||||
|                             String pk = body.getPk(); | ||||
|                             if (pk.contains("~")) { | ||||
|                                 String[] pks = pk.split("~"); | ||||
|                                 idTsMap.put(pks[0], new UFDateTime(body.getTs())); | ||||
|                                 bodyPks.add(pks[0]); | ||||
|                                 Set<String> planSet = (Set)planPks.get(head.getPk()); | ||||
|                                 if (planSet == null) { | ||||
|                                     planSet = new HashSet(); | ||||
|                                     planPks.put(head.getPk(), planSet); | ||||
|                                 } | ||||
| 
 | ||||
|                                 planSet.add(pks[1]); | ||||
|                             } else { | ||||
|                                 idTsMap.put(body.getPk(), new UFDateTime(body.getTs())); | ||||
|                                 bodyPks.add(body.getPk()); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             QueryTreeFormatVO queryTemplateInfo = new QueryTreeFormatVO(); | ||||
|             queryTemplateInfo.setOid("0001Z810000000081SLU"); | ||||
|             queryTemplateInfo.setQuerytype("tree"); | ||||
|             queryTemplateInfo.setPageInfo((PageInfo)null); | ||||
|             queryTemplateInfo.setPageCode("400401200_return23"); | ||||
|             queryTemplateInfo.setQueryAreaCode(info.getQueryAreaCode()); | ||||
|             List<Condition> conditions = new ArrayList(); | ||||
|             QueryCondition con = new QueryCondition(); | ||||
|             Condition condition = new Condition(); | ||||
|             condition.setOprtype("="); | ||||
|             condition.setLogic("and"); | ||||
|             condition.setField("pk_order_b.pk_order_b"); | ||||
|             StringBuilder sb = new StringBuilder(); | ||||
| 
 | ||||
|             for(String pk : bodyPks) { | ||||
|                 sb.append(pk).append(","); | ||||
|             } | ||||
| 
 | ||||
|             if (sb.length() > 0) { | ||||
|                 sb.deleteCharAt(sb.length() - 1); | ||||
|             } | ||||
| 
 | ||||
|             Value value = new Value(); | ||||
|             value.setFirstvalue(sb.toString()); | ||||
|             condition.setValue(value); | ||||
|             conditions.add(condition); | ||||
|             con.setConditions(conditions); | ||||
|             con.setLogic("and"); | ||||
|             queryTemplateInfo.setQuerycondition(con); | ||||
|             INCCloudQueryService queryutil = (INCCloudQueryService)ServiceLocator.find(INCCloudQueryService.class); | ||||
|             IQueryScheme scheme = queryutil.convertCondition(queryTemplateInfo); | ||||
|             IOrderQueryFor23 query = (IOrderQueryFor23)ServiceLocator.find(IOrderQueryFor23.class); | ||||
|             OrderVO[] sorceVOs = query.queryFor23(scheme, (String[])bodyPks.toArray(new String[bodyPks.size()])); | ||||
|             if (sorceVOs != null) { | ||||
|                 for(OrderVO vo : sorceVOs) { | ||||
|                     OrderHeaderVO head = vo.getHVO(); | ||||
|                     head.setTs((UFDateTime)idTsMap.get(head.getPk_order())); | ||||
|                     OrderItemVO[] items = vo.getBVO(); | ||||
|                     if (items != null) { | ||||
|                         List<OrderItemVO> list = new LinkedList(); | ||||
| 
 | ||||
|                         for(OrderItemVO item : items) { | ||||
|                             if (idTsMap.get(item.getPk_order_b()) != null) { | ||||
|                                 item.setTs((UFDateTime)idTsMap.get(item.getPk_order_b())); | ||||
|                                 Set<String> set = (Set)planPks.get(head.getPk_order()); | ||||
|                                 if (set != null) { | ||||
|                                     if (set.contains(item.getPk_receiveplan())) { | ||||
|                                         list.add(item); | ||||
|                                     } | ||||
|                                 } else { | ||||
|                                     list.add(item); | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
| 
 | ||||
|                         vo.setBVO((OrderItemVO[])list.toArray(new OrderItemVO[list.size()])); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 IPfExchangeService service = (IPfExchangeService)ServiceLocator.find(IPfExchangeService.class); | ||||
| 
 | ||||
|                 for (OrderVO vo : sorceVOs) { | ||||
|                     for (OrderItemVO itemVO:vo.getBVO()){ | ||||
|                         if(null != itemVO.getAttributeValue("vbdef33") && itemVO.getNastnum().compareTo(itemVO.getAttributeValue("vbdef33"))<0){ | ||||
|                             throw new BusinessException("采购数量大于最终需求数量不能生成采购订单!"); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 AggregatedValueObject[] arrivos = service.runChangeDataAry("21", "23", sorceVOs, (PfParameterVO)null); | ||||
|                 ArriveVO[] vos = (ArriveVO[])arrivos; | ||||
|                 List<ArriveMatFeeVO[]> gransonds = new ArrayList(); | ||||
|                 if (!ArrayUtil.isEmpty(vos)) { | ||||
|                     for(ArriveVO vo : vos) { | ||||
|                         if (!ArrayUtil.isEmpty(vo.getAllGrandSonVOs())) { | ||||
|                             gransonds.add(vo.getAllGrandSonVOs()); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 vos = (ArriveVO[])(new TransferSortUtil("vsourcerowno", "vsourcecode")).sort(vos); | ||||
|                 ExtBillCardOperator operator = new ExtBillCardOperator(info.getPagecode()); | ||||
|                 if (vos != null && vos.length > 0) { | ||||
|                     for(ArriveVO vo : vos) { | ||||
|                         BillBodySortUtils.sort(vo.getBVO(), "crowno"); | ||||
|                         ArriveHeaderVO hvo = vo.getHVO(); | ||||
|                         UFBoolean bisback = hvo.getBisback(); | ||||
|                         if (bisback == null) { | ||||
|                             hvo.setBisback(UFBoolean.FALSE); | ||||
|                         } | ||||
| 
 | ||||
|                         int[] rows = this.getItemRows(vo); | ||||
|                         SCMRowNoUtils.setMultiSelectRowNo(vo.getBVO(), rows); | ||||
|                     } | ||||
| 
 | ||||
|                     cards = new ExtBillCard[vos.length]; | ||||
| 
 | ||||
|                     for(int i = 0; i < vos.length; ++i) { | ||||
|                         cards[i] = operator.toCard(vos[i]); | ||||
|                         ArrivalScalaSetter.setArrivalScalaBillCard(cards[i]); | ||||
|                         (new ArrivalPrecisionHandler()).processCard(cards[i]); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 if (gransonds.size() > 0 && !ArrayUtil.isEmpty(vos)) { | ||||
|                     for(int i = 0; i < vos.length; ++i) { | ||||
|                         if (cards[i].getGrandSons("card_fee_detail") == null) { | ||||
|                             ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004100_0", "04004100-0309", (String)null, new String[]{vos[i].getBVO()[0].getVsourcecode()})); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004100_0", "04004100-0005")); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             ExceptionUtils.wrapException(e); | ||||
|         } | ||||
| 
 | ||||
|         return cards; | ||||
|     } | ||||
| 
 | ||||
|     private int[] getItemRows(ArriveVO aggVO) { | ||||
|         BillHelper<ArriveVO> helper = new BillHelper(aggVO); | ||||
|         int[] trows = new int[aggVO.getBVO().length]; | ||||
|         List<Integer> lists = new ArrayList(); | ||||
| 
 | ||||
|         for(int i = 0; i < trows.length; ++i) { | ||||
|             Object object = helper.getBodyValue(i, "pk_material"); | ||||
|             if (object != null && !object.toString().equals("null")) { | ||||
|                 lists.add(i); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         int[] rows = new int[lists.size()]; | ||||
| 
 | ||||
|         for(int n = 0; n < lists.size(); ++n) { | ||||
|             rows[n] = (Integer)lists.get(n); | ||||
|         } | ||||
| 
 | ||||
|         return rows; | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue