|
|
@@ -50,27 +50,27 @@ public class stockbill extends Controller {
|
|
|
String tableName = "st_stockbill";
|
|
|
Long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
Long sys_enterpriseid = content.getLong("sys_enterpriseid");
|
|
|
- Rows contactrows =dbConnect.runSqlQuery("select * from sys_enterprise_contacts where sys_enterpriseid="+sys_enterpriseid+" and ifnull(deleted,0)=0");
|
|
|
- Long rec_contactsid=content.getLongValue("rec_contactsid");
|
|
|
- if(contactrows.isNotEmpty()){
|
|
|
+ Rows contactrows = dbConnect.runSqlQuery("select * from sys_enterprise_contacts where sys_enterpriseid=" + sys_enterpriseid + " and ifnull(deleted,0)=0");
|
|
|
+ Long rec_contactsid = content.getLongValue("rec_contactsid");
|
|
|
+ if (contactrows.isNotEmpty()) {
|
|
|
rec_contactsid = contactrows.get(0).getLong("contactsid");
|
|
|
}
|
|
|
Long departmentid = content.getLongValue("departmentid");
|
|
|
String type = content.getStringValue("type");
|
|
|
- long stockid= content.getLongValue("stockid");
|
|
|
+ long stockid = content.getLongValue("stockid");
|
|
|
String typemx = content.getStringValue("typemx");
|
|
|
String remarks = content.getStringValue("remarks");
|
|
|
String billdate = content.getStringValue("billdate");
|
|
|
String outplace = content.getStringValue("outplace");
|
|
|
String delivery = content.getStringValue("delivery");
|
|
|
- Rows invoicerows =dbConnect.runSqlQuery("select * from sys_enterprise_finance where sys_enterpriseid="+sys_enterpriseid+" order by isdefault desc");
|
|
|
+ Rows invoicerows = dbConnect.runSqlQuery("select * from sys_enterprise_finance where sys_enterpriseid=" + sys_enterpriseid + " order by isdefault desc");
|
|
|
String invoice_enterprisename = content.getStringValue("invoice_enterprisename");
|
|
|
String invoice_address = content.getStringValue("invoice_address");
|
|
|
String invoice_taxno = content.getStringValue("invoice_taxno");
|
|
|
- if(invoicerows.isNotEmpty()){
|
|
|
- invoice_enterprisename=invoicerows.get(0).getString("enterprisename");
|
|
|
- invoice_address=invoicerows.get(0).getString("address");
|
|
|
- invoice_taxno=invoicerows.get(0).getString("taxno");
|
|
|
+ if (invoicerows.isNotEmpty()) {
|
|
|
+ invoice_enterprisename = invoicerows.get(0).getString("enterprisename");
|
|
|
+ invoice_address = invoicerows.get(0).getString("address");
|
|
|
+ invoice_taxno = invoicerows.get(0).getString("taxno");
|
|
|
}
|
|
|
String tracknumber = content.getStringValue("tracknumber");
|
|
|
|
|
|
@@ -170,8 +170,8 @@ public class stockbill extends Controller {
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
|
|
|
- Rows rowsdetail = dbConnect.runSqlQuery("select amount from st_stockbill_items where st_stockbillid="+st_stockbillid);
|
|
|
- row.put("receivableamount",rowsdetail.sum("amount"));
|
|
|
+ Rows rowsdetail = dbConnect.runSqlQuery("select amount from st_stockbill_items where st_stockbillid=" + st_stockbillid);
|
|
|
+ row.put("receivableamount", rowsdetail.sum("amount"));
|
|
|
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
@@ -179,31 +179,13 @@ public class stockbill extends Controller {
|
|
|
@API(title = "查询出入库单列表", apiversion = R.ID20230719153903.v1.class)
|
|
|
@CACHEING
|
|
|
public String queryStockbillList() throws YosException {
|
|
|
+ ArrayList<String> billtypes = new ArrayList<>();
|
|
|
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.outplace like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t3.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t6.depname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append(")");
|
|
|
- }
|
|
|
if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
- JSONArray jsonArray =whereObject.getJSONArray("type");
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
- StringBuffer str=new StringBuffer("(");
|
|
|
- for(Object o :jsonArray){
|
|
|
- str.append("'"+(String)o+"',");
|
|
|
- }
|
|
|
- String result = str.substring(0, str.length() - 1);
|
|
|
- result=result+")";
|
|
|
- where.append(" and(");
|
|
|
- where.append("t1.type in"+result);
|
|
|
- where.append(")");
|
|
|
- }
|
|
|
+ JSONArray jsonArray = whereObject.getJSONArray("type");
|
|
|
+ billtypes = (ArrayList<String>) jsonArray.toJavaList(String.class);
|
|
|
}
|
|
|
if (whereObject.containsKey("typemx") && !"".equals(whereObject.getString("typemx"))) {
|
|
|
where.append(" and t1.typemx ='").append(whereObject.getString("typemx")).append("' ");
|
|
|
@@ -223,84 +205,63 @@ public class stockbill extends Controller {
|
|
|
if (whereObject.containsKey("remarks") && !"".equals(whereObject.getString("remarks"))) {
|
|
|
where.append("and t1.remarks like'%").append(whereObject.getString("remarks")).append("%' ");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if (whereObject.containsKey("dateinterval") && !"".equals(whereObject.getString("dateinterval"))) {
|
|
|
- if(whereObject.getString("dateinterval").equals("past30days")){
|
|
|
+ if (whereObject.getString("dateinterval").equals("past30days")) {
|
|
|
where.append("and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >=DATE_SUB(CURDATE(), INTERVAL 30 DAY)");
|
|
|
} else if (whereObject.getString("dateinterval").equals("past15days")) {
|
|
|
where.append("and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >=DATE_SUB(CURDATE(), INTERVAL 15 DAY)");
|
|
|
- }else if (whereObject.getString("dateinterval").equals("today")) {
|
|
|
+ } else if (whereObject.getString("dateinterval").equals("today")) {
|
|
|
where.append("and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >=CURDATE()");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (whereObject.containsKey("checknoprint") && !"".equals(whereObject.getString("checknoprint"))) {
|
|
|
- if(whereObject.getBooleanValue("checknoprint")){
|
|
|
+ if (whereObject.getBooleanValue("checknoprint")) {
|
|
|
where.append("and t1.status ='审核' and isreport=0");
|
|
|
}
|
|
|
}
|
|
|
if (whereObject.containsKey("nowaybillgenerated") && !"".equals(whereObject.getString("nowaybillgenerated"))) {
|
|
|
- if(whereObject.getBooleanValue("checknoprint")){
|
|
|
+ if (whereObject.getBooleanValue("checknoprint")) {
|
|
|
where.append("and t1.isreceiver=0 and ifnull(txlogisticid,'')='' ");
|
|
|
}
|
|
|
}
|
|
|
if (whereObject.containsKey("paynocheck") && !"".equals(whereObject.getString("paynocheck"))) {
|
|
|
where.append("and t1.status ='新建' and delivery='到付'");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if (whereObject.containsKey("param") && !"".equals(whereObject.getString("param"))) {
|
|
|
- Rows rowsStockbillid = dbConnect.runSqlQuery("select t1.st_stockbillid from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid " +
|
|
|
- " where t1.siteid='" + siteid + "' and (t2.itemname like '%" + whereObject.getString("param") + "%' or t2.itemno like '%" + whereObject.getString("param") + "%')");
|
|
|
-
|
|
|
- if (rowsStockbillid.toJsonArray("st_stockbillid").isEmpty()) {
|
|
|
- where.append(" and t1.st_stockbillid in (0)");
|
|
|
- } else {
|
|
|
- String str = rowsStockbillid.toJsonArray("st_stockbillid").toJSONString();
|
|
|
- str = str.replace("[", "(").replace("]", ")");
|
|
|
- where.append(" and t1.st_stockbillid in").append(str);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
-// SQLFactory sqlFactory = new SQLFactory(this, "出入库单列表查询", pageSize, pageNumber, pageSorting);
|
|
|
-// sqlFactory.addParameter("siteid", siteid);
|
|
|
-// sqlFactory.addParameter_SQL("where", where);
|
|
|
-// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
- QuerySQL querySQL = queryStockbillList(where.toString());
|
|
|
- querySQL.setPage(pageSize, pageNumber);
|
|
|
- querySQL.setOrderBy(pageSorting);
|
|
|
- Rows rows = querySQL.query();
|
|
|
-
|
|
|
- return getSucReturnObject().setData(rows).toString();
|
|
|
- }
|
|
|
|
|
|
- //查询出入库单列表
|
|
|
- public QuerySQL queryStockbillList(String where) throws YosException {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill","*");
|
|
|
- querySQL.setTableAlias("t1");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid",
|
|
|
- "enterprisename", "abbreviation");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t3", "t1.sys_enterpriseid = t3.sys_enterpriseid AND t1.siteid = t3.siteid",
|
|
|
- "agentnum");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t4", "t1.rec_contactsid=t4.contactsid and t1.siteid = t4.siteid");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_accountbalance", "t5", "t5.sys_enterpriseid=t1.sys_enterpriseid and t1.siteid = t5.siteid and t5.sa_accountclassid =(select t1.sa_accountclassid from sa_accountclass t1 where t1.siteid='"+siteid+"' and t1.accountname='现金账户')",
|
|
|
- "discountamount");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill", "*").setTableAlias("t1");
|
|
|
+ if (billtypes.contains("销售出库")) {
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid AND t1.siteid = t2.siteid",
|
|
|
+ "enterprisename", "abbreviation");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t3", "t1.sys_enterpriseid = t3.sys_enterpriseid AND t1.siteid = t3.siteid",
|
|
|
+ "agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t4", "t1.rec_contactsid=t4.contactsid and t1.siteid = t4.siteid");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_accountbalance", "t5", "t5.sys_enterpriseid=t1.sys_enterpriseid and t1.siteid = t5.siteid and t5.sa_accountclassid =(select t1.sa_accountclassid from sa_accountclass t1 where t1.siteid='" + siteid + "' and t1.accountname='现金账户')",
|
|
|
+ "discountamount");
|
|
|
+ querySQL.addQueryFields("recname", "t4.name");
|
|
|
+ querySQL.addQueryFields("recphonenumber", "t4.phonenumber");
|
|
|
+ querySQL.addQueryFields("recaddress", "t4.address");
|
|
|
+ }
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t6", "t1.departmentid=t6.departmentid and t1.siteid = t6.siteid",
|
|
|
- "depno","depname");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_supplier", "t7", "t1.sa_supplierid=t7.sa_supplierid and t1.siteid = t7.siteid",
|
|
|
- "suppno","suppname","suppshortname");
|
|
|
+ "depno", "depname");
|
|
|
+ if (billtypes.contains("其他入库")) {
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_supplier", "t7", "t1.sa_supplierid=t7.sa_supplierid and t1.siteid = t7.siteid",
|
|
|
+ "suppno", "suppname", "suppshortname");
|
|
|
+ }
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "st_stock", "t8", "t1.stockid=t8.stockid and t1.siteid = t8.siteid",
|
|
|
"stockname");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "st_dbstockbill", "t9", "t1.sourceid=t9.st_dbstockbillid and t1.siteid = t9.siteid and t1.sourceobject='st_dbstockbill'");
|
|
|
- querySQL.addQueryFields("recname", "t4.name");
|
|
|
- querySQL.addQueryFields("recphonenumber", "t4.phonenumber");
|
|
|
- querySQL.addQueryFields("recaddress", "t4.address");
|
|
|
- querySQL.addQueryFields("dbbillno", "t9.billno");
|
|
|
-
|
|
|
+ if (billtypes.contains("其他入库") || billtypes.contains("其他出库")) {
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "st_dbstockbill", "t9", "t1.sourceid=t9.st_dbstockbillid and t1.siteid = t9.siteid and t1.sourceobject='st_dbstockbill'");
|
|
|
+ querySQL.addQueryFields("dbbillno", "t9.billno");
|
|
|
+ }
|
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
|
+ querySQL.setWhere("t1.type", billtypes);
|
|
|
querySQL.setWhere(where);
|
|
|
- return querySQL;
|
|
|
+ querySQL.setCondition("t1.billno", "t1.outplace", "t3.agentnum", " t2.enterprisename", "t6.depname");
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+ Rows rows = querySQL.query();
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -328,91 +289,92 @@ public class stockbill extends Controller {
|
|
|
return batchDeleteErr.getReturnObject().toString();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@API(title = "审核", apiversion = R.ID20230719154103.v1.class)
|
|
|
- @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class,restcontroller.sale.stockbill.stockbill.class})
|
|
|
+ @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class, restcontroller.sale.stockbill.stockbill.class})
|
|
|
public String check() throws YosException {
|
|
|
Long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
- Stockbill.check(this,st_stockbillid,true);
|
|
|
+ Stockbill.check(this, st_stockbillid, true);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
@API(title = "反审核", apiversion = R.ID20230719154203.v1.class)
|
|
|
- @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class,stockbill.class,restcontroller.sale.stockbill.stockbill.class})
|
|
|
+ @CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class, Order.class, OrderItems.class, stockbill.class, restcontroller.sale.stockbill.stockbill.class})
|
|
|
public String uncheck() throws YosException {
|
|
|
Long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
- Stockbill.check(this,st_stockbillid,false);
|
|
|
+ Stockbill.check(this, st_stockbillid, false);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
@API(title = "生成送修单", apiversion = R.ID2025070415073603.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {sendrepair.class, sendrepair_pj.class})
|
|
|
public String sendrepair() throws YosException {
|
|
|
- JSONArray st_stockbillids =content.getJSONArray("st_stockbillids");
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill","st_stockbillid","status","type","typemx","remarks","sys_enterpriseid","isrepair");
|
|
|
+ JSONArray st_stockbillids = content.getJSONArray("st_stockbillids");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "st_stockbill", "st_stockbillid", "status", "type", "typemx", "remarks", "sys_enterpriseid", "isrepair");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.st_stockbillid",st_stockbillids.toJavaList(Long.class));
|
|
|
+ querySQL.setWhere("t1.st_stockbillid", st_stockbillids.toJavaList(Long.class));
|
|
|
Rows rows = querySQL.query();
|
|
|
|
|
|
- QuerySQL querySQLDetail = SQLFactory.createQuerySQL(this, "st_stockbill_items","*");
|
|
|
+ QuerySQL querySQLDetail = SQLFactory.createQuerySQL(this, "st_stockbill_items", "*");
|
|
|
querySQLDetail.setTableAlias("t1");
|
|
|
- querySQLDetail.addJoinTable(JOINTYPE.left, "sa_aftersalesmag_items", "t2", "t1.sourceobject ='sa_aftersalesmag_items' and t1.sourceid=t2.sa_aftersalesmag_itemsid AND t1.siteid = t2.siteid","name","phonenumber","address","stockdate","enddate","remarks","duty","demand","reason");
|
|
|
- querySQLDetail.addQueryFields("sku","t2.machinecode");
|
|
|
+ querySQLDetail.addJoinTable(JOINTYPE.left, "sa_aftersalesmag_items", "t2", "t1.sourceobject ='sa_aftersalesmag_items' and t1.sourceid=t2.sa_aftersalesmag_itemsid AND t1.siteid = t2.siteid", "name", "phonenumber", "address", "stockdate", "enddate", "remarks", "duty", "demand", "reason");
|
|
|
+ querySQLDetail.addQueryFields("sku", "t2.machinecode");
|
|
|
|
|
|
querySQLDetail.setSiteid(siteid);
|
|
|
- querySQLDetail.setWhere("t1.st_stockbillid",st_stockbillids.toJavaList(Long.class));
|
|
|
+ querySQLDetail.setWhere("t1.st_stockbillid", st_stockbillids.toJavaList(Long.class));
|
|
|
|
|
|
RowsMap rowsMapDetail = querySQLDetail.query().toRowsMap("st_stockbillid");
|
|
|
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- for(Row row:rows){
|
|
|
- if(!row.getString("type").equals("返修入库")){
|
|
|
+ for (Row row : rows) {
|
|
|
+ if (!row.getString("type").equals("返修入库")) {
|
|
|
return getErrReturnObject().setErrMsg("非返修入库单无法生成送修单").toString();
|
|
|
}
|
|
|
- if(row.getBoolean("isrepair")){
|
|
|
+ if (row.getBoolean("isrepair")) {
|
|
|
return getErrReturnObject().setErrMsg("已生成送修单,无法再次生成").toString();
|
|
|
}
|
|
|
- if(!row.getString("type").equals("返修入库")){
|
|
|
+ if (!row.getString("type").equals("返修入库")) {
|
|
|
return getErrReturnObject().setErrMsg("非返修入库单无法生成送修单").toString();
|
|
|
}
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_sendrepair");
|
|
|
- long sa_sendrepairid = createTableID("sa_sendrepair");
|
|
|
+ long sa_sendrepairid = createTableID("sa_sendrepair");
|
|
|
insertSQL.setUniqueid(sa_sendrepairid);
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
insertSQL.setValue("billno", createBillCode("sendrepair"));
|
|
|
insertSQL.setValue("remarks", row.getString("remarks"));
|
|
|
- insertSQL.setValue("sys_enterpriseid",row.getLong("sys_enterpriseid"));
|
|
|
+ insertSQL.setValue("sys_enterpriseid", row.getLong("sys_enterpriseid"));
|
|
|
insertSQL.setValue("sourcetable", "st_stockbill");
|
|
|
insertSQL.setValue("sourceid", row.getLong("st_stockbillid"));
|
|
|
insertSQL.setValue("status", "新建");
|
|
|
- insertSQL.setValue("createby",username);
|
|
|
+ insertSQL.setValue("createby", username);
|
|
|
insertSQL.setDateValue("createdate");
|
|
|
insertSQL.setDateValue("billdate");
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
|
|
|
- for(Row rowdetail :rowsMapDetail.get(row.getString("st_stockbillid"))){
|
|
|
+ for (Row rowdetail : rowsMapDetail.get(row.getString("st_stockbillid"))) {
|
|
|
insertSQL = SQLFactory.createInsertSQL(this, "sa_sendrepair_detail");
|
|
|
- long sa_sendrepair_detailid = createTableID("sa_sendrepair_detail");
|
|
|
+ long sa_sendrepair_detailid = createTableID("sa_sendrepair_detail");
|
|
|
insertSQL.setUniqueid(sa_sendrepair_detailid);
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("sa_sendrepairid",sa_sendrepairid);
|
|
|
+ insertSQL.setValue("sa_sendrepairid", sa_sendrepairid);
|
|
|
insertSQL.setValue("name", rowdetail.getString("name"));
|
|
|
- insertSQL.setValue("phonenumber",rowdetail.getString("phonenumber"));
|
|
|
- insertSQL.setValue("address",rowdetail.getString("address"));
|
|
|
- insertSQL.setValue("stockdate",StringUtils.isBlank(rowdetail.getString("stockdate"))?"null":rowdetail.getString("stockdate"));
|
|
|
- insertSQL.setValue("enddate",StringUtils.isBlank(rowdetail.getString("enddate"))?"null":rowdetail.getString("enddate"));
|
|
|
- insertSQL.setValue("remarks",rowdetail.getString("remarks"));
|
|
|
- insertSQL.setValue("duty",rowdetail.getString("duty"));
|
|
|
- insertSQL.setValue("demand",rowdetail.getString("demand"));
|
|
|
- insertSQL.setValue("reason",rowdetail.getString("reason"));
|
|
|
- insertSQL.setValue("qty",rowdetail.getBigDecimal("qty"));
|
|
|
- insertSQL.setValue("sku",rowdetail.getString("sku"));
|
|
|
- insertSQL.setValue("itemid",rowdetail.getString("itemid"));
|
|
|
+ insertSQL.setValue("phonenumber", rowdetail.getString("phonenumber"));
|
|
|
+ insertSQL.setValue("address", rowdetail.getString("address"));
|
|
|
+ insertSQL.setValue("stockdate", StringUtils.isBlank(rowdetail.getString("stockdate")) ? "null" : rowdetail.getString("stockdate"));
|
|
|
+ insertSQL.setValue("enddate", StringUtils.isBlank(rowdetail.getString("enddate")) ? "null" : rowdetail.getString("enddate"));
|
|
|
+ insertSQL.setValue("remarks", rowdetail.getString("remarks"));
|
|
|
+ insertSQL.setValue("duty", rowdetail.getString("duty"));
|
|
|
+ insertSQL.setValue("demand", rowdetail.getString("demand"));
|
|
|
+ insertSQL.setValue("reason", rowdetail.getString("reason"));
|
|
|
+ insertSQL.setValue("qty", rowdetail.getBigDecimal("qty"));
|
|
|
+ insertSQL.setValue("sku", rowdetail.getString("sku"));
|
|
|
+ insertSQL.setValue("itemid", rowdetail.getString("itemid"));
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
- sqlList.add("update st_stockbill_items set isrepair=1 where st_stockbill_itemsid="+rowdetail.getLong("st_stockbill_itemsid"));
|
|
|
+ sqlList.add("update st_stockbill_items set isrepair=1 where st_stockbill_itemsid=" + rowdetail.getLong("st_stockbill_itemsid"));
|
|
|
|
|
|
}
|
|
|
- sqlList.add("update st_stockbill set isrepair=1 where st_stockbillid="+row.getLong("st_stockbillid"));
|
|
|
+ sqlList.add("update st_stockbill set isrepair=1 where st_stockbillid=" + row.getLong("st_stockbillid"));
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
@@ -420,7 +382,7 @@ public class stockbill extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String xsckcheck(Long st_stockbillid,boolean isinstock) throws YosException {
|
|
|
+ public String xsckcheck(Long st_stockbillid, boolean isinstock) throws YosException {
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and siteid='" + siteid + "'");
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.*,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.st_stockbillid ='"
|
|
|
@@ -434,27 +396,27 @@ public class stockbill extends Controller {
|
|
|
return "单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非新建状态,无法审核";
|
|
|
}
|
|
|
}
|
|
|
- for(Row row : rowsdetail){
|
|
|
- if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO)<1) {
|
|
|
+ for (Row row : rowsdetail) {
|
|
|
+ if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO) < 1) {
|
|
|
return "表体数量不能小于0";
|
|
|
}
|
|
|
}
|
|
|
- if (rows.get(0).getBigDecimal("payamount").compareTo(BigDecimal.ZERO)<=0) {
|
|
|
+ if (rows.get(0).getBigDecimal("payamount").compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
return "扣款金额需大于0";
|
|
|
}
|
|
|
if (StringUtils.isBlank(rows.get(0).getString("outplace"))) {
|
|
|
return "发货地不可为空";
|
|
|
}
|
|
|
- if ((rows.get(0).getBigDecimal("payamount").add(rows.get(0).getBigDecimal("paydiscountamount"))).compareTo(rowsdetail.sum("amount"))!=0) {
|
|
|
+ if ((rows.get(0).getBigDecimal("payamount").add(rows.get(0).getBigDecimal("paydiscountamount"))).compareTo(rowsdetail.sum("amount")) != 0) {
|
|
|
return "扣款金额与应扣金额不符,不能审核";
|
|
|
}
|
|
|
- Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
+ Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
if (accountbalancerows.isNotEmpty()) {
|
|
|
BigDecimal discountamount = accountbalancerows.get(0).getBigDecimal("discountamount");
|
|
|
- if (rows.get(0).getBigDecimal("paydiscountamount").compareTo(discountamount)>0) {
|
|
|
+ if (rows.get(0).getBigDecimal("paydiscountamount").compareTo(discountamount) > 0) {
|
|
|
return "优惠金额不能大于可用优惠金额";
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return "账户不存在";
|
|
|
}
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
@@ -462,30 +424,30 @@ public class stockbill extends Controller {
|
|
|
// RowsMap stockRowsMap =stockRows.toRowsMap("itemid");
|
|
|
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
- if(rows.get(0).getBoolean("rb")){
|
|
|
- if(rows.get(0).getString("type").equals("销售出库")){
|
|
|
+ if (rows.get(0).getBoolean("rb")) {
|
|
|
+ if (rows.get(0).getString("type").equals("销售出库")) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- if (Accountbalance.judgeBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount"))) {
|
|
|
- CashbillEntity entity = getCashbillEntity(rows.get(0).getBigDecimal("payamount"),rows.get(0).getBigDecimal("paydiscountamount"), st_stockbillid, "销售出库单审核", rows.get(0).getString("billno"), "由销售出库单" + rows.get(0).getString("billno") + "审核时生成");
|
|
|
- JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, sys_enterpriseid,accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
+ if (Accountbalance.judgeBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), rowsdetail.sum("amount"))) {
|
|
|
+ CashbillEntity entity = getCashbillEntity(rows.get(0).getBigDecimal("payamount"), rows.get(0).getBigDecimal("paydiscountamount"), st_stockbillid, "销售出库单审核", rows.get(0).getString("billno"), "由销售出库单" + rows.get(0).getString("billno") + "审核时生成");
|
|
|
+ JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
} else {
|
|
|
- return "账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount")) + "元!";
|
|
|
+ return "账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), rowsdetail.sum("amount")) + "元!";
|
|
|
}
|
|
|
}
|
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from st_stockbill_items where st_stockbillid=" + st_stockbillid + ")");
|
|
|
RowsMap rowsMap = rowsOrderDetail.toRowsMap("sa_orderitemsid");
|
|
|
Rows rowsDispatchDetailGroup = dbConnect.runSqlQuery("select sum(t1.qty) qty,t1.sa_orderitemsid,t1.siteid from st_stockbill_items t1 where t1.st_stockbillid=" + st_stockbillid + " group by t1.sa_orderitemsid,t1.siteid");
|
|
|
- Rows rowsjudge =dbConnect.runSqlQuery("select * from (select sa_orderitemsid,sum(qty) qty from st_stockbill_items where st_stockbillid ='"+st_stockbillid+"' group by sa_orderitemsid) t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid where t1.qty>t2.undeliqty");
|
|
|
- if(rowsjudge.isNotEmpty()){
|
|
|
+ Rows rowsjudge = dbConnect.runSqlQuery("select * from (select sa_orderitemsid,sum(qty) qty from st_stockbill_items where st_stockbillid ='" + st_stockbillid + "' group by sa_orderitemsid) t1 inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid where t1.qty>t2.undeliqty");
|
|
|
+ if (rowsjudge.isNotEmpty()) {
|
|
|
return "存在商品已完全出库,无法审核";
|
|
|
}
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").subtract(row.getBigDecimal("qty")) + ",deliedqty=" + (row.getBigDecimal("qty").add(rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
- for(Row row :rowsdetail){
|
|
|
- if(row.getBoolean("skucontrol")){
|
|
|
- sqlList.add("update st_stockbill_items set wmsuploadflag2=1 where st_stockbill_itemsid="+row.getLong("st_stockbill_itemsid"));
|
|
|
+ for (Row row : rowsdetail) {
|
|
|
+ if (row.getBoolean("skucontrol")) {
|
|
|
+ sqlList.add("update st_stockbill_items set wmsuploadflag2=1 where st_stockbill_itemsid=" + row.getLong("st_stockbill_itemsid"));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -502,7 +464,7 @@ public class stockbill extends Controller {
|
|
|
// }
|
|
|
// // String batchno = row.getString("batchno");
|
|
|
// }
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// for(Row row :rowsdetail){
|
|
|
// String itemid= row.getString("itemid");
|
|
|
// long stockid=row.getLong("stockid");
|
|
|
@@ -520,7 +482,7 @@ public class stockbill extends Controller {
|
|
|
// Rows orderRows =dbConnect.runSqlQuery("select * from sa_order where sa_orderid in(select t2.sa_orderid from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.st_stockbillid='"+st_stockbillid+"')");
|
|
|
// RowsMap orderRowsMap =orderRows.toRowsMap("sa_orderid");
|
|
|
|
|
|
- sqlList.addAll(updateAccountbalance_freez(st_stockbillid,isinstock));
|
|
|
+ sqlList.addAll(updateAccountbalance_freez(st_stockbillid, isinstock));
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
// Accountbalance.remindSend(this, sys_enterpriseid, sa_cashbillid);
|
|
|
@@ -528,7 +490,7 @@ public class stockbill extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public String unxsckcheck(Long st_stockbillid,boolean isinstock) throws YosException {
|
|
|
+ public String unxsckcheck(Long st_stockbillid, boolean isinstock) throws YosException {
|
|
|
|
|
|
|
|
|
Rows rows = dbConnect.runSqlQuery("select * from st_stockbill where st_stockbillid ='"
|
|
|
@@ -544,24 +506,24 @@ public class stockbill extends Controller {
|
|
|
return "单号为:【" + rows.get(0).getString("billno") + "】的出入库单为非审核状态,无法反审核";
|
|
|
}
|
|
|
}
|
|
|
- for(Row row : rowsdetail){
|
|
|
- if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO)<1) {
|
|
|
+ for (Row row : rowsdetail) {
|
|
|
+ if (row.getBigDecimal("qty").compareTo(BigDecimal.ZERO) < 1) {
|
|
|
return "表体数量不能小于0";
|
|
|
}
|
|
|
}
|
|
|
- if (rows.get(0).getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO)<0) {
|
|
|
+ if (rows.get(0).getBigDecimal("paydiscountamount").compareTo(BigDecimal.ZERO) < 0) {
|
|
|
return "优惠金额不能小于0";
|
|
|
}
|
|
|
- if (rows.get(0).getBigDecimal("payamount").compareTo(BigDecimal.ZERO)<=0) {
|
|
|
+ if (rows.get(0).getBigDecimal("payamount").compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
return "扣款金额需大于0";
|
|
|
}
|
|
|
if (StringUtils.isBlank(rows.get(0).getString("outplace"))) {
|
|
|
return "发货地不可为空";
|
|
|
}
|
|
|
- if ((rows.get(0).getBigDecimal("payamount").add(rows.get(0).getBigDecimal("paydiscountamount"))).compareTo(rowsdetail.sum("amount"))!=0) {
|
|
|
+ if ((rows.get(0).getBigDecimal("payamount").add(rows.get(0).getBigDecimal("paydiscountamount"))).compareTo(rowsdetail.sum("amount")) != 0) {
|
|
|
return "扣款金额与应扣金额不符,不能反审核";
|
|
|
}
|
|
|
- Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid="+sys_enterpriseid);
|
|
|
+ Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance t1 inner join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t2.accountname='现金账户' and t1.sys_enterpriseid=" + sys_enterpriseid);
|
|
|
if (accountbalancerows.isEmpty()) {
|
|
|
return "账户不存在";
|
|
|
}
|
|
|
@@ -573,15 +535,15 @@ public class stockbill extends Controller {
|
|
|
// RowsMap stockRowsMap =stockRows.toRowsMap("itemid");
|
|
|
|
|
|
String order_paymentnode = Parameter.getString(siteid, "order_paymentnode");
|
|
|
- if(rows.get(0).getBoolean("rb")){
|
|
|
- if(rows.get(0).getString("type").equals("销售出库")){
|
|
|
+ if (rows.get(0).getBoolean("rb")) {
|
|
|
+ if (rows.get(0).getString("type").equals("销售出库")) {
|
|
|
if (order_paymentnode.equals("3")) {
|
|
|
- if (Accountbalance.judgeBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount").negate())) {
|
|
|
- CashbillEntity entity = getCashbillEntity(rows.get(0).getBigDecimal("payamount").negate(),rows.get(0).getBigDecimal("paydiscountamount").negate(), st_stockbillid, "销售出库单反审核", rows.get(0).getString("billno"), "由销售出库单" + rows.get(0).getString("billno") + "反审核时生成");
|
|
|
- JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, sys_enterpriseid,accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
+ if (Accountbalance.judgeBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), rowsdetail.sum("amount").negate())) {
|
|
|
+ CashbillEntity entity = getCashbillEntity(rows.get(0).getBigDecimal("payamount").negate(), rows.get(0).getBigDecimal("paydiscountamount").negate(), st_stockbillid, "销售出库单反审核", rows.get(0).getString("billno"), "由销售出库单" + rows.get(0).getString("billno") + "反审核时生成");
|
|
|
+ JSONObject createCashbillPay = Accountbalance.createCashbillPay(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), entity, true);
|
|
|
sqlList.addAll(createCashbillPay.getJSONArray("sqlList").toJavaList(String.class));
|
|
|
} else {
|
|
|
- return "账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"),rowsdetail.sum("amount")) + "元!";
|
|
|
+ return "账户余额不足,还差" + Accountbalance.InsufficientBalance(this, sys_enterpriseid, accountbalancerows.get(0).getLong("sa_accountclassid"), rowsdetail.sum("amount")) + "元!";
|
|
|
}
|
|
|
}
|
|
|
Rows rowsOrderDetail = dbConnect.runSqlQuery("select t1.undeliqty,t1.deliedqty,t1.qty,t1.sa_orderitemsid from sa_orderitems t1 where t1.sa_orderitemsid in (select sa_orderitemsid from st_stockbill_items where st_stockbillid=" + st_stockbillid + ")");
|
|
|
@@ -590,9 +552,9 @@ public class stockbill extends Controller {
|
|
|
for (Row row : rowsDispatchDetailGroup) {
|
|
|
sqlList.add("update sa_orderitems set undeliqty=" + rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("undeliqty").add(row.getBigDecimal("qty")) + ",deliedqty=" + (rowsMap.get(row.getLong("sa_orderitemsid")).get(0).getBigDecimal("deliedqty").subtract(row.getBigDecimal("qty"))) + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
- for(Row row :rowsdetail){
|
|
|
- if(row.getBoolean("skucontrol")){
|
|
|
- sqlList.add("update st_stockbill_items set wmsuploadflag2=0 where st_stockbill_itemsid="+row.getLong("st_stockbill_itemsid"));
|
|
|
+ for (Row row : rowsdetail) {
|
|
|
+ if (row.getBoolean("skucontrol")) {
|
|
|
+ sqlList.add("update st_stockbill_items set wmsuploadflag2=0 where st_stockbill_itemsid=" + row.getLong("st_stockbill_itemsid"));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -609,7 +571,7 @@ public class stockbill extends Controller {
|
|
|
// }
|
|
|
// // String batchno = row.getString("batchno");
|
|
|
// }
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// for(Row row :rowsdetail){
|
|
|
// String itemid= row.getString("itemid");
|
|
|
// long stockid=row.getLong("stockid");
|
|
|
@@ -626,7 +588,7 @@ public class stockbill extends Controller {
|
|
|
// Rows stockbillitems = dbConnect.runSqlQuery("select t2.sa_orderid,sum(t2.price*t1.qty) amount from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.siteid='"+siteid+"'and t1.st_stockbillid="+st_stockbillid+" group by t2.sa_orderid");
|
|
|
// Rows orderRows =dbConnect.runSqlQuery("select * from sa_order where sa_orderid in(select t2.sa_orderid from st_stockbill_items t1 inner join sa_orderitems t2 on t1.siteid=t2.siteid and t1.sa_orderitemsid=t2.sa_orderitemsid where t1.st_stockbillid='"+st_stockbillid+"')");
|
|
|
// RowsMap orderRowsMap =orderRows.toRowsMap("sa_orderid");
|
|
|
- sqlList.addAll(updateAccountbalance_freez(st_stockbillid,isinstock));
|
|
|
+ sqlList.addAll(updateAccountbalance_freez(st_stockbillid, isinstock));
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
// Accountbalance.remindSend(this, sys_enterpriseid, sa_cashbillid);
|
|
|
@@ -661,25 +623,25 @@ public class stockbill extends Controller {
|
|
|
@API(title = "红冲", apiversion = R.ID2025072409344603.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {stockbill.class, stockbillitems.class})
|
|
|
public String hongc() throws YosException {
|
|
|
- long st_stockbillid=content.getLong("st_stockbillid");
|
|
|
+ long st_stockbillid = content.getLong("st_stockbillid");
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
Rows rows = dbConnect.runSqlQuery("select t1.*,ifnull(t2.sa_sendrepairid,0) sa_sendrepairid from st_stockbill t1 left join sa_sendrepair t2 on t1.st_stockbillid=t2.sourceid and t1.siteid=t2.siteid and t2.sourcetable='st_stockbill' where t1.st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
|
Rows rowsdetail = dbConnect.runSqlQuery("select t1.*,t2.skucontrol from st_stockbill_items t1 left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.st_stockbillid ='"
|
|
|
+ st_stockbillid + "' and t1.siteid='" + siteid + "'");
|
|
|
- if(rows.isEmpty()){
|
|
|
+ if (rows.isEmpty()) {
|
|
|
return getErrReturnObject().setErrMsg("该出入库单不存在")
|
|
|
.toString();
|
|
|
}
|
|
|
- if(!rows.get(0).getString("status").equals("审核")){
|
|
|
+ if (!rows.get(0).getString("status").equals("审核")) {
|
|
|
return getErrReturnObject().setErrMsg("非审核的出入库单无法红冲")
|
|
|
.toString();
|
|
|
}
|
|
|
- if(rows.get(0).getInteger("rb")==0){
|
|
|
+ if (rows.get(0).getInteger("rb") == 0) {
|
|
|
return getErrReturnObject().setErrMsg("只能红冲蓝字出入库单")
|
|
|
.toString();
|
|
|
}
|
|
|
- if(rows.get(0).getInteger("sa_sendrepairid")!=0){
|
|
|
+ if (rows.get(0).getInteger("sa_sendrepairid") != 0) {
|
|
|
return getErrReturnObject().setErrMsg("来源于送修单的出库单不能红冲")
|
|
|
.toString();
|
|
|
}
|
|
|
@@ -699,16 +661,16 @@ public class stockbill extends Controller {
|
|
|
insertSQL.setValue("remarks", rows.get(0).getString("remarks"));
|
|
|
insertSQL.setValue("billdate", getDateTime_Str());
|
|
|
insertSQL.setValue("billno", createBillCode("stockbill"));
|
|
|
- insertSQL.setValue("outplace", rows.get(0).getString("outplace"));
|
|
|
- insertSQL.setValue("delivery", rows.get(0).getString("delivery"));
|
|
|
- insertSQL.setValue("invoice_enterprisename", rows.get(0).getString("invoice_enterprisename"));
|
|
|
- insertSQL.setValue("invoice_address", rows.get(0).getString("invoice_address"));
|
|
|
- insertSQL.setValue("invoice_taxno", rows.get(0).getString("invoice_taxno"));
|
|
|
- insertSQL.setValue("tracknumber", rows.get(0).getString("tracknumber"));
|
|
|
- insertSQL.setValue("isconfirm", rows.get(0).getString("isconfirm"));
|
|
|
+ insertSQL.setValue("outplace", rows.get(0).getString("outplace"));
|
|
|
+ insertSQL.setValue("delivery", rows.get(0).getString("delivery"));
|
|
|
+ insertSQL.setValue("invoice_enterprisename", rows.get(0).getString("invoice_enterprisename"));
|
|
|
+ insertSQL.setValue("invoice_address", rows.get(0).getString("invoice_address"));
|
|
|
+ insertSQL.setValue("invoice_taxno", rows.get(0).getString("invoice_taxno"));
|
|
|
+ insertSQL.setValue("tracknumber", rows.get(0).getString("tracknumber"));
|
|
|
+ insertSQL.setValue("isconfirm", rows.get(0).getString("isconfirm"));
|
|
|
|
|
|
- insertSQL.setValue("sourceobject", "st_stockbill");
|
|
|
- insertSQL.setValue("sourceid", rows.get(0).getLong("st_stockbillid"));
|
|
|
+ insertSQL.setValue("sourceobject", "st_stockbill");
|
|
|
+ insertSQL.setValue("sourceid", rows.get(0).getLong("st_stockbillid"));
|
|
|
|
|
|
insertSQL.setValue("period", rows.get(0).getString("period"));
|
|
|
|
|
|
@@ -722,11 +684,11 @@ public class stockbill extends Controller {
|
|
|
sqlList.add(insertSQL.getSQL());
|
|
|
|
|
|
int i = 0;
|
|
|
- for(Row row : rowsdetail){
|
|
|
- InsertSQL insertDetailSQL= SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
+ for (Row row : rowsdetail) {
|
|
|
+ InsertSQL insertDetailSQL = SQLFactory.createInsertSQL(this, "st_stockbill_items");
|
|
|
insertDetailSQL.setUniqueid(createTableID("st_stockbill_items"));
|
|
|
insertDetailSQL.setSiteid(siteid);
|
|
|
- insertDetailSQL.setValue("rowno", i + 1);
|
|
|
+ insertDetailSQL.setValue("rowno", i + 1);
|
|
|
insertDetailSQL.setValue("st_stockbillid", st_stockbillid);
|
|
|
insertDetailSQL.setValue("sa_orderitemsid", row.getLong("sa_orderitemsid"));
|
|
|
insertDetailSQL.setValue("itemid", row.getString("itemid"));
|
|
|
@@ -743,8 +705,8 @@ public class stockbill extends Controller {
|
|
|
insertDetailSQL.setValue("price", row.getBigDecimal("price"));
|
|
|
insertDetailSQL.setValue("stockid", row.getString("stockid"));
|
|
|
insertDetailSQL.setValue("amount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price")));
|
|
|
- insertDetailSQL.setValue("untaxedprice", row.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP));
|
|
|
- insertDetailSQL.setValue("untaxedamount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price").divide(new BigDecimal(1.13),2, BigDecimal.ROUND_HALF_UP)));
|
|
|
+ insertDetailSQL.setValue("untaxedprice", row.getBigDecimal("price").divide(new BigDecimal(1.13), 2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ insertDetailSQL.setValue("untaxedamount", row.getBigDecimal("qty").multiply(row.getBigDecimal("price").divide(new BigDecimal(1.13), 2, BigDecimal.ROUND_HALF_UP)));
|
|
|
|
|
|
insertDetailSQL.setValue("sourceid", row.getLong("st_stockbill_itemsid"));
|
|
|
insertDetailSQL.setValue("sourceobject", "st_stockbill_items");
|
|
|
@@ -779,7 +741,7 @@ public class stockbill extends Controller {
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
|
|
|
- public CashbillEntity getCashbillEntity(BigDecimal amount,BigDecimal discountamount, Long ownerid, String source, String sourcenotes, String remarks) throws YosException {
|
|
|
+ public CashbillEntity getCashbillEntity(BigDecimal amount, BigDecimal discountamount, Long ownerid, String source, String sourcenotes, String remarks) throws YosException {
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
entity.setAmount(amount);
|
|
|
entity.setDiscountamountamount(discountamount);
|
|
|
@@ -793,13 +755,12 @@ public class stockbill extends Controller {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param type
|
|
|
* @param rb
|
|
|
* @param fischeck
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean isinstock(String type,String rb,boolean fischeck){
|
|
|
+ public boolean isinstock(String type, String rb, boolean fischeck) {
|
|
|
if (type.equals("其他出库") || type.equals("销售出库")
|
|
|
|| type.equals("生产领料出库") || type.equals("委外领料出库")
|
|
|
|| type.equals("返修出库")) {
|
|
|
@@ -904,18 +865,19 @@ public class stockbill extends Controller {
|
|
|
|
|
|
/**
|
|
|
* 账户余额冻结
|
|
|
+ *
|
|
|
* @param addorsub
|
|
|
*/
|
|
|
- public ArrayList<String> updateAccountbalance_freez(long st_stockbillid,boolean addorsub) throws YosException {
|
|
|
- ArrayList<String> sqllist= new ArrayList<>();
|
|
|
+ public ArrayList<String> updateAccountbalance_freez(long st_stockbillid, boolean addorsub) throws YosException {
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
/******** 冻结数据 ********/
|
|
|
Rows rows = dbConnect.runSqlQuery("select t4.sa_accountbalanceid,t3.sa_orderid,t3.sonum,ROUND(sum(t1.qty*t2.price*ifnull(t2.pricerate,1)*ifnull(t2.rwpricerate,1)), 2) amount from st_stockbill_items t1 \n" +
|
|
|
" inner join sa_orderitems t2 on t1.sa_orderitemsid=t2.sa_orderitemsid and t1.siteid=t2.siteid\n" +
|
|
|
" inner join sa_order t3 on t2.sa_orderid=t3.sa_orderid and t2.siteid=t3.siteid\n" +
|
|
|
"\t\t\t\t\t\t\t\t\tleft join sa_accountbalance t4 on t4.sa_accountclassid=t3.sa_accountclassid and t4.sys_enterpriseid=t3.sys_enterpriseid and t4.siteid=t3.siteid\n" +
|
|
|
- " where t1.st_stockbillid="+st_stockbillid+" group by t4.sa_accountbalanceid,t3.sa_orderid,t3.sonum");
|
|
|
+ " where t1.st_stockbillid=" + st_stockbillid + " group by t4.sa_accountbalanceid,t3.sa_orderid,t3.sonum");
|
|
|
if (addorsub) {
|
|
|
- for(Row row :rows) {
|
|
|
+ for (Row row : rows) {
|
|
|
String sonum = row.getString("sonum");
|
|
|
long sa_orderid = row.getLong("sa_orderid");
|
|
|
long sa_accountbalanceid = row.getLong("sa_accountbalanceid");
|
|
|
@@ -942,14 +904,14 @@ public class stockbill extends Controller {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- for(Row row : rows){
|
|
|
+ for (Row row : rows) {
|
|
|
long sa_orderid = row.getLong("sa_orderid");
|
|
|
long sa_accountbalanceid = row.getLong("sa_accountbalanceid");
|
|
|
BigDecimal amount = row.getBigDecimal("amount");
|
|
|
Rows accountbalancefreezrows = dbConnect.runSqlQuery("select sa_accountbalance_freezid,amount from sa_accountbalance_freez where sourceid=" + sa_orderid + " and sourcetable='sa_order' and siteid='" + siteid + "'");
|
|
|
if (accountbalancefreezrows.size() > 0) {
|
|
|
- sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-"+amount+" where sa_accountbalanceid="+sa_accountbalanceid);
|
|
|
- sqllist.add("update sa_accountbalance_freez set amount=amount-"+amount+" where sa_accountbalance_freezid="+accountbalancefreezrows.get(0).getLong("sa_accountbalance_freezid"));
|
|
|
+ sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-" + amount + " where sa_accountbalanceid=" + sa_accountbalanceid);
|
|
|
+ sqllist.add("update sa_accountbalance_freez set amount=amount-" + amount + " where sa_accountbalance_freezid=" + accountbalancefreezrows.get(0).getLong("sa_accountbalance_freezid"));
|
|
|
}
|
|
|
}
|
|
|
}
|