zengtx преди 3 години
родител
ревизия
0905bf48e2

+ 3 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/MOMainController.java

@@ -94,7 +94,7 @@ public class MOMainController implements ApplicationContextAware {
                             "ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone',mo.cPersonCode as 'headerAttributeString10',hr.cPsn_Num as 'headerAttributeString9'," +
                             "hr1.cPsn_Name as 'salerCode',mo.cMaker as 'customerContacts','采购业务实体名称' as poBusinessUnitCode," +
                             "'' as 'customerContactsPhone','0.00' as 'totalAmount','0.00' as 'exTaxAmount', curr.cexch_code as 'currencyCode'," +
-                            "mo.iTaxRate as 'headerTaxRate',mo.dDate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark'," +
+                            "mo.iTaxRate as 'headerTaxRate',mo.dDate as 'customerDemandDate', mo.cMemo as 'remark'," +
                             "'' as 'sourceDocNum',mo.cMaker as 'buyerCode',mo.dCreateTime  as 'publishDate',0 as 'tenantId'," +
                             "0 as 'totalAmount','' as 'headerAttributeString1', mo.cCode as 'headerAttributeString2','' as 'headerAttributeString3'," +
                             "'' as 'headerAttributeString4'  from OM_MOMain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
@@ -120,7 +120,7 @@ public class MOMainController implements ApplicationContextAware {
                             "ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone',mo.cPersonCode as 'headerAttributeString10',hr.cPsn_Num as 'headerAttributeString9'," +
                             "hr1.cPsn_Name as 'salerCode',mo.cMaker as 'customerContacts','采购业务实体名称' as poBusinessUnitCode," +
                             "'' as 'customerContactsPhone','0.00' as 'totalAmount','0.00' as 'exTaxAmount', curr.cexch_code as 'currencyCode'," +
-                            "mo.iTaxRate as 'headerTaxRate',mo.dDate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark'," +
+                            "mo.iTaxRate as 'headerTaxRate',mo.dDate as 'customerDemandDate', mo.cMemo as 'remark'," +
                             "'' as 'sourceDocNum',mo.cMaker as 'buyerCode',mo.dCreateTime  as 'publishDate',0 as 'tenantId'," +
                             "0 as 'totalAmount','' as 'headerAttributeString1', mo.cCode as 'headerAttributeString2','' as 'headerAttributeString3'," +
                             "'' as 'headerAttributeString4'  from OM_MOMain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
@@ -142,7 +142,7 @@ public class MOMainController implements ApplicationContextAware {
                             "ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone',mo.cPersonCode as 'headerAttributeString10',hr.cPsn_Num as 'headerAttributeString9'," +
                             "hr1.cPsn_Name as 'salerCode',mo.cMaker as 'customerContacts','采购业务实体名称' as poBusinessUnitCode," +
                             "'' as 'customerContactsPhone','0.00' as 'totalAmount','0.00' as 'exTaxAmount', curr.cexch_code as 'currencyCode'," +
-                            "mo.iTaxRate as 'headerTaxRate',mo.dDate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark'," +
+                            "mo.iTaxRate as 'headerTaxRate',mo.dDate as 'customerDemandDate', mo.cMemo as 'remark'," +
                             "'' as 'sourceDocNum',mo.cMaker as 'buyerCode',mo.dCreateTime  as 'publishDate',0 as 'tenantId'," +
                             "0 as 'totalAmount','' as 'headerAttributeString1', mo.cCode as 'headerAttributeString2','' as 'headerAttributeString3'," +
                             "'' as 'headerAttributeString4'  from OM_MOMain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +

+ 3 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/POPomainController.java

@@ -88,7 +88,7 @@ public class POPomainController implements ApplicationContextAware {
                             "ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone',mo.cMaker as 'customerContacts'," +
                             "mo.cPOID as headerAttributeString2,'' as 'customerContactsPhone','0.00' as 'totalAmount','0.00' as 'exTotalAmount'," +
                             "'0.00' as 'exTaxAmount', curr.cexch_code as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
-                            "mo.dPODate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
+                            "mo.dPODate as 'customerDemandDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
                             "mo.cMaker as 'buyerCode',hr1.cPsn_Name as salerCode," +
                             " mo.cmaketime  as 'publishDate'  from PO_Pomain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
                             "left join (select cPsn_Num, cPsn_Name from hr_hi_person) hr " +
@@ -109,7 +109,7 @@ public class POPomainController implements ApplicationContextAware {
                             "ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone',mo.cMaker as 'customerContacts'," +
                             "mo.cPOID as headerAttributeString2,'' as 'customerContactsPhone','0.00' as 'totalAmount','0.00' as 'exTotalAmount'," +
                             "'0.00' as 'exTaxAmount', curr.cexch_code as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
-                            "mo.dPODate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
+                            "mo.dPODate as 'customerDemandDate',mo.cMemo as 'remark','' as 'sourceDocNum'," +
                             "mo.cMaker as 'buyerCode',hr1.cPsn_Name as salerCode," +
                             " mo.cmaketime  as 'publishDate'  from PO_Pomain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
                             "left join (select cPsn_Num, cPsn_Name from hr_hi_person) hr " +
@@ -130,7 +130,7 @@ public class POPomainController implements ApplicationContextAware {
                             "ven.cVenPerson as 'supplierContacts',ven.cVenBranchPhone as 'supplierContactsPhone',mo.cMaker as 'customerContacts'," +
                             "mo.cPOID as headerAttributeString2,'' as 'customerContactsPhone','0.00' as 'totalAmount','0.00' as 'exTotalAmount'," +
                             "'0.00' as 'exTaxAmount', curr.cexch_code as 'currencyCode',mo.iTaxRate as 'headerTaxRate'," +
-                            "mo.dPODate as 'customerDemandDate','' as 'supplierPromiseDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
+                            "mo.dPODate as 'customerDemandDate', mo.cMemo as 'remark','' as 'sourceDocNum'," +
                             "mo.cMaker as 'buyerCode',hr1.cPsn_Name as salerCode," +
                             " mo.cmaketime  as 'publishDate'  from PO_Pomain mo left join Vendor ven on mo.cVenCode = ven.cVenCode " +
                             "left join (select cPsn_Num, cPsn_Name from hr_hi_person) hr " +

+ 75 - 43
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/JsonChangeUtils.java

@@ -15,6 +15,7 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -60,23 +61,16 @@ public class JsonChangeUtils implements ApplicationContextAware{
             jf.put("publishDate",publishDate+" 00:00:00");
             //查询子表信息
             if(map.get("pkorg").equals("one")){
-//                String sql = "select MODetailsID as MODetailsID,"+map.get("accId")+" as cAccId,"+map.get("MOID")+" as MOID,'' as cCode," +
-//                        "'N0201001237' as customerItemCode,'门幅120  颜色 为深色' as cInvName,'lineStatus' as lineStatus," +
-//                        "'' as attributeCode1,'' as attributeCode2,'' as attributeCode3,'' as attributeCode4,'' as attributeValue1,'' as attributeValue2," +
-//                        "'' as attributeValue3,'' as attributeValue4," +
-//                        "'materialKeyAttribute' as materialKeyAttribute,iQuantity as customerDemandQty,cUnitID as customerUomCode,'demandDate' as customerDemandDate," +
-//                        "iTaxPrice as customerPrice,(iPerTaxRate/100) as lineTaxRate,iMoney as amount,'12' as lineAttributeString1,'34' as lineAttributeString2," +
-//                        "'56' as lineAttributeString3,'78' as lineAttributeString4,cbMemo as lineAttributeString5 " +
-//                        "from OM_MODetails where MOID = "+map.get("MOID");
-                //mo.cInvCode,inv.cInvName
+                BigDecimal totalAmount = BigDecimal.ZERO; //总金额
+                BigDecimal exTaxAmount = BigDecimal.ZERO;//总无税金额
                 String sql = "select mo.iVouchRowNo as 'poLineNum',mo.MODetailsID as MODetailsID,mo.MODetailsID as 'moDetailId','"+map.get("pkorg")+"' as pkorg," +
                         "'' as receivingInventoryOrgCode,'"+map.get("moId")+"' as MOID,'"+map.get("accId")+"' as 'accId'," +
-                        "'"+map.get("poNum")+"' as poNum,mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName'," +
+                        "'"+map.get("poNum")+"' as poNum,mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName',mo.dArriveDate as 'supplierPromiseDate'," +
                         "'' as 'poLineStatus',mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2',mo.cFree3 as 'attributeValue3'," +
                         "mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2','cfree3'  as 'attributeCode3'," +
                         "'cfree4'  as 'attributeCode4',mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode'," +
-                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
-                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount'," +
+                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.iMoney as 'iMoney'," +
+                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iSum as 'amount'," +
                         "mo.cDefine28 as 'lineAttributeString1',mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3'," +
                         "mo.cDefine30 as 'lineAttributeString4',mo.cbMemo as 'lineAttributeString5',mo.cDefine22 as lineAttributeString6,'' as lineAttributeString7,'' as lineAttributeString8," +
                         "cFree1 as 'color','' as 'customerNumber'," +
@@ -84,19 +78,26 @@ public class JsonChangeUtils implements ApplicationContextAware{
                         "left join Inventory inv  on mo.cInvCode = inv.cInvCode"+
                         " where mo.MOID = "+map.get("moId");
                 List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
+                for(Map<String, Object> mapList:list){
+                    totalAmount = totalAmount.add(new BigDecimal(mapList.get("amount").toString()));
+                    exTaxAmount = exTaxAmount.add(new BigDecimal(mapList.get("iMoney").toString()));
+                }
                 //子表转JSON
                 List<JSONObject> json = toMOListJson(list);
                 jf.put("poLineList",json);
-
+                jf.put("totalAmount",totalAmount);
+                jf.put("exTaxAmount",exTaxAmount);
             }else if(map.get("pkorg").equals("two")){
+                BigDecimal totalAmount = BigDecimal.ZERO; //总金额
+                BigDecimal exTaxAmount = BigDecimal.ZERO;//总无税金额
                 String sql = "select mo.iVouchRowNo as 'poLineNum',mo.MODetailsID as MODetailsID,mo.MODetailsID as 'moDetailId','"+map.get("pkorg")+"' as pkorg," +
                         "'' as receivingInventoryOrgCode,'"+map.get("moId")+"' as MOID,'"+map.get("accId")+"' as 'accId'," +
-                        "'"+map.get("poNum")+"' as poNum,mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName'," +
+                        "'"+map.get("poNum")+"' as poNum,mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName',mo.dArriveDate as 'supplierPromiseDate'," +
                         "'' as 'poLineStatus',mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2',mo.cFree3 as 'attributeValue3'," +
                         "mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2','cfree3'  as 'attributeCode3'," +
                         "'cfree4'  as 'attributeCode4',mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode'," +
-                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
-                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount'," +
+                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.iMoney as 'iMoney'," +
+                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iSum as 'amount'," +
                         "mo.cDefine28 as 'lineAttributeString1',mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3'," +
                         "mo.cDefine30 as 'lineAttributeString4',mo.cbMemo as 'lineAttributeString5',mo.cDefine22 as lineAttributeString6,'' as lineAttributeString7,'' as lineAttributeString8," +
                         "cFree1 as 'color','' as 'customerNumber'," +
@@ -104,19 +105,26 @@ public class JsonChangeUtils implements ApplicationContextAware{
                         "left join Inventory inv  on mo.cInvCode = inv.cInvCode"+
                         " where mo.MOID = "+map.get("moId");
                 List<Map<String, Object>> list = senYuDataSourceTwo.queryForList(sql);
+                for(Map<String, Object> mapList:list){
+                    totalAmount = totalAmount.add(new BigDecimal(mapList.get("amount").toString()));
+                    exTaxAmount = exTaxAmount.add(new BigDecimal(mapList.get("iMoney").toString()));
+                }
                 //子表转JSON
                 List<JSONObject> json = toMOListJson(list);
                 jf.put("poLineList",json);
-
+                jf.put("totalAmount",totalAmount);
+                jf.put("exTaxAmount",exTaxAmount);
             }else if(map.get("pkorg").equals("three")){
+                BigDecimal totalAmount = BigDecimal.ZERO; //总金额
+                BigDecimal exTaxAmount = BigDecimal.ZERO;//总无税金额
                 String sql = "select mo.iVouchRowNo as 'poLineNum',mo.MODetailsID as MODetailsID,mo.MODetailsID as 'moDetailId','"+map.get("pkorg")+"' as pkorg," +
                         "'' as receivingInventoryOrgCode,'"+map.get("moId")+"' as MOID,'"+map.get("accId")+"' as 'accId'," +
-                        "'"+map.get("poNum")+"' as poNum,mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName'," +
+                        "'"+map.get("poNum")+"' as poNum,mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName',mo.dArriveDate as 'supplierPromiseDate', " +
                         "'' as 'poLineStatus',mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2',mo.cFree3 as 'attributeValue3'," +
                         "mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2','cfree3'  as 'attributeCode3'," +
                         "'cfree4'  as 'attributeCode4',mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode'," +
-                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
-                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount'," +
+                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.iMoney as 'iMoney'," +
+                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iSum as 'amount'," +
                         "mo.cDefine28 as 'lineAttributeString1',mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3'," +
                         "mo.cDefine30 as 'lineAttributeString4',mo.cbMemo as 'lineAttributeString5',mo.cDefine22 as lineAttributeString6,'' as lineAttributeString7,'' as lineAttributeString8," +
                         "cFree1 as 'color','' as 'customerNumber'," +
@@ -124,10 +132,15 @@ public class JsonChangeUtils implements ApplicationContextAware{
                         "left join Inventory inv  on mo.cInvCode = inv.cInvCode"+
                         " where mo.MOID = "+map.get("moId");
                 List<Map<String, Object>> list = iSenYuDataSourceThree.queryForList(sql);
+                for(Map<String, Object> mapList:list){
+                    totalAmount = totalAmount.add(new BigDecimal(mapList.get("amount").toString()));
+                    exTaxAmount = exTaxAmount.add(new BigDecimal(mapList.get("iMoney").toString()));
+                }
                 //子表转JSON
                 List<JSONObject> json = toMOListJson(list);
                 jf.put("poLineList",json);
-
+                jf.put("totalAmount",totalAmount);
+                jf.put("exTaxAmount",exTaxAmount);
             }
 
 
@@ -147,6 +160,7 @@ public class JsonChangeUtils implements ApplicationContextAware{
     public static List<JSONObject> toPoMainJson(Map<String, Object> result) {
         List<JSONObject> pljf = new ArrayList<JSONObject>();// 表数据json集合
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
+
         JSONObject jf = new JSONObject();
         //for (int i = 0; i < result.size(); i++) {
             Map<String, Object> map = result;//.get(i);
@@ -165,59 +179,78 @@ public class JsonChangeUtils implements ApplicationContextAware{
             jf.put("publishDate",publishDate+" 00:00:00");
             //查询子表信息
             if(map.get("pkorg").equals("one")){
-//                String sql = "select '666' as cAccId,cPOID as cCode,cInvCode,'' as cInvName,'1' as lineStatus,'' as materialKeyAttribute," +
-//                        " iQuantity as purchaseQuantity,cUnitID as cUnitID,'' as demandDate,iTaxPrice as iTaxPrice,iPerTaxRate as iPerTaxRate," +
-//                        "iSum as lineTotalPrice,'' as smallPo,'' as packId,'' as distributionPoint,'' as dyeFactoryCode,cbMemo as cbMemo " +
-//                        "from PO_Podetails  where POID = '"+map.get("POID")+"'";
+                BigDecimal totalAmount = BigDecimal.ZERO; //总金额
+                BigDecimal exTaxAmount = BigDecimal.ZERO;//总无税金额
 
                 String sql ="select '"+map.get("accId")+"' as 'accId',mo.iVouchRowNo as 'poLineNum',ID as 'moDetailId','"+map.get("poNum")+"' as poNum," +
-                        "mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName','' as 'poLineStatus'," +
+                        "mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName','' as 'poLineStatus',mo.dArriveDate as 'supplierPromiseDate'," +
                         "'' as receivingInventoryOrgCode,mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2'," +
                         "mo.cFree3 as 'attributeValue3',mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2'," +
                         "'cfree3'  as 'attributeCode3','cfree4'  as 'attributeCode4',mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode'," +
-                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
-                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount',mo.cDefine28 as 'lineAttributeString1'," +
+                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.iMoney as 'iMoney'," +
+                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iSum as 'amount',mo.cDefine28 as 'lineAttributeString1'," +
                         "mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3','' as 'attributeString1',mo.cDefine30 as 'lineAttributeString4'," +
                         "mo.cbMemo as 'lineAttributeString5',mo.cDefine22 as lineAttributeString6,'' as lineAttributeString7,'' as lineAttributeString8,'' as 'color'," +
                         "'' as 'externalLineNum',0 as 'itemAttrId' from PO_Podetails mo left join Inventory inv on mo.cInvCode = inv.cInvCode"+
                         " where mo.POID = '"+map.get("moId")+"'";
                 List<Map<String, Object>> list = senYuDataSourceOne.queryForList(sql);
+                for(Map<String, Object> mapList:list){
+                    totalAmount = totalAmount.add(new BigDecimal(mapList.get("amount").toString()));
+                    exTaxAmount = exTaxAmount.add(new BigDecimal(mapList.get("iMoney").toString()));
+                }
                 //子表转JSON
                 List<JSONObject> json = toListJson(list);
                 jf.put("poLineList",json);
+                jf.put("totalAmount",totalAmount);
+                jf.put("exTaxAmount",exTaxAmount);
             }else if(map.get("pkorg").equals("two")){
+                BigDecimal totalAmount = BigDecimal.ZERO; //总金额
+                BigDecimal exTaxAmount = BigDecimal.ZERO;//总无税金额
                 String sql ="select '"+map.get("accId")+"' as 'accId',mo.iVouchRowNo as 'poLineNum',ID as 'moDetailId','"+map.get("poNum")+"' as poNum," +
-                        "mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName','' as 'poLineStatus'," +
+                        "mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName','' as 'poLineStatus',mo.dArriveDate as 'supplierPromiseDate'," +
                         "'' as receivingInventoryOrgCode,mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2'," +
                         "mo.cFree3 as 'attributeValue3',mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2'," +
                         "'cfree3'  as 'attributeCode3','cfree4'  as 'attributeCode4',mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode'," +
-                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
-                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount',mo.cDefine28 as 'lineAttributeString1'," +
+                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.iMoney as 'iMoney'," +
+                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iSum as 'amount',mo.cDefine28 as 'lineAttributeString1'," +
                         "mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3','' as 'attributeString1',mo.cDefine30 as 'lineAttributeString4'," +
                         "mo.cbMemo as 'lineAttributeString5',mo.cDefine22 as lineAttributeString6,'' as lineAttributeString7,'' as lineAttributeString8,'' as 'color'," +
                         "'' as 'externalLineNum',0 as 'itemAttrId' from PO_Podetails mo left join Inventory inv on mo.cInvCode = inv.cInvCode"+
                         " where mo.POID = '"+map.get("moId")+"'";
                 List<Map<String, Object>> list = senYuDataSourceTwo.queryForList(sql);
+                for(Map<String, Object> mapList:list){
+                    totalAmount = totalAmount.add(new BigDecimal(mapList.get("amount").toString()));
+                    exTaxAmount = exTaxAmount.add(new BigDecimal(mapList.get("iMoney").toString()));
+                }
                 //子表转JSON
                 List<JSONObject> json = toListJson(list);
                 jf.put("poLineList",json);
-
+                jf.put("totalAmount",totalAmount);
+                jf.put("exTaxAmount",exTaxAmount);
             }else if(map.get("pkorg").equals("three")){
+                BigDecimal totalAmount = BigDecimal.ZERO; //总金额
+                BigDecimal exTaxAmount = BigDecimal.ZERO;//总无税金额
                 String sql ="select '"+map.get("accId")+"' as 'accId',mo.iVouchRowNo as 'poLineNum',ID as 'moDetailId','"+map.get("poNum")+"' as poNum," +
-                        "mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName','' as 'poLineStatus'," +
+                        "mo.cInvCode as 'customerItemCode',inv.cInvName as 'itemName','' as 'poLineStatus',mo.dArriveDate as 'supplierPromiseDate'," +
                         "'' as receivingInventoryOrgCode,mo.cFree1 as 'attributeValue1',mo.cFree2 as 'attributeValue2'," +
                         "mo.cFree3 as 'attributeValue3',mo.cFree4 as 'attributeValue4','cfree1' as 'attributeCode1','cfree2'  as 'attributeCode2'," +
                         "'cfree3'  as 'attributeCode3','cfree4'  as 'attributeCode4',mo.iQuantity as 'customerDemandQty',mo.cUnitID as 'customerUomCode'," +
-                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.dArriveDate as 'customerPromiseDate'," +
-                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iMoney as 'amount',mo.cDefine28 as 'lineAttributeString1'," +
+                        "'"+map.get("customerDemandDate")+"' as 'customerDemandDate',mo.iMoney as 'iMoney'," +
+                        "mo.iTaxPrice as 'customerPrice',(mo.iPerTaxRate/100) as 'lineTaxRate',mo.iSum as 'amount',mo.cDefine28 as 'lineAttributeString1'," +
                         "mo.cDefine32 as 'lineAttributeString2',mo.cDefine29 as 'lineAttributeString3','' as 'attributeString1',mo.cDefine30 as 'lineAttributeString4'," +
                         "mo.cbMemo as 'lineAttributeString5',mo.cDefine22 as lineAttributeString6,'' as lineAttributeString7,'' as lineAttributeString8,'' as 'color'," +
                         "'' as 'externalLineNum',0 as 'itemAttrId' from PO_Podetails mo left join Inventory inv on mo.cInvCode = inv.cInvCode"+
                         " where mo.POID = '"+map.get("moId")+"'";
                 List<Map<String, Object>> list = iSenYuDataSourceThree.queryForList(sql);
+                for(Map<String, Object> mapList:list){
+                    totalAmount = totalAmount.add(new BigDecimal(mapList.get("amount").toString()));
+                    exTaxAmount = exTaxAmount.add(new BigDecimal(mapList.get("iMoney").toString()));
+                }
                 //子表转JSON
                 List<JSONObject> json = toListJson(list);
                 jf.put("poLineList",json);
+                jf.put("totalAmount",totalAmount);
+                jf.put("exTaxAmount",exTaxAmount);
             }
 
             jf.remove("pkorg");
@@ -277,6 +310,7 @@ public class JsonChangeUtils implements ApplicationContextAware{
      */
     public static List<JSONObject> toListJson(List<Map<String, Object>> result) {
         List<JSONObject> pljf = new ArrayList<JSONObject>();// 表数据json集合
+        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
         JSONObject jf = new JSONObject();
         for (int i = 0; i < result.size(); i++) {
             Map<String, Object> map = result.get(i);
@@ -289,6 +323,9 @@ public class JsonChangeUtils implements ApplicationContextAware{
                     jf.put(key, map.get(key));
                 }
             }
+            String supplierPromiseDate = sf.format(map.get("supplierPromiseDate"));
+            jf.put("supplierPromiseDate",supplierPromiseDate+" 00:00:00");
+            jf.remove("iMoney");
             pljf.add(jf);
         }
         return pljf;
@@ -314,16 +351,10 @@ public class JsonChangeUtils implements ApplicationContextAware{
                     jf.put(key, map.get(key));
                 }
             }
-            String customerPromiseDate = sf.format(map.get("customerPromiseDate"));
-            jf.put("customerPromiseDate",customerPromiseDate+" 00:00:00");
+            String supplierPromiseDate = sf.format(map.get("supplierPromiseDate"));
+            jf.put("supplierPromiseDate",supplierPromiseDate+" 00:00:00");
             //查询委外用料子表数据
             if(map.get("pkorg").equals("one")){
-//                String sql = "select '' as poOutsourceNum,''as poNum,'903' as cAccId,"+map.get("MOID")+" as MOID,'YU-02' as customerItemCode,'' as itemAttrId," +
-//                        "'' as attributeCode1,'' as attributeCode2,'' as attributeCode3,'' as attributeCode4,'' as attributeValue1,'' as attributeValue2," +
-//                        "'' as attributeValue3,'' as attributeValue4," +
-//                        "'' as customerUnitID,'' as customerUnit,'' as customerPromiseQty,'' as outsourceAttributeString1,'' as outsourceAttributeString2," +
-//                        "'' as outsourceAttributeString3,'' as iUnitQuantity " +
-//                        " from OM_MOMaterials where MOMaterialsID = "+map.get("MODetailsID");
 
                 String sql1 = "select '"+map.get("accId")+"' as accId,'"+map.get("MOID")+"' as poId,'"+map.get("poNum")+"' as poNum," +
                         "'N0201002142' as 'customerItemCode','' as 'itemAttrId','cfree1' as attributeCode1,'' as customerItemId," +
@@ -367,6 +398,7 @@ public class JsonChangeUtils implements ApplicationContextAware{
                 jf.remove("MODetailsID");
                 jf.remove("MOID");
                 jf.remove("pkorg");
+                jf.remove("iMoney");
                 pljf.add(jf);
         }
         return pljf;