|
@@ -52,11 +52,15 @@ public class Stock extends Controller {
|
|
|
Long stockid = content.getLong("stockid");
|
|
|
String stockname = content.getString("stockname");
|
|
|
String stockno = content.getString("stockno");
|
|
|
- Long isused = content.getLong("isused");
|
|
|
- Long issalestock = content.getLong("issalestock");
|
|
|
+ Long isused = content.getLongValue("isused");
|
|
|
+ Long issalestock = content.getLongValue("issalestock");
|
|
|
+ String type = content.getStringValue("type");
|
|
|
+ boolean isnegative = content.getBooleanValue("isnegative");
|
|
|
+ boolean isintotalstock = content.getBooleanValue("isintotalstock");
|
|
|
Rows rows = dbConnect.runSqlQuery("select stockid from st_stock where siteid='" + siteid + "' and stockname = '" + stockname + "'");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "仓库新增");
|
|
|
- if (stockid == 0 || dbConnect.runSqlQuery("select 1 from st_stock where siteid='" + siteid + "' and stockid=" + stockid).isEmpty()) {
|
|
|
+ Rows stockrows = dbConnect.runSqlQuery("select * from st_stock where siteid='" + siteid + "' and stockid=" + stockid);
|
|
|
+ if (stockid <= 0 || stockrows.isEmpty()) {
|
|
|
if (rows.isNotEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该仓库已存在").toString();
|
|
|
}
|
|
@@ -65,6 +69,9 @@ public class Stock extends Controller {
|
|
|
if (rows.isNotEmpty() && stockid != rows.get(0).getLong("stockid")) {
|
|
|
return getErrReturnObject().setErrMsg("该仓库已存在").toString();
|
|
|
}
|
|
|
+ if(stockrows.get(0).getBoolean("isused")){
|
|
|
+ return getErrReturnObject().setErrMsg("该仓库已启用,无法更新").toString();
|
|
|
+ }
|
|
|
sqlFactory = new SQLFactory(this, "仓库更新");
|
|
|
}
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
@@ -75,6 +82,9 @@ public class Stock extends Controller {
|
|
|
sqlFactory.addParameter("stockno", stockno);
|
|
|
sqlFactory.addParameter("isused", isused);
|
|
|
sqlFactory.addParameter("issalestock", issalestock);
|
|
|
+ sqlFactory.addParameter("type",type);
|
|
|
+ sqlFactory.addParameter("isnegative",isnegative);
|
|
|
+ sqlFactory.addParameter("isintotalstock",isintotalstock);
|
|
|
dbConnect.runSqlUpdate(sqlFactory.getSQL());
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
@@ -100,10 +110,14 @@ public class Stock extends Controller {
|
|
|
@API(title = "删除", apiversion = R.ID20230104095004.v1.class)
|
|
|
@CACHEING_CLEAN(apiversions = {R.ID20230104094604.v1.class})
|
|
|
public String delete() throws YosException {
|
|
|
- JSONArray stockids = content.getJSONArray("stockids");
|
|
|
+ long stockid = content.getLong("stockid");
|
|
|
+ Rows rows =dbConnect.runSqlQuery("select * from st_invbal where stockid="+stockid+" and siteid='"+siteid+"'");
|
|
|
+ if(rows.isNotEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("已有库存数据的仓库不允许删除").toString();
|
|
|
+ }
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "仓库删除");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_in("stockids", stockids.toArray());
|
|
|
+ sqlFactory.addParameter("stockid", stockid);
|
|
|
dbConnect.runSqlUpdate(sqlFactory.getSQL());
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|