Browse Source

p2商品档案对接内容

eganwu 1 year ago
parent
commit
d51f01765d
1 changed files with 56 additions and 7 deletions
  1. 56 7
      src/custom/service/AutoDockItemService.java

+ 56 - 7
src/custom/service/AutoDockItemService.java

@@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import common.BaseClass;
 import common.ServiceController;
 import common.YosException;
-import common.data.Row;
-import common.data.Rows;
-import common.data.RowsMap;
-import common.data.SQLFactory;
+import common.data.*;
 import common.data.db.DBConnect;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
@@ -36,7 +33,7 @@ public class AutoDockItemService extends ServiceController {
             String paramname = "AutoDockItemServiceTime" + "_" + siteid;
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Etc/GMT-8"));
-            String AutoDockItemServiceTime = getAutoDockItemServiceTime(paramname,simpleDateFormat);
+            String AutoDockItemServiceTime = getAutoDockItemServiceTime(paramname, simpleDateFormat);
 
             ArrayList<String> sqlList = new ArrayList<>();
             Rows itemRows = dbConnect.runSqlQuery("SELECT itemid,itemno from  plm_item WHERE siteid = '" + siteid + "' AND status = '新建' ");
@@ -169,8 +166,60 @@ public class AutoDockItemService extends ServiceController {
                         sqlList.add(sqlFactory.getSQL());
 
                     } else {
-                        sqlList.add("update plm_item set itemname='" + jsonObject.getString("fitemname") + "',volume='" + jsonObject.getStringValue("fvolume") + "',packageqty='" + (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")) + "' where itemid=" + itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid"));
-                        System.out.println("update plm_item set itemname='" + jsonObject.getString("fitemname") + "',volume='" + jsonObject.getStringValue("fvolume") + "',packageqty='" + (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")) + "' where itemid=" + itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid"));
+//                        sqlList.add("update plm_item set itemname='" + jsonObject.getString("fitemname") + "',volume='" + jsonObject.getStringValue("fvolume") + "',packageqty='" + (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")) + "' where itemid=" + itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid"));
+//                        System.out.println("update plm_item set itemname='" + jsonObject.getString("fitemname") + "',volume='" + jsonObject.getStringValue("fvolume") + "',packageqty='" + (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")) + "' where itemid=" + itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid"));
+                        Long itemid = itemRowsMapAll.get(jsonObject.getString("fitemno")).get(0).getLong("itemid");
+                        String spec = jsonObject.getString("spec");//尺寸
+                        String cheek = jsonObject.getString("fsizedescription");//工艺
+                        String material = jsonObject.getString("fmaterialdes");//选项
+                        String color = jsonObject.getString("fcolor");//颜色
+                        boolean isonsale = true;
+                        if (dbConnect.runSqlQuery("SELECT 1 FROM plm_item t1 LEFT JOIN plm_itemextend t2 ON t2.itemid=t1.itemid AND t2.siteid=t1.siteid " +
+                                "WHERE spec='" + spec + "' AND cheek='" + cheek + "' AND material='" + material + "' AND color='" + color + "'").isEmpty()) {
+                            isonsale = false;
+                            sqlList.add("delete from sa_itemgroupmx WHERE itemid=" + itemid + " and siteid='" + siteid + "' ");
+                            Rows rows = dbConnect.runSqlQuery("SELECT sa_itemgroupid from sa_itemgroupmx WHERE itemid=" + itemid + " and siteid='" + siteid + "' ");
+                            ArrayList<Long> sa_itemgroupids = rows.toArrayList("sa_itemgroupid", new ArrayList<>());
+                            for (Long sa_itemgroupid : sa_itemgroupids) {
+                                int count = dbConnect.runSqlQuery(0, "SELECT count(0) count from sa_itemgroupmx WHERE sa_itemgroupid=" + sa_itemgroupid + " and siteid='" + siteid + "' ").getInteger("count");
+                                if (count == 1) {
+                                    sqlList.add("delete from sa_itemgroup WHERE sa_itemgroupid=" + sa_itemgroupid + " and siteid='" + siteid + "' ");
+                                }
+                            }
+                        }
+                        boolean iscustomsize = false;
+                        if (spec.equals("custom") || cheek.equals("custom") || material.equals("custom") || color.equals("custom")) {
+                            iscustomsize = true;
+                        }
+
+                        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(dbConnect, "plm_item");
+                        updateSQL.setWhere("itemid", itemid);
+                        updateSQL.setSiteid(siteid);
+                        updateSQL.setValue("isonsale", isonsale);
+                        updateSQL.setValue("iscustomsize", iscustomsize);
+                        updateSQL.setValue("itemname", jsonObject.getString("fitemname"));
+                        updateSQL.setValue("volume", jsonObject.getStringValue("fvolume"));
+                        updateSQL.setValue("packageqty", (StringUtils.isBlank(jsonObject.getStringValue("fpackqty")) ? "0" : jsonObject.getStringValue("fpackqty")));
+                        updateSQL.setValue("itemno", jsonObject.getString("fitemno"));//商品编码
+                        updateSQL.setValue("model", jsonObject.getString("fmodel"));//型号
+                        updateSQL.setValue("cheek", cheek);//工艺
+                        updateSQL.setValue("itemname", jsonObject.getString("fitemname"));//品名
+//                        updateSQL.setValue("standards","");//规格
+                        updateSQL.setValue("color", color);//颜色
+                        updateSQL.setValue("batchcontrol", jsonObject.getBooleanValue("fisbatch"));//批次管理
+                        if (unitRowsMap.containsKey(jsonObject.getString("funit"))) {
+                            updateSQL.setValue("unitid", unitRowsMap.get(jsonObject.getString("funit")).get(0).getLong("unitid"));
+                        } else {
+                            updateSQL.setValue("unitid", 0);
+                        }
+                        updateSQL.setValue("spec", spec);//尺寸
+                        sqlList.add(updateSQL.getSQL());
+
+                        UpdateSQL updateSQL2 = SQLFactory.createUpdateSQL(dbConnect, "plm_itemextend");
+                        updateSQL2.setWhere("itemid", itemid);
+                        updateSQL2.setSiteid(siteid);
+                        updateSQL2.setValue("material", material);//颜色
+                        sqlList.add(updateSQL2.getSQL());
                     }
 
                 }