Explorar o código

序列号及货品档案添加字段

hu hai 1 ano
pai
achega
2d9c428b8b

+ 5 - 0
src/custom/restcontroller/R.java

@@ -5692,6 +5692,11 @@ public class R {
         public static class v1 {
         public static class v1 {
         }
         }
     }
     }
+
+    public static class ID2025021910425003 {
+        public static class v1 {
+        }
+    }
 }
 }
 
 
 
 

+ 19 - 0
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -201,6 +201,25 @@ public class Item extends Controller {
         sqlFactory.addParameter("grossprofitmargin", content.getBigDecimal("grossprofitmargin"));
         sqlFactory.addParameter("grossprofitmargin", content.getBigDecimal("grossprofitmargin"));
         sqlFactory.addParameter("soldbase", content.getBigDecimal("soldbase"));
         sqlFactory.addParameter("soldbase", content.getBigDecimal("soldbase"));
         sqlFactory.addParameter("byname", content.getStringValue("byname"));
         sqlFactory.addParameter("byname", content.getStringValue("byname"));
+        //rate,grade,custamount,safeqty,icaddqty,icminqty,iswriteoff,isnegative,ispartorderautocheck,islimitemparts,itemname_print,
+                //applicablegassource,hygienelicensenum,departmentid,executionstandards,itemclsnum,outplace
+        sqlFactory.addParameter("rate", content.getBigDecimal("rate"));
+        sqlFactory.addParameter("grade", content.getStringValue("grade"));
+        sqlFactory.addParameter("custamount", content.getBigDecimal("custamount"));
+        sqlFactory.addParameter("safeqty", content.getBigDecimal("safeqty"));
+        sqlFactory.addParameter("icaddqty", content.getBigDecimal("icaddqty"));
+        sqlFactory.addParameter("icminqty", content.getBigDecimal("icminqty"));
+        sqlFactory.addParameter("iswriteoff", content.getBooleanValue("iswriteoff"));
+        sqlFactory.addParameter("isnegative", content.getBooleanValue("isnegative"));
+        sqlFactory.addParameter("ispartorderautocheck", content.getBooleanValue("ispartorderautocheck"));
+        sqlFactory.addParameter("islimitemparts", content.getBooleanValue("islimitemparts"));
+        sqlFactory.addParameter("itemname_print", content.getStringValue("itemname_print"));
+        sqlFactory.addParameter("applicablegassource", content.getStringValue("applicablegassource"));
+        sqlFactory.addParameter("hygienelicensenum", content.getStringValue("hygienelicensenum"));
+        sqlFactory.addParameter("departmentid", content.getLongValue("departmentid"));
+        sqlFactory.addParameter("executionstandards", content.getStringValue("executionstandards"));
+        sqlFactory.addParameter("itemclsnum", content.getStringValue("itemclsnum"));
+        sqlFactory.addParameter("outplace", content.getStringValue("outplace"));
 
 
         sqlList.add(sqlFactory.getSQL());
         sqlList.add(sqlFactory.getSQL());
         // 货品档案扩展属性字段表
         // 货品档案扩展属性字段表

+ 22 - 1
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案列表.sql

@@ -44,6 +44,23 @@ SELECT t1.itemid,
        t1.cost,
        t1.cost,
        t1.grossprofit,
        t1.grossprofit,
        t1.grossprofitmargin,
        t1.grossprofitmargin,
+       t1.rate,
+       t1.grade,
+       t1.custamount,
+       t1.safeqty,
+       t1.icaddqty,
+       t1.icminqty,
+       t1.iswriteoff,
+       t1.isnegative,
+       t1.ispartorderautocheck,
+       t1.islimitemparts,
+       t1.itemname_print,
+       t1.applicablegassource,
+       t1.hygienelicensenum,
+       t1.departmentid,
+       t1.executionstandards,
+       t1.itemclsnum,
+       t1.outplace,
        t6.auxunitid,
        t6.auxunitid,
        t6.unitgroupname,
        t6.unitgroupname,
        t7.unitname axunitname,
        t7.unitname axunitname,
@@ -68,7 +85,9 @@ SELECT t1.itemid,
        t10.price price2,
        t10.price price2,
        t11.price price3,
        t11.price price3,
        t12.price price4,
        t12.price price4,
-       t13.price price5
+       t13.price price5,
+       t14.depname,
+       t15.stockname
 FROM plm_item t1
 FROM plm_item t1
          LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
          LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
          LEFT JOIN plm_unitgroup t6 ON t6.unitgroupid = t1.unitgroupid
          LEFT JOIN plm_unitgroup t6 ON t6.unitgroupid = t1.unitgroupid
@@ -81,5 +100,7 @@ FROM plm_item t1
          left join sa_itemprice t11 on t11.itemid = t1.itemid AND t11.siteid = t1.siteid and t11.pricegrade=3
          left join sa_itemprice t11 on t11.itemid = t1.itemid AND t11.siteid = t1.siteid and t11.pricegrade=3
          left join sa_itemprice t12 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=4
          left join sa_itemprice t12 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=4
          left join sa_itemprice t13 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=5
          left join sa_itemprice t13 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=5
+         LEFT JOIN sys_department t14 ON t14.departmentid = t1.departmentid AND t14.siteid = t1.siteid
+         LEFT JOIN st_stock t15 ON t15.stockno = t1.stockno AND t15.siteid = t1.siteid
 WHERE t1.siteid = $siteid$
 WHERE t1.siteid = $siteid$
   and $where$
   and $where$

+ 6 - 2
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案新增.sql

@@ -4,11 +4,15 @@ insert into plm_item (siteid, itemid, createby, createdate, changeuserid, change
                       weight, height, width, length, delivery, istool, marketprice, standards, stockstatus2,
                       weight, height, width, length, delivery, istool, marketprice, standards, stockstatus2,
                       stockstatus1, warrantyday, iswuliao, isservice, color, packageqty, ismodule, iswoodproducts,
                       stockstatus1, warrantyday, iswuliao, isservice, color, packageqty, ismodule, iswoodproducts,
                       sa_customschemeid, cheek, delistingstatus, financeclasstype, stockno, volume, marketingcategory,
                       sa_customschemeid, cheek, delistingstatus, financeclasstype, stockno, volume, marketingcategory,
-                      pricingmetod,cheekschemeid,colorschemeid,materialschemeid,cost,grossprofit,grossprofitmargin,saleprice)
+                      pricingmetod,cheekschemeid,colorschemeid,materialschemeid,cost,grossprofit,grossprofitmargin,saleprice,
+                      rate,grade,custamount,safeqty,icaddqty,icminqty,iswriteoff,isnegative,ispartorderautocheck,islimitemparts,itemname_print,
+                      applicablegassource,hygienelicensenum,departmentid,executionstandards,itemclsnum,outplace)
 values ($siteid$, $itemid$, $username$, CURRENT_TIME, $userid$, $username$, CURRENT_TIME, $itemno$, $unitid$,
 values ($siteid$, $itemid$, $username$, CURRENT_TIME, $userid$, $username$, CURRENT_TIME, $itemno$, $unitid$,
         $isauxunit$, $unitgroupid$, $itemname$, $isonsale$, '新建', $model$, $spec$, $orderminqty$, $orderaddqty$,
         $isauxunit$, $unitgroupid$, $itemname$, $isonsale$, '新建', $model$, $spec$, $orderminqty$, $orderaddqty$,
         $orderminqty_auxunit$, $orderaddqty_auxunit$, $remarks$, $barcode$, $skucontrol$, $batchcontrol$, $grossweight$,
         $orderminqty_auxunit$, $orderaddqty_auxunit$, $remarks$, $barcode$, $skucontrol$, $batchcontrol$, $grossweight$,
         $weight$, $height$, $width$, $length$, $delivery$, $istool$, $marketprice$, $standards$,
         $weight$, $height$, $width$, $length$, $delivery$, $istool$, $marketprice$, $standards$,
         $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$, $color$, $packageqty$, $ismodule$,
         $stockstatus2$, $stockstatus1$, $warrantyday$, $iswuliao$, $isservice$, $color$, $packageqty$, $ismodule$,
         $iswoodproducts$, $sa_customschemeid$, $cheek$, $delistingstatus$, $financeclasstype$, $stockno$, $volume$,
         $iswoodproducts$, $sa_customschemeid$, $cheek$, $delistingstatus$, $financeclasstype$, $stockno$, $volume$,
-        $marketingcategory$, $pricingmetod$,$cheekschemeid$,$colorschemeid$,$materialschemeid$,$cost$,$grossprofit$,$grossprofitmargin$,$saleprice$)
+        $marketingcategory$, $pricingmetod$,$cheekschemeid$,$colorschemeid$,$materialschemeid$,$cost$,$grossprofit$,$grossprofitmargin$,$saleprice$,
+        $rate$,$grade$,$custamount$,$safeqty$,$icaddqty$,$icminqty$,$iswriteoff$,$isnegative$,$ispartorderautocheck$,$islimitemparts$,$itemname_print$,
+        $applicablegassource$,$hygienelicensenum$,$departmentid$,$executionstandards$,$itemclsnum$,$outplace$)

+ 18 - 1
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案更新.sql

@@ -53,7 +53,24 @@ SET changeuserid=$userid$,
     saleprice=$saleprice$,
     saleprice=$saleprice$,
     grossprofitmargin=$grossprofitmargin$,
     grossprofitmargin=$grossprofitmargin$,
     soldbase=$soldbase$,
     soldbase=$soldbase$,
-    byname=$byname$
+    byname=$byname$,
+    rate=$rate$,
+    grade=$grade$,
+    custamount=$custamount$,
+    safeqty=$safeqty$,
+    icaddqty=$icaddqty$,
+    icminqty=$icminqty$,
+    iswriteoff=$iswriteoff$,
+    isnegative=$isnegative$,
+    ispartorderautocheck=$ispartorderautocheck$,
+    islimitemparts=$islimitemparts$,
+    itemname_print=$itemname_print$,
+    applicablegassource=$applicablegassource$,
+    hygienelicensenum=$hygienelicensenum$,
+    departmentid=$departmentid$,
+    executionstandards=$executionstandards$,
+    itemclsnum=$itemclsnum$,
+    outplace=$outplace$
 WHERE itemid = $itemid$
 WHERE itemid = $itemid$
   and siteid = $siteid$
   and siteid = $siteid$
 
 

+ 5 - 1
src/custom/restcontroller/webmanage/sale/item/SQL/货品档案详情.sql

@@ -28,7 +28,9 @@ SELECT t1.*,
        ifnull(t10.price,0) price2,
        ifnull(t10.price,0) price2,
        ifnull(t11.price,0) price3,
        ifnull(t11.price,0) price3,
        ifnull(t12.price,0) price4,
        ifnull(t12.price,0) price4,
-       ifnull(t13.price,0) price5
+       ifnull(t13.price,0) price5,
+       t14.depname,
+       t15.stockname
 FROM plm_item t1
 FROM plm_item t1
          LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
          LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
          LEFT JOIN plm_itemextend t8 ON t8.itemid = t1.itemid AND t8.siteid = t1.siteid
          LEFT JOIN plm_itemextend t8 ON t8.itemid = t1.itemid AND t8.siteid = t1.siteid
@@ -41,5 +43,7 @@ FROM plm_item t1
          left join sa_itemprice t11 on t11.itemid = t1.itemid AND t11.siteid = t1.siteid and t11.pricegrade=3
          left join sa_itemprice t11 on t11.itemid = t1.itemid AND t11.siteid = t1.siteid and t11.pricegrade=3
          left join sa_itemprice t12 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=4
          left join sa_itemprice t12 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=4
          left join sa_itemprice t13 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=5
          left join sa_itemprice t13 on t12.itemid = t1.itemid AND t12.siteid = t1.siteid and t12.pricegrade=5
+         LEFT JOIN sys_department t14 ON t14.departmentid = t1.departmentid AND t14.siteid = t1.siteid
+         LEFT JOIN st_stock t15 ON t15.stockno = t1.stockno AND t15.siteid = t1.siteid
 WHERE t1.siteid = $siteid$
 WHERE t1.siteid = $siteid$
   and t1.itemid = $itemid$
   and t1.itemid = $itemid$

+ 33 - 28
src/custom/restcontroller/webmanage/sale/toolscode/SQL/商品序列号档案列表查询.sql

@@ -1,32 +1,37 @@
 SELECT
 SELECT
     t1.sa_itemskuid,
     t1.sa_itemskuid,
-	t1.sys_enterpriseid,
-	t1.stockid,
-	t1.sku,
-	t1.islimit,
-	t1.isused,
-	t1.itemid,
-	t2.itemno,
-	t2.itemname,
-	t2.spec,
-	t2.model,
-	t1.status,
-	t1.createuserid,
-	t1.createby,
-	t1.createdate,
-	t1.changeuserid,
-	t1.changeby,
-	t1.changedate,
-	t3.abbreviation ,
-	t3.enterprisename ,
-	t3.phonenumber,
-	t4.stockname 
+    t1.stockid,
+    t1.sku,
+    t1.mono,
+    t1.isused,
+    t1.itemid,
+    t2.itemno,
+    t2.itemname,
+    t2.spec,
+    t2.model,
+    t2.marketingcategory,
+    t2.stockno itemstockno,
+    t1.status,
+    t1.createuserid,
+    t1.createby,
+    t1.createdate,
+    t1.changeby,
+    t1.changedate,
+    t3.agentnum ,
+    t4.enterprisename,
+    t5.stockno,
+    t5.stockname,
+    t6.changenotes
 FROM
 FROM
-	sa_itemsku t1
-	LEFT JOIN plm_item t2 ON t1.itemid = t2.itemid 
-	AND t1.siteid = t2.siteid
-	LEFT JOIN sys_enterprise t3 ON t1.sys_enterpriseid = t3.sys_enterpriseid 
-	AND t1.siteid = t3.siteid
-	LEFT JOIN st_stock t4 ON t1.stockid = t4.stockid 
-	AND t1.siteid = t4.siteid
+    sa_itemsku t1
+        LEFT JOIN plm_item t2 ON t1.itemid = t2.itemid
+        AND t1.siteid = t2.siteid
+        LEFT JOIN sa_agents t3 ON t1.sa_agentsid = t3.sa_agentsid
+        AND t1.siteid = t3.siteid
+        LEFT JOIN sys_enterprise t4 ON t3.sys_enterpriseid = t4.sys_enterpriseid
+        AND t3.siteid = t4.siteid
+        LEFT JOIN st_stock t5 ON t1.stockid = t5.stockid
+        AND t1.siteid = t5.siteid
+        left join (select * from sa_itemsku_change where  sa_itemsku_changeid in (select max(sa_itemsku_changeid) from sa_itemsku_change group by sa_itemskuid)) t6
+         on t1.sa_itemskuid = t6.sa_itemskuid AND t1.siteid = t6.siteid
 	where t1.siteid=$siteid$ and $where$
 	where t1.siteid=$siteid$ and $where$

+ 2 - 2
src/custom/restcontroller/webmanage/sale/toolscode/SQL/商品序列号档案新增.sql

@@ -1,2 +1,2 @@
-insert into sa_itemsku (siteid, sa_itemskuid,createuserid,createby,createdate,changeuserid,changeby, changedate,sku,islimit,isused,itemid,sys_enterpriseid,stockid,status)
-values ($siteid$, $sa_itemskuid$,$userid$,$username$, CURRENT_TIME,$userid$, $username$, CURRENT_TIME, $sku$,$islimit$,0,$itemid$,$sys_enterpriseid$,$stockid$,'在库');
+insert into sa_itemsku (siteid, sa_itemskuid,createuserid,createby,createdate,changeuserid,changeby, changedate,sku,islimit,isused,itemid,sa_agentsid,stockid,status,changenotes,mono)
+values ($siteid$, $sa_itemskuid$,$userid$,$username$, CURRENT_TIME,$userid$, $username$, CURRENT_TIME, $sku$,$islimit$,0,$itemid$,$sa_agentsid$,$stockid$,'在库','','');

+ 1 - 1
src/custom/restcontroller/webmanage/sale/toolscode/SQL/商品序列号档案更新.sql

@@ -7,7 +7,7 @@ SET
     islimit = $islimit$,
     islimit = $islimit$,
     itemid=$itemid$,
     itemid=$itemid$,
     stockid=$stockid$,
     stockid=$stockid$,
-    sys_enterpriseid = $sys_enterpriseid$
+    sa_agentsid = $sa_agentsid$
 WHERE sa_itemskuid = $sa_itemskuid$ and siteid=$siteid$
 WHERE sa_itemskuid = $sa_itemskuid$ and siteid=$siteid$
 
 
 
 

+ 15 - 10
src/custom/restcontroller/webmanage/sale/toolscode/SQL/商品序列号档案详情查询.sql

@@ -1,32 +1,37 @@
 SELECT
 SELECT
     t1.sa_itemskuid,
     t1.sa_itemskuid,
-	t1.sys_enterpriseid,
 	t1.stockid,
 	t1.stockid,
 	t1.sku,
 	t1.sku,
-	t1.islimit,
+	t1.mono,
 	t1.isused,
 	t1.isused,
 	t1.itemid,
 	t1.itemid,
 	t2.itemno,
 	t2.itemno,
 	t2.itemname,
 	t2.itemname,
 	t2.spec,
 	t2.spec,
 	t2.model,
 	t2.model,
+    t2.marketingcategory,
+    t2.stockno itemstockno,
 	t1.status,
 	t1.status,
 	t1.createuserid,
 	t1.createuserid,
 	t1.createby,
 	t1.createby,
 	t1.createdate,
 	t1.createdate,
-	t1.changeuserid,
 	t1.changeby,
 	t1.changeby,
 	t1.changedate,
 	t1.changedate,
-	t3.abbreviation ,
-	t3.enterprisename ,
-	t3.phonenumber,
-	t4.stockname 
+	t3.agentnum ,
+	t4.enterprisename,
+	t5.stockno,
+	t5.stockname,
+    t6.changenotes
 FROM
 FROM
 	sa_itemsku t1
 	sa_itemsku t1
 	LEFT JOIN plm_item t2 ON t1.itemid = t2.itemid 
 	LEFT JOIN plm_item t2 ON t1.itemid = t2.itemid 
 	AND t1.siteid = t2.siteid
 	AND t1.siteid = t2.siteid
-	LEFT JOIN sys_enterprise t3 ON t1.sys_enterpriseid = t3.sys_enterpriseid 
+	LEFT JOIN sa_agents t3 ON t1.sa_agentsid = t3.sa_agentsid
 	AND t1.siteid = t3.siteid
 	AND t1.siteid = t3.siteid
-	LEFT JOIN st_stock t4 ON t1.stockid = t4.stockid 
-	AND t1.siteid = t4.siteid
+    LEFT JOIN sys_enterprise t4 ON t3.sys_enterpriseid = t4.sys_enterpriseid
+        AND t3.siteid = t4.siteid
+	LEFT JOIN st_stock t5 ON t1.stockid = t5.stockid
+	AND t1.siteid = t5.siteid
+    left join (select * from sa_itemsku_change where  sa_itemsku_changeid in (select max(sa_itemsku_changeid) from sa_itemsku_change group by sa_itemskuid)) t6
+              on t1.sa_itemskuid = t6.sa_itemskuid AND t1.siteid = t6.siteid
 	where t1.sa_itemskuid=$sa_itemskuid$
 	where t1.sa_itemskuid=$sa_itemskuid$

+ 65 - 8
src/custom/restcontroller/webmanage/sale/toolscode/toolscode.java

@@ -183,7 +183,7 @@ public class toolscode extends Controller {
         // 表名
         // 表名
         String tableName = "sa_itemsku";
         String tableName = "sa_itemsku";
         Long sa_itemskuid = content.getLong("sa_itemskuid");
         Long sa_itemskuid = content.getLong("sa_itemskuid");
-        Long sys_enterpriseid = content.getLong("sys_enterpriseid");
+        Long sa_agentsid = content.getLong("sa_agentsid");
         Long stockid = content.getLong("stockid");
         Long stockid = content.getLong("stockid");
         // Long sys_enterpriseid = content.getLong("sys_enterpriseid");
         // Long sys_enterpriseid = content.getLong("sys_enterpriseid");
         // Long sa_logiscompid = content.getLong("sa_logiscompid");
         // Long sa_logiscompid = content.getLong("sa_logiscompid");
@@ -201,7 +201,7 @@ public class toolscode extends Controller {
                 return getErrReturnObject().setErrMsg("该序列号已被使用").toString();
                 return getErrReturnObject().setErrMsg("该序列号已被使用").toString();
             }
             }
             sa_itemskuid = createTableID(tableName);
             sa_itemskuid = createTableID(tableName);
-            sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+            sqlFactory.addParameter("sa_agentsid", sa_agentsid);
             sqlFactory.addParameter("itemid", itemid);
             sqlFactory.addParameter("itemid", itemid);
             sqlFactory.addParameter("stockid", stockid);
             sqlFactory.addParameter("stockid", stockid);
             sqlFactory.addParameter("islimit", islimit);
             sqlFactory.addParameter("islimit", islimit);
@@ -209,22 +209,66 @@ public class toolscode extends Controller {
             sqlList.add(DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "新增", "商品序列号档案新增成功").getSQL());
             sqlList.add(DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "新增", "商品序列号档案新增成功").getSQL());
         } else {
         } else {
             Rows rows = dbConnect
             Rows rows = dbConnect
-                    .runSqlQuery("SELECT status,sa_itemskuid from sa_itemsku WHERE sa_itemskuid = " + sa_itemskuid);
+                    .runSqlQuery("SELECT status,sa_itemskuid,sa_agentsid,stockid,itemid from sa_itemsku WHERE sa_itemskuid = " + sa_itemskuid);
             Rows rowscode = dbConnect.runSqlQuery("select sa_itemskuid from sa_itemsku where siteid='" + siteid
             Rows rowscode = dbConnect.runSqlQuery("select sa_itemskuid from sa_itemsku where siteid='" + siteid
                     + "' and sku='" + sku + "' and sa_itemskuid !=" + sa_itemskuid);
                     + "' and sku='" + sku + "' and sa_itemskuid !=" + sa_itemskuid);
             if (!rowscode.isEmpty()) {
             if (!rowscode.isEmpty()) {
                 return getErrReturnObject().setErrMsg("该序列号已被使用").toString();
                 return getErrReturnObject().setErrMsg("该序列号已被使用").toString();
             }
             }
             if (rows.isNotEmpty()) {
             if (rows.isNotEmpty()) {
-                if (rows.get(0).getString("status").equals("在库")) {
+                if (!rows.get(0).getBoolean("isused")) {
+                    long oldsa_agentsid=0;
+                    long newsa_agentsid=0;
+                    long olditemid=0;
+                    long newitemid=0;
+                    long oldstockid=0;
+                    long newstockid=0;
+
                     sqlFactory = new SQLFactory(this, "商品序列号档案更新");
                     sqlFactory = new SQLFactory(this, "商品序列号档案更新");
-                    sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+                    sqlFactory.addParameter("sa_agentsid", sa_agentsid);
                     sqlFactory.addParameter("islimit", islimit);
                     sqlFactory.addParameter("islimit", islimit);
                     sqlFactory.addParameter("itemid", itemid);
                     sqlFactory.addParameter("itemid", itemid);
                     sqlFactory.addParameter("stockid", stockid);
                     sqlFactory.addParameter("stockid", stockid);
                     sqlFactory.addParameter("sku", sku);
                     sqlFactory.addParameter("sku", sku);
                     sqlList.add(
                     sqlList.add(
                             DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "更新", "商品序列号档案更新成功").getSQL());
                             DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "更新", "商品序列号档案更新成功").getSQL());
+                    if(sa_agentsid!=rows.get(0).getLong("sa_agentsid")){
+                        newsa_agentsid=sa_agentsid;
+                        oldsa_agentsid=rows.get(0).getLong("sa_agentsid");
+                    }
+                    if(itemid!=rows.get(0).getLong("itemid")){
+                        newitemid=itemid;
+                        olditemid=rows.get(0).getLong("itemid");
+                        if(StringUtils.isBlank(content.getStringValue("changenotes"))){
+                            return getErrReturnObject().setErrMsg("变更商品信息时,需填写变更原因").toString();
+                        }
+                    }
+                    if(stockid!=rows.get(0).getLong("stockid")){
+                        newstockid=stockid;
+                        oldstockid=rows.get(0).getLong("stockid");
+                    }
+                    if(newstockid!=0 || newitemid!=0 || newsa_agentsid!=0){
+                        InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_itemsku_change");
+                        insertSQL.setValue("siteid", siteid);
+                        insertSQL.setValue("sa_itemsku_changeid", createTableID("sa_itemsku_change"));
+                        insertSQL.setValue("sa_itemskuid", sa_itemskuid);
+                        insertSQL.setValue("sa_agentsid", oldsa_agentsid);
+                        insertSQL.setValue("sa_agentsidnew", newsa_agentsid);
+
+                        insertSQL.setValue("itemid", olditemid);
+                        insertSQL.setValue("itemidnew", newitemid);
+
+                        insertSQL.setValue("stockid", oldstockid);
+                        insertSQL.setValue("stockidnew", newstockid);
+                        if(newitemid!=0){
+                            insertSQL.setValue("changenotes", content.getStringValue("changenotes"));
+                        }
+
+                        insertSQL.setDateValue("changedate");
+                        insertSQL.setValue("changeby", username);
+                        sqlList.add(insertSQL.getSQL());
+                    }
+
                 } else {
                 } else {
                     return getErrReturnObject().setErrMsg("非在库状态下无法编辑").toString();
                     return getErrReturnObject().setErrMsg("非在库状态下无法编辑").toString();
                 }
                 }
@@ -268,7 +312,7 @@ public class toolscode extends Controller {
                 where.append(" and(");
                 where.append(" and(");
                 where.append("t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.sku like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.sku like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t3.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t3.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append(")");
                 where.append(")");
             }
             }
@@ -292,6 +336,19 @@ public class toolscode extends Controller {
         return getSucReturnObject().setData(rows).toString();
         return getSucReturnObject().setData(rows).toString();
     }
     }
 
 
+    @API(title = "查询序列号变更记录", apiversion = R.ID2025021910425003.v1.class)
+    public String queryToolscodeChangeNotesList() throws YosException {
+        Long sa_itemskuid = content.getLong("sa_itemskuid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_itemsku_change",  "*");
+        querySQL.setTableAlias("t1");
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("sa_itemskuid",sa_itemskuid);
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
+
     @API(title = "删除", apiversion = R.ID20221215101103.v1.class)
     @API(title = "删除", apiversion = R.ID20221215101103.v1.class)
     @CACHEING_CLEAN(apiversions = {R.ID20221215101003.v1.class, R.ID20221215100903.v1.class})
     @CACHEING_CLEAN(apiversions = {R.ID20221215101003.v1.class, R.ID20221215100903.v1.class})
     public String delete() throws YosException {
     public String delete() throws YosException {
@@ -304,8 +361,8 @@ public class toolscode extends Controller {
                     + "' and sa_itemskuid='" + sa_itemskuid + "'");
                     + "' and sa_itemskuid='" + sa_itemskuid + "'");
 
 
             if (RowsStatus.isNotEmpty()) {
             if (RowsStatus.isNotEmpty()) {
-                if (!RowsStatus.get(0).getString("status").equals("在库")) {
-                    batchDeleteErr.addErr(sa_itemskuid, "非在库状态的商品序列号档案无法删除");
+                if (RowsStatus.get(0).getBoolean("isused")) {
+                    batchDeleteErr.addErr(sa_itemskuid, "已使用的商品序列号无法删除");
                     continue;
                     continue;
                 }
                 }
             }
             }