|
|
@@ -5,7 +5,6 @@ import common.ServiceController;
|
|
|
import common.YosException;
|
|
|
import common.data.*;
|
|
|
import common.data.db.DBConnect;
|
|
|
-import org.apache.ibatis.jdbc.SQL;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
@@ -20,7 +19,8 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
|
|
|
@Override
|
|
|
public void serviceRun() throws Exception {
|
|
|
-
|
|
|
+ stockIn();
|
|
|
+ cxwgIn();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -35,8 +35,8 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
*/
|
|
|
public void stockIn() throws YosException {
|
|
|
Rows rows = TQWMS.runSqlQuery("SELECT t1.DetailID,t1.SerialNo,t1.MaterialCode,t1.CreateDate FROM TInDetailInt t1 INNER JOIN TMaterialsSerialNo t2 on t1.SerialNo=t2.SerialNo WHERE year(t1.CreateDate)>=2018 and t1.Status=0 and t1.IsDeleted=0 and t2.sysfrom='DRP'");
|
|
|
-
|
|
|
if (rows.isNotEmpty()) {
|
|
|
+ logger.info("监测到有{}个入库序列号", rows.size());
|
|
|
QuerySQL billCheckSQL = SQLFactory.createQuerySQL(dbConnect, "st_stockbill", "billno").setTableAlias("t1");
|
|
|
billCheckSQL.addJoinTable(JOINTYPE.inner, "st_stockbill_items_sku", "t2", "t1.st_stockbillid=t2.st_stockbillid", "sku");
|
|
|
billCheckSQL.setWhere("siteid", "MD").setWhere("t1.type in ('返修入库','销售出库')");
|
|
|
@@ -59,10 +59,11 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
String sku = row.getString("SerialNo");
|
|
|
String itemno = row.getString("MaterialCode");
|
|
|
Date createdate = row.getDate("CreateDate");
|
|
|
-
|
|
|
+ logger.info("开始处理序列号{}", sku);
|
|
|
if (billCodeList.contains(sku)) {
|
|
|
//如果序列号已经存在返修入库、或者销售出库,则将状态改为11
|
|
|
TQWMS.runSqlUpdate("update TInDetailInt set status=11,ModifyDate=GETDATE() where DetailID=" + DetailID);
|
|
|
+ logger.info("序列号{}已经存在返修入库、或者销售出库,将中间表状态改为11", sku);
|
|
|
continue;
|
|
|
}
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
@@ -70,27 +71,33 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
if (createdate.before(calendar.getTime())) {
|
|
|
//超过时间未能处理,则将状态改为12
|
|
|
TQWMS.runSqlUpdate("update TInDetailInt set status=12,ModifyDate=GETDATE() where DetailID=" + DetailID);
|
|
|
+ logger.info("序列号{}超过两个月未能正确处理,将中间表状态改为12", sku);
|
|
|
continue;
|
|
|
}
|
|
|
if (!codeRowsMap.containsKey(sku)) {
|
|
|
+ logger.info("序列号{}不存在", sku);
|
|
|
//序列号不存在,则跳过
|
|
|
continue;
|
|
|
}
|
|
|
if (!codeRowsMap.get(sku).getRow(0).getString("itemno").equals(itemno)) {
|
|
|
//商品编号不匹配,则跳过
|
|
|
+ logger.info("序列号{}商品编号{}不匹配,DRP中为{}", sku, itemno, codeRowsMap.get(sku).getRow(0).getString("itemno"));
|
|
|
continue;
|
|
|
}
|
|
|
if (codeRowsMap.get(sku).getRow(0).getInteger("stockid") > 0) {
|
|
|
//序列号仓库不为空,则跳过
|
|
|
+ logger.info("序列号{}仓库不为空", sku);
|
|
|
continue;
|
|
|
}
|
|
|
String instockno = codeRowsMap.get(sku).getRow(0).getString("stockno");
|
|
|
if (instockno.isEmpty()) {
|
|
|
//商品默认仓库为空,则跳过
|
|
|
+ logger.info("序列号{}所属商品没有默认仓库", sku);
|
|
|
continue;
|
|
|
}
|
|
|
if (stockRowsMap.get(instockno).isEmpty()) {
|
|
|
//仓库不存在,跳过
|
|
|
+ logger.info("序列号{}所属仓库不存在", sku);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -123,7 +130,7 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
stStockbillitems.setValue("rowno", 1);
|
|
|
stStockbillitems.setValue("createby", "wms");
|
|
|
stStockbillitems.setValue("itemid", coderow.getLong("itemid"));
|
|
|
- stStockbillitems.setValue("skucontrol",true);
|
|
|
+ stStockbillitems.setValue("skucontrol", true);
|
|
|
stStockbillitems.setValue("itemno", coderow.getString("itemno"));
|
|
|
stStockbillitems.setValue("itemname", coderow.getString("itemname"));
|
|
|
stStockbillitems.setValue("model", coderow.getString("model"));
|
|
|
@@ -157,6 +164,7 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
dbConnect.runSqlUpdate("delete from st_stockbill where st_stockbillid=" + st_stockbillid);
|
|
|
dbConnect.runSqlUpdate("delete from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
dbConnect.runSqlUpdate("delete from st_stockbill_items_sku where st_stockbillid=" + st_stockbillid);
|
|
|
+ logger.info("序列号{}生成入库单审核失败", sku);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -168,6 +176,7 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
public void cxwgIn() throws YosException {
|
|
|
Rows rows = TQWMS.runSqlQuery("SELECT DetailID,T1.SerialNo,T1.CreateDate,T1.MaterialCode FROM TInDetailInt T1 INNER JOIN TMaterialsSerialNo T2 ON T1.SerialNo=T2.SerialNo WHERE T2.sysfrom='U8_888' AND T1.Status=0");
|
|
|
if (rows.isNotEmpty()) {
|
|
|
+ logger.info("监测到有{}个创新外购入库序列号", rows.size());
|
|
|
QuerySQL billCheckSQL = SQLFactory.createQuerySQL(dbConnect, "st_stockbill", "billno").setTableAlias("t1");
|
|
|
billCheckSQL.addJoinTable(JOINTYPE.inner, "st_stockbill_items_sku", "t2", "t1.st_stockbillid=t2.st_stockbillid", "sku");
|
|
|
billCheckSQL.setWhere("siteid", "MD").setWhere("t2.sku", rows.toArrayList("cinvsn"));
|
|
|
@@ -197,13 +206,15 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
String sku = row.getString("SerialNo");
|
|
|
String itemno = row.getString("MaterialCode");
|
|
|
Date createdate = row.getDate("CreateDate");
|
|
|
-
|
|
|
+ logger.info("开始处理序列号{}", sku);
|
|
|
if (!codeCheckList.contains(itemno)) {
|
|
|
+ logger.info("序列号{}商品编码{}不存在于中间表inventory中", sku, itemno);
|
|
|
continue;
|
|
|
}
|
|
|
if (billCodeList.contains(sku)) {
|
|
|
//如果序列号已经出入库记录
|
|
|
TQWMS.runSqlUpdate("update TInDetailInt set status=11,ModifyDate=GETDATE() where DetailID=" + DetailID);
|
|
|
+ logger.info("序列号{}已经存在出入库记录,将中间表状态改为11", sku);
|
|
|
continue;
|
|
|
}
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
@@ -211,18 +222,22 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
if (createdate.before(calendar.getTime())) {
|
|
|
//超过时间未能处理,则将状态改为12
|
|
|
TQWMS.runSqlUpdate("update TInDetailInt set status=12,ModifyDate=GETDATE() where DetailID=" + DetailID);
|
|
|
+ logger.info("序列号{}超过两个月未能正确处理,将中间表状态改为12", sku);
|
|
|
continue;
|
|
|
}
|
|
|
if (!codeRowsMap.containsKey(sku)) {
|
|
|
//序列号不存在,则跳过
|
|
|
+ logger.info("序列号{}不存在", sku);
|
|
|
continue;
|
|
|
}
|
|
|
if (!codeRowsMap.get(sku).getRow(0).getString("itemno").equals(itemno)) {
|
|
|
//商品编号不匹配,则跳过
|
|
|
+ logger.info("序列号{}商品编号{}不匹配,DRP中为{}", sku, itemno, codeRowsMap.get(sku).getRow(0).getString("itemno"));
|
|
|
continue;
|
|
|
}
|
|
|
if (codeRowsMap.get(sku).getRow(0).getInteger("stockid") > 0) {
|
|
|
//序列号仓库不为空,则跳过
|
|
|
+ logger.info("序列号{}仓库不为空", sku);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -290,6 +305,7 @@ public class GetStockBillFromTQWms extends ServiceController {
|
|
|
dbConnect.runSqlUpdate("delete from st_stockbill where st_stockbillid=" + st_stockbillid);
|
|
|
dbConnect.runSqlUpdate("delete from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
dbConnect.runSqlUpdate("delete from st_stockbill_items_sku where st_stockbillid=" + st_stockbillid);
|
|
|
+ logger.info("序列号{}生成入库单审核失败", sku);
|
|
|
}
|
|
|
}
|
|
|
}
|