|
|
@@ -0,0 +1,157 @@
|
|
|
+package service;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.ServiceController;
|
|
|
+import common.YosException;
|
|
|
+import common.data.Row;
|
|
|
+import common.data.Rows;
|
|
|
+import common.data.RowsMap;
|
|
|
+import common.data.SQLFactory;
|
|
|
+import org.apache.commons.lang.StringEscapeUtils;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import restcontroller.webmanage.sale.item.Item;
|
|
|
+import utility.ERPDocking;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+public class AutoDockItemService extends ServiceController {
|
|
|
+ @Override
|
|
|
+ public void serviceRun() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ String siteid ="ZZYOS";
|
|
|
+ Rows itemRows = dbConnect.runSqlQuery("SELECT itemid,itemno from plm_item WHERE siteid = '" + siteid + "' AND status = '新建' ");
|
|
|
+ Rows itemRowsAll = dbConnect.runSqlQuery("SELECT itemid,itemno from plm_item WHERE siteid = '" + siteid + "'");
|
|
|
+ //单位
|
|
|
+ Rows unitRows = dbConnect.runSqlQuery("SELECT unitid,unitname from plm_unit WHERE siteid = '" + siteid + "'");
|
|
|
+ RowsMap unitRowsMap = itemRows.toRowsMap("unitname");
|
|
|
+
|
|
|
+ RowsMap itemRowsMap = itemRows.toRowsMap("itemno");
|
|
|
+ RowsMap itemRowsMapAll = itemRowsAll.toRowsMap("itemno");
|
|
|
+ ERPDocking erpDocking =new ERPDocking();
|
|
|
+ Rows servicesRows = dbConnect.runSqlQuery("select lastruntime from sys_services where classname='AutoDockItemService'");
|
|
|
+ Date date =new Date();
|
|
|
+ if(!servicesRows.isEmpty()){
|
|
|
+ if(StringUtils.isNotBlank(servicesRows.get(0).getString("lastruntime"))){
|
|
|
+ date=servicesRows.get(0).getDate("lastruntime");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ JSONArray jsonArray = erpDocking.getErpItemRows(simpleDateFormat.format(date), 100000, 1);
|
|
|
+ if(!jsonArray.isEmpty()){
|
|
|
+ for (Object object:jsonArray) {
|
|
|
+ JSONObject jsonObject =(JSONObject)object;
|
|
|
+ if(!itemRowsMapAll.containsKey(jsonObject.getString("fitemno"))){
|
|
|
+ long itemid = createTableID("plm_item");
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(Item.class, "货品档案新增");
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("itemid", createTableID("plm_item"));
|
|
|
+ sqlFactory.addParameter("username", "admin");
|
|
|
+ sqlFactory.addParameter("userid", 1);
|
|
|
+ sqlFactory.addParameter("itemno", jsonObject.getString("fitemno"));
|
|
|
+ if(unitRowsMap.containsKey(jsonObject.getString("funit"))){
|
|
|
+ sqlFactory.addParameter("unitid", unitRowsMap.get(jsonObject.getString("funit")).get(0).getLong("unitid"));
|
|
|
+ }else {
|
|
|
+ sqlFactory.addParameter("unitid", 0);
|
|
|
+ }
|
|
|
+ sqlFactory.addParameter("isauxunit", 0);
|
|
|
+ sqlFactory.addParameter("unitgroupid","null");
|
|
|
+
|
|
|
+ sqlFactory.addParameter("itemname", jsonObject.getString("fitemname"));
|
|
|
+ sqlFactory.addParameter("isonsale", 0);
|
|
|
+ sqlFactory.addParameter("model", jsonObject.getString("fmodel"));
|
|
|
+ sqlFactory.addParameter("spec", jsonObject.getString("spec"));
|
|
|
+ // 订单起订量
|
|
|
+ sqlFactory.addParameter("orderminqty", 1);
|
|
|
+ // 订单增量
|
|
|
+ sqlFactory.addParameter("orderaddqty", 1);
|
|
|
+ // 订单起订量控制单位(0:主单位;1:辅助单位)
|
|
|
+ sqlFactory.addParameter("orderminqty_auxunit", 0);
|
|
|
+ // 订单增量控制单位(0:主单位;1:辅助单位)
|
|
|
+ sqlFactory.addParameter("orderaddqty_auxunit", 0);
|
|
|
+ // 说明
|
|
|
+ sqlFactory.addParameter("remarks", "");
|
|
|
+ // 商品条形码
|
|
|
+ sqlFactory.addParameter("barcode", "");
|
|
|
+ // 是否单品管理
|
|
|
+ sqlFactory.addParameter("skucontrol",0);
|
|
|
+ // 是否批次管理
|
|
|
+ sqlFactory.addParameter("batchcontrol", jsonObject.getBooleanValue("fisbatch"));
|
|
|
+ // 毛重(g)
|
|
|
+ sqlFactory.addParameter("grossweight", 0);
|
|
|
+ // 净重(g)
|
|
|
+ sqlFactory.addParameter("weight", 0);
|
|
|
+ // 高度(mm)
|
|
|
+ sqlFactory.addParameter("height", 0);
|
|
|
+ // 宽度(mm)
|
|
|
+ sqlFactory.addParameter("width", 0);
|
|
|
+ // 长度(mm)
|
|
|
+ sqlFactory.addParameter("length", 0);
|
|
|
+ // 交期
|
|
|
+ sqlFactory.addParameter("delivery", 1);
|
|
|
+ // 牌价
|
|
|
+ sqlFactory.addParameter("marketprice", 0);
|
|
|
+ // 是否工具
|
|
|
+ sqlFactory.addParameter("istool", 0);
|
|
|
+ // 产品标准
|
|
|
+ sqlFactory.addParameter("standards","");
|
|
|
+ // 库存缺货标准
|
|
|
+ sqlFactory.addParameter("stockstatus2", 1);
|
|
|
+ // 库存充足标准
|
|
|
+ sqlFactory.addParameter("stockstatus1", 1);
|
|
|
+ // 保修期(年)
|
|
|
+ sqlFactory.addParameter("warrantyday", 1);
|
|
|
+ // 是否营销物料
|
|
|
+ sqlFactory.addParameter("iswuliao",1);
|
|
|
+ // 是否服务物料
|
|
|
+ sqlFactory.addParameter("isservice", 0);
|
|
|
+
|
|
|
+ sqlFactory.addParameter("color", jsonObject.getStringValue("fcolor"));
|
|
|
+ sqlFactory.addParameter("cheek", jsonObject.getStringValue("fsizedescription"));
|
|
|
+ sqlFactory.addParameter("delistingstatus","");
|
|
|
+
|
|
|
+ sqlFactory.addParameter("ismodule", 0);
|
|
|
+ sqlFactory.addParameter("packageqty", 0);
|
|
|
+ sqlFactory.addParameter("iswoodproducts", 0);
|
|
|
+
|
|
|
+ sqlFactory.addParameter("sa_customschemeid", 0);
|
|
|
+ sqlFactory.addParameter("financeclasstype", jsonObject.getStringValue("fdescription"));
|
|
|
+
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+ // 货品档案扩展属性字段表
|
|
|
+
|
|
|
+ sqlFactory = new SQLFactory(Item.class, "货品档案-扩展新增");
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("userid", 1);
|
|
|
+ sqlFactory.addParameter("username", "admin");
|
|
|
+ sqlFactory.addParameter("plm_itemextendid", createTableID("plm_itemextend"));
|
|
|
+ sqlFactory.addParameter("itemid", itemid);
|
|
|
+ sqlFactory.addParameter("material", jsonObject.getString("fmaterialdes"));
|
|
|
+ sqlFactory.addParameter("pressure", "");
|
|
|
+ sqlFactory.addParameter("caliber", "");
|
|
|
+ sqlFactory.addParameter("butterflyplatedrive", "");
|
|
|
+ sqlFactory.addParameter("connection", "");
|
|
|
+ sqlFactory.addParameter("valveplatematerial", "");
|
|
|
+ sqlFactory.addParameter("bodymaterial", "");
|
|
|
+ sqlFactory.addParameter("actuatortype", "");
|
|
|
+ sqlFactory.addParameter("actuatorbrand", "");
|
|
|
+ sqlFactory.addParameter("isbutterfly", "");
|
|
|
+ sqlFactory.addParameter("erpitemno", jsonObject.getString("fitemno"));
|
|
|
+ sqlFactory.addParameter("erpitemname", jsonObject.getString("fitemname"));
|
|
|
+ sqlFactory.addParameter("specalnote","");
|
|
|
+ sqlFactory.addParameter("prodline", "");
|
|
|
+ sqlFactory.addParameter("device", "");
|
|
|
+
|
|
|
+ sqlList.add(sqlFactory.getSQL());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|