|
@@ -19,8 +19,10 @@ import restcontroller.webmanage.sale.order.Order;
|
|
|
import restcontroller.webmanage.sale.order.OrderItems;
|
|
import restcontroller.webmanage.sale.order.OrderItems;
|
|
|
import utility.ERPDocking;
|
|
import utility.ERPDocking;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
|
|
public class dispatchItems extends Controller {
|
|
public class dispatchItems extends Controller {
|
|
|
|
|
|
|
@@ -253,6 +255,115 @@ public class dispatchItems extends Controller {
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @API(title = "发货单商品所有明细列表", apiversion = R.ID20230508113003.v1.class)
|
|
|
|
|
+ @CACHEING
|
|
|
|
|
+ public String queryDispatchAllItemsList() throws YosException, IOException {
|
|
|
|
|
+ /*
|
|
|
|
|
+ * 过滤条件设置
|
|
|
|
|
+ */
|
|
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
|
|
+ if(sys_enterpriseid>0) {
|
|
|
|
|
+ where.append(" and t4.sys_enterpriseid ='").append(sys_enterpriseid).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (content.containsKey("where")) {
|
|
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
|
|
+ where.append(" and(");
|
|
|
|
|
+ where.append(" t4.billno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t8.sonum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t9.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t10.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append(")");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
|
|
+ where.append(" and t4.billdate >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
|
|
+ where.append(" and t4.billdate <='").append(whereObject.getString("enddate")).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean isExport = content.getBooleanValue("isExport");
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "发货单明细所有列表查询", pageSize, pageNumber, pageSorting);
|
|
|
|
|
+ if(isExport){
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "发货单明细所有列表查询");
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
+ RowsMap rowsMap =rows.toRowsMap("itemno");
|
|
|
|
|
+ ERPDocking erpDocking =new ERPDocking();
|
|
|
|
|
+ JSONArray jsonArray =new JSONArray();
|
|
|
|
|
+ if(rows.toJsonArray("itemno").size()!=0){
|
|
|
|
|
+ if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
|
|
|
|
|
+ jsonArray=erpDocking.getErpIcinvbalRows(200000, 1,rows.toJsonArray("itemno"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
|
|
|
|
|
+ sqlFactory1.addParameter("siteid", siteid);
|
|
|
|
|
+ Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
|
|
+ RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
|
|
|
|
|
+
|
|
|
|
|
+ if(!jsonArray.isEmpty()){
|
|
|
|
|
+ for (Object object:jsonArray) {
|
|
|
|
|
+ JSONObject jsonObject =(JSONObject)object;
|
|
|
|
|
+
|
|
|
|
|
+ if(rowsMap.containsKey(jsonObject.getString("fitemno"))){
|
|
|
|
|
+ if(rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()){
|
|
|
|
|
+ if(sumQtyRowsMap.containsKey(jsonObject.getString("fitemno"))){
|
|
|
|
|
+ rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty").subtract( sumQtyRowsMap.get(jsonObject.getString("fitemno")).get(0).getBigDecimal("qty")));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ rowsMap.get(jsonObject.getString("fitemno")).get(0).put("delinvbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
|
|
+ }
|
|
|
|
|
+ rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (Row row:rows) {
|
|
|
|
|
+ if(!row.containsKey("delinvbalqty")){
|
|
|
|
|
+ row.put("delinvbalqty", row.getBigDecimal("undeliqty").negate());
|
|
|
|
|
+ row.put("invbalqty", 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isExport) {
|
|
|
|
|
+ //去除不需要导出项
|
|
|
|
|
+ String[] removeFieldList = {"sa_dispatch_itemsid", "sa_dispatchid", "sa_orderitemsid", "rowno", "itemid",
|
|
|
|
|
+ "outwarehouseqty", "batchno", "price", "amount", "undeliqty",
|
|
|
|
|
+ "deliedqty", "invbalqty", "delinvbalqty"};
|
|
|
|
|
+ for (String key : removeFieldList) {
|
|
|
|
|
+ rows.getFieldList().remove(key);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Rows uploadRows = uploadExcelToObs("sa_dispatch", "发货单明细所有列表查询", rows, getTitleMap());
|
|
|
|
|
+ return getSucReturnObject().setData(uploadRows).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ //返回导出的标题
|
|
|
|
|
+ public HashMap<String, String> getTitleMap() {
|
|
|
|
|
+ HashMap<String, String> titleMap = new HashMap<>();
|
|
|
|
|
+ titleMap.put("billno", "发货单号");
|
|
|
|
|
+ titleMap.put("status", "状态");
|
|
|
|
|
+ titleMap.put("sonum", "订单号");
|
|
|
|
|
+ titleMap.put("enterprisename", "企业名称");
|
|
|
|
|
+ titleMap.put("agentnum", "经销商编号");
|
|
|
|
|
+ titleMap.put("billdate", "发货日期");
|
|
|
|
|
+ titleMap.put("orderRowno", "订单行号");
|
|
|
|
|
+ titleMap.put("itemno", "产品编码");
|
|
|
|
|
+ titleMap.put("itemname", "品名");
|
|
|
|
|
+ titleMap.put("unitname", "单位");
|
|
|
|
|
+ titleMap.put("qty", "发货数量");
|
|
|
|
|
+ titleMap.put("remarks", "发货行备注");
|
|
|
|
|
+
|
|
|
|
|
+ return titleMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "删除明细", apiversion = R.ID20221115104803.v1.class)
|
|
@API(title = "删除明细", apiversion = R.ID20221115104803.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {dispatchItems.class,dispatch.class})
|
|
@CACHEING_CLEAN(apiClass = {dispatchItems.class,dispatch.class})
|
|
|
public String deletemx() throws YosException {
|
|
public String deletemx() throws YosException {
|