|
|
@@ -18,6 +18,7 @@ public class sendplandetail extends Controller {
|
|
|
public sendplandetail(JSONObject content) throws YosException {
|
|
|
super(content);
|
|
|
}
|
|
|
+
|
|
|
//ID2025120110193103
|
|
|
@API(title = "订单信息刷新(新)", apiversion = R.ID2025120110193103.v1.class)
|
|
|
public String orderRefresh_new() throws YosException {
|
|
|
@@ -59,9 +60,9 @@ public class sendplandetail extends Controller {
|
|
|
RowsMap invbalrowsMap = invbalrows.toRowsMap("itemid");
|
|
|
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
- long olditemid=0;
|
|
|
- BigDecimal oldcanuseqty=BigDecimal.ZERO;
|
|
|
- BigDecimal oldsendqty=BigDecimal.ZERO;
|
|
|
+ long olditemid = 0;
|
|
|
+ BigDecimal oldcanuseqty = BigDecimal.ZERO;
|
|
|
+ BigDecimal oldsendqty = BigDecimal.ZERO;
|
|
|
long[] sendplandetailids = createTableID("sa_sendplandetail", rows.size());
|
|
|
int i = 0;
|
|
|
for (Row row : rows) {
|
|
|
@@ -93,7 +94,7 @@ public class sendplandetail extends Controller {
|
|
|
insertSQL.setValue("sendqty", 0);
|
|
|
insertSQL.setValue("colorflag", 0);
|
|
|
} else {
|
|
|
- sendqty=row.getBigDecimal("sendqty");
|
|
|
+ sendqty = row.getBigDecimal("sendqty");
|
|
|
insertSQL.setValue("sendqty", sendqty);
|
|
|
if (canuseqty.compareTo(row.getBigDecimal("sendqty")) >= 0) {
|
|
|
insertSQL.setValue("colorflag", 2);
|
|
|
@@ -102,17 +103,17 @@ public class sendplandetail extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(row.getLong("itemid")==olditemid){
|
|
|
- insertSQL.setValue("canuseqty", (oldcanuseqty.compareTo(BigDecimal.ZERO)==0?canuseqty:oldcanuseqty).subtract(oldsendqty));
|
|
|
- oldcanuseqty= (oldcanuseqty.compareTo(BigDecimal.ZERO)==0?canuseqty:oldcanuseqty).subtract(oldsendqty);
|
|
|
- }else{
|
|
|
+ if (row.getLong("itemid") == olditemid) {
|
|
|
+ insertSQL.setValue("canuseqty", (oldcanuseqty.compareTo(BigDecimal.ZERO) == 0 ? canuseqty : oldcanuseqty).subtract(oldsendqty));
|
|
|
+ oldcanuseqty = (oldcanuseqty.compareTo(BigDecimal.ZERO) == 0 ? canuseqty : oldcanuseqty).subtract(oldsendqty);
|
|
|
+ } else {
|
|
|
insertSQL.setValue("canuseqty", canuseqty);
|
|
|
}
|
|
|
- if(row.getLong("itemid")!=olditemid){
|
|
|
- oldcanuseqty=BigDecimal.ZERO;
|
|
|
+ if (row.getLong("itemid") != olditemid) {
|
|
|
+ oldcanuseqty = BigDecimal.ZERO;
|
|
|
}
|
|
|
- olditemid=row.getLong("itemid");
|
|
|
- oldsendqty=sendqty;
|
|
|
+ olditemid = row.getLong("itemid");
|
|
|
+ oldsendqty = sendqty;
|
|
|
list.add(insertSQL.getSQL());
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(list);
|
|
|
@@ -123,6 +124,7 @@ public class sendplandetail extends Controller {
|
|
|
}
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
+
|
|
|
//ID2025032709331803
|
|
|
@API(title = "订单信息刷新", apiversion = R.ID2025032709331803.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {sendplandetail.class})
|
|
|
@@ -195,7 +197,7 @@ public class sendplandetail extends Controller {
|
|
|
BigDecimal willoutqty = BigDecimal.ZERO;
|
|
|
BigDecimal invbalqty = BigDecimal.ZERO;
|
|
|
UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_sendplandetail");
|
|
|
- updateSQL.setUniqueid(row.getLong("sa_sendplandetailid")).setSiteid(siteid);
|
|
|
+ updateSQL.setUniqueid(row.getLong("sa_sendplandetailid"));
|
|
|
if (stockbillrowsMap.containsKey(row.getString("itemid"))) {
|
|
|
willoutqty = stockbillrowsMap.get(row.getString("itemid")).get(0).getBigDecimal("qty");
|
|
|
}
|
|
|
@@ -226,15 +228,15 @@ public class sendplandetail extends Controller {
|
|
|
}
|
|
|
|
|
|
Rows sendplandetailsgroupitemid = dbConnect.runSqlQuery("select t2.itemid,count(1) count from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplanid=" + sa_sendplanid + " and t1.siteid='" + siteid + "' group by t2.itemid HAVING COUNT(1) > 1");
|
|
|
- RowsMap sendplandetailsrowsMap =sendplandetails.toRowsMap("itemid");
|
|
|
- for(Row row :sendplandetailsgroupitemid){
|
|
|
- if(sendplandetailsrowsMap.containsKey(row.getString("itemid"))){
|
|
|
- BigDecimal sendqty=BigDecimal.ZERO;
|
|
|
- for(int a=0; a<sendplandetailsrowsMap.get(row.getString("itemid")).size();a++){
|
|
|
- if(a>0){
|
|
|
- list.add("update sa_sendplandetail set canuseqty=canuseqty-"+sendqty+" where sa_sendplandetailid="+sendplandetailsrowsMap.get(row.getString("itemid")).get(a).getLong("sa_sendplandetailid"));
|
|
|
+ RowsMap sendplandetailsrowsMap = sendplandetails.toRowsMap("itemid");
|
|
|
+ for (Row row : sendplandetailsgroupitemid) {
|
|
|
+ if (sendplandetailsrowsMap.containsKey(row.getString("itemid"))) {
|
|
|
+ BigDecimal sendqty = BigDecimal.ZERO;
|
|
|
+ for (int a = 0; a < sendplandetailsrowsMap.get(row.getString("itemid")).size(); a++) {
|
|
|
+ if (a > 0) {
|
|
|
+ list.add("update sa_sendplandetail set canuseqty=canuseqty-" + sendqty + " where sa_sendplandetailid=" + sendplandetailsrowsMap.get(row.getString("itemid")).get(a).getLong("sa_sendplandetailid"));
|
|
|
}
|
|
|
- sendqty=sendqty.add(sendplandetailsrowsMap.get(row.getString("itemid")).get(a).getBigDecimal("sendqty"));
|
|
|
+ sendqty = sendqty.add(sendplandetailsrowsMap.get(row.getString("itemid")).get(a).getBigDecimal("sendqty"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -257,24 +259,24 @@ public class sendplandetail extends Controller {
|
|
|
public String updatesendqty() throws YosException {
|
|
|
long sa_sendplandetailid = content.getLong("sa_sendplandetailid");
|
|
|
BigDecimal sendqty = content.getBigDecimal("sendqty");
|
|
|
- String outplace= content.getString("outplace");
|
|
|
+ String outplace = content.getString("outplace");
|
|
|
Rows sendplandetails = dbConnect.runSqlQuery("select t2.itemid,t1.sa_sendplanid from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplandetailid=" + sa_sendplandetailid + " and t1.siteid='" + siteid + "'");
|
|
|
- if(sendplandetails.isEmpty()){
|
|
|
+ if (sendplandetails.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("发货计划明细不存在").toString();
|
|
|
}
|
|
|
|
|
|
- dbConnect.runSqlUpdate("update sa_sendplandetail set sendqty=" + sendqty + ",outplace='"+outplace+"' where sa_sendplandetailid=" + sa_sendplandetailid);
|
|
|
+ dbConnect.runSqlUpdate("update sa_sendplandetail set sendqty=" + sendqty + ",outplace='" + outplace + "' where sa_sendplandetailid=" + sa_sendplandetailid);
|
|
|
|
|
|
|
|
|
ArrayList<String> list = new ArrayList<>();
|
|
|
- Rows sendplandetailsgroupitemid = dbConnect.runSqlQuery("select t2.itemid,t1.sa_sendplandetailid,t1.sendqty,t1.canuseqty from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplanid=" + sendplandetails.get(0).getLong("sa_sendplanid") + " and t2.itemid="+sendplandetails.get(0).getLong("itemid")+" and t1.siteid='" + siteid + "' order by t2.sa_orderid desc");
|
|
|
+ Rows sendplandetailsgroupitemid = dbConnect.runSqlQuery("select t2.itemid,t1.sa_sendplandetailid,t1.sendqty,t1.canuseqty from sa_sendplandetail t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid where t1.sa_sendplanid=" + sendplandetails.get(0).getLong("sa_sendplanid") + " and t2.itemid=" + sendplandetails.get(0).getLong("itemid") + " and t1.siteid='" + siteid + "' order by t2.sa_orderid desc");
|
|
|
BigDecimal sendqtyold = BigDecimal.ZERO;
|
|
|
- BigDecimal canuseqty= sendplandetailsgroupitemid.max("canuseqty");
|
|
|
- for(int a=0; a<sendplandetailsgroupitemid.size();a++){
|
|
|
- if(a>0){
|
|
|
- list.add("update sa_sendplandetail set canuseqty="+canuseqty.subtract(sendqtyold)+" where sa_sendplandetailid="+sendplandetailsgroupitemid.get(a).getLong("sa_sendplandetailid"));
|
|
|
+ BigDecimal canuseqty = sendplandetailsgroupitemid.max("canuseqty");
|
|
|
+ for (int a = 0; a < sendplandetailsgroupitemid.size(); a++) {
|
|
|
+ if (a > 0) {
|
|
|
+ list.add("update sa_sendplandetail set canuseqty=" + canuseqty.subtract(sendqtyold) + " where sa_sendplandetailid=" + sendplandetailsgroupitemid.get(a).getLong("sa_sendplandetailid"));
|
|
|
}
|
|
|
- sendqtyold=sendqtyold.add(sendplandetailsgroupitemid.get(a).getBigDecimal("sendqty"));
|
|
|
+ sendqtyold = sendqtyold.add(sendplandetailsgroupitemid.get(a).getBigDecimal("sendqty"));
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(list);
|
|
|
return getSucReturnObject().toString();
|
|
|
@@ -284,12 +286,12 @@ public class sendplandetail extends Controller {
|
|
|
@API(title = "生成销售出库单", apiversion = R.ID2025032709355603.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {sendplandetail.class})
|
|
|
public String createIcstockBill() throws YosException {
|
|
|
- long sa_sendplanid=content.getLong("sa_sendplanid");
|
|
|
- Rows rows = dbConnect.runSqlQuery("select * from sa_sendplan where sa_sendplanid="+sa_sendplanid);
|
|
|
- ArrayList<Long> sa_orderitemsids =new ArrayList<>();
|
|
|
+ long sa_sendplanid = content.getLong("sa_sendplanid");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_sendplan where sa_sendplanid=" + sa_sendplanid);
|
|
|
+ ArrayList<Long> sa_orderitemsids = new ArrayList<>();
|
|
|
|
|
|
- if(rows.isNotEmpty()){
|
|
|
- departmentid=rows.get(0).getLong("departmentid");
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ departmentid = rows.get(0).getLong("departmentid");
|
|
|
}
|
|
|
JSONArray detailarray = content.getJSONArray("details");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -321,16 +323,16 @@ public class sendplandetail extends Controller {
|
|
|
agent.put(key, paolist);
|
|
|
agentmap.put(sys_enterpriseid, agent);
|
|
|
}
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_orderitems","*");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_orderitems", "*");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("sa_orderitemsid", sa_orderitemsids);
|
|
|
Rows orderdetails = querySQL.query();
|
|
|
- RowsMap orderdetailsRowsMap=orderdetails.toRowsMap("sa_orderitemsid");
|
|
|
+ RowsMap orderdetailsRowsMap = orderdetails.toRowsMap("sa_orderitemsid");
|
|
|
Iterator<Map.Entry<String, HashMap<String, List<JSONObject>>>> iter = agentmap
|
|
|
.entrySet().iterator();
|
|
|
|
|
|
- ArrayList <Long> st_stockbillids =new ArrayList<Long>();
|
|
|
+ ArrayList<Long> st_stockbillids = new ArrayList<Long>();
|
|
|
|
|
|
while (iter.hasNext()) {
|
|
|
Map.Entry entry = (Map.Entry) iter.next();
|
|
|
@@ -364,8 +366,8 @@ public class sendplandetail extends Controller {
|
|
|
sqlFactory.addParameter("delivery", firstItem.getStringValue("delivery"));
|
|
|
} else {
|
|
|
sqlFactory.addParameter("outplace", "");
|
|
|
- sqlFactory.addParameter("rec_contactsid",0);
|
|
|
- sqlFactory.addParameter("delivery","");
|
|
|
+ sqlFactory.addParameter("rec_contactsid", 0);
|
|
|
+ sqlFactory.addParameter("delivery", "");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -375,7 +377,7 @@ public class sendplandetail extends Controller {
|
|
|
sqlFactory.addParameter("changeby", username);
|
|
|
sqlFactory.addParameter("changedate", getDateTime_Str());
|
|
|
sqlFactory.addParameter("checkby", "");
|
|
|
- sqlFactory.addParameter("checkdate","null");
|
|
|
+ sqlFactory.addParameter("checkdate", "null");
|
|
|
sqlFactory.addParameter("remarks", "");
|
|
|
sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
|
@@ -425,10 +427,10 @@ public class sendplandetail extends Controller {
|
|
|
detailquerySQL.setSiteid(siteid);
|
|
|
detailquerySQL.setWhere("t1.st_stockbillid", st_stockbillids);
|
|
|
Rows rowsdetail = detailquerySQL.query();
|
|
|
- RowsMap rowsdetailMap =rowsdetail.toRowsMap("st_stockbillid");
|
|
|
- for (long st_stockbillid :st_stockbillids){
|
|
|
- if(rowsdetailMap.containsKey(String.valueOf(st_stockbillid))){
|
|
|
- sqlList1.add("update st_stockbill set payamount="+ rowsdetailMap.get(String.valueOf(st_stockbillid)).sum("amount")+" where st_stockbillid="+st_stockbillid);
|
|
|
+ RowsMap rowsdetailMap = rowsdetail.toRowsMap("st_stockbillid");
|
|
|
+ for (long st_stockbillid : st_stockbillids) {
|
|
|
+ if (rowsdetailMap.containsKey(String.valueOf(st_stockbillid))) {
|
|
|
+ sqlList1.add("update st_stockbill set payamount=" + rowsdetailMap.get(String.valueOf(st_stockbillid)).sum("amount") + " where st_stockbillid=" + st_stockbillid);
|
|
|
}
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList1);
|
|
|
@@ -443,13 +445,13 @@ public class sendplandetail extends Controller {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "发货计划订单未发货量(简略)");
|
|
|
sqlFactory.addParameter_SQL("where", "1=1");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_sendplandetail", "sa_sendplanid","sa_sendplandetailid", "colorflag", "outplace", "sendqty", "willoutqty", "willinqty", "canuseqty");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_sendplandetail", "sa_sendplanid", "sa_sendplandetailid", "colorflag", "outplace", "sendqty", "willoutqty", "willinqty", "canuseqty");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t2", "t1.siteid = t2.siteid and t1.sa_orderid = t2.sa_orderid", "sonum", "checkdate", "sys_enterpriseid", "sa_orderid","rec_contactsid","delivery","invoicename","invoiceaddress");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_order", "t2", "t1.siteid = t2.siteid and t1.sa_orderid = t2.sa_orderid", "sonum", "checkdate", "sys_enterpriseid", "sa_orderid", "rec_contactsid", "delivery", "invoicename", "invoiceaddress");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_orderitems", "t3", "t3.siteid = t1.siteid and t3.sa_orderitemsid = t1.sa_orderitemsid", "rowno", "remarks", "sa_orderitemsid");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.siteid = t1.siteid and t4.sa_agentsid = t1.sa_agentsid", "agentnum");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t5.siteid = t4.siteid and t5.sys_enterpriseid = t4.sys_enterpriseid", "enterprisename", "abbreviation");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t6", "t6.siteid = t3.siteid and t6.itemid = t3.itemid", "itemno", "itemname", "model", "itemid","topclassnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t6", "t6.siteid = t3.siteid and t6.itemid = t3.itemid", "itemno", "itemname", "model", "itemid", "topclassnum");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, sqlFactory, "t7", "t7.sa_orderitemsid = t3.sa_orderitemsid", "undeliqty");
|
|
|
querySQL.addQueryFields("willoutqty_jh", "t7.willoutqty");
|
|
|
querySQL.addQueryFields("sendqty_canzhao", "t1.sendqty");
|
|
|
@@ -461,42 +463,42 @@ public class sendplandetail extends Controller {
|
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
|
|
|
- QuerySQL querySQL_ck=SQLFactory.createQuerySQL(this,"st_invbal","itemid","qty");
|
|
|
+ QuerySQL querySQL_ck = SQLFactory.createQuerySQL(this, "st_invbal", "itemid", "qty");
|
|
|
querySQL_ck.setTableAlias("t1");
|
|
|
querySQL_ck.addJoinTable(JOINTYPE.left, "st_stock", "t2", "t1.siteid = t2.siteid and t1.stockid = t2.stockid", "stockno");
|
|
|
querySQL_ck.setSiteid(siteid);
|
|
|
querySQL_ck.setWhere("t1.itemid", rows.toArrayList("itemid"));
|
|
|
Rows rows_ck = querySQL_ck.query();
|
|
|
- RowsMap rowsCkRowsMap =rows_ck.toRowsMap("stockno");
|
|
|
- for(Row row :rows){
|
|
|
- if(rowsCkRowsMap.containsKey("101")){
|
|
|
- if(rowsCkRowsMap.get("101").toRowsMap("itemid").containsKey(row.getString("itemid"))){
|
|
|
- row.put("qty_xs",rowsCkRowsMap.get("101").toRowsMap("itemid").get(row.getString("itemid")).get(0).getBigDecimal("qty"));
|
|
|
- }else{
|
|
|
- row.put("qty_xs",0);
|
|
|
+ RowsMap rowsCkRowsMap = rows_ck.toRowsMap("stockno");
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (rowsCkRowsMap.containsKey("101")) {
|
|
|
+ if (rowsCkRowsMap.get("101").toRowsMap("itemid").containsKey(row.getString("itemid"))) {
|
|
|
+ row.put("qty_xs", rowsCkRowsMap.get("101").toRowsMap("itemid").get(row.getString("itemid")).get(0).getBigDecimal("qty"));
|
|
|
+ } else {
|
|
|
+ row.put("qty_xs", 0);
|
|
|
}
|
|
|
- }else{
|
|
|
- row.put("qty_xs",0);
|
|
|
+ } else {
|
|
|
+ row.put("qty_xs", 0);
|
|
|
}
|
|
|
|
|
|
- if(rowsCkRowsMap.containsKey("103")){
|
|
|
- if(rowsCkRowsMap.get("103").toRowsMap("itemid").containsKey(row.getString("itemid"))){
|
|
|
- row.put("qty_tq",rowsCkRowsMap.get("103").toRowsMap("itemid").get(row.getString("itemid")).get(0).getBigDecimal("qty"));
|
|
|
- }else{
|
|
|
- row.put("qty_tq",0);
|
|
|
+ if (rowsCkRowsMap.containsKey("103")) {
|
|
|
+ if (rowsCkRowsMap.get("103").toRowsMap("itemid").containsKey(row.getString("itemid"))) {
|
|
|
+ row.put("qty_tq", rowsCkRowsMap.get("103").toRowsMap("itemid").get(row.getString("itemid")).get(0).getBigDecimal("qty"));
|
|
|
+ } else {
|
|
|
+ row.put("qty_tq", 0);
|
|
|
}
|
|
|
- }else{
|
|
|
- row.put("qty_tq",0);
|
|
|
+ } else {
|
|
|
+ row.put("qty_tq", 0);
|
|
|
}
|
|
|
|
|
|
- if(rowsCkRowsMap.containsKey("109")){
|
|
|
- if(rowsCkRowsMap.get("109").toRowsMap("itemid").containsKey(row.getString("itemid"))){
|
|
|
- row.put("qty_mq",rowsCkRowsMap.get("109").toRowsMap("itemid").get(row.getString("itemid")).get(0).getBigDecimal("qty"));
|
|
|
- }else{
|
|
|
- row.put("qty_mq",0);
|
|
|
+ if (rowsCkRowsMap.containsKey("109")) {
|
|
|
+ if (rowsCkRowsMap.get("109").toRowsMap("itemid").containsKey(row.getString("itemid"))) {
|
|
|
+ row.put("qty_mq", rowsCkRowsMap.get("109").toRowsMap("itemid").get(row.getString("itemid")).get(0).getBigDecimal("qty"));
|
|
|
+ } else {
|
|
|
+ row.put("qty_mq", 0);
|
|
|
}
|
|
|
- }else{
|
|
|
- row.put("qty_mq",0);
|
|
|
+ } else {
|
|
|
+ row.put("qty_mq", 0);
|
|
|
}
|
|
|
|
|
|
}
|