Explorar el Código

接口调整,数据上传

callm hace 2 años
padre
commit
3bf1c8af8e
Se han modificado 1 ficheros con 149 adiciones y 20 borrados
  1. 149 20
      src/main/java/com/uas/eis/serviceImpl/MESHelperServiceImpl.java

+ 149 - 20
src/main/java/com/uas/eis/serviceImpl/MESHelperServiceImpl.java

@@ -42,7 +42,6 @@ public class MESHelperServiceImpl implements MESHelperService {
 			throw new ApiSystemException(new ApiResult(ErrorMessage.BUSINESS_DATAILLEGAL,requestId));
 		}
 		String type = map.get("type").toString();
-		JSONObject json = JSONObject.fromObject(map.get("detail"));
 		HelperType helperType = HelperType.getTypeByCode(type);
 		if(null == helperType){
 			throw new ApiSystemException(new ApiResult(ErrorMessage.BUSINESS_TYPEILLEGAL,requestId));
@@ -52,10 +51,10 @@ public class MESHelperServiceImpl implements MESHelperService {
 		List<Map<Object, Object>> remap = new ArrayList<>();
 		switch(helperType){
 			case UploadBaraccept:
-				remap = UploadBaraccept(data);
+				remap = UploadBaraccept(map.get("detail").toString());
 				break;
 			case GetBaraccept:
-				remap = GetBaraccept(data);
+				remap = GetBaraccept(map.get("detail").toString());
 				break;
 			default:
 				err = -1;
@@ -76,21 +75,21 @@ public class MESHelperServiceImpl implements MESHelperService {
 			Map<Object, Object> remap = new HashMap<>();
 			String remark = "";
 			SqlRowList rs=baseDao.queryForRowSet("select ban_id from baracceptnotify where ban_barcode='"+map.get("ban_barcode")+"'");
-			remap.put("ban_id",baseDao.getSeqId("baracceptnotify_seq"));
-			if(rs.hasNext()){
-				remark = "重复";
+			map.put("ban_id",baseDao.getSeqId("baracceptnotify_seq"));
+			if(rs.next()){
+				remark = "["+map.get("ban_barcode")+"]重复";
 				remap.put("remark",remark);
-				relist.add(remap);
-				return relist;
-			}
-			try {
-				baseDao.execute(SqlUtil.getInsertSqlByMap(map,"BARACCEPTNOTIFY"));
-				remap.put("result","OK");
-				remap.put("remark",remark);
-			}catch (Exception e){
-				remap.put("result","NG");
-				remap.put("remark",e.getMessage());
-				e.printStackTrace();
+			}else{
+				try {
+					String sql=SqlUtil.getInsertSqlByMap(map,"BARACCEPTNOTIFY");
+					baseDao.execute(SqlUtil.getInsertSqlByMap(map,"BARACCEPTNOTIFY"));
+					remap.put("result","["+map.get("ban_barcode")+"]OK");
+					remap.put("remark",remark);
+				}catch (Exception e){
+					remap.put("result","NG");
+					remap.put("remark",e.getMessage());
+					e.printStackTrace();
+				}
 			}
 			relist.add(remap);
 		}
@@ -126,7 +125,140 @@ public class MESHelperServiceImpl implements MESHelperService {
 		return relist;
 	}
 
+	public void submit(String caller, int id) {
+		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("")) {
+			BaseUtil.showError("送货通知单号不允许为空");
+		}
+		if (sendcode[1] == null || sendcode[1].equals("")) {
+			BaseUtil.showError("本批交货箱数不允许为空");
+		}
+		if (baseDao.getCount("select 1 from acceptNotify where an_sendcode='" + sendcode + "'") > 1) {
+			BaseUtil.showError("送货单号" + 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) {
+				BaseUtil.showError("未交数量不能大于本批数量.<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) {
+			BaseUtil.showError("请检查采购单+序号对应的供应编号、应付供应商、币别、采购员、付款方式、应付供应商是否和主表一致,序号" + 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) {
+			BaseUtil.showError("序号" + 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) {
+			BaseUtil.showError("序号" + 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) {
+			BaseUtil.showError("批号重复,行:" + 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) {
+				BaseUtil.showError("批号重复,行:" + 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) {
+			BaseUtil.showError("数量超过了PO数量,提交失败:<br>" + notEnoughSale);
+		}
+		// 执行提交操作
+		//baseDao.submit("acceptNotify", "an_id=" + id, "an_status", "an_statuscode");
+		// 记录操作
+		//baseDao.logger.submit(caller, "an_id", id);
+	}
+
+	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 + "'");
@@ -139,7 +271,4 @@ public class MESHelperServiceImpl implements MESHelperService {
 		}
 		return AE_MASTER.toString();
 	}
-
-
-
 }