123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- package restcontroller.webmanage.sale.customscheme;
- import beans.data.BatchDeleteErr;
- 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.RowsMap;
- import common.data.SQLFactory;
- import org.apache.commons.io.filefilter.FalseFileFilter;
- import restcontroller.R;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- public class customschemeItems extends Controller {
- /**
- * 构造函数
- *
- * @param content
- */
- public customschemeItems(JSONObject content) throws YosException {
- super(content);
- }
- @API(title = "方案选择列表查询", apiversion = R.ID20230325133303.v1.class)
- @CACHEING
- public String querySelectSchemeList() throws YosException {
- /*
- * 过滤条件设置
- */
- Long sa_customschemeid = content.getLong("sa_customschemeid");
- Rows rows = dbConnect.runSqlQuery("select value from sa_customscheme_items where sa_customschemeid="+sa_customschemeid);
- Rows selectRows = new Rows();
- JSONObject jsonObject1 =new JSONObject();
- JSONObject jsonObject2 =new JSONObject();
- JSONObject jsonObject3 =new JSONObject();
- JSONObject jsonObject4 =new JSONObject();
- if(siteid.equalsIgnoreCase("DLB")){
- jsonObject1.put("value", "spec");
- jsonObject1.put("description", "尺寸");
- jsonObject2.put("value", "material");
- jsonObject2.put("description", "选项");
- jsonObject3.put("value", "color");
- jsonObject3.put("description", "颜色");
- jsonObject4.put("value", "cheek");
- jsonObject4.put("description", "工艺");
- }else {
- jsonObject1.put("value", "spec");
- jsonObject1.put("description", "尺寸");
- jsonObject2.put("value", "material");
- jsonObject2.put("description", "基材");
- jsonObject3.put("value", "color");
- jsonObject3.put("description", "颜色");
- jsonObject4.put("value", "cheek");
- jsonObject4.put("description", "边框");
- }
- boolean hsacolor =false;
- boolean hsamaterial =false;
- boolean hsaspec =false;
- boolean hsacheek =false;
- if(!rows.isEmpty()){
- for (Row row:rows) {
- if(row.getString("value").equals("color")){
- hsacolor=true;
- }
- if(row.getString("value").equals("material")){
- hsamaterial=true;
- }
- if(row.getString("value").equals("spec")){
- hsaspec=true;
- }
- if(row.getString("value").equals("cheek")){
- hsacheek=true;
- }
- }
- }
- JSONArray jsonArray = new JSONArray();
- if(!hsacolor){
- jsonArray.add(jsonObject3);
- }
- if(!hsamaterial){
- jsonArray.add(jsonObject2);
- }
- if(!hsaspec){
- jsonArray.add(jsonObject1);
- }
- if(!hsacheek){
- jsonArray.add(jsonObject4);
- }
- return getSucReturnObject().setData(jsonArray).toString();
- }
- @API(title = "新建或修改商品定制方案明细", apiversion = R.ID20230321155503.v1.class,intervaltime = 200)
- @CACHEING_CLEAN(apiClass = {customschemeItems.class})
- public String insertormodify_customschemeItems() throws YosException {
- Long sa_customschemeid = content.getLong("sa_customschemeid");
- JSONArray iteminfos = content.getJSONArray("iteminfos");
- ArrayList<String> sqlList = new ArrayList<>();
- Rows rowscount = dbConnect.runSqlQuery("select sa_customschemeid from sa_customscheme where sa_customschemeid=" + sa_customschemeid);
- Rows RowsStatus = dbConnect.runSqlQuery("select itemid from plm_item where siteid='" + siteid + "' and sa_customschemeid='" + sa_customschemeid + "'");
- if (rowscount.isEmpty()) {
- return getErrReturnObject().setErrMsg("该商品定制方案不存在").toString();
- }
- if (RowsStatus.isNotEmpty()) {
- return getErrReturnObject().setErrMsg("已在商品档案中使用的定制方案明细无法新增修改").toString();
- }
- int i = 0;
- long[] sa_customscheme_itemsid = createTableID("sa_customscheme_items", iteminfos.size());
- for (Object obj : iteminfos) {
- JSONObject iteminfo = (JSONObject) obj;
- if (iteminfo.getLong("sa_customscheme_itemsid") <= 0 || dbConnect
- .runSqlQuery("select sa_customscheme_itemsid from sa_customscheme_items where sa_customscheme_itemsid="
- + iteminfo.getLong("sa_customscheme_itemsid"))
- .isEmpty()) {
- if(i==0){
- sqlList.add("delete from sa_customscheme_items where sa_customschemeid="+sa_customschemeid);
- }
- SQLFactory saleFactory = new SQLFactory(this, "商品定制方案明细新增");
- System.out.println("1234");
- saleFactory.addParameter("siteid", siteid);
- saleFactory.addParameter("sa_customscheme_itemsid", sa_customscheme_itemsid[i]);
- saleFactory.addParameter("sa_customschemeid", sa_customschemeid);
- saleFactory.addParameter("value", iteminfo.getStringValue("value"));
- saleFactory.addParameter("description", iteminfo.getStringValue("description"));
- saleFactory.addParameter("isonlydisplay", iteminfo.getLongValue("isonlydisplay"));
- sqlList.add(saleFactory.getSQL());
- i++;
- } else {
- SQLFactory saleFactory = new SQLFactory(this, "商品定制方案明细更新");
- saleFactory.addParameter("siteid", siteid);
- saleFactory.addParameter("sa_customscheme_itemsid", iteminfo.getLongValue("sa_customscheme_itemsid"));
- saleFactory.addParameter("sa_customschemeid", sa_customschemeid);
- saleFactory.addParameter("value", iteminfo.getStringValue("value"));
- saleFactory.addParameter("description", iteminfo.getStringValue("description"));
- saleFactory.addParameter("isonlydisplay", iteminfo.getLongValue("isonlydisplay"));
- sqlList.add(saleFactory.getSQL());
- }
- }
- dbConnect.runSqlUpdate(sqlList);
- return querycustomschemeItemsList();
- }
- @API(title = "商品定制方案明细明细列表", apiversion = R.ID20230321155603.v1.class)
- @CACHEING
- public String querycustomschemeItemsList() 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.value like'%").append(whereObject.getString("condition")).append("%' ");
- where.append("or t1.description like'%").append(whereObject.getString("condition")).append("%' ");
- where.append(")");
- }
- }
- Long sa_customschemeid = content.getLong("sa_customschemeid");
- // String hrid = content.getString("hrid");
- SQLFactory sqlFactory = new SQLFactory(this, "商品定制方案明细列表查询", pageSize, pageNumber, pageSorting);
- sqlFactory.addParameter_SQL("where", where);
- sqlFactory.addParameter("sa_customschemeid", sa_customschemeid);
- sqlFactory.addParameter("siteid", siteid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "删除明细", apiversion = R.ID20230321155703.v1.class)
- @CACHEING_CLEAN(apiClass = {customschemeItems.class})
- public String deletemx() throws YosException {
- JSONArray sa_customscheme_itemsids = content.getJSONArray("sa_customscheme_itemsids");
- BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_customscheme_itemsids.size());
- long sa_customschemeid = 0;
- for (Object o : sa_customscheme_itemsids) {
- long sa_customscheme_itemsid = Long.parseLong(o.toString());
- Rows RowsStatus = dbConnect
- .runSqlQuery("select itemid from plm_item where siteid='" + siteid
- + "' and sa_customschemeid in (select sa_customschemeid from sa_customscheme_items where sa_customscheme_itemsid='" + sa_customscheme_itemsid + "')");
- if (RowsStatus.isNotEmpty()) {
- batchDeleteErr.addErr(sa_customschemeid, "已在商品档案中使用的定制方案明细无法删除");
- continue;
- }
- ArrayList<String> list = new ArrayList<>();
- SQLFactory deletesql = new SQLFactory("sql:delete from sa_customscheme_items where siteid='" + siteid
- + "' and sa_customscheme_itemsid=" + sa_customscheme_itemsid);
- list.add(deletesql.getSQL());
- dbConnect.runSqlUpdate(list);
- }
- return batchDeleteErr.getReturnObject().toString();
- }
- }
|