| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- 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");
- RowsMap invbalsSaleRowsMap = SQLFactory.createQuerySQL(dbConnect, "st_invbal_sale").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());
- // }
- // }
- //是否为销售仓库
- if (SQLFactory.getRow(this, "st_stock", stockid).getBoolean("issalestock")) {
- if (!invbalsSaleRowsMap.containsKey(String.valueOf(itemid))) {
- InsertSQL invbalInsert = SQLFactory.createInsertSQL(this, "st_invbal_sale");
- 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_sale");
- invbalUpdate.addValue("qty", invbalsSaleRowsMap.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();
- }
- }
|