tntdc il y a 2 ans
Parent
commit
a654265686

+ 3 - 1
adm/src/main/java/com/minpay/common/util/HttpPostUtil.java

@@ -96,15 +96,17 @@ public class HttpPostUtil {
 	}
 	
 	
-	 public static String sendPostRequest(String url, Map param){
+	 public static String sendPostRequest(String url, Map param, String user, String pass){
    	  String result = "";
    	  try{
 	    	   URL httpurl = new URL(url);
 	    	   HttpURLConnection httpConn = (HttpURLConnection)httpurl.openConnection();
+	    	   httpConn.setRequestProperty("Authorization", "Basic " + Base64.encode((user+":"+pass).getBytes()));
 	    	   httpConn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
 	    	   httpConn.setDoOutput(true);
 	    	   httpConn.setDoInput(true);
 	    	   PrintWriter out = new PrintWriter(httpConn.getOutputStream());
+	    	   out.print(com.alibaba.fastjson.JSONObject.toJSONString(param));
 	    	   out.flush();
 	    	   out.close();
 		       BufferedReader in = new BufferedReader(new InputStreamReader(httpConn.getInputStream(),"UTF-8"));

+ 144 - 134
adm/src/main/java/com/minpay/guomao/transManage/TransManageAction.java

@@ -1,22 +1,29 @@
 package com.minpay.guomao.transManage;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+
 import javax.servlet.http.HttpServletRequest;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.min.util.DateUtil;
 import com.minpay.common.service.IPublicService;
 import com.minpay.common.util.CommonUtil;
 import com.minpay.common.util.HttpPostUtil;
 import com.minpay.db.table.mapper.ApCompanyInfMapper;
+import com.minpay.db.table.mapper.ApContractInfMapper;
 import com.minpay.db.table.mapper.ApOrderInfMapper;
 import com.minpay.db.table.mapper.ApProductInfMapper;
 import com.minpay.db.table.mapper.ApTransferFlowMapper;
 import com.minpay.db.table.model.ApCompanyInf;
 import com.minpay.db.table.model.ApCompanyInfExample;
+import com.minpay.db.table.model.ApContractInf;
 import com.minpay.db.table.model.ApOrderInf;
 import com.minpay.db.table.model.ApProductInf;
 import com.minpay.db.table.model.ApTransferFlow;
@@ -28,6 +35,7 @@ import com.startup.minpay.frame.service.base.Service;
 import com.startup.minpay.frame.target.MINAction;
 import com.startup.minpay.frame.target.MINComponent;
 import com.startup.minpay.frame.target.MINParam;
+
 import net.sf.json.JSONObject;
 
 @MINComponent
@@ -54,107 +62,120 @@ public class TransManageAction implements IMINAction{
 	 * @param request
 	 * @return
 	 * @throws MINBusinessException
+	 * @throws IOException 
 	 */
 	@MINAction(value = SUPPLIER_TRANSMISSION,session = false)
 	public MINActionResult supplierTransmission(
 			HttpServletRequest request
-			) throws MINBusinessException{
+			) throws MINBusinessException, IOException{
 		MINActionResult res = new MINActionResult();
 		
 		int count = 0;
 		String GUID = request.getParameter("GUID");
 		String HEADER = request.getParameter("HEADER");
+		System.out.println(HEADER);
+		
 		//获取当前时间
 		String currentTime = DateUtil.getCurrentDateTimeString();
 		res.set("GUID", GUID);
 		try {
-			JSONObject jsonHeader = JSONObject.fromObject(HEADER);
-			//供应商编号----ERP客商编码
-			String LIFNR = CommonUtil.objToString(jsonHeader.get("LIFNR"));
-			if(CommonUtil.isEmpty(LIFNR)){
-				throw new MINBusinessException("LIFNR不可为空!");
-			}
-			if(LIFNR.length() > 20){
-				throw new MINBusinessException("LIFNR长度太长!");
-			}
-			//供应商描述---客户名称
-			String NAME1 = CommonUtil.objToString(jsonHeader.get("NAME1"));
-			if(CommonUtil.isEmpty(NAME1)){
-				throw new MINBusinessException("NAME1不可为空!");
-			}
-			if(NAME1.length() > 30){
-				throw new MINBusinessException("NAME1长度太长!");
-			}
-			//统一社会信用代码---税号
-			String TAXNUMXL = CommonUtil.objToString(jsonHeader.get("TAXNUMXL"));
-			if(CommonUtil.isEmpty(TAXNUMXL)){
-				throw new MINBusinessException("TAXNUMXL不可为空!");
-			}
-			if(TAXNUMXL.length() > 50){
-				throw new MINBusinessException("TAXNUMXL长度太长!");
-			}
-			
-			//简称
-			String EXTRA1 = CommonUtil.objToString(jsonHeader.get("EXTRA1"));
-			if(!CommonUtil.isEmpty(EXTRA1)){
-				if(EXTRA1.length() > 30){
-					throw new MINBusinessException("EXTRA1长度太长!");
+			JSONArray jsonHeaderArray = JSONArray.parseArray(HEADER);
+			for(Object object : jsonHeaderArray) {
+				Map jsonHeader = (Map)object;
+				//供应商编号----ERP客商编码
+				String LIFNR = CommonUtil.objToString(jsonHeader.get("LIFNR"));
+				if(CommonUtil.isEmpty(LIFNR)){
+					throw new MINBusinessException("LIFNR不可为空!");
 				}
-			}
-			//客户首字母
-			String EXTRA2 = CommonUtil.objToString(jsonHeader.get("EXTRA2"));
-			if(!CommonUtil.isEmpty(EXTRA2)){
-				if(EXTRA2.length() > 20){
-					throw new MINBusinessException("EXTRA2长度太长!");
+				if(LIFNR.length() > 20){
+					throw new MINBusinessException("LIFNR长度太长!");
+				}
+				//供应商描述---客户名称
+				String NAME1 = CommonUtil.objToString(jsonHeader.get("NAME1"));
+				if(CommonUtil.isEmpty(NAME1)){
+					throw new MINBusinessException("NAME1不可为空!");
+				}
+				if(NAME1.length() > 30){
+					throw new MINBusinessException("NAME1长度太长!");
+				}
+				//统一社会信用代码---税号
+				String TAXNUMXL = CommonUtil.objToString(jsonHeader.get("TAXNUMXL"));
+				if(CommonUtil.isEmpty(TAXNUMXL)){
+					throw new MINBusinessException("TAXNUMXL不可为空!");
+				}
+				if(TAXNUMXL.length() > 50){
+					throw new MINBusinessException("TAXNUMXL长度太长!");
 				}
-			}
-			//系统内外
-			String EXTRA3 = CommonUtil.objToString(jsonHeader.get("EXTRA3"));
-			//客户类型 MM-采购  SD--销售
-			String EXTRA4 = CommonUtil.objToString(jsonHeader.get("EXTRA4"));
-			
-			//查询客户是否存在
-			ApCompanyInfExample example = new ApCompanyInfExample();
-			example.createCriteria().andErpCodeEqualTo(LIFNR).andStateEqualTo("00");
-			List<ApCompanyInf> list =	Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).selectByExample(example);
-			
-			ApCompanyInf companyInfo = new ApCompanyInf();
-			//ERP客商编码
-			companyInfo.setErpCode(LIFNR);
-			//客户名称
-			companyInfo.setName(NAME1);
-			//税号
-			companyInfo.setDutyParagraph(TAXNUMXL);
-			//简称
-			companyInfo.setShortName(EXTRA1);
-			//客户首字母
-			companyInfo.setInitial(EXTRA2);
-			//系统内外	TODO 需做处理
-			companyInfo.setType(EXTRA3);
-			if("MM".equals(EXTRA4)){
-				companyInfo.setBuyType("00");
-			}else if("SD".equals(EXTRA4)){
-				companyInfo.setBuyType("01");
-			}
-			//存在---做修改
-			if(list.size() > 0){
-				String id = list.get(0).getId();
-				companyInfo.setId(id);
-				//修改时间
-				companyInfo.setModifyTime(currentTime);
-				count = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).updateByPrimaryKeySelective(companyInfo);
 				
-			}else{
-				//不存在--新增
-				String id = Service.lookup(IPublicService.class).getSequence("AP_CUSTOMER_INF_ID");
-				companyInfo.setId(id);
-				//创建时间
-				companyInfo.setCreateTime(currentTime);
-				companyInfo.setProjectCode("00001");
-				//部门
-				companyInfo.setBranchId("100002|100005|100197");
-				count = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).insertSelective(companyInfo);
+				//简称
+				String EXTRA1 = CommonUtil.objToString(jsonHeader.get("EXTRA1"));
+				if(!CommonUtil.isEmpty(EXTRA1)){
+					if(EXTRA1.length() > 30){
+						throw new MINBusinessException("EXTRA1长度太长!");
+					}
+				}
+				//客户首字母
+				String EXTRA2 = CommonUtil.objToString(jsonHeader.get("EXTRA2"));
+				if(!CommonUtil.isEmpty(EXTRA2)){
+					if(EXTRA2.length() > 20){
+						throw new MINBusinessException("EXTRA2长度太长!");
+					}
+				}
+				//系统内外
+				String EXTRA3 = CommonUtil.objToString(jsonHeader.get("EXTRA3"));
+				//客户类型 MM-采购  SD--销售
+				//String EXTRA4 = CommonUtil.objToString(jsonHeader.get("EXTRA4"));
+				
+				//查询客户是否存在
+				ApCompanyInfExample example = new ApCompanyInfExample();
+				example.createCriteria().andErpCodeEqualTo(LIFNR).andStateEqualTo("00");
+				List<ApCompanyInf> list =	Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).selectByExample(example);
+				
+				ApCompanyInf companyInfo = new ApCompanyInf();
+				//ERP客商编码
+				companyInfo.setErpCode(LIFNR);
+				//客户名称
+				companyInfo.setName(NAME1);
+				//税号
+				companyInfo.setDutyParagraph(TAXNUMXL);
+				//简称
+				companyInfo.setShortName(EXTRA1);
+				//客户首字母
+				companyInfo.setInitial(EXTRA2);
+				//系统内外
+				if("内".equals(EXTRA3)) {
+					companyInfo.setType("00");
+				} else {
+					companyInfo.setType("01");
+				}
+				
+				/*if("MM".equals(EXTRA4)){
+					companyInfo.setBuyType("00");
+				}else if("SD".equals(EXTRA4)){
+					companyInfo.setBuyType("01");
+				}*/
+				companyInfo.setBuyType("02");
+				//存在---做修改
+				if(list.size() > 0){
+					String id = list.get(0).getId();
+					companyInfo.setId(id);
+					//修改时间
+					companyInfo.setModifyTime(currentTime);
+					count = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).updateByPrimaryKeySelective(companyInfo);
+					
+				}else{
+					//不存在--新增
+					String id = Service.lookup(IPublicService.class).getSequence("AP_CUSTOMER_INF_ID");
+					companyInfo.setId(id);
+					//创建时间
+					companyInfo.setCreateTime(currentTime);
+					companyInfo.setProjectCode("00001");
+					//部门
+					companyInfo.setBranchId("100002|100005|100197");
+					count = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).insertSelective(companyInfo);
+				}
 			}
+			
 		} catch (Exception e) {
 			e.printStackTrace();
 			res.set("STATUS", "E");
@@ -312,15 +333,10 @@ public class TransManageAction implements IMINAction{
 	 * @throws MINBusinessException
 	 */
 	
-	@MINAction(value = PURCHASE_ORDER_TRANSMISSION,session = false)
+	@MINAction(value = PURCHASE_ORDER_TRANSMISSION)
 	public MINActionResult purchaseOrderTransmission(
 			@MINParam(key ="orderId") String orderId,
-			@MINParam(key ="purchaseTeam") String purchaseTeam,
-			@MINParam(key ="orderName") String orderName,
-			@MINParam(key ="legalContractNo") String legalContractNo,
-			@MINParam(key ="sellerErpCode") String sellerErpCode,
 			@MINParam(key ="erpPostingDate") String erpPostingDate,
-			@MINParam(key ="contractType") String contractType,
 			@MINParam(key ="transferNum") String transferNum,
 			@MINParam(key ="preSettlement") String preSettlement,
 			@MINParam(key ="realPrice") String realPrice,
@@ -329,27 +345,15 @@ public class TransManageAction implements IMINAction{
 			@MINParam(key ="aoiTransferredNum") String aoiTransferredNum,
 			@MINParam(key ="aoiRemainingTransNum") String aoiRemainingTransNum
 			) throws MINBusinessException{
-		
-		if(CommonUtil.isEmpty(purchaseTeam)){
-			throw new MINBusinessException("采购组不可为空!");
-		}
-		if(CommonUtil.isEmpty(orderName)){
-			throw new MINBusinessException("订单名称不可为空!");
-		}
-		
-		if(CommonUtil.isEmpty(legalContractNo)){
-			throw new MINBusinessException("法务合同号不可为空!");
-		}
-		if(CommonUtil.isEmpty(sellerErpCode)){
-			throw new MINBusinessException("客户编码不可为空!");
-		}
+		ApOrderInf order = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApOrderInfMapper.class).selectByPrimaryKey(orderId);
+		String contractId = order.getContractId();
+		ApContractInf contractInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApContractInfMapper.class).selectByPrimaryKey(contractId);
+		String sellerId = contractInf.getSellerId();
+		ApCompanyInf companyInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).selectByPrimaryKey(sellerId);
 		
 		if(CommonUtil.isEmpty(erpPostingDate)){
 			throw new MINBusinessException("ERP过账日期不可为空!");
 		}
-		if(CommonUtil.isEmpty(contractType)){
-			throw new MINBusinessException("合同类型不可为空!");
-		}
 		//查询铝锭产品信息  --上海铝锭
 		ApProductInf productInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApProductInfMapper.class).selectByPrimaryKey("O100000073");
 		if(productInf == null){
@@ -383,21 +387,21 @@ public class TransManageAction implements IMINAction{
 		//采购组织
 		hederMap.put("EKORG","2405");
 		//采购组
-		hederMap.put("EKGRP",purchaseTeam);
+		hederMap.put("EKGRP",contractInf.getPurchaseTeam());
 		//公司代码
 		hederMap.put("BUKRS","2405");
 		//凭证类型
 		hederMap.put("BSART", "C001");
 		//订单名称
-		hederMap.put("Z_DSPT_NO", orderName);
+		hederMap.put("Z_DSPT_NO", order.getName());
 		//法务合同号
-		hederMap.put("ZZCONTRACTCODE", legalContractNo);
+		hederMap.put("ZZCONTRACTCODE", contractInf.getLegalContractNo());
 		//ERP客户编码
-		hederMap.put("KUNNR", sellerErpCode);
+		hederMap.put("KUNNR", companyInf.getErpCode());
 		//单据日期
 		hederMap.put("AUDAT", erpPostingDate);
 		//合同类型长单---Y 其他--N
-		if("00".equals(contractType)){
+		if("00".equals(contractInf.getContractType())){
 			hederMap.put("Z_FLAG","Y");
 		}else{
 			hederMap.put("Z_FLAG","N");
@@ -433,10 +437,15 @@ public class TransManageAction implements IMINAction{
 		itemMap.put("WERKS","2405");
 		//库存地点
 		itemMap.put("LGORT","A001");
+		list.add(itemMap);
 		try {
 			//调用
 			String url = Service.lookup(IPublicService.class).getSysParValue("TRANSFER_ORDER_URL");
-			HttpPostUtil.sendPostRequest(url, requestBody);
+			String user = Service.lookup(IPublicService.class).getSysParValue("TRANSFER_ORDER_USER");
+			String pass = Service.lookup(IPublicService.class).getSysParValue("TRANSFER_ORDER_PASS");
+			System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(requestBody));
+			String result = HttpPostUtil.sendPostRequest(url+"CGFH/MM858", requestBody, user, pass);
+			System.out.println(result);
 			//SAP销售订单号
 			String VBELN = "";
 			//获取订单信息
@@ -519,12 +528,8 @@ public class TransManageAction implements IMINAction{
 	@MINAction(value = SALE_ORDER_TRANSMISSION,session = false)
 	public MINActionResult saleOrderTransmission(
 			@MINParam(key ="orderId") String orderId,
-			@MINParam(key ="orderName") String orderName,
-			@MINParam(key ="legalContractNo") String legalContractNo,
-			@MINParam(key ="buyerErpCode") String buyerErpCode,
 			@MINParam(key ="buyerNameAll") String buyerNameAll,
 			@MINParam(key ="erpPostingDate") String erpPostingDate,
-			@MINParam(key ="contractType") String contractType,
 			@MINParam(key ="transferNum") String transferNum,
 			@MINParam(key ="preSettlement") String preSettlement,
 			@MINParam(key ="realPrice") String realPrice,
@@ -533,24 +538,19 @@ public class TransManageAction implements IMINAction{
 			@MINParam(key ="aoiTransferredNum") String aoiTransferredNum,
 			@MINParam(key ="aoiRemainingTransNum") String aoiRemainingTransNum
 			) throws MINBusinessException{
+		ApOrderInf order = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApOrderInfMapper.class).selectByPrimaryKey(orderId);
+		String contractId = order.getContractId();
+		ApContractInf contractInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApContractInfMapper.class).selectByPrimaryKey(contractId);
+		String buyerId = contractInf.getBuyerId();
+		ApCompanyInf companyInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApCompanyInfMapper.class).selectByPrimaryKey(buyerId);
 		
-		if(CommonUtil.isEmpty(orderName)){
-			throw new MINBusinessException("订单名称不可为空!");
-		}
-		
-		if(CommonUtil.isEmpty(legalContractNo)){
-			throw new MINBusinessException("法务合同号不可为空!");
-		}
-		if(CommonUtil.isEmpty(buyerErpCode)){
-			throw new MINBusinessException("客户编码不可为空!");
-		}
-		
+		String orderName = order.getName();
+		String legalContractNo = contractInf.getLegalContractNo();
+		String buyerErpCode = companyInf.getErpCode();
+		String contractType = contractInf.getContractType();
 		if(CommonUtil.isEmpty(erpPostingDate)){
 			throw new MINBusinessException("ERP过账日期不可为空!");
 		}
-		if(CommonUtil.isEmpty(contractType)){
-			throw new MINBusinessException("合同类型不可为空!");
-		}
 		//查询铝锭产品信息  --上海铝锭
 		ApProductInf productInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ApProductInfMapper.class).selectByPrimaryKey("O100000073");
 		if(productInf == null){
@@ -640,10 +640,15 @@ public class TransManageAction implements IMINAction{
 		itemMap.put("WERKS","2405");
 		//库存地点
 		itemMap.put("LGORT","A001");
+		list.add(itemMap);
 		try {
 			String url = Service.lookup(IPublicService.class).getSysParValue("TRANSFER_ORDER_URL");
+			String user = Service.lookup(IPublicService.class).getSysParValue("TRANSFER_ORDER_USER");
+			String pass = Service.lookup(IPublicService.class).getSysParValue("TRANSFER_ORDER_PASS");
 			//调用
-			HttpPostUtil.sendPostRequest(url, requestBody);
+			System.out.println(JSON.toJSONString(requestBody));
+			String result = HttpPostUtil.sendPostRequest(url+"XSFH/SD418", requestBody, user, pass);
+			System.out.println("result:======"+result);
 			//SAP销售订单号
 			String VBELN = "";
 			//获取订单信息
@@ -707,6 +712,11 @@ public class TransManageAction implements IMINAction{
 		return res;
 	}
 	
-	
-	
+	public static void main(String[] args) {
+		String header = "[{'EKORG':'2405','LIFNR':'0010010867','NAME1':'DTceshi47','TAXNUMXL':'1234648646416341AV','LAND1':'CN','ORT01':'120100','ORT02':'','EXTRA1':'DTCESHI47','EXTRA2':'DT','EXTRA3':'鍐?','EXTRA4':'MM','EXTRA5':''},{'EKORG':'2405','LIFNR':'0010010908','NAME1':'娴嬭瘯渚涘簲鍟嗛摑鐢?0919','TAXNUMXL':'9876543234567','LAND1':'CN','ORT01':'','ORT02':'','EXTRA1':'閾濈數001','EXTRA2':'QWE','EXTRA3':'鍐?','EXTRA4':'MM','EXTRA5':''}]";
+		JSONArray array = JSONArray.parseArray(header);
+		for(Object object : array) {
+			System.out.println(object.toString());
+		}
+	}
 }

+ 3 - 1
adm/src/main/webapp/admin/longcontractManage/longpcManage.html

@@ -408,7 +408,9 @@
 		        	dates :dates,
 		        	contractNo : contractNo,
 		        	createUser :createUser,
-		        	jiesuan : jiesuan
+		        	jiesuan : jiesuan,
+		        	type : type,
+		        	conType : conType
 		        }
 	      	});
 	}

+ 36 - 16
adm/src/main/webapp/admin/orderManage/transferDetail.html

@@ -81,6 +81,8 @@
        var realPrice;
        //采购销售 00采购01销售
        var conType;
+       // 订单id
+       var orderId;
        layui.use('form', function(){
     	    var rowData = layui.sessionData("ROW_DATA").NOW_ROW;
     	    layui.each(rowData, function(index, item){ 
@@ -101,6 +103,7 @@
     	    	$("#preSettlement").val(realPrice);
     	    }
     	    conType = rowData.conType;
+    	    orderId = rowData.orderId;
     	}); 
     	
        layui.use('laydate', function(){
@@ -148,25 +151,42 @@
             });
     		//监听提交
             form.on('submit(demo1)', function(data) {
+            	data.field.orderId = orderId;
             	if(conType == '00'){//采购
-            		
+	            	 $.request({
+						action : 'TransManageAction/purchaseOrderTransmission',
+						data :  data.field ,
+						success : function(data) {
+							 layer.alert('操作成功!',  function(){
+								 window.parent.location.reload(); 
+				                 parent. layer.close(layer.index);  
+							}); 	
+						},
+						error : function(data) {
+							 $.ErrorAlert(data.msg);
+						}
+					});	
+               		 return false;
             	}else if(conType == '01'){//销售
-            		
+            	     $.request({
+     					action : 'TransManageAction/saleOrderTransmission',
+     					data :  data.field ,
+     					success : function(data) {
+     						 layer.alert('保存成功!',  function(){
+     			                 window.parent.location.reload(); 
+     	  		                 parent.layer.close(layer.index);  
+     						});  	
+     					},
+     					error : function(data) {
+     						layer.alert(data.MINErrorMessage, {
+     	  						icon: 5,
+     	  						title: "提示"
+     	  					});
+     					}
+     				});	
+                    return false;	
             	}
-             /*  $.request({
-					action : 'ProductManageAction/modifyProduct',
-					data :  data.field ,
-					success : function(data) {
-						 layer.alert('操作成功!',  function(){
-							 window.parent.location.reload(); 
-			                 parent. layer.close(layer.index);  
-						}); 	
-					},
-					error : function(data) {
-						 $.ErrorAlert(data.msg);
-					}
-				});	
-                return false; */
+            
             });
     		
       });