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 stockbill_itemsids= (ArrayList) 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 stockbill_itemsids= (ArrayList) 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(); } }