dispatchItems.java 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. package restcontroller.webmanage.sale.dispatch;
  2. import beans.data.BatchDeleteErr;
  3. import beans.dispatch.Dispatch;
  4. import beans.itemclass.ItemClass;
  5. import beans.parameter.Parameter;
  6. import beans.salearea.SaleArea;
  7. import com.alibaba.fastjson.JSONArray;
  8. import com.alibaba.fastjson.JSONObject;
  9. import common.Controller;
  10. import common.YosException;
  11. import common.annotation.API;
  12. import common.annotation.CACHEING;
  13. import common.annotation.CACHEING_CLEAN;
  14. import common.data.*;
  15. import org.apache.commons.lang.StringUtils;
  16. import org.apache.poi.ss.usermodel.CellStyle;
  17. import org.apache.poi.ss.usermodel.DataFormat;
  18. import org.apache.poi.xssf.usermodel.XSSFCellStyle;
  19. import org.apache.poi.xssf.usermodel.XSSFSheet;
  20. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  21. import restcontroller.R;
  22. import restcontroller.sale.promotion.promotion;
  23. import restcontroller.webmanage.sale.order.Order;
  24. import restcontroller.webmanage.sale.order.OrderItems;
  25. import utility.ERPDocking;
  26. import utility.tools.WebRequest;
  27. import java.io.IOException;
  28. import java.math.BigDecimal;
  29. import java.util.ArrayList;
  30. import java.util.HashMap;
  31. public class dispatchItems extends Controller {
  32. public dispatchItems(JSONObject arg0) throws YosException {
  33. super(arg0);
  34. // TODO Auto-generated constructor stub
  35. }
  36. @API(title = "审核订单列表查询", apiversion = R.ID20221114165903.v1.class)
  37. @CACHEING
  38. public String queryCheckOrderList() throws YosException {
  39. /*
  40. * 过滤条件设置
  41. */
  42. StringBuffer where = new StringBuffer(" 1=1 ");
  43. if (content.containsKey("where")) {
  44. JSONObject whereObject = content.getJSONObject("where");
  45. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  46. where.append(" and(");
  47. where.append("t1.sonum like'%").append(whereObject.getString("condition")).append("%' ");
  48. where.append("or t2.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
  49. where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
  50. where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
  51. where.append(")");
  52. }
  53. if (whereObject.containsKey("sonum") && !"".equals(whereObject.getString("sonum"))) {
  54. where.append(" and t1.sonum ='").append(whereObject.getString("sonum")).append("' ");
  55. }
  56. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  57. where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
  58. }
  59. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  60. where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
  61. }
  62. }
  63. // String hrid = content.getString("hrid");
  64. SQLFactory sqlFactory = new SQLFactory(this, "审核订单列表查询", pageSize, pageNumber, pageSorting);
  65. sqlFactory.addParameter_SQL("where", where);
  66. sqlFactory.addParameter("sys_enterpriseid", content.getLong("sys_enterpriseid"));
  67. sqlFactory.addParameter("siteid", siteid);
  68. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  69. return getSucReturnObject().setData(rows).toString();
  70. }
  71. @API(title = "发货商品列表查询", apiversion = R.ID20221114170003.v1.class)
  72. @CACHEING
  73. public String queryOrderItemgList() throws YosException {
  74. /*
  75. * 过滤条件设置
  76. */
  77. StringBuffer where = new StringBuffer(" 1=1 ");
  78. if (content.containsKey("where")) {
  79. JSONObject whereObject = content.getJSONObject("where");
  80. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  81. where.append(" and(");
  82. where.append("t1.itemname like'%").append(whereObject.getString("condition")).append("%' ");
  83. where.append("or t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
  84. where.append("or t1.unit like'%").append(whereObject.getString("condition")).append("%' ");
  85. where.append("or t3.sonum like'%").append(whereObject.getString("condition")).append("%' ");
  86. where.append("or t3.typemx like'%").append(whereObject.getString("condition")).append("%' ");
  87. where.append(")");
  88. }
  89. if (whereObject.containsKey("sa_orderid") && !"".equals(whereObject.getString("sa_orderid"))) {
  90. Long sa_orderid = whereObject.getLongValue("sa_orderid");
  91. if (sa_orderid > 0) {
  92. where.append(" and t1.sa_orderid ='").append(sa_orderid).append("' ");
  93. }
  94. }
  95. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  96. where.append(" and DATE_FORMAT(t3.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
  97. }
  98. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  99. where.append(" and DATE_FORMAT(t3.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
  100. }
  101. }
  102. SQLFactory sqlFactory = new SQLFactory(this, "发货商品列表查询", pageSize, pageNumber, pageSorting);
  103. sqlFactory.addParameter_SQL("where", where);
  104. sqlFactory.addParameter("sys_enterpriseid", content.getLongValue("sys_enterpriseid"));
  105. sqlFactory.addParameter("sa_dispatchid", content.getLongValue("sa_dispatchid"));
  106. sqlFactory.addParameter("siteid", siteid);
  107. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  108. return getSucReturnObject().setData(rows).toString();
  109. }
  110. @API(title = "erp批次库存查询", apiversion = R.ID20230427101303.v1.class)
  111. @CACHEING
  112. public String queryErpIcinvbalBatchList() throws YosException {
  113. BigDecimal qty = content.getBigDecimalValue("qty");
  114. JSONArray jsonArray = content.getJSONArray("itemnos");
  115. JSONArray jsonArrayfinal = new JSONArray();
  116. ERPDocking erpDocking = new ERPDocking(siteid);
  117. JSONArray rows = erpDocking.getErpIcinvbalBatchRows(1000, 1, jsonArray);
  118. for (Object object : rows) {
  119. JSONObject jsonObject = (JSONObject) object;
  120. if (jsonObject.getBigDecimalValue("fqty").compareTo(qty) >= 0) {
  121. jsonArrayfinal.add(jsonObject);
  122. }
  123. }
  124. return getSucReturnObject().setData(jsonArrayfinal).toString();
  125. }
  126. @API(title = "新建或修改发货单商品明细", apiversion = R.ID20221115104603.v1.class, intervaltime = 200)
  127. @CACHEING_CLEAN(apiClass = {dispatchItems.class, dispatch.class})
  128. public String insertormodify_dispatchItems() throws YosException {
  129. Long sa_dispatchid = content.getLong("sa_dispatchid");
  130. JSONArray iteminfos = content.getJSONArray("iteminfos");
  131. ArrayList<String> sqlList = new ArrayList<>();
  132. Rows rowscount = dbConnect.runSqlQuery("select billno,status from sa_dispatch where sa_dispatchid=" + sa_dispatchid);
  133. if (!rowscount.isEmpty()) {
  134. if (!rowscount.get(0).getString("status").equals("新建")) {
  135. return getErrReturnObject().setErrMsg("非新建状态的发货单无法新增修改").toString();
  136. }
  137. }
  138. int i = 0;
  139. long maxid = 0;
  140. long[] sa_dispatch_itemsid = createTableID("sa_dispatch_items", iteminfos.size());
  141. Rows maxidRows = dbConnect
  142. .runSqlQuery("select MAX(rowno) rowno from sa_dispatch_items where sa_dispatchid=" + sa_dispatchid);
  143. if (!maxidRows.isEmpty()) {
  144. maxid = maxidRows.get(0).getLong("rowno");
  145. }
  146. for (Object obj : iteminfos) {
  147. JSONObject iteminfo = (JSONObject) obj;
  148. if (iteminfo.getLong("sa_dispatch_itemsid") <= 0 || dbConnect
  149. .runSqlQuery("select sa_dispatch_itemsid from sa_dispatch_items where sa_dispatch_itemsid="
  150. + iteminfo.getLong("sa_dispatch_itemsid"))
  151. .isEmpty()) {
  152. // Rows sa_dispatch_itemsrows = dbConnect.runSqlQuery("select sa_dispatch_itemsid,qty,remarks from sa_dispatch_items where sa_dispatchid="
  153. // + sa_dispatchid + " and sa_orderitemsid=" + iteminfo.getLong("sa_orderitemsid"));
  154. // if (!sa_dispatch_itemsrows.isEmpty()) {
  155. // SQLFactory saleFactory = new SQLFactory(this, "发货单明细更新");
  156. // saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsrows.get(0).getLong("sa_dispatch_itemsid"));
  157. // // saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
  158. // saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty").add(sa_dispatch_itemsrows.get(0).getBigDecimal("qty")));
  159. // if (!StringUtils.isBlank(iteminfo.getString("remarks"))) {
  160. // saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
  161. // } else {
  162. // saleFactory.addParameter("remarks", sa_dispatch_itemsrows.get(0).getString("remarks"));
  163. // }
  164. //
  165. // saleFactory.addParameter("userid", userid);
  166. // saleFactory.addParameter("username", username);
  167. // saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
  168. // saleFactory.addParameter("batchno", iteminfo.getStringValue("batchno"));
  169. // sqlList.add(saleFactory.getSQL());
  170. // } else {
  171. // SQLFactory saleFactory = new SQLFactory(this, "发货单明细新增");
  172. // saleFactory.addParameter("siteid", siteid);
  173. // saleFactory.addParameter("rowno", maxid + i + 1);
  174. // saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsid[i]);
  175. // saleFactory.addParameter("sa_dispatchid", sa_dispatchid);
  176. // saleFactory.addParameter("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
  177. // saleFactory.addParameter("itemid", iteminfo.getString("itemid"));
  178. // saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty"));
  179. // saleFactory.addParameter("batchcontrol", iteminfo.getBooleanValue("batchcontrol"));
  180. // saleFactory.addParameter("batchno", "");
  181. // saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
  182. // saleFactory.addParameter("userid", userid);
  183. // saleFactory.addParameter("username", username);
  184. // saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
  185. // sqlList.add(saleFactory.getSQL());
  186. // }
  187. SQLFactory saleFactory = new SQLFactory(this, "发货单明细新增");
  188. saleFactory.addParameter("siteid", siteid);
  189. saleFactory.addParameter("rowno", maxid + i + 1);
  190. saleFactory.addParameter("sa_dispatch_itemsid", sa_dispatch_itemsid[i]);
  191. saleFactory.addParameter("sa_dispatchid", sa_dispatchid);
  192. saleFactory.addParameter("sa_orderitemsid", iteminfo.getLong("sa_orderitemsid"));
  193. saleFactory.addParameter("itemid", iteminfo.getString("itemid"));
  194. saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty"));
  195. saleFactory.addParameter("batchcontrol", iteminfo.getBooleanValue("batchcontrol"));
  196. saleFactory.addParameter("batchno", "");
  197. saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
  198. saleFactory.addParameter("userid", userid);
  199. saleFactory.addParameter("username", username);
  200. saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
  201. sqlList.add(saleFactory.getSQL());
  202. i++;
  203. } else {
  204. SQLFactory saleFactory = new SQLFactory(this, "发货单明细更新");
  205. saleFactory.addParameter("sa_dispatch_itemsid", iteminfo.getLong("sa_dispatch_itemsid"));
  206. // saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
  207. saleFactory.addParameter("qty", iteminfo.getBigDecimal("qty"));
  208. saleFactory.addParameter("remarks", iteminfo.getString("remarks"));
  209. saleFactory.addParameter("batchno", iteminfo.getStringValue("batchno"));
  210. saleFactory.addParameter("userid", userid);
  211. saleFactory.addParameter("username", username);
  212. saleFactory.addParameter("billno", rowscount.get(0).getString("billno"));
  213. sqlList.add(saleFactory.getSQL());
  214. }
  215. }
  216. dbConnect.runSqlUpdate(sqlList);
  217. return queryDispatchItemsList();
  218. }
  219. @API(title = "发货单商品明细列表", apiversion = R.ID20221115104703.v1.class)
  220. @CACHEING
  221. public String queryDispatchItemsList() throws YosException {
  222. /*
  223. * 过滤条件设置
  224. */
  225. StringBuffer where = new StringBuffer(" 1=1 ");
  226. if (content.containsKey("where")) {
  227. JSONObject whereObject = content.getJSONObject("where");
  228. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  229. where.append(" and(");
  230. where.append("t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
  231. where.append("or t2.model like'%").append(whereObject.getString("condition")).append("%' ");
  232. where.append("or t2.spec like'%").append(whereObject.getString("condition")).append("%' ");
  233. where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
  234. where.append(")");
  235. }
  236. }
  237. Long sa_dispatchid = content.getLong("sa_dispatchid");
  238. // String hrid = content.getString("hrid");
  239. SQLFactory sqlFactory = new SQLFactory(this, "发货单明细列表查询", pageSize, pageNumber, pageSorting);
  240. sqlFactory.addParameter_SQL("where", where);
  241. sqlFactory.addParameter("sa_dispatchid", sa_dispatchid);
  242. sqlFactory.addParameter("siteid", siteid);
  243. Rows rows = dbConnect.runSqlQuery(sqlFactory);
  244. RowsMap rowsMap = rows.toRowsMap("itemno");
  245. ERPDocking erpDocking = new ERPDocking(siteid);
  246. JSONArray jsonArray = new JSONArray();
  247. JSONObject object = new JSONObject();
  248. object.put("classname", "getIcinvbal");
  249. object.put("method", "getMsg");
  250. JSONObject content = new JSONObject();
  251. content.put("fitemnos", rows.toJsonArray("itemno"));
  252. object.put("content", content);
  253. WebRequest request = new WebRequest();
  254. //System.out.println(object.toString());
  255. if(siteid.equalsIgnoreCase("lsa")){
  256. String result = request.doPost(object.toString(),
  257. "http://60.190.151.198:8089/BYESB/jaxrs/webclientrest");
  258. if(isJSONArray(result)){
  259. jsonArray = JSONArray.parseArray(result);
  260. }
  261. }else{
  262. if (rows.toJsonArray("itemno").size() != 0) {
  263. if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") ) {
  264. jsonArray = erpDocking.getErpIcinvbalRows(200000, 1, rows.toJsonArray("itemno"));
  265. }
  266. }
  267. }
  268. SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
  269. sqlFactory1.addParameter("siteid", siteid);
  270. sqlFactory1.addParameter_in("itemno", rows.toArrayList("itemno", new ArrayList<>()));
  271. Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
  272. RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
  273. if(!siteid.equalsIgnoreCase("lsa")){
  274. for(Row row : rows){
  275. if(StringUtils.isNotBlank(row.getString("batchno"))){
  276. JSONArray jsonArray1 =new JSONArray();
  277. jsonArray1.add(row.getString("itemno"));
  278. JSONArray jsonArrayBatch = erpDocking.getErpIcinvbalBatchRowsforbatchno(20000, 1, jsonArray1,row.getString("batchno"));
  279. if(!jsonArrayBatch.isEmpty()){
  280. if(sumQtyRowsMap.containsKey(row.getString("itemno"))){
  281. RowsMap rowsMapByBatchno = sumQtyRowsMap.get(row.getString("itemno")).toRowsMap("batchno");
  282. if(rowsMapByBatchno.containsKey(row.getString("batchno"))){
  283. for(Row row1 :sumQtyRowsMap.get(row.getString("itemno"))){
  284. if(row.getString("batchno").equals(row1.getString("batchno"))){
  285. row.put("delinvbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty").subtract(row1.getBigDecimal("qty")));
  286. row.put("invbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
  287. }
  288. }
  289. }else{
  290. row.put("delinvbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
  291. row.put("invbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
  292. }
  293. }else{
  294. row.put("delinvbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
  295. row.put("invbalqty", ((JSONObject)jsonArrayBatch.get(0)).getBigDecimalValue("fqty"));
  296. }
  297. }else{
  298. row.put("delinvbalqty", row.getBigDecimal("qty").negate());
  299. row.put("invbalqty", 0);
  300. }
  301. }
  302. }
  303. }
  304. if (!jsonArray.isEmpty()) {
  305. for (Object obj : jsonArray) {
  306. JSONObject jsonObject = (JSONObject) obj;
  307. if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
  308. if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
  309. if (sumQtyRowsMap.containsKey(jsonObject.getString("fitemno"))) {
  310. if(siteid.equalsIgnoreCase("lsa")){
  311. for(Row row :rowsMap.get(jsonObject.getString("fitemno"))){
  312. row.put("delinvbalqty", jsonObject.getBigDecimalValue("FQty").subtract(sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
  313. }
  314. //rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("FQty").subtract(sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
  315. }else{
  316. for(Row row :rowsMap.get(jsonObject.getString("fitemno"))){
  317. if(StringUtils.isBlank(row.getString("batchno"))){
  318. for(Row row1 :sumQtyRowsMap.get(jsonObject.getString("fitemno"))){
  319. if(StringUtils.isBlank(row1.getString("batchno"))){
  320. row.put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract(row1.getBigDecimal("qty")));
  321. }
  322. }
  323. }
  324. }
  325. //rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract(sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
  326. }
  327. } else {
  328. if(siteid.equalsIgnoreCase("lsa")){
  329. for(Row row :rowsMap.get(jsonObject.getString("fitemno"))){
  330. row.put("delinvbalqty", jsonObject.getBigDecimalValue("FQty"));
  331. }
  332. //rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("FQty"));
  333. }else{
  334. for(Row row :rowsMap.get(jsonObject.getString("fitemno"))){
  335. if(StringUtils.isBlank(row.getString("batchno"))){
  336. row.put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
  337. }
  338. }
  339. //rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
  340. }
  341. }
  342. if(siteid.equalsIgnoreCase("lsa")){
  343. rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("FQty"));
  344. }else{
  345. for(Row row :rowsMap.get(jsonObject.getString("fitemno"))){
  346. if(StringUtils.isBlank(row.getString("batchno"))){
  347. row.put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
  348. }
  349. }
  350. //rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
  351. }
  352. }
  353. }
  354. }
  355. }
  356. for (Row row : rows) {
  357. if (!row.containsKey("delinvbalqty")) {
  358. row.put("delinvbalqty", row.getBigDecimal("undeliqty").negate());
  359. row.put("invbalqty", 0);
  360. }
  361. }
  362. return getSucReturnObject().setData(rows).toString();
  363. }
  364. @API(title = "发货单商品所有明细列表", apiversion = R.ID20230508113003.v1.class)
  365. @CACHEING
  366. public String queryDispatchAllItemsList() throws YosException, IOException {
  367. /*
  368. * 过滤条件设置
  369. */
  370. StringBuffer where = new StringBuffer(" 1=1 ");
  371. if (sys_enterpriseid > 0) {
  372. where.append(" and t4.sys_enterpriseid ='").append(sys_enterpriseid).append("' ");
  373. where.append(" and ifnull(t1.outwarehouseqty, 0)>0 ");
  374. }
  375. if (content.containsKey("where")) {
  376. JSONObject whereObject = content.getJSONObject("where");
  377. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  378. where.append(" and(");
  379. where.append(" t4.billno like'%").append(whereObject.getString("condition")).append("%' ");
  380. where.append("or t8.sonum like'%").append(whereObject.getString("condition")).append("%' ");
  381. where.append("or t9.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
  382. where.append("or t10.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
  383. where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
  384. where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
  385. where.append(")");
  386. }
  387. if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
  388. where.append(" and(");
  389. where.append("t9.agentnum like'%").append(whereObject.getString("agentinfo")).append("%' ");
  390. where.append("or t10.enterprisename like'%").append(whereObject.getString("agentinfo")).append("%' ");
  391. where.append(")");
  392. }
  393. if (whereObject.containsKey("iteminfo") && !"".equals(whereObject.getString("iteminfo"))) {
  394. where.append(" and(");
  395. where.append("t2.itemno like'%").append(whereObject.getString("iteminfo")).append("%' ");
  396. where.append("or t2.itemname like'%").append(whereObject.getString("iteminfo")).append("%' ");
  397. where.append(")");
  398. }
  399. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  400. where.append(" and t4.billdate >=date('").append(whereObject.getString("begindate")).append("') ");
  401. }
  402. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  403. where.append(" and t4.billdate <=date('").append(whereObject.getString("enddate")).append("') ");
  404. }
  405. if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
  406. where.append(" and t4.status ='").append(whereObject.getString("status")).append("' ");
  407. }
  408. if (whereObject.containsKey("isnotsent") && !"".equals(whereObject.getString("isnotsent"))) {
  409. if (whereObject.getBooleanValue("isnotsent")) {
  410. //System.out.println(" and t4.status ='复核' and ifnull(t1.outwarehouseqty, 0)< ifnull(t1.qty, 0)");
  411. where.append(" and t1.sa_dispatchid in(SELECT sa_dispatchid FROM (SELECT sum(outwarehouseqty) outwarehouseqty,sa_dispatchid FROM sa_dispatch_items WHERE siteid='"+siteid+"' GROUP BY sa_dispatchid) a WHERE a.outwarehouseqty=0)");
  412. }
  413. }
  414. if (whereObject.containsKey("itemclassid") && !"".equals(whereObject.getString("itemclassid"))) {
  415. ArrayList<Long> list = ItemClass.getSubItemClassIds(this, whereObject.getLong("itemclassid"));
  416. list.add(whereObject.getLong("itemclassid"));
  417. SQLFactory sqlFactory = new SQLFactory(this, "查询营销类别下的商品");
  418. sqlFactory.addParameter("siteid",siteid);
  419. sqlFactory.addParameter_in("itemclassid", list);
  420. where.append(" and t2.itemid in (").append(sqlFactory.getSQL()).append(") ");
  421. }
  422. }
  423. boolean isExport = content.getBooleanValue("isExport");
  424. // SQLFactory sqlFactory = new SQLFactory(this, "发货单明细所有列表查询", pageSize, pageNumber, pageSorting);
  425. // if (isExport) {
  426. // sqlFactory = new SQLFactory(this, "发货单明细所有列表查询");
  427. // }
  428. // sqlFactory.addParameter_SQL("where", where);
  429. // sqlFactory.addParameter("siteid", siteid);
  430. // Rows rows = dbConnect.runSqlQuery(sqlFactory);
  431. QuerySQL querySQL = queryListManage(where.toString());
  432. querySQL.setOrderBy(pageSorting);
  433. Rows rows;
  434. querySQL.setPage(pageSize, pageNumber);
  435. rows = querySQL.query();
  436. SQLFactory areasqlFactory = new SQLFactory(this, "发货单明细关联区域列表查询");
  437. areasqlFactory.addParameter("siteid", siteid);
  438. areasqlFactory.addParameter_in("sys_enterpriseids", rows.toArrayList("sys_enterpriseid", new ArrayList<>()));
  439. Rows areaRows = dbConnect.runSqlQuery(areasqlFactory);
  440. RowsMap areaRowsMap = areaRows.toRowsMap("sys_enterpriseid");
  441. SQLFactory itemclasssqlFactory = new SQLFactory(this, "发货单明细关联商品营销类别查询");
  442. itemclasssqlFactory.addParameter("siteid", siteid);
  443. itemclasssqlFactory.addParameter_in("itemids", rows.toArrayList("itemid", new ArrayList<>()));
  444. Rows itemclassRows = dbConnect.runSqlQuery(itemclasssqlFactory);
  445. RowsMap itemclassRowsMap = itemclassRows.toRowsMap("itemid");
  446. // SQLFactory itemsqlFactory = new SQLFactory(this, "发货单明细关联商品列表查询");
  447. // itemsqlFactory.addParameter("siteid", siteid);
  448. // itemsqlFactory.addParameter_in("itemids", rows.toArrayList("itemid", new ArrayList<>()));
  449. // Rows itemRows = dbConnect.runSqlQuery(itemsqlFactory);
  450. // RowsMap itemRowsMap = itemRows.toRowsMap("itemid");
  451. // SQLFactory ordersqlFactory = new SQLFactory(this, "发货单明细关联订单列表查询");
  452. // ordersqlFactory.addParameter("siteid", siteid);
  453. // ordersqlFactory.addParameter_in("sa_orderitemsids", rows.toArrayList("sa_orderitemsid", new ArrayList<>()));
  454. // Rows orderRows = dbConnect.runSqlQuery(ordersqlFactory);
  455. // RowsMap orderRowsMap = orderRows.toRowsMap("sa_orderitemsid");
  456. RowsMap rowsMap = rows.toRowsMap("itemno");
  457. ERPDocking erpDocking = new ERPDocking(siteid);
  458. JSONArray jsonArray = new JSONArray();
  459. if (rows.toJsonArray("itemno").size() != 0) {
  460. if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") ) {
  461. //jsonArray = erpDocking.getErpIcinvbalRows(200000, 1, rows.toJsonArray("itemno"));
  462. }
  463. }
  464. SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
  465. sqlFactory1.addParameter("siteid", siteid);
  466. sqlFactory1.addParameter_in("itemno", rows.toArrayList("itemno", new ArrayList<>()));
  467. Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
  468. RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
  469. if (!jsonArray.isEmpty()) {
  470. for (Object object : jsonArray) {
  471. JSONObject jsonObject = (JSONObject) object;
  472. if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
  473. if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
  474. if (sumQtyRowsMap.containsKey(jsonObject.getString("fitemno"))) {
  475. rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract(sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
  476. } else {
  477. rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
  478. }
  479. rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
  480. }
  481. }
  482. }
  483. }
  484. for (Row row : rows) {
  485. if (areaRowsMap.containsKey(row.getString("sys_enterpriseid"))) {
  486. row.put("areaname", areaRowsMap.get(row.getString("sys_enterpriseid")).get(0).getString("areaname"));
  487. } else {
  488. row.put("areaname", "");
  489. }
  490. if (itemclassRowsMap.containsKey(row.getString("itemid"))) {
  491. row.put("itemclassname", itemclassRowsMap.get(row.getString("itemid")).get(0).getString("itemclassname"));
  492. } else {
  493. row.put("itemclassname", "");
  494. }
  495. if (!row.containsKey("delinvbalqty")) {
  496. row.put("delinvbalqty", row.getBigDecimal("undeliqty").negate().doubleValue());
  497. row.put("invbalqty", 0);
  498. }
  499. }
  500. // if (isExport) {
  501. // //去除不需要导出项
  502. // rows.getFieldList().remove("sa_dispatch_itemsid");
  503. // rows.getFieldList().remove("sa_dispatchid");
  504. // rows.getFieldList().remove("sa_orderitemsid");
  505. // rows.getFieldList().remove("sa_orderid");
  506. // rows.getFieldList().remove("sys_enterpriseid");
  507. // rows.getFieldList().remove("isclose");
  508. // rows.getFieldList().remove("rowno");
  509. // rows.getFieldList().remove("itemid");
  510. // rows.getFieldList().remove("batchno");
  511. // Rows rowsrolename= dbConnect.runSqlQuery("select * from sys_userrole t1 inner join sys_role t2 on t1.roleid=t2.roleid and t1.siteid=t2.siteid where t2.rolename='经销商员工' and t1.userid="+userid);
  512. // if(!rowsrolename.isEmpty()){
  513. // rows.getFieldList().remove("price");
  514. // rows.getFieldList().remove("amount");
  515. // }
  516. // rows.getFieldList().remove("undeliqty");
  517. // rows.getFieldList().remove("deliedqty");
  518. // rows.getFieldList().remove("outwarehousedate");
  519. // Rows uploadRows = uploadExcelToObs("dispatch", "发货单明细列表", rows, getTitleMap());
  520. // return getSucReturnObject().setData(uploadRows).toString();
  521. // }
  522. return getSucReturnObject().setData(rows).toString();
  523. }
  524. //查询订单列表(管理端)
  525. public QuerySQL queryListManage(String where) throws YosException {
  526. QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_dispatch_items",
  527. "sa_dispatch_itemsid", "sa_dispatchid", "sa_orderitemsid", "isclose", "rowno", "itemid", "outwarehousedate", "batchno", "remarks");
  528. querySQL.setTableAlias("t1");
  529. querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t2.itemid = t1.itemid AND t2.siteid = t1.siteid",
  530. "itemno","itemname");
  531. querySQL.addJoinTable(JOINTYPE.inner, "sa_dispatch", "t4", "t4.sa_dispatchid = t1.sa_dispatchid AND t4.siteid = t1.siteid",
  532. "billno", "status", "billdate", "closedate");
  533. querySQL.addJoinTable(JOINTYPE.left, "sa_orderitems", "t5", "t5.sa_orderitemsid=t1.sa_orderitemsid and t5.siteid=t1.siteid",
  534. "spec","price","undeliqty","deliedqty","amount","rowno");
  535. querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t8", "t8.sa_orderid=t4.sa_orderid and t8.siteid=t4.siteid",
  536. "sonum","type","typemx","sa_accountclassinfos","sa_orderid");
  537. querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t9", "t9.sys_enterpriseid = t4.sys_enterpriseid and t9.siteid = t4.siteid",
  538. "agentnum");
  539. querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t10", "t10.sys_enterpriseid = t4.sys_enterpriseid and t10.siteid = t4.siteid",
  540. "enterprisename", "sys_enterpriseid");
  541. querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t11", "t11.unitid = t2.unitid and t11.siteid = t2.siteid",
  542. "unitname");
  543. querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t12", "t12.sa_accountclassid=t8.sa_accountclassid and t12.siteid=t8.siteid");
  544. querySQL.addQueryFields("qty", "ifnull(t1.qty, 0)");
  545. querySQL.addQueryFields("outwarehouseqty", "ifnull(t1.outwarehouseqty, 0)");
  546. querySQL.addQueryFields("orderRowno", "t5.rowno");
  547. querySQL.addQueryFields("accountnames", "if(ifnull(replace(replace(replace(JSON_EXTRACT (t8.sa_accountclassinfos, '$**.accountname' ),'[',''),']',''),'\\\"',''),'')='',t12.accountname,replace(replace(replace(JSON_EXTRACT (t8.sa_accountclassinfos, '$**.accountname' ),'[',''),']',''),'\\\"',''))");
  548. querySQL.setWhere("t1.siteid", siteid);
  549. querySQL.setWhere(where);
  550. return querySQL;
  551. }
  552. @API(title = "工厂发货/退货明细", apiversion = R.ID20230626104003.v1.class)
  553. @CACHEING
  554. public String queryDispatchAndAftersalesmagItemsList() throws YosException, IOException {
  555. /*
  556. * 过滤条件设置
  557. */
  558. StringBuffer where = new StringBuffer(" 1=1 ");
  559. if (content.containsKey("where")) {
  560. JSONObject whereObject = content.getJSONObject("where");
  561. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  562. where.append(" and(");
  563. where.append("t.sonum like'%").append(whereObject.getString("condition")).append("%' ");
  564. where.append("or t.itemno like'%").append(whereObject.getString("condition")).append("%' ");
  565. where.append("or t.itemname like'%").append(whereObject.getString("condition")).append("%' ");
  566. where.append("or t.remarks like'%").append(whereObject.getString("condition")).append("%' ");
  567. where.append("or t.billno like'%").append(whereObject.getString("condition")).append("%' ");
  568. where.append(")");
  569. }
  570. if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
  571. where.append(" and(");
  572. where.append("t.type ='").append(whereObject.getString("type")).append("' ");
  573. where.append(")");
  574. }
  575. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  576. where.append(" and DATE_FORMAT(t.date, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
  577. }
  578. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  579. where.append(" and DATE_FORMAT(t.date, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
  580. }
  581. if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
  582. where.append(" and t.status ='").append(whereObject.getString("status")).append("' ");
  583. }
  584. }
  585. SQLFactory sqlFactory = new SQLFactory(this, "工厂发货及退货明细(经销商)", pageSize, pageNumber, pageSorting);
  586. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  587. sqlFactory.addParameter_SQL("where", where);
  588. sqlFactory.addParameter("siteid", siteid);
  589. Rows rows = dbConnect.runSqlQuery(sqlFactory);
  590. return getSucReturnObject().setData(rows).toString();
  591. }
  592. @API(title = "工厂发货/退货明细(区域经理)", apiversion = R.ID20231030091403.v1.class)
  593. @CACHEING
  594. public String queryDispatchAndAftersalesmagItemsManagerList() throws YosException, IOException {
  595. /*
  596. * 过滤条件设置
  597. */
  598. StringBuffer where = new StringBuffer(" 1=1 ");
  599. if (content.containsKey("where")) {
  600. JSONObject whereObject = content.getJSONObject("where");
  601. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  602. where.append(" and(");
  603. where.append("t.sonum like'%").append(whereObject.getString("condition")).append("%' ");
  604. where.append("or t.itemno like'%").append(whereObject.getString("condition")).append("%' ");
  605. where.append("or t.itemname like'%").append(whereObject.getString("condition")).append("%' ");
  606. where.append("or t.remarks like'%").append(whereObject.getString("condition")).append("%' ");
  607. where.append(")");
  608. }
  609. if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
  610. where.append(" and(");
  611. where.append("t.type ='").append(whereObject.getString("type")).append("' ");
  612. where.append(")");
  613. }
  614. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  615. where.append(" and DATE_FORMAT(t.date, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
  616. }
  617. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  618. where.append(" and DATE_FORMAT(t.date, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
  619. }
  620. if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
  621. where.append(" and t.status ='").append(whereObject.getString("status")).append("' ");
  622. }
  623. }
  624. boolean isExport = content.getBooleanValue("isExport");
  625. SQLFactory areasqlFactory = new SQLFactory(new promotion(content), "区域经理查询下属营销区域");
  626. areasqlFactory.addParameter("siteid", siteid);
  627. areasqlFactory.addParameter("hrid", hrid);
  628. Rows arearows = dbConnect.runSqlQuery(areasqlFactory);
  629. ArrayList<Long> arrayList = arearows.toArrayList("sa_saleareaid", new ArrayList<Long>());
  630. arrayList.addAll(SaleArea.getSubSaleAreaIds(this, arrayList));
  631. SQLFactory sqlFactory = new SQLFactory(this, "工厂发货及退货明细(区域经理)", pageSize, pageNumber, pageSorting);
  632. sqlFactory.addParameter_in("sa_saleareaids", arrayList);
  633. sqlFactory.addParameter_SQL("where", where);
  634. sqlFactory.addParameter("siteid", siteid);
  635. Rows rows = dbConnect.runSqlQuery(sqlFactory);
  636. // if (isExport) {
  637. // //去除不需要导出项
  638. // rows.getFieldList().remove("sa_dispatch_itemsid");
  639. // rows.getFieldList().remove("sa_dispatchid");
  640. // rows.getFieldList().remove("sa_orderitemsid");
  641. // rows.getFieldList().remove("sa_orderid");
  642. // rows.getFieldList().remove("sys_enterpriseid");
  643. // rows.getFieldList().remove("isclose");
  644. // rows.getFieldList().remove("rowno");
  645. // rows.getFieldList().remove("itemid");
  646. // rows.getFieldList().remove("batchno");
  647. // Rows rowsrolename= dbConnect.runSqlQuery("select * from sys_userrole t1 inner join sys_role t2 on t1.roleid=t2.roleid and t1.siteid=t2.siteid where t2.rolename='经销商员工' and t1.userid="+userid);
  648. // if(!rowsrolename.isEmpty()){
  649. // rows.getFieldList().remove("price");
  650. // rows.getFieldList().remove("amount");
  651. // }
  652. // rows.getFieldList().remove("undeliqty");
  653. // rows.getFieldList().remove("deliedqty");
  654. // rows.getFieldList().remove("outwarehousedate");
  655. // Rows uploadRows = uploadExcelToObs("dispatch", "发货单明细列表", rows, getTitleMap());
  656. // return getSucReturnObject().setData(uploadRows).toString();
  657. // }
  658. return getSucReturnObject().setData(rows).toString();
  659. }
  660. //返回导出的标题
  661. public HashMap<String, String> getTitleMap() throws YosException {
  662. HashMap<String, String> titleMap = new HashMap<>();
  663. titleMap.put("billno", "发货单号");
  664. titleMap.put("status", "状态");
  665. titleMap.put("sonum", "订单号");
  666. titleMap.put("enterprisename", "企业名称");
  667. titleMap.put("agentnum", "经销商编号");
  668. titleMap.put("billdate", "发货日期");
  669. titleMap.put("orderRowno", "订单行号");
  670. titleMap.put("itemno", "产品编码");
  671. titleMap.put("itemname", "品名");
  672. titleMap.put("unitname", "单位");
  673. titleMap.put("qty", "发货数量");
  674. titleMap.put("remarks", "发货行备注");
  675. titleMap.put("outwarehouseqty", "已出库数量");
  676. Rows rowsrolename = dbConnect.runSqlQuery("select * from sys_userrole t1 inner join sys_role t2 on t1.roleid=t2.roleid and t1.siteid=t2.siteid where t2.rolename='经销商员工' and t1.userid=" + userid);
  677. if (rowsrolename.isEmpty()) {
  678. titleMap.put("price", "单价");
  679. titleMap.put("amount", "金额");
  680. }
  681. return titleMap;
  682. }
  683. @API(title = "删除明细", apiversion = R.ID20221115104803.v1.class)
  684. @CACHEING_CLEAN(apiClass = {dispatchItems.class, dispatch.class})
  685. public String deletemx() throws YosException {
  686. JSONArray sa_dispatch_itemsids = content.getJSONArray("sa_dispatch_itemsids");
  687. BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_dispatch_itemsids.size());
  688. long sa_dispatchid = 0;
  689. for (Object o : sa_dispatch_itemsids) {
  690. long sa_dispatch_itemsid = Long.parseLong(o.toString());
  691. Rows RowsStatus = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,t2.status,t1.sa_dispatchid from sa_dispatch_items t1 left join sa_dispatch t2 on t1.sa_dispatchid=t2.sa_dispatchid and t1.siteid=t2.siteid where t1.siteid='"
  692. + siteid + "' and t1.sa_dispatch_itemsid='" + sa_dispatch_itemsid + "'");
  693. if (RowsStatus.isNotEmpty()) {
  694. sa_dispatchid = RowsStatus.get(0).getLong("sa_dispatchid");
  695. if (!RowsStatus.get(0).getString("status").equals("新建")) {
  696. batchDeleteErr.addErr(sa_dispatch_itemsid, "非新建状态的发货单明细无法删除");
  697. continue;
  698. }
  699. }
  700. ArrayList<String> list = new ArrayList<>();
  701. SQLFactory deletesql = new SQLFactory("sql:delete from sa_dispatch_items where siteid='" + siteid
  702. + "' and sa_dispatch_itemsid=" + sa_dispatch_itemsid);
  703. list.add(deletesql.getSQL());
  704. dbConnect.runSqlUpdate(list);
  705. }
  706. //重新排序
  707. updateRowNo(sa_dispatchid);
  708. return batchDeleteErr.getReturnObject().toString();
  709. }
  710. /**
  711. * 重新对发货单行进行排序
  712. *
  713. * @param
  714. * @throws YosException
  715. */
  716. public void updateRowNo(Long sa_dispatchid) throws YosException {
  717. String sql = "SELECT sa_dispatch_itemsid from sa_dispatch_items WHERE sa_dispatchid= " + sa_dispatchid + " and siteid = '" + siteid + "' ORDER BY sa_dispatch_itemsid asc ";
  718. ArrayList<Long> sa_dispatch_itemsids = dbConnect.runSqlQuery(sql).toArrayList("sa_dispatch_itemsid", new ArrayList<>());
  719. ArrayList<String> sqlList = new ArrayList<>();
  720. int rowno = 1;
  721. for (Long id : sa_dispatch_itemsids) {
  722. sqlList.add("UPDATE sa_dispatch_items SET rowno=" + rowno + " WHERE sa_dispatch_itemsid = " + id);
  723. rowno++;
  724. }
  725. dbConnect.runSqlUpdate(sqlList);
  726. }
  727. }