|
|
@@ -428,10 +428,24 @@ public class aftersalesmag extends Controller {
|
|
|
// Rows rows = dbConnect
|
|
|
// .runSqlQuery("select sa_aftersalesmagid,status,billno from sa_aftersalesmag where sa_aftersalesmagid ='"
|
|
|
// + sa_aftersalesmagid + "' and siteid='" + siteid + "'");
|
|
|
+ long stockid=0;
|
|
|
+ long st_stockbillidold=0;
|
|
|
+ Rows stockrows = dbConnect.runSqlQuery("select t1.stockid from st_stock t1 where t1.stockname ='返修仓库' and t1.siteid='" + siteid + "'");
|
|
|
+ if(!stockrows.isEmpty()){
|
|
|
+ stockid=stockrows.get(0).getLong("stockid");
|
|
|
+ }
|
|
|
Rows rows = dbConnect.runSqlQuery("select t1.*,t3.agentnum,t2.enterprisename from sa_aftersalesmag t1 left join sys_enterprise t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_agents t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid where t1.sa_aftersalesmagid ='"
|
|
|
+ sa_aftersalesmagid + "' and t1.siteid='" + siteid + "'");
|
|
|
- Rows rowsdetail = dbConnect.runSqlQuery("select t4.itemno,t2.batchno,t1.qty,t1.price,t1.reason from sa_aftersalesmag_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join plm_item t4 on t1.itemid=t4.itemid and t1.siteid=t4.siteid where t1.sa_aftersalesmagid ='"
|
|
|
+ Rows rowsdetail = dbConnect.runSqlQuery("select t1.sa_aftersalesmag_itemsid,t1.machinecode,t1.itemid,t4.itemno,t4.model,t2.batchno,t1.qty,t1.price,t1.reason from sa_aftersalesmag_items t1 left join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid left join plm_item t4 on t1.itemid=t4.itemid and t1.siteid=t4.siteid where t1.sa_aftersalesmagid ='"
|
|
|
+ sa_aftersalesmagid + "' and t1.siteid='" + siteid + "'");
|
|
|
+ if(rows.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("返退单不存在")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ if(rowsdetail.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("返退单明细为空,无法审核反审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
for (Row row : rows) {
|
|
|
if (ischeck) {
|
|
|
if (!row.getString("status").equals("确认")) {
|
|
|
@@ -443,16 +457,68 @@ public class aftersalesmag extends Controller {
|
|
|
return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的返退单为非审核状态,无法反审核")
|
|
|
.toString();
|
|
|
}
|
|
|
+ Rows stockbillrows =dbConnect.runSqlQuery("select st_stockbillid,status from st_stockbill where sourceobject ='sa_aftersalesmag' and sourceid="+sa_aftersalesmagid+" and siteid='"+siteid+"'");
|
|
|
+ if(stockbillrows.isNotEmpty()){
|
|
|
+ st_stockbillidold=stockbillrows.get(0).getLong("st_stockbillid");
|
|
|
+ if(!stockbillrows.get(0).getString("status").equals("新建")){
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的返退单对应的返退入库单为非新建状态,无法反审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
SQLFactory sqlFactoryupdate;
|
|
|
if (ischeck) {
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
+ long st_stockbillid = createTableID("st_stockbill");
|
|
|
+ insertSQL.setUniqueid(st_stockbillid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
+ insertSQL.setValue("type", "返退入库");
|
|
|
+// insertSQL.setValue("typemx", "");
|
|
|
+ insertSQL.setValue("sys_enterpriseid",rows.get(0).getLong("sys_enterpriseid"));
|
|
|
+ insertSQL.setValue("rb", 1);
|
|
|
+ insertSQL.setValue("sourceobject", "sa_aftersalesmag");
|
|
|
+ insertSQL.setValue("sourceid", sa_aftersalesmagid);
|
|
|
+ insertSQL.setValue("stockid", stockid);
|
|
|
+ insertSQL.setValue("remarks", rows.get(0).getString("remarks"));
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ insertSQL.setValue("createby",username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setDateValue("billdate");
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+
|
|
|
+ int i=1;
|
|
|
+ for(Row row :rowsdetail){
|
|
|
+ insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ long st_stockbill_itemsid = createTableID("st_stockbill_items");
|
|
|
+ insertSQL.setUniqueid(st_stockbill_itemsid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("rowno",i);
|
|
|
+ insertSQL.setValue("sa_dispatch_itemsid",0);
|
|
|
+ insertSQL.setValue("sourceobject", "sa_aftersalesmag_items");
|
|
|
+ insertSQL.setValue("sourceid", row.getLong("sa_aftersalesmag_itemsid"));
|
|
|
+ insertSQL.setValue("stockid", row.getLong("outstockid"));
|
|
|
+ insertSQL.setValue("itemid",row.getLong("itemid"));
|
|
|
+ insertSQL.setValue("itemno",row.getString("itemno"));
|
|
|
+ insertSQL.setValue("itemname",row.getString("itemname"));
|
|
|
+ insertSQL.setValue("model",row.getString("model"));
|
|
|
+ insertSQL.setValue("sku",row.getString("machinecode"));
|
|
|
+ insertSQL.setValue("qty",row.getBigDecimal("qty"));
|
|
|
+ insertSQL.setValue("isrepair",false);
|
|
|
+ insertSQL.setValue("st_stockbillid",st_stockbillid);
|
|
|
+ i++;
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
sqlFactoryupdate = new SQLFactory(this, "返退单审核");
|
|
|
sqlList.add(
|
|
|
DataContrlLog.createLog(this, "sa_aftersalesmag", sa_aftersalesmagid, "审核", "返退单审核成功").getSQL());
|
|
|
} else {
|
|
|
+ sqlList.add("delete from st_stockbill where sourceobject ='sa_aftersalesmag' and sourceid="+sa_aftersalesmagid+" and siteid='"+siteid+"'");
|
|
|
+ sqlList.add("delete from st_stockbill_items where st_stockbillid="+st_stockbillidold+" and siteid='"+siteid+"'");
|
|
|
sqlFactoryupdate = new SQLFactory(this, "返退单反审核");
|
|
|
sqlList.add(
|
|
|
DataContrlLog.createLog(this, "sa_aftersalesmag", sa_aftersalesmagid, "反审核", "返退单反审核成功").getSQL());
|