|
@@ -24,70 +24,71 @@ import common.data.RowsMap;
|
|
|
import common.data.SQLFactory;
|
|
|
import common.data.db.DBConnect;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.hslf.dev.UserEditAndPersistListing;
|
|
|
import restcontroller.R;
|
|
|
import utility.ERPDocking;
|
|
|
|
|
|
@API(title = "库存管理")
|
|
|
public class invbal extends Controller {
|
|
|
|
|
|
- public invbal(JSONObject content) throws YosException {
|
|
|
- super(content);
|
|
|
- // TODO Auto-generated constructor stub
|
|
|
- }
|
|
|
+ public invbal(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ // TODO Auto-generated constructor stub
|
|
|
+ }
|
|
|
+
|
|
|
+ public static HashMap<String, Long> itemhashmap = new HashMap<>(16);
|
|
|
+ public static HashMap<Long, String> itemnomap = new HashMap<>(16);
|
|
|
+
|
|
|
|
|
|
- public static HashMap<String, Long> itemhashmap = new HashMap<>(16);
|
|
|
- public static HashMap<Long, String> itemnomap = new HashMap<>(16);
|
|
|
-
|
|
|
-
|
|
|
@API(title = "从erp新增更新库存", apiversion = R.ID20230222203603.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20230222203803.class})
|
|
|
- public String caculate() throws YosException {
|
|
|
- JSONArray itemids = content.getJSONArray("itemids");
|
|
|
- boolean rightnow = content.getBooleanValue("rightnow");
|
|
|
- JSONArray erpitemnos = new JSONArray();
|
|
|
- if (itemnomap.isEmpty()) {
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select itemid,erpitemno from plm_itemextend where siteid='" + siteid + "'");
|
|
|
- for (Row row : rows) {
|
|
|
- itemnomap.put(row.getLong("itemid"), row.getString("erpitemno"));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (Object object : itemids) {
|
|
|
- long itemid =((Integer)object).longValue();
|
|
|
- if (itemnomap.containsKey(itemid)) {
|
|
|
- erpitemnos.add(itemnomap.get(itemid));
|
|
|
- } else {
|
|
|
- Rows rows = dbConnect.runSqlQuery("select erpitemno from plm_itemextend where itemid='" + itemid
|
|
|
- + "' and siteid='" + siteid + "'");
|
|
|
- if (!rows.isEmpty()) {
|
|
|
- erpitemnos.add(rows.get(0).getString("erpitemno"));
|
|
|
- itemnomap.put(itemid, rows.get(0).getString("erpitemno"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Invbal.caculate_erpitemno(this, erpitemnos, rightnow);
|
|
|
- return getSucReturnObject().toString();
|
|
|
- }
|
|
|
-
|
|
|
+ public String caculate() throws YosException {
|
|
|
+ JSONArray itemids = content.getJSONArray("itemids");
|
|
|
+ boolean rightnow = content.getBooleanValue("rightnow");
|
|
|
+ JSONArray erpitemnos = new JSONArray();
|
|
|
+ if (itemnomap.isEmpty()) {
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select itemid,erpitemno from plm_itemextend where siteid='" + siteid + "'");
|
|
|
+ for (Row row : rows) {
|
|
|
+ itemnomap.put(row.getLong("itemid"), row.getString("erpitemno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Object object : itemids) {
|
|
|
+ long itemid = ((Integer) object).longValue();
|
|
|
+ if (itemnomap.containsKey(itemid)) {
|
|
|
+ erpitemnos.add(itemnomap.get(itemid));
|
|
|
+ } else {
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select erpitemno from plm_itemextend where itemid='" + itemid
|
|
|
+ + "' and siteid='" + siteid + "'");
|
|
|
+ if (!rows.isEmpty()) {
|
|
|
+ erpitemnos.add(rows.get(0).getString("erpitemno"));
|
|
|
+ itemnomap.put(itemid, rows.get(0).getString("erpitemno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Invbal.caculate_erpitemno(this, erpitemnos, rightnow);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
@API(title = "从erp新增更新库存(站点全部)", apiversion = R.ID20230222203703.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20230222203803.class})
|
|
|
- public String caculateAll() throws YosException {
|
|
|
- if (itemnomap.isEmpty()) {
|
|
|
- Rows rows = dbConnect
|
|
|
- .runSqlQuery("select itemid,erpitemno from plm_itemextend where siteid='" + siteid + "'");
|
|
|
- for (Row row : rows) {
|
|
|
- itemnomap.put(row.getLong("itemid"), row.getString("erpitemno"));
|
|
|
- }
|
|
|
- }
|
|
|
- Invbal.caculate_erpitemno(this);
|
|
|
- return getSucReturnObject().toString();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ public String caculateAll() throws YosException {
|
|
|
+ if (itemnomap.isEmpty()) {
|
|
|
+ Rows rows = dbConnect
|
|
|
+ .runSqlQuery("select itemid,erpitemno from plm_itemextend where siteid='" + siteid + "'");
|
|
|
+ for (Row row : rows) {
|
|
|
+ itemnomap.put(row.getLong("itemid"), row.getString("erpitemno"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Invbal.caculate_erpitemno(this);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@API(title = "查询库存列表", apiversion = R.ID20230222203803.v1.class)
|
|
|
public String queryInvbalList() throws YosException {
|
|
|
- boolean istotal = content.getBooleanValue("istotal");
|
|
|
+ boolean istotal = content.getBooleanValue("istotal");
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
@@ -101,116 +102,116 @@ public class invbal extends Controller {
|
|
|
}
|
|
|
}
|
|
|
SQLFactory sqlFactory;
|
|
|
- if(istotal) {
|
|
|
- sqlFactory = new SQLFactory(this, "销售库存列表查询", pageSize, pageNumber, pageSorting);
|
|
|
- }else {
|
|
|
- sqlFactory = new SQLFactory(this, "即时库存列表查询", pageSize, pageNumber, pageSorting);
|
|
|
- }
|
|
|
-
|
|
|
+ if (istotal) {
|
|
|
+ sqlFactory = new SQLFactory(this, "销售库存列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+ } else {
|
|
|
+ sqlFactory = new SQLFactory(this, "即时库存列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+ }
|
|
|
+
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
- @API(title = "查询Erp库存列表", apiversion = R.ID20230408091703.v1.class)
|
|
|
- public String queryErpInvbalList() throws YosException, IOException {
|
|
|
- boolean isExport = content.getBooleanValue("isExport");
|
|
|
- //String iteminfo = content.getStringValue("iteminfo");
|
|
|
- //String agentinfo = content.getStringValue("agentinfo");
|
|
|
- //boolean all = content.getBooleanValue("all");
|
|
|
- //JSONArray itemclassids = content.getJSONArray("itemclassids");
|
|
|
- String where =" 1=1 ";
|
|
|
- SQLFactory sqlFactory =new SQLFactory(this,"商品列表", pageSize, pageNumber, pageSorting);
|
|
|
- if (isExport) {
|
|
|
- sqlFactory = new SQLFactory(this,"商品列表");
|
|
|
- }
|
|
|
- if (content.containsKey("where")) {
|
|
|
- JSONObject whereObject = content.getJSONObject("where");
|
|
|
- if(whereObject.containsKey("iteminfo")){
|
|
|
- if(!StringUtils.isBlank(whereObject.getStringValue("iteminfo"))){
|
|
|
- where=where+" and (t2.itemno like '%"+whereObject.getStringValue("iteminfo")+"%' or t2.itemname like '%"+whereObject.getStringValue("iteminfo")+"%') ";
|
|
|
- }
|
|
|
- }
|
|
|
- if(whereObject.containsKey("itemclassids")){
|
|
|
- if (whereObject.getLong("itemclassids")!=0) {
|
|
|
- ArrayList<Long> itemclassList = new ArrayList<Long>();
|
|
|
- //System.out.println(row.getLong("itemclassid"));
|
|
|
- long itemclassid = whereObject.getLong("itemclassids");
|
|
|
- itemclassList.add(itemclassid);
|
|
|
- itemclassList.addAll(ItemClass.getSubItemClassIds(this,itemclassid));
|
|
|
- String sql = " and t2.itemid in ( SELECT itemid from sa_itemsaleclass WHERE itemclassid IN " + itemclassList + " and siteid='" + siteid + "')";
|
|
|
- sql = sql.replace("[", "(").replace("]", ")");
|
|
|
- where=where+sql;
|
|
|
- }
|
|
|
- }
|
|
|
+ @API(title = "查询Erp库存列表", apiversion = R.ID20230408091703.v1.class)
|
|
|
+ public String queryErpInvbalList() throws YosException, IOException {
|
|
|
+ boolean isExport = content.getBooleanValue("isExport");
|
|
|
+ //String iteminfo = content.getStringValue("iteminfo");
|
|
|
+ //String agentinfo = content.getStringValue("agentinfo");
|
|
|
+ //boolean all = content.getBooleanValue("all");
|
|
|
+ //JSONArray itemclassids = content.getJSONArray("itemclassids");
|
|
|
+ String where = " 1=1 ";
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "商品列表", pageSize, pageNumber, pageSorting);
|
|
|
+ if (isExport) {
|
|
|
+ sqlFactory = new SQLFactory(this, "商品列表");
|
|
|
+ }
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("iteminfo")) {
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("iteminfo"))) {
|
|
|
+ where = where + " and (t2.itemno like '%" + whereObject.getStringValue("iteminfo") + "%' or t2.itemname like '%" + whereObject.getStringValue("iteminfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("itemclassids")) {
|
|
|
+ if (whereObject.getLong("itemclassids") != 0) {
|
|
|
+ ArrayList<Long> itemclassList = new ArrayList<Long>();
|
|
|
+ //System.out.println(row.getLong("itemclassid"));
|
|
|
+ long itemclassid = whereObject.getLong("itemclassids");
|
|
|
+ itemclassList.add(itemclassid);
|
|
|
+ itemclassList.addAll(ItemClass.getSubItemClassIds(this, itemclassid));
|
|
|
+ String sql = " and t2.itemid in ( SELECT itemid from sa_itemsaleclass WHERE itemclassid IN " + itemclassList + " and siteid='" + siteid + "')";
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ where = where + sql;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (whereObject.containsKey("all") && !"".equals(whereObject.getString("all"))) {
|
|
|
- if(!whereObject.getBooleanValue("all")){
|
|
|
- where = where+" and 1=2 ";
|
|
|
- }
|
|
|
- }
|
|
|
- if (whereObject.containsKey("isonsale") && !"".equals(whereObject.getString("isonsale"))) {
|
|
|
- where = where+" and t2.isonsale ='"+whereObject.getString("isonsale") + "' ";
|
|
|
- }
|
|
|
- if(whereObject.containsKey("agentinfo")){
|
|
|
- if(!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))){
|
|
|
- sqlFactory =new SQLFactory(this,"订单明细未发商品列表", pageSize, pageNumber, pageSorting);
|
|
|
- if (isExport) {
|
|
|
- sqlFactory = new SQLFactory(this,"订单明细未发商品列表");
|
|
|
- }
|
|
|
- //System.out.println(StringUtils.isBlank(itemname) && StringUtils.isBlank(itemno) && itemclassids.size()==0);
|
|
|
- if(!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))){
|
|
|
- where=where+" and (t6.agentnum like '%"+whereObject.getStringValue("agentinfo")+"%' or t5.enterprisename like '%"+whereObject.getStringValue("agentinfo")+"%') ";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- //System.out.println(sqlFactory.getSQL());
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
- Rows rowsitemclass = dbConnect.runSqlQuery(" select t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 LEFT JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='" + siteid + "'");
|
|
|
- RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
|
|
|
-
|
|
|
- RowsMap rowsMap =rows.toRowsMap("itemno");
|
|
|
-
|
|
|
-
|
|
|
- SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
|
|
|
- sqlFactory1.addParameter("siteid", siteid);
|
|
|
- where=" 1=1 ";
|
|
|
- sqlFactory1.addParameter_SQL("where", where);
|
|
|
- Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
- RowsMap sumAllQtyRowsMap= sumQtyRows.toRowsMap("itemno");
|
|
|
- if (content.containsKey("where")) {
|
|
|
- JSONObject whereObject = content.getJSONObject("where");
|
|
|
- if(!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))){
|
|
|
- where=where+" and (t6.agentnum like '%"+whereObject.getStringValue("agentinfo")+"%' or t5.enterprisename like '%"+whereObject.getStringValue("agentinfo")+"%') ";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- sqlFactory1.addParameter_SQL("where", where);
|
|
|
- sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
- RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
|
|
|
-
|
|
|
- SQLFactory sqlFactory2 =new SQLFactory(this,"商品未发货数量汇总");
|
|
|
- sqlFactory2.addParameter("siteid", siteid);
|
|
|
- where=" 1=1 ";
|
|
|
- sqlFactory2.addParameter_SQL("where", where);
|
|
|
- Rows sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
- RowsMap sumUnAllQtyRowsMap= sumUnQtyRows.toRowsMap("itemno");
|
|
|
- if (content.containsKey("where")) {
|
|
|
- JSONObject whereObject = content.getJSONObject("where");
|
|
|
- if(!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))){
|
|
|
- where=where+" and (t6.agentnum like '%"+whereObject.getStringValue("agentinfo")+"%' or t5.enterprisename like '%"+whereObject.getStringValue("agentinfo")+"%') ";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- sqlFactory2.addParameter_SQL("where", where);
|
|
|
- sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
- RowsMap sumUnQtyRowsMap= sumUnQtyRows.toRowsMap("itemno");
|
|
|
+ if (whereObject.containsKey("all") && !"".equals(whereObject.getString("all"))) {
|
|
|
+ if (!whereObject.getBooleanValue("all")) {
|
|
|
+ where = where + " and 1=2 ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isonsale") && !"".equals(whereObject.getString("isonsale"))) {
|
|
|
+ where = where + " and t2.isonsale ='" + whereObject.getString("isonsale") + "' ";
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("agentinfo")) {
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ sqlFactory = new SQLFactory(this, "订单明细未发商品列表", pageSize, pageNumber, pageSorting);
|
|
|
+ if (isExport) {
|
|
|
+ sqlFactory = new SQLFactory(this, "订单明细未发商品列表");
|
|
|
+ }
|
|
|
+ //System.out.println(StringUtils.isBlank(itemname) && StringUtils.isBlank(itemno) && itemclassids.size()==0);
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ where = where + " and (t6.agentnum like '%" + whereObject.getStringValue("agentinfo") + "%' or t5.enterprisename like '%" + whereObject.getStringValue("agentinfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ //System.out.println(sqlFactory.getSQL());
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ Rows rowsitemclass = dbConnect.runSqlQuery(" select t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 LEFT JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='" + siteid + "'");
|
|
|
+ RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
|
|
|
+
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("itemno");
|
|
|
+
|
|
|
+
|
|
|
+ SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
|
|
|
+ sqlFactory1.addParameter("siteid", siteid);
|
|
|
+ where = " 1=1 ";
|
|
|
+ sqlFactory1.addParameter_SQL("where", where);
|
|
|
+ Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ RowsMap sumAllQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ where = where + " and (t6.agentnum like '%" + whereObject.getStringValue("agentinfo") + "%' or t5.enterprisename like '%" + whereObject.getStringValue("agentinfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory1.addParameter_SQL("where", where);
|
|
|
+ sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
+
|
|
|
+ SQLFactory sqlFactory2 = new SQLFactory(this, "商品未发货数量汇总");
|
|
|
+ sqlFactory2.addParameter("siteid", siteid);
|
|
|
+ where = " 1=1 ";
|
|
|
+ sqlFactory2.addParameter_SQL("where", where);
|
|
|
+ Rows sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
+ RowsMap sumUnAllQtyRowsMap = sumUnQtyRows.toRowsMap("itemno");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ where = where + " and (t6.agentnum like '%" + whereObject.getStringValue("agentinfo") + "%' or t5.enterprisename like '%" + whereObject.getStringValue("agentinfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory2.addParameter_SQL("where", where);
|
|
|
+ sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
+ RowsMap sumUnQtyRowsMap = sumUnQtyRows.toRowsMap("itemno");
|
|
|
|
|
|
|
|
|
ERPDocking erpDocking =new ERPDocking(siteid);
|
|
@@ -223,114 +224,349 @@ public class invbal extends Controller {
|
|
|
jsonArray=erpDocking.getErpIcinvbalRows(200000, 1,new JSONArray());
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
+ if (!jsonArray.isEmpty()) {
|
|
|
|
|
|
- for (Object object:jsonArray) {
|
|
|
- JSONObject jsonObject =(JSONObject)object;
|
|
|
- if(rowsMap.containsKey(jsonObject.getString("fitemno"))){
|
|
|
- if(rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()){
|
|
|
- rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- for (Row row:rows) {
|
|
|
- String itemclass=itemclassRowsMap.get(row.getString("itemid")).toJsonArray("itemclassname").toString().substring(1,itemclassRowsMap.get(row.getString("itemid")).toJsonArray("itemclassname").toString().length()-1);
|
|
|
- row.put("itemclass", itemclass.replaceAll("\"", ""));
|
|
|
- if(sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
- row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
- }else {
|
|
|
- row.put("unsoldqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
- }
|
|
|
- if(sumUnQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
- row.put("undelqty", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty").stripTrailingZeros().toPlainString());
|
|
|
- row.put("qty", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
- }else {
|
|
|
- row.put("undelqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
- row.put("qty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
- }
|
|
|
- if(sumUnAllQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
- row.put("undelqtysum", sumUnAllQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty").stripTrailingZeros().toPlainString());
|
|
|
- }else {
|
|
|
- row.put("undelqtysum", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
- }
|
|
|
- if(sumAllQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
- row.put("unsoldqtysum", sumAllQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
- }else {
|
|
|
- row.put("unsoldqtysum", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
- }
|
|
|
-
|
|
|
- if(!row.containsKey("invbalqty")){
|
|
|
- row.put("invbalqty",BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- for (Row row:rows) {
|
|
|
-
|
|
|
- row.put("canbesent", (row.getBigDecimal("invbalqty").subtract(row.getBigDecimal("unsoldqty"))).stripTrailingZeros().toPlainString());
|
|
|
- row.put("canbesale", ((row.getBigDecimal("invbalqty").subtract(row.getBigDecimal("unsoldqty"))).subtract(row.getBigDecimal("undelqtysum"))).stripTrailingZeros().toPlainString());
|
|
|
- if(row.getString("itemno").equals("10901371")){
|
|
|
- System.out.println(row.getString("canbesent"));
|
|
|
- System.out.println(row.getString("canbesale"));
|
|
|
- System.out.println(row.toJsonObject().toJSONString());
|
|
|
- }
|
|
|
- }
|
|
|
- if(isExport){
|
|
|
- //去除不需要导出项
|
|
|
- rows.getFieldList().remove("itemid");
|
|
|
- rows.getFieldList().remove("packageqty");
|
|
|
- rows.getFieldList().remove("qty");
|
|
|
- for (Row row:rows) {
|
|
|
- if(row.getString("itemno").equals("10901371")){
|
|
|
- System.out.println(row.getString("canbesent"));
|
|
|
- System.out.println(row.getString("canbesale"));
|
|
|
- System.out.println(row.toJsonObject().toJSONString());
|
|
|
- }
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) object;
|
|
|
+ if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
|
|
|
+ if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
|
|
|
+ rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Row row : rows) {
|
|
|
+ String itemclass = itemclassRowsMap.get(row.getString("itemid")).toJsonArray("itemclassname").toString().substring(1, itemclassRowsMap.get(row.getString("itemid")).toJsonArray("itemclassname").toString().length() - 1);
|
|
|
+ row.put("itemclass", itemclass.replaceAll("\"", ""));
|
|
|
+ if (sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("unsoldqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+ if (sumUnQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("undelqty", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty").stripTrailingZeros().toPlainString());
|
|
|
+ row.put("qty", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("undelqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ row.put("qty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+ if (sumUnAllQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("undelqtysum", sumUnAllQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("undelqtysum", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+ if (sumAllQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("unsoldqtysum", sumAllQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("unsoldqtysum", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!row.containsKey("invbalqty")) {
|
|
|
+ row.put("invbalqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ for (Row row : rows) {
|
|
|
+
|
|
|
+ row.put("canbesent", (row.getBigDecimal("invbalqty").subtract(row.getBigDecimal("unsoldqty"))).stripTrailingZeros().toPlainString());
|
|
|
+ row.put("canbesale", ((row.getBigDecimal("invbalqty").subtract(row.getBigDecimal("unsoldqty"))).subtract(row.getBigDecimal("undelqtysum"))).stripTrailingZeros().toPlainString());
|
|
|
+// if (row.getString("itemno").equals("10901371")) {
|
|
|
+// System.out.println(row.getString("canbesent"));
|
|
|
+// System.out.println(row.getString("canbesale"));
|
|
|
+// System.out.println(row.toJsonObject().toJSONString());
|
|
|
+// }
|
|
|
+ }
|
|
|
+ if (isExport) {
|
|
|
+ //去除不需要导出项
|
|
|
+ rows.getFieldList().remove("itemid");
|
|
|
+ rows.getFieldList().remove("packageqty");
|
|
|
+ rows.getFieldList().remove("qty");
|
|
|
+// for (Row row : rows) {
|
|
|
+// if (row.getString("itemno").equals("10901371")) {
|
|
|
+// System.out.println(row.getString("canbesent"));
|
|
|
+// System.out.println(row.getString("canbesale"));
|
|
|
+// System.out.println(row.toJsonObject().toJSONString());
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+ Rows uploadRows = uploadExcelToObs("invbal", "库存列表", rows, getTitleMap());
|
|
|
+ return getSucReturnObject().setData(uploadRows).toString();
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- Rows uploadRows = uploadExcelToObs("invbal", "库存列表", 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("itemname", "产品名称");
|
|
|
- titleMap.put("itemno", "产品编号");
|
|
|
- titleMap.put("undelqty", "未发数量");
|
|
|
- titleMap.put("invbalqty", "库存数");
|
|
|
- titleMap.put("canbesent", "预计可发量");
|
|
|
- titleMap.put("canbesale", "预计可售量");
|
|
|
- titleMap.put("unitname", "单位");
|
|
|
- titleMap.put("itemclass", "营销分类");
|
|
|
- titleMap.put("isonsale", "是否上架");
|
|
|
- return titleMap;
|
|
|
- }
|
|
|
-
|
|
|
- @API(title = "查询指定商品对应的未发货订单明细", apiversion = R.ID20230408101803.v1.class)
|
|
|
- public String queryOrderDetailList() throws YosException {
|
|
|
- String itemno = content.getString("itemno");
|
|
|
- StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
- if (content.containsKey("where")) {
|
|
|
- JSONObject whereObject = content.getJSONObject("where");
|
|
|
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where.append(" and(");
|
|
|
- where.append("t5.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t6.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append(")");
|
|
|
- }
|
|
|
- }
|
|
|
- SQLFactory sqlFactory =new SQLFactory(this,"未发货订单明细列表", pageSize, pageNumber, pageSorting);
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter("itemno", itemno);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
- return getSucReturnObject().setData(rows).toString();
|
|
|
- }
|
|
|
+ //返回导出的标题
|
|
|
+ public HashMap<String, String> getTitleMap() {
|
|
|
+ HashMap<String, String> titleMap = new HashMap<>();
|
|
|
+ titleMap.put("itemname", "产品名称");
|
|
|
+ titleMap.put("itemno", "产品编号");
|
|
|
+ titleMap.put("undelqty", "未发数量");
|
|
|
+ titleMap.put("invbalqty", "库存数");
|
|
|
+ titleMap.put("canbesent", "预计可发量");
|
|
|
+ titleMap.put("canbesale", "预计可售量");
|
|
|
+ titleMap.put("unitname", "单位");
|
|
|
+ titleMap.put("itemclass", "营销分类");
|
|
|
+ titleMap.put("isonsale", "是否上架");
|
|
|
+ return titleMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询指定商品对应的未发货订单明细", apiversion = R.ID20230408101803.v1.class)
|
|
|
+ public String queryOrderDetailList() throws YosException {
|
|
|
+ String itemno = content.getString("itemno");
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t5.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t6.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "未发货订单明细列表", pageSize, pageNumber, pageSorting);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("itemno", itemno);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "商品补货分析", apiversion = R.ID20231228102402.v1.class)
|
|
|
+ public String queryItemSalesList() throws YosException, IOException {
|
|
|
+ boolean isExport = content.getBooleanValue("isExport");
|
|
|
+ int year = content.getIntValue("year");
|
|
|
+ if (year <= 0) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ year = calendar.get(Calendar.YEAR);
|
|
|
+ }
|
|
|
+
|
|
|
+ String begindate = year+"-01-01";
|
|
|
+ String enddate = (year+1)+"-01-01";
|
|
|
+
|
|
|
+ String where = " 1=1 ";
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "商品列表", pageSize, pageNumber, pageSorting);
|
|
|
+ if (isExport) {
|
|
|
+ sqlFactory = new SQLFactory(this, "商品列表");
|
|
|
+ }
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("iteminfo")) {
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("iteminfo"))) {
|
|
|
+ where = where + " and (t2.itemno like '%" + whereObject.getStringValue("iteminfo") + "%' or t2.itemname like '%" + whereObject.getStringValue("iteminfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("itemclassids")) {
|
|
|
+ if (whereObject.getLong("itemclassids") != 0) {
|
|
|
+ ArrayList<Long> itemclassList = new ArrayList<Long>();
|
|
|
+ long itemclassid = whereObject.getLong("itemclassids");
|
|
|
+ itemclassList.add(itemclassid);
|
|
|
+ itemclassList.addAll(ItemClass.getSubItemClassIds(this, itemclassid));
|
|
|
+ String sql = " and t2.itemid in ( SELECT itemid from sa_itemsaleclass WHERE itemclassid IN " + itemclassList + " and siteid='" + siteid + "')";
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ where = where + sql;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("all") && !"".equals(whereObject.getString("all"))) {
|
|
|
+ if (!whereObject.getBooleanValue("all")) {
|
|
|
+ where = where + " and 1=2 ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isonsale") && !"".equals(whereObject.getString("isonsale"))) {
|
|
|
+ where = where + " and t2.isonsale ='" + whereObject.getString("isonsale") + "' ";
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("agentinfo")) {
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ sqlFactory = new SQLFactory(this, "订单明细未发商品列表", pageSize, pageNumber, pageSorting);
|
|
|
+ if (isExport) {
|
|
|
+ sqlFactory = new SQLFactory(this, "订单明细未发商品列表");
|
|
|
+ }
|
|
|
+ //System.out.println(StringUtils.isBlank(itemname) && StringUtils.isBlank(itemno) && itemclassids.size()==0);
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ where = where + " and (t6.agentnum like '%" + whereObject.getStringValue("agentinfo") + "%' or t5.enterprisename like '%" + whereObject.getStringValue("agentinfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+ //System.out.println(sqlFactory.getSQL());
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ Rows rowsitemclass = dbConnect.runSqlQuery(" select t7.itemclassname,t6.itemid,t8.brandname from sa_itemsaleclass t6 LEFT JOIN plm_itemclass t7 ON t7.itemclassid = t6.itemclassid AND t7.siteid = t6.siteid LEFT JOIN sa_brand t8 ON t8.sa_brandid = t7.sa_brandid AND t8.siteid = t7.siteid where t6.siteid='" + siteid + "'");
|
|
|
+ RowsMap itemclassRowsMap = rowsitemclass.toRowsMap("itemid");
|
|
|
+
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("itemno");
|
|
|
+
|
|
|
+
|
|
|
+ SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
|
|
|
+ sqlFactory1.addParameter("siteid", siteid);
|
|
|
+ where = " 1=1 ";
|
|
|
+ sqlFactory1.addParameter_SQL("where", where);
|
|
|
+ Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ RowsMap sumAllQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ where = where + " and (t6.agentnum like '%" + whereObject.getStringValue("agentinfo") + "%' or t5.enterprisename like '%" + whereObject.getStringValue("agentinfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory1.addParameter_SQL("where", where);
|
|
|
+ sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
+
|
|
|
+ SQLFactory sqlFactory2 = new SQLFactory(this, "商品未发货数量汇总");
|
|
|
+ sqlFactory2.addParameter("siteid", siteid);
|
|
|
+ where = " 1=1 ";
|
|
|
+ sqlFactory2.addParameter_SQL("where", where);
|
|
|
+ Rows sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
+ RowsMap sumUnAllQtyRowsMap = sumUnQtyRows.toRowsMap("itemno");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (!StringUtils.isBlank(whereObject.getStringValue("agentinfo"))) {
|
|
|
+ where = where + " and (t6.agentnum like '%" + whereObject.getStringValue("agentinfo") + "%' or t5.enterprisename like '%" + whereObject.getStringValue("agentinfo") + "%') ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlFactory2.addParameter_SQL("where", where);
|
|
|
+ sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
|
|
|
+ RowsMap sumUnQtyRowsMap = sumUnQtyRows.toRowsMap("itemno");
|
|
|
+
|
|
|
+
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (rows.toJsonArray("itemno").size() != 0) {
|
|
|
+ if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true") && siteid.equalsIgnoreCase("ccyosg")) {
|
|
|
+ if (rows.toJsonArray("itemno").size() <= 2000) {
|
|
|
+ jsonArray = erpDocking.getErpIcinvbalRows(200000, 1, rows.toJsonArray("itemno"));
|
|
|
+ } else {
|
|
|
+ jsonArray = erpDocking.getErpIcinvbalRows(200000, 1, new JSONArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!jsonArray.isEmpty()) {
|
|
|
+
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) object;
|
|
|
+ if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
|
|
|
+ if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
|
|
|
+ rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Row row : rows) {
|
|
|
+ String itemclass = itemclassRowsMap.get(row.getString("itemid")).toJsonArray("itemclassname").toString().substring(1, itemclassRowsMap.get(row.getString("itemid")).toJsonArray("itemclassname").toString().length() - 1);
|
|
|
+ row.put("itemclass", itemclass.replaceAll("\"", ""));
|
|
|
+ if (sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("unsoldqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+ if (sumUnQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("undelqty", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty").stripTrailingZeros().toPlainString());
|
|
|
+ row.put("qty", sumUnQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("undelqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ row.put("qty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+ if (sumUnAllQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("undelqtysum", sumUnAllQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("undeliqty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("undelqtysum", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+ if (sumAllQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
+ row.put("unsoldqtysum", sumAllQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty").stripTrailingZeros().toPlainString());
|
|
|
+ } else {
|
|
|
+ row.put("unsoldqtysum", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!row.containsKey("invbalqty")) {
|
|
|
+ row.put("invbalqty", BigDecimal.ZERO.stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //查询统计商品月销量销
|
|
|
+ SQLFactory sqlFactory3 = new SQLFactory(this, "查询统计商品月销量销");
|
|
|
+ sqlFactory3.addParameter("siteid", siteid);
|
|
|
+ sqlFactory3.addParameter("begindate", begindate);
|
|
|
+ sqlFactory3.addParameter("enddate", enddate);
|
|
|
+ sqlFactory3.addParameter_in("itemid", rows.toArray("itemid"));
|
|
|
+ RowsMap monthRowsMap = dbConnect.runSqlQuery(sqlFactory3).toRowsMap("itemid");
|
|
|
+
|
|
|
+ SQLFactory sqlFactory4 = new SQLFactory(this, "查询退货统计");
|
|
|
+ sqlFactory4.addParameter("siteid", siteid);
|
|
|
+ sqlFactory4.addParameter("begindate", begindate);
|
|
|
+ sqlFactory4.addParameter("enddate", enddate);
|
|
|
+ sqlFactory4.addParameter_in("itemid", rows.toArray("itemid"));
|
|
|
+ RowsMap returnRowsMap = dbConnect.runSqlQuery(sqlFactory4).toRowsMap("itemid");
|
|
|
+
|
|
|
+
|
|
|
+ SQLFactory sqlFactory5 = new SQLFactory(this, "查询手工关闭统计");
|
|
|
+ sqlFactory5.addParameter("siteid", siteid);
|
|
|
+ sqlFactory5.addParameter("begindate", begindate);
|
|
|
+ sqlFactory5.addParameter("enddate", enddate);
|
|
|
+ sqlFactory5.addParameter_in("itemid", rows.toArray("itemid"));
|
|
|
+ RowsMap closeRowsMap = dbConnect.runSqlQuery(sqlFactory5).toRowsMap("itemid");
|
|
|
+
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+
|
|
|
+ row.put("canbesent", (row.getBigDecimal("invbalqty").subtract(row.getBigDecimal("unsoldqty"))).stripTrailingZeros().toPlainString());
|
|
|
+ row.put("canbesale", ((row.getBigDecimal("invbalqty").subtract(row.getBigDecimal("unsoldqty"))).subtract(row.getBigDecimal("undelqtysum"))).stripTrailingZeros().toPlainString());
|
|
|
+ Rows monthRows = monthRowsMap.getOrDefault(row.getString("itemid"), new Rows());
|
|
|
+ for (Row month : monthRows) {
|
|
|
+ row.put("month_" + month.getString("month"), month.getBigDecimal("qty"));
|
|
|
+ }
|
|
|
+ //补足月份
|
|
|
+ row = initMonthRow(row);
|
|
|
+ //处理退货
|
|
|
+ Rows returnRows = returnRowsMap.getOrDefault(row.getString("itemid"), new Rows());
|
|
|
+ for (Row returnRow : returnRows) {
|
|
|
+ String key = "month_" + returnRow.getString("month");
|
|
|
+ row.replace(key, row.getBigDecimal(key).subtract(returnRow.getBigDecimal("qty")));
|
|
|
+ }
|
|
|
+ //
|
|
|
+ Rows closeRows = closeRowsMap.getOrDefault(row.getString("itemid"), new Rows());
|
|
|
+ for (Row closeRow : closeRows) {
|
|
|
+ String key = "month_" + closeRow.getString("month");
|
|
|
+ row.replace(key, row.getBigDecimal(key).subtract(closeRow.getBigDecimal("qty")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isExport) {
|
|
|
+ //去除不需要导出项
|
|
|
+ rows.getFieldList().remove("itemid");
|
|
|
+ rows.getFieldList().remove("packageqty");
|
|
|
+ rows.getFieldList().remove("qty");
|
|
|
+ Rows uploadRows = uploadExcelToObs("invbal", "商品补货分析", rows, getTitleMap());
|
|
|
+ return getSucReturnObject().setData(uploadRows).toString();
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Row initMonthRow(Row row) {
|
|
|
+ row.putIfAbsent("month_01", 0);
|
|
|
+ row.putIfAbsent("month_02", 0);
|
|
|
+ row.putIfAbsent("month_03", 0);
|
|
|
+ row.putIfAbsent("month_04", 0);
|
|
|
+ row.putIfAbsent("month_05", 0);
|
|
|
+ row.putIfAbsent("month_06", 0);
|
|
|
+ row.putIfAbsent("month_07", 0);
|
|
|
+ row.putIfAbsent("month_08", 0);
|
|
|
+ row.putIfAbsent("month_09", 0);
|
|
|
+ row.putIfAbsent("month_10", 0);
|
|
|
+ row.putIfAbsent("month_11", 0);
|
|
|
+ row.putIfAbsent("month_12", 0);
|
|
|
+ return row;
|
|
|
+ }
|
|
|
|
|
|
}
|