Переглянути джерело

添加供应商条码上传接口

callm 5 днів тому
батько
коміт
b74ae683b7

+ 43 - 0
src/main/java/com/uas/eis/controller/MESHelperController.java

@@ -0,0 +1,43 @@
+package com.uas.eis.controller;
+
+import com.uas.eis.sdk.entity.ApiResult;
+import com.uas.eis.sdk.resp.ApiResponse;
+import com.uas.eis.service.MESHelperService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author xiaost
+ * @date 2022/8/16 11:35
+ **/
+@RestController
+@RequestMapping("/MES/helper")
+public class MESHelperController {
+    @Autowired
+    private MESHelperService mesHelperService;
+
+    @RequestMapping(value="/dllMain")
+    public ApiResult<List<Map<Object, Object>>> DLLMain(HttpServletRequest request, String data){
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        String accessKey = request.getHeader("AccessKey");
+        String requestId = request.getHeader("RequestId");
+        List<Map<Object, Object>> map = mesHelperService.DLLMain(accessKey,requestId,data);
+        Boolean err=false;
+        for (Map<Object, Object> map1 : map) {
+            if(map1.get("remark")!=null&&!map1.get("remark").equals("")){
+                err=true;
+            }
+        }
+        if(err){
+            return ApiResponse.FailRsp(requestId,map);
+        }else{
+            return ApiResponse.successRsp(requestId,map);
+        }
+    }
+}

+ 97 - 0
src/main/java/com/uas/eis/core/support/MesHelperApiLoginInterceptor.java

@@ -0,0 +1,97 @@
+package com.uas.eis.core.support;
+
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.dao.SqlRowList;
+import com.uas.eis.entity.ErrorMessage;
+import com.uas.eis.exception.ApiSystemException;
+import com.uas.eis.sdk.entity.ApiResult;
+import com.uas.eis.utils.MD5Util;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+@Service
+public class MesHelperApiLoginInterceptor extends HandlerInterceptorAdapter {
+
+    @Autowired
+    private BaseDao baseDao;
+
+    // 签名超时时长,默认时间为5分钟,ms
+    private static final int SIGN_EXPIRED_TIME = 60 * 60 * 1000;
+    private static final String ACCESS_KEY = "AccessKey";
+    private static final String ACCESS_SECRET = "AccessSecret";
+    private static final String TIMESTAMP_KEY = "Timestamp";
+    private static final String SIGN_KEY = "Signature";
+    private static final String RequestId = "RequestId";
+    private static Map<String,String> tokenConfig = TokenProperties.getAllProperty();
+
+
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String accessKey = request.getHeader(ACCESS_KEY);
+        String accessSecret = request.getHeader(ACCESS_SECRET);
+        String requestId = request.getHeader(RequestId);
+
+        // 检查KEY是否合理
+        if (StringUtils.isEmpty(accessKey) || StringUtils.isEmpty(accessSecret)) {
+            throw new ApiSystemException(new ApiResult(ErrorMessage.ACCESSKEY_ILLEGAL,requestId));
+        }
+
+        //改用中心账套表取账户密码
+        SqlRowList rs = baseDao.queryForRowSet("select AE_SECRET from APIEMPLOYEE where AE_KEY=?",accessKey);
+        if(rs.next()){
+            if(!accessSecret.equals(rs.getString("AE_SECRET"))) {
+                throw new ApiSystemException(new ApiResult(ErrorMessage.ACCESSSECRET_ERROR,requestId));
+            }
+        }else{
+            throw new ApiSystemException(new ApiResult(ErrorMessage.ACCESSKEY_ERROR,requestId));
+        }
+
+        return true;
+    }
+
+    private boolean verificationSign(HttpServletRequest request, String accessKey, String accessSecret) throws UnsupportedEncodingException {
+        Enumeration<?> pNames = request.getHeaderNames();
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put(ACCESS_KEY,request.getHeader(ACCESS_KEY));
+        params.put(RequestId,request.getHeader(RequestId));
+        params.put(TIMESTAMP_KEY,request.getHeader(TIMESTAMP_KEY));
+        String originSign = request.getHeader(SIGN_KEY);
+        String sign = createSign(params, accessSecret);
+        System.out.println(sign);
+
+        return sign.equals(originSign);
+    }
+
+    private String createSign(Map<String, Object> params, String accessSecret) throws UnsupportedEncodingException {
+        Set<String> keysSet = params.keySet();
+        Object[] keys = keysSet.toArray();
+        Arrays.sort(keys);
+        StringBuilder temp = new StringBuilder();
+        boolean first = true;
+        for (Object key : keys) {
+            if (first) {
+                first = false;
+            } else {
+                temp.append("&");
+            }
+            temp.append(key).append("=");
+            Object value = params.get(key);
+            String valueString = "";
+            if (null != value) {
+                valueString = String.valueOf(value);
+            }
+            temp.append(valueString);
+        }
+        temp.append("&").append(ACCESS_SECRET).append("=").append(accessSecret);
+        System.out.println(temp);
+        System.out.println(MD5Util.encrypt32Up(temp.toString()));
+       // System.out.println(MD5Util.getEncryption(temp.toString()));
+        return MD5Util.encrypt32Up(temp.toString()).toUpperCase();
+    }
+}

+ 6 - 1
src/main/java/com/uas/eis/entity/ErrorMessage.java

@@ -13,7 +13,12 @@ public enum ErrorMessage {
     TIMEOUT_ILLEGAL("1003","请求超时"),
     REQUESTID_ILLEGAL("1004","随机字符串不合法"),
     SIGNATURE_ILLEGAL("1005","签名错误"),
-    BUSINESS_ILLEGAL("2001","业务异常");
+    BUSINESS_ILLEGAL("2001","业务异常"),
+    BUSINESS_TYPENULL("2002","类型不能为空"),
+    BUSINESS_TYPEILLEGAL("2003","类型不在范围内"),
+    BUSINESS_DATAILLEGAL("2004","业务数据为空"),
+    ACCESSSECRET_ERROR("1002","密码不正确"),
+    ACCESSKEY_ERROR("1001","用户名不存在");
 
     private String code;
     private String message;

+ 50 - 0
src/main/java/com/uas/eis/entity/HelperType.java

@@ -0,0 +1,50 @@
+package com.uas.eis.entity;
+
+/**
+ * Created by xiaost 2022-08-17
+ * MES对接写号定义类型与代码
+ */
+public enum HelperType {
+    UploadBaraccept("UploadBaraccept","上传条码数据") , //上传条码数据
+    GetPuOrder("GetPuOrder","获取采购单信息") , //上传条码数据
+    GetBaraccept("GetBaraccept","生成送货通知单号") ; //生成送货通知单号
+
+    private String code;
+    private String name;
+
+    HelperType(String  code, String name){
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code 获取 类型
+     * @param code
+     * @return
+     */
+    public static HelperType getTypeByCode(String code){
+        for (HelperType helperType:values()) {
+            if (helperType.getCode().equals(code)) {
+                return helperType;
+            }
+        }
+        return null;
+    }
+
+}

+ 20 - 0
src/main/java/com/uas/eis/sdk/entity/ApiResult.java

@@ -1,5 +1,6 @@
 package com.uas.eis.sdk.entity;
 
+import com.uas.eis.entity.ErrorMessage;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -70,4 +71,23 @@ public class ApiResult<T> {
                 ", data=" + data +
                 '}';
     }
+
+    public ApiResult(String code, String message,String requestId,T data){
+        this.code = code;
+        this.message = message;
+        this.requestId = requestId;
+        this.data = data;
+    }
+
+    public ApiResult(String code, String message,String requestId){
+        this.code = code;
+        this.message = message;
+        this.requestId = requestId;
+    }
+
+    public ApiResult(ErrorMessage errorMessage, String requestId){
+        this.code = errorMessage.getCode();
+        this.message = errorMessage.getMessage();
+        this.requestId = requestId;
+    }
 }

+ 7 - 0
src/main/java/com/uas/eis/sdk/resp/ApiResponse.java

@@ -33,6 +33,13 @@ public class ApiResponse {
         return new ApiResult<T>().setCode(code).setMessage(msg).setRequestId(requestId).setData(data);
     }
 
+    public static <T> ApiResult<T> successRsp(String requestId,T data) {
+        return successRsp("0",SUCCESS,requestId,data);
+    }
+
+    public static <T> ApiResult<T> FailRsp(String requestId,T data) {
+        return successRsp("0","fail",requestId,data);
+    }
 
     public static <T> ApiResult<T> failRsp(String code, String msg) {
         return new ApiResult<T>().setCode(code).setMessage(msg);

+ 9 - 0
src/main/java/com/uas/eis/service/MESHelperService.java

@@ -0,0 +1,9 @@
+package com.uas.eis.service;
+
+import java.util.List;
+import java.util.Map;
+
+public interface MESHelperService {
+
+	List<Map<Object, Object>> DLLMain(String accessKey, String requestId, String data);
+}

+ 334 - 0
src/main/java/com/uas/eis/serviceImpl/MESHelperServiceImpl.java

@@ -0,0 +1,334 @@
+package com.uas.eis.serviceImpl;
+
+import com.uas.eis.core.config.SpObserver;
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.dao.SqlRowList;
+import com.uas.eis.entity.ErrorMessage;
+import com.uas.eis.entity.HelperType;
+import com.uas.eis.exception.ApiSystemException;
+import com.uas.eis.sdk.entity.ApiResult;
+import com.uas.eis.service.MESHelperService;
+import com.uas.eis.utils.*;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class MESHelperServiceImpl implements MESHelperService {
+
+	@Autowired
+	private BaseDao baseDao;
+
+	@Value("${spring.datasource.username}")
+	private String username;
+
+	@Override
+	public List<Map<Object, Object>> DLLMain(String accessKey, String requestId, String data) {
+		String AE_MASTER = checkAccessKey(accessKey, requestId);
+		SpObserver.putSp(AE_MASTER);
+		Map<Object, Object> map = BaseUtil.parseFormStoreToMap(data);
+		//解析map
+		if(!StringUtil.hasText(map.get("type"))){
+			throw new ApiSystemException(new ApiResult(ErrorMessage.BUSINESS_TYPENULL,requestId));
+		}
+		if(!StringUtil.hasText(map.get("detail"))){
+			throw new ApiSystemException(new ApiResult(ErrorMessage.BUSINESS_DATAILLEGAL,requestId));
+		}
+		String type = map.get("type").toString();
+		HelperType helperType = HelperType.getTypeByCode(type);
+		if(null == helperType){
+			throw new ApiSystemException(new ApiResult(ErrorMessage.BUSINESS_TYPEILLEGAL,requestId));
+		}
+		int err = 0;
+		//返回值
+		List<Map<Object, Object>> remap = new ArrayList<>();
+		switch(helperType){
+			case UploadBaraccept:
+				remap = UploadBaraccept(map.get("detail").toString());
+				break;
+			case GetBaraccept:
+				remap = GetBaraccept(map.get("detail").toString());
+				break;
+			case GetPuOrder:
+				remap = GetPuOrder(map.get("detail").toString());
+				break;
+			default:
+				err = -1;
+				break;
+		}
+		if(err == -1){
+			throw new ApiSystemException(new ApiResult(ErrorMessage.BUSINESS_TYPEILLEGAL,requestId));
+		}
+		SpObserver.putSp(username);
+		return remap;
+	}
+
+	private List<Map<Object, Object>> UploadBaraccept(String data)
+	{
+		List<Map<Object, Object>> maps = BaseUtil.parseGridStoreToMaps(data);
+		List<Map<Object, Object>> relist = new ArrayList<>();
+        SqlRowList rs=null;
+        String remark = "";
+		for (Map<Object, Object> map : maps) {
+
+			Map<Object, Object> remap = new HashMap<>();
+			if(map.size()==0){
+				remark = "参数不完整,请检查";
+				remap.put("remark",remark);
+				relist.add(remap);
+				continue;
+			}
+
+			rs=baseDao.queryForRowSet("select ban_id from baracceptnotify where ban_barcode='"+map.get("ban_barcode")+"'");
+			map.put("ban_id",baseDao.getSeqId("baracceptnotify_seq"));
+			if(rs.next()){
+				remark = "["+map.get("ban_barcode")+"]重复";
+				remap.put("remark",remark);
+			}else{
+				try {
+					String sql=SqlUtil.getInsertSqlByMap(map,"BARACCEPTNOTIFY");
+					baseDao.execute(SqlUtil.getInsertSqlByMap(map,"BARACCEPTNOTIFY"));
+					remap.put("result","["+map.get("ban_barcode").toString()+"]OK");
+					remap.put("remark",remark);
+				}catch (Exception e){
+					remap.put("result","NG");
+					remap.put("remark",e.getMessage());
+					e.printStackTrace();
+				}
+			}
+			relist.add(remap);
+		}
+		return relist;
+	}
+
+	private List<Map<Object, Object>> GetPuOrder(String data){
+		Map<Object, Object> map = BaseUtil.parseFormStoreToMap(data);
+		String pucode=map.get("pucode").toString();
+		SqlRowList rs=baseDao.queryForRowSet("select pu_code,pd_detno,pd_prodcode,nvl(pd_qty,0)pd_qty,nvl(pd_yqty,0)pd_yqty,nvl(pd_acceptqty,0)pd_acceptqty from purchase left join purchasedetail on pu_id=pd_puid where pu_code='"+pucode+"' and pu_vendcode='001.003'");
+		List<Map<Object, Object>> relist = new ArrayList<>();
+		while (rs.next()){
+			Map<Object, Object> remap = new HashMap<>();
+			remap.put("pu_code",rs.getString("pu_code"));
+			remap.put("pd_detno",rs.getString("pd_detno"));
+			remap.put("pd_prodcode",rs.getString("pd_prodcode"));
+			remap.put("pd_qty",rs.getString("pd_qty"));
+			remap.put("pd_yqty",rs.getString("pd_yqty"));
+			remap.put("pd_acceptqty",rs.getString("pd_acceptqty"));
+			relist.add(remap);
+		}
+		return relist;
+	}
+
+	private List<Map<Object, Object>> GetBaraccept(String data)
+	{
+		Map<Object, Object> map = BaseUtil.parseFormStoreToMap(data);
+		Map<Object, Object> remap = new HashMap<>();
+		List<Map<Object, Object>> relist = new ArrayList<>();
+		String code=baseDao.sGetMaxNumber("VendAcceptNotify",0);
+		String sendcode=map.get("sendcode").toString();
+		SqlRowList rs=baseDao.queryForRowSet("select an_code from AcceptNotify where an_sendcode='"+sendcode+"'");
+		if(rs.next()){
+			remap.put("result","NG");
+			remap.put("remark","["+sendcode+"]已经生成单据["+rs.getString("an_code")+"]");
+			relist.add(remap);
+			return relist;
+		}
+		rs=baseDao.queryForRowSet("select ban_id from baracceptnotify where ban_sendcode='"+sendcode+"'");
+		if(rs.next()){
+			int an_id=baseDao.getSeqId("AcceptNotify_seq");
+			baseDao.execute("insert into AcceptNotify(AN_ID, AN_CODE, AN_DATE, AN_VENDCODE,AN_VENDNAME, AN_BUYERID, AN_CURRENCY, AN_RATE, AN_RECORDER, AN_INDATE, AN_STATUSCODE, AN_STATUS, AN_SOURCE," +
+					"AN_PAYMENTCODE, AN_PAYMENT, AN_BUYER, AN_SENDCODE, AN_SENDSTATUS, AN_RECEIVECODE, AN_RECEIVENAME)" +
+					"select '"+an_id+"',A.* from (select '"+code+"' an_code,sysdate AN_DATE,max(pu_vendcode),max(pu_vendname) ,max(ve_id),max(purchase.PU_CURRENCY),max(purchase.PU_RATE),max(ve_shortname)||'@vendor'," +
+					"sysdate AN_indate,'ENTERING','在录入','VENDOR',max(PU_PAYMENTSCODE),max(PU_PAYMENTS),max(pu_buyername),'"+map.get("sendcode")+"' an_sendcode,'待上传',max(ve_code),max(ve_name) from BARACCEPTNOTIFY " +
+					"left join purchase on ban_pucode=pu_code left join product on pr_code=ban_prodcode left join vendor on ve_code=pu_vendcode where ban_sendcode='"+sendcode+"' )A");
+
+			baseDao.execute("insert into ACCEPTNOTIFYDETAIL(AND_ID, AND_ANID, AND_DETNO, AND_ORDERID, AND_ORDERCODE, AND_ORDERDETNO, AND_PRODCODE, AND_INQTY)" +
+					"select ACCEPTNOTIFYDETAIL_seq.nextval,"+an_id+",rownum,A.* from (select max(pd_id),ban_pucode,ban_pudetno,ban_prodcode,sum(ban_qty) from BARACCEPTNOTIFY " +
+					"left join purchase on ban_pucode=pu_code left join purchasedetail on pu_id=pd_puid and ban_pudetno=pd_detno left join product on pr_code=ban_prodcode where ban_sendcode='"+sendcode+"' group by ban_prodcode,ban_pudetno,ban_pucode)A");
+
+			baseDao.execute("update BARACCEPTNOTIFY set (ban_anid,BAN_ANCODE, BAN_ANDID, BAN_ANDDETNO)=(select max(an_id),max(an_code),max(and_id),max(and_detno) from ACCEPTNOTIFYDETAIL " +
+					"left join ACCEPTNOTIFY on and_anid=an_id where an_sendcode=ban_sendcode " +
+					"and and_prodcode=ban_prodcode and ban_pudetno=and_orderdetno and and_ordercode=ban_pucode group by ban_pudetno) where ban_sendcode='"+sendcode+"'");
+			String errMsg=submit("VendAcceptNotify",an_id);
+			if(!errMsg.equals("")){
+				remap.put("result","NG");
+				remap.put("remark",errMsg);
+				relist.add(remap);
+				//如果单据有异常清除条码
+				delete("VendAcceptNotify",an_id);
+				return relist;
+			}
+			baseDao.execute("update acceptNotify set an_status='已审核',an_statuscode='AUDITED' where an_id="+an_id);
+			remap.put("result","生成单据成功");
+			remap.put("code",code);
+			relist.add(remap);
+		}else{
+			remap.put("result","NG");
+			remap.put("remark","单据["+sendcode+"]未上传条码");
+			relist.add(remap);
+			return relist;
+		}
+		return relist;
+	}
+
+	public String submit(String caller, int id) {
+		String ErrMsg="";
+		boolean bool = baseDao.isDBSetting("BarCodeSetting", "unLimitSendQty");
+		Object status = baseDao.getFieldDataByCondition("acceptNotify", "an_statuscode", "an_id=" + id);
+		Object[] sendcode = baseDao.getFieldsDataByCondition("acceptNotify", "an_sendcode,an_remark", "an_id=" + id);
+		if (sendcode[0] == null || sendcode[0].equals("")) {
+			return ErrMsg="送货通知单号不允许为空";
+		}
+		if (baseDao.getCount("select 1 from acceptNotify where an_sendcode='" + sendcode + "'") > 1) {
+			return ErrMsg="送货单号" + sendcode + "不允许重复";
+		}
+		SqlRowList rs = null;
+		//通知单数量不能大于采购单数量-已转通知数之和
+		if (!bool) {
+			Double wqty = 0.0, and_qty = 0.0;
+			SqlRowList rsXq = baseDao.queryForRowSet(" select nvl(pd_qty,0)-nvl(pd_yqty,0) wqty,nvl(and_inqty,0) and_inqty from purchasedetail left join acceptnotifydetail on and_ordercode = pd_code "
+					+ " and and_orderdetno = pd_detno where and_anid = ? and nvl(pd_qty,0)-nvl(pd_yqty,0)>0 and  nvl(pd_qty,0)-nvl(pd_yqty,0)-nvl(and_inqty,0)<0", id);
+			if (rsXq.next()) {
+				wqty = rsXq.getDouble("wqty");
+				and_qty = rsXq.getDouble("and_inqty");
+			}
+			rs = baseDao.queryForRowSet("select wm_concat(and_detno) and_detno from acceptNotifydetail where and_anid = ? and exists (select 1 from purchasedetail "
+					+ "	where pd_code = and_ordercode and pd_detno = and_orderdetno and (pd_qty - nvl(pd_yqty,0)) < nvl(and_inqty,0)) ", id);
+			if (rs.next() && rs.getString("and_detno") != null) {
+				return ErrMsg="未交数量不能大于本批数量.<br>序号" + rs.getString("and_detno") + (wqty > 0 ? (":待交数" + wqty) : "") + (and_qty > 0 ? ("本批数量" + and_qty + ".") : "");
+			}
+		}
+		rs = baseDao.queryForRowSet("select wm_concat(and_detno) and_detno from acceptNotifydetail left join purchasedetail on pd_code = and_ordercode and pd_detno = and_orderdetno left join purchase on pd_puid = pu_id "
+				+ " where and_anid ='"+id+"' and not exists(select 1 from acceptnotify where nvl(an_vendcode, ' ') = nvl(pu_vendcode,' ') and  nvl(an_vendname,' ') = nvl(pu_vendname,' ') and nvl(an_currency,' ') = nvl(pu_currency,' ') and nvl(pu_buyername,' ') = nvl(an_buyer,' ') and nvl(pu_payments,' ') = nvl(an_payment,' ') and nvl(pu_receivename,' ') = nvl(an_receivename,' ') and an_id='"+id+"')");
+		/*if (rs.next() && rs.getString("and_detno") != null) {
+			return ErrMsg="请检查采购单+序号对应的供应编号、应付供应商、币别、采购员、付款方式、应付供应商是否和主表一致,序号" + rs.getString("and_detno");
+		}*/
+		/*rs = baseDao.queryForRowSet("select wm_concat(and_detno) and_detno from acceptnotifydetail where and_anid =? and and_barqty>0 and nvl(and_barqty,0)<>nvl(and_inqty,0)",id);
+		if (rs.next() && rs.getString("and_detno") != null){
+			BaseUtil.showError("序号"+rs.getString("and_detno")+"存在条码,条码数量不等于采购数量");
+		}*/
+		rs = baseDao.queryForRowSet("select wm_concat(and_detno)and_detno from (select max(AND_INQTY)AND_INQTY,nvl(sum(ban_qty),0)ban_qty,and_detno from  acceptnotifydetail " +
+				"left join BARACCEPTNOTIFY on ban_andid=and_id where and_anid =?  group by and_detno) where AND_INQTY<>ban_qty", id);
+		if (rs.next() && rs.getString("and_detno") != null) {
+			return ErrMsg="序号" + rs.getString("and_detno") + "条码数量不等于采购数量";
+		}
+		rs = baseDao.queryForRowSet("select wm_concat(and_detno) and_detno from acceptnotifydetail left join product on pr_code = and_prodcode where and_anid =? and nvl(pr_tracekind,0) <> 0 and nvl(and_barqty,0) = 0", id);
+		if (rs.next() && rs.getString("and_detno") != null) {
+			return ErrMsg="序号" + rs.getString("and_detno") + "是管控物料,条码数量不允许为0";
+		}
+		//updatePrice(id);
+		// 判断是否超采购数收料
+		if (!bool) {
+			checkQty(id);
+		}
+		// 判断批号是否重复
+		String errRows = baseDao
+				.getJdbcTemplate()
+				.queryForObject(
+						"select wmsys.wm_concat(and_detno) from acceptnotifydetail where and_anid=? and (and_batchcode,and_prodcode,and_whcode) in (select and_batchcode,and_prodcode,and_whcode from (select count(1) c, and_batchcode,and_prodcode,and_whcode from acceptnotifydetail where (and_batchcode,and_prodcode,and_whcode) in (select and_batchcode,and_prodcode,and_whcode from acceptnotifydetail where and_anid=?) group by and_batchcode,and_prodcode,and_whcode) where c > 1)",
+						String.class, id, id);
+		if (errRows != null) {
+			return ErrMsg="批号重复,行:" + errRows;
+		} else {
+			errRows = baseDao
+					.getJdbcTemplate()
+					.queryForObject(
+							"select wmsys.wm_concat(and_detno) from acceptnotifydetail where and_anid=? and (and_batchcode,and_prodcode,and_whcode) in (select ba_code,ba_prodcode,ba_whcode from batch)",
+							String.class, id);
+			if (errRows != null) {
+				return ErrMsg="批号重复,行:" + errRows;
+			}
+		}
+		String notEnoughSale = baseDao
+				.getJdbcTemplate()
+				.queryForObject(
+						"select wmsys.wm_concat('<br>行:'||and_detno||',PO数:'||nvl(pd_qty,0)||',通知单已提交数:'||nvl(and_commitedqty,0)||',本次数:'||nvl(and_inqty,0)) from (select and_detno,and_inqty,(select sum(nvl(and_inqty,0)) from acceptnotifydetail left join acceptnotify on an_id=and_anid where and_ordercode=A.and_ordercode and and_orderdetno=A.and_orderdetno and an_statuscode<>'ENTERING') and_commitedqty,nvl(pd_qty,0)+nvl(pd_backqty,0) pd_qty from acceptnotifydetail A left join purchasedetail on pd_code=and_ordercode and pd_detno=and_orderdetno where and_anid=?) where nvl(pd_qty,0)<nvl(and_commitedqty,0)+nvl(and_inqty,0)",
+						String.class, id);
+		if (notEnoughSale != null && !bool) {
+			return ErrMsg="数量超过了PO数量,提交失败:<br>" + notEnoughSale;
+		}
+		baseDao.execute("update acceptNotify set an_status='已提交',an_statuscode='COMMITED' where an_id="+id);
+		return ErrMsg;
+	}
+
+	public void delete(String caller, int id) {
+
+		//删除Dispatch
+		baseDao.deleteById("acceptNotify", "an_id", id);
+		//删除DispatchDetail
+		baseDao.deleteById("acceptNotifyDetail", "and_anid", id);
+		//删除DispatchDetail
+		/*baseDao.deleteById("baracceptNotify", "ban_anid", id);*/
+		baseDao.deleteByCondition("baracceptNotify", " ban_anid = " + id + "and nvl(ban_pdid,0)=0");
+	}
+
+	public void confirmDelivery(String caller, int id) {
+		// 只能对状态为[已提交]的订单进行审核操作!
+		Object status = baseDao.getFieldDataByCondition("AcceptNotify", "an_statuscode", "an_id=" + id);
+		int count = baseDao.getCount("select count(1) cn from baracceptnotify where ban_anid = " + id + " and nvl(ban_printstatus,0) <> -1");
+		if (count > 0) {
+			//BaseUtil.showError("存在条码未打印,不允许确认送货");
+		}
+		// 执行审核操作
+		//baseDao.audit("AcceptNotify", "an_id=" + id, "an_status", "an_statuscode");
+		// 记录操作
+		//baseDao.logger.audit(caller, "an_id", id);
+	}
+
+	/**
+	 * 判断是否超采购数收料
+	 *
+	 * @author yingp 2013-4-17 9:08:59
+	 */
+	public void checkQty(int id) {
+		SqlRowList rs = baseDao.queryForRowSet(
+				"SELECT and_ordercode,and_orderdetno,sum(and_inqty) and_inqty FROM AcceptNotifyDetail where and_anid=? group by and_ordercode,and_orderdetno",
+				id);
+		String code = null;
+		int detno = 0;
+		Object count = null;
+		boolean bool = false;
+		StringBuffer sb = new StringBuffer();
+		while (rs.next()) {
+			code = rs.getString("and_ordercode");
+			detno = rs.getInt("and_orderdetno");
+			count = baseDao.getFieldDataByCondition("AcceptNotifyDetail left join AcceptNotify on an_id=and_anid", "sum(and_inqty)",
+					"and_ordercode='" + code + "' and and_orderdetno=" + detno + " and an_statuscode in('AUDITED','TURNIN') and and_anid<>"
+							+ id);
+			if (count != null) {
+				bool = baseDao.checkByCondition("PurchaseDetail", "pd_code='" + code + "' and pd_detno=" + detno
+						+ " and nvl(pd_qty,0)+nvl(pd_backqty,0)<" + (Double.parseDouble(count.toString()) + rs.getDouble("and_inqty")));
+				if (!bool) {
+					sb.append("<br>");
+					sb.append("不能超采购数量收料,采购单号[");
+					sb.append(code);
+					sb.append("],明细行号[");
+					sb.append(detno);
+					sb.append("]");
+				}
+			}
+		}
+		if (sb.length() > 0) {
+			BaseUtil.showError(sb.toString());
+		}
+	}
+
+	private String checkAccessKey(String accessKey,String requestId){
+		Object accessSecret_O = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_SECRET", "AE_KEY='" + accessKey + "'");
+		Object AE_MASTER = baseDao.getFieldDataByCondition("APIEMPLOYEE", "AE_MASTER", "AE_KEY='" + accessKey + "'");
+		String accessSecret = accessSecret_O == null ? "" : accessSecret_O.toString();
+		// 检查KEY是否合理
+		if (StringUtils.isEmpty(accessKey) || StringUtils.isEmpty(accessSecret) || AE_MASTER== null || "".equals(AE_MASTER.toString())) {
+			ApiResult apiResult = new ApiResult(ErrorMessage.ACCESSKEY_ILLEGAL.getCode(),ErrorMessage.ACCESSKEY_ILLEGAL.getMessage(),requestId);
+			throw new ApiSystemException(apiResult);
+		}
+		return AE_MASTER.toString();
+	}
+}

+ 2 - 2
src/main/resources/application-dev.yml

@@ -4,7 +4,7 @@ spring:
         driverClassName: oracle.jdbc.OracleDriver
         username: STW_TEST
         password: select!#%*(
-        url: jdbc:oracle:thin:@127.0.0.1:1521:orcl
+        url: jdbc:oracle:thin:@10.1.81.208:11559:orcl
         initialSize: 1
         maxActive: 3
         maxWait: 30000
@@ -23,7 +23,7 @@ server:
         uri_encoding: UTF-8
     context-path:
         /eis
-    port: 8186
+    port: 8900
 
 action:
     api_action: /EIS/api,/EIS/mes,/EIS/erp

+ 2 - 2
src/main/resources/application-prod.yml

@@ -4,7 +4,7 @@ spring:
         driverClassName: oracle.jdbc.OracleDriver
         username: STW_TEST
         password: select!#%*(
-        url: jdbc:oracle:thin:@127.0.0.1:1521:orcl
+        url: jdbc:oracle:thin:@10.1.81.208:11559:orcl
         initialSize: 1
         maxActive: 3
         maxWait: 30000
@@ -23,7 +23,7 @@ server:
         uri_encoding: UTF-8
     context-path:
         /EIS
-
+    port: 8900
 action:
     api_action: /EIS/api,/EIS/mes,/EIS/erp
     public_actions: /EIS/logout,/EIS/hello1