callm 2 лет назад
Родитель
Сommit
c5e290b440
1 измененных файлов с 34 добавлено и 18 удалено
  1. 34 18
      src/main/java/com/uas/eis/serviceImpl/MESHelperServiceImpl.java

+ 34 - 18
src/main/java/com/uas/eis/serviceImpl/MESHelperServiceImpl.java

@@ -126,7 +126,16 @@ public class MESHelperServiceImpl implements MESHelperService {
 			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 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);
@@ -139,18 +148,16 @@ public class MESHelperServiceImpl implements MESHelperService {
 		return relist;
 	}
 
-	public void submit(String caller, int id) {
+	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("")) {
-			BaseUtil.showError("送货通知单号不允许为空");
-		}
-		if (sendcode[1] == null || sendcode[1].equals("")) {
-			BaseUtil.showError("本批交货箱数不允许为空");
+			return ErrMsg="送货通知单号不允许为空";
 		}
 		if (baseDao.getCount("select 1 from acceptNotify where an_sendcode='" + sendcode + "'") > 1) {
-			BaseUtil.showError("送货单号" + sendcode + "不允许重复");
+			return ErrMsg="送货单号" + sendcode + "不允许重复";
 		}
 		SqlRowList rs = null;
 		//通知单数量不能大于采购单数量-已转通知数之和
@@ -165,13 +172,13 @@ public class MESHelperServiceImpl implements MESHelperService {
 			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 + ".") : ""));
+				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) {
-			BaseUtil.showError("请检查采购单+序号对应的供应编号、应付供应商、币别、采购员、付款方式、应付供应商是否和主表一致,序号" + rs.getString("and_detno"));
+			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){
@@ -180,11 +187,11 @@ public class MESHelperServiceImpl implements MESHelperService {
 		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") + "条码数量不等于采购数量");
+			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) {
-			BaseUtil.showError("序号" + rs.getString("and_detno") + "是管控物料,条码数量不允许为0");
+			return ErrMsg="序号" + rs.getString("and_detno") + "是管控物料,条码数量不允许为0";
 		}
 		//updatePrice(id);
 		// 判断是否超采购数收料
@@ -198,7 +205,7 @@ public class MESHelperServiceImpl implements MESHelperService {
 						"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);
+			return ErrMsg="批号重复,行:" + errRows;
 		} else {
 			errRows = baseDao
 					.getJdbcTemplate()
@@ -206,7 +213,7 @@ public class MESHelperServiceImpl implements MESHelperService {
 							"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);
+				return ErrMsg="批号重复,行:" + errRows;
 			}
 		}
 		String notEnoughSale = baseDao
@@ -215,12 +222,21 @@ public class MESHelperServiceImpl implements MESHelperService {
 						"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);
+			return ErrMsg="数量超过了PO数量,提交失败:<br>" + notEnoughSale;
 		}
-		// 执行提交操作
-		//baseDao.submit("acceptNotify", "an_id=" + id, "an_status", "an_statuscode");
-		// 记录操作
-		//baseDao.logger.submit(caller, "an_id", id);
+		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) {