销售订单同步关闭
This commit is contained in:
		
							parent
							
								
									13d8c2b50a
								
							
						
					
					
						commit
						dc8a09b92e
					
				|  | @ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding='gb2312'?> | ||||
| <module> | ||||
| <rest> | ||||
| 	<resource classname="nccloud.api.so.so.UpCloses.CloseSoResource"  exinfo="关闭订单"/> | ||||
| </rest> | ||||
| </module> | ||||
|  | @ -0,0 +1,105 @@ | |||
| package nccloud.api.so.so.UpCloses; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.itf.so.m30.closemanage.ISaleOrderCloseManageMaintain; | ||||
| import nc.pubitf.so.m30.api.ISaleOrderQueryAPI; | ||||
| import nc.pubitf.uapbd.IRateTypePubService; | ||||
| import nc.vo.so.m30.entity.SaleOrderBVO; | ||||
| import nc.vo.so.m30.entity.SaleOrderVO; | ||||
| import nccloud.api.rest.utils.ResultMessageUtil; | ||||
| import nccloud.framework.service.ServiceLocator; | ||||
| import nccloud.pubitf.scmpub.pub.batchopr.dto.ISCMBatchOprContext; | ||||
| import nccloud.pubitf.scmpub.pub.batchopr.dto.SCMBatchOprContext; | ||||
| import nccloud.pubitf.scmpub.pub.batchopr.dto.SCMBatchResultDTO; | ||||
| import nccloud.web.scmpub.pub.utils.batchopr.SCMBatchOperator; | ||||
| import nccloud.ws.rest.resource.AbstractNCCRestResource; | ||||
| import org.json.JSONString; | ||||
| 
 | ||||
| import javax.ws.rs.Consumes; | ||||
| import javax.ws.rs.POST; | ||||
| import javax.ws.rs.Path; | ||||
| import javax.ws.rs.Produces; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| @Path("so/so/Close") | ||||
| public class CloseSoResource extends AbstractNCCRestResource { | ||||
|     @Override | ||||
|     public String getModule() { | ||||
|         return "so"; | ||||
|     } | ||||
|     @POST | ||||
|     @Path("/ClosesoWith") | ||||
|     @Consumes({"application/json"}) | ||||
|     @Produces({"application/json"}) | ||||
|     public JSONString CloseSoResource(JSONString json) { | ||||
|         JSONObject errojson = new JSONObject(); | ||||
|         try { | ||||
|             JSONObject jObject = JSON.parseObject(json.toJSONString()); | ||||
|             if (jObject == null) { | ||||
|                 return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); | ||||
|             } | ||||
|             JSONArray array = jObject.getJSONArray("bills"); | ||||
|             if (array.isEmpty()) { | ||||
|                 return ResultMessageUtil.exceptionToJSON(new NullPointerException("请选择销售订单")); | ||||
|             } | ||||
|             String[] ids = new String[array.size()]; | ||||
|             for (int i = 0; i < array.size(); i++) { | ||||
|                 SaleOrderVO saleOrderVO = new SaleOrderVO(); | ||||
|                 String pk = (String) array.getJSONObject(i).getOrDefault("pk", ""); | ||||
|                 ids[i] = pk; | ||||
| 
 | ||||
|             } | ||||
|             ISaleOrderQueryAPI iSaleOrderQueryAPI= NCLocator.getInstance() | ||||
|                     .lookup(ISaleOrderQueryAPI.class); | ||||
|             SaleOrderVO[] billvos = iSaleOrderQueryAPI.queryVOByIDs(ids); | ||||
| //            ISCMBatchOprContext context = new SCMBatchOprContext(); | ||||
| //            context.setInterfaceName("nc.itf.so.m30.closemanage.ISaleOrderCloseManageMaintain"); | ||||
| //            context.setMethodName("closeSaleOrder"); | ||||
| //            context.setParamTypes(new Class[]{SaleOrderVO[].class}); | ||||
| //            context.setParams(new Object[]{billvos}); | ||||
| //            context.setBillPos(0); | ||||
| 
 | ||||
| //            SCMBatchResultDTO resulet = SCMBatchOperator.doRemoteCall(context); | ||||
|             ISaleOrderCloseManageMaintain iSaleOrderCloseManageMaintain = NCLocator.getInstance() | ||||
|                     .lookup(ISaleOrderCloseManageMaintain.class); | ||||
|             SaleOrderVO[] saleOrderVOS= iSaleOrderCloseManageMaintain.closeSaleOrder(billvos); | ||||
|             if(saleOrderVOS.length == 0){ | ||||
|                  errojson.put("status", "0"); | ||||
|                  errojson.put("message", "关闭失败"); | ||||
|                  errojson.put("codeList", ""); | ||||
|                  return ResultMessageUtil.toJSON(errojson); | ||||
| 
 | ||||
|             } | ||||
|             errojson.put("status", "1"); | ||||
|             errojson.put("message", "成功关闭"); | ||||
|             errojson.put("codeList", ""); | ||||
|             // 返回表示操作成功的JSON字符串 | ||||
|             return ResultMessageUtil.toJSON(errojson); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         } catch (Exception e) { | ||||
|             errojson.put("status", "0"); | ||||
|             errojson.put("message", e.getMessage()); | ||||
|             errojson.put("codeList", ""); | ||||
|             // 返回表示操作失败的JSON字符串 | ||||
|             return ResultMessageUtil.toJSON(errojson); | ||||
|         } | ||||
|     } | ||||
|     private void setCloseOpenReason(SaleOrderVO[] bills,String reason) { | ||||
|         for(SaleOrderVO bill : bills) { | ||||
|             SaleOrderBVO[] bodys = bill.getChildrenVO(); | ||||
| 
 | ||||
|             for(SaleOrderBVO body : bodys) { | ||||
|                 body.setVclosereason(reason); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue