|
|
@@ -0,0 +1,873 @@
|
|
|
+package restcontroller.webmanage.sale.u8;
|
|
|
+
|
|
|
+import beans.data.BatchDeleteErr;
|
|
|
+import beans.datacontrllog.DataContrlLog;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import common.Controller;
|
|
|
+import common.YosException;
|
|
|
+import common.annotation.API;
|
|
|
+import common.annotation.CACHEING;
|
|
|
+import common.annotation.CACHEING_CLEAN;
|
|
|
+import common.data.*;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import restcontroller.R;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+@API(title = "销售出库U8上传")
|
|
|
+public class u8 extends Controller {
|
|
|
+ public u8(JSONObject content) throws YosException {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "新增更新销售出库U8上传", apiversion = R.ID2025073114070603.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class})
|
|
|
+ public String insertormodify_u8() throws YosException {
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ // 表名
|
|
|
+
|
|
|
+ String tableName = "u8";
|
|
|
+ Long u8id = content.getLong("u8id");
|
|
|
+ String entity = content.getStringValue("entity");
|
|
|
+ String remarks = content.getStringValue("remarks");
|
|
|
+ String billdate = content.getStringValue("billdate");
|
|
|
+ if (u8id <= 0) {
|
|
|
+
|
|
|
+ u8id = createTableID(tableName);
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, tableName);
|
|
|
+ insertSQL.setUniqueid(u8id);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("entity", entity);
|
|
|
+ insertSQL.setValue("remarks", remarks);
|
|
|
+ insertSQL.setValue("billdate", billdate);
|
|
|
+ insertSQL.setValue("period", billdate.substring(0, 7));
|
|
|
+ insertSQL.setValue("billno", createBillCode("u8"));
|
|
|
+
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("status", "新建");
|
|
|
+ sqlList.add(insertSQL.getSQL());
|
|
|
+
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "u8", u8id, "新增", "销售出库U8上传新增成功").getSQL());
|
|
|
+ } else {
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
+ "SELECT status from u8 WHERE u8id = "
|
|
|
+ + u8id);
|
|
|
+ if (rows.isNotEmpty()) {
|
|
|
+ if (rows.get(0).getString("status").equals("新建")) {
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, tableName);
|
|
|
+ updateSQL.setUniqueid(u8id);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("entity", entity);
|
|
|
+ updateSQL.setValue("remarks", remarks);
|
|
|
+ updateSQL.setValue("billdate", billdate);
|
|
|
+ updateSQL.setValue("period", billdate.substring(0, 7));
|
|
|
+
|
|
|
+ updateSQL.setValue("changeby", username);
|
|
|
+ updateSQL.setDateValue("changedate");
|
|
|
+ sqlList.add(updateSQL.getSQL());
|
|
|
+
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "u8", u8id, "更新", "销售出库U8上传更新成功").getSQL());
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().setErrMsg("该销售出库U8上传不存在").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+ content.put("u8id", u8id);
|
|
|
+
|
|
|
+ return queryu8Main();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "销售出库U8上传详情", apiversion = R.ID2025073114072103.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryu8Main() throws YosException {
|
|
|
+ long u8id = content.getLong("u8id");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "u8","*");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+
|
|
|
+ querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setWhere("t1.u8id",u8id);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
+ return getSucReturnObject().setData(row).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "销售出库U8上传列表", apiversion = R.ID2025073114074303.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String queryu8List() throws YosException {
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.billno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.entity like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+// SQLFactory sqlFactory = new SQLFactory(this, "出入库单列表查询", pageSize, pageNumber, pageSorting);
|
|
|
+// sqlFactory.addParameter("siteid", siteid);
|
|
|
+// sqlFactory.addParameter_SQL("where", where);
|
|
|
+// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "u8","*");
|
|
|
+ querySQL.setTableAlias("t1");
|
|
|
+ querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setWhere(where);
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "删除", apiversion = R.ID2025073114073103.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class})
|
|
|
+ public String delete() throws YosException {
|
|
|
+ JSONArray u8ids = content.getJSONArray("u8ids");
|
|
|
+ BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, u8ids.size());
|
|
|
+ for (Object o : u8ids) {
|
|
|
+ long u8id = Long.parseLong(o.toString());
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery("select u8id,status from u8 where siteid='"
|
|
|
+ + siteid + "' and u8id='" + u8id + "'");
|
|
|
+
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
+ if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
+ batchDeleteErr.addErr(u8id, "非新建状态的销售出库U8上传无法删除");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+ sqllist.add("delete from u8 where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8billcodes where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8bills where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8itemprice where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ }
|
|
|
+ return batchDeleteErr.getReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "审核", apiversion = R.ID2025073114081603.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class})
|
|
|
+ public String check() throws YosException {
|
|
|
+ long u8id = content.getLong("u8id");
|
|
|
+ ArrayList<String> sqllist=new ArrayList<>();
|
|
|
+ Rows department =dbConnect.runSqlQuery("select departmentid,depno from sys_department where siteid='"+siteid+"'");
|
|
|
+ RowsMap departmentRowsMap = department.toRowsMap("depno");
|
|
|
+
|
|
|
+ Rows stock =dbConnect.runSqlQuery("select stockid,stockno from st_stock where siteid='"+siteid+"'");
|
|
|
+ RowsMap stockRowsMap = stock.toRowsMap("stockno");
|
|
|
+ Rows u8=dbConnect.runSqlQuery("select * from u8 where u8id="+u8id);
|
|
|
+ Rows u8billcodes=dbConnect.runSqlQuery("select * from u8billcodes where u8id="+u8id);
|
|
|
+ RowsMap u8billcodesRowsMap= u8billcodes.toRowsMap("itemid");
|
|
|
+ Rows u8bills=dbConnect.runSqlQuery("select t1.*,ifnull(t2.price,0) price,ifnull(t2.taxprice,0) taxprice,t2.taxrate,t3.itemname,t3.itemno,t3.model from (select siteid,itemid,u8id,stockid,rb,sum(qty) qty from u8billcodes group by siteid,itemid,u8id,stockid,rb) t1 left join u8itemprice t2 on t1.u8id=t2.u8id and t1.itemid=t2.itemid and t1.stockid=t2.stockid left join plm_item t3 on t1.itemid=t3.itemid and t1.siteid=t3.siteid where t1.u8id="+u8id);
|
|
|
+ RowsMap u8billsRowsMap=u8bills.toRowsMap("rb");
|
|
|
+ if(u8.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("该销售出库U8上传不存在").toString();
|
|
|
+ }
|
|
|
+ //销售出库蓝
|
|
|
+ long st_stockbillid = createTableID("st_stockbill");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
+ insertSQL.setUniqueid(st_stockbillid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("departmentid", departmentRowsMap.containsKey("103")?departmentRowsMap.get("103").get(0).getLong("departmentid"):0);
|
|
|
+ insertSQL.setValue("stockid", stockRowsMap.containsKey("103")?stockRowsMap.get("103").get(0).getLong("stockid"):0);
|
|
|
+ insertSQL.setValue("type", "其他出库");
|
|
|
+ insertSQL.setValue("typemx", "销售出库");
|
|
|
+ insertSQL.setValue("rb", 1);
|
|
|
+ insertSQL.setValue("remarks", "U8单据上传生成");
|
|
|
+ insertSQL.setValue("billdate", u8.get(0).getString("billdate"));
|
|
|
+ insertSQL.setValue("period",u8.get(0).getString("period"));
|
|
|
+ insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
+ insertSQL.setValue("isconfirm", 0);
|
|
|
+ insertSQL.setValue("sourceobject", "u8");
|
|
|
+ insertSQL.setValue("sourceid", u8id);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", 0);
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("status", "审核");
|
|
|
+ insertSQL.setValue("checkby", username);
|
|
|
+ insertSQL.setDateValue("checkdate");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ if(u8billsRowsMap.containsKey("1")){
|
|
|
+ int i=0;
|
|
|
+ for(Row row : u8billsRowsMap.get("1")){
|
|
|
+ InsertSQL insertSQLdetail = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ long st_stockbill_itemsid =createTableID("st_stockbill_items");
|
|
|
+ insertSQLdetail.setUniqueid(st_stockbill_itemsid);
|
|
|
+ insertSQLdetail.setSiteid(siteid);
|
|
|
+ insertSQLdetail.setValue("rowno", i + 1);
|
|
|
+ insertSQLdetail.setValue("st_stockbillid", st_stockbillid);
|
|
|
+ insertSQLdetail.setValue("itemid", row.getLong("itemid"));
|
|
|
+ insertSQLdetail.setValue("qty", row.getBigDecimal("qty"));
|
|
|
+ insertSQLdetail.setValue("discountrate", 1);
|
|
|
+ insertSQLdetail.setValue("sa_dispatch_itemsid", 0);
|
|
|
+ insertSQLdetail.setValue("itemno", row.getString("itemno"));
|
|
|
+ insertSQLdetail.setValue("itemname", row.getString("itemname"));
|
|
|
+ insertSQLdetail.setValue("model", row.getString("model"));
|
|
|
+ insertSQLdetail.setValue("price", row.getBigDecimal("price"));
|
|
|
+ insertSQLdetail.setValue("amount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price")));
|
|
|
+ insertSQLdetail.setValue("untaxedprice", row.getBigDecimal("taxprice"));
|
|
|
+ insertSQLdetail.setValue("untaxedamount", row.getBigDecimal("qty").multiply(row.getBigDecimal("taxprice")));
|
|
|
+ i++;
|
|
|
+ sqllist.add(insertSQLdetail.getSQL());
|
|
|
+ if(u8billcodesRowsMap.containsKey(row.getString("itemid"))){
|
|
|
+ for(Row row1 :u8billcodesRowsMap.get(row.getString("itemid"))){
|
|
|
+ if(row1.getBoolean("rb")){
|
|
|
+ InsertSQL insertSQLdetailsku = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
|
|
|
+ long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
|
|
|
+ insertSQLdetailsku.setUniqueid(st_stockbill_items_skuid);
|
|
|
+ insertSQLdetailsku.setSiteid(siteid);
|
|
|
+ insertSQLdetailsku.setValue("stockid", row1.getLong("stockid"));
|
|
|
+ insertSQLdetailsku.setValue("itemid",row1.getLong("itemid"));
|
|
|
+ insertSQLdetailsku.setValue("sku",StringUtils.isBlank(row1.getString("sku"))?"":row1.getString("sku"));
|
|
|
+ insertSQLdetailsku.setValue("st_stockbillid",st_stockbillid);
|
|
|
+ insertSQLdetailsku.setValue("st_stockbill_itemsid",st_stockbill_itemsid);
|
|
|
+ sqllist.add(insertSQLdetailsku.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //销售出库红
|
|
|
+ st_stockbillid = createTableID("st_stockbill");
|
|
|
+ insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
+ insertSQL.setUniqueid(st_stockbillid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("departmentid", departmentRowsMap.containsKey("103")?departmentRowsMap.get("103").get(0).getLong("departmentid"):0);
|
|
|
+ insertSQL.setValue("stockid", stockRowsMap.containsKey("103")?stockRowsMap.get("103").get(0).getLong("stockid"):0);
|
|
|
+ insertSQL.setValue("type", "其他出库");
|
|
|
+ insertSQL.setValue("typemx", "销售出库");
|
|
|
+ insertSQL.setValue("rb", 0);
|
|
|
+ insertSQL.setValue("remarks", "U8单据上传生成");
|
|
|
+ insertSQL.setValue("billdate", u8.get(0).getString("billdate"));
|
|
|
+ insertSQL.setValue("period",u8.get(0).getString("period"));
|
|
|
+ insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
+ insertSQL.setValue("isconfirm", 0);
|
|
|
+ insertSQL.setValue("sourceobject", "u8");
|
|
|
+ insertSQL.setValue("sourceid", u8id);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", 0);
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("status", "审核");
|
|
|
+ insertSQL.setValue("checkby", username);
|
|
|
+ insertSQL.setDateValue("checkdate");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ if(u8billsRowsMap.containsKey("0")){
|
|
|
+ int i=0;
|
|
|
+ for(Row row : u8billsRowsMap.get("0")){
|
|
|
+ InsertSQL insertSQLdetail = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ long st_stockbill_itemsid =createTableID("st_stockbill_items");
|
|
|
+ insertSQLdetail.setUniqueid(st_stockbill_itemsid);
|
|
|
+ insertSQLdetail.setSiteid(siteid);
|
|
|
+ insertSQLdetail.setValue("rowno", i + 1);
|
|
|
+ insertSQLdetail.setValue("st_stockbillid", st_stockbillid);
|
|
|
+ insertSQLdetail.setValue("itemid", row.getLong("itemid"));
|
|
|
+ insertSQLdetail.setValue("qty", row.getBigDecimal("qty"));
|
|
|
+ insertSQLdetail.setValue("discountrate", 1);
|
|
|
+ insertSQLdetail.setValue("sa_dispatch_itemsid", 0);
|
|
|
+ insertSQLdetail.setValue("itemno", row.getString("itemno"));
|
|
|
+ insertSQLdetail.setValue("itemname", row.getString("itemname"));
|
|
|
+ insertSQLdetail.setValue("model", row.getString("model"));
|
|
|
+ insertSQLdetail.setValue("price", row.getBigDecimal("price"));
|
|
|
+ insertSQLdetail.setValue("amount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price")));
|
|
|
+ insertSQLdetail.setValue("untaxedprice", row.getBigDecimal("taxprice"));
|
|
|
+ insertSQLdetail.setValue("untaxedamount", row.getBigDecimal("qty").multiply(row.getBigDecimal("taxprice")));
|
|
|
+ i++;
|
|
|
+ sqllist.add(insertSQLdetail.getSQL());
|
|
|
+ if(u8billcodesRowsMap.containsKey(row.getString("itemid"))){
|
|
|
+ for(Row row1 :u8billcodesRowsMap.get(row.getString("itemid"))){
|
|
|
+ if(!row1.getBoolean("rb")){
|
|
|
+ InsertSQL insertSQLdetailsku = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
|
|
|
+ long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
|
|
|
+ insertSQLdetailsku.setUniqueid(st_stockbill_items_skuid);
|
|
|
+ insertSQLdetailsku.setSiteid(siteid);
|
|
|
+ insertSQLdetailsku.setValue("stockid", row1.getLong("stockid"));
|
|
|
+ insertSQLdetailsku.setValue("itemid",row1.getLong("itemid"));
|
|
|
+ insertSQLdetailsku.setValue("sku",StringUtils.isBlank(row1.getString("sku"))?"":row1.getString("sku"));
|
|
|
+ insertSQLdetailsku.setValue("st_stockbillid",st_stockbillid);
|
|
|
+ insertSQLdetailsku.setValue("st_stockbill_itemsid",st_stockbill_itemsid);
|
|
|
+ sqllist.add(insertSQLdetailsku.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //外购入库蓝
|
|
|
+ st_stockbillid = createTableID("st_stockbill");
|
|
|
+ insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
+ insertSQL.setUniqueid(st_stockbillid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("departmentid", departmentRowsMap.containsKey("101")?departmentRowsMap.get("101").get(0).getLong("departmentid"):0);
|
|
|
+ insertSQL.setValue("stockid", stockRowsMap.containsKey("101")?stockRowsMap.get("101").get(0).getLong("stockid"):0);
|
|
|
+ insertSQL.setValue("type", "其他入库");
|
|
|
+ insertSQL.setValue("typemx", "外购入库");
|
|
|
+ insertSQL.setValue("rb", 1);
|
|
|
+ insertSQL.setValue("remarks", "U8单据上传生成");
|
|
|
+ insertSQL.setValue("billdate", u8.get(0).getString("billdate"));
|
|
|
+ insertSQL.setValue("period",u8.get(0).getString("period"));
|
|
|
+ insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
+ insertSQL.setValue("isconfirm", 0);
|
|
|
+ insertSQL.setValue("sourceobject", "u8");
|
|
|
+ insertSQL.setValue("sourceid", u8id);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", 0);
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("status", "审核");
|
|
|
+ insertSQL.setValue("checkby", username);
|
|
|
+ insertSQL.setDateValue("checkdate");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ if(u8billsRowsMap.containsKey("1")){
|
|
|
+ int i=0;
|
|
|
+ for(Row row : u8billsRowsMap.get("1")){
|
|
|
+ InsertSQL insertSQLdetail = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ long st_stockbill_itemsid =createTableID("st_stockbill_items");
|
|
|
+ insertSQLdetail.setUniqueid(st_stockbill_itemsid);
|
|
|
+ insertSQLdetail.setSiteid(siteid);
|
|
|
+ insertSQLdetail.setValue("rowno", i + 1);
|
|
|
+ insertSQLdetail.setValue("st_stockbillid", st_stockbillid);
|
|
|
+ insertSQLdetail.setValue("itemid", row.getLong("itemid"));
|
|
|
+ insertSQLdetail.setValue("qty", row.getBigDecimal("qty"));
|
|
|
+ insertSQLdetail.setValue("discountrate", 1);
|
|
|
+ insertSQLdetail.setValue("sa_dispatch_itemsid", 0);
|
|
|
+ insertSQLdetail.setValue("itemno", row.getString("itemno"));
|
|
|
+ insertSQLdetail.setValue("itemname", row.getString("itemname"));
|
|
|
+ insertSQLdetail.setValue("model", row.getString("model"));
|
|
|
+ insertSQLdetail.setValue("price", row.getBigDecimal("price"));
|
|
|
+ insertSQLdetail.setValue("amount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price")));
|
|
|
+ insertSQLdetail.setValue("untaxedprice", row.getBigDecimal("taxprice"));
|
|
|
+ insertSQLdetail.setValue("untaxedamount", row.getBigDecimal("qty").multiply(row.getBigDecimal("taxprice")));
|
|
|
+ i++;
|
|
|
+ sqllist.add(insertSQLdetail.getSQL());
|
|
|
+ if(u8billcodesRowsMap.containsKey(row.getString("itemid"))){
|
|
|
+ for(Row row1 :u8billcodesRowsMap.get(row.getString("itemid"))){
|
|
|
+ if(row1.getBoolean("rb")){
|
|
|
+ InsertSQL insertSQLdetailsku = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
|
|
|
+ long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
|
|
|
+ insertSQLdetailsku.setUniqueid(st_stockbill_items_skuid);
|
|
|
+ insertSQLdetailsku.setSiteid(siteid);
|
|
|
+ insertSQLdetailsku.setValue("stockid", row1.getLong("stockid"));
|
|
|
+ insertSQLdetailsku.setValue("itemid",row1.getLong("itemid"));
|
|
|
+ insertSQLdetailsku.setValue("sku",StringUtils.isBlank(row1.getString("sku"))?"":row1.getString("sku"));
|
|
|
+ insertSQLdetailsku.setValue("st_stockbillid",st_stockbillid);
|
|
|
+ insertSQLdetailsku.setValue("st_stockbill_itemsid",st_stockbill_itemsid);
|
|
|
+ sqllist.add(insertSQLdetailsku.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //外购入库红
|
|
|
+ st_stockbillid = createTableID("st_stockbill");
|
|
|
+ insertSQL = SQLFactory.createInsertSQL(this, "st_stockbill");
|
|
|
+ insertSQL.setUniqueid(st_stockbillid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("departmentid", departmentRowsMap.containsKey("101")?departmentRowsMap.get("101").get(0).getLong("departmentid"):0);
|
|
|
+ insertSQL.setValue("stockid", stockRowsMap.containsKey("101")?stockRowsMap.get("101").get(0).getLong("stockid"):0);
|
|
|
+ insertSQL.setValue("type", "其他入库");
|
|
|
+ insertSQL.setValue("typemx", "外购入库");
|
|
|
+ insertSQL.setValue("rb", 0);
|
|
|
+ insertSQL.setValue("remarks", "U8单据上传生成");
|
|
|
+ insertSQL.setValue("billdate", u8.get(0).getString("billdate"));
|
|
|
+ insertSQL.setValue("period",u8.get(0).getString("period"));
|
|
|
+ insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
+ insertSQL.setValue("isconfirm", 0);
|
|
|
+ insertSQL.setValue("sourceobject", "u8");
|
|
|
+ insertSQL.setValue("sourceid", u8id);
|
|
|
+ insertSQL.setValue("sys_enterpriseid", 0);
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
+ insertSQL.setDateValue("createdate");
|
|
|
+ insertSQL.setValue("changeby", username);
|
|
|
+ insertSQL.setDateValue("changedate");
|
|
|
+ insertSQL.setValue("status", "审核");
|
|
|
+ insertSQL.setValue("checkby", username);
|
|
|
+ insertSQL.setDateValue("checkdate");
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ if(u8billsRowsMap.containsKey("0")){
|
|
|
+ int i=0;
|
|
|
+ for(Row row : u8billsRowsMap.get("0")){
|
|
|
+ InsertSQL insertSQLdetail = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ long st_stockbill_itemsid =createTableID("st_stockbill_items");
|
|
|
+ insertSQLdetail.setUniqueid(st_stockbill_itemsid);
|
|
|
+ insertSQLdetail.setSiteid(siteid);
|
|
|
+ insertSQLdetail.setValue("rowno", i + 1);
|
|
|
+ insertSQLdetail.setValue("st_stockbillid", st_stockbillid);
|
|
|
+ insertSQLdetail.setValue("itemid", row.getLong("itemid"));
|
|
|
+ insertSQLdetail.setValue("qty", row.getBigDecimal("qty"));
|
|
|
+ insertSQLdetail.setValue("discountrate", 1);
|
|
|
+ insertSQLdetail.setValue("sa_dispatch_itemsid", 0);
|
|
|
+ insertSQLdetail.setValue("itemno", row.getString("itemno"));
|
|
|
+ insertSQLdetail.setValue("itemname", row.getString("itemname"));
|
|
|
+ insertSQLdetail.setValue("model", row.getString("model"));
|
|
|
+ insertSQLdetail.setValue("price", row.getBigDecimal("price"));
|
|
|
+ insertSQLdetail.setValue("amount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price")));
|
|
|
+ insertSQLdetail.setValue("untaxedprice", row.getBigDecimal("taxprice"));
|
|
|
+ insertSQLdetail.setValue("untaxedamount", row.getBigDecimal("qty").multiply(row.getBigDecimal("taxprice")));
|
|
|
+ i++;
|
|
|
+ sqllist.add(insertSQLdetail.getSQL());
|
|
|
+ if(u8billcodesRowsMap.containsKey(row.getString("itemid"))){
|
|
|
+ for(Row row1 :u8billcodesRowsMap.get(row.getString("itemid"))){
|
|
|
+ if(!row1.getBoolean("rb")){
|
|
|
+ InsertSQL insertSQLdetailsku = SQLFactory.createInsertSQL(this, "st_stockbill_items_sku");
|
|
|
+ long st_stockbill_items_skuid = createTableID("st_stockbill_items_sku");
|
|
|
+ insertSQLdetailsku.setUniqueid(st_stockbill_items_skuid);
|
|
|
+ insertSQLdetailsku.setSiteid(siteid);
|
|
|
+ insertSQLdetailsku.setValue("stockid", row1.getLong("stockid"));
|
|
|
+ insertSQLdetailsku.setValue("itemid",row1.getLong("itemid"));
|
|
|
+ insertSQLdetailsku.setValue("sku", StringUtils.isBlank(row1.getString("sku"))?"":row1.getString("sku"));
|
|
|
+ insertSQLdetailsku.setValue("st_stockbillid",st_stockbillid);
|
|
|
+ insertSQLdetailsku.setValue("st_stockbill_itemsid",st_stockbill_itemsid);
|
|
|
+ sqllist.add(insertSQLdetailsku.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "u8");
|
|
|
+ updateSQL.setUniqueid(u8id);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", "审核");
|
|
|
+// updateSQL.setValue("checkby", username);
|
|
|
+// updateSQL.setDateValue("checkdate");
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ updateIcinvbal(true,u8id);
|
|
|
+
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "反审核", apiversion = R.ID2025073114082503.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class})
|
|
|
+ public String uncheck() throws YosException {
|
|
|
+ long u8id = content.getLong("u8id");
|
|
|
+ ArrayList<String> sqllist=new ArrayList<>();
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "u8");
|
|
|
+ updateSQL.setUniqueid(u8id);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("status", "新建");
|
|
|
+// updateSQL.setValue("checkby", "");
|
|
|
+// updateSQL.setValue("checkdate","null");
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
+
|
|
|
+ sqllist.add("delete from st_stockbill_items where st_stockbillid in(select st_stockbillid from st_stockbill where sourceid="+u8id +" and sourceobject='u8')");
|
|
|
+ sqllist.add("delete from st_stockbill_items_sku where st_stockbillid in(select st_stockbillid from st_stockbill where sourceid="+u8id +" and sourceobject='u8')");
|
|
|
+ sqllist.add("delete from st_stockbill where sourceid="+u8id +" and sourceobject='u8'");
|
|
|
+
|
|
|
+ updateIcinvbal(false,u8id);
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateIcinvbal(boolean ischeck,long u8id) throws YosException {
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
+ sql.append("select t.stockid,t.itemid,sum(t.qty)qty from (");
|
|
|
+ sql.append("select T2.itemid,T2.stockid,");
|
|
|
+ sql.append("CASE ");
|
|
|
+ sql.append("WHEN T1.type='其他出库' and t1.rb='1' then -T2.qty ");
|
|
|
+ sql.append("WHEN T1.type='其他出库' and t1.rb='0' then T2.qty ");
|
|
|
+ sql.append("WHEN T1.type='其他入库' and t1.rb='1' then T2.qty ");
|
|
|
+ sql.append("WHEN T1.type='其他入库' and t1.rb='0' then -T2.qty ");
|
|
|
+ sql.append("end qty ");
|
|
|
+ sql.append(" from st_stockbill t1 ");
|
|
|
+ sql.append("inner join st_stockbill_items t2 on t1.st_stockbillid=t2.st_stockbillid ");
|
|
|
+ sql.append("where t1.sourceobject='U8' and t1.sourceid='"
|
|
|
+ + u8id + "' and t1.status='审核' ");
|
|
|
+ sql.append(")t group by t.stockid,t.itemid");
|
|
|
+
|
|
|
+ Rows rows= dbConnect.runSqlQuery(sql.toString());
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ RowsMap invbalsRowsMap = SQLFactory.createQuerySQL(dbConnect, "st_invbal").setWhere("siteid", siteid).setWhere("itemid", rows.toArrayList("itemid")).query().toRowsMap("itemid");
|
|
|
+ RowsMap invbalsTotalRowsMap = SQLFactory.createQuerySQL(dbConnect, "st_invbal_total").setWhere("siteid", siteid).setWhere("itemid", rows.toArrayList("itemid")).query().toRowsMap("itemid");
|
|
|
+ int i = 0;
|
|
|
+ for (Row row : rows) {
|
|
|
+ long itemid =row.getLong("itemid");
|
|
|
+ long stockid = row.getLong("stockid");
|
|
|
+ BigDecimal qty = ischeck ? row.getBigDecimal("qty") : row.getBigDecimal("qty").negate();
|
|
|
+ if (!invbalsRowsMap.containsKey(String.valueOf(itemid)) || !invbalsRowsMap.get(String.valueOf(itemid)).toRowsMap("stockid").containsKey(String.valueOf(stockid))) {
|
|
|
+ InsertSQL invbalInsert = SQLFactory.createInsertSQL(this, "st_invbal");
|
|
|
+ invbalInsert.setValue("siteid", siteid);
|
|
|
+ invbalInsert.setValue("stockid", stockid);
|
|
|
+ invbalInsert.setValue("itemid", itemid);
|
|
|
+ invbalInsert.setValue("qty", qty.doubleValue());
|
|
|
+ sqlList.add(invbalInsert.getSQL());
|
|
|
+ } else {
|
|
|
+ UpdateSQL invbalUpdate = SQLFactory.createUpdateSQL(this, "st_invbal");
|
|
|
+ invbalUpdate.addValue("qty", invbalsRowsMap.get(String.valueOf(itemid)).get(0).getBigDecimal("qty").add(qty));
|
|
|
+ invbalUpdate.setWhere("itemid", itemid);
|
|
|
+ invbalUpdate.setWhere("stockid", stockid);
|
|
|
+ invbalUpdate.setWhere("siteid", siteid);
|
|
|
+ sqlList.add(invbalUpdate.getSQL());
|
|
|
+ }
|
|
|
+ //是否纳入总仓
|
|
|
+
|
|
|
+ if (SQLFactory.getRow(this,"st_stock", stockid).getBoolean("isintotalstock")) {
|
|
|
+ if (!invbalsTotalRowsMap.containsKey(String.valueOf(itemid))) {
|
|
|
+ InsertSQL invbalInsert = SQLFactory.createInsertSQL(this, "st_invbal_total");
|
|
|
+ invbalInsert.setValue("siteid", siteid);
|
|
|
+ invbalInsert.setValue("itemid", itemid);
|
|
|
+ invbalInsert.setValue("cansaleqty", qty.doubleValue());//可销售数量
|
|
|
+ invbalInsert.setValue("candispatchqty", qty.doubleValue());//可发货数量
|
|
|
+ invbalInsert.setValue("qty", qty.doubleValue());//库存数量
|
|
|
+ sqlList.add(invbalInsert.getSQL());
|
|
|
+ } else {
|
|
|
+ UpdateSQL invbalUpdate = SQLFactory.createUpdateSQL(this, "st_invbal_total");
|
|
|
+ invbalUpdate.addValue("qty", invbalsTotalRowsMap.get(String.valueOf(itemid)).get(0).getBigDecimal("qty").add(qty));//库存数量
|
|
|
+ invbalUpdate.setWhere("itemid", itemid);
|
|
|
+ invbalUpdate.setWhere("siteid", siteid);
|
|
|
+ sqlList.add(invbalUpdate.getSQL());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "一键清空", apiversion = R.ID2025073114272903.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class, u8billcodes.class, u8bills.class, u8itemprice.class})
|
|
|
+ public String deleteAll() throws YosException {
|
|
|
+ long u8id = content.getLong("u8id");
|
|
|
+ ArrayList<String> sqllist=new ArrayList<>();
|
|
|
+
|
|
|
+ Rows RowsStatus = dbConnect.runSqlQuery("select u8id,status from u8 where siteid='"
|
|
|
+ + siteid + "' and u8id='" + u8id + "'");
|
|
|
+
|
|
|
+ if (RowsStatus.isNotEmpty()) {
|
|
|
+ if (!RowsStatus.get(0).getString("status").equals("新建")) {
|
|
|
+ return getErrReturnObject().setErrMsg("非新建状态的销售出库U8上传无法一键清空").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sqllist.add("delete from u8billcodes where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8bills where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8itemprice where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "一键取单", apiversion = R.ID2025073114290603.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class, u8billcodes.class, u8bills.class, u8itemprice.class})
|
|
|
+ public String oneclickaddbills() throws YosException {
|
|
|
+ long u8id = content.getLong("u8id");
|
|
|
+ ArrayList<String> sqllist=new ArrayList<>();
|
|
|
+ sqllist.add("delete from u8billcodes where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8bills where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+ sqllist.add("delete from u8itemprice where siteid='" + siteid + "' and u8id=" + u8id);
|
|
|
+
|
|
|
+ SQLFactory sqlFactory =new SQLFactory(this,"销售出库U8上传序列号查询");
|
|
|
+ sqlFactory.addParameter("u8id",u8id);
|
|
|
+ Rows rows =dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ for(Row row : rows){
|
|
|
+ long u8billcodesid = createTableID("u8billcodes");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "u8billcodes");
|
|
|
+ insertSQL.setUniqueid(u8billcodesid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("u8id", u8id);
|
|
|
+ insertSQL.setValue("sourceid", row.getString("sourceid"));
|
|
|
+ insertSQL.setValue("sourceobject", row.getString("sourceobject"));
|
|
|
+ insertSQL.setValue("type", row.getString("type"));
|
|
|
+ insertSQL.setValue("typemx", row.getString("typemx"));
|
|
|
+ insertSQL.setValue("stockid", row.getString("stockid"));
|
|
|
+ insertSQL.setValue("status", row.getString("status"));
|
|
|
+ insertSQL.setValue("rb", row.getString("rb"));
|
|
|
+ insertSQL.setValue("qty", row.getString("qty"));
|
|
|
+ insertSQL.setValue("st_stockbillid", row.getString("st_stockbillid"));
|
|
|
+ insertSQL.setValue("st_stockbill_items_skuid", row.getString("st_stockbill_items_skuid"));
|
|
|
+
|
|
|
+ insertSQL.setValue("sku", row.getString("sku"));
|
|
|
+ insertSQL.setValue("itemid", row.getString("itemid"));
|
|
|
+ insertSQL.setValue("billno", row.getString("billno"));
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ sqllist=new ArrayList<>();
|
|
|
+ sqlFactory =new SQLFactory(this,"销售出库U8上传单据查询");
|
|
|
+ sqlFactory.addParameter("u8id",u8id);
|
|
|
+ Rows rowsbill =dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ for(Row row : rowsbill){
|
|
|
+ long u8billsid = createTableID("u8bills");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "u8bills");
|
|
|
+ insertSQL.setUniqueid(u8billsid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("u8id", u8id);
|
|
|
+ insertSQL.setValue("name", row.getString("name"));
|
|
|
+ insertSQL.setValue("address", row.getString("address"));
|
|
|
+ insertSQL.setValue("billdate", row.getString("billdate"));
|
|
|
+ insertSQL.setValue("outplace", row.getString("outplace"));
|
|
|
+ insertSQL.setValue("remarks", row.getString("remarks"));
|
|
|
+ insertSQL.setValue("period", row.getString("period"));
|
|
|
+ insertSQL.setValue("sys_enterpriseid", row.getString("sys_enterpriseid"));
|
|
|
+ insertSQL.setValue("rb", row.getString("rb"));
|
|
|
+ insertSQL.setValue("sourceobject", row.getString("sourceobject"));
|
|
|
+ insertSQL.setValue("sourceid", row.getString("sourceid"));
|
|
|
+ insertSQL.setValue("phonenumber", row.getString("phonenumber"));
|
|
|
+ insertSQL.setValue("st_stockbillid", row.getString("st_stockbillid"));
|
|
|
+ insertSQL.setValue("type", row.getString("type"));
|
|
|
+ insertSQL.setValue("typemx", row.getString("typemx"));
|
|
|
+ insertSQL.setValue("billno", row.getString("billno"));
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ sqllist=new ArrayList<>();
|
|
|
+ Rows stock =dbConnect.runSqlQuery("select stockid,stockno from st_stock where siteid='"+siteid+"'");
|
|
|
+ RowsMap stockRowsMap = stock.toRowsMap("stockno");
|
|
|
+
|
|
|
+ SQLFactory sqlFactory1 =new SQLFactory(this,"销售出库u8商品价格查询");
|
|
|
+ sqlFactory1.addParameter("u8id",u8id);
|
|
|
+ sqlFactory1.addParameter("tqstockid",stockRowsMap.containsKey("103")?stockRowsMap.get("103").get(0).getLong("stockid"):0);
|
|
|
+ sqlFactory1.addParameter("mqstockid",stockRowsMap.containsKey("109")?stockRowsMap.get("109").get(0).getLong("stockid"):0);
|
|
|
+ Rows rowsitemprice=dbConnect.runSqlQuery(sqlFactory1);
|
|
|
+ for(Row row : rowsitemprice){
|
|
|
+ long u8itempriceid = createTableID("u8itemprice");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "u8itemprice");
|
|
|
+ insertSQL.setUniqueid(u8itempriceid);
|
|
|
+ insertSQL.setSiteid(siteid);
|
|
|
+ insertSQL.setValue("u8id", u8id);
|
|
|
+ insertSQL.setValue("itemid", row.getString("itemid"));
|
|
|
+ insertSQL.setValue("taxrate", row.getString("taxrate"));
|
|
|
+ insertSQL.setValue("stockid", row.getString("stockid"));
|
|
|
+ insertSQL.setValue("saleprice", row.getString("saleprice"));
|
|
|
+ insertSQL.setValue("saleamount", row.getBigDecimal("saleprice").multiply(row.getBigDecimal("qty")));
|
|
|
+ insertSQL.setValue("qty", row.getString("qty"));
|
|
|
+ sqllist.add(insertSQL.getSQL());
|
|
|
+ }
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "选择取单", apiversion = R.ID2025073114292603.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class, u8billcodes.class, u8bills.class, u8itemprice.class})
|
|
|
+ public String selectaddbills() throws YosException {
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "价格调整", apiversion = R.ID2025073114312903.v1.class)
|
|
|
+ @CACHEING_CLEAN(apiClass = {u8.class, u8billcodes.class, u8bills.class, u8itemprice.class})
|
|
|
+ public String changeprice() throws YosException {
|
|
|
+ long u8id = content.getLong("u8id");
|
|
|
+ String changetype=content.getString("changetype");
|
|
|
+ BigDecimal changevalue=content.getBigDecimal("changevalue");
|
|
|
+ ArrayList<String> sqllist=new ArrayList<>();
|
|
|
+
|
|
|
+ Rows u8itempricerows = dbConnect.runSqlQuery("select * from u8itemprice where siteid='"+siteid+"' and u8id="+u8id);
|
|
|
+ for(Row row :u8itempricerows){
|
|
|
+ BigDecimal taxprice=BigDecimal.ZERO;
|
|
|
+ BigDecimal price=BigDecimal.ZERO;
|
|
|
+ if(changetype.equals("百分比")){
|
|
|
+ taxprice= row.getBigDecimal("saleprice").multiply(BigDecimal.valueOf(100).add(changevalue)).divide(BigDecimal.valueOf(100)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ price=taxprice.multiply(BigDecimal.valueOf(100).add(row.getBigDecimal("taxrate"))).divide(BigDecimal.valueOf(100)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ }else if (changetype.equals("金额")) {
|
|
|
+ taxprice = row.getBigDecimal("saleprice").add(changevalue);
|
|
|
+ price=taxprice.multiply(BigDecimal.valueOf(100).add(row.getBigDecimal("taxrate"))).divide(BigDecimal.valueOf(100)).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ }
|
|
|
+ sqllist.add("update u8itemprice set price="+price+",taxprice="+taxprice+" where u8itempriceid="+ row.getLong("u8itempriceid"));
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "u8");
|
|
|
+ updateSQL.setUniqueid(u8id);
|
|
|
+ updateSQL.setSiteid(siteid);
|
|
|
+ updateSQL.setValue("changetype",changetype);
|
|
|
+ updateSQL.setValue("changevalue",changevalue);
|
|
|
+ sqllist.add(updateSQL.getSQL());
|
|
|
+ dbConnect.runSqlUpdate(sqllist);
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @API(title = "创建U8发货单", apiversion = R.ID2025080113261703.v1.class)
|
|
|
+ public String createU8Bill() throws YosException {
|
|
|
+ long u8id=content.getLong("u8id");
|
|
|
+ Rows u8s=dbConnect.runSqlQuery("select * from u8 where u8id="+u8id);
|
|
|
+ if(u8s.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("该销售出库U8上传不存在").toString();
|
|
|
+ }
|
|
|
+ Row u8=u8s.get(0);
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("accesstoken", 1);
|
|
|
+ object.put("classname", "U8System_Dispatch");
|
|
|
+ object.put("method", "insert");
|
|
|
+
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("cAcc_Id", "666");
|
|
|
+ content.put("ddate", u8.getString("billdate"));
|
|
|
+ content.put("cdlcode", u8.getString("billno"));
|
|
|
+ content.put("sysfrom", "drp");
|
|
|
+
|
|
|
+ JSONArray detail = new JSONArray();
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t3.itemno,t1.itemid,t1.stockno,ifnull(t1.qty,0) qty,ifnull(t2.price,0) price,ifnull(t2.taxprice,0) taxprice,ifnull(t2.taxrate,0) taxrate,t2.stockid from (\n" +
|
|
|
+ "select distinct t1.itemid,t1.u8id,case when t2.outplace='谈桥' then '103' when t2.outplace='马桥' then '109' else t3.stockno end as stockno,sum(t1.qty)qty from u8billcodes t1\n" +
|
|
|
+ "inner join u8bills t2 on t1.billno=t2.billno and t1.u8id=t2.u8id \n" +
|
|
|
+ "left join st_stock t3 on t1.stockid=t3.stockid\n" +
|
|
|
+ "where t1.rb='1' and t1.u8id=" +u8id+
|
|
|
+ " group by t1.itemid,case when t2.outplace='谈桥' then '103' when t2.outplace='马桥' then '109' else t3.stockno end,t1.u8id )t1 left join U8ITEMPRICE t2 on t1.u8id=t2.u8id and t1.itemid=t2.itemid left join plm_item t3 on t1.itemid=t3.itemid");
|
|
|
+ int rowno = 1;
|
|
|
+ for (Row row : rows) {
|
|
|
+ BigDecimal qty = row.getBigDecimal("qty");
|
|
|
+ BigDecimal taxrate = row.getBigDecimal("taxrate");
|
|
|
+ BigDecimal taxprice = row.getBigDecimal("taxprice");
|
|
|
+ BigDecimal price = row.getBigDecimal("price");
|
|
|
+
|
|
|
+ JSONObject dObject = new JSONObject();
|
|
|
+ dObject.put("cinvcode", row.getString("itemno"));
|
|
|
+ dObject.put("iquantity", qty + "");
|
|
|
+ dObject.put("irowno", rowno++);
|
|
|
+ dObject.put("fprice", price + "");// 去税单价
|
|
|
+ // dObject.put("famount", new BigDecimal(Math.mul(fprice, fqty,
|
|
|
+ // 2)).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());//去税金额
|
|
|
+ dObject.put(
|
|
|
+ "famount",price.multiply(qty).setScale(2, BigDecimal.ROUND_HALF_UP)
|
|
|
+ .toPlainString());// 去税金额
|
|
|
+
|
|
|
+ dObject.put(
|
|
|
+ "ftax", (taxprice.subtract(price)).multiply(qty).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());// 税额
|
|
|
+
|
|
|
+ dObject.put("ftaxrate", taxrate + "");// 税率
|
|
|
+ dObject.put(
|
|
|
+ "ftaxamount", taxprice.multiply(qty).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());// 价税合计
|
|
|
+ dObject.put("ftaxprice", taxprice + "");// 含税单价
|
|
|
+ dObject.put("fstockno", row.getString("stockno").toString());
|
|
|
+ Rows codeRows =dbConnect.runSqlQuery("select sku from u8billcodes where rb='1' and u8id='"
|
|
|
+ + u8id
|
|
|
+ + "' and "
|
|
|
+ + "itemid='"
|
|
|
+ + row.getString("itemid")
|
|
|
+ + "' and stockid='"
|
|
|
+ + row.getString("stockid")
|
|
|
+ + "' and ifnull(sku,'')!=''");
|
|
|
+ dObject.put("fmachinecodes", codeRows.toArrayList("sku"));
|
|
|
+ detail.add(dObject);
|
|
|
+ }
|
|
|
+ content.put("detail", detail);
|
|
|
+ object.put("content", content);
|
|
|
+ // U8Rest rest = new U8Rest();
|
|
|
+
|
|
|
+ // String a = rest.post(object.toString());
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "创建U8退货单", apiversion = R.ID2025080113595003.v1.class)
|
|
|
+ public String createU8ReturnBill() throws YosException {
|
|
|
+ long u8id=content.getLong("u8id");
|
|
|
+ Rows u8s=dbConnect.runSqlQuery("select * from u8 where u8id="+u8id);
|
|
|
+ if(u8s.isEmpty()){
|
|
|
+ return getErrReturnObject().setErrMsg("该销售出库U8上传不存在").toString();
|
|
|
+ }
|
|
|
+ Row u8=u8s.get(0);
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("accesstoken", 1);
|
|
|
+ object.put("classname", "U8System_Dispatch");
|
|
|
+ object.put("method", "insertReturn");
|
|
|
+
|
|
|
+ JSONObject content = new JSONObject();
|
|
|
+ content.put("cAcc_Id", "666");
|
|
|
+ content.put("ddate", u8.getString("billdate"));
|
|
|
+ content.put("cdlcode", u8.getString("billno") + "R");
|
|
|
+ content.put("sysfrom", "drp");
|
|
|
+
|
|
|
+ JSONArray detail = new JSONArray();
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t1.itemid,t1.stockno,ifnull(-t1.qty,0) qty,ifnull(t2.price,0) price,ifnull(t2.taxprice,0) taxprice,ifnull(t2.taxrate,0) taxrate,t3.itemno,t2.stockid from (\n" +
|
|
|
+ "select distinct t1.itemid,t1.u8id,case when t2.outplace='谈桥' then '103' when t2.outplace='马桥' then '109' else t3.stockno end as stockno,sum(t1.qty)qty from u8billcodes t1\n" +
|
|
|
+ "inner join u8bills t2 on t1.billno=t2.billno and t1.u8id=t2.u8id \n" +
|
|
|
+ "left join st_stock t3 on t1.stockid=t3.stockid\n" +
|
|
|
+ "where t1.rb='0' and t1.u8id=" +u8id+
|
|
|
+ " group by t1.itemid,case when t2.outplace='谈桥' then '103' when t2.outplace='马桥' then '109' else t3.stockno end,t1.u8id )t1 left join U8ITEMPRICE t2 on t1.u8id=t2.u8id and t1.itemid=t2.itemid left join plm_item t3 on t1.itemid=t3.itemid");
|
|
|
+ int rowno = 1;
|
|
|
+ for (Row row : rows) {
|
|
|
+ BigDecimal qty = row.getBigDecimal("qty");
|
|
|
+ BigDecimal taxrate = row.getBigDecimal("taxrate");
|
|
|
+ BigDecimal taxprice = row.getBigDecimal("taxprice");
|
|
|
+ BigDecimal price = row.getBigDecimal("price");
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject dObject = new JSONObject();
|
|
|
+ dObject.put("cinvcode", row.getString("itemno"));
|
|
|
+ dObject.put("iquantity", qty + "");
|
|
|
+ dObject.put("irowno", rowno++);
|
|
|
+ dObject.put("fprice", price + "");
|
|
|
+ dObject.put("famount", price.multiply(qty).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
|
|
|
+
|
|
|
+ dObject.put(
|
|
|
+ "ftax", (taxprice.subtract(price)).multiply(qty).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
|
|
|
+ dObject.put("ftaxrate", taxrate + "");
|
|
|
+ dObject.put(
|
|
|
+ "ftaxamount", taxprice.multiply(qty).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
|
|
|
+ dObject.put("ftaxprice", taxprice + "");
|
|
|
+ dObject.put("fstockno", row.getString("fstockno").toString());
|
|
|
+ Rows codeRows =dbConnect.runSqlQuery("select sku from u8billcodes where rb='0' and u8id='"
|
|
|
+ + u8id
|
|
|
+ + "' and "
|
|
|
+ + "itemid='"
|
|
|
+ + row.getString("itemid")
|
|
|
+ + "' and stockid='"
|
|
|
+ + row.getString("stockid")
|
|
|
+ + "' and ifnull(sku,'')!=''");
|
|
|
+
|
|
|
+ dObject.put("fmachinecodes", codeRows.toArrayList("sku"));
|
|
|
+ detail.add(dObject);
|
|
|
+ }
|
|
|
+ content.put("detail", detail);
|
|
|
+ object.put("content", content);
|
|
|
+ U8Rest rest = new U8Rest();
|
|
|
+
|
|
|
+ // String a = rest.post(object.toString());
|
|
|
+ //System.err.println(a);
|
|
|
+ // ((PaoSet) getThisPaoSet()).addWarning(new P2AppException("", a));
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|