Browse Source

指令下发

hu 4 days ago
parent
commit
55d7c21015

+ 15 - 0
src/custom/restcontroller/R.java

@@ -5787,6 +5787,21 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025060314132803 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025060314293003 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025060314341703 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 16 - 4
src/custom/restcontroller/webmanage/sale/stockbill/stockbill.java

@@ -304,8 +304,8 @@ public class stockbill extends Controller {
 
         Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
                 + st_stockbillid + "' and  siteid='" + siteid + "'");
-        Rows rowsdetail = dbConnect.runSqlQuery("select * from st_stockbill_items where st_stockbillid ='"
-                + st_stockbillid + "' and  siteid='" + siteid + "'");
+        Rows rowsdetail = dbConnect.runSqlQuery("select t1.*,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.st_stockbillid ='"
+                + st_stockbillid + "' and  t1.siteid='" + siteid + "'");
         long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
 
         if (rows.isEmpty()) {
@@ -366,6 +366,12 @@ public class stockbill extends Controller {
                 for (Row row : rowsDispatchDetailGroup) {
                     sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").subtract(row.getBigDecimal("qty")) + ",deliedqty=" + (row.getBigDecimal("qty").add(rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
                 }
+                for(Row row :rowsdetail){
+                    if(row.getBoolean("skucontrol")){
+                        sqlList.add("update st_stockbill_items set wmsuploadflag2=1 where st_stockbill_itemsid="+row.getLong("st_stockbill_itemsid"));
+                    }
+
+                }
             }
             for(Row row :rowsdetail){
                 String itemid= row.getString("itemid");
@@ -419,8 +425,8 @@ public class stockbill extends Controller {
 
         Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
                 + st_stockbillid + "' and  siteid='" + siteid + "'");
-        Rows rowsdetail = dbConnect.runSqlQuery("select * from st_stockbill_items where st_stockbillid ='"
-                + st_stockbillid + "' and  siteid='" + siteid + "'");
+        Rows rowsdetail = dbConnect.runSqlQuery("select t1.*,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.st_stockbillid ='"
+                + st_stockbillid + "' and  t1.siteid='" + siteid + "'");
         long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
 
         if (rows.isEmpty()) {
@@ -478,6 +484,12 @@ public class stockbill extends Controller {
                 for (Row row : rowsDispatchDetailGroup) {
                     sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
                 }
+                for(Row row :rowsdetail){
+                    if(row.getBoolean("skucontrol")){
+                        sqlList.add("update st_stockbill_items set wmsuploadflag2=0 where st_stockbill_itemsid="+row.getLong("st_stockbill_itemsid"));
+                    }
+
+                }
             }
             for(Row row :rowsdetail){
                 String itemid= row.getString("itemid");

+ 83 - 0
src/custom/restcontroller/webmanage/sale/wmssend/MqWms.java

@@ -0,0 +1,83 @@
+package restcontroller.webmanage.sale.wmssend;
+
+import common.YosException;
+import common.data.Row;
+import common.data.Rows;
+import common.data.db.DBConnect;
+import common.data.db.DBSource;
+
+import java.math.BigDecimal;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * 向中间表上传单据信息
+ *
+ * @author SJW
+ *
+ */
+public class MqWms {
+	private String SQL = null;
+
+	/**
+	 * 构造函数,初始化
+	 */
+	public MqWms() {
+
+	}
+
+	/**
+	 * 上传出库指令(销售出库)
+	 *
+	 *            出入库表体
+	 * @throws SQLException
+	 */
+	public void uploadOutStockbilldetail(Rows rows) throws YosException {
+		DBSource dbSource =new DBSource();
+		dbSource.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+		dbSource.setUrl("jdbc:sqlserver://192.168.130.71:1433;databasename=YUNL_DB");
+		dbSource.setUsername("sa");
+		dbSource.setPassword("p2admin");
+		DBConnect dbConnect =new DBConnect(dbSource);
+		DBConnect thisdbConnect =new DBConnect();
+		for(Row row :rows){
+			String fagentnum = row.getString("agentnum");
+			// String fagentname =
+			// parentpao.getPaoSet("tagents").getPao(0).getString("fagentname");
+			String abbreviation = row.getString("abbreviation");
+			String contact = row.getString("name");
+			String address =row.getString("address");
+			String phonenumber = row.getString("phonenumber");
+
+			String billno = row.getString("billno");
+			String rowno = row.getString("rowno");
+			String itemno = row.getString("itemno");
+			BigDecimal qty = row.getBigDecimal("qty");
+			SQL = "insert into Wms_Rdrecord32(cCode,rowno,cInvCode,iQuantity,dDate,fagentnum,fagentname,fcontact,fphonenumber,faddress,WMSstatus)";
+			SQL = SQL + " select ";
+			SQL = SQL + " '" + billno + "',";// 单据编号
+			SQL = SQL + " '" + rowno + "',";// 行号
+			SQL = SQL + " '" + itemno + "',";// 品号
+			SQL = SQL + " " + qty + ",";// 出库数量
+			SQL = SQL + " GETDATE(),";// 创建日期
+			SQL = SQL + " '" + fagentnum + "',";
+			SQL = SQL + " '" + abbreviation + "',";
+			SQL = SQL + " '" + contact + "',";
+			SQL = SQL + " '" + phonenumber + "',";
+			SQL = SQL + " '" + address + "',";
+			SQL = SQL + " 0 ";//
+
+			if (!SQL.equals("")) {
+				//dbConnect.runSqlUpdate(SQL);
+				thisdbConnect.runSqlUpdate("update st_stockbill_items set wmsuploadflag=2 where st_stockbill_itemsid="+row.getLong("st_stockbill_itemsid"));
+
+			}
+		}
+	}
+
+}

+ 408 - 0
src/custom/restcontroller/webmanage/sale/wmssend/Wms.java

@@ -0,0 +1,408 @@
+package restcontroller.webmanage.sale.wmssend;
+
+import common.YosException;
+import common.data.Row;
+import common.data.Rows;
+import common.data.db.DBConnect;
+import common.data.db.DBSource;
+
+import java.math.BigDecimal;
+import java.sql.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.*;
+
+/**
+ * 向中间表上传单据信息
+ *
+ * @author SJW
+ *
+ */
+public class Wms {
+	private String SQL = null;
+
+	/**
+	 * 构造函数,初始化
+	 */
+	public Wms() {
+
+	}
+
+	/**
+	 * 上传出库指令(销售出库)
+	 *
+	 *            出入库表头
+	 */
+	private int uploadOutStockbill(Row row, String username) throws YosException {
+		DBSource dbSource =new DBSource();
+		dbSource.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+		dbSource.setUrl("jdbc:sqlserver://192.168.0.98:1433;databasename=DB_meida");
+		dbSource.setUsername("sa");
+		dbSource.setPassword("omh_123");
+		DBConnect dbConnect =new DBConnect(dbSource);
+
+		int OutPlanID = 0;
+
+		// 更新表头
+		String billno = row.getString("billno");
+		String type = "1";// 1:销售出库 2:调拨出库 3:送件单 4:借出
+		String billdate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
+				.format(row.getString("billdate"));
+		String enterprisename = row.getString("enterprisename");
+		String abbreviation = row.getString("abbreviation");
+		String contact = row.getString("name");
+		String address =row.getString("address");
+		String phonenumber = row.getString("phonenumber");
+		SQL = "insert into TOutInt(BillNo,BillType,CreateDate,IsDeleted,OutDate,SellCompany,SellPerson,Selladdress,Sellphone,Status,createby,ShortName) ";
+		SQL = SQL + "values(";
+		SQL = SQL + "'" + billno + "',";// 出库单号
+		SQL = SQL + "'" + type + "',";// 出库类型
+		SQL = SQL + "GETDATE(),";// 创建日期
+		SQL = SQL + "0,";// 是否已删除
+		SQL = SQL + "'" + billdate + "',";// 出库日期,单据日期
+		SQL = SQL + "'" + enterprisename + "',";// 经销商名称
+		SQL = SQL + "'" + contact + "',";// 经销商联系人
+		SQL = SQL + "'" + address + "',";// 经销商地址
+		SQL = SQL + "'" + phonenumber + "',";// 联系方式
+		SQL = SQL + "0,";// 状态:0:WMS未处理 1:WMS正在出库 2:WMS出库完成 10:ERP出库完成
+		SQL = SQL + "'" + username + "',";
+		SQL = SQL + "'" + abbreviation + "')";// 经销商简称
+		if (!SQL.equals("")) {
+			dbConnect.runSqlUpdate(SQL);
+			Rows rows = dbConnect.runSqlQuery("select top(1) OutPlanID from TOutInt where BillNo='"
+					+ billno + "' order by CreateDate desc ");
+
+			if (rows.isNotEmpty()) {
+				OutPlanID = rows.get(0).getInteger("OutPlanID");
+			}
+		}
+
+		return OutPlanID;
+	}
+
+	/**
+	 * 上传出库指令(销售出库)
+	 *
+	 *            出入库表体
+	 * @throws SQLException
+	 */
+	public void uploadOutStockbilldetail(Rows rows, String username) throws YosException {
+		HashMap<String, Integer> map = new HashMap<String, Integer>();
+		HashMap<String, ArrayList<String>> bills = new HashMap<String, ArrayList<String>>();
+		DBSource dbSource =new DBSource();
+		dbSource.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
+		dbSource.setUrl("jdbc:sqlserver://192.168.0.98:1433;databasename=DB_meida");
+		dbSource.setUsername("sa");
+		dbSource.setPassword("omh_123");
+		DBConnect dbConnect =new DBConnect(dbSource);
+		DBConnect thisdbConnect =new DBConnect();
+		for(Row row :rows){
+			String billno=row.getString("billno");
+			ArrayList<String> itemnos = null;
+			if (bills.containsKey(billno)) {
+				itemnos = bills.get(billno);
+			} else {
+				itemnos = new ArrayList<String>();
+			}
+			if (!map.containsKey(billno)) {
+				int OutPlanID = uploadOutStockbill(row,username);
+				if (OutPlanID == 0) {
+					continue;
+				}
+				map.put(billno, OutPlanID);
+			}
+			int OutPlanID = map.get(billno);
+			String billdate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
+					.format(row.getString("billdate"));
+			String itemno = row.getString("itemno");
+			BigDecimal qty = row.getBigDecimal("qty");
+			if (!itemnos.contains(itemno)) {
+				itemnos.add(itemno);
+				bills.put(billno, itemnos);
+				SQL = "insert into TOutDetailInt(OutPlanID,BillNo,CreateDate,IsDeleted,OutDate,MaterialCode,PlanOutQuantity,OutQuantity,Status)";
+				SQL = SQL + " select ";
+				SQL = SQL + " '" + OutPlanID + "',";// 对应出库通知单主表ID
+				SQL = SQL + " '" + billno + "',";// 单据编号
+				SQL = SQL + " GETDATE(),";// 创建日期
+				SQL = SQL + " 0,";// 是否删除
+				SQL = SQL + " '" + billdate + "',";// 出库日期
+				SQL = SQL + " '" + itemno + "',";// 品号
+				SQL = SQL + " " + qty + ",";// 出库数量
+				SQL = SQL + " 0,";// 已出库数量
+				SQL = SQL + " 0";// 状态:0:WMS未处理 1:WMS正在出库 2:WMS出库完成
+				// 10:ERP出库完成
+			} else {
+				SQL = " update TOutDetailInt set PlanOutQuantity=PlanOutQuantity+"
+						+ qty
+						+ " where OutPlanID='"
+						+ OutPlanID
+						+ "' and MaterialCode='" + itemno + "'";
+			}
+
+			if (!SQL.equals("")) {
+				dbConnect.runSqlUpdate(SQL);
+				thisdbConnect.runSqlUpdate("update st_stockbill_items set wmsuploadflag=2 where st_stockbill_itemsid="+row.getLong("st_stockbill_itemsid"));
+
+			}
+		}
+	}
+
+//	/**
+//	 * 下载入库指令
+//	 *
+//	 * @throws P2Exception
+//	 * @throws SQLException
+//	 */
+//	public void downloadStockbill() throws Exception {
+//		Connection connection = null;
+//		PreparedStatement pstmt = null;
+//		PreparedStatement pstmt2 = null;
+//		ResultSet result = null;
+//		try {
+//			PaoSetRemote icstockbillSet = P2Server.getP2Server().getPaoSet(
+//					"icstockbill",
+//					P2Server.getP2Server().getUserInfo("SAMADMIN"));
+//			SQL = "SELECT t1.DetailID,t1.SerialNo,t1.MaterialCode FROM TInDetailInt t1 INNER JOIN TMaterialsSerialNo t2 on t1.SerialNo=t2.SerialNo WHERE year(t1.CreateDate)>=2018 and t1.Status=0 and t1.IsDeleted=0 and t2.sysfrom='DRP'";
+//			connection = new JdbcConnect().connect();
+//			pstmt = connection.prepareStatement(SQL);
+//			result = pstmt.executeQuery();
+//			while (result.next()) {
+//				int DetailID = result.getInt("DetailID");
+//				String FMACHINECODE = result.getString("SerialNo");// 机器码
+//				String FITEMNO = result.getString("MaterialCode");// 品号
+//				PaoSetRemote tmachinecode = P2Server.getP2Server().getPaoSet(
+//						"tmachinecode", icstockbillSet.getUserInfo());
+//				tmachinecode.setWhere("FMACHINECODE='" + FMACHINECODE
+//						+ "' and FITEMNO='" + FITEMNO + "'");
+//				tmachinecode.reset();
+//				PaoSetRemote ttiem = P2Server.getP2Server().getPaoSet("titem",
+//						P2Server.getP2Server().getSystemUserInfo());
+//				ttiem.setWhere("fitemno='" + FITEMNO + "'");
+//				ttiem.reset();
+//				if (tmachinecode.count() != 1 || ttiem.isEmpty()) {
+//					ttiem.close();
+//					System.err.println("序列号" + FMACHINECODE + "不存在或对应货品不存在");
+//					continue;// 如果序列号不存在或数量大于1则跳过
+//				}
+//
+//				// 判断该单有没有做返修入库单,如有,则将该信息标记为11
+//				PaoSetRemote icstockbillmachinecode = P2Server.getP2Server()
+//						.getPaoSet("icstockbillmachinecode",
+//								icstockbillSet.getUserInfo());
+//				icstockbillmachinecode.setWhere("FMACHINECODE='" + FMACHINECODE
+//						+ "'");
+//				icstockbillmachinecode.reset();
+//				boolean flag = false;
+//				int i = 0;
+//				PaoRemote icpao1 = null;
+//				while ((icpao1 = icstockbillmachinecode.getPao(i)) != null) {
+//					if (!icpao1.getPaoSet("ICSTOCKBILL").isEmpty()) {
+//						if (icpao1.getPaoSet("ICSTOCKBILL").getPao(0)
+//								.getString("ftype").equals("返修入库")
+//								|| icpao1.getPaoSet("ICSTOCKBILL").getPao(0)
+//										.getString("ftype").equals("销售出库")) {
+//							flag = true;
+//							break;
+//						}
+//					}
+//					i++;
+//				}
+//				if (flag) {
+//					String SQL = "update TInDetailInt set status=11,ModifyDate=GETDATE() where DetailID="
+//							+ DetailID + " ";
+//					pstmt2 = connection.prepareStatement(SQL);
+//					pstmt2.executeUpdate();
+//					pstmt2.close();
+//					pstmt2 = null;
+//					System.err.println("序列号" + FMACHINECODE
+//							+ "将中间表入库状态更新为11,DetailID" + DetailID);
+//				}
+//				if (!tmachinecode.getPao(0).getString("fstockno").equals("")
+//						|| flag) {
+//					if (!tmachinecode.getPao(0).getString("fstockno")
+//							.equals("")) {
+//						System.err.println("序列号" + FMACHINECODE + "所在仓库不为空");
+//					}
+//					ttiem.close();
+//					continue;
+//				}
+//
+//				{
+//					String instockno = ttiem.getPao(0).getString("fstockno");// 默认入库仓库
+//					if (instockno.equals("")) {
+//						System.err.println("序列号" + FMACHINECODE + "货品档案默认仓库为空");
+//						ttiem.close();
+//						continue;
+//					}
+//
+//					String fmono = tmachinecode.getPao(0).getString("fmono");// 生产订单号
+//					String fstockno = tmachinecode.getPao(0).getString(
+//							"fstockno");// 目前所在仓库
+//					String fbillnum = "";
+//					PaoSetRemote icmcode = tmachinecode.getPao(0).getPaoSet(
+//							"ICSTOCKBILLMACHINECODE");// 出入库机器码表
+//					if (!fmono.equals("") && fstockno.equals("")
+//							&& icmcode.count() == 0) {
+//						System.err.println("序列号" + FMACHINECODE + "生成生产入库单");
+//						// 当生产订单号不为空,仓库为空且没有出入库记录时,生成产品入库单
+//						PaoSetRemote tmodetail = P2Server.getP2Server()
+//								.getPaoSet("tmodetail",
+//										icstockbillSet.getUserInfo());
+//						tmodetail.setWhere("fmono='" + fmono
+//								+ "' and fitemno='" + FITEMNO
+//								+ "' and FQTY > isnull(FCOMPLETEQTY,0) ");
+//						tmodetail.setOrderBy("FCOMPLETEQTY DESC");
+//						tmodetail.reset();
+//						if (tmodetail.count() == 0) {// 如不存在对应的生产订单信息,则跳过
+//							ttiem.close();
+//							System.err.println("序列号" + FMACHINECODE
+//									+ "找不到对应的生产订单" + fmono);
+//							continue;
+//						} else {
+//							tmodetail.getPao(0).select();
+//							tmodetail.getPao(0).setValue("FADDQTY", 1);
+//						}
+//
+//						icstockbillSet.setApp("STOCKBILL5");
+//						icstockbill pao = (icstockbill) icstockbillSet
+//								.addAtEnd();
+//						pao.setValue("fdepno",
+//								tmodetail.getPao(0).getPaoSet("TMO").getPao(0)
+//										.getString("fdepno"));
+//						pao.setValue("description", "fromwms");
+//						pao.setValue("fnotes", "谈桥立仓入库生成");
+//						pao.addRowsFromModetail(tmodetail);
+//						PaoSetRemote icstockbilldetail = pao
+//								.getPaoSet("ICSTOCKBILLDETAIL");
+//						icstockbilldetail.getPao(0).setValue("fstockno",
+//								instockno);// 指定入库仓库为立体仓库编号
+//						PaoSetRemote ICSTOCKBILLMACHINECODE = pao
+//								.getPaoSet("ICSTOCKBILLMACHINECODE");
+//						PaoRemote mm = ICSTOCKBILLMACHINECODE.addAtEnd();// 为产品入库单增加序列号
+//						mm.setValue("FMACHINECODE", FMACHINECODE, 11l);
+//						mm.setValue("FITEMNO", FITEMNO, 11l);
+//						mm.setValue("FSTOCKNO", instockno, 11l);// 立体仓库编号
+//						pao.check(true);// 产品入库单审核
+//						fbillnum = pao.getString("fbillnum");
+//					} else if (fstockno.equals("")) {
+//						// 此处还需判断是否是调拨入库
+//						int DBSTOCKBILLID = tmachinecode.getPao(0).getInt(
+//								"DBSTOCKBILLID");// 调拨单ID
+//						int DBSTOCKBILLDETAIID = tmachinecode.getPao(0).getInt(
+//								"DBSTOCKBILLDETAIID");// 调拨单行ID
+//
+//						icstockbillSet.setApp("STOCKBILL2");// 其他入库单
+//						icstockbill pao = (icstockbill) icstockbillSet
+//								.addAtEnd();
+//						pao.setValue("fstockno", instockno);
+//						pao.setValue("fnotes", "谈桥立仓入库生成");
+//						pao.setValue("description", "fromwms");
+//						fbillnum = pao.getString("fbillnum");
+//						if (DBSTOCKBILLID > 0) {// 如该序列号处于调拨出库状态,则该入库单为调拨入库单
+//							pao.setValue("fsourceobject", "DBSTOCKBILL");
+//							pao.setValue("fsourceid", DBSTOCKBILLID);
+//							pao.setValue("FTYPEMX", "调拨入库", 11l);
+//
+//							PaoSetRemote DBSTOCKBILL = pao
+//									.getPaoSet("DBSTOCKBILL");
+//							if (!DBSTOCKBILL.isEmpty()) {
+//								Date fdate = DBSTOCKBILL.getPao(0).getDate(
+//										"fdate");// 调拨单单据日期
+//								if (!pao.periodIsClose(pao.getPeriod(fdate))) {
+//									pao.setValue("fdate", fdate, 2l);
+//								}
+//							}
+//							System.err.println("序列号" + FMACHINECODE + "生成调拨入库单"
+//									+ fbillnum);
+//						} else {
+//							pao.setValue("FTYPEMX", "立体仓库入库", 11l);
+//							System.err.println("序列号" + FMACHINECODE + "生成其他入库单"
+//									+ fbillnum);
+//						}
+//						PaoSetRemote icpao = pao.getPaoSet("icstockbilldetail");
+//						PaoRemote newpao = icpao.addAtEnd();
+//						newpao.setValue("fitemno", FITEMNO);
+//						newpao.setValue("fstockno", instockno);
+//						newpao.setValue("fqty", 1);
+//						if (DBSTOCKBILLID > 0) {// 如该序列号处于调拨出库状态,则该入库单为调拨入库单
+//							newpao.setValue("fsourceobject",
+//									"DBSTOCKBILLDETAIL");
+//							newpao.setValue("fsourceid", DBSTOCKBILLDETAIID);
+//						}
+//						PaoSetRemote ICSTOCKBILLMACHINECODE = pao
+//								.getPaoSet("ICSTOCKBILLMACHINECODE");
+//						PaoRemote mm = ICSTOCKBILLMACHINECODE.addAtEnd();
+//						mm.setValue("FMACHINECODE", FMACHINECODE, 11L);
+//						mm.setValue("FITEMNO", FITEMNO, 11l);
+//						mm.setValue("FSTOCKNO", instockno);// 立体仓库编号
+//						pao.check(true);
+//
+//					}
+//					icstockbillSet.save();
+//					if (!fbillnum.equals("")) {
+//						System.err.println("序列号" + FMACHINECODE + "中间表状态更新为1");
+//						String SQL = "update TInDetailInt set status=1 where DetailID="
+//								+ DetailID + " ";
+//						SQL = SQL
+//								+ "insert into TInDetailLog(SerialNo,CreateDate,IsDeleted,MaterialCode,BillNo,BillType)";
+//						SQL = SQL + " select ";
+//						SQL = SQL + "'" + FMACHINECODE + "',";
+//						SQL = SQL + "GETDATE(),";
+//						SQL = SQL + "0,";
+//						SQL = SQL + "'" + FITEMNO + "',";
+//						SQL = SQL + "'" + fbillnum + "',";
+//						SQL = SQL + "1";
+//						pstmt2 = connection.prepareStatement(SQL);
+//						pstmt2.executeUpdate();
+//						pstmt2.close();
+//						pstmt2 = null;
+//					}
+//				}
+//				ttiem.close();
+//			}
+//			icstockbillSet.close();
+//			result.close();
+//			result = null;
+//			pstmt.close();
+//			pstmt = null;
+//			connection.close();
+//			connection = null;
+//		} catch (Exception e) {
+//			System.err.println("downloadStockbill:" + e.getMessage());
+//		} finally {
+//			try {
+//				if (result != null) {
+//					result.close();
+//					result = null;
+//				}
+//			} catch (SQLException e1) {
+//				e1.printStackTrace();
+//			}
+//			try {
+//				if (pstmt != null) {
+//					pstmt.close();
+//					pstmt = null;
+//				}
+//			} catch (SQLException e1) {
+//				e1.printStackTrace();
+//			}
+//			try {
+//				if (pstmt2 != null) {
+//					pstmt2.close();
+//					pstmt2 = null;
+//				}
+//			} catch (SQLException e1) {
+//				e1.printStackTrace();
+//			}
+//			try {
+//				if (connection != null) {
+//					connection.close();
+//					connection = null;
+//				}
+//			} catch (SQLException e1) {
+//				e1.printStackTrace();
+//			}
+//		}
+//		SQL = null;
+//	}
+}

+ 126 - 0
src/custom/restcontroller/webmanage/sale/wmssend/wmssend.java

@@ -0,0 +1,126 @@
+package restcontroller.webmanage.sale.wmssend;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.annotation.CACHEING;
+import common.data.QuerySQL;
+import common.data.Rows;
+import common.data.SQLFactory;
+import org.apache.commons.lang.StringUtils;
+import restcontroller.R;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+
+
+@API(title = "立体仓库指令下发")
+public class wmssend extends Controller {
+    public wmssend(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    @API(title = "指令下发列表", apiversion = R.ID2025060314132803.v1.class)
+    public String querylist() throws YosException {
+        /*
+         * 过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            System.err.println(whereObject.containsKey("wmsuploadflag") && !"".equals(whereObject.getString("wmsuploadflag")));
+
+            if (whereObject.containsKey("wmsuploadflag") && !"".equals(whereObject.getString("wmsuploadflag"))) {
+
+                if(whereObject.getString("wmsuploadflag").equals("全部")){
+                    where.append("and 1=1 ");
+                } else if(whereObject.getString("wmsuploadflag").equals("已下发")){
+                    where.append("and t1.wmsuploadflag =2");
+                } else if(whereObject.getString("wmsuploadflag").equals("未下发")){
+                    where.append("and t1.wmsuploadflag !=2");
+                }
+            }
+            if (whereObject.containsKey("stock") && !"".equals(whereObject.getString("stock"))) {
+
+                where.append(" and t2.outplace like'%").append(whereObject.getString("stock")).append("%' ");
+
+            }
+            if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
+                where.append(" and DATE_FORMAT(t2.billdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and DATE_FORMAT(t2.billdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
+            }
+        }
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items", "qty", "st_stockbill_itemsid","st_stockbillid",
+                "wmsuploadflag","itemid");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "st_stockbill", "t2", "t1.siteid = t2.siteid and t1.st_stockbillid = t2.st_stockbillid","billno","type","rb","billdate","outplace");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t1.siteid=t3.siteid and t1.itemid=t3.itemid","itemno","itemname","model","spec");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t2.siteid=t4.siteid and t2.sys_enterpriseid=t4.sys_enterpriseid","agentnum");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t2.siteid=t5.siteid and t2.sys_enterpriseid=t5.sys_enterpriseid","enterprisename");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t1.wmsuploadflag2 =1");
+        querySQL.setWhere(where.toString());
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "数量汇总", apiversion = R.ID2025060314341703.v1.class)
+    public String sumqty() throws YosException {
+        JSONArray st_stockbill_itemsids = content.getJSONArray("st_stockbill_itemsids");
+        ArrayList<Long> stockbill_itemsids= (ArrayList<Long>) st_stockbill_itemsids.toJavaList(Long.class);
+        stockbill_itemsids.add(0l);
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items", "qty");
+        querySQL.setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("st_stockbill_itemsid",stockbill_itemsids);
+        Rows rows = querySQL.query();
+        BigDecimal sumqty = rows.sum("qty");
+        return getSucReturnObject().setData(sumqty).toString();
+    }
+
+    @API(title = "指令下发", apiversion = R.ID2025060314293003.v1.class)
+    public String wmssendout() throws YosException {
+        JSONArray st_stockbill_itemsids = content.getJSONArray("st_stockbill_itemsids");
+        ArrayList<Long> stockbill_itemsids= (ArrayList<Long>) st_stockbill_itemsids.toJavaList(Long.class);
+        stockbill_itemsids.add(0l);
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items", "*");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "st_stockbill", "t2", "t1.siteid = t2.siteid and t1.st_stockbillid = t2.st_stockbillid","outplace","billno","billdate");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t1.siteid=t3.siteid and t1.itemid=t3.itemid","itemno");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t2.siteid=t4.siteid and t2.sys_enterpriseid=t4.sys_enterpriseid","agentnum");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t2.siteid=t5.siteid and t2.sys_enterpriseid=t5.sys_enterpriseid","enterprisename","abbreviation");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t6", "t2.siteid=t6.siteid and t2.rec_contactsid=t6.contactsid","name","phonenumber","address");
+
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("st_stockbill_itemsid",stockbill_itemsids);
+        Rows rows = querySQL.query();
+        JSONArray outplaceList = rows.toJsonArray("outplace",true);
+        for(Object o :outplaceList){
+            String outplace=(String)o;
+            if(StringUtils.isBlank(outplace)){
+                return getErrReturnObject().setErrMsg("发货地不可为空").toString();
+            }
+        }
+        if(outplaceList.size()>1){
+            return getErrReturnObject().setErrMsg("不可同时选择两个发货地").toString();
+        }
+        if (rows.get(0).getString("outplace").equals("谈桥")) {
+            Wms wms = new Wms();
+            wms.uploadOutStockbilldetail(rows,username);
+        } else if (rows.get(0).getString("outplace").equals("马桥")) {
+            MqWms wms = new MqWms();
+            wms.uploadOutStockbilldetail(rows);
+        }
+
+        return getSucReturnObject().toString();
+    }
+
+
+}