LG88888888 3 năm trước cách đây
mục cha
commit
7fb33e8654

+ 10 - 3
src/main/java/net/chenlin/dp/modules/api/controller/CustomerController.java

@@ -1,5 +1,7 @@
 package net.chenlin.dp.modules.api.controller;
 
+import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
 import net.chenlin.dp.common.support.orm.db.DynamicDataSource;
 import net.chenlin.dp.common.utils.SpringContextUtils;
@@ -7,9 +9,11 @@ import net.chenlin.dp.modules.api.dao.CustomerMapper;
 import net.chenlin.dp.modules.api.service.CustomerService;
 import net.chenlin.dp.modules.api.vo.ICustomer;
 import net.chenlin.dp.modules.api.vo.ICustomerEdit;
+import net.chenlin.dp.modules.api.vo.YonyouSaleOrder;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 public class CustomerController {
     private CustomerService customerService=new CustomerService();
@@ -22,13 +26,16 @@ public class CustomerController {
     public void addCustomer() throws OpenAPIException {
         customerService.getToaccount();
         try {
-            List<ICustomer> iCustomers = customerService.CrmCustomer();
+            List<Map<String,Object>> iCustomers = customerService.CrmCustomer();
             if (iCustomers!=null &&iCustomers.size()>0){
-                for (ICustomer i:iCustomers){
+                for (Map<String,Object> i:iCustomers){
                     String s = customerService.addCustomer(i);
                     if (s.equals("0")){
+                        Object customer = i.get("customer");
+                        ObjectMapper objectMapper = new ObjectMapper();
+                        ICustomer zfsp = objectMapper.convertValue(customer, ICustomer.class);
                         DynamicDataSource.setDataSource("last-data-source");
-                        customerMapper.UpdateCustomer(i.getCode());
+                        customerMapper.UpdateCustomer(zfsp.getCode());
                         DynamicDataSource.setDataSource("");
                     }
                 }

+ 19 - 14
src/main/java/net/chenlin/dp/modules/api/service/CustomerService.java

@@ -11,10 +11,7 @@ import net.chenlin.dp.modules.api.dao.AcceptOrderMapper;
 import net.chenlin.dp.modules.api.dao.CustomerMapper;
 import net.chenlin.dp.modules.api.vo.*;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
 
 /**
  * 客户接口
@@ -33,12 +30,10 @@ public class CustomerService {
      * @param customer
      * @throws OpenAPIException
      */
-    public String addCustomer(ICustomer customer) throws OpenAPIException {
-            Map<String,Object>map=new HashMap<>();
-            map.put("customer",customer);
-            String s = JSONObject.toJSONString(map);
+    public String addCustomer(Map<String,Object>ms) throws OpenAPIException {
+        String s1 = JSONObject.toJSONString(ms);
             try {
-                JSONObject add = customerService.add(s, getToaccount);
+                JSONObject add = customerService.add(s1, getToaccount);
                 HashMap hashMap = JSONObject.parseObject(add.toString(), HashMap.class);
                 Object tradeid = hashMap.get("tradeid");
                 if (!tradeid.equals("")&&tradeid!=null){
@@ -49,6 +44,7 @@ public class CustomerService {
                     return "";
                 }
             }catch (Exception e){
+
                 throw new OpenAPIException(e.getMessage(), e);
             }
 
@@ -110,23 +106,32 @@ public class CustomerService {
         }
     }
 
-    public List<ICustomer>CrmCustomer(){
+    public List<Map<String,Object>>CrmCustomer(){
         DynamicDataSource.setDataSource("last-data-source");
         List<ICustomer> iCustomers = customerMapper.ICustomerList();
+        List<Map<String,Object>> list=new ArrayList<>();
         if (iCustomers!=null &&iCustomers.size()>0) {
             for (ICustomer i : iCustomers) {
                 List<CustomerBanks> bank = customerMapper.bank(i.getCode());
                 CustomerAddress addr = customerMapper.addr(i.getCode());
+                Map<String,Object>map=new HashMap<>();
+                Map<String,Object>maps=new HashMap<>();
+                map.put("code",i.getCode());
+                map.put("name",i.getName());
+                map.put("abbrname",i.getAbbrname());
+                map.put("sort_code",i.getSort_code());
+                map.put("devliver_site",i.getDevliver_site());
                 if (bank!=null&&bank.size()>0){
-                    i.setBanks(bank);
+                    map.put("banks",bank);
                 }if (addr!=null){
-                    i.setAddresses(addr);
+                    map.put("addresses",addr);
                 }
-
+                maps.put("customer",map);
+                list.add(maps);
             }
         }
             DynamicDataSource.setDataSource("");
-            return iCustomers;
+            return list;
     }
 
     /**

+ 4 - 4
src/main/java/net/chenlin/dp/modules/api/service/PayrequestService.java

@@ -285,7 +285,7 @@ public class PayrequestService extends BaseService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc8 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc8.setName("存货数量");
                 if (s.getIapplyamt_s()!=null&&!s.getIapplyamt_s().equals("0E-10")){
-                    fc8.setValue(new BigDecimal(s.getIapplyamt_s()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc8.setValue(new BigDecimal(s.getIapplyamt_s()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc8.setValue("0");
                 }
@@ -293,7 +293,7 @@ public class PayrequestService extends BaseService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc9 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc9.setName("单价");
                 if (s.getInattaxprice()!=null&&!s.getInattaxprice().equals("0E-10")){
-                    fc9.setValue(new BigDecimal(s.getInattaxprice()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc9.setValue(new BigDecimal(s.getInattaxprice()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc9.setValue("0");
                 }
@@ -302,7 +302,7 @@ public class PayrequestService extends BaseService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc10= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc10.setName("金额");
                 if (s.getIapplyamt()!=null&&!s.getIapplyamt().equals("0E-10")){
-                    fc10.setValue(new BigDecimal(s.getIapplyamt()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc10.setValue(new BigDecimal(s.getIapplyamt()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                     BigDecimal b=new BigDecimal(s.getIapplyamt());
                     BigDecimal add = a.add(b);
                     a=add;
@@ -314,7 +314,7 @@ public class PayrequestService extends BaseService {
             }
             OapiProcessinstanceCreateRequest.FormComponentValueVo fc5 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
             fc5.setName("申请金额");
-            fc5.setValue(a.setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+            fc5.setValue(a.setScale(2,BigDecimal.ROUND_HALF_UP).toString());
 //                fc5.setValue(so.getPersonname());
             formComponentValueVoList.add(fc5);
 

+ 7 - 7
src/main/java/net/chenlin/dp/modules/api/service/PurchaseOrderService.java

@@ -256,7 +256,7 @@ public class PurchaseOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fo = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fo.setName("数量");
                 if (s.getQuantity()!=null&&!s.getQuantity().equals("0E-10")){
-                    fo.setValue(new BigDecimal(s.getQuantity()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fo.setValue(new BigDecimal(s.getQuantity()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fo.setValue("0");
                 }
@@ -265,7 +265,7 @@ public class PurchaseOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc7 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc7.setName("含税单价");
                 if (s.getTaxprice()!=null&&!s.getTaxprice().equals("0E-10")){
-                    fc7.setValue(new BigDecimal(s.getTaxprice()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc7.setValue(new BigDecimal(s.getTaxprice()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc7.setValue("0");
                 }
@@ -274,7 +274,7 @@ public class PurchaseOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc8 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc8.setName("无税单价");
                 if (s.getPrice()!=null&&!s.getPrice().equals("0E-10")){
-                    fc8.setValue(new BigDecimal(s.getPrice()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc8.setValue(new BigDecimal(s.getPrice()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc8.setValue("0");
                 }
@@ -292,7 +292,7 @@ public class PurchaseOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc10= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc10.setName("无税金额");
                 if (s.getMoney()!=null&&!s.getMoney().equals("0E-10")){
-                    fc10.setValue(new BigDecimal(s.getMoney()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc10.setValue(new BigDecimal(s.getMoney()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc10.setValue("0");
                 }
@@ -304,7 +304,7 @@ public class PurchaseOrderService {
                     BigDecimal sum=new BigDecimal(s.getSum());
                     BigDecimal money=new BigDecimal(s.getMoney());
                     BigDecimal subtract = sum.subtract(money);
-                    fc11.setValue(subtract.setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc11.setValue(subtract.setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc11.setValue("0");
                 }
@@ -315,7 +315,7 @@ public class PurchaseOrderService {
                 fc12.setName("价税合计");
                 if (s.getSum()!=null&&!s.getSum().equals("0E-10")){
                     countSum=countSum.add(new BigDecimal(s.getSum()));
-                    fc12.setValue(new BigDecimal(s.getSum()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc12.setValue(new BigDecimal(s.getSum()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc12.setValue("0");
                 }
@@ -342,7 +342,7 @@ public class PurchaseOrderService {
             }
             OapiProcessinstanceCreateRequest.FormComponentValueVo pso = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
             pso.setName("总金额");
-            pso.setValue(countSum.setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+            pso.setValue(countSum.setScale(2,BigDecimal.ROUND_HALF_UP).toString());
             formComponentValueVoList.add(pso);
 
 

+ 3 - 3
src/main/java/net/chenlin/dp/modules/api/service/SaleOrderService.java

@@ -524,7 +524,7 @@ public class SaleOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc7 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc7.setName("单价(含税)");
                 if(s.getTaxunitprice()!=null&&!s.getTaxunitprice().equals("0E-10")){
-                    fc7.setValue(new BigDecimal(s.getTaxunitprice()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc7.setValue(new BigDecimal(s.getTaxunitprice()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc7.setValue("0");
                 }
@@ -533,7 +533,7 @@ public class SaleOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc8 = new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc8.setName("订购数量");
                 if(s.getQuantity()!=null&&!s.getQuantity().equals("")){
-                    fc8.setValue(new BigDecimal(s.getQuantity()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc8.setValue(new BigDecimal(s.getQuantity()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc8.setValue("0");
                 }
@@ -543,7 +543,7 @@ public class SaleOrderService {
                 OapiProcessinstanceCreateRequest.FormComponentValueVo fc12= new OapiProcessinstanceCreateRequest.FormComponentValueVo();
                 fc12.setName("总金额(含税)");
                 if(s.getSum()!=null&&!s.getSum().equals("0E-10")){
-                    fc12.setValue(new BigDecimal(s.getSum()).setScale(4,BigDecimal.ROUND_HALF_UP).toString());
+                    fc12.setValue(new BigDecimal(s.getSum()).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                 }else {
                     fc12.setValue("0");
                 }