|
|
@@ -0,0 +1,236 @@
|
|
|
+package restcontroller.webmanage.sale.supplier;
|
|
|
+
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.annotation.CACHEING;
|
|
|
+import common.annotation.CACHEING_CLEAN;
|
|
|
+import common.data.*;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
+@API(title = "供应商")
|
|
|
+public class supplier extends Controller {
|
|
|
+ public supplier(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "新增更新供应商", apiversion = R.ID2025070213232103.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {supplier.class})
|
|
|
+ public String insertormodify_supplier() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ // 表名
|
|
|
+ String tableName = "sa_supplier";
|
|
|
+ Long sa_supplierid = content.getLong("sa_supplierid");
|
|
|
+ String suppno =content.getStringValue("suppno");
|
|
|
+ String suppname = content.getStringValue("suppname");
|
|
|
+ String suppshortname = content.getStringValue("suppshortname");
|
|
|
+ String remarks = content.getStringValue("remarks");
|
|
|
+ if (sa_supplierid <= 0 || dbConnect.runSqlQuery(
|
|
|
+ "select sa_supplierid from sa_supplier where sa_supplierid=" + sa_supplierid)
|
|
|
+ .isEmpty()) {
|
|
|
+ sa_supplierid = createTableID(tableName);
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, tableName);
|
|
|
+ insertSQL.setUniqueid(sa_supplierid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("suppno", suppno);
|
|
|
+ insertSQL.setValue("suppname", suppname);
|
|
|
+ insertSQL.setValue("suppshortname",suppshortname);
|
|
|
+ insertSQL.setValue("remarks", remarks);
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ insertSQL.setValue("isused", false);
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_supplier", sa_supplierid, "新增", "供应商新增成功").getSQL());
|
|
|
+ } else {
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
+ "SELECT status from sa_supplier WHERE sa_supplierid = "
|
|
|
+ + sa_supplierid);
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ if (rows.get(0).getString("status").equals("新建")) {
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, tableName);
|
|
|
+ updateSQL.setUniqueid(sa_supplierid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("suppno", suppno);
|
|
|
+ updateSQL.setValue("suppname", suppname);
|
|
|
+ updateSQL.setValue("suppshortname",suppshortname);
|
|
|
+ updateSQL.setValue("remarks", remarks);
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_supplier", sa_supplierid, "更新", "供应商更新成功")
|
|
|
+ .getSQL());
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("该供应商不存在").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ content.put("sa_supplierid", sa_supplierid);
|
|
|
+
|
|
|
+ return querysupplierMain();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "供应商详情", apiversion = R.ID2025070213283503.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querysupplierMain() throws YosException {
|
|
|
+ Long sa_supplierid = content.getLong("sa_supplierid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_supplier", "*");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setWhere("t1.sa_supplierid",sa_supplierid);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询供应商列表", apiversion = R.ID2025070213285403.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String querysupplierList() throws YosException {
|
|
|
+ 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("t1.suppno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(" or t1.suppname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(" or t1.suppshortname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("isused") && !"".equals(whereObject.getString("isused"))) {
|
|
|
+ where.append(" and t1.isused ='").append(whereObject.getString("isused")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_supplier", "*");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere(where.toString());
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "删除", apiversion = R.ID2025070213311303.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {supplier.class})
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray sa_supplierids = content.getJSONArray("sa_supplierids");
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_supplierids.size());
|
|
|
+ for (Object o : sa_supplierids) {
|
|
|
+ long sa_supplierid = Long.parseLong(o.toString());
|
|
|
+ Rows RowsStatus = dbConnect
|
|
|
+ .runSqlQuery("select sa_supplierid,status from sa_supplier where siteid='" + siteid
|
|
|
+ + "' and sa_supplierid='" + sa_supplierid + "'");
|
|
|
+
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
+ if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
+ batchDeleteErr.addErr(sa_supplierid, "非新建状态的供应商无法删除");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate("delete from sa_supplier where siteid='" + siteid + "' and sa_supplierid="
|
|
|
+ + sa_supplierid);
|
|
|
+ }
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "审核", apiversion = R.ID2025070213312503.v1.class)
|
|
|
+ @CACHEING_CLEAN( apiClass = {supplier.class})
|
|
|
+ public String check() throws YosException {
|
|
|
+ Long sa_supplierid = content.getLong("sa_supplierid");
|
|
|
+ boolean ischeck = content.getBooleanValue("ischeck");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.sa_supplierid,t1.status,t1.suppno from sa_supplier t1 where t1.sa_supplierid ='"
|
|
|
+ + sa_supplierid + "' and t1.siteid='" + siteid + "'");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ if(ischeck){
|
|
|
+ if (!row.getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态的【"+row.getString("suppno")+"】供应商无法审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (!row.getString("status").equals("审核")) {
|
|
|
+ return getErrReturnObject().setErrMsg("非审核状态的【"+row.getString("suppno")+"】供应商无法反审核")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_supplier");
|
|
|
+ updateSQL.setUniqueid(sa_supplierid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", ischeck?"审核":"新建");
|
|
|
+ updateSQL.setValue("checkby", ischeck?username:"null");
|
|
|
+ if(ischeck){
|
|
|
+ updateSQL.setDateValue("checkdate");
|
|
|
+ }else{
|
|
|
+ updateSQL.setValue("checkdate","null");
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ if (ischeck) {
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_supplier", sa_supplierid, "审核", "供应商审核成功").getSQL());
|
|
|
+ } else {
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_supplier", sa_supplierid, "反审核", "供应商审核成功").getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "是否启用", apiversion = R.ID2025070213313403.v1.class)
|
|
|
+ @CACHEING_CLEAN( apiClass = {supplier.class})
|
|
|
+ public String isused() throws YosException {
|
|
|
+ Long sa_supplierid = content.getLong("sa_supplierid");
|
|
|
+ boolean isused = content.getBooleanValue("isused");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.sa_supplierid,t1.status,t1.suppno from sa_supplier t1 where t1.sa_supplierid ='"
|
|
|
+ + sa_supplierid + "' and t1.siteid='" + siteid + "'");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (row.getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("非审核状态的【"+row.getString("suppno")+"】供应商无法启用停用")
|
|
|
+ .toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_supplier");
|
|
|
+ updateSQL.setUniqueid(sa_supplierid);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("isused", isused);
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+ if (isused) {
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_supplier", sa_supplierid, "启用", "供应商启用成功").getSQL());
|
|
|
+ } else {
|
|
|
+ sqlList.add(
|
|
|
+ DataContrlLog.createLog(this, "sa_supplier", sa_supplierid, "停用", "供应商停用成功").getSQL());
|
|
|
+ }
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|