|
|
@@ -17,10 +17,12 @@ import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
import common.annotation.CACHEING;
|
|
|
import common.annotation.CACHEING_CLEAN;
|
|
|
-import common.data.Row;
|
|
|
-import common.data.Rows;
|
|
|
-import common.data.RowsMap;
|
|
|
-import common.data.SQLFactory;
|
|
|
+import common.data.*;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.DataFormat;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import restcontroller.R;
|
|
|
import restcontroller.webmanage.sale.aftersalesmag.twriteoffbill_orderchange;
|
|
|
import restcontroller.webmanage.sale.rebate.Rebate;
|
|
|
@@ -63,27 +65,27 @@ public class OrderItems extends Controller {
|
|
|
|
|
|
String type = orderRows.get(0).getString("type");
|
|
|
JSONArray items = content.getJSONArray("items");
|
|
|
- Long sa_promotionid=orderRows.get(0).getLong("sa_promotionid");
|
|
|
+ Long sa_promotionid = orderRows.get(0).getLong("sa_promotionid");
|
|
|
|
|
|
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
//查询erp库存
|
|
|
// Invbal.selectErpInvbal(this, items);
|
|
|
|
|
|
- Rows itemRows =dbConnect.runSqlQuery("select itemid,orderaddqty,orderminqty,itemno from plm_item where siteid='"+siteid+"'");
|
|
|
- RowsMap itemRowsMap= itemRows.toRowsMap("itemid");
|
|
|
+ Rows itemRows = dbConnect.runSqlQuery("select itemid,orderaddqty,orderminqty,itemno from plm_item where siteid='" + siteid + "'");
|
|
|
+ RowsMap itemRowsMap = itemRows.toRowsMap("itemid");
|
|
|
for (Object obj : items) {
|
|
|
JSONObject item = (JSONObject) obj;
|
|
|
Long itemid = item.getLong("itemid");
|
|
|
Long sa_orderitemsid = item.getLong("sa_orderitemsid");
|
|
|
BigDecimal qty = item.getBigDecimalValue("qty");
|
|
|
- if(!type.equals("促销订单")){
|
|
|
- if(itemRowsMap.containsKey(item.getString("itemid"))){
|
|
|
- if(itemRowsMap.get(item.getString("itemid")).isNotEmpty()){
|
|
|
- BigDecimal orderaddqty =itemRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("orderaddqty");
|
|
|
- BigDecimal orderminqty =itemRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("orderminqty");
|
|
|
- if(((qty.subtract(orderminqty)).remainder(orderaddqty)).compareTo(BigDecimal.ZERO)!=0){
|
|
|
- return getErrReturnObject().setErrMsg("品号为"+itemRowsMap.get(item.getString("itemid")).get(0).getString("itemno")+"的商品数量不符合该商品的起订量和增量").toString();
|
|
|
+ if (!type.equals("促销订单")) {
|
|
|
+ if (itemRowsMap.containsKey(item.getString("itemid"))) {
|
|
|
+ if (itemRowsMap.get(item.getString("itemid")).isNotEmpty()) {
|
|
|
+ BigDecimal orderaddqty = itemRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("orderaddqty");
|
|
|
+ BigDecimal orderminqty = itemRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("orderminqty");
|
|
|
+ if (((qty.subtract(orderminqty)).remainder(orderaddqty)).compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("品号为" + itemRowsMap.get(item.getString("itemid")).get(0).getString("itemno") + "的商品数量不符合该商品的起订量和增量").toString();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -91,31 +93,31 @@ public class OrderItems extends Controller {
|
|
|
}
|
|
|
//商品信息
|
|
|
Row itemRow = getItemRow(itemid);
|
|
|
- Rows promotionitems =dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid);
|
|
|
+ Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
|
|
|
RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
|
|
|
- if(type.equals("促销订单")){
|
|
|
- if(promotionitemsRowsMap.containsKey(item.getString("itemid"))){
|
|
|
- if(promotionitemsRowsMap.get(item.getString("itemid")).isNotEmpty()){
|
|
|
- BigDecimal saledqty =promotionitemsRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("saledqty");
|
|
|
- BigDecimal groupqty =promotionitemsRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("groupqty");
|
|
|
- boolean islimit =promotionitemsRowsMap.get(item.getString("itemid")).get(0).getBoolean("islimit");
|
|
|
- if(islimit){
|
|
|
- if(groupqty.compareTo(saledqty.add(qty))<0){
|
|
|
- return getErrReturnObject().setErrMsg(itemRow.getString("itemno")+"商品数量已超过促销活动的限定数量【"+groupqty.subtract(saledqty)+"】,无法新建").toString();
|
|
|
+ if (type.equals("促销订单")) {
|
|
|
+ if (promotionitemsRowsMap.containsKey(item.getString("itemid"))) {
|
|
|
+ if (promotionitemsRowsMap.get(item.getString("itemid")).isNotEmpty()) {
|
|
|
+ BigDecimal saledqty = promotionitemsRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("saledqty");
|
|
|
+ BigDecimal groupqty = promotionitemsRowsMap.get(item.getString("itemid")).get(0).getBigDecimal("groupqty");
|
|
|
+ boolean islimit = promotionitemsRowsMap.get(item.getString("itemid")).get(0).getBoolean("islimit");
|
|
|
+ if (islimit) {
|
|
|
+ if (groupqty.compareTo(saledqty.add(qty)) < 0) {
|
|
|
+ return getErrReturnObject().setErrMsg(itemRow.getString("itemno") + "商品数量已超过促销活动的限定数量【" + groupqty.subtract(saledqty) + "】,无法新建").toString();
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- BigDecimal price1=new BigDecimal(0);
|
|
|
+ BigDecimal price1 = new BigDecimal(0);
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "订单商品明细_新增");
|
|
|
if (sa_orderitemsid <= 0) {
|
|
|
Rows rows = dbConnect.runSqlQuery("SELECT sa_orderitemsid,price from sa_orderitems WHERE siteid='" + siteid + "' and itemid=" + itemid + " and sa_orderid=" + sa_orderid);
|
|
|
if (rows.isEmpty()) {
|
|
|
sa_orderitemsid = createTableID("sa_orderitems");
|
|
|
} else {
|
|
|
- price1=rows.get(0).getBigDecimal("price");
|
|
|
+ price1 = rows.get(0).getBigDecimal("price");
|
|
|
sa_orderitemsid = rows.get(0).getLong("sa_orderitemsid");
|
|
|
sqlFactory = new SQLFactory(this, "订单商品明细_更新");
|
|
|
}
|
|
|
@@ -178,43 +180,43 @@ public class OrderItems extends Controller {
|
|
|
// break;
|
|
|
case "促销订单":
|
|
|
defaultprice = itemPrice.getGraderateprice();
|
|
|
- price= itemPrice.getPromotionPrice(sa_promotionid);
|
|
|
+ price = itemPrice.getPromotionPrice(sa_promotionid);
|
|
|
break;
|
|
|
default:
|
|
|
defaultprice = itemPrice.getGraderateprice();
|
|
|
- price= itemPrice.getGraderateprice();
|
|
|
+ price = itemPrice.getGraderateprice();
|
|
|
}
|
|
|
} else {
|
|
|
price = item.getBigDecimalValue("price");
|
|
|
- if(price.compareTo(price1)!=0){
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单商品【"+itemRow.getString("itemname")+"】由单价:"+price1+"修改为单价:"+price, "订单修改单价").getSQL());
|
|
|
+ if (price.compareTo(price1) != 0) {
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单商品【" + itemRow.getString("itemname") + "】由单价:" + price1 + "修改为单价:" + price, "订单修改单价").getSQL());
|
|
|
}
|
|
|
defaultprice = item.getBigDecimalValue("defaultprice");
|
|
|
// if (!type.equals("特殊订单") && defaultprice.compareTo(rows.get(0).getBigDecimal("defaultprice")) != 0 && defaultprice.compareTo(itemPrice.getContractprice()) < 0) {
|
|
|
// return getErrReturnObject().setErrMsg("调整价格不可小于协议价").toString();
|
|
|
// }
|
|
|
}
|
|
|
- if(type.equals("特殊订单")){
|
|
|
+ if (type.equals("特殊订单")) {
|
|
|
if (item.containsKey("defaultprice")) {
|
|
|
- if(item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO)>0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO)<=0){
|
|
|
+ if (item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO) > 0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
sqlFactory.addParameter("price", item.getBigDecimalValue("price"));
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", price.multiply(qty));
|
|
|
- }else if(item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO)<=0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO)>0){
|
|
|
- sqlFactory.addParameter("price",item.getBigDecimalValue("amount").divide(qty,4));
|
|
|
+ } else if (item.getBigDecimalValue("price").compareTo(BigDecimal.ZERO) <= 0 && item.getBigDecimalValue("amount").compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ sqlFactory.addParameter("price", item.getBigDecimalValue("amount").divide(qty, 4));
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", item.getBigDecimalValue("amount"));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlFactory.addParameter("price", price);
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", price.multiply(qty));
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
sqlFactory.addParameter("price", price);
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", price.multiply(qty));
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
sqlFactory.addParameter("price", price);
|
|
|
//折前金额(元)
|
|
|
sqlFactory.addParameter("amount", price.multiply(qty));
|
|
|
@@ -329,31 +331,31 @@ public class OrderItems extends Controller {
|
|
|
public String freeze() throws YosException {
|
|
|
Long sa_orderid = content.getLong("sa_orderid");
|
|
|
JSONArray sa_orderitemsids = content.getJSONArray("sa_orderitemsids");
|
|
|
- boolean isfreeze=content.getBooleanValue("isfreeze");
|
|
|
- Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid="+sa_orderid+ " and siteid='"+siteid+"'");
|
|
|
- if(!orderRows.isEmpty()){
|
|
|
+ boolean isfreeze = content.getBooleanValue("isfreeze");
|
|
|
+ Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
+ if (!orderRows.isEmpty()) {
|
|
|
|
|
|
- if(!orderRows.get(0).getString("status").equals("审核")){
|
|
|
- if(isfreeze){
|
|
|
+ if (!orderRows.get(0).getString("status").equals("审核")) {
|
|
|
+ if (isfreeze) {
|
|
|
return getErrReturnObject().setErrMsg("非审核状态无法进行冻结").toString();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return getErrReturnObject().setErrMsg("非审核状态无法进行反冻结").toString();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return getErrReturnObject().setErrMsg("该订单不存在").toString();
|
|
|
}
|
|
|
SQLFactory sqlFactory;
|
|
|
- if(isfreeze){
|
|
|
- sqlFactory = new SQLFactory(this, "订单商品明细_冻结");
|
|
|
- }else {
|
|
|
- sqlFactory = new SQLFactory(this, "订单商品明细_反冻结");
|
|
|
+ if (isfreeze) {
|
|
|
+ sqlFactory = new SQLFactory(this, "订单商品明细_冻结");
|
|
|
+ } else {
|
|
|
+ sqlFactory = new SQLFactory(this, "订单商品明细_反冻结");
|
|
|
}
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter_in("sa_orderitemsid", sa_orderitemsids.toArray());
|
|
|
String sql = sqlFactory.getSQL();
|
|
|
- System.out.println(sql);
|
|
|
+ System.out.println(sql);
|
|
|
dbConnect.runSqlUpdate(sql);
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
@@ -362,23 +364,23 @@ public class OrderItems extends Controller {
|
|
|
@CACHEING_CLEAN(apiClass = {Order.class, OrderItems.class, restcontroller.sale.order.Order.class, ToolBill.class})
|
|
|
public String updateOrderItemsDiscountrate() throws YosException {
|
|
|
Long sa_orderid = content.getLong("sa_orderid");
|
|
|
- BigDecimal discountrate =content.getBigDecimal("discountrate");
|
|
|
- Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid="+sa_orderid+ " and siteid='"+siteid+"'");
|
|
|
- if(!orderRows.isEmpty()){
|
|
|
- if(!orderRows.get(0).getString("status").equals("新建")){
|
|
|
+ BigDecimal discountrate = content.getBigDecimal("discountrate");
|
|
|
+ Rows orderRows = dbConnect.runSqlQuery("select * from sa_order where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
+ if (!orderRows.isEmpty()) {
|
|
|
+ if (!orderRows.get(0).getString("status").equals("新建")) {
|
|
|
return getErrReturnObject().setErrMsg("非新建状态无法进行商品行折扣变更").toString();
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return getErrReturnObject().setErrMsg("该订单不存在").toString();
|
|
|
}
|
|
|
|
|
|
- Rows orderItemsRows = dbConnect.runSqlQuery("select * from sa_orderitems where sa_orderid="+sa_orderid+ " and siteid='"+siteid+"'");
|
|
|
- ArrayList<String> sqlList =new ArrayList<>();
|
|
|
- if(!orderItemsRows.isEmpty()){
|
|
|
- for (Row row :orderItemsRows) {
|
|
|
- BigDecimal price =row.getBigDecimal("price").multiply(discountrate);
|
|
|
- BigDecimal amount =row.getBigDecimal("amount").multiply(discountrate);
|
|
|
- sqlList.add("update sa_orderitems set price="+price+",amount="+amount+" where sa_orderitemsid="+row.getLong("sa_orderitemsid"));
|
|
|
+ Rows orderItemsRows = dbConnect.runSqlQuery("select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
+ if (!orderItemsRows.isEmpty()) {
|
|
|
+ for (Row row : orderItemsRows) {
|
|
|
+ BigDecimal price = row.getBigDecimal("price").multiply(discountrate);
|
|
|
+ BigDecimal amount = row.getBigDecimal("amount").multiply(discountrate);
|
|
|
+ sqlList.add("update sa_orderitems set price=" + price + ",amount=" + amount + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
@@ -431,26 +433,26 @@ public class OrderItems extends Controller {
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
|
|
|
- RowsMap rowsMap =rows.toRowsMap("itemno");
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("itemno");
|
|
|
|
|
|
- SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
|
|
|
+ SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
|
|
|
sqlFactory1.addParameter("siteid", siteid);
|
|
|
Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
- RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
|
|
|
+ RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
|
|
|
- ERPDocking erpDocking =new ERPDocking();
|
|
|
- JSONArray jsonArray =new JSONArray();
|
|
|
- if(rows.toJsonArray("itemno").size()!=0){
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (rows.toJsonArray("itemno").size() != 0) {
|
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
|
|
|
- jsonArray=erpDocking.getErpIcinvbalRows(200000, 1,rows.toJsonArray("itemno"));
|
|
|
+ jsonArray = erpDocking.getErpIcinvbalRows(200000, 1, rows.toJsonArray("itemno"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
- for (Object object:jsonArray) {
|
|
|
- JSONObject jsonObject =(JSONObject)object;
|
|
|
- if(rowsMap.containsKey(jsonObject.getString("fitemno"))){
|
|
|
- if(rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()){
|
|
|
+ if (!jsonArray.isEmpty()) {
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) object;
|
|
|
+ if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
|
|
|
+ if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
|
|
|
rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
}
|
|
|
}
|
|
|
@@ -459,13 +461,13 @@ public class OrderItems extends Controller {
|
|
|
//查询附件
|
|
|
RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
|
|
|
for (Row row : rows) {
|
|
|
- if(sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
+ if (sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
row.put("unsoldqty", BigDecimal.ZERO);
|
|
|
}
|
|
|
- if(!row.containsKey("invbalqty")){
|
|
|
- row.put("invbalqty",BigDecimal.ZERO);
|
|
|
+ if (!row.containsKey("invbalqty")) {
|
|
|
+ row.put("invbalqty", BigDecimal.ZERO);
|
|
|
}
|
|
|
row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
row.put("contractprice", 0);
|
|
|
@@ -492,7 +494,7 @@ public class OrderItems extends Controller {
|
|
|
@API(title = "查询订单所有明细列表", apiversion = R.ID20230508111703.v1.class)
|
|
|
public String selectAllList() throws YosException, IOException {
|
|
|
StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
- if(sys_enterpriseid>0) {
|
|
|
+ if (sys_enterpriseid > 0) {
|
|
|
where.append(" and t5.sys_enterpriseid ='").append(sys_enterpriseid).append("' ");
|
|
|
}
|
|
|
if (content.containsKey("where")) {
|
|
|
@@ -526,26 +528,26 @@ public class OrderItems extends Controller {
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
|
|
|
- RowsMap rowsMap =rows.toRowsMap("itemno");
|
|
|
+ RowsMap rowsMap = rows.toRowsMap("itemno");
|
|
|
|
|
|
- SQLFactory sqlFactory1 =new SQLFactory(this,"商品发货数量汇总");
|
|
|
+ SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
|
|
|
sqlFactory1.addParameter("siteid", siteid);
|
|
|
Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
|
|
|
- RowsMap sumQtyRowsMap= sumQtyRows.toRowsMap("itemno");
|
|
|
+ RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
|
|
|
|
|
|
- ERPDocking erpDocking =new ERPDocking();
|
|
|
- JSONArray jsonArray =new JSONArray();
|
|
|
- if(rows.toJsonArray("itemno").size()!=0){
|
|
|
+ ERPDocking erpDocking = new ERPDocking();
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ if (rows.toJsonArray("itemno").size() != 0) {
|
|
|
if (Parameter.get("system.ccerp_dockswitch").equalsIgnoreCase("true")) {
|
|
|
- jsonArray=erpDocking.getErpIcinvbalRows(200000, 1,rows.toJsonArray("itemno"));
|
|
|
+ jsonArray = erpDocking.getErpIcinvbalRows(200000, 1, rows.toJsonArray("itemno"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
- for (Object object:jsonArray) {
|
|
|
- JSONObject jsonObject =(JSONObject)object;
|
|
|
- if(rowsMap.containsKey(jsonObject.getString("fitemno"))){
|
|
|
- if(rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()){
|
|
|
+ if (!jsonArray.isEmpty()) {
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject jsonObject = (JSONObject) object;
|
|
|
+ if (rowsMap.containsKey(jsonObject.getString("fitemno"))) {
|
|
|
+ if (rowsMap.get(jsonObject.getString("fitemno")).isNotEmpty()) {
|
|
|
rowsMap.get(jsonObject.getString("fitemno")).get(0).put("invbalqty", jsonObject.getBigDecimalValue("fqty"));
|
|
|
}
|
|
|
}
|
|
|
@@ -554,29 +556,41 @@ public class OrderItems extends Controller {
|
|
|
//查询附件
|
|
|
RowsMap attinfoRowsMap = getAttachmentUrl("plm_item", ids);
|
|
|
for (Row row : rows) {
|
|
|
- if(sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()){
|
|
|
+ if (sumQtyRowsMap.get(row.getString("itemno")).isNotEmpty()) {
|
|
|
row.put("unsoldqty", sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
row.put("unsoldqty", BigDecimal.ZERO);
|
|
|
}
|
|
|
- if(!row.containsKey("invbalqty")){
|
|
|
- row.put("invbalqty",BigDecimal.ZERO);
|
|
|
+ if (!row.containsKey("invbalqty")) {
|
|
|
+ row.put("invbalqty", BigDecimal.ZERO);
|
|
|
}
|
|
|
row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
row.put("contractprice", 0);
|
|
|
}
|
|
|
|
|
|
if (isExport) {
|
|
|
- //去除不需要导出项
|
|
|
- String[] removeFieldList = {"sa_orderitemsid", "itemid", "sa_orderid", "candispatchqty", "cansaleqty",
|
|
|
- "totalaty", "orderminqty_auxunit", "orderminqty", "orderaddqty_auxunit", "orderaddqty",
|
|
|
- "spec", "delivery", "erpitemno", "erpitemname", "material", "standards", "stockstatus"};
|
|
|
- for (String key : removeFieldList) {
|
|
|
- rows.getFieldList().remove(key);
|
|
|
- }
|
|
|
+ ExcelFactory excelFactory = new ExcelFactory("订单明细查询");
|
|
|
|
|
|
- Rows uploadRows = uploadExcelToObs("order", "订单商品明细_所有列表", rows, getTitleMap());
|
|
|
- return getSucReturnObject().setData(uploadRows).toString();
|
|
|
+ XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
|
|
|
+ XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
|
|
|
+
|
|
|
+ CellStyle style = xssfFWorkbook.createCellStyle();
|
|
|
+ // 设置为文本格式,防止身份证号变成科学计数法
|
|
|
+ DataFormat format = xssfFWorkbook.createDataFormat();
|
|
|
+ style.setDataFormat(format.getFormat("@"));
|
|
|
+ // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
|
|
|
+ sheet.setDefaultColumnStyle(0, style);
|
|
|
+ ExportDown.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
|
|
|
+ XSSFCellStyle titleCellStyle2 = ExportDown.createTitleCellStyle2(xssfFWorkbook);
|
|
|
+ XSSFCellStyle titleCellStyle3 = ExportDown.createBodyCellStyle(xssfFWorkbook);
|
|
|
+ ExportDown.batchDetail(sheet, titleCellStyle2, titleCellStyle3, rows);// 写入标题
|
|
|
+
|
|
|
+ Rows uploadRows = uploadExcelToObs(excelFactory);
|
|
|
+ String url = "";
|
|
|
+ if (!uploadRows.isEmpty()) {
|
|
|
+ url = uploadRows.get(0).getString("url");
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(url).toString();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -657,7 +671,7 @@ public class OrderItems extends Controller {
|
|
|
case "特殊订单":
|
|
|
sqlFactory = new SQLFactory(this, "查询可添加商品列表_特殊订单", pageSize, pageNumber, pageSorting);
|
|
|
sqlFactory.addParameter("tradefield", tradefield);
|
|
|
- if(sys_enterpriseid1>0){
|
|
|
+ if (sys_enterpriseid1 > 0) {
|
|
|
where.append(" and t1.isonsale ='1' ");
|
|
|
}
|
|
|
break;
|
|
|
@@ -692,9 +706,9 @@ public class OrderItems extends Controller {
|
|
|
row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
row.put("brand", brandRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
- if( itemPriceRowsMap.containsKey(row.getLong("itemid"))){
|
|
|
+ if (itemPriceRowsMap.containsKey(row.getLong("itemid"))) {
|
|
|
row.put("price", itemPriceRowsMap.get(row.getLong("itemid")).getPrice());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
row.put("price", 0);
|
|
|
}
|
|
|
|