|
|
@@ -39,8 +39,7 @@ public class toolscode extends Controller {
|
|
|
XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
|
|
|
XSSFCellStyle titleCellStyle3 = ExportExcel.createBodyCellStyle(xssfFWorkbook);
|
|
|
XSSFCellStyle titleCellStyle4 = ExportExcel.createTitleCellStyle3(xssfFWorkbook);
|
|
|
- ExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
|
|
|
- xssfFWorkbook);// 写入标题
|
|
|
+ ExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4, xssfFWorkbook);// 写入标题
|
|
|
|
|
|
Rows aa = uploadExcelToObs(excelFactory);
|
|
|
String url = "";
|
|
|
@@ -133,8 +132,7 @@ public class toolscode extends Controller {
|
|
|
sqlFactoryupload.addParameter("stockid", 0);
|
|
|
|
|
|
sqllist.add(sqlFactoryupload.getSQL());
|
|
|
- sqllist.add(
|
|
|
- DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "导入", "商品序列号导入成功").getSQL());
|
|
|
+ sqllist.add(DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "导入", "商品序列号导入成功").getSQL());
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
@@ -193,10 +191,8 @@ public class toolscode extends Controller {
|
|
|
boolean islimit = content.getBooleanValue("islimit");
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "商品序列号档案新增");
|
|
|
|
|
|
- if (sa_itemskuid <= 0 || dbConnect
|
|
|
- .runSqlQuery("select sa_itemskuid from sa_itemsku where sa_itemskuid=" + sa_itemskuid).isEmpty()) {
|
|
|
- Rows rowscode = dbConnect.runSqlQuery(
|
|
|
- "select sa_itemskuid from sa_itemsku where siteid='" + siteid + "' and sku='" + sku + "'");
|
|
|
+ if (sa_itemskuid <= 0 || dbConnect.runSqlQuery("select sa_itemskuid from sa_itemsku where sa_itemskuid=" + sa_itemskuid).isEmpty()) {
|
|
|
+ Rows rowscode = dbConnect.runSqlQuery("select sa_itemskuid from sa_itemsku where siteid='" + siteid + "' and sku='" + sku + "'");
|
|
|
if (!rowscode.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该序列号已被使用").toString();
|
|
|
}
|
|
|
@@ -208,21 +204,19 @@ public class toolscode extends Controller {
|
|
|
sqlFactory.addParameter("sku", sku);
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_itemsku", sa_itemskuid, "新增", "商品序列号档案新增成功").getSQL());
|
|
|
} else {
|
|
|
- Rows rows = dbConnect
|
|
|
- .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
|
|
|
- + "' and sku='" + sku + "' and sa_itemskuid !=" + sa_itemskuid);
|
|
|
+ Rows rows = dbConnect.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 + "' and sku='" + sku + "' and sa_itemskuid !=" + sa_itemskuid);
|
|
|
if (!rowscode.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该序列号已被使用").toString();
|
|
|
}
|
|
|
if (rows.isNotEmpty()) {
|
|
|
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;
|
|
|
+ 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.addParameter("sa_agentsid", sa_agentsid);
|
|
|
@@ -230,24 +224,23 @@ public class toolscode extends Controller {
|
|
|
sqlFactory.addParameter("itemid", itemid);
|
|
|
sqlFactory.addParameter("stockid", stockid);
|
|
|
sqlFactory.addParameter("sku", sku);
|
|
|
- sqlList.add(
|
|
|
- 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");
|
|
|
+ sqlList.add(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"))){
|
|
|
+ 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 (stockid != rows.get(0).getLong("stockid")) {
|
|
|
+ newstockid = stockid;
|
|
|
+ oldstockid = rows.get(0).getLong("stockid");
|
|
|
}
|
|
|
- if(newstockid!=0 || newitemid!=0 || newsa_agentsid!=0){
|
|
|
+ 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"));
|
|
|
@@ -261,7 +254,7 @@ public class toolscode extends Controller {
|
|
|
insertSQL.setValue("stockid", oldstockid);
|
|
|
insertSQL.setValue("stockidnew", newstockid);
|
|
|
insertSQL.setValue("changenotes", "");
|
|
|
- if(newitemid!=0){
|
|
|
+ if (newitemid != 0) {
|
|
|
insertSQL.setValue("changenotes", content.getStringValue("changenotes"));
|
|
|
}
|
|
|
|
|
|
@@ -306,46 +299,71 @@ public class toolscode extends Controller {
|
|
|
|
|
|
@API(title = "查询商品序列号档案列表", apiversion = R.ID20221215101003.v1.class)
|
|
|
public String queryToolscodeList() throws YosException {
|
|
|
- StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ QuerySQL skuQuery = SQLFactory.createQuerySQL(this, "sa_itemsku").setTableAlias("t1");
|
|
|
+ skuQuery.setPage(pageNumber, pageSize);
|
|
|
+ skuQuery.setWhere("siteid", siteid);
|
|
|
if (content.containsKey("where")) {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
- where.append(" and(");
|
|
|
- where.append("t2.itemno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.sku 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(")");
|
|
|
+ if (!"".equals(whereObject.getStringValue("condition"))) {
|
|
|
+ String condition = whereObject.getString("condition");
|
|
|
+ skuQuery.setWhere("( t1.sku like'%" + condition + "%'" + "or exists(select * from plm_item where plm_item.itemid=t1.itemid and (plm_item.itemno like'%" + condition + "%'or plm_item.itemname like'%" + condition + "%'))" + "or exists(select * from sa_agents where sa_agents.sa_agentsid=t1.sa_agentsid and sa_agents.agentnum like'%" + condition + "%')" + ")");
|
|
|
}
|
|
|
- if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
- where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ if (!"".equals(whereObject.getStringValue("status"))) {
|
|
|
+ skuQuery.setWhere("t1.status", whereObject.getString("status"));
|
|
|
}
|
|
|
- if (whereObject.containsKey("isused") && !"".equals(whereObject.getString("isused"))) {
|
|
|
- where.append(" and t1.isused ='").append(whereObject.getString("isused")).append("' ");
|
|
|
+ if (!"".equals(whereObject.getStringValue("isused"))) {
|
|
|
+ skuQuery.setWhere("t1.isused", whereObject.getBooleanValue("isused"));
|
|
|
}
|
|
|
}
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "商品序列号档案列表查询");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- sqlFactory.addParameter_SQL("where", where);
|
|
|
-// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
- querySQL.setTableAlias("t0");
|
|
|
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t0.siteid='111'","*");
|
|
|
- querySQL.setPage(pageSize, pageNumber);
|
|
|
- querySQL.setOrderBy(pageSorting);
|
|
|
- Rows rows = querySQL.query();
|
|
|
- return getSucReturnObject().setData(rows).toString();
|
|
|
+ Rows skuRows = skuQuery.query();
|
|
|
+ if (skuRows.isNotEmpty()) {
|
|
|
+ RowsMap itemRowsMap = SQLFactory.createQuerySQL(this, "plm_item", "itemid", "itemno", "itemname", "spec", "model", "marketingcategory", "stockno").setWhere("itemid", skuRows.toArrayList("itemid")).query().toRowsMap("itemid");
|
|
|
+ RowsMap agentsRowsMap = SQLFactory.createQuerySQL(this, "sa_agents", "sa_agentsid", "agentnum").addJoinTable(JOINTYPE.inner, "sys_enterprise", "sys_enterprise", "sa_agentsid=:sa_agentsid", "enterprisename").setWhere("sa_agentsid", skuRows.toArrayList("sa_agentsid")).query().toRowsMap("sa_agentsid");
|
|
|
+ RowsMap stockRowsMap = SQLFactory.createQuerySQL(this, "st_stock", "stockid", "stockno", "stockname").setWhere("stockid", skuRows.toArrayList("stockid")).query().toRowsMap("stockid");
|
|
|
+ RowsMap skuChangeRowsMap = SQLFactory.createQuerySQL(this, "sa_itemsku_change", "sa_itemskuid", "changenotes").setWhere("sa_itemskuid", skuRows.toArrayList("sa_itemskuid")).setOrderBy("sa_itemsku_changeid desc").query().toRowsMap("sa_itemskuid");
|
|
|
+
|
|
|
+ for (Row skuRow : skuRows) {
|
|
|
+ String itemid = skuRow.getString("itemid");
|
|
|
+ if (itemRowsMap.containsKey(itemid) && itemRowsMap.get(itemid).isNotEmpty()) {
|
|
|
+ Row itemRow = itemRowsMap.get(itemid).get(0);
|
|
|
+ skuRow.put("itemno", itemRow.getString("itemno"));
|
|
|
+ skuRow.put("itemname", itemRow.getString("itemname"));
|
|
|
+ skuRow.put("spec", itemRow.getString("spec"));
|
|
|
+ skuRow.put("model", itemRow.getString("model"));
|
|
|
+ skuRow.put("marketingcategory", itemRow.getString("marketingcategory"));
|
|
|
+ skuRow.put("itemstockno", itemRow.getString("stockno"));
|
|
|
+ }
|
|
|
+ String sa_agentsid = skuRow.getString("sa_agentsid");
|
|
|
+ if (agentsRowsMap.containsKey(sa_agentsid) && agentsRowsMap.get(sa_agentsid).isNotEmpty()) {
|
|
|
+ Row agentRow = agentsRowsMap.get(sa_agentsid).get(0);
|
|
|
+ skuRow.put("agentnum", agentRow.getString("agentnum"));
|
|
|
+ skuRow.put("enterprisename", agentRow.getString("enterprisename"));
|
|
|
+ }
|
|
|
+ String stockid = skuRow.getString("stockid");
|
|
|
+ if (stockRowsMap.containsKey(stockid) && stockRowsMap.get(stockid).isNotEmpty()) {
|
|
|
+ Row stockRow = stockRowsMap.get(stockid).get(0);
|
|
|
+ skuRow.put("stockno", stockRow.getString("stockno"));
|
|
|
+ skuRow.put("stockname", stockRow.getString("stockname"));
|
|
|
+ }
|
|
|
+ String sa_itemskuid = skuRow.getString("sa_itemskuid");
|
|
|
+ if (skuChangeRowsMap.containsKey(sa_itemskuid) && skuChangeRowsMap.get(sa_itemskuid).isNotEmpty()) {
|
|
|
+ Row changeNoteRow = skuChangeRowsMap.get(sa_itemskuid).get(0);
|
|
|
+ skuRow.put("changenotes", changeNoteRow.getString("changenotes"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(skuRows).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 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);
|
|
|
+ querySQL.setWhere("sa_itemskuid", sa_itemskuid);
|
|
|
Rows rows = querySQL.query();
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
@@ -358,8 +376,7 @@ public class toolscode extends Controller {
|
|
|
BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_itemskuids.size());
|
|
|
for (Object o : sa_itemskuids) {
|
|
|
long sa_itemskuid = Long.parseLong(o.toString());
|
|
|
- Rows RowsStatus = dbConnect.runSqlQuery("select sa_itemskuid,status from sa_itemsku where siteid='" + siteid
|
|
|
- + "' and sa_itemskuid='" + sa_itemskuid + "'");
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery("select sa_itemskuid,status from sa_itemsku where siteid='" + siteid + "' and sa_itemskuid='" + sa_itemskuid + "'");
|
|
|
|
|
|
if (RowsStatus.isNotEmpty()) {
|
|
|
if (RowsStatus.get(0).getBoolean("isused")) {
|
|
|
@@ -368,15 +385,13 @@ public class toolscode extends Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- dbConnect.runSqlUpdate(
|
|
|
- "delete from sa_itemsku where siteid='" + siteid + "' and sa_itemskuid=" + sa_itemskuid);
|
|
|
+ dbConnect.runSqlUpdate("delete from sa_itemsku where siteid='" + siteid + "' and sa_itemskuid=" + sa_itemskuid);
|
|
|
}
|
|
|
return batchDeleteErr.getReturnObject().toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
- public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows,
|
|
|
- HashMap<String, String> titlemap) {
|
|
|
+ public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows, HashMap<String, String> titlemap) {
|
|
|
ArrayList<String> keylist = datarows.getFieldList();
|
|
|
XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
|
|
|
XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
|