wmssend.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package restcontroller.webmanage.sale.wmssend;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import common.Controller;
  5. import common.YosException;
  6. import common.annotation.API;
  7. import common.annotation.CACHEING;
  8. import common.data.QuerySQL;
  9. import common.data.Rows;
  10. import common.data.SQLFactory;
  11. import org.apache.commons.lang.StringUtils;
  12. import restcontroller.R;
  13. import java.math.BigDecimal;
  14. import java.util.ArrayList;
  15. @API(title = "立体仓库指令下发")
  16. public class wmssend extends Controller {
  17. public wmssend(JSONObject content) throws YosException {
  18. super(content);
  19. }
  20. @API(title = "指令下发列表", apiversion = R.ID2025060314132803.v1.class)
  21. public String querylist() throws YosException {
  22. /*
  23. * 过滤条件设置
  24. */
  25. StringBuffer where = new StringBuffer(" 1=1 ");
  26. if (content.containsKey("where")) {
  27. JSONObject whereObject = content.getJSONObject("where");
  28. System.err.println(whereObject.containsKey("wmsuploadflag") && !"".equals(whereObject.getString("wmsuploadflag")));
  29. if (whereObject.containsKey("wmsuploadflag") && !"".equals(whereObject.getString("wmsuploadflag"))) {
  30. if(whereObject.getString("wmsuploadflag").equals("全部")){
  31. where.append("and 1=1 ");
  32. } else if(whereObject.getString("wmsuploadflag").equals("已下发")){
  33. where.append("and t1.wmsuploadflag =2");
  34. } else if(whereObject.getString("wmsuploadflag").equals("未下发")){
  35. where.append("and t1.wmsuploadflag !=2");
  36. }
  37. }
  38. if (whereObject.containsKey("stock") && !"".equals(whereObject.getString("stock"))) {
  39. where.append(" and t2.outplace like'%").append(whereObject.getString("stock")).append("%' ");
  40. }
  41. if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
  42. where.append(" and DATE_FORMAT(t2.billdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
  43. }
  44. if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
  45. where.append(" and DATE_FORMAT(t2.billdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
  46. }
  47. }
  48. QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items", "qty", "st_stockbill_itemsid","st_stockbillid",
  49. "wmsuploadflag","itemid");
  50. querySQL.setTableAlias("t1");
  51. querySQL.addJoinTable(JOINTYPE.left, "st_stockbill", "t2", "t1.siteid = t2.siteid and t1.st_stockbillid = t2.st_stockbillid","billno","type","rb","billdate","outplace");
  52. querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t1.siteid=t3.siteid and t1.itemid=t3.itemid","itemno","itemname","model","spec");
  53. querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t2.siteid=t4.siteid and t2.sys_enterpriseid=t4.sys_enterpriseid","agentnum");
  54. querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t2.siteid=t5.siteid and t2.sys_enterpriseid=t5.sys_enterpriseid","enterprisename");
  55. querySQL.setSiteid(siteid);
  56. querySQL.setWhere("t1.wmsuploadflag2 =1");
  57. querySQL.setWhere(where.toString());
  58. querySQL.setPage(pageSize, pageNumber);
  59. querySQL.setOrderBy(pageSorting);
  60. Rows rows = querySQL.query();
  61. return getSucReturnObject().setData(rows).toString();
  62. }
  63. @API(title = "数量汇总", apiversion = R.ID2025060314341703.v1.class)
  64. public String sumqty() throws YosException {
  65. JSONArray st_stockbill_itemsids = content.getJSONArray("st_stockbill_itemsids");
  66. ArrayList<Long> stockbill_itemsids= (ArrayList<Long>) st_stockbill_itemsids.toJavaList(Long.class);
  67. stockbill_itemsids.add(0l);
  68. QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items", "qty");
  69. querySQL.setTableAlias("t1");
  70. querySQL.setSiteid(siteid);
  71. querySQL.setWhere("st_stockbill_itemsid",stockbill_itemsids);
  72. Rows rows = querySQL.query();
  73. BigDecimal sumqty = rows.sum("qty");
  74. return getSucReturnObject().setData(sumqty).toString();
  75. }
  76. @API(title = "指令下发", apiversion = R.ID2025060314293003.v1.class)
  77. public String wmssendout() throws YosException {
  78. JSONArray st_stockbill_itemsids = content.getJSONArray("st_stockbill_itemsids");
  79. ArrayList<Long> stockbill_itemsids= (ArrayList<Long>) st_stockbill_itemsids.toJavaList(Long.class);
  80. stockbill_itemsids.add(0l);
  81. QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill_items", "*");
  82. querySQL.setTableAlias("t1");
  83. querySQL.addJoinTable(JOINTYPE.left, "st_stockbill", "t2", "t1.siteid = t2.siteid and t1.st_stockbillid = t2.st_stockbillid","outplace","billno","billdate");
  84. querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t1.siteid=t3.siteid and t1.itemid=t3.itemid","itemno");
  85. querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t2.siteid=t4.siteid and t2.sys_enterpriseid=t4.sys_enterpriseid","agentnum");
  86. querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t2.siteid=t5.siteid and t2.sys_enterpriseid=t5.sys_enterpriseid","enterprisename","abbreviation");
  87. querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t6", "t2.siteid=t6.siteid and t2.rec_contactsid=t6.contactsid","name","phonenumber","address");
  88. querySQL.setSiteid(siteid);
  89. querySQL.setWhere("st_stockbill_itemsid",stockbill_itemsids);
  90. Rows rows = querySQL.query();
  91. JSONArray outplaceList = rows.toJsonArray("outplace",true);
  92. for(Object o :outplaceList){
  93. String outplace=(String)o;
  94. if(StringUtils.isBlank(outplace)){
  95. return getErrReturnObject().setErrMsg("发货地不可为空").toString();
  96. }
  97. }
  98. if(outplaceList.size()>1){
  99. return getErrReturnObject().setErrMsg("不可同时选择两个发货地").toString();
  100. }
  101. if (rows.get(0).getString("outplace").equals("谈桥")) {
  102. Wms wms = new Wms();
  103. wms.uploadOutStockbilldetail(rows,username);
  104. } else if (rows.get(0).getString("outplace").equals("马桥")) {
  105. MqWms wms = new MqWms();
  106. wms.uploadOutStockbilldetail(rows);
  107. }
  108. return getSucReturnObject().toString();
  109. }
  110. }