|
@@ -0,0 +1,197 @@
|
|
|
|
|
+package restcontroller.webmanage.sale.sizecustomizedscheme;
|
|
|
|
|
+
|
|
|
|
|
+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.Row;
|
|
|
|
|
+import common.data.Rows;
|
|
|
|
|
+import common.data.SQLFactory;
|
|
|
|
|
+import restcontroller.R;
|
|
|
|
|
+import restcontroller.sale.item.Item;
|
|
|
|
|
+
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+
|
|
|
|
|
+public class sizecustomizedscheme extends Controller {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构造函数
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ */
|
|
|
|
|
+ public sizecustomizedscheme(JSONObject content) throws YosException {
|
|
|
|
|
+ super(content);
|
|
|
|
|
+ }
|
|
|
|
|
+ @API(title = "尺寸定制方案单新增更新", apiversion = R.ID20230707091503.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {sizecustomizedscheme.class, Item.class, restcontroller.webmanage.sale.item.Item.class})
|
|
|
|
|
+ public String insertormodify_sizecustomizedscheme() throws YosException {
|
|
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
+ // 表名
|
|
|
|
|
+ String tableName = "sa_sizecustomizedscheme";
|
|
|
|
|
+ Long sa_sizecustomizedschemeid = content.getLong("sa_sizecustomizedschemeid");
|
|
|
|
|
+ String schemename = content.getStringValue("schemename");
|
|
|
|
|
+ String schemedescription = content.getStringValue("schemedescription");
|
|
|
|
|
+ String type = content.getStringValue("type");
|
|
|
|
|
+ BigDecimal min =content.getBigDecimalValue("min");
|
|
|
|
|
+ BigDecimal max =content.getBigDecimalValue("max");
|
|
|
|
|
+ int decimalplaces =content.getIntValue("decimalplaces");
|
|
|
|
|
+
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "尺寸定制方案新增");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sa_sizecustomizedschemeid <= 0 || dbConnect.runSqlQuery(
|
|
|
|
|
+ "select sa_sizecustomizedschemeid from sa_sizecustomizedscheme where sa_sizecustomizedschemeid=" + sa_sizecustomizedschemeid)
|
|
|
|
|
+ .isEmpty()) {
|
|
|
|
|
+ sa_sizecustomizedschemeid = createTableID(tableName);
|
|
|
|
|
+ sqlList.add(
|
|
|
|
|
+ DataContrlLog.createLog(this, "sa_sizecustomizedscheme", sa_sizecustomizedschemeid, "新增", "尺寸定制方案新增成功").getSQL());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
|
|
+ "SELECT status from sa_sizecustomizedscheme WHERE sa_sizecustomizedschemeid = "
|
|
|
|
|
+ + sa_sizecustomizedschemeid);
|
|
|
|
|
+ if (!rows.get(0).getString("status").equals("新建")) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态的尺寸定制方案无法修改").toString();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlFactory = new SQLFactory(this, "尺寸定制方案更新");
|
|
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_sizecustomizedscheme", sa_sizecustomizedschemeid, "更新", "尺寸定制方案更新成功")
|
|
|
|
|
+ .getSQL());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ sqlFactory.addParameter("userid", userid);
|
|
|
|
|
+ sqlFactory.addParameter("username", username);
|
|
|
|
|
+ sqlFactory.addParameter("sa_sizecustomizedschemeid", sa_sizecustomizedschemeid);
|
|
|
|
|
+ //尺寸定制方案单号createBillCode("sizecustomizedschemebill")
|
|
|
|
|
+ sqlFactory.addParameter("billno", "123456");
|
|
|
|
|
+ sqlFactory.addParameter("schemename", schemename);
|
|
|
|
|
+ sqlFactory.addParameter("schemedescription", schemedescription);
|
|
|
|
|
+ sqlFactory.addParameter("type", type);
|
|
|
|
|
+ sqlFactory.addParameter("min", min);
|
|
|
|
|
+ sqlFactory.addParameter("max", max);
|
|
|
|
|
+ sqlFactory.addParameter("decimalplaces", decimalplaces);
|
|
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+
|
|
|
|
|
+ content.put("sa_sizecustomizedschemeid", sa_sizecustomizedschemeid);
|
|
|
|
|
+
|
|
|
|
|
+ return querysizecustomizedschemeMain();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @API(title = "尺寸定制方案单详情", apiversion = R.ID20230707091603.v1.class)
|
|
|
|
|
+ @CACHEING
|
|
|
|
|
+ public String querysizecustomizedschemeMain() throws YosException {
|
|
|
|
|
+ Long sa_sizecustomizedschemeid = content.getLong("sa_sizecustomizedschemeid");
|
|
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "尺寸定制方案详情查询");
|
|
|
|
|
+ sqlFactory.addParameter("sa_sizecustomizedschemeid", sa_sizecustomizedschemeid);
|
|
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
|
|
+
|
|
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @API(title = "查询尺寸定制方案单列表", apiversion = R.ID20230707091703.v1.class)
|
|
|
|
|
+ @CACHEING
|
|
|
|
|
+ public String querysizecustomizedschemeList() 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.billno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t1.schemename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append("or t1.schemedescription like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
|
|
+ where.append(")");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
|
|
+ where.append("and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ SQLFactory 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 = "审核核反审核", apiversion = R.ID20230707111103.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {sizecustomizedscheme.class})
|
|
|
|
|
+ public String check() throws YosException {
|
|
|
|
|
+ Long sa_sizecustomizedschemeid = content.getLong("sa_sizecustomizedschemeid");
|
|
|
|
|
+ boolean ischeck = content.getBooleanValue("ischeck");
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select * from sa_sizecustomizedscheme where sa_sizecustomizedschemeid ='"
|
|
|
|
|
+ + sa_sizecustomizedschemeid + "' and siteid='" + siteid + "'");
|
|
|
|
|
+ for (Row row : rows) {
|
|
|
|
|
+ if (ischeck) {
|
|
|
|
|
+ if (!row.getString("status").equals("新建")) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的返退单为非新建状态,无法审核")
|
|
|
|
|
+ .toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (!row.getString("status").equals("审核")) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的返退单为非审核状态,无法反审核")
|
|
|
|
|
+ .toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
+ SQLFactory sqlFactoryupdate;
|
|
|
|
|
+ if (ischeck) {
|
|
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "尺寸定制方案审核");
|
|
|
|
|
+ sqlList.add(
|
|
|
|
|
+ DataContrlLog.createLog(this, "sa_sizecustomizedscheme", sa_sizecustomizedschemeid, "审核", "尺寸定制方案审核成功").getSQL());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlFactoryupdate = new SQLFactory(this, "尺寸定制方案反审核");
|
|
|
|
|
+ sqlList.add(
|
|
|
|
|
+ DataContrlLog.createLog(this, "sa_sizecustomizedscheme", sa_sizecustomizedschemeid, "反审核", "尺寸定制方案反审核成功").getSQL());
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlFactoryupdate.addParameter("siteid", siteid);
|
|
|
|
|
+ sqlFactoryupdate.addParameter("sa_sizecustomizedschemeid", sa_sizecustomizedschemeid);
|
|
|
|
|
+ sqlFactoryupdate.addParameter("username", username);
|
|
|
|
|
+ sqlList.add(sqlFactoryupdate.getSQL());
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+ return getSucReturnObject().toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @API(title = "删除", apiversion = R.ID20230707091803.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {sizecustomizedscheme.class})
|
|
|
|
|
+ public String delete() throws YosException {
|
|
|
|
|
+
|
|
|
|
|
+ JSONArray sa_sizecustomizedschemeids = content.getJSONArray("sa_sizecustomizedschemeids");
|
|
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_sizecustomizedschemeids.size());
|
|
|
|
|
+ for (Object o : sa_sizecustomizedschemeids) {
|
|
|
|
|
+ long sa_sizecustomizedschemeid = Long.parseLong(o.toString());
|
|
|
|
|
+ Rows RowsStatus = dbConnect
|
|
|
|
|
+ .runSqlQuery("select * from sa_sizecustomizedscheme where status !='新建' and siteid='" + siteid
|
|
|
|
|
+ + "' and sa_sizecustomizedschemeid='" + sa_sizecustomizedschemeid + "'");
|
|
|
|
|
+ Rows RowsCount = dbConnect
|
|
|
|
|
+ .runSqlQuery("select * from plm_item where (widthschemeid="+sa_sizecustomizedschemeid +" or lengthschemeid="+sa_sizecustomizedschemeid +") and siteid='"+siteid+"'");
|
|
|
|
|
+
|
|
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
|
|
+ batchDeleteErr.addErr(sa_sizecustomizedschemeid, "非新建状态的尺寸定制方案无法删除");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (RowsCount.isNotEmpty()) {
|
|
|
|
|
+ batchDeleteErr.addErr(sa_sizecustomizedschemeid, "已在商品档案中使用的尺寸定制方案明细无法删除");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ dbConnect.runSqlUpdate("delete from sa_sizecustomizedscheme where siteid='" + siteid + "' and sa_sizecustomizedschemeid="
|
|
|
|
|
+ + sa_sizecustomizedschemeid);
|
|
|
|
|
+ }
|
|
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|