Эх сурвалжийг харах

Merge branch 'master' of ssh://10.10.100.21/source/saas-platform

zhouy 7 жил өмнө
parent
commit
4b2fd4e28e
100 өөрчлөгдсөн 2760 нэмэгдсэн , 719 устгасан
  1. 34 6
      README.md
  2. 4 0
      applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/CommonService.java
  3. 0 9
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/ListReqDTO.java
  4. 18 7
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  5. 2 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/BillCodeSeq.java
  6. 101 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImport.java
  7. 110 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImportDetail.java
  8. 80 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataTemplet.java
  9. 10 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Status.java
  10. 72 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/TempletSet.java
  11. 6 0
      applications/commons/commons-server/pom.xml
  12. 10 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/CommonController.java
  13. 83 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ExcelController.java
  14. 11 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/HomePageController.java
  15. 0 2
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/CommonMapper.java
  16. 10 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportDetailMapper.java
  17. 17 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportMapper.java
  18. 9 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataTempletMapper.java
  19. 4 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/EndProductMapper.java
  20. 2 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/HomePageMapper.java
  21. 2 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/CommonService.java
  22. 14 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/ExcelService.java
  23. 2 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/HomePageService.java
  24. 34 5
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/CommonServiceImpl.java
  25. 6 1
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/EndProductServiceImpl.java
  26. 444 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/ExcelServiceImpl.java
  27. 7 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/HomePageServiceImpl.java
  28. 1 1
      applications/commons/commons-server/src/main/resources/config/application-docker-prod.yml
  29. 12 0
      applications/commons/commons-server/src/main/resources/config/application-docker-test.yml
  30. 9 0
      applications/commons/commons-server/src/main/resources/logback-spring.xml
  31. 4 7
      applications/commons/commons-server/src/main/resources/mapper/CommonMapper.xml
  32. 83 0
      applications/commons/commons-server/src/main/resources/mapper/DataImportDetailMapper.xml
  33. 83 0
      applications/commons/commons-server/src/main/resources/mapper/DataImportMapper.xml
  34. 17 0
      applications/commons/commons-server/src/main/resources/mapper/DataTempletMapper.xml
  35. 9 0
      applications/commons/commons-server/src/main/resources/mapper/EndProductMapper.xml
  36. 25 0
      applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml
  37. 4 0
      applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/CustomerDTO.java
  38. 12 34
      applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendorDTO.java
  39. 3 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Customer.java
  40. 4 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustomerList.java
  41. 12 179
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Vendor.java
  42. 13 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/VendorList.java
  43. 8 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/AddressController.java
  44. 6 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java
  45. 7 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java
  46. 7 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/VendorController.java
  47. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/AddressMapper.java
  48. 5 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java
  49. 2 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerMapper.java
  50. 22 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/DataImportMapper.java
  51. 8 6
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/EmployeeMapper.java
  52. 4 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductMapper.java
  53. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendorMapper.java
  54. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/WarehouseMapper.java
  55. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/AddressService.java
  56. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerService.java
  57. 4 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductService.java
  58. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorService.java
  59. 5 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/AddressServiceImpl.java
  60. 55 32
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java
  61. 8 6
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BomServiceImpl.java
  62. 93 12
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java
  63. 7 4
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/EmployeeServiceImpl.java
  64. 108 10
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java
  65. 78 11
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java
  66. 8 10
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/WarehouseServiceImpl.java
  67. 1 1
      applications/document/document-server/src/main/resources/config/application-docker-prod.yml
  68. 12 0
      applications/document/document-server/src/main/resources/config/application-docker-test.yml
  69. 9 0
      applications/document/document-server/src/main/resources/logback-spring.xml
  70. 14 6
      applications/document/document-server/src/main/resources/mapper/AddressMapper.xml
  71. 14 2
      applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml
  72. 2 0
      applications/document/document-server/src/main/resources/mapper/CustomerListMapper.xml
  73. 25 32
      applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml
  74. 105 0
      applications/document/document-server/src/main/resources/mapper/DataImportMapper.xml
  75. 6 2
      applications/document/document-server/src/main/resources/mapper/EmployeeMapper.xml
  76. 19 0
      applications/document/document-server/src/main/resources/mapper/ProductMapper.xml
  77. 61 58
      applications/document/document-server/src/main/resources/mapper/VendorMapper.xml
  78. 3 0
      applications/document/document-server/src/main/resources/mapper/WarehouseMapper.xml
  79. 20 0
      applications/money/money-dto/src/main/java/com/usoftchina/saas/money/dto/VerificationDTO.java
  80. 29 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/MoneyReportColltroller.java
  81. 14 4
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/VerificationController.java
  82. 5 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/BanksubledgerMapper.java
  83. 12 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/CustmonthMapper.java
  84. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/CustomerCheckViewMapper.java
  85. 12 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VendmonthMapper.java
  86. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VendorAcountViewMapper.java
  87. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VerificationMapper.java
  88. 103 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Custmonth.java
  89. 103 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Vendmonth.java
  90. 20 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Verification.java
  91. 4 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/MoneyReportService.java
  92. 2 2
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/FundtransferServiceImpl.java
  93. 152 59
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/MoneyReportServiceImpl.java
  94. 45 48
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java
  95. 50 53
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthspendingsServiceImpl.java
  96. 8 31
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java
  97. 17 30
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  98. 47 37
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java
  99. 1 1
      applications/money/money-server/src/main/resources/config/application-docker-prod.yml
  100. 12 0
      applications/money/money-server/src/main/resources/config/application-docker-test.yml

+ 34 - 6
README.md

@@ -106,13 +106,15 @@
 | 192.168.0.178 |  root  | select123*** |  CentOS7, Docker  | Cpu: 4, Mem: 8G, Disk: 20G |
 | 192.168.0.179 |  root  | select123*** |  CentOS7, Docker  | Cpu: 4, Mem: 8G, Disk: 20G |
 | 192.168.0.180 |  root  | select123*** |  CentOS7, Docker  | Cpu: 4, Mem: 8G, Disk: 20G |
-| 192.168.0.181 |  root  | select123*** |  CentOS7, Docker  | Cpu: 4, Mem: 8G, Disk: 80G |
+| 192.168.0.181 |  root  | select123*** |  CentOS7, Docker  | Cpu: 8, Mem: 16G, Disk: 80G |
 | 192.168.0.182 |  root  | select123*** |  CentOS7, Redis  | Cpu: 2, Mem: 8G, Disk: 20G |
 | 192.168.0.183 |  root  | select123*** |  CentOS7, Mongo  | Cpu: 4, Mem: 8G, Disk: 50G |
+| 192.168.0.184 |  root  | select123*** |  CentOS7, Docker  | Cpu: 8, Mem: 16G, Disk: 50G |
+| 192.168.0.185 |  root  | select123*** |  CentOS7, Docker  | Cpu: 8, Mem: 16G, Disk: 50G |
 
 > 构建
 
-* [jenkins](http://192.168.0.181:8080/job/saas) **账号** admin **密码** select123***
+* [jenkins](http://192.168.0.181:8080/job/saas/view/dev) **账号** admin **密码** select123***
 
 > 日志
 
@@ -123,11 +125,9 @@
 > 服务
 
 * [eureka http://192.168.0.181:8500](http://192.168.0.181:8500) **账号** admin **密码** select111***
-* [eureka 本地调试 http://192.168.0.181:8510](http://192.168.0.181:8510) **账号** admin **密码** select111***
 * [gateway http://192.168.0.181:8560](http://192.168.0.181:8560)
-* [gateway 本地调试 http://192.168.0.181:8570](http://192.168.0.181:8570)
-* [admin](http://192.168.0.181:8520) **账号** admin **密码** select111***
-* [zipkin](http://192.168.0.181:8540) **账号** admin **密码** select111***
+* [admin http://192.168.0.181:8520](http://192.168.0.181:8520) **账号** admin **密码** select111***
+* [zipkin http://192.168.0.181:8540](http://192.168.0.181:8540) **账号** admin **密码** select111***
 
 > 访问
 
@@ -136,6 +136,34 @@
 * [打印 https://saas-report-dev.usoftchina.com:5443](https://saas-report-dev.usoftchina.com:5443)
 * [接口 https://saas-api-dev.usoftchina.com:5443](https://saas-api-dev.usoftchina.com:5443)
 
+# 本地调试环境
+
+> 服务
+
+* [eureka http://192.168.0.181:8510](http://192.168.0.181:8510) **账号** admin **密码** select111***
+* [gateway http://192.168.0.181:8570](http://192.168.0.181:8570)
+
+
+# 测试环境
+
+> 构建
+
+* [jenkins](http://192.168.0.181:8080/job/saas/view/test) **账号** admin **密码** select123***
+
+> 服务
+
+* [eureka http://192.168.0.181:8515](http://192.168.0.181:8515) **账号** admin **密码** select111***
+* [gateway http://192.168.0.181:8575](http://192.168.0.181:8575)
+* [admin http://192.168.0.181:8535](http://192.168.0.181:8535) **账号** admin **密码** select111***
+* [zipkin http://192.168.0.181:8555](http://192.168.0.181:8555) **账号** admin **密码** select111***
+
+> 访问
+
+* [门户 https://saas-test.usoftchina.com:5443](https://saas-test.usoftchina.com:5443)
+* [系统 https://trade-test.usoftchina.com:5443](https://trade-test.usoftchina.com:5443)
+* [打印 https://saas-report-dev.usoftchina.com:5443](https://saas-report-dev.usoftchina.com:5443)
+* [接口 https://saas-api-test.usoftchina.com:5443](https://saas-api-test.usoftchina.com:5443)
+
 # 生产环境
 
 > 数据库

+ 4 - 0
applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/CommonService.java

@@ -9,4 +9,8 @@ public interface CommonService {
     @PostMapping("/action/audit")
     public String commonAudit(@RequestParam("table") String table, @RequestParam("keyvalue") String keyvalue, @RequestParam("status") String status,
                                       @RequestParam("statuscode") String statuscode, @RequestParam("auditdate") String auditdate, @RequestParam("auditman") String auditman);
+
+    @PostMapping("/action/resAudit")
+    public String commonResAudit(@RequestParam("table") String table, @RequestParam("keyvalue") String keyvalue, @RequestParam("status") String status,
+                              @RequestParam("statuscode") String statuscode, @RequestParam("auditdate") String auditdate, @RequestParam("auditman") String auditman);
 }

+ 0 - 9
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/ListReqDTO.java

@@ -21,15 +21,6 @@ public class ListReqDTO implements Serializable {
 
     private String calculateFields;
 
-    private String ym;
-
-    public String getYm() {
-        return ym;
-    }
-
-    public void setYm(String ym) {
-        this.ym = ym;
-    }
 
     //将列拼成查询语句,直接查询出数据的格式为json
     public String getCalculateFieldsSql() {

+ 18 - 7
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -34,7 +34,12 @@ public enum BizExceptionCode implements BaseExceptionCode {
     BIZ_UNENDPRODUCT(79310,"系统还未结账,不能反结账"),
     BIZ_RELUPDATE_CODEANDNAME(79311,"存在关联单据,不允许更新编号,名称"),
     BIZ_RELUPDATE_AMOUNT(79312,"存在关联单据,不允许更新期初应收,期初预收,期初日期"),
+    BIZ_BANNED(79313, "只能禁用已开启的单据"),
+    BIZ_ENABLE(79314, "只能开启已禁用的单据"),
+
+
     NO_OPRATIONDATA(79400,"无可操作单据"),
+    NULL_DATA(23232,"无数据"),
 
     BOM_SAVE(79401, "产品编号+版本号已存在"),
     REPEAT_NAME(79501, "名称重复"),
@@ -56,7 +61,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     VENDOR_ISCLOSE(79505, "供应商已关闭"),
     PRODUCT_ISCLOSE(79506, "物料已关闭"),
     CUSTOMER_ISCLOSE(79507, "客户资料已关闭"),
-
+    REQUIREDFIELD_NULL(79508,"存在必填字段为空"),
 
     //采购 70000-71999
     PURCCHECKIN_POST_ERROR(70000,""),
@@ -65,20 +70,26 @@ public enum BizExceptionCode implements BaseExceptionCode {
     PURCHASE_ORDER_HASAUDIT(70002, "存在已审核单据,单据编号:%s"),
     PURCHASE_ORDER_HASUNAUDIT(70003, "存在未审核单据,单据编号:%s"),
 
+
+
     //销售
     SALE_ALL_TURNOUT(72000, "该销售单已全部转出货,无法转出货单"),
-    SALE_CLOSE(72001, "单据已关闭,无法进行操作"),
+    SALE_CLOSE(72001, "单据已关闭,无法%s"),
     SALE_YQTYBEYONDQTY(72001, "明细行已转数量大于数量"),
     SALE_NULL_BILL(72002, "单据不存在或者明细为空"),
     SALEOUT_ALL_TURNIN(72003, "该出货单已全部转退货,无法转销售退货单"),
-    SALEOUT_POSTSTATUS_ERROR(72004,"当前单据状态无法进行此操作"),
-    SALEOUT_POST_ERROR(72005,""),
+    SALEOUT_POSTSTATUS_ERROR(72004,"当前单据状态无法进行此操作"),
+    SALEOUT_POST_ERROR(72005,"编号:<u>%s</u>处理失败,%s"),
     SALEOUT_UNAUDIT_ERROR(72006,"销售订单已转出货单,无法反审核"),
     SALE_ORDER_HASAUDIT(72003, "存在已审核单据,单据编号:%s"),
     SALE_EXISTS_PURCHASE(72004, "存在已转的采购单据,单据编号:%s"),
-    SALE_ALREADY_UNAUDIT(72007, "单据状态为未审核,无法反审核"),
+    SALE_ALREADY_UNAUDIT(72007, "反审核失败!该单据非审核状态"),
     SALE_CUST_CLOSE(72008, "客户已关闭,无法审核"),
-
+    SALE_ORDER_ISUNAUDIT(72009, "存在未审核单据,单据编号:%s"),
+    SALE_ORDER_ISCOLSED(72010, "存在已关闭单据,单据编号:%s"),
+    SALE_ORDER_CUSTBANDED(72011, "存在已禁用客户,无法%s,单据编号:"),
+    SALE_CUSTBANDED(72013, "存在已禁用客户,无法%s"),
+    SALE_AUDITED(72014,"审核失败!该单据已审核"),
     //资金
     PAYBALANCE_OUTNOWBALANCE(74001,"本次核销金额不能大于未核销金额"),
     PAYBALANCE_UNIQUESOURCECODE(74002, "保存失败!不能选择重复的源单"),
@@ -93,7 +104,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     DELETE_NOT_EXIS(74008,"删除失败,当前单据不存在!"),
     DOCUMENTS_AUDITED(74009,"存在已审核单据:%S"),
     DOCUMENTS_UNAUDITED(74010,"存在未审核单据:%S"),
-    BANK_AMOUNT_NOTENOUGHS(74011, "资金账不足:%S"),
+    BANK_AMOUNT_NOTENOUGHS(74011, "资金账户余额不足:%S"),
 
     //反结账
     EARLY_USERING(74012, "期初余额被使用,无法反结账"),

+ 2 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/BillCodeSeq.java

@@ -14,6 +14,8 @@ public enum  BillCodeSeq {
 
     VENDOR("供应商资料", "Vendor"),
 
+    BANKINFORMATION("资金账户资料", "Bankinformation"),
+
     WAREHOUSE("仓库资料", "Warehouse"),
 
     PURCHASE("采购订单", "Purchase"),

+ 101 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImport.java

@@ -0,0 +1,101 @@
+package com.usoftchina.saas.commons.po;
+
+import java.util.Date;
+
+/**
+ * @author: guq
+ * @create: 2018-11-29 15:15
+ **/
+public class DataImport {
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    private Integer di_id;
+
+    private String di_caller;
+
+    private Long companyid;
+
+    private Date di_date;
+
+    private Integer di_count;
+
+    private String di_result;
+
+    private Integer di_success;
+
+    private String di_man;
+
+    private Integer di_toformal;
+
+    public Integer getDi_id() {
+        return di_id;
+    }
+
+    public void setDi_id(Integer di_id) {
+        this.di_id = di_id;
+    }
+
+    public String getDi_caller() {
+        return di_caller;
+    }
+
+    public void setDi_caller(String di_caller) {
+        this.di_caller = di_caller == null ? null : di_caller.trim();
+    }
+
+
+
+    public Date getDi_date() {
+        return di_date;
+    }
+
+    public void setDi_date(Date di_date) {
+        this.di_date = di_date;
+    }
+
+    public Integer getDi_count() {
+        return di_count;
+    }
+
+    public void setDi_count(Integer di_count) {
+        this.di_count = di_count;
+    }
+
+    public String getDi_result() {
+        return di_result;
+    }
+
+    public void setDi_result(String di_result) {
+        this.di_result = di_result == null ? null : di_result.trim();
+    }
+
+    public Integer getDi_success() {
+        return di_success;
+    }
+
+    public void setDi_success(Integer di_success) {
+        this.di_success = di_success;
+    }
+
+    public String getDi_man() {
+        return di_man;
+    }
+
+    public void setDi_man(String di_man) {
+        this.di_man = di_man == null ? null : di_man.trim();
+    }
+
+    public Integer getDi_toformal() {
+        return di_toformal;
+    }
+
+    public void setDi_toformal(Integer di_toformal) {
+        this.di_toformal = di_toformal;
+    }
+}

+ 110 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataImportDetail.java

@@ -0,0 +1,110 @@
+package com.usoftchina.saas.commons.po;
+
+/**
+ * @author: guq
+ * @create: 2018-11-29 15:16
+ **/
+public class DataImportDetail {
+
+    private Integer dd_id;
+
+    private String dd_maindata;
+
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    private Integer dd_detno;
+
+    private Integer dd_diid;
+
+    private Integer dd_checked;
+
+    private Integer dd_success;
+
+    private Integer dd_toformal;
+
+    private Long companyid;
+
+    private String dd_detaildata;
+
+    private String dd_codevalue;
+
+    public Integer getDd_id() {
+        return dd_id;
+    }
+
+    public void setDd_id(Integer dd_id) {
+        this.dd_id = dd_id;
+    }
+
+    public String getDd_maindata() {
+        return dd_maindata;
+    }
+
+    public void setDd_maindata(String dd_maindata) {
+        this.dd_maindata = dd_maindata == null ? null : dd_maindata.trim();
+    }
+
+    public Integer getDd_detno() {
+        return dd_detno;
+    }
+
+    public void setDd_detno(Integer dd_detno) {
+        this.dd_detno = dd_detno;
+    }
+
+    public Integer getDd_diid() {
+        return dd_diid;
+    }
+
+    public void setDd_diid(Integer dd_diid) {
+        this.dd_diid = dd_diid;
+    }
+
+    public Integer getDd_checked() {
+        return dd_checked;
+    }
+
+    public void setDd_checked(Integer dd_checked) {
+        this.dd_checked = dd_checked;
+    }
+
+    public Integer getDd_success() {
+        return dd_success;
+    }
+
+    public void setDd_success(Integer dd_success) {
+        this.dd_success = dd_success;
+    }
+
+    public Integer getDd_toformal() {
+        return dd_toformal;
+    }
+
+    public void setDd_toformal(Integer dd_toformal) {
+        this.dd_toformal = dd_toformal;
+    }
+
+
+    public String getDd_detaildata() {
+        return dd_detaildata;
+    }
+
+    public void setDd_detaildata(String dd_detaildata) {
+        this.dd_detaildata = dd_detaildata == null ? null : dd_detaildata.trim();
+    }
+
+    public String getDd_codevalue() {
+        return dd_codevalue;
+    }
+
+    public void setDd_codevalue(String dd_codevalue) {
+        this.dd_codevalue = dd_codevalue == null ? null : dd_codevalue.trim();
+    }
+
+}

+ 80 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/DataTemplet.java

@@ -0,0 +1,80 @@
+package com.usoftchina.saas.commons.po;
+
+/**
+ * @author: guq
+ * @create: 2018-11-27 16:20
+ **/
+public class DataTemplet {
+
+    private Integer dt_id;
+
+    private String dt_caller;
+
+    private String dt_description;
+
+    public String getDt_columns() {
+        return dt_columns;
+    }
+
+    public void setDt_columns(String dt_columns) {
+        this.dt_columns = dt_columns;
+    }
+
+    private String dt_title;
+
+    private String dt_columns;
+
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    private String dt_exampledata;
+
+    private Long companyid;
+
+    public Integer getDt_id() {
+        return dt_id;
+    }
+
+    public void setDt_id(Integer dt_id) {
+        this.dt_id = dt_id;
+    }
+
+    public String getDt_caller() {
+        return dt_caller;
+    }
+
+    public void setDt_caller(String dt_caller) {
+        this.dt_caller = dt_caller == null ? null : dt_caller.trim();
+    }
+
+    public String getDt_description() {
+        return dt_description;
+    }
+
+    public void setDt_description(String dt_description) {
+        this.dt_description = dt_description == null ? null : dt_description.trim();
+    }
+
+    public String getDt_title() {
+        return dt_title;
+    }
+
+    public void setDt_title(String dt_title) {
+        this.dt_title = dt_title == null ? null : dt_title.trim();
+    }
+
+    public String getDt_exampledata() {
+        return dt_exampledata;
+    }
+
+    public void setDt_exampledata(String dt_exampledata) {
+        this.dt_exampledata = dt_exampledata == null ? null : dt_exampledata.trim();
+    }
+
+
+}

+ 10 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Status.java

@@ -17,6 +17,16 @@ public enum Status {
     OPEN("已开启"),
 
 
+    /**
+     * 已禁用
+     */
+    BANNED("已禁用"),
+
+    /**
+     * 已启用
+     */
+    ENABLE("已启用"),
+
     /**
      * 已审核
      */

+ 72 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/TempletSet.java

@@ -0,0 +1,72 @@
+package com.usoftchina.saas.commons.po;
+
+/**
+ * @author: guq
+ * @create: 2018-11-27 20:52
+ **/
+public class TempletSet {
+    private String description;
+    private int width;
+    private String field;
+    private String necessary;
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    private String position;
+    private boolean codefield;
+    private String type;
+
+    public boolean isCodefield() {
+        return codefield;
+    }
+
+    public void setCodefield(boolean codefield) {
+        this.codefield = codefield;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public String getField() {
+        return field;
+    }
+
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    public String getNecessary() {
+        return necessary;
+    }
+
+    public void setNecessary(String necessary) {
+        this.necessary = necessary;
+    }
+
+    public String getPosition() {
+        return position;
+    }
+
+    public void setPosition(String position) {
+        this.position = position;
+    }
+}

+ 6 - 0
applications/commons/commons-server/pom.xml

@@ -65,6 +65,12 @@
             <artifactId>test-starter</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>3.17</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 10 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/CommonController.java

@@ -39,6 +39,16 @@ public class CommonController {
         return deferredResult;
     }
 
+    @PostMapping("/action/resAudit")
+    public DeferredResult commonResAudit(@RequestParam("table") String table, @RequestParam("keyvalue") String keyvalue, @RequestParam("status") String status,
+                                      @RequestParam("statuscode") String statuscode, @RequestParam("auditdate") String auditdate, @RequestParam("auditman") String auditman) {
+
+        DeferredResult<String> deferredResult = new DeferredResult<>();
+        CompletableFuture.supplyAsync(() -> commonService.commonResAudit(table, keyvalue, status, statuscode, auditdate, auditman))
+                .whenCompleteAsync((result, throwable) -> deferredResult.setResult(result));
+        return deferredResult;
+    }
+
     @GetMapping("/timeout/test")
     public void timeout(@RequestParam("time") Long time){
         try {

+ 83 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ExcelController.java

@@ -0,0 +1,83 @@
+package com.usoftchina.saas.commons.controller;
+
+import com.usoftchina.saas.auth.client.annotation.IgnoreAuth;
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.service.ExcelService;
+import com.usoftchina.saas.utils.DateUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.util.Date;
+import java.util.Map;
+
+/**导入模板下载、解析
+ * @author: guq
+ * @create: 2018-11-26 11:43
+ **/
+@RestController
+@RequestMapping("/excel")
+public class ExcelController {
+
+    @Autowired
+    private ExcelService excelService;
+
+    @RequestMapping("/import/templet")
+    public void CreateTemplet(@RequestParam("caller") String caller, HttpServletResponse response) throws IOException {
+        Map<String, Object> map = excelService.CreateTemplet(caller);
+        SXSSFWorkbook workbook = (SXSSFWorkbook)map.get("workbook");
+        String title = map.get("title").toString() + "_" + DateUtils.format(new Date(), "yyyyMMdd");
+        String filename = URLEncoder.encode(title + ".xlsx", "UTF-8");
+        response.setContentType("application/vnd.ms-excel");
+        response.setHeader("Content-Disposition", "attachment;filename=" + filename);
+        OutputStream out;
+        out = response.getOutputStream();
+        workbook.write(out);
+        out.close();
+    }
+
+    @PostMapping(value = "/import/parse", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    public Result ParseTemplet(@RequestParam("caller") String caller, @RequestPart(value = "file") MultipartFile file) throws IOException {
+        InputStream is = null;
+        Workbook wb = null;
+        Integer keyvalue = null;
+        long size = file.getSize();
+        if (size > 104857600) {
+            return Result.error(new String(("{error: '文件过大', size:" + size + "}").getBytes("utf-8"), "iso8859-1"));
+        } else {
+            excelService.clearBefore(caller);
+            String ft = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
+            is = file.getInputStream();
+            if (ft.equals("xlsx")) {
+                wb = new XSSFWorkbook(is);
+            } else if(ft.equals("xls")){
+                wb = new HSSFWorkbook(is);
+            } else {
+                return Result.error(new String("{error: 'excel文件的格式不太规范,导入失败<hr>可以尝试将文件另存为.xls文件,或将数据选择性粘贴到excel模板,然后导入'}".getBytes("utf-8"),
+                        "iso8859-1"));
+            }
+            keyvalue = excelService.parseTemplet(wb, caller);
+        }
+        return Result.success(keyvalue);
+    }
+
+    @RequestMapping(value = "/test")
+    public Result ParseTemplet(String caller) throws IOException {
+        InputStream is = null;
+        Workbook wb = null;
+        File file = new File("C:\\Users\\guh-pc\\Desktop\\import.xlsx");
+        is = new FileInputStream(file);
+        wb = new XSSFWorkbook(is);
+        excelService.parseTemplet(wb, caller);
+        return Result.success();
+    }
+
+}

+ 11 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/HomePageController.java

@@ -93,4 +93,15 @@ public class HomePageController {
         return homePageService.saleFutureData();
     }
 
+    /**
+     * @Description 关键数据
+     * @return: com.usoftchina.saas.base.Result
+     * @Author: guq
+     * @Date: 2018/11/14
+     */
+    @GetMapping("/keyData")
+    public Result keyData() {
+        return homePageService.keyData();
+    }
+
 }

+ 0 - 2
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/CommonMapper.java

@@ -4,8 +4,6 @@ import org.apache.ibatis.annotations.Param;
 
 public interface CommonMapper {
 
-    int getCountBaseSet(@Param("companyId") Long companyId);
-
     int getCountWarehouse(@Param("companyId") Long companyId);
 
     int getCountProduct(@Param("companyId") Long companyId);

+ 10 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportDetailMapper.java

@@ -0,0 +1,10 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.DataImportDetail;
+
+public interface DataImportDetailMapper {
+
+    int insertSelective(DataImportDetail record);
+
+    void deleteByIds(String ids);
+}

+ 17 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataImportMapper.java

@@ -0,0 +1,17 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.DataImport;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface DataImportMapper {
+    void deleteByCaller(@Param("caller") String caller, @Param("companyid") Long companyid);
+    int insertSelective(DataImport record);
+
+    void updateErr(@Param("err") String err, @Param("id") Integer id);
+
+    String selectByCaller(@Param("caller") String caller, @Param("companyId") Long companyId);
+
+    void deleteByIds(String ids);
+}

+ 9 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/DataTempletMapper.java

@@ -0,0 +1,9 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.DataTemplet;
+import org.apache.ibatis.annotations.Param;
+
+public interface DataTempletMapper {
+
+    DataTemplet selectByCaller(@Param("caller") String caller, @Param("companyid") Long companyid);
+}

+ 4 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/EndProductMapper.java

@@ -10,6 +10,8 @@ public interface EndProductMapper {
 
     void endProduct(Map<String, Object> map);
 
+    void end(Map<String, Object> map);
+
     String selectPeriod(@Param("companyId") Long companyId);
 
     String selectUnPeriod(@Param("companyId") Long companyId);
@@ -18,6 +20,8 @@ public interface EndProductMapper {
 
     void updatePeriodStatus(@Param("status") Long status,@Param("period") String period, @Param("companyId") Long companyId);
 
+    void updateRe(@Param("ym") String ym, @Param("companyId") Long companyId);
+
     int checkPay(Long companyId);
     int checkRec(Long companyId);
     void deleteSub(Long companyId);

+ 2 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/HomePageMapper.java

@@ -17,4 +17,6 @@ public interface HomePageMapper {
     String getSaleData(Long componyId);
 
     String getSaleFutureData(Long componyId);
+
+    String getKeyData(Long companyId);
 }

+ 2 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/CommonService.java

@@ -11,4 +11,6 @@ public interface CommonService {
     InitStatusDTO initCheck();
 
     String commonAudit(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman);
+
+    String commonResAudit(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman);
 }

+ 14 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/ExcelService.java

@@ -0,0 +1,14 @@
+package com.usoftchina.saas.commons.service;
+
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+
+import java.util.Map;
+
+public interface ExcelService {
+    Map<String, Object> CreateTemplet(String caller);
+
+    void clearBefore(String caller);
+
+    Integer parseTemplet(Workbook wb, String caller);
+}

+ 2 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/HomePageService.java

@@ -49,4 +49,6 @@ public interface HomePageService {
     Result saleData();
 
     Result saleFutureData();
+
+    Result keyData();
 }

+ 34 - 5
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/CommonServiceImpl.java

@@ -23,10 +23,7 @@ public class CommonServiceImpl implements CommonService {
         InitStatusDTO result = new InitStatusDTO();
         int count = 0;
         Long companyId = BaseContextHolder.getCompanyId();
-        count = commonMapper.getCountBaseSet(companyId);
-        if (count > 0){
-            result.setBaseSet(true);
-        }
+        result.setBaseSet(true);
         count = commonMapper.getCountWarehouse(companyId);
         if (count > 0){
             result.setWarehouse(true);
@@ -61,7 +58,18 @@ public class CommonServiceImpl implements CommonService {
         }
         return "success";
     }
-
+    @Override
+    public String commonResAudit(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        if (StringUtils.isEmpty(table) || StringUtils.isEmpty(keyvalue)) {
+            return null;
+        }
+        String sql = resAuditedSql(table, keyvalue, status, statuscode, auditdate, auditman, companyId);
+        if (null != sql) {
+            commonMapper.commonAudit(sql);
+        }
+        return "success";
+    }
     private String praseSql(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman, Long companyId) {
         String sql = "update " + table + " set ";
         StringBuilder sb = new StringBuilder();
@@ -83,4 +91,25 @@ public class CommonServiceImpl implements CommonService {
         }
         return null;
     }
+    private String resAuditedSql(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman, Long companyId) {
+        String sql = "update " + table + " set ";
+        StringBuilder sb = new StringBuilder();
+        if (!StringUtils.isEmpty(status)) {
+            sb.append(" " + status + " = '" + Status.UNAUDITED.getDisplay() + "',");
+        }
+        if (!StringUtils.isEmpty(statuscode)) {
+            sb.append(" " + statuscode + "='" + Status.UNAUDITED.name() + "',");
+        }
+        if (!StringUtils.isEmpty(auditdate)) {
+            sb.append(" " + auditdate + "= null ,");
+        }
+        if (!StringUtils.isEmpty(auditman)) {
+            sb.append(" " + auditman + "= null ,");
+        }
+        if (sb.length() > 0) {
+            sql =  sql + sb.substring(0, sb.length() - 1) + " where " + keyvalue + " and companyId=" + companyId;
+            return sql;
+        }
+        return null;
+    }
 }

+ 6 - 1
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/EndProductServiceImpl.java

@@ -16,6 +16,7 @@ import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
 import java.util.HashMap;
@@ -55,6 +56,7 @@ public class EndProductServiceImpl implements EndProductService {
         return map;
     }
 
+    @Transactional
     @Override
     public String endAccount() {
         String period = endProductMapper.selectPeriod(BaseContextHolder.getCompanyId());
@@ -63,13 +65,15 @@ public class EndProductServiceImpl implements EndProductService {
         map.put("yearMonth", period);
         map.put("companyId", BaseContextHolder.getCompanyId());
         map.put("result", null);
-        endProductMapper.endProduct(map);
+//        endProductMapper.endProduct(map);
+        endProductMapper.end(map);
         endProductMapper.updatePeriodStatus(99L, period, BaseContextHolder.getCompanyId());
         DocBaseDTO docBaseDTO = generateMsgObj(Long.parseLong(period));
         messageLogService.customizeLog(docBaseDTO, Operation.ENDPRODUCT);
         return String.valueOf(map.get("result"));
     }
 
+    @Transactional
     @Override
     public void unEndAccount() {
         int payc = endProductMapper.checkPay(BaseContextHolder.getCompanyId());
@@ -83,6 +87,7 @@ public class EndProductServiceImpl implements EndProductService {
         if (StringUtils.isEmpty(period)){
             throw new BizException(BizExceptionCode.BIZ_UNENDPRODUCT);
         }else{
+            endProductMapper.updateRe(period, BaseContextHolder.getCompanyId());
             endProductMapper.updatePeriodStatus(0L, period, BaseContextHolder.getCompanyId());
             messageLogService.customizeLog(generateMsgObj(Long.parseLong(period)), Operation.UNENDPRODUCT);
         }

+ 444 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/ExcelServiceImpl.java

@@ -0,0 +1,444 @@
+package com.usoftchina.saas.commons.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.usoftchina.saas.commons.dto.ProductBaseDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.mapper.DataImportDetailMapper;
+import com.usoftchina.saas.commons.mapper.DataImportMapper;
+import com.usoftchina.saas.commons.mapper.DataTempletMapper;
+import com.usoftchina.saas.commons.po.*;
+import com.usoftchina.saas.commons.service.ExcelService;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.utils.CollectionUtils;
+import com.usoftchina.saas.utils.DateUtils;
+import com.usoftchina.saas.utils.StringUtils;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author: guq
+ * @create: 2018-11-26 15:19
+ **/
+@Service
+public class ExcelServiceImpl implements ExcelService{
+
+    @Autowired
+    private DataTempletMapper dataTempletMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
+    @Autowired
+    private DataImportDetailMapper dataImportDetailMapper;
+
+    @Override
+    public Map<String, Object> CreateTemplet(String caller) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        Map<String, Object> map = new HashMap<>();
+        SXSSFWorkbook workbook = new SXSSFWorkbook();
+        DataTemplet dataTemplet = dataTempletMapper.selectByCaller(caller, companyId);
+        if (null == dataTemplet) {
+            throw new BizException(9876, "没有查询到对应的excel配置");
+        }
+        //列
+        String cols = dataTemplet.getDt_columns();
+        JSONArray array = (JSONArray) JSONArray.parse(cols);
+        //模板数据
+        String remark = dataTemplet.getDt_description();
+        String exampledata = dataTemplet.getDt_exampledata();
+        JSONArray datas = (JSONArray) JSONArray.parse(exampledata);
+        createWorkbook(workbook, 1, array, datas, remark);
+        map.put("workbook", workbook);
+        map.put("title", dataTemplet.getDt_title());
+        return map;
+    }
+
+    @Override
+    public void clearBefore(String caller) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        String ids = dataImportMapper.selectByCaller(caller, companyId);
+        if (!StringUtils.isEmpty(ids)) {
+            dataImportDetailMapper.deleteByIds(ids);
+            dataImportMapper.deleteByIds(ids);
+        };
+
+    }
+
+    @Override
+    public Integer parseTemplet(Workbook wb, String caller) {
+        if (wb == null || StringUtils.isEmpty(caller)) {
+            throw new BizException(BizExceptionCode.NULL_DATA);
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        DataImport di = new DataImport();
+        di.setCompanyid(companyId);
+        di.setDi_caller(caller);
+        di.setDi_date(new Date());
+        di.setDi_man(BaseContextHolder.getUserName());
+        di.setDi_toformal(0);
+        di.setDi_success(0);
+        List<Map<String,String>> datas = new ArrayList<Map<String,String>>();
+        DataTemplet dataTemplet = dataTempletMapper.selectByCaller(caller, companyId);
+        String cols = dataTemplet.getDt_columns();
+        if (StringUtils.isEmpty(cols)) {
+            throw new BizException(12135, "没有查询到对应的excel配置");
+        }
+        //前端列表信息
+        List<TempletSet> templetSets = JSONArray.parseArray(cols, TempletSet.class);
+        Map<String, List<TempletSet>> columns = CollectionUtils.groupBy(templetSets, TempletSet::getPosition);
+        List<String> positions = SetToList(columns.keySet());
+        String cellData = null;
+        String codeValue = null;
+        //读取默认从第2行开始读取
+        List<String> keys = new ArrayList<>();
+        //获取第一个sheet
+        Sheet sheet = wb.getSheetAt(0);
+        //获取最大行数
+        int rownum = sheet.getPhysicalNumberOfRows();
+        if (rownum < 3) {
+            throw new BizException(12324, "请先填写数据");
+        }
+        //获取第2行
+        Row row = sheet.getRow(1);
+        //获取最大列数
+        int colnum = row.getPhysicalNumberOfCells();
+        String key = null;
+        //添加keys
+        for (int j = 0;j < colnum; j++){
+            key = (String) getCellFormatValue(row.getCell(j));
+            keys.add(key);
+        }
+        //存储数据
+        for (int i = 2; i < rownum; i++) {
+            Map<String,String> map = new LinkedHashMap<String,String>();
+            row = sheet.getRow(i);
+            if(row !=null){
+                for (int j = 0;j < colnum; j++){
+                    cellData = (String) getCellFormatValue(row.getCell(j));
+                    //检测字段必填与否
+                    map.put(keys.get(j), cellData);
+                }
+            }else{
+                break;
+            }
+            datas.add(map);
+        }
+        dataImportMapper.insertSelective(di);
+        Integer keyvalue = di.getDi_id();
+        //数据转换成字段
+        if (!CollectionUtils.isEmpty(datas)) {
+            StringBuilder err = new StringBuilder();
+            JSONArray mains = new JSONArray();
+            JSONArray details = new JSONArray();
+            //数据行循环
+            for (int i = 0; i < datas.size(); i++) {
+                Map<String,String> data = datas.get(i);
+                DataImportDetail dd = new DataImportDetail();
+                //界面值
+                String value = null;
+                JSONObject mainData = null;
+                JSONObject detailData = null;
+                dd.setCompanyid(companyId);
+                dd.setDd_diid(keyvalue);
+                //主从表循环
+                for (int j = 0; j < positions.size(); j++) {
+                   String position = positions.get(j);
+                    //标识是否一个主表的数据
+                   boolean difference = true;
+                    //依据主从表分类
+                   if ("main".equals(position)) {
+                       List<TempletSet> main = columns.get(position);
+                       for (TempletSet set : main) {
+                           //取excel值
+                           if ("true".equals(set.getNecessary())) {
+                               value = data.get("*" + set.getDescription());
+                           } else {
+                               value = data.get(set.getDescription());
+                           }
+                           //取编号字段
+                           if (set.isCodefield() && !data.get("*" + set.getDescription()).equals("")) {
+                               mainData = new JSONObject();
+                               codeValue = value;
+                               difference = true;
+                           }
+                           //检查是否是同一单
+                           if (set.isCodefield() && data.get("*" + set.getDescription()).equals("")) {
+                               difference = false;
+                               break;
+                           }
+                           //检查主表必填字段是否完整
+                           if (difference) {
+                               dd.setDd_codevalue(codeValue);
+                               if ("true".equals(set.getNecessary()) && data.get("*" + set.getDescription()).equals("")) {
+                                   err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
+                                   break;
+                               }
+                           }
+                           //检测日期类型是否规范
+                           if ("date".equals(set.getType()) && !StringUtils.isEmpty(value)) {
+                               value = praseDate(value);
+                               if (null == value) {
+                                   err.append("第" + (i + 3) + "行 " + set.getDescription() + " 日期格式不正确!<br/> ");
+                                   break;
+                               }
+                           }
+                           //插入主表数据
+                           if (null != mainData) {
+                               mainData.put(set.getField(), value);
+                           }
+                       }
+                       //所有主表数据进行分类
+                       if (null != mainData) {
+                           //mains.add(mainData);
+                           dd.setDd_maindata(mainData.toJSONString());
+                       }
+                   } else {
+                       //从表字段
+                       List<TempletSet> detail = columns.get(position);
+                       detailData = new JSONObject();
+                       for (TempletSet set : detail) {
+                           //取excel值
+                           if ("true".equals(set.getNecessary())) {
+                               value = data.get("*" + set.getDescription());
+                           } else {
+                               value = data.get(set.getDescription());
+                           }
+                           if ("true".equals(set.getNecessary()) && value.equals("")) {
+                               err.append("第" + (i + 3) + "行 " + set.getDescription() + " 必填字段未填写!<br/> ");
+                               break;
+                           }
+                           //检测日期类型是否规范
+                           if ("date".equals(set.getType()) && !StringUtils.isEmpty(value)) {
+                               value = praseDate(value);
+                               if (null == value) {
+                                   err.append("第" + (i + 3) + "行 " + set.getDescription() + " 日期格式不正确!<br/> ");
+                                   break;
+                               }
+                           }
+                           //拼从表数据
+                           detailData.put(set.getField(), value);
+                       }
+                       if (detailData.size() > 0) {
+                           dd.setDd_codevalue(codeValue);
+                           dd.setDd_detaildata(detailData.toJSONString());
+                       }
+                   }
+                }
+                dataImportDetailMapper.insertSelective(dd);
+            }
+            //必填项检查
+            if (err.length() > 0) {
+                dataImportMapper.updateErr(err.toString(), keyvalue);
+                throw new BizException(123456789, err.toString());
+            }
+        }
+        return keyvalue;
+    }
+
+
+
+    private boolean validateDateFormat(String date) {
+        boolean flag = false;
+        if (StringUtils.isEmpty(date)) {
+            return false;
+        }
+        String regEx1 = "[0-9]{4}/[0-9]{2}/[0-9]{2}";
+        String regEX2 = "[0-9]{4}-[0-9]{2}-[0-9]{2}";
+        // 编译正则表达式
+        Pattern pattern1 = Pattern.compile(regEx1);
+        Pattern pattern2 = Pattern.compile(regEX2);
+        Matcher matcher = pattern1.matcher(date);
+        // 字符串是否与正则表达式相匹配
+        flag = matcher.matches();
+        if (!flag) {
+            flag = pattern2.matcher(date).matches();
+        }
+        return flag;
+    }
+
+    private String praseDate(String num) {
+        try {
+            Integer days = Integer.valueOf(num);
+            return DateUtils.plusDay(days, "1899-12-30");
+        }catch (Exception e) {
+            return null;
+        }
+    }
+
+    //保证先遍历主表
+    private List<String> SetToList(Set<String> sets) {
+        List<String> list = new ArrayList<>();
+        list.add("main");
+        for (String str : sets) {
+            if (!"main".equals(str)) {
+                list.add(str);
+            }
+        }
+        return list;
+    }
+
+    public static Object getCellFormatValue(Cell cell){
+        Object cellValue = null;
+        if(cell!=null){
+            //判断cell类型
+            switch(cell.getCellType()){
+                case Cell.CELL_TYPE_NUMERIC:{
+                    cellValue = String.valueOf(cell.getNumericCellValue());
+                    //判断是否为INT类型
+                    if (Double.valueOf(cellValue.toString()).intValue() - Double.valueOf(cellValue.toString()) == 0) {
+                        return cellValue.toString().substring(0, cellValue.toString().indexOf("."));
+                    }
+                    break;
+                }
+                case Cell.CELL_TYPE_FORMULA:{
+                    //判断cell是否为日期格式
+                    if(DateUtil.isCellDateFormatted(cell)){
+                        //转换为日期格式YYYY-mm-dd
+                        cellValue = cell.getDateCellValue();
+                    }else{
+                        //数字
+                        cellValue = String.valueOf(cell.getNumericCellValue());
+                    }
+                    break;
+                }
+                case Cell.CELL_TYPE_STRING:{
+                    cellValue = cell.getRichStringCellValue().getString();
+                    break;
+                }
+                default:
+                    cellValue = "";
+            }
+        }else{
+            cellValue = "";
+        }
+        return cellValue;
+    }
+
+
+    protected Cell getCell(Sheet sheet, int row, int col) {
+        Row sheetRow = sheet.getRow(row);
+        if (sheetRow == null) {
+            sheetRow = sheet.createRow(row);
+        }
+        Cell cell = sheetRow.getCell(col);
+        if (cell == null) {
+            cell = sheetRow.createCell(col);
+        }
+        return cell;
+    }
+
+    /**
+     * 生成excel工作表
+     *
+     * 数据
+     */
+    private void createWorkbook(SXSSFWorkbook workbook, int sheetIdx, JSONArray cols, JSONArray datas, String remark){
+        Sheet sheet = workbook.createSheet("sheet" + sheetIdx);
+        CellStyle style = getCellStyle(workbook, true);
+        CellStyle detailStyle = getCellStyle(workbook, false);
+        //sheet.autoSizeColumn(2);
+       // sheet.createFreezePane(0, 1);// 固定列
+        Cell cell = null;
+        int rIdx = 0;
+        int cIdx = 0;
+        short width = 0;
+        DataFormat format = workbook.createDataFormat();
+        Row row = null;
+        if (remark != null) {
+            row = sheet.createRow(rIdx);
+            row.setHeightInPoints((short) 50);
+            sheet.setColumnWidth(cIdx, 500);
+            cell = getCell(sheet, rIdx, cIdx);
+            cell.setCellValue(remark);
+            sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, cols.size() - 1));
+            rIdx++;
+        }
+        row = sheet.createRow(rIdx);
+        row.setHeightInPoints((short) 22);
+        List<String> keys = new ArrayList<String>();
+        if (!CollectionUtils.isEmpty(cols)) {
+            String value = "";
+            //列出主表的列
+            for (int i = 0; i < cols.size(); i++) {
+                JSONObject obj = (JSONObject) cols.get(i);
+                width = (short) (obj.get("width") == null ? 0 : (int)obj.get("width")*35.7);
+                width = width == 0 ? 4000 : width;
+                sheet.setColumnWidth(cIdx, width);
+               // sheet.createFreezePane(cols.size() + 1, 2);
+                cell = getCell(sheet, rIdx, cIdx);
+                value = obj.get("description") == null ? value : obj.get("description").toString();
+                if ("true".equals(obj.get("necessary"))) {
+                    value = "*" + value;
+                }
+                if ("date".equals(obj.get("type"))) {
+                    short df= workbook.createDataFormat().getFormat("yyyy-MM-dd");
+                    style.setDataFormat(df);
+                }
+                if ("main".equals(obj.get("position"))) {
+                    cell.setCellStyle(style);
+                } else {
+                    cell.setCellStyle(detailStyle);
+                }
+                cell.setCellValue(value);
+                keys.add(String.valueOf(obj.get("description")));
+                cIdx++;
+                value = "";
+            }
+            rIdx++;
+            if (!CollectionUtils.isEmpty(datas)) {
+                for(Object d :datas) {
+                    JSONObject data = (JSONObject)d;
+                    cIdx = 0;
+                    row = sheet.createRow(rIdx);
+                    row.setHeightInPoints((short) 20);
+                    for (String key : keys) {
+                        Cell c = getCell(sheet, rIdx, cIdx);
+                        if (data.get(key) != null) {
+                            String v = String.valueOf(data.get(key));
+                            if ("".equals(v) || "null".equals(v)) {
+                                c.setCellValue(0);
+                            } else if (!v.matches("^-?[0-9]+(.[0-9]+)?")) {
+                                c.setCellValue(v);
+                            } else {
+                                c.setCellValue(Double.parseDouble(v.replace(",", "")));
+                            }
+                        } else {
+                            c.setCellValue("");
+                        }
+                        cIdx++;
+                    }
+                    rIdx++;
+                }
+            }
+        }
+    }
+
+    private CellStyle getCellStyle(SXSSFWorkbook workbook, boolean main) {
+        CellStyle style = workbook.createCellStyle();
+        style.setFillBackgroundColor((short) 18);
+        style.setFillPattern(FillPatternType.LEAST_DOTS);
+        Font font = workbook.createFont();
+        font.setFontName("仿宋_GB2312");// 字体
+        font.setFontHeightInPoints((short) 12);// 字号
+        font.setColor((short)64);// 颜色
+        style.setFont(font);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setFillForegroundColor(HSSFColor.GREEN.index);
+        style.setFillBackgroundColor(main ? HSSFColor.LIGHT_YELLOW.index : HSSFColor.PALE_BLUE.index);
+        style.setBorderBottom(BorderStyle.MEDIUM);
+        style.setBorderLeft(BorderStyle.MEDIUM);
+        style.setBorderRight(BorderStyle.MEDIUM);
+        style.setBorderTop(BorderStyle.MEDIUM);
+        return style;
+    }
+
+}

+ 7 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/HomePageServiceImpl.java

@@ -79,6 +79,13 @@ public class HomePageServiceImpl implements HomePageService{
         return Result.success(json);
     }
 
+    @Override
+    public Result keyData() {
+        Long companyId = BaseContextHolder.getCompanyId();
+        Object data = parseJson(homePageMapper.getKeyData(companyId));
+        return Result.success(data);
+    }
+
     private Object parseJson(String text) {
         Object json = null;
         if (null != text) {

+ 1 - 1
applications/commons/commons-server/src/main/resources/config/application-docker-prod.yml

@@ -13,7 +13,7 @@ spring:
     username: saas
     password: select123***
   datasource:
-    url: jdbc:mysql://10.10.100.18:3306/saas_biz?characterEncoding=utf-8&useSSL=false
+    url: jdbc:mysql://10.10.100.18:3306/saas_biz?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
     username: saas
     password: select111***
 logging:

+ 12 - 0
applications/commons/commons-server/src/main/resources/config/application-docker-test.yml

@@ -0,0 +1,12 @@
+eureka:
+  instance:
+    hostname: saas-commons-server-test
+    prefer-ip-address: false
+  client:
+    serviceUrl:
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-test:8515/eureka/
+spring:
+  rabbitmq:
+    virtual-host: test
+server:
+  port: 8915

+ 9 - 0
applications/commons/commons-server/src/main/resources/logback-spring.xml

@@ -110,6 +110,15 @@
         </root>
     </springProfile>
 
+    <springProfile name="docker-test">
+        <logger name="org.springframework" level="WARN"/>
+        <logger name="com.usoftchina.saas" level="WARN"/>
+        <root level="WARN">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+            <appender-ref ref="JSON_APPENDER"/>
+        </root>
+    </springProfile>
+
     <springProfile name="docker-prod">
         <logger name="org.springframework" level="WARN"/>
         <logger name="com.usoftchina.saas" level="WARN"/>

+ 4 - 7
applications/commons/commons-server/src/main/resources/mapper/CommonMapper.xml

@@ -1,21 +1,18 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.usoftchina.saas.commons.mapper.CommonMapper" >
-    <select id="getCountBaseSet" resultType="int">
-        SELECT COUNT(*) FROM ENTERPRISE WHERE COMPANYID = #{companyId}
-    </select>
     <select id="getCountWarehouse" resultType="int">
-        SELECT COUNT(*) FROM WAREHOUSE WHERE COMPANYID=#{companyId} AND WH_STATUSCODE = 'OPEN'
+        SELECT COUNT(*) FROM WAREHOUSE WHERE COMPANYID=#{companyId} AND WH_STATUSCODE = 'ENABLE'
     </select>
     <select id="getCountProduct" resultType="int">
-        SELECT COUNT(*) FROM PRODUCT WHERE COMPANYID=#{companyId} AND PR_STATUSCODE = 'OPEN'
+        SELECT COUNT(*) FROM PRODUCT WHERE COMPANYID=#{companyId} AND PR_STATUSCODE = 'ENABLE'
     </select>
     <select id="getCountCustomer" resultType="int">
-        SELECT COUNT(*) FROM CUSTOMER WHERE COMPANYID=#{companyId} AND CU_STATUSCODE = 'OPEN'
+        SELECT COUNT(*) FROM CUSTOMER WHERE COMPANYID=#{companyId} AND CU_STATUSCODE = 'ENABLE'
     </select>
 
     <select id="getCountVendor" resultType="int">
-        SELECT COUNT(*) FROM VENDOR WHERE COMPANYID=#{companyId} AND VE_STATUSCODE = 'OPEN'
+        SELECT COUNT(*) FROM VENDOR WHERE COMPANYID=#{companyId} AND VE_STATUSCODE = 'ENABLE'
     </select>
 
     <update id="commonAudit" parameterType="string">

+ 83 - 0
applications/commons/commons-server/src/main/resources/mapper/DataImportDetailMapper.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.DataImportDetailMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.commons.po.DataImportDetail" >
+    <id column="dd_id" property="dd_id" jdbcType="INTEGER" />
+    <result column="dd_maindata" property="dd_maindata" jdbcType="VARCHAR" />
+    <result column="dd_detno" property="dd_detno" jdbcType="INTEGER" />
+    <result column="dd_diid" property="dd_diid" jdbcType="INTEGER" />
+    <result column="dd_checked" property="dd_checked" jdbcType="INTEGER" />
+    <result column="dd_success" property="dd_success" jdbcType="INTEGER" />
+    <result column="dd_toformal" property="dd_toformal" jdbcType="INTEGER" />
+    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="dd_detaildata" property="dd_detaildata" jdbcType="VARCHAR" />
+    <result column="dd_codevalue" property="dd_codevalue" jdbcType="VARCHAR" />
+  </resultMap>
+
+  <delete id="deleteByIds">
+    delete from data_importdetail where dd_diid in (${value})
+  </delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImportDetail" >
+    insert into data_importdetail
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="dd_maindata != null" >
+        dd_maindata,
+      </if>
+      <if test="dd_detno != null" >
+        dd_detno,
+      </if>
+      <if test="dd_diid != null" >
+        dd_diid,
+      </if>
+      <if test="dd_checked != null" >
+        dd_checked,
+      </if>
+      <if test="dd_success != null" >
+        dd_success,
+      </if>
+      <if test="dd_toformal != null" >
+        dd_toformal,
+      </if>
+      <if test="companyid != null" >
+        companyid,
+      </if>
+      <if test="dd_detaildata != null" >
+        dd_detaildata,
+      </if>
+      <if test="dd_codevalue != null" >
+        dd_codevalue,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="dd_maindata != null" >
+        #{dd_maindata,jdbcType=VARCHAR},
+      </if>
+      <if test="dd_detno != null" >
+        #{dd_detno,jdbcType=INTEGER},
+      </if>
+      <if test="dd_diid != null" >
+        #{dd_diid,jdbcType=INTEGER},
+      </if>
+      <if test="dd_checked != null" >
+        #{dd_checked,jdbcType=INTEGER},
+      </if>
+      <if test="dd_success != null" >
+        #{dd_success,jdbcType=INTEGER},
+      </if>
+      <if test="dd_toformal != null" >
+        #{dd_toformal,jdbcType=INTEGER},
+      </if>
+      <if test="companyid != null" >
+        #{companyid,jdbcType=INTEGER},
+      </if>
+      <if test="dd_detaildata != null" >
+        #{dd_detaildata,jdbcType=VARCHAR},
+      </if>
+      <if test="dd_codevalue != null" >
+        #{dd_codevalue,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+
+ </mapper>

+ 83 - 0
applications/commons/commons-server/src/main/resources/mapper/DataImportMapper.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.DataImportMapper" >
+<delete id="deleteByCaller">
+  delete from data_import where di_caller=#{caller} and companyid=#{companyid} and
+  il_toformal=0 and il_result is not null
+</delete>
+  <delete id="deleteByIds">
+    delete from data_import where di_id in (${value});
+  </delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImport" >
+    <selectKey  resultType="java.lang.Integer" keyProperty="di_id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    insert into data_import
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        di_caller,
+      </if>
+      <if test="companyid != null" >
+        companyid,
+      </if>
+      <if test="di_date != null" >
+        di_date,
+      </if>
+      <if test="di_count != null" >
+        di_count,
+      </if>
+      <if test="di_result != null" >
+        di_result,
+      </if>
+      <if test="di_success != null" >
+        di_success,
+      </if>
+      <if test="di_man != null" >
+        di_man,
+      </if>
+      <if test="di_toformal != null" >
+        di_toformal,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        #{di_caller,jdbcType=VARCHAR},
+      </if>
+      <if test="companyid != null" >
+        #{companyid,jdbcType=INTEGER},
+      </if>
+      <if test="di_date != null" >
+        #{di_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="di_count != null" >
+        #{di_count,jdbcType=INTEGER},
+      </if>
+      <if test="di_result != null" >
+        #{di_result,jdbcType=VARCHAR},
+      </if>
+      <if test="di_success != null" >
+        #{di_success,jdbcType=INTEGER},
+      </if>
+      <if test="di_man != null" >
+        #{di_man,jdbcType=VARCHAR},
+      </if>
+      <if test="di_toformal != null" >
+        #{di_toformal,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+
+  <update id="updateErr" >
+    update data_import
+    set
+    di_result = #{err},
+    di_success = 0
+    where di_id = #{id}
+  </update>
+
+
+  <select id="selectByCaller" resultType="string">
+    select group_concat(di_id) from data_import where di_caller=#{caller} and di_toformal=0 and di_result is not null
+  </select>
+</mapper>

+ 17 - 0
applications/commons/commons-server/src/main/resources/mapper/DataTempletMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.DataTempletMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.commons.po.DataTemplet" >
+    <id column="dt_id" property="dt_id" jdbcType="INTEGER" />
+    <result column="dt_caller" property="dt_caller" jdbcType="VARCHAR" />
+    <result column="dt_description" property="dt_description" jdbcType="VARCHAR" />
+    <result column="dt_title" property="dt_title" jdbcType="VARCHAR" />
+    <result column="dt_exampledata" property="dt_exampledata" jdbcType="VARCHAR" />
+    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="dt_columns" property="dt_columns" jdbcType="VARCHAR"/>
+  </resultMap>
+
+  <select id="selectByCaller" resultMap="BaseResultMap">
+    select * from data_Templet where dt_caller=#{caller}
+  </select>
+</mapper>

+ 9 - 0
applications/commons/commons-server/src/main/resources/mapper/EndProductMapper.xml

@@ -28,10 +28,19 @@
     <select id="endProduct" parameterMap="spParamMap" statementType="CALLABLE">
         CALL SP_ENDPRODUCT(?, ?, ?)
     </select>
+
+    <select id="end" parameterMap="spParamMap" statementType="CALLABLE">
+        CALL SP_END(?, ?, ?)
+    </select>
+
     <update id="updatePeriodStatus" >
         update periodsdetail set pd_status=#{status} where pd_detno=#{period} and companyId=#{companyId}
     </update>
 
+    <update id="updateRe" >
+        UPDATE receivablesdetail SET RD_STATUS=0 WHERE date_format(rd_date, '%Y%m')=#{ym} AND companyid=#{companyId};
+    </update>
+
     <select id="checkPay" parameterType="java.lang.Long" resultType="java.lang.Integer">
         select count(1) from vendor where (ve_id,companyid) in (select pb_vendid,companyid from (
         select pbd_ym,pb_vendid,paybalance.companyid from paybalance,paybalancedetail where pb_id=pbd_pbid and pbd_slkind='期初余额'

+ 25 - 0
applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml

@@ -91,4 +91,29 @@
 
         (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%c'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d6 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_6)
        </select>
+
+    <select id="getKeyData" parameterType="long" resultType="string">
+          select concat('{"storageTotal":',storageTotal,',"receiveTotal":',receiveTotal,',"payTotal":',payTotal,',"balanceTotal":',balanceTotal,'}') from (
+            #库存总额:
+            (
+            SELECT ifnull(storage_,0) storageTotal from (
+            select sum(ifnull(po_amount,0)) storage_ from productonhand where companyid=#{componyId})a
+            ) a1,
+            #应收总额
+            (
+            select ifnull(receive_,0) receiveTotal from (
+            select sum(ifnull(cu_leftamount,0)) receive_ from customer where companyid=#{componyId}) b
+            )b1,
+            #应付总额
+            (
+            select ifnull(pay_,0) payTotal from (
+            select sum(ifnull(ve_leftamount,0)) pay_ from vendor where companyId=#{componyId}) c
+            )c1,
+            #账户余额
+            (
+            select ifnull(balance_,0) balanceTotal from (
+            select sum(ifnull(bk_thisamount,0)) balance_ from bankinformation where companyid=#{componyId})d
+            )d1
+            );
+    </select>
 </mapper>

+ 4 - 0
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/CustomerDTO.java

@@ -14,6 +14,8 @@ import java.util.Date;
 public class CustomerDTO extends CommonBaseDTO implements Serializable {
     private String cu_code;
 
+    private String cu_shortname;
+
     private String cu_name;
 
     private String cu_uu;
@@ -57,4 +59,6 @@ public class CustomerDTO extends CommonBaseDTO implements Serializable {
     private Double cu_recamount;
 
     private Double cu_preamount;
+
+    private String cu_remark;
 }

+ 12 - 34
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendorDTO.java

@@ -1,52 +1,30 @@
 package com.usoftchina.saas.document.dto;
 
 import com.usoftchina.saas.base.dto.CommonBaseDTO;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.io.Serializable;
 
-@ApiModel(value = "Vendor", description = "供应商资料")
+@Data
 public class VendorDTO extends CommonBaseDTO implements Serializable{
 
-    @ApiModelProperty(value = "供应商编号")
+
     private String ve_code;
-    @ApiModelProperty(value = "供应商名称")
-    private String ve_name;
-    @ApiModelProperty(value = "供应商类型")
-    private String ve_type;
-    @ApiModelProperty(value = "状态")
-    private String ve_status;
 
-    public String getVe_code() {
-        return ve_code;
-    }
+    private String ve_shortname;
 
-    public void setVe_code(String ve_code) {
-        this.ve_code = ve_code;
-    }
+    private String ve_name;
+
+    private String ve_type;
 
-    public String getVe_name() {
-        return ve_name;
-    }
+    private String ve_status;
 
-    public void setVe_name(String ve_name) {
-        this.ve_name = ve_name;
-    }
+    private String ve_remark;
 
-    public String getVe_type() {
-        return ve_type;
-    }
+    private Long ve_buyerid;
 
-    public void setVe_type(String ve_type) {
-        this.ve_type = ve_type;
-    }
+    private String ve_buyercode;
 
-    public String getVe_status() {
-        return ve_status;
-    }
+    private String ve_buyername;
 
-    public void setVe_status(String ve_status) {
-        this.ve_status = ve_status;
-    }
 }

+ 3 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Customer.java

@@ -10,6 +10,8 @@ public class Customer extends CommonBaseEntity implements Serializable {
 
     private String cu_code;
 
+    private String cu_shortname;
+
     private String cu_name;
 
     private String cu_uu;
@@ -54,4 +56,5 @@ public class Customer extends CommonBaseEntity implements Serializable {
 
     private Double cu_preamount;
 
+    private String cu_remark;
 }

+ 4 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustomerList.java

@@ -15,6 +15,8 @@ public class CustomerList extends CommonBaseEntity{
 //customer
     private String cu_code;
 
+    private String cu_shortname;
+
     private String cu_name;
 
     private String cu_uu;
@@ -58,6 +60,8 @@ public class CustomerList extends CommonBaseEntity{
     private Double cu_recamount;
 
     private Double cu_preamount;
+
+    private String cu_remark;
 //customeraddress
 
     private Long ca_cuid;

+ 12 - 179
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Vendor.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.document.entities;
 
 import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -10,12 +11,19 @@ import java.util.Date;
  * @author chenwei
  * @Date 2018/10/13
  */
+@Data
 public class Vendor extends CommonBaseEntity implements Serializable{
 
     /**
      * 供应商编号
      */
     private String ve_code;
+
+    /**
+     * 供应商简称
+     */
+    private String ve_shortname;
+
     /**
      * 供应商名称
      */
@@ -97,187 +105,12 @@ public class Vendor extends CommonBaseEntity implements Serializable{
 
     private Double ve_preamount;
 
-    public Double getVe_payamount() {
-        return ve_payamount;
-    }
-
-    public void setVe_payamount(Double ve_payamount) {
-        this.ve_payamount = ve_payamount;
-    }
-
-    public Double getVe_leftamount() {
-        return ve_leftamount;
-    }
-
-    public void setVe_leftamount(Double ve_leftamount) {
-        this.ve_leftamount = ve_leftamount;
-    }
-
-    public Integer getVe_beginym() {
-        return ve_beginym;
-    }
-
-    public void setVe_beginym(Integer ve_beginym) {
-        this.ve_beginym = ve_beginym;
-    }
-
-    public String getVe_code() {
-        return ve_code;
-    }
-
-    public void setVe_code(String ve_code) {
-        this.ve_code = ve_code;
-    }
-
-    public String getVe_name() {
-        return ve_name;
-    }
-
-    public void setVe_name(String ve_name) {
-        this.ve_name = ve_name;
-    }
-
-    public String getVe_uu() {
-        return ve_uu;
-    }
-
-    public void setVe_uu(String ve_uu) {
-        this.ve_uu = ve_uu;
-    }
-
-    public String getVe_type() {
-        return ve_type;
-    }
-
-    public void setVe_type(String ve_type) {
-        this.ve_type = ve_type;
-    }
-
-    public Date getVe_begindate() {
-        return ve_begindate;
-    }
-
-    public void setVe_begindate(Date ve_begindate) {
-        this.ve_begindate = ve_begindate;
-    }
-
-    public Double getVe_beginapamount() {
-        return ve_beginapamount;
-    }
-
-    public void setVe_beginapamount(Double ve_beginapamount) {
-        this.ve_beginapamount = ve_beginapamount;
-    }
-
-    public Double getVe_beginprepayamount() {
-        return ve_beginprepayamount;
-    }
-
-    public void setVe_beginprepayamount(Double ve_beginprepayamount) {
-        this.ve_beginprepayamount = ve_beginprepayamount;
-    }
-
-    public Long getVe_promisedays() {
-        return ve_promisedays;
-    }
-
-    public void setVe_promisedays(Long ve_promisedays) {
-        this.ve_promisedays = ve_promisedays;
-    }
-
-    public Double getVe_taxrate() {
-        return ve_taxrate;
-    }
-
-    public void setVe_taxrate(Double ve_taxrate) {
-        this.ve_taxrate = ve_taxrate;
-    }
-
-    public String getVe_nsrzh() {
-        return ve_nsrzh;
-    }
-
-    public void setVe_nsrzh(String ve_nsrzh) {
-        this.ve_nsrzh = ve_nsrzh;
-    }
-
-    public String getVe_bankaccount() {
-        return ve_bankaccount;
-    }
-
-    public void setVe_bankaccount(String ve_bankaccount) {
-        this.ve_bankaccount = ve_bankaccount;
-    }
-
-    public String getVe_bankcode() {
-        return ve_bankcode;
-    }
-
-    public void setVe_bankcode(String ve_bankcode) {
-        this.ve_bankcode = ve_bankcode;
-    }
-
-    public String getVe_status() {
-        return ve_status;
-    }
-
-    public void setVe_status(String ve_status) {
-        this.ve_status = ve_status;
-    }
-
-    public String getVe_statuscode() {
-        return ve_statuscode;
-    }
-
-    public void setVe_statuscode(String ve_statuscode) {
-        this.ve_statuscode = ve_statuscode;
-    }
-
-    public String getVe_text1() {
-        return ve_text1;
-    }
-
-    public void setVe_text1(String ve_text1) {
-        this.ve_text1 = ve_text1;
-    }
-
-    public String getVe_text2() {
-        return ve_text2;
-    }
-
-    public void setVe_text2(String ve_text2) {
-        this.ve_text2 = ve_text2;
-    }
-
-    public String getVe_text3() {
-        return ve_text3;
-    }
-
-    public void setVe_text3(String ve_text3) {
-        this.ve_text3 = ve_text3;
-    }
-
-    public String getVe_text4() {
-        return ve_text4;
-    }
-
-    public void setVe_text4(String ve_text4) {
-        this.ve_text4 = ve_text4;
-    }
+    private String ve_remark;
 
-    public String getVe_text5() {
-        return ve_text5;
-    }
+    private Long ve_buyerid;
 
-    public void setVe_text5(String ve_text5) {
-        this.ve_text5 = ve_text5;
-    }
+    private String ve_buyercode;
 
-    public Double getVe_preamount() {
-        return ve_preamount;
-    }
+    private String ve_buyername;
 
-    public void setVe_preamount(Double ve_preamount) {
-        this.ve_preamount = ve_preamount;
-    }
 }

+ 13 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/VendorList.java

@@ -14,6 +14,11 @@ public class VendorList implements Serializable {
      * 供应商编号
      */
     private String ve_code;
+
+    /**
+     * 供应商简称
+     */
+    private String ve_shortname;
     /**
      * 供应商名称
      */
@@ -91,6 +96,14 @@ public class VendorList implements Serializable {
      */
     private String ve_text5;
 
+    private String ve_remark;
+
+    private Long ve_buyerid;
+
+    private String ve_buyercode;
+
+    private String ve_buyername;
+
     /* 从表字段 */
 
     private Integer vc_veid;

+ 8 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/AddressController.java

@@ -27,6 +27,14 @@ public class AddressController {
         return Result.success();
     }
 
+    @PostMapping("/setDefault/{id}")
+    public Result setDefault(@PathVariable("id") Long id){
+        addressService.setDefault(id);
+        return Result.success();
+    }
+
+
+
     @PostMapping("/batchDelete")
     public Result deleteByIds(String ids){
         addressService.removeByIds(ids);

+ 6 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java

@@ -174,4 +174,10 @@ public class CustomerController {
         return Result.success();
     }
 
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        customerService.saveToFormal(id, update);
+        return Result.success();
+    }
 }

+ 7 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java

@@ -16,9 +16,7 @@ import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 @RestController
 @RequestMapping("/product")
@@ -107,4 +105,11 @@ public class ProductController {
         return Result.success(productService.getReserveCost(page, listReqDTO));
     }
 
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        productService.saveToFormal(id, update);
+        return Result.success();
+    }
+
 }

+ 7 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/VendorController.java

@@ -134,4 +134,11 @@ public class VendorController {
         return Result.success();
     }
 
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        vendorService.saveToFormal(id, update);
+        return Result.success();
+    }
+
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/AddressMapper.java

@@ -32,4 +32,6 @@ public interface AddressMapper extends CommonBaseMapper<Address> {
     List<Address> selectAll(@Param("companyId") Long companyId);
 
     int getCountFromPurchase(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    void setDefault(@Param("id") Long id, @Param("companyId") Long companyId);
 }

+ 5 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java

@@ -24,11 +24,15 @@ public interface BankinformationMapper extends CommonBaseMapper<Bankinformation>
     List<Bankinformation> selectBankinformationBycondition(@Param("con") String con, @Param("companyId") Long companyId);
 
     List<ComboDTO> getCombo(@Param("companyId") Long companyId);
-    String selectBankcode(String bk_bankcode);
+    String selectBankcode(@Param("bk_bankcode") String bk_bankcode, @Param("companyId") Long companyId);
     Long selectBankId(String bk_bankcode);
 
     void check(Map<String, Object> map);
 
     Double selectamount(Long id);
 
+    int validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
+
+    int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
+
 }

+ 2 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerMapper.java

@@ -17,8 +17,6 @@ public interface CustomerMapper extends CommonBaseMapper<Customer> {
 
     int updateByPrimaryKeySelective(Customer record);
 
-    int updateByPrimaryKey(Customer record);
-
     String selectCodeById(Long id);
 
     Integer validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
@@ -37,4 +35,6 @@ public interface CustomerMapper extends CommonBaseMapper<Customer> {
     int validNameAndCodeWhenRelated(Customer customer);
 
     List<ComboDTO> getCombo(@Param("id") Long id,@Param("companyId") Long companyId);
+
+    Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 22 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/DataImportMapper.java

@@ -0,0 +1,22 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.commons.po.DataImport;
+import com.usoftchina.saas.commons.po.DataImportDetail;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface DataImportMapper {
+    void deleteByCaller(@Param("caller") String caller, @Param("companyid") Long companyid);
+    int insertSelective(DataImport record);
+
+    void updateErr(@Param("err") String err, @Param("id") Integer id);
+
+    List<DataImportDetail> selectDataById(Integer id);
+
+    DataImportDetail selectMainBycode(@Param("code") String code, @Param("id") int id, @Param("companyid") Long companyId);
+
+    void updateDataImport(Integer id);
+
+    void updateDataImportError(@Param("err") String err,@Param("id") int id);
+}

+ 8 - 6
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/EmployeeMapper.java

@@ -20,16 +20,18 @@ public interface EmployeeMapper extends CommonBaseMapper<Employee> {
 
     List<EmployeeDTO> selectEmployeeListByCondition(@Param("con") String con,@Param("companyId") Long companyId);
 
-    Integer validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
+    int validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
 
-    Integer validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
+    int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
 
-    Integer validatePhoneWhenInsert(@Param("phone") String phone, @Param("companyId") Long companyId);
+    int validatePhoneWhenInsert(@Param("phone") String phone, @Param("companyId") Long companyId);
 
-    Integer validatePhoneWhenUpdate(@Param("phone") String phone, @Param("id") Long id, @Param("companyId") Long company);
+    int validatePhoneWhenUpdate(@Param("phone") String phone, @Param("id") Long id, @Param("companyId") Long company);
 
 
-    Integer validateNameAndCodeWhenInsert(@Param("code") String code,@Param("name") String em_name,@Param("companyId") Long companyId);
+    int validateNameAndCodeWhenInsert(@Param("code") String code,@Param("name") String em_name,@Param("companyId") Long companyId);
 
-    Integer validateNameAndCodeWhenUpdate(@Param("code") String code,@Param("name") String em_name,@Param("id") Long em_id,@Param("companyId") Long id);
+    int validateNameAndCodeWhenUpdate(@Param("code") String code,@Param("name") String em_name,@Param("id") Long id,@Param("companyId") Long companyId);
+
+    List<Employee> selectByName(@Param("name") String name, @Param("companyId") Long companyId);
 }

+ 4 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductMapper.java

@@ -48,4 +48,8 @@ public interface ProductMapper extends CommonBaseMapper<Product> {
     boolean deleteProdIOByCode(@Param("code") String code, @Param("companyId") Long companyId);
 
     boolean deleteProdIODetailByCode(@Param("code") String code, @Param("companyId") Long companyId);
+
+    Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
+
+    List<ProductReserveCostDTO> selectReserveCostByIgnoreWarehouse(@Param("con") String con, @Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendorMapper.java

@@ -31,4 +31,6 @@ public interface VendorMapper extends CommonBaseMapper<Vendor> {
     int validFinish(@Param("id") Long id,@Param("companyId") Long companyId);
 
     void check(Map<String, Object> map);
+
+    Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/WarehouseMapper.java

@@ -44,4 +44,6 @@ public interface WarehouseMapper extends CommonBaseMapper<Warehouse> {
     int selectCountByCode(@Param("code") String code, @Param("companyId") Long companyId, @Param("id") Long id);
 
     int deleteCheckProdIO(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    Warehouse selectWareHouse(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/AddressService.java

@@ -17,4 +17,6 @@ public interface AddressService extends CommonBaseService<AddressMapper, Address
     List<Address> selectAll();
 
     DocBaseDTO saveData(Address address);
+
+    void setDefault(Long id);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerService.java

@@ -44,4 +44,6 @@ public interface CustomerService extends CommonBaseService<CustomerMapper, Custo
     PageInfo<CustomerList> getDbfind(PageRequest page, ListReqDTO listReqDTO);
 
     List<ComboDTO> getAddressCombo(Long id);
+
+    void saveToFormal(Integer id, boolean update);
 }

+ 4 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductService.java

@@ -17,6 +17,7 @@ import com.usoftchina.saas.document.mapper.ProductMapper;
 import com.usoftchina.saas.page.PageRequest;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ProductService extends CommonBaseService<ProductMapper, Product> {
 
@@ -109,7 +110,7 @@ public interface ProductService extends CommonBaseService<ProductMapper, Product
      * @param listReqDTO
      * @return
      */
-    PageInfo<ProductReserveCostDTO> getReserveCost(PageRequest page, ListReqDTO listReqDTO);
+    Map<String, Object> getReserveCost(PageRequest page, ListReqDTO listReqDTO);
 
     /**
      * 通过明细ID删除明细
@@ -117,4 +118,6 @@ public interface ProductService extends CommonBaseService<ProductMapper, Product
      * @return
      */
     boolean deleteDetailById(Long id);
+
+    void saveToFormal(Integer id, boolean update);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorService.java

@@ -95,4 +95,6 @@ public interface VendorService extends CommonBaseService<VendorMapper, Vendor>{
      * @return
      */
     boolean batchDelete(BatchDealBaseDTO baseDTOs);
+
+    void saveToFormal(Integer id, boolean update);
 }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/AddressServiceImpl.java

@@ -58,6 +58,11 @@ public class AddressServiceImpl extends CommonBaseServiceImpl<AddressMapper, Add
         return docBaseDTO;
     }
 
+    @Override
+    public void setDefault(Long id) {
+        getMapper().setDefault(id,BaseContextHolder.getCompanyId());
+    }
+
     /**
      * 通过主键删除
      * @param id

+ 55 - 32
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java

@@ -3,11 +3,13 @@ package com.usoftchina.saas.document.service.impl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.entities.Bankinformation;
 import com.usoftchina.saas.document.entities.Banksubledger;
@@ -16,6 +18,8 @@ import com.usoftchina.saas.document.mapper.BanksubledgerMapper;
 import com.usoftchina.saas.document.service.BankinformationService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.utils.DateUtils;
+import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -40,6 +44,8 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
     private BanksubledgerMapper banksubledgerMapper;
     @Autowired
     private MessageLogService messageLogService;
+    @Autowired
+    private MaxnumberService maxnumberService;
 
     @Transactional
     @Override
@@ -52,7 +58,10 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
         bankinformation.setCreatorName(BaseContextHolder.getUserName());
         int bid = Math.toIntExact(bankinformation.getId());
 
-        String bktion = bankinformationMapper.selectBankcode(bankinformation.getBk_bankcode());
+        String bk_code = RegexpUtils.replaceSpecCharacter(bankinformation.getBk_bankcode());
+        String code = pushMaxnubmer(bk_code, bankinformation.getId());
+
+        String bktion = bankinformationMapper.selectBankcode(bankinformation.getBk_bankcode() ,BaseContextHolder.getCompanyId());
         //先判断ID,再判断编号
         if (bankinformation.getId() == 0)
         {
@@ -60,7 +69,10 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
                 throw new BizException(500, BizExceptionCode.ACCOUNT_EXISTS.getMessage());
             }
             bankinformation.setBk_thisamount(bankinformation.getBk_beginamount());
+            bankinformation.setBk_bankcode(code);
             bankinformationMapper.insertSelective(bankinformation);
+            Banksubledger banksubledger = this.changBanksubledger(bankinformation);
+            banksubledgerMapper.insertSelective(banksubledger);
         }else {
             bankinformation.setUpdaterId(BaseContextHolder.getUserId());
             bankinformation.setUpdaterName(BaseContextHolder.getUserName());
@@ -93,37 +105,7 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
             }else {
                 bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
             }
-        }
-
-
-        //中间表
-        Banksubledger banksubledger = new Banksubledger();
-        Date date = bankinformation.getBk_date();
-        String dateString = date2String(date, "yyyyMMdd");
-        int ym = Integer.parseInt(dateString);
-
-        String date1 = date2String(date, "yyyyMM");
-        date1 = date1 + "01 00:00:00";
-        Date d = null;
-        try {
-            d = string2Date(date1, "yyyy-MM-dd hh:mm:ss");
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        banksubledger.setCompanyId(BaseContextHolder.getCompanyId());
-        banksubledger.setBl_ym(ym);
-        banksubledger.setBl_bankid(Math.toIntExact(bankinformation.getId()));
-        banksubledger.setBl_bankcode(bankinformation.getBk_bankcode());
-        banksubledger.setBl_bankname(bankinformation.getBk_bankname());
-        banksubledger.setBl_code("期初余额");
-        banksubledger.setBl_kind("期初余额");
-        banksubledger.setBl_date(d);
-        banksubledger.setBl_orderamount(bankinformation.getBk_beginamount());
-
-        if(bankinformation.getId() == 0){
-            banksubledgerMapper.insertSelective(banksubledger);
-        }else{
+            Banksubledger banksubledger = this.changBanksubledger(bankinformation);
             banksubledgerMapper.updateByPrimaryKeySelective(banksubledger);
         }
         return true;
@@ -191,6 +173,30 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
 
+    //插入中间表
+    public Banksubledger changBanksubledger(Bankinformation bankinformation){
+        Banksubledger banksubledger = new Banksubledger();
+        Date date = bankinformation.getBk_date();
+        banksubledger.setCompanyId(BaseContextHolder.getCompanyId());
+        banksubledger.setBl_ym(DateUtils.getYm(date));
+        banksubledger.setBl_bankid(Math.toIntExact(bankinformation.getId()));
+        banksubledger.setBl_bankcode(bankinformation.getBk_bankcode());
+        banksubledger.setBl_bankname(bankinformation.getBk_bankname());
+        banksubledger.setBl_code("期初余额");
+        banksubledger.setBl_kind("期初余额");
+
+        String date1 = date2String(date, "yyyy-MM");
+        date1 = date1 + "-01 00:00:00";
+        Date d = null;
+        try {
+            d = string2Date(date1, "yyyy-MM-dd hh:mm:ss");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        banksubledger.setBl_date(d);
+        banksubledger.setBl_orderamount(bankinformation.getBk_beginamount());
+        return banksubledger;
+    }
 
     /**
      * String转Date类型
@@ -223,4 +229,21 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
         }
         return null;
     }
+
+    /**
+     * @Description: 检验获取并更新单号
+     * @Param: [code, id]
+     * @return: java.lang.String
+     * @Author: chenwei
+     * @Date: 2018/10/26
+     */
+    private String pushMaxnubmer(String code, Long id) {
+        if (null == code) {
+            throw new BizException(BizExceptionCode.NULL_CODE);
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                getMapper().validateCodeWhenUpdate(code, id, companyId);
+        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.BANKINFORMATION.getCaller()).getData();
+    }
 }

+ 8 - 6
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BomServiceImpl.java

@@ -56,6 +56,8 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
 //                String code = pushMaxnubmer(bom.getBo_mothercode(), bom.getId());
                 String code = bom.getBo_mothercode();
                 bom.setBo_mothercode(code);
+                bom.setBo_statuscode(Status.ENABLE.name());
+                bom.setBo_status(Status.ENABLE.getDisplay());
                 bom.setCompanyId(companyId);
                 bom.setCreatorId(userId);
                 bom.setCreatorName(userName);
@@ -209,8 +211,8 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
 
             bom = new Bom();
             bom.setId(id);
-            bom.setBo_status(Status.CLOSE.getDisplay());
-            bom.setBo_statuscode(Status.CLOSE.name());
+            bom.setBo_status(Status.BANNED.getDisplay());
+            bom.setBo_statuscode(Status.BANNED.name());
             bom.setUpdaterId(BaseContextHolder.getUserId());
             bom.setUpdateTime(new Date());
 
@@ -232,12 +234,12 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
             if(bom == null){
                 throw new BizException(BizExceptionCode.NO_DATA);
             }
-            if (Status.CLOSE.name().equals(bom.getBo_statuscode())){
+            if (Status.BANNED.name().equals(bom.getBo_statuscode())){
                 String code = bom.getBo_mothercode();
                 bom = new Bom();
                 bom.setId(id);
-                bom.setBo_statuscode(Status.OPEN.name());
-                bom.setBo_status(Status.OPEN.getDisplay());
+                bom.setBo_statuscode(Status.ENABLE.name());
+                bom.setBo_status(Status.ENABLE.getDisplay());
                 bom.setUpdateTime(new Date());
                 bom.setUpdaterId(BaseContextHolder.getUserId());
                 getMapper().updateByPrimaryKeySelective(bom);
@@ -246,7 +248,7 @@ public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implem
                 messageLogService.customizeLog(docBaseDTO, Operation.ENABLE);
                 return docBaseDTO;
             }else {
-                throw new BizException(BizExceptionCode.BIZ_OPEN);
+                throw new BizException(BizExceptionCode.BIZ_ENABLE);
             }
         }else {
             throw new BizException(BizExceptionCode.ILLEGAL_ID);

+ 93 - 12
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
@@ -11,25 +12,25 @@ import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
+import com.usoftchina.saas.commons.po.DataImportDetail;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
-import com.usoftchina.saas.document.dto.CustomerDTO;
-import com.usoftchina.saas.document.dto.CustomerFormDTO;
-import com.usoftchina.saas.document.dto.CustomeraddressDTO;
-import com.usoftchina.saas.document.dto.CustomercontactDTO;
+import com.usoftchina.saas.document.dto.*;
 import com.usoftchina.saas.document.entities.*;
 import com.usoftchina.saas.document.mapper.*;
 import com.usoftchina.saas.document.service.CustomerService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
+import sun.reflect.generics.tree.LongSignature;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -59,6 +60,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
     private SubledgerMapper subledgerMapper;
     @Autowired
     private CustomerMapper customerMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
 
 
     @Override
@@ -306,6 +309,9 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         subledger.setCompanyId(BaseContextHolder.getCompanyId());
         subledger.setSl_date(DateUtils.getFirstDay(customer.getCu_begindate()));
         subledger.setSl_ym(DateUtils.getYm(customer.getCu_begindate()));
+        subledger.setCreateTime(new Date());
+        subledger.setCreatorId(BaseContextHolder.getUserId());
+        subledger.setCreatorName(BaseContextHolder.getUserName());
         if (amount > new Double(0)){
             subledger.setSl_amount(amount);
         }else {
@@ -399,11 +405,11 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         DocBaseDTO docBaseDTO = null;
         if (null!=id) {
             Customer customer = getMapper().selectByPrimaryKey(id);
-            if(Status.CLOSE.name().equals(customer.getCu_statuscode())){
-                throw new BizException(BizExceptionCode.BIZ_CLOSE);
+            if(Status.BANNED.name().equals(customer.getCu_statuscode())){
+                throw new BizException(BizExceptionCode.BIZ_BANNED);
             }
-            customer.setCu_statuscode(Status.CLOSE.name());
-            customer.setCu_status(Status.CLOSE.getDisplay());
+            customer.setCu_statuscode(Status.BANNED.name());
+            customer.setCu_status(Status.BANNED.getDisplay());
             getMapper().updateByPrimaryKeySelective(customer);
             docBaseDTO = getBaseDTOById(id);
             //日志
@@ -434,11 +440,11 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         DocBaseDTO docBaseDTO = null;
         if (null!=id) {
             Customer customer = getMapper().selectByPrimaryKey(id);
-            if(Status.OPEN.name().equals(customer.getCu_statuscode())){
-                throw new BizException(BizExceptionCode.BIZ_OPEN);
+            if(Status.ENABLE.name().equals(customer.getCu_statuscode())){
+                throw new BizException(BizExceptionCode.BIZ_ENABLE);
             }
-            customer.setCu_statuscode(Status.OPEN.name());
-            customer.setCu_status(Status.OPEN.getDisplay());
+            customer.setCu_statuscode(Status.ENABLE.name());
+            customer.setCu_status(Status.ENABLE.getDisplay());
             getMapper().updateByPrimaryKeySelective(customer);
             docBaseDTO = getBaseDTOById(id);
             //日志
@@ -485,6 +491,81 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return getMapper().getCombo(id,BaseContextHolder.getCompanyId());
     }
 
+    @Autowired
+    private EmployeeMapper employeeMapper;
+    @Override
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder err = new StringBuilder();
+        List<CustomerFormDTO> list = new ArrayList<>();
+        CustomerFormDTO listDTO = null;
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        if (!CollectionUtils.isEmpty(details)) {
+            Map<String, List<DataImportDetail>> datas = CollectionUtils.groupBy(details, DataImportDetail::getDd_codevalue);
+            Integer detno = null;
+            for (String code : datas.keySet()) {
+                listDTO = new CustomerFormDTO();
+                List<CustomercontactDTO> details_ = new ArrayList<>();
+                int i = getMapper().validateCodeWhenInsert(code, companyId);
+                List<DataImportDetail> data = datas.get(code);
+                DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
+                CustomerDTO customerDTO = JSONObject.parseObject(main.getDd_maindata(), CustomerDTO.class);
+                //验证业务员
+                if (!StringUtils.isEmpty(customerDTO.getCu_sellername())) {
+                    List<Employee> employees = employeeMapper.selectByName(customerDTO.getCu_sellername(), companyId);
+                    if (null == employees || employees.size() == 0 || StringUtils.isEmpty(employees.get(0))) {
+                        err.append("客户编号为: " + customerDTO.getCu_code() + " 的业务员: "+ customerDTO.getCu_sellername() +" 在系统中不存在,请确认数据是否正确");
+                        break;
+                    }
+                    customerDTO.setCu_sellerid(Integer.valueOf(employees.get(0).getId().toString()));
+                    customerDTO.setCu_sellercode(employees.get(0).getEm_code());
+                    customerDTO.setCu_sellername(employees.get(0).getEm_name());
+                }
+                customerDTO.setCu_status(Status.OPEN.getDisplay());
+                customerDTO.setCu_statuscode(Status.OPEN.name());
+                //编号不存在
+                if (i == 0) {
+                    customerDTO.setId(0l);
+                    //编号存在、需要更新
+                } else if (update){
+                    Long cu_id = getMapper().selectIdByCode(code, companyId);
+                    customerDTO.setId(cu_id);
+                    //编号存在、不需要处理
+                } else {
+                    continue;
+                }
+                //添加从表
+                if (data.size() > 0) {
+                    detno = 1;
+                    for (DataImportDetail vendorDetail : data) {
+                        CustomercontactDTO detail = JSONObject.parseObject(vendorDetail.getDd_detaildata(), CustomercontactDTO.class);
+                        if (null != detail) {
+                            detail.setCc_cuid(customerDTO.getId());
+                            detail.setCc_detno(detno);
+                            detno++;
+                            details_.add(detail);
+                        }
+                    }
+                }
+                listDTO.setMain(customerDTO);
+                listDTO.setItems1(details_);
+                listDTO.setItems2(new ArrayList<CustomeraddressDTO>());
+                list.add(listDTO);
+            }
+            if (err.length() > 0) {
+                dataImportMapper.updateDataImportError(err.toString(), id);
+                throw new BizException(12345, err.toString());
+            }
+            for (CustomerFormDTO  dto : list) {
+                saveFormData(dto);
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+
 
     private List<CustomerList> getListByMode(ListReqDTO req) {
         List<CustomerList> list = null;

+ 7 - 4
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/EmployeeServiceImpl.java

@@ -65,19 +65,22 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
     @Override
     public DocBaseDTO saveFormData(Employee employee) {
         DocBaseDTO docBaseDTO = null;
-        String code = pushMaxnubmer(employee.getEm_code(), employee.getId());
+        Long companyId = BaseContextHolder.getCompanyId();
+        employee.setCompanyId(companyId);
         if(employee.getId() == 0){
+            String code = employee.getEm_code();
             //检查名称和编号
-            int count = getMapper().validateNameAndCodeWhenInsert(code,employee.getEm_name(),BaseContextHolder.getCompanyId());
+            int count = getMapper().validateNameAndCodeWhenInsert(code,employee.getEm_name(),companyId);
             if (count>0) {
                 throw new BizException(BizExceptionCode.REPEAT_EMNAMECODE);
             }
+            code = pushMaxnubmer(employee.getEm_code(), employee.getId());
             //检查电话号码
             count = getMapper().validatePhoneWhenInsert(employee.getEm_mobile(),BaseContextHolder.getCompanyId());
             if (count>0) {
                 throw new BizException(BizExceptionCode.REPEAT_TEL);
             }
-            employee.setCompanyId(BaseContextHolder.getCompanyId());
+            employee.setEm_code(code);
             employee.setCreatorId(BaseContextHolder.getUserId());
             employee.setCreateTime(new Date());
             employee.setCreatorName(BaseContextHolder.getUserName());
@@ -87,7 +90,7 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
             messageLogService.save(docBaseDTO);
         }else{
             //检查名称和编号
-            int count = getMapper().validateNameAndCodeWhenUpdate(code,employee.getEm_name(),employee.getId(),BaseContextHolder.getCompanyId());
+            int count = getMapper().validateNameAndCodeWhenUpdate(employee.getEm_code(),employee.getEm_name(),employee.getId(),companyId);
             if (count>0) {
                 throw new BizException(BizExceptionCode.REPEAT_EMNAMECODE);
             }

+ 108 - 10
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java

@@ -1,8 +1,8 @@
 package com.usoftchina.saas.document.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
@@ -12,6 +12,7 @@ import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
+import com.usoftchina.saas.commons.po.DataImportDetail;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
@@ -19,12 +20,15 @@ import com.usoftchina.saas.document.dto.ProductDTO;
 import com.usoftchina.saas.document.dto.ProductListDTO;
 import com.usoftchina.saas.document.dto.ProductReserveCostDTO;
 import com.usoftchina.saas.document.entities.*;
+import com.usoftchina.saas.document.mapper.DataImportMapper;
 import com.usoftchina.saas.document.mapper.ProductDetailMapper;
 import com.usoftchina.saas.document.mapper.ProductMapper;
+import com.usoftchina.saas.document.mapper.WarehouseMapper;
 import com.usoftchina.saas.document.service.ProductService;
 import com.usoftchina.saas.document.service.WarehouseService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -44,6 +48,10 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     private WarehouseService warehouseService;
     @Autowired
     private ProductDetailMapper productDetailMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
+    @Autowired
+    private WarehouseMapper warehouseMapper;
 
     @Override
     public PageInfo<ProductDTO> getProductsByCondition(PageRequest page, ListReqDTO listReqDTO) {
@@ -318,8 +326,8 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
             String code = getMapper().getCodeById(id);
             Product product = new Product();
             product.setId(id);
-            product.setPr_status(Status.CLOSE.getDisplay());
-            product.setPr_statuscode(Status.CLOSE.name());
+            product.setPr_status(Status.BANNED.getDisplay());
+            product.setPr_statuscode(Status.BANNED.name());
             product.setUpdaterId(BaseContextHolder.getUserId());
             product.setUpdateTime(new Date());
             getMapper().updateByPrimaryKeySelective(product);
@@ -341,12 +349,12 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
             if (product == null) {
                 throw new BizException(BizExceptionCode.NO_DATA);
             }
-            if (!Status.CLOSE.getDisplay().equals(product.getPr_status())){
-                throw new BizException(BizExceptionCode.BIZ_OPEN);
+            if (!Status.ENABLE.getDisplay().equals(product.getPr_status())){
+                throw new BizException(BizExceptionCode.BIZ_ENABLE);
             }else{
                 product.setId(id);
-                product.setPr_statuscode(Status.OPEN.name());
-                product.setPr_status(Status.OPEN.getDisplay());
+                product.setPr_statuscode(Status.ENABLE.name());
+                product.setPr_status(Status.ENABLE.getDisplay());
                 product.setUpdaterId(BaseContextHolder.getUserId());
                 product.setUpdateTime(new Date());
                 getMapper().updateByPrimaryKeySelective(product);
@@ -481,7 +489,8 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     }
 
     @Override
-    public PageInfo<ProductReserveCostDTO> getReserveCost(PageRequest page, ListReqDTO listReqDTO) {
+    public Map<String, Object> getReserveCost(PageRequest page, ListReqDTO listReqDTO) {
+        Map<String, Object> map = new HashMap<String, Object>();
         //设置分页
         if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
             page = new PageRequest();
@@ -492,7 +501,9 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
         List<ProductReserveCostDTO> reserveCostList = geReserveCost(listReqDTO);
         //取分页信息
         PageInfo<ProductReserveCostDTO> pageInfo = new PageInfo<ProductReserveCostDTO>(reserveCostList);
-        return pageInfo;
+        map.put("list", pageInfo);
+        map.put("calculate", null);
+        return map;
     }
 
     @Override
@@ -518,13 +529,100 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
         return true;
     }
 
+
+
+    @Override
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder err = new StringBuilder();
+        List<ProductListDTO> list = new ArrayList<>();
+        ProductListDTO listDTO = null;
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        if (!CollectionUtils.isEmpty(details)) {
+            Map<String, List<DataImportDetail>> datas = CollectionUtils.groupBy(details, DataImportDetail::getDd_codevalue);
+            Integer detno = null;
+            for (String code : datas.keySet()) {
+                listDTO = new ProductListDTO();
+                List<ProductDetail> productDetails = new ArrayList<>();
+                int i = getMapper().validateCodeWhenInsert(code, companyId);
+                List<DataImportDetail> data = datas.get(code);
+                DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
+                Product product = JSONObject.parseObject(main.getDd_maindata(), Product.class);
+                Warehouse warehouse = null;
+                //验证仓库
+                if (!StringUtils.isEmpty(product.getPr_whcode())) {
+                    warehouse = warehouseMapper.selectWareHouse(product.getPr_whcode(), companyId);
+                    if (null == warehouse) {
+                        err.append("物料编号为: " + product.getPr_code() + " 的物料仓库: "+ product.getPr_whname() +" 在系统中不存在,请确认数据是否正确");
+                        break;
+                    }
+                    product.setPr_whid(warehouse.getId());
+                    product.setPr_status(Status.OPEN.getDisplay());
+                    product.setPr_statuscode(Status.OPEN.name());
+                }
+                //编号不存在
+                if (i == 0) {
+                    product.setId(0l);
+                    //编号存在、需要更新
+                } else if (update){
+                    Long pr_id = getMapper().selectIdByCode(code, companyId);
+                    product.setId(pr_id);
+                    //编号存在、不需要处理
+                } else {
+                    continue;
+                }
+                //添加从表
+                if (data.size() > 0) {
+                    detno = 1;
+                    for (DataImportDetail productDetail : data) {
+                        ProductDetail detail = JSONObject.parseObject(productDetail.getDd_detaildata(), ProductDetail.class);
+                        if (null != detail) {
+                            //验证仓库
+                            if (!StringUtils.isEmpty(product.getPr_whcode())) {
+                                warehouse = warehouseMapper.selectWareHouse(detail.getPd_whcode(), companyId);
+                                if (null == warehouse) {
+                                    err.append("物料编号为: " + product.getPr_code() + " 的物料仓库: "+ product.getPr_whname() +" 在系统中不存在,请确认数据是否正确");
+                                    break;
+                                }
+                                detail.setPd_whid(Integer.valueOf(warehouse.getId().toString()));
+                                detail.setPd_detno(detno);
+                                detno++;
+                            }
+                            productDetails.add(detail);
+                        }
+                    }
+                }
+
+                listDTO.setMain(product);
+                listDTO.setItems(productDetails);
+                list.add(listDTO);
+            }
+            if (err.length() > 0) {
+                dataImportMapper.updateDataImportError(err.toString(), id);
+                throw new BizException(12345, err.toString());
+            }
+            for (ProductListDTO  dto : list) {
+                saveData(dto);
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+
     private List<ProductReserveCostDTO> geReserveCost(ListReqDTO listReqDTO) {
         Long companyId = BaseContextHolder.getCompanyId();
         String condition = listReqDTO.getFinalCondition();
         if(condition == null){
             condition = "1=1";
         }
-        return getMapper().selectReserveCost(condition, companyId);
+        if ("DETAIL".equals(listReqDTO.getMode())) {
+            return getMapper().selectReserveCost(condition, companyId);
+        } else {
+            return getMapper().selectReserveCostByIgnoreWarehouse(condition, companyId);
+        }
+
     }
 
     private List<ProductDTO> getList(ListReqDTO listReqDTO){

+ 78 - 11
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java

@@ -1,8 +1,8 @@
 package com.usoftchina.saas.document.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
@@ -11,21 +11,22 @@ import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
+import com.usoftchina.saas.commons.po.DataImportDetail;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.dto.ProductListDTO;
 import com.usoftchina.saas.document.dto.VendorDTO;
 import com.usoftchina.saas.document.dto.VendorListDTO;
-import com.usoftchina.saas.document.entities.Subledger;
-import com.usoftchina.saas.document.entities.Vendor;
-import com.usoftchina.saas.document.entities.VendorList;
-import com.usoftchina.saas.document.entities.Vendorcontact;
+import com.usoftchina.saas.document.entities.*;
+import com.usoftchina.saas.document.mapper.DataImportMapper;
 import com.usoftchina.saas.document.mapper.SubledgerMapper;
 import com.usoftchina.saas.document.mapper.VendorMapper;
 import com.usoftchina.saas.document.mapper.VendorcontactMapper;
 import com.usoftchina.saas.document.service.VendorService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.utils.CollectionUtils;
 import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +54,8 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
     private SubledgerMapper subledgerMapper;
     @Autowired
     private VendorMapper vendorMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
 
     @Override
     public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, ListReqDTO listReqDTO) {
@@ -276,6 +279,9 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
         }
         subledger.setSl_orderamount(Math.abs(amount));
         subledger.setSl_namount(Math.abs(amount));
+        subledger.setCreateTime(new Date());
+        subledger.setCreatorId(BaseContextHolder.getUserId());
+        subledger.setCreatorName(BaseContextHolder.getUserName());
         Long sl_id = subledgerMapper.selectByKindCodeVendid("期初余额","期初余额",
                 Math.toIntExact(main.getId()),BaseContextHolder.getCompanyId(),YM);
 
@@ -330,8 +336,8 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
         if(id != null && id > 0){
             Vendor vendor = new Vendor();
             vendor.setId(id);
-            vendor.setVe_status(Status.CLOSE.getDisplay());
-            vendor.setVe_statuscode(Status.CLOSE.name());
+            vendor.setVe_status(Status.BANNED.getDisplay());
+            vendor.setVe_statuscode(Status.BANNED.name());
             vendor.setUpdaterId(BaseContextHolder.getUserId());
             vendor.setUpdateTime(new Date());
 
@@ -358,19 +364,19 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
             if(vendor == null){
                 throw new BizException(BizExceptionCode.NO_DATA);
             }
-            if (Status.CLOSE.name().equals(vendor.getVe_statuscode())){
+            if (Status.BANNED.name().equals(vendor.getVe_statuscode())){
                 String code = vendor.getVe_code();
                 vendor = new Vendor();
                 vendor.setId(id);
-                vendor.setVe_statuscode(Status.OPEN.name());
-                vendor.setVe_status(Status.OPEN.getDisplay());
+                vendor.setVe_statuscode(Status.ENABLE.name());
+                vendor.setVe_status(Status.ENABLE.getDisplay());
                 getMapper().updateByPrimaryKeySelective(vendor);
                 //记录LOG
                 DocBaseDTO docBaseDTO = generateMsgObj(id, code);
                 messageLogService.customizeLog(docBaseDTO, Operation.ENABLE);
                 return docBaseDTO;
             }else {
-                throw new BizException(BizExceptionCode.BIZ_OPEN);
+                throw new BizException(BizExceptionCode.BIZ_ENABLE);
             }
         }else {
             throw new BizException(BizExceptionCode.ILLEGAL_ID);
@@ -427,6 +433,67 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
         return true;
     }
 
+    @Override
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder err = new StringBuilder();
+        List<VendorListDTO> list = new ArrayList<>();
+        VendorListDTO listDTO = null;
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        if (!CollectionUtils.isEmpty(details)) {
+            Map<String, List<DataImportDetail>> datas = CollectionUtils.groupBy(details, DataImportDetail::getDd_codevalue);
+            Integer detno = null;
+            for (String code : datas.keySet()) {
+                listDTO = new VendorListDTO();
+                List<Vendorcontact> details_ = new ArrayList<>();
+                int i = getMapper().validateCodeWhenInsert(code, companyId);
+                List<DataImportDetail> data = datas.get(code);
+                DataImportDetail main = dataImportMapper.selectMainBycode(code, id, companyId);
+                Vendor vendor = JSONObject.parseObject(main.getDd_maindata(), Vendor.class);
+                vendor.setVe_status(Status.OPEN.getDisplay());
+                vendor.setVe_statuscode(Status.OPEN.name());
+                //编号不存在
+                if (i == 0) {
+                    vendor.setId(0l);
+                    //编号存在、需要更新
+                } else if (update){
+                    Long pr_id = getMapper().selectIdByCode(code, companyId);
+                    vendor.setId(pr_id);
+                    //编号存在、不需要处理
+                } else {
+                    continue;
+                }
+                //添加从表
+                if (data.size() > 0) {
+                    detno = 1;
+                    for (DataImportDetail productDetail : data) {
+                        Vendorcontact detail = JSONObject.parseObject(productDetail.getDd_detaildata(), Vendorcontact.class);
+                        if (null != detail) {
+                            detail.setVc_veid(vendor.getId());
+                            detail.setVc_detno(detno);
+                            detno++;
+                            details_.add(detail);
+                        }
+                    }
+                }
+                listDTO.setMain(vendor);
+                listDTO.setItems(details_);
+                list.add(listDTO);
+            }
+            if (err.length() > 0) {
+                dataImportMapper.updateDataImportError(err.toString(), id);
+                throw new BizException(12345, err.toString());
+            }
+            for (VendorListDTO  dto : list) {
+                saveFormData(dto);
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+
     private List<VendorDTO> getList(ListReqDTO listReqDTO){
         Long companyId = BaseContextHolder.getCompanyId();
         String condition = listReqDTO.getFinalCondition();

+ 8 - 10
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/WarehouseServiceImpl.java

@@ -21,7 +21,6 @@ import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.HashMap;
@@ -172,8 +171,8 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
             }
             Warehouse warehouse = new Warehouse();
             warehouse.setId(id);
-            warehouse.setWh_status(Status.CLOSE.getDisplay());
-            warehouse.setWh_statuscode(Status.CLOSE.name());
+            warehouse.setWh_status(Status.BANNED.getDisplay());
+            warehouse.setWh_statuscode(Status.BANNED.name());
             warehouse.setUpdaterId(BaseContextHolder.getUserId());
             warehouse.setUpdateTime(new Date());
 
@@ -195,12 +194,12 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
             if(warehouse == null){
                 throw new BizException(BizExceptionCode.NO_DATA);
             }
-            if (Status.CLOSE.name().equals(warehouse.getWh_statuscode())){
+            if (Status.BANNED.name().equals(warehouse.getWh_statuscode())){
                 String code = warehouse.getWh_code();
                 warehouse = new Warehouse();
                 warehouse.setId(id);
-                warehouse.setWh_statuscode(Status.OPEN.name());
-                warehouse.setWh_status(Status.OPEN.getDisplay());
+                warehouse.setWh_statuscode(Status.ENABLE.name());
+                warehouse.setWh_status(Status.ENABLE.getDisplay());
                 warehouse.setUpdaterId(BaseContextHolder.getUserId());
                 warehouse.setUpdateTime(new Date());
 
@@ -210,7 +209,7 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
                 messageLogService.customizeLog(docBaseDTO, Operation.ENABLE);
                 return docBaseDTO;
             }else {
-                throw new BizException(BizExceptionCode.BIZ_OPEN);
+                throw new BizException(BizExceptionCode.BIZ_ENABLE);
             }
         }else {
             throw new BizException(BizExceptionCode.ILLEGAL_ID);
@@ -233,8 +232,7 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
     public void delete(Long id) {
         //删除前检测物料是否存在默认仓库
         Long companyId = BaseContextHolder.getCompanyId();
-        companyId = 1l;
-        Integer num = 0;
+        int num = 0;
         num = warehouseMapper.deleteCheckProduct(id, companyId);
         if (num > 0) {
             throw new BizException(BizExceptionCode.PRODUCT_HAS_WAREHOUSE);
@@ -255,8 +253,8 @@ public class WarehouseServiceImpl extends CommonBaseServiceImpl<WarehouseMapper,
     private void singleDelete(Long id) {
         if (null != id) {
             //主表删除
-            getMapper().deleteByPrimaryKey(id);
             DocBaseDTO docBaseDTO = getBaseDTOById(id);
+            getMapper().deleteByPrimaryKey(id);
             //日志
             messageLogService.delete(docBaseDTO);
         }

+ 1 - 1
applications/document/document-server/src/main/resources/config/application-docker-prod.yml

@@ -13,7 +13,7 @@ spring:
     username: saas
     password: select123***
   datasource:
-    url: jdbc:mysql://10.10.100.18:3306/saas_biz?characterEncoding=utf-8&useSSL=false
+    url: jdbc:mysql://10.10.100.18:3306/saas_biz?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
     username: saas
     password: select111***
   redis:

+ 12 - 0
applications/document/document-server/src/main/resources/config/application-docker-test.yml

@@ -0,0 +1,12 @@
+eureka:
+  instance:
+    hostname: saas-document-server-test
+    prefer-ip-address: false
+  client:
+    serviceUrl:
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-test:8515/eureka/
+spring:
+  rabbitmq:
+    virtual-host: test
+server:
+  port: 9495

+ 9 - 0
applications/document/document-server/src/main/resources/logback-spring.xml

@@ -104,6 +104,15 @@
         </root>
     </springProfile>
 
+    <springProfile name="docker-test">
+        <logger name="org.springframework" level="WARN"/>
+        <logger name="com.usoftchina.saas" level="WARN"/>
+        <root level="WARN">
+            <appender-ref ref="CONSOLE_APPENDER"/>
+            <appender-ref ref="JSON_APPENDER"/>
+        </root>
+    </springProfile>
+
     <springProfile name="docker-prod">
         <logger name="org.springframework" level="WARN"/>
         <logger name="com.usoftchina.saas" level="WARN"/>

+ 14 - 6
applications/document/document-server/src/main/resources/mapper/AddressMapper.xml

@@ -204,10 +204,18 @@
         </if>
     </where>
   </select>
-    <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
-        SELECT AD_ADDRESS display,AD_ADDRESS value FROM ADDRESS WHERE COMPANYID=#{companyId}
-    </select>
-    <select id="getCountFromPurchase" resultType="int">
-        SELECT COUNT(*) FROM PURCHASE WHERE PU_SHIPADDRESSCODE = (SELECT AD_ADDRESS FROM ADDRESS WHERE AD_ID = #{id}) AND companyId = #{companyId}
-    </select>
+  <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
+      SELECT AD_ADDRESS display,AD_ADDRESS value FROM ADDRESS WHERE COMPANYID=#{companyId}
+  </select>
+  <select id="getCountFromPurchase" resultType="int">
+      SELECT COUNT(*) FROM PURCHASE WHERE PU_SHIPADDRESSCODE = (SELECT AD_ADDRESS FROM ADDRESS WHERE AD_ID = #{id}) AND companyId = #{companyId}
+  </select>
+
+  <update id="setDefault">
+    update address set ad_default = 1 where ad_id=#{id} and companyId=#{companyId};
+    update address set ad_default = 0 where ad_id!=#{id} and companyId=#{companyId};
+  </update>
+
+
+
 </mapper>

+ 14 - 2
applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -209,6 +209,9 @@
         #{creatorName,jdbcType=VARCHAR},
       </if>
     </trim>
+    <selectKey resultType="Long" keyProperty="id" order="AFTER">
+      SELECT LAST_INSERT_ID()
+    </selectKey>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
     update bankinformation
@@ -321,8 +324,9 @@
     </select>
 
 
-  <select id="selectBankcode" parameterType="java.lang.String" resultType="java.lang.String">
-        select bk_bankcode from bankinformation where bk_bankcode = #{bk_bankcode,jdbcType=VARCHAR}
+  <select id="selectBankcode" resultType="java.lang.String">
+        select bk_bankcode from bankinformation where
+        bk_bankcode = #{bk_bankcode,jdbcType=VARCHAR} and companyId = #{companyId}
     </select>
 
   <select id="selectBankId" parameterType="java.lang.String" resultType="java.lang.Long">
@@ -343,4 +347,12 @@
     <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
     <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
   </parameterMap>
+
+
+  <select id="validateCodeWhenInsert" resultType="int">
+        select count(*) from bankinformation where bk_bankcode = #{code} and companyId =#{companyId}
+    </select>
+  <select id="validateCodeWhenUpdate" resultType="int" >
+        select count(*) from bankinformation where bk_bankcode = #{code} and bk_id != #{id} and companyId =#{companyId}
+    </select>
 </mapper>

+ 2 - 0
applications/document/document-server/src/main/resources/mapper/CustomerListMapper.xml

@@ -4,6 +4,7 @@
   <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.CustomerList">
     <id column="cu_id" jdbcType="INTEGER" property="id" />
     <result column="cu_code" jdbcType="VARCHAR" property="cu_code" />
+    <result column="cu_shortname" jdbcType="VARCHAR" property="cu_shortname"/>
     <result column="cu_name" jdbcType="VARCHAR" property="cu_name" />
     <result column="cu_uu" jdbcType="VARCHAR" property="cu_uu" />
     <result column="cu_type" jdbcType="VARCHAR" property="cu_type" />
@@ -36,6 +37,7 @@
     <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
     <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
     <result column="createTime" property="createTime" jdbcType="TIMESTAMP"/>
+    <result column="cu_remark" property="cu_remark" jdbcType="VARCHAR"/>
   </resultMap>
 
 

+ 25 - 32
applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml

@@ -4,6 +4,7 @@
   <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Customer">
     <id column="cu_id" jdbcType="INTEGER" property="id" />
     <result column="cu_code" jdbcType="VARCHAR" property="cu_code" />
+    <result column="cu_shortname" jdbcType="VARCHAR" property="cu_shortname" />
     <result column="cu_name" jdbcType="VARCHAR" property="cu_name" />
     <result column="cu_uu" jdbcType="VARCHAR" property="cu_uu" />
     <result column="cu_type" jdbcType="VARCHAR" property="cu_type" />
@@ -29,13 +30,14 @@
     <result column="cu_leftamount" jdbcType="DOUBLE" property="cu_leftamount" />
     <result column="cu_recamount" jdbcType="DOUBLE" property="cu_recamount" />
     <result column="cu_preamount" jdbcType="DOUBLE" property="cu_preamount" />
+    <result column="cu_remark" jdbcType="VARCHAR" property="cu_remark" />
   </resultMap>
   <sql id="Base_Column_List">
-    cu_id, cu_code, cu_name, cu_uu, cu_type, cu_begindate, cu_beginaramount, cu_beginprerecamount, 
+    cu_id, cu_code,cu_shortname, cu_name, cu_uu, cu_type, cu_begindate, cu_beginaramount, cu_beginprerecamount,
     cu_promisedays, cu_taxrate, cu_sellerid, cu_sellercode, cu_sellername, cu_credit, 
     cu_status, cu_statuscode, companyid,
     updaterid, updatetime, cu_text1, cu_text2, cu_text3, cu_text4, cu_text5, cu_leftamount, 
-    cu_recamount,cu_preamount
+    cu_recamount,cu_preamount,cu_remark
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     select
@@ -57,6 +59,9 @@
       <if test="cu_code != null">
         cu_code,
       </if>
+      <if test="cu_shortname != null">
+        cu_shortname,
+      </if>
       <if test="cu_name != null">
         cu_name,
       </if>
@@ -141,12 +146,18 @@
       <if test="creatorName != null" >
         creatorName,
       </if>
+      <if test="cu_remark!=null">
+        cu_remark,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
 
       <if test="cu_code != null">
         #{cu_code,jdbcType=VARCHAR},
       </if>
+      <if test="cu_shortname !=null">
+        #{cu_shortname,jdbcType=VARCHAR}
+      </if>
       <if test="cu_name != null">
         #{cu_name,jdbcType=VARCHAR},
       </if>
@@ -231,6 +242,9 @@
       <if test="creatorName != null" >
         #{creatorName,jdbcType=VARCHAR},
       </if>
+      <if test="cu_remark !=null">
+        #{cu_remark,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Customer">
@@ -239,6 +253,9 @@
       <if test="cu_code != null">
         cu_code = #{cu_code,jdbcType=VARCHAR},
       </if>
+      <if test="cu_shortname !=null">
+        cu_shortname = #{cu_shortname,jdbcType=VARCHAR},
+      </if>
       <if test="cu_name != null">
         cu_name = #{cu_name,jdbcType=VARCHAR},
       </if>
@@ -314,39 +331,12 @@
       <if test="cu_preamount != null">
         cu_preamount = #{cu_preamount,jdbcType=DOUBLE},
       </if>
+      <if test="cu_remark != null">
+        cu_remark = #{cu_remark,jdbcType=VARCHAR},
+      </if>
     </set>
     where cu_id = #{id,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Customer">
-    update customer
-    set cu_code = #{cu_code,jdbcType=VARCHAR},
-      cu_name = #{cu_name,jdbcType=VARCHAR},
-      cu_uu = #{cu_uu,jdbcType=VARCHAR},
-      cu_type = #{cu_type,jdbcType=VARCHAR},
-      cu_begindate = #{cu_begindate,jdbcType=TIMESTAMP},
-      cu_beginaramount = #{cu_beginaramount,jdbcType=DOUBLE},
-      cu_beginprerecamount = #{cu_beginprerecamount,jdbcType=DOUBLE},
-      cu_promisedays = #{cu_promisedays,jdbcType=DOUBLE},
-      cu_taxrate = #{cu_taxrate,jdbcType=DOUBLE},
-      cu_sellerid = #{cu_sellerid,jdbcType=INTEGER},
-      cu_sellercode = #{cu_sellercode,jdbcType=VARCHAR},
-      cu_sellername = #{cu_sellername,jdbcType=VARCHAR},
-      cu_credit = #{cu_credit,jdbcType=DOUBLE},
-      cu_status = #{cu_status,jdbcType=VARCHAR},
-      cu_statuscode = #{cu_statuscode,jdbcType=VARCHAR},
-      companyid = #{companyid,jdbcType=INTEGER},
-      updaterid = #{updaterid,jdbcType=INTEGER},
-      updatetime = #{updatetime,jdbcType=TIMESTAMP},
-      cu_text1 = #{cu_text1,jdbcType=VARCHAR},
-      cu_text2 = #{cu_text2,jdbcType=VARCHAR},
-      cu_text3 = #{cu_text3,jdbcType=VARCHAR},
-      cu_text4 = #{cu_text4,jdbcType=VARCHAR},
-      cu_text5 = #{cu_text5,jdbcType=VARCHAR},
-      cu_leftamount = #{cu_leftamount,jdbcType=DOUBLE},
-      cu_recamount = #{cu_recamount,jdbcType=DOUBLE},
-      cu_preamount = #{cu_preamount,jdbcType=DOUBLE}
-    where cu_id = #{id,jdbcType=INTEGER}
-  </update>
 
   <select id="validateCodeWhenInsert" resultType="int">
     select count(1) from customer where cu_code = #{code} and companyId =#{companyId}
@@ -397,5 +387,8 @@
     SELECT ca_address display,ca_address value FROM customeraddress WHERE ca_cuid=#{id} and COMPANYID=#{companyId} order by ca_id desc
   </select>
 
+  <select id="selectIdByCode" resultType="long">
+    select ve_id from VENDOR where ve_code=#{code} and companyId=#{companyId}
+  </select>
 
 </mapper>

+ 105 - 0
applications/document/document-server/src/main/resources/mapper/DataImportMapper.xml

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.document.mapper.DataImportMapper" >
+  <resultMap id="DetailMap" type="com.usoftchina.saas.commons.po.DataImportDetail" >
+    <id column="dd_id" property="dd_id" jdbcType="INTEGER" />
+    <result column="dd_maindata" property="dd_maindata" jdbcType="VARCHAR" />
+    <result column="dd_detno" property="dd_detno" jdbcType="INTEGER" />
+    <result column="dd_diid" property="dd_diid" jdbcType="INTEGER" />
+    <result column="dd_checked" property="dd_checked" jdbcType="INTEGER" />
+    <result column="dd_success" property="dd_success" jdbcType="INTEGER" />
+    <result column="dd_toformal" property="dd_toformal" jdbcType="INTEGER" />
+    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="dd_detaildata" property="dd_detaildata" jdbcType="VARCHAR" />
+    <result column="dd_codevalue" property="dd_codevalue" jdbcType="VARCHAR" />
+  </resultMap>
+
+  <delete id="deleteByCaller">
+  delete from data_import where di_caller=#{caller} and companyid=#{companyid} and
+  il_toformal=0 and il_result is not null
+</delete>
+
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.DataImport" >
+    <selectKey  resultType="java.lang.Integer" keyProperty="di_id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    insert into data_import
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        di_caller,
+      </if>
+      <if test="companyid != null" >
+        companyid,
+      </if>
+      <if test="di_date != null" >
+        di_date,
+      </if>
+      <if test="di_count != null" >
+        di_count,
+      </if>
+      <if test="di_result != null" >
+        di_result,
+      </if>
+      <if test="di_success != null" >
+        di_success,
+      </if>
+      <if test="di_man != null" >
+        di_man,
+      </if>
+      <if test="di_toformal != null" >
+        di_toformal,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="di_caller != null" >
+        #{di_caller,jdbcType=VARCHAR},
+      </if>
+      <if test="companyid != null" >
+        #{companyid,jdbcType=INTEGER},
+      </if>
+      <if test="di_date != null" >
+        #{di_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="di_count != null" >
+        #{di_count,jdbcType=INTEGER},
+      </if>
+      <if test="di_result != null" >
+        #{di_result,jdbcType=VARCHAR},
+      </if>
+      <if test="di_success != null" >
+        #{di_success,jdbcType=INTEGER},
+      </if>
+      <if test="di_man != null" >
+        #{di_man,jdbcType=VARCHAR},
+      </if>
+      <if test="di_toformal != null" >
+        #{di_toformal,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+
+  <update id="updateErr" >
+  update data_import
+  set
+  di_result = #{err},
+  di_success = 0,
+  where di_id = #{id}
+</update>
+
+<select id="selectDataById" resultMap="DetailMap">
+  select * from  data_importdetail
+  where dd_diid = #{id}
+</select>
+
+  <select id="selectMainBycode" resultMap="DetailMap">
+    select * from  data_importdetail
+    where dd_codevalue = #{code} and dd_diid=#{id} and ifnull(dd_success,0)=0 and dd_maindata is not null and companyid=#{companyid}
+  </select>
+
+  <update id="updateDataImport" parameterType="integer">
+    update data_import set di_toformal=1,di_success=1  where di_id=#{id}
+  </update>
+  <update id="updateDataImportError">
+    update data_import set di_toformal=1,di_result=#{err} where di_id=#{id}
+  </update>
+</mapper>

+ 6 - 2
applications/document/document-server/src/main/resources/mapper/EmployeeMapper.xml

@@ -239,9 +239,13 @@
   <select id="validateNameAndCodeWhenInsert" resultType="int">
     select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and companyId =#{companyId}
   </select>
-  <select id="validateNameAndCodeWhenUpdate" resultType="int" >
-    select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and em_id !=#{id} and companyId =#{companyId}
+  
+  <select id="validateNameAndCodeWhenUpdate" resultType="int">
+    select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and em_id !=#{id}  and companyId =#{companyId}
   </select>
 
+  <select id="selectByName" resultMap="BaseResultMap">
+    select * from employee where em_name = #{name} and companyId=#{companyId}
+  </select>
 
 </mapper>

+ 19 - 0
applications/document/document-server/src/main/resources/mapper/ProductMapper.xml

@@ -476,6 +476,21 @@
         </where>
         ORDER BY PR_ID DESC
     </select>
+    <select id="selectReserveCostByIgnoreWarehouse" resultMap="ProdReserveCostResultMap">
+        select pr_code,pr_spec,pr_detail,pr_unit,sum(pw_onhand) pw_onhand,sum(pw_amount) pw_amount
+        from productWH tab left join Product on pw_prodcode=pr_code left join warehouse on pw_whid=wh_id
+        <where>
+            <if test="con!=null">
+                ${con}
+            </if>
+            <if test="companyId!=null">
+                and tab.companyId=#{companyId} and Product.companyId=#{companyId} and warehouse.companyId=#{companyId}
+                and pw_onhand!=0
+            </if>
+        </where>
+        group by pr_code,pr_spec,pr_detail,pr_unit,pr_id
+        ORDER BY PR_ID DESC
+    </select>
     <select id="getCountFromPurc" resultType="int">
         SELECT COUNT(*) FROM PURCHASEDETAIL
         WHERE PD_PRODID = #{id} AND COMPANYID=#{companyId}
@@ -901,5 +916,9 @@
     <delete id="deleteProdIODetailByCode">
         DELETE FROM PRODIODETAIL WHERE PD_PIID IN (SELECT PI_ID FROM PRODINOUT WHERE PI_INOUTNO=#{code} AND PRODINOUT.COMPANYID = #{companyId}) AND PRODIODETAIL.COMPANYID = #{companyId}
     </delete>
+
+    <select id="selectIdByCode" resultType="long">
+        select pr_id from product where pr_code=#{code} and companyId=#{companyId}
+    </select>
 </mapper>
 

+ 61 - 58
applications/document/document-server/src/main/resources/mapper/VendorMapper.xml

@@ -4,6 +4,7 @@
     <resultMap id="VendorResultMapper" type="com.usoftchina.saas.document.entities.Vendor">
         <id column="ve_id" property="id" jdbcType="INTEGER" />
         <result column="ve_code" property="ve_code" jdbcType="VARCHAR" />
+        <result column="ve_shortname" property="ve_shortname" jdbcType="VARCHAR"/>
         <result column="ve_uu" property="ve_uu" jdbcType="VARCHAR" />
         <result column="ve_name" property="ve_name" jdbcType="VARCHAR" />
         <result column="ve_type" property="ve_type" jdbcType="VARCHAR" />
@@ -29,13 +30,16 @@
         <result column="ve_leftamount" property="ve_leftamount" jdbcType="DOUBLE" />
         <result column="ve_beginym" property="ve_beginym" jdbcType="INTEGER" />
         <result column="ve_preamount" property="ve_preamount" jdbcType="DOUBLE" />
+        <result column="ve_remark" property="ve_remark" jdbcType="VARCHAR" />
     </resultMap>
     <resultMap id="VendorDTOResultMapper" type="com.usoftchina.saas.document.dto.VendorDTO">
         <id column="ve_id" property="id" jdbcType="INTEGER" />
         <result column="ve_code" property="ve_code" jdbcType="VARCHAR" />
+        <result column="ve_shortname" property="ve_shortname" jdbcType="VARCHAR"/>
         <result column="ve_name" property="ve_name" jdbcType="VARCHAR" />
         <result column="ve_type" property="ve_type" jdbcType="VARCHAR" />
         <result column="ve_status" property="ve_status" jdbcType="VARCHAR" />
+        <result column="ve_remark" property="ve_remark" jdbcType="VARCHAR" />
     </resultMap>
 
     <select id="getVendorsByCondition" resultMap="VendorDTOResultMapper">
@@ -55,6 +59,7 @@
         <id column="ve_id" property="id" jdbcType="INTEGER" />
         <result column="ve_code" property="ve_code" jdbcType="VARCHAR" />
         <result column="ve_uu" property="ve_uu" jdbcType="VARCHAR" />
+        <result column="ve_shortname" property="ve_shortname" jdbcType="VARCHAR"/>
         <result column="ve_name" property="ve_name" jdbcType="VARCHAR" />
         <result column="ve_type" property="ve_type" jdbcType="VARCHAR" />
         <result column="ve_begindate" property="ve_begindate" jdbcType="TIMESTAMP" />
@@ -73,6 +78,10 @@
         <result column="ve_text3" property="ve_text3" jdbcType="VARCHAR" />
         <result column="ve_text4" property="ve_text4" jdbcType="VARCHAR" />
         <result column="ve_text5" property="ve_text5" jdbcType="VARCHAR" />
+        <result column="ve_remark" property="ve_remark" jdbcType="VARCHAR" />
+        <result column="ve_buyerid" property="ve_buyerid" jdbcType="INTEGER" />
+        <result column="ve_buyercode" property="ve_buyercode" jdbcType="VARCHAR" />
+        <result column="ve_buyername" property="ve_buyername" jdbcType="VARCHAR" />
         <result column="vc_veid" property="vc_veid" jdbcType="INTEGER" />
         <result column="vc_detno" property="vc_detno" jdbcType="INTEGER" />
         <result column="vc_name" property="vc_name" jdbcType="VARCHAR" />
@@ -99,10 +108,11 @@
     </select>
 
     <sql id="Base_Column_List" >
-        ve_id, ve_code, ve_name, ve_uu, ve_type, ve_begindate, ve_beginapamount, ve_beginprepayamount,
+        ve_id, ve_code, ve_shortname,ve_name, ve_uu, ve_type, ve_begindate, ve_beginapamount, ve_beginprepayamount,
         ve_promisedays, ve_taxrate, ve_nsrzh, ve_bankaccount, ve_bankcode, ve_status, ve_statuscode,
         companyId, updaterId, updateTime, ve_text1,
-        ve_text2, ve_text3, ve_text4, ve_text5, ve_payamount, ve_leftamount, ve_beginym, ve_preamount
+        ve_text2, ve_text3, ve_text4, ve_text5, ve_payamount, ve_leftamount, ve_beginym, ve_preamount,ve_remark,
+        ve_buyerid,ve_buyercode,ve_buyername
     </sql>
     <select id="selectByPrimaryKey" resultMap="VendorResultMapper" parameterType="java.lang.Long" >
         select
@@ -114,31 +124,6 @@
         delete from vendor
         where ve_id = #{id}
     </delete>
-    <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Vendor" >
-        insert into vendor (ve_code, ve_name,
-        ve_uu, ve_type, ve_begindate,
-        ve_beginapamount, ve_beginprepayamount,
-        ve_promisedays, ve_taxrate, ve_nsrzh,
-        ve_bankaccount, ve_bankcode, ve_status,
-        ve_statuscode, companyId, updaterId,
-        updateTime, ve_text1, ve_text2,
-        ve_text3, ve_text4, ve_text5,
-        ve_payamount, ve_leftamount, ve_beginym ,ve_preamount,
-        creatorId,createTime,creatorName
-        )
-        values (#{ve_code,jdbcType=VARCHAR}, #{ve_name,jdbcType=VARCHAR},
-        #{ve_uu,jdbcType=VARCHAR}, #{ve_type,jdbcType=VARCHAR}, #{ve_begindate,jdbcType=TIMESTAMP},
-        #{ve_beginapamount,jdbcType=DOUBLE}, #{ve_beginprepayamount,jdbcType=DOUBLE},
-        #{ve_promisedays,jdbcType=DECIMAL}, #{ve_taxrate,jdbcType=DOUBLE}, #{ve_nsrzh,jdbcType=VARCHAR},
-        #{ve_bankaccount,jdbcType=VARCHAR}, #{ve_bankcode,jdbcType=VARCHAR}, #{ve_status,jdbcType=VARCHAR},
-        #{ve_statuscode,jdbcType=VARCHAR}, #{companyId,jdbcType=DECIMAL}, #{updaterId,jdbcType=DECIMAL},
-        #{updateTime,jdbcType=TIMESTAMP}, #{ve_text1,jdbcType=VARCHAR}, #{ve_text2,jdbcType=VARCHAR},
-        #{ve_text3,jdbcType=VARCHAR}, #{ve_text4,jdbcType=VARCHAR}, #{ve_text5,jdbcType=VARCHAR},
-        #{ve_payamount,jdbcType=DOUBLE}, #{ve_leftamount,jdbcType=DOUBLE}, #{ve_beginym,jdbcType=INTEGER},
-        #{ve_preamount,jdbcType=DOUBLE},
-        #{creatorId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{creatorName,jdbcType=VARCHAR}
-        )
-    </insert>
     <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Vendor" >
         <selectKey resultType="java.lang.Long" keyProperty="id">
             SELECT LAST_INSERT_ID() AS ID
@@ -148,6 +133,9 @@
             <if test="ve_code != null" >
                 ve_code,
             </if>
+            <if test="ve_shortname !=null">
+                ve_shortname,
+            </if>
             <if test="ve_name != null" >
                 ve_name,
             </if>
@@ -232,11 +220,26 @@
             <if test="creatorName != null" >
                 creatorName,
             </if>
+            <if test="ve_remark!=null">
+                ve_remark,
+            </if>
+            <if test="ve_buyerid!=null">
+                ve_buyerid,
+            </if>
+            <if test="ve_buyercode!=null">
+                ve_buyercode,
+            </if>
+            <if test="ve_buyername!=null">
+                ve_buyername
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
             <if test="ve_code != null" >
                 #{ve_code,jdbcType=VARCHAR},
             </if>
+            <if test="ve_shortname !=null">
+                #{ve_shortname,jdbcType=VARCHAR},
+            </if>
             <if test="ve_name != null" >
                 #{ve_name,jdbcType=VARCHAR},
             </if>
@@ -321,6 +324,18 @@
             <if test="creatorName != null" >
                 #{creatorName,jdbcType=VARCHAR},
             </if>
+            <if test="ve_remark != null">
+                #{ve_remark,jdbcType=VARCHAR},
+            </if>
+            <if test="ve_buyerid != null">
+                #{ve_buyerid,jdbcType=INTEGER},
+            </if>
+            <if test="ve_buyercode != null">
+                #{ve_buyercode,jdbcType=VARCHAR},
+            </if>
+            <if test="ve_buyername != null">
+                #{ve_buyername,jdbcType=VARCHAR}
+            </if>
         </trim>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Vendor" >
@@ -329,6 +344,9 @@
             <if test="ve_code != null" >
                 ve_code = #{ve_code,jdbcType=VARCHAR},
             </if>
+            <if test="ve_shortname !=null">
+                ve_shortname = #{ve_shortname,jdbcType=VARCHAR},
+            </if>
             <if test="ve_name != null" >
                 ve_name = #{ve_name,jdbcType=VARCHAR},
             </if>
@@ -404,40 +422,21 @@
             <if test="ve_preamount !=null" >
                 #{ve_preamount,jdbcType=DOUBLE},
             </if>
+            <if test="ve_remark != null" >
+                ve_remark = #{ve_remark,jdbcType=VARCHAR},
+            </if>
+            <if test="ve_buyerid != null" >
+                ve_buyerid = #{ve_buyerid,jdbcType=INTEGER},
+            </if>
+            <if test="ve_buyercode != null" >
+                ve_buyercode = #{ve_buyercode,jdbcType=VARCHAR},
+            </if>
+            <if test="ve_buyername != null" >
+                ve_buyername = #{ve_buyername,jdbcType=VARCHAR}
+            </if>
         </set>
         where ve_id = #{id}
     </update>
-    <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Vendor" >
-        update vendor
-        set ve_code = #{ve_code,jdbcType=VARCHAR},
-        ve_name = #{ve_name,jdbcType=VARCHAR},
-        ve_uu = #{ve_uu,jdbcType=VARCHAR},
-        ve_type = #{ve_type,jdbcType=VARCHAR},
-        ve_begindate = #{ve_begindate,jdbcType=TIMESTAMP},
-        ve_beginapamount = #{ve_beginapamount,jdbcType=DOUBLE},
-        ve_beginprepayamount = #{ve_beginprepayamount,jdbcType=DOUBLE},
-        ve_promisedays = #{ve_promisedays,jdbcType=DECIMAL},
-        ve_taxrate = #{ve_taxrate,jdbcType=DOUBLE},
-        ve_nsrzh = #{ve_nsrzh,jdbcType=VARCHAR},
-        ve_bankaccount = #{ve_bankaccount,jdbcType=VARCHAR},
-        ve_bankcode = #{ve_bankcode,jdbcType=VARCHAR},
-        ve_status = #{ve_status,jdbcType=VARCHAR},
-        ve_statuscode = #{ve_statuscode,jdbcType=VARCHAR},
-        companyId = #{companyId,jdbcType=DECIMAL},
-        updaterId = #{updaterId,jdbcType=DECIMAL},
-        updateTime = #{updateTime,jdbcType=TIMESTAMP},
-        ve_text1 = #{ve_text1,jdbcType=VARCHAR},
-        ve_text2 = #{ve_text2,jdbcType=VARCHAR},
-        ve_text3 = #{ve_text3,jdbcType=VARCHAR},
-        ve_text4 = #{ve_text4,jdbcType=VARCHAR},
-        ve_text5 = #{ve_text5,jdbcType=VARCHAR},
-        ve_payamount = #{ve_payamount,jdbcType=DOUBLE},
-        ve_leftamount = #{ve_leftamount,jdbcType=DOUBLE},
-        ve_beginym = #{ve_beginym,jdbcType=INTEGER},
-        ve_preamount =#{ve_preamount,jdbcType=DOUBLE}
-        where ve_id = #{id}
-    </update>
-
     <select id="validateCodeWhenInsert" resultType="int">
         select count(*) from VENDOR where VE_CODE = #{code} and companyId =#{companyId}
     </select>
@@ -469,5 +468,9 @@
         <parameter property="v_companyid" jdbcType="INTEGER" mode="IN" />
         <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
     </parameterMap>
+
+    <select id="selectIdByCode" resultType="long">
+        select ve_id from VENDOR where ve_code=#{code} and companyId=#{companyId}
+    </select>
 </mapper>
 

+ 3 - 0
applications/document/document-server/src/main/resources/mapper/WarehouseMapper.xml

@@ -370,5 +370,8 @@
     <select id="deleteCheckProdIO" resultType="int">
         SELECT COUNT(*) FROM PRODIODETAIL WHERE pd_whid = #{id} and companyid = #{companyId}
     </select>
+    <select id="selectWareHouse" resultMap="WarehouseResultMapper">
+        select * from warehouse where wh_code=#{code} and companyId=#{companyId}
+    </select>
 </mapper>
 

+ 20 - 0
applications/money/money-dto/src/main/java/com/usoftchina/saas/money/dto/VerificationDTO.java

@@ -68,6 +68,26 @@ public class VerificationDTO extends  CommonBaseDTO implements Serializable {
 
     private String vc_text5;
 
+    private Date vc_auditdate;
+
+    private String vc_auditman;
+
+    public Date getVc_auditdate() {
+        return vc_auditdate;
+    }
+
+    public void setVc_auditdate(Date vc_auditdate) {
+        this.vc_auditdate = vc_auditdate;
+    }
+
+    public String getVc_auditman() {
+        return vc_auditman;
+    }
+
+    public void setVc_auditman(String vc_auditman) {
+        this.vc_auditman = vc_auditman;
+    }
+
     public Integer getVc_id() {
         return vc_id;
     }

+ 29 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/MoneyReportColltroller.java

@@ -58,10 +58,38 @@ public class MoneyReportColltroller {
         return Result.success(listData);
     }
 
-    //冲账明细表
+    //核销明细表
     @GetMapping("/accountdetails")
     public Result accountdetails(PageRequest page, ListReqDTO req) {
         Map<String, Object> listData = moneyReportService.accountdetails(page, req);
         return Result.success(listData);
     }
+
+    //应付总账
+    @GetMapping("/vendormonthdetails")
+    public Result vendormonthdetails(PageRequest page, ListReqDTO req) {
+        Map<String, Object> listData = moneyReportService.vendormonthdetails(page, req);
+        return Result.success(listData);
+    }
+
+    //应收总账
+    @GetMapping("/custormonthdetails")
+    public Result custormonthdetails(PageRequest page, ListReqDTO req) {
+        Map<String, Object> listData = moneyReportService.custormonthdetails(page, req);
+        return Result.success(listData);
+    }
+
+    //其他收支明细表
+    @GetMapping("/othrinoutdetails")
+    public Result othrinoutdetails(PageRequest page, ListReqDTO req) {
+        Map<String, Object> listData = moneyReportService.othrinoutdetails(page, req);
+        return Result.success(listData);
+    }
+
+    //毛利润分析表
+    @GetMapping("/profitdetails")
+    public Result profitdetails(PageRequest page, ListReqDTO req) {
+        Map<String, Object> listData = moneyReportService.profitdetails(page, req);
+        return Result.success(listData);
+    }
 }

+ 14 - 4
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/VerificationController.java

@@ -13,6 +13,7 @@ import com.usoftchina.saas.money.po.VerificationList;
 import com.usoftchina.saas.money.service.VerificationService;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 /**
@@ -58,6 +59,7 @@ public class VerificationController {
      * @param form
      * @return
      */
+    @Transactional
     @RequestMapping("/save")
     public Result<DocSavedDTO> saveFormData(@RequestBody VerificationFormDTO form) {
         DocBaseDTO base = verificationService.saveFormData(form);
@@ -69,7 +71,8 @@ public class VerificationController {
      * @param id
      * @return
      */
-    @RequestMapping("/delete/{id}")
+    @Transactional
+    @PostMapping("/delete/{id}")
     public Result delete(@PathVariable("id") Long id) {
         verificationService.delete(id);
         return Result.success();
@@ -80,7 +83,8 @@ public class VerificationController {
      * @param id
      * @return
      */
-    @RequestMapping("/deleteDetail1/{id}")
+    @Transactional
+    @PostMapping("/deleteDetail1/{id}")
     public Result deleteDetail1(@PathVariable("id") Long id) {
         verificationService.deleteDetail1(id);
         return Result.success();
@@ -91,37 +95,43 @@ public class VerificationController {
      * @param id
      * @return
      */
-    @RequestMapping("/deleteDetail2/{id}")
+    @Transactional
+    @PostMapping("/deleteDetail2/{id}")
     public Result deleteDetail2(@PathVariable("id") Long id) {
         verificationService.deleteDetail2(id);
         return Result.success();
     }
 
+    @Transactional
     @RequestMapping("/audit")
     public Result audit(@RequestBody VerificationFormDTO formDTO) {
         DocBaseDTO audit = verificationService.audit(formDTO);
         return Result.success(audit);
     }
 
+    @Transactional
     @RequestMapping("/unAudit/{id}")
     public Result resAudit(@PathVariable("id") Long id) {
         verificationService.resAudit(id);
         return Result.success();
     }
 
+    @Transactional
     @RequestMapping("/batchAudit")
     public Result batchAudit(@RequestBody  BatchDealBaseDTO body) {
         verificationService.batchAudit(body);
         return Result.success();
     }
 
+    @Transactional
     @RequestMapping("/batchUnAudit")
     public Result batchUnAudit(@RequestBody BatchDealBaseDTO body) {
         verificationService.batchUnAudit(body);
         return Result.success();
     }
 
-    @RequestMapping("/batchDelete")
+    @Transactional
+    @PostMapping("/batchDelete")
     public Result batchDelete(@RequestBody BatchDealBaseDTO body) {
         verificationService.batchDelete(body);
         return Result.success();

+ 5 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/BanksubledgerMapper.java

@@ -38,5 +38,9 @@ public interface BanksubledgerMapper extends CommonBaseMapper<Banksubledger> {
 
     int updateBankcode(@Param("bk_thisamount") Double bk_thisamount, @Param("nowbalance") Double nowbalance,
                        @Param("bankcode") String bankcode, @Param("symbol") String symbol);
-    Double selectThisamount(String bankcode);
+    Double selectThisamount(@Param("bankcode") String bankcode, @Param("companyId") Long companyId);
+
+
+    List<Banksubledger> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
+    String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
 }

+ 12 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/CustmonthMapper.java

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.money.mapper;
+
+import com.usoftchina.saas.money.po.Custmonth;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface CustmonthMapper {
+    List<Custmonth> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
+    void callCustm(Map<String, Integer> map);
+}

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/CustomerCheckViewMapper.java

@@ -10,6 +10,6 @@ import java.util.List;
 public interface CustomerCheckViewMapper {
     List<CustomerCheckView> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
     String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
-    VendOrCustAdd selectCustAdd(@Param("sl_custid") Integer sl_vendid, @Param("sl_ym") Integer sl_ym, @Param("companyId") Long companyId);
+    VendOrCustAdd selectCustAdd(@Param("sl_custid") Integer sl_custid, @Param("cons") String cons, @Param("companyId") Long companyId);
     Integer getId(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 12 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VendmonthMapper.java

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.money.mapper;
+
+import com.usoftchina.saas.money.po.Vendmonth;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface VendmonthMapper {
+    List<Vendmonth> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
+    void callVend(Map<String, Integer> map);
+}

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VendorAcountViewMapper.java

@@ -9,6 +9,6 @@ import java.util.List;
 public interface VendorAcountViewMapper {
     List<VendorAcountView> selectByCondition(@Param("con")String con, @Param("companyId")Long companyId);
     String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
-    VendOrCustAdd selectVendAdd(@Param("sl_vendid") Integer sl_vendid, @Param("sl_ym") Integer sl_ym, @Param("companyId") Long companyId);
+    VendOrCustAdd selectVendAdd(@Param("sl_vendid") Integer sl_vendid, @Param("cons") String cons, @Param("companyId") Long companyId);
     Integer getId(@Param("code") String code, @Param("companyId") Long companyId);
 }

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VerificationMapper.java

@@ -37,7 +37,7 @@ public interface VerificationMapper extends CommonBaseMapper<Verification> {
 
     String selectCodeById(Long id);
 
-    String validateResAudit(Long id);
+    String validateResAudit(@Param("id") Long id);
 
     int validateSetAcount(@Param("detno") int detno,@Param("companyid")Long companyid);
 }

+ 103 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Custmonth.java

@@ -0,0 +1,103 @@
+package com.usoftchina.saas.money.po;
+
+public class Custmonth {
+    private Integer cm_id;
+
+    private Integer cm_yearmonth;
+
+    private Integer cm_custid;
+
+    private String cm_custcode;
+
+    private String cm_custname;
+
+    private Double cm_beginamount;
+
+    private Double cm_nowamount;
+
+    private Double cm_nowpreamount;
+
+    private Double cm_endamount;
+
+    private Integer companyid;
+
+    public Integer getCm_id() {
+        return cm_id;
+    }
+
+    public void setCm_id(Integer cm_id) {
+        this.cm_id = cm_id;
+    }
+
+    public Integer getCm_yearmonth() {
+        return cm_yearmonth;
+    }
+
+    public void setCm_yearmonth(Integer cm_yearmonth) {
+        this.cm_yearmonth = cm_yearmonth;
+    }
+
+    public Integer getCm_custid() {
+        return cm_custid;
+    }
+
+    public void setCm_custid(Integer cm_custid) {
+        this.cm_custid = cm_custid;
+    }
+
+    public String getCm_custcode() {
+        return cm_custcode;
+    }
+
+    public void setCm_custcode(String cm_custcode) {
+        this.cm_custcode = cm_custcode == null ? null : cm_custcode.trim();
+    }
+
+    public String getCm_custname() {
+        return cm_custname;
+    }
+
+    public void setCm_custname(String cm_custname) {
+        this.cm_custname = cm_custname == null ? null : cm_custname.trim();
+    }
+
+    public Double getCm_beginamount() {
+        return cm_beginamount;
+    }
+
+    public void setCm_beginamount(Double cm_beginamount) {
+        this.cm_beginamount = cm_beginamount;
+    }
+
+    public Double getCm_nowamount() {
+        return cm_nowamount;
+    }
+
+    public void setCm_nowamount(Double cm_nowamount) {
+        this.cm_nowamount = cm_nowamount;
+    }
+
+    public Double getCm_nowpreamount() {
+        return cm_nowpreamount;
+    }
+
+    public void setCm_nowpreamount(Double cm_nowpreamount) {
+        this.cm_nowpreamount = cm_nowpreamount;
+    }
+
+    public Double getCm_endamount() {
+        return cm_endamount;
+    }
+
+    public void setCm_endamount(Double cm_endamount) {
+        this.cm_endamount = cm_endamount;
+    }
+
+    public Integer getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Integer companyid) {
+        this.companyid = companyid;
+    }
+}

+ 103 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Vendmonth.java

@@ -0,0 +1,103 @@
+package com.usoftchina.saas.money.po;
+
+public class Vendmonth {
+    private Integer vm_id;
+
+    private Integer vm_yearmonth;
+
+    private Integer vm_vendid;
+
+    private String vm_vendcode;
+
+    private String vm_vendname;
+
+    private Double vm_beginamount;
+
+    private Double vm_nowamount;
+
+    private Double vm_nowpreamount;
+
+    private Double vm_endamount;
+
+    private Integer companyid;
+
+    public Integer getVm_id() {
+        return vm_id;
+    }
+
+    public void setVm_id(Integer vm_id) {
+        this.vm_id = vm_id;
+    }
+
+    public Integer getVm_yearmonth() {
+        return vm_yearmonth;
+    }
+
+    public void setVm_yearmonth(Integer vm_yearmonth) {
+        this.vm_yearmonth = vm_yearmonth;
+    }
+
+    public Integer getVm_vendid() {
+        return vm_vendid;
+    }
+
+    public void setVm_vendid(Integer vm_vendid) {
+        this.vm_vendid = vm_vendid;
+    }
+
+    public String getVm_vendcode() {
+        return vm_vendcode;
+    }
+
+    public void setVm_vendcode(String vm_vendcode) {
+        this.vm_vendcode = vm_vendcode;
+    }
+
+    public String getVm_vendname() {
+        return vm_vendname;
+    }
+
+    public void setVm_vendname(String vm_vendname) {
+        this.vm_vendname = vm_vendname;
+    }
+
+    public Double getVm_beginamount() {
+        return vm_beginamount;
+    }
+
+    public void setVm_beginamount(Double vm_beginamount) {
+        this.vm_beginamount = vm_beginamount;
+    }
+
+    public Double getVm_nowamount() {
+        return vm_nowamount;
+    }
+
+    public void setVm_nowamount(Double vm_nowamount) {
+        this.vm_nowamount = vm_nowamount;
+    }
+
+    public Double getVm_nowpreamount() {
+        return vm_nowpreamount;
+    }
+
+    public void setVm_nowpreamount(Double vm_nowpreamount) {
+        this.vm_nowpreamount = vm_nowpreamount;
+    }
+
+    public Double getVm_endamount() {
+        return vm_endamount;
+    }
+
+    public void setVm_endamount(Double vm_endamount) {
+        this.vm_endamount = vm_endamount;
+    }
+
+    public Integer getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Integer companyid) {
+        this.companyid = companyid;
+    }
+}

+ 20 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Verification.java

@@ -65,6 +65,26 @@ public class Verification extends CommonBaseEntity implements Serializable {
 
     private String vc_text5;
 
+    private Date vc_auditdate;
+
+    private String vc_auditman;
+
+    public Date getVc_auditdate() {
+        return vc_auditdate;
+    }
+
+    public void setVc_auditdate(Date vc_auditdate) {
+        this.vc_auditdate = vc_auditdate;
+    }
+
+    public String getVc_auditman() {
+        return vc_auditman;
+    }
+
+    public void setVc_auditman(String vc_auditman) {
+        this.vc_auditman = vc_auditman;
+    }
+
     public Integer getVc_id() {
         return vc_id;
     }

+ 4 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/MoneyReportService.java

@@ -17,4 +17,8 @@ public interface MoneyReportService {
     Map<String, Object> acountBalance(PageRequest page, ListReqDTO req);
     Map<String, Object> customercheck(PageRequest page, ListReqDTO req);
     Map<String, Object> accountdetails(PageRequest page, ListReqDTO req);
+    Map<String, Object> vendormonthdetails(PageRequest page, ListReqDTO req);
+    Map<String, Object> custormonthdetails(PageRequest page, ListReqDTO req);
+    Map<String, Object> othrinoutdetails(PageRequest page, ListReqDTO req);
+    Map<String, Object> profitdetails(PageRequest page, ListReqDTO req);
 }

+ 2 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/FundtransferServiceImpl.java

@@ -216,8 +216,8 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
         Iterator isList = fundtransferdetailList.iterator();
         while (isList.hasNext()){
             Fundtransferdetail fundtransferdetail = (Fundtransferdetail) isList.next();
-            Double amount = banksubledgerMapper.selectThisamount(fundtransferdetail.getFtd_bankcode());
-            Double inamount = banksubledgerMapper.selectThisamount(fundtransferdetail.getFtd_inbankcode());
+            Double amount = banksubledgerMapper.selectThisamount(fundtransferdetail.getFtd_bankcode(), BaseContextHolder.getCompanyId());
+            Double inamount = banksubledgerMapper.selectThisamount(fundtransferdetail.getFtd_inbankcode(), BaseContextHolder.getCompanyId());
             banksubledgerMapper.updateBankcode(amount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "+");
             banksubledgerMapper.updateBankcode(inamount, fundtransferdetail.getFtd_nowbalance(),

+ 152 - 59
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/MoneyReportServiceImpl.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.money.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
@@ -10,15 +11,13 @@ import com.usoftchina.saas.money.po.CustomerCheckView;
 import com.usoftchina.saas.money.po.VendorAcountView;
 import com.usoftchina.saas.money.po.VendOrCustAdd;
 import com.usoftchina.saas.money.service.MoneyReportService;
+import com.usoftchina.saas.page.PageDefault;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author heqw
@@ -38,6 +37,10 @@ public class MoneyReportServiceImpl implements MoneyReportService {
     private CustomerCheckViewMapper customerCheckViewMapper;
     @Autowired
     private AccountDetailsViewMapper accountDetailsViewMapper;
+    @Autowired
+    private VendmonthMapper vendmonthMapper;
+    @Autowired
+    private CustmonthMapper custmonthMapper;
 
     @Override
     public Map<String, Object> vendorCheck(PageRequest page, ListReqDTO req) {
@@ -69,28 +72,66 @@ public class MoneyReportServiceImpl implements MoneyReportService {
         return getListDATA(page, req, "accountdetails");
     }
 
-    private Map<String, Object> getListDATA(PageRequest page, ListReqDTO req, String type) {
-        //设置默认分页
+    @Override
+    public Map<String, Object> vendormonthdetails(PageRequest page, ListReqDTO req) {
+        return getListDATA(page, req, "vendormonthdetails");
+    }
+
+    @Override
+    public Map<String, Object> custormonthdetails(PageRequest page, ListReqDTO req) {
+        return getListDATA(page, req, "custormonthdetails");
+    }
+
+    @Override
+    public Map<String, Object> othrinoutdetails(PageRequest page, ListReqDTO req) {
+        return getListDATA(page, req, "othrinoutdetails");
+    }
+
+    @Override
+    public Map<String, Object> profitdetails(PageRequest page, ListReqDTO req) {
+        return getListDATA(page, req, "profitdetails");
+    }
+
+    private Map<String, Object> getListDATA(@PageDefault(size = 10) PageRequest page, ListReqDTO req, String type) {
+        if ("custormonthdetails".equals(type)){
+            Map map1 = this.getYm(req.getCondition());
+            Map<String, Integer> map = new HashMap();
+            map.put("v_YearMonth", Integer.valueOf((String) map1.get("yearmonth")));
+            map.put("v_YearMonthTo", Integer.valueOf((String) map1.get("yearmonthTo")));
+            map.put("v_companyid", Math.toIntExact(BaseContextHolder.getCompanyId()));
+            custmonthMapper.callCustm(map);
+        }else if ("vendormonthdetails".equals(type)){
+            Map map1 = this.getYm(req.getCondition());
+            Map<String, Integer> map = new HashMap();
+            map.put("v_YearMonth", Integer.valueOf((String) map1.get("yearmonth")));
+            map.put("v_YearMonthTo", Integer.valueOf((String) map1.get("yearmonthTo")));
+            map.put("v_companyid",  Math.toIntExact(BaseContextHolder.getCompanyId()));
+            vendmonthMapper.callVend(map);
+        }
+
+      /*  //设置默认分页
         if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
             page = new PageRequest();
             page.setNumber(1);
             page.setSize(10);
-        }
-        PageHelper.startPage(page.getNumber(), page.getSize());
-
-        //查询数据
-        Map<String, Object> map = getListByType(req, type);
-        //取分页信息
-        PageInfo lists = new PageInfo((List) map.get("list"));
-        map.remove("list");
-        map.put("list", lists);
-        return map;
+        }*/
+
+          PageHelper.startPage(page.getNumber(), page.getSize());
+
+          //查询数据
+          Map<String, Object> map = getListByType(req, type);
+          //取分页信息
+          PageInfo lists = new PageInfo((List) map.get("list"));
+          map.remove("list");
+          map.put("list", lists);
+          return map;
     }
 
     private Map<String, Object> getListByType(ListReqDTO req, String type) {
         List list = null;
         Long companyId = BaseContextHolder.getCompanyId();
         String con = req.getFinalCondition();
+        String cons = this.getDate(req.getCondition());
         String calculateFieldsSql = req.getCalculateFieldsSql();
         JSONArray arr = null;
         if (null == con) {
@@ -98,35 +139,34 @@ public class MoneyReportServiceImpl implements MoneyReportService {
         }
 
         String res = null;
-        VendOrCustAdd vendOrCustAdd = new VendOrCustAdd();
         List<Map<String, Double>> list1 = new ArrayList<>();
         if ("Supplier".equals(type)) {
             list = vendorAcountViewMapper.selectByCondition(con, companyId);
             if (list.size() >0) {
                 VendorAcountView vendorAcountView = (VendorAcountView) list.get(0);
+                //取时间
+
                 Integer vid = new Integer(0);
                 vid = vendorAcountViewMapper.getId(vendorAcountView.getPi_vendcode(), Long.valueOf(vendorAcountView.getCompanyId()));
-                Integer ym = Integer.valueOf(req.getYm());
-                vendOrCustAdd = vendorAcountViewMapper.selectVendAdd(vid, ym, Long.valueOf(vendorAcountView.getCompanyId()));
-                vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
-                        + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
-                        - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
-                //封装成list
-                Map<String, Double> map1 = new HashMap<>();
-                map1.put("beginamount", vendOrCustAdd.getBeginamount());
-                list1.add(map1);
-
-                Map<String, Double> map2 = new HashMap<>();
-                map2.put("nowamount", vendOrCustAdd.getNowamount());
-                list1.add(map2);
-
-                Map<String, Double> map3 = new HashMap<>();
-                map3.put("nowpay", vendOrCustAdd.getNowpay());
-                list1.add(map3);
-
-                Map<String, Double> map4 = new HashMap<>();
-                map4.put("nowbalance", vendOrCustAdd.getNowbalance());
-                list1.add(map4);
+                VendOrCustAdd vendOrCustAdd = vendorAcountViewMapper.selectVendAdd(vid, cons, Long.valueOf(vendorAcountView.getCompanyId()));
+                if (vendOrCustAdd != null) {
+                    //封装成list
+                    Map<String, Double> map1 = new HashMap<>();
+                    map1.put("beginamount", vendOrCustAdd.getBeginamount());
+                    list1.add(map1);
+
+                    Map<String, Double> map2 = new HashMap<>();
+                    map2.put("nowamount", vendOrCustAdd.getNowamount());
+                    list1.add(map2);
+
+                    Map<String, Double> map3 = new HashMap<>();
+                    map3.put("nowpay", vendOrCustAdd.getNowpay());
+                    list1.add(map3);
+
+                    Map<String, Double> map4 = new HashMap<>();
+                    map4.put("nowbalance", vendOrCustAdd.getNowbalance());
+                    list1.add(map4);
+                }
             }
         } else if("payDetail".equals(type)){
             list = paydetailViewMapper.selectByCondition(con, companyId);
@@ -153,33 +193,38 @@ public class MoneyReportServiceImpl implements MoneyReportService {
                 Integer vid = new Integer(0);
 
                 vid = customerCheckViewMapper.getId(customerCheckView.getPi_custcode(), Long.valueOf(customerCheckView.getCompanyId()));
-                Integer ym = Integer.valueOf(req.getYm());
-                vendOrCustAdd = customerCheckViewMapper.selectCustAdd(vid, ym, Long.valueOf(customerCheckView.getCompanyId()));
-                vendOrCustAdd.setNowbalance((vendOrCustAdd.getBeginamount() == null ? new Double(0) : vendOrCustAdd.getBeginamount())
-                        + (vendOrCustAdd.getNowamount() == null ? new Double(0) : vendOrCustAdd.getNowamount())
-                        - (vendOrCustAdd.getNowpay() == null ? new Double(0) : vendOrCustAdd.getNowpay()));
-                //封装成list
-                Map<String, Double> map1 = new HashMap<>();
-                map1.put("beginamount", vendOrCustAdd.getBeginamount());
-                list1.add(map1);
-
-                Map<String, Double> map2 = new HashMap<>();
-                map2.put("nowamount", vendOrCustAdd.getNowamount());
-                list1.add(map2);
-
-                Map<String, Double> map3 = new HashMap<>();
-                map3.put("nowpay", vendOrCustAdd.getNowpay());
-                list1.add(map3);
-
-                Map<String, Double> map4 = new HashMap<>();
-                map4.put("nowbalance", vendOrCustAdd.getNowbalance());
-                list1.add(map4);
+                VendOrCustAdd vendOrCustAdd = customerCheckViewMapper.selectCustAdd(vid, cons, Long.valueOf(customerCheckView.getCompanyId()));
+                if (vendOrCustAdd != null) {
+                    //封装成list
+                    Map<String, Double> map1 = new HashMap<>();
+                    map1.put("beginamount", vendOrCustAdd.getBeginamount());
+                    list1.add(map1);
+
+                    Map<String, Double> map2 = new HashMap<>();
+                    map2.put("nowamount", vendOrCustAdd.getNowamount());
+                    list1.add(map2);
+
+                    Map<String, Double> map3 = new HashMap<>();
+                    map3.put("nowpay", vendOrCustAdd.getNowpay());
+                    list1.add(map3);
+
+                    Map<String, Double> map4 = new HashMap<>();
+                    map4.put("nowbalance", vendOrCustAdd.getNowbalance());
+                    list1.add(map4);
+                }
             }
         }else if ("accountdetails".equals(type)){
             list = accountDetailsViewMapper.selectByCondition(con, companyId);
             if (!StringUtils.isEmpty(calculateFieldsSql)) {
                 res = accountDetailsViewMapper.selectCalculateFields(calculateFieldsSql, con, companyId);
             }
+        }else if("vendormonthdetails".equals(type)){
+            list = vendmonthMapper.selectByCondition(con, companyId);
+            res = null;
+        }else if ("custormonthdetails".equals(type)){
+            System.out.println("companyid"+companyId);
+            list = custmonthMapper.selectByCondition(con, companyId);
+            res = null;
         }
 
         try {
@@ -197,4 +242,52 @@ public class MoneyReportServiceImpl implements MoneyReportService {
         }
         return map;
     }
+
+    public String getDate(String cons){
+        JSONArray jsonArray = JSONArray.parseArray(cons);
+        String con = " 1 = 1";
+        if (null != jsonArray && jsonArray.size() > 0) {
+            StringBuffer finalCondition = new StringBuffer();
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+                Object type = jsonObject.get("type");
+                if ("date".equals(type)){
+                    String value = (String) jsonObject.get("value");
+                    value = value.replace(",", "' and '");
+                    con =  " a.sl_date between '" + value + "'" ;
+                    return con;
+                }
+            }
+        }
+        return con;
+    }
+
+    //取两个期间
+    public Map<String, String> getYm(String cons){
+        System.out.println("cons:" + cons);
+        JSONArray jsonArray = JSONArray.parseArray(cons);
+        Map<String, String> map = new HashMap<>();
+        if (null != jsonArray && jsonArray.size() > 0) {
+            StringBuffer finalCondition = new StringBuffer();
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject jsonObject = (JSONObject) jsonArray.get(i);
+//
+//                String yearmonth = "yearmonth";
+//                String yearmonthTo = "yearmonthTo";
+//                if (st.equals("vend")){
+//                    yearmonth = "vm_" + yearmonth;
+//                    yearmonthTo = "vm_" + yearmonthTo;
+//                }else if (st.equals("cust")){
+//                    yearmonth = "cm_" + yearmonth;
+//                    yearmonthTo = "cm_" + yearmonthTo;
+//                }
+                    String value = (String) jsonObject.get("value");
+                    String[] arr = value.split(",");
+                    map.put("yearmonth", arr[0]);
+                    map.put("yearmonthTo", arr[1]);
+            }
+        }
+        System.out.println("map:" + map);
+        return map;
+    }
 }

+ 45 - 48
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java

@@ -119,7 +119,7 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
         DocBaseDTO docBaseDTO = this.insert(othte);
         Long id = docBaseDTO.getId();
 
-        Double amount = banksubledgerMapper.selectThisamount(othreceipts.getOr_bankcode());
+        Double amount = banksubledgerMapper.selectThisamount(othreceipts.getOr_bankcode(), companyId);
         //取从表金额
         List<Othreceiptsdetail> othreceiptsdetailList = othte.getItems();
         Iterator isList = othreceiptsdetailList.iterator();
@@ -151,32 +151,32 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
          * cu_recamount=nvl(cu_recamount,0)-rb_rbdamount,
          * cu_leftamount=cu_beginaramount-cu_beginprerecamount+cu_recamount-cu_preamount;
          */
-        if (othreceipts.getOr_custid() != null && othreceipts.getOr_custid() != 0) {
-            Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(othreceipts.getOr_custid());
-            Double preamount = customerData.getCu_preamount() == null ? new Double(0) : customerData.getCu_preamount();
-            Double beginapamount = customerData.getCu_beginaramount() == null ? new Double(0) : customerData.getCu_beginaramount();
-            Double beginprepayamount = customerData.getCu_beginprerecamount() == null ? new Double(0) : customerData.getCu_beginprerecamount();
-            Double recamount = customerData.getCu_recamount() == null ? new Double(0) : customerData.getCu_recamount();
-
-            Customer customer = new Customer();
-            customer.setId(Long.valueOf(othreceipts.getOr_custid()));
-            customer.setCu_preamount(preamount);
-            customer.setCu_recamount(recamount + or_amount);
-            customer.setCu_leftamount(beginapamount - beginprepayamount + recamount + or_amount - preamount);
-            recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
-
-            //插入subledger中间表
-            Subledger subledger = new Subledger();
-            subledger.setSl_code(othreceipts.getOr_code());
-            subledger.setSl_kind("其他收入单");
-            subledger.setSl_custid(othreceipts.getOr_custid());
-            subledger.setSl_vendid(0);
-            subledger.setSl_date(othreceipts.getOr_date());
-            subledger.setSl_ym(DateUtils.getYm(othreceipts.getOr_date()));
-            subledger.setSl_amount(or_amount);
-            subledger.setCompanyId(BaseContextHolder.getCompanyId());
-            subledgerMapper.insertSelective(subledger);
-        }
+//        if (othreceipts.getOr_custid() != null && othreceipts.getOr_custid() != 0) {
+//            Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(othreceipts.getOr_custid());
+//            Double preamount = customerData.getCu_preamount() == null ? new Double(0) : customerData.getCu_preamount();
+//            Double beginapamount = customerData.getCu_beginaramount() == null ? new Double(0) : customerData.getCu_beginaramount();
+//            Double beginprepayamount = customerData.getCu_beginprerecamount() == null ? new Double(0) : customerData.getCu_beginprerecamount();
+//            Double recamount = customerData.getCu_recamount() == null ? new Double(0) : customerData.getCu_recamount();
+//
+//            Customer customer = new Customer();
+//            customer.setId(Long.valueOf(othreceipts.getOr_custid()));
+//            customer.setCu_preamount(preamount);
+//            customer.setCu_recamount(recamount + or_amount);
+//            customer.setCu_leftamount(beginapamount - beginprepayamount + recamount + or_amount - preamount);
+//            recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
+//
+//            //插入subledger中间表
+//            Subledger subledger = new Subledger();
+//            subledger.setSl_code(othreceipts.getOr_code());
+//            subledger.setSl_kind("其他收入单");
+//            subledger.setSl_custid(othreceipts.getOr_custid());
+//            subledger.setSl_vendid(0);
+//            subledger.setSl_date(othreceipts.getOr_date());
+//            subledger.setSl_ym(DateUtils.getYm(othreceipts.getOr_date()));
+//            subledger.setSl_amount(or_amount);
+//            subledger.setCompanyId(BaseContextHolder.getCompanyId());
+//            subledgerMapper.insertSelective(subledger);
+//        }
 
 
         //计算期间金额
@@ -219,7 +219,7 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
 
 
         //更新资金
-        Double amount = banksubledgerMapper.selectThisamount(othreceipts.getOr_bankcode());
+        Double amount = banksubledgerMapper.selectThisamount(othreceipts.getOr_bankcode(), BaseContextHolder.getCompanyId());
         List<Othreceiptsdetail> othreceiptsdetailList = othreceiptsdetailMapper.selectByPrimaryKey(id);
         Iterator isList = othreceiptsdetailList.iterator();
         while (isList.hasNext()){
@@ -249,21 +249,21 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
          * cu_recamount=nvl(cu_recamount,0)-rb_rbdamount,
          * cu_leftamount=cu_beginaramount-cu_beginprerecamount+cu_recamount-cu_preamount;
          */
-        if (othreceipts.getOr_custid() != null && othreceipts.getOr_custid() != 0) {
-            Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(othreceipts.getOr_custid());
-            Double preamount = customerData.getCu_preamount() == null ? new Double(0) : customerData.getCu_preamount();
-            Double beginapamount = customerData.getCu_beginaramount() == null ? new Double(0) : customerData.getCu_beginaramount();
-            Double beginprepayamount = customerData.getCu_beginprerecamount() == null ? new Double(0) : customerData.getCu_beginprerecamount();
-            Double recamount = customerData.getCu_recamount() == null ? new Double(0) : customerData.getCu_recamount();
-
-            Customer customer = new Customer();
-            customer.setId(Long.valueOf(othreceipts.getOr_custid()));
-            customer.setCu_preamount(preamount);
-            customer.setCu_recamount(recamount - or_amount);
-            customer.setCu_leftamount(beginapamount - beginprepayamount + recamount - or_amount - preamount);
-            recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
-            subledgerMapper.deleteByPrimaryKey(othreceipts.getOr_code(), "其他收入单",BaseContextHolder.getCompanyId());
-        }
+//        if (othreceipts.getOr_custid() != null && othreceipts.getOr_custid() != 0) {
+//            Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(othreceipts.getOr_custid());
+//            Double preamount = customerData.getCu_preamount() == null ? new Double(0) : customerData.getCu_preamount();
+//            Double beginapamount = customerData.getCu_beginaramount() == null ? new Double(0) : customerData.getCu_beginaramount();
+//            Double beginprepayamount = customerData.getCu_beginprerecamount() == null ? new Double(0) : customerData.getCu_beginprerecamount();
+//            Double recamount = customerData.getCu_recamount() == null ? new Double(0) : customerData.getCu_recamount();
+//
+//            Customer customer = new Customer();
+//            customer.setId(Long.valueOf(othreceipts.getOr_custid()));
+//            customer.setCu_preamount(preamount);
+//            customer.setCu_recamount(recamount - or_amount);
+//            customer.setCu_leftamount(beginapamount - beginprepayamount + recamount - or_amount - preamount);
+//            recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
+//            subledgerMapper.deleteByPrimaryKey(othreceipts.getOr_code(), "其他收入单",BaseContextHolder.getCompanyId());
+//        }
 
 
         //计算期间金额
@@ -433,11 +433,8 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
             banksubledger.setBl_income(othreceiptsdetail.getOrd_nowbalance());
             banksubledger.setBl_remark(othreceiptsdetail.getOrd_remark());
             banksubledger.setBl_orderamount(othreceiptsdetail.getOrd_nowbalance());
-            if (banksubledgerMapper.selectCode(banksubledger.getBl_code()) == null){
-                banksubledgerMapper.insertSelective(banksubledger);
-            }else {
-                banksubledgerMapper.updateByPrimaryKeySelective(banksubledger);
-            }
+            banksubledger.setBl_item(othreceiptsdetail.getOrd_type());
+            banksubledgerMapper.insertSelective(banksubledger);
         }
     }
 

+ 50 - 53
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthspendingsServiceImpl.java

@@ -159,7 +159,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         DocBaseDTO docBaseDTO = this.insert(othsp);
         Long id = docBaseDTO.getId();
 
-        Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode());
+        Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode(), companyId);
         //取从表金额
         List<Othspendingsdetail> othspendingsdetailList = othsp.getItems();
         Iterator isList = othspendingsdetailList.iterator();
@@ -186,37 +186,37 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         bankinformation.setBk_spending(spending + bk_amount);
         bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
 
-        /**
-         * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
-         * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
-         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
-         */
-        if (othspendings.getOs_vendid() != null && othspendings.getOs_vendid() != 0) {
-            Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
-            Double preamount = vendorData.getVe_preamount() == null ? new Double(0) : vendorData.getVe_preamount();
-            Double beginapamount = vendorData.getVe_beginapamount() == null ? new Double(0) : vendorData.getVe_beginapamount();
-            Double beginprepayamount = vendorData.getVe_beginprepayamount() == null ? new Double(0) : vendorData.getVe_beginprepayamount();
-            Double payamount = vendorData.getVe_payamount() == null ? new Double(0) : vendorData.getVe_payamount();
-
-            Vendor vendor = new Vendor();
-            vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
-            vendor.setVe_preamount(preamount);
-            vendor.setVe_payamount(payamount - bk_amount);
-            vendor.setVe_leftamount(beginapamount - beginprepayamount + payamount - bk_amount - preamount);
-            paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
+//        /**
+//         * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
+//         * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
+//         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+//         */
+//        if (othspendings.getOs_vendid() != null && othspendings.getOs_vendid() != 0) {
+//            Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
+//            Double preamount = vendorData.getVe_preamount() == null ? new Double(0) : vendorData.getVe_preamount();
+//            Double beginapamount = vendorData.getVe_beginapamount() == null ? new Double(0) : vendorData.getVe_beginapamount();
+//            Double beginprepayamount = vendorData.getVe_beginprepayamount() == null ? new Double(0) : vendorData.getVe_beginprepayamount();
+//            Double payamount = vendorData.getVe_payamount() == null ? new Double(0) : vendorData.getVe_payamount();
+//
+//            Vendor vendor = new Vendor();
+//            vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
+//            vendor.setVe_preamount(preamount);
+//            vendor.setVe_payamount(payamount - bk_amount);
+//            vendor.setVe_leftamount(beginapamount - beginprepayamount + payamount - bk_amount - preamount);
+//            paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
 
             //插入subledger中间表
-            Subledger subledger = new Subledger();
-            subledger.setSl_code(othspendings.getOs_code());
-            subledger.setSl_kind("其他支出单");
-            subledger.setSl_custid(0);
-            subledger.setSl_vendid(othspendings.getOs_vendid());
-            subledger.setSl_date(othspendings.getOs_date());
-            subledger.setSl_ym(DateUtils.getYm(othspendings.getOs_date()));
-            subledger.setSl_amount(bk_amount);
-            subledger.setCompanyId(BaseContextHolder.getCompanyId());
-            subledgerMapper.insertSelective(subledger);
-        }
+//            Subledger subledger = new Subledger();
+//            subledger.setSl_code(othspendings.getOs_code());
+//            subledger.setSl_kind("其他支出单");
+//            subledger.setSl_custid(0);
+//            subledger.setSl_vendid(othspendings.getOs_vendid());
+//            subledger.setSl_date(othspendings.getOs_date());
+//            subledger.setSl_ym(DateUtils.getYm(othspendings.getOs_date()));
+//            subledger.setSl_amount(bk_amount);
+//            subledger.setCompanyId(BaseContextHolder.getCompanyId());
+//            subledgerMapper.insertSelective(subledger);
+//        }
 
         //计算期间金额
         Statsinfo statsinfo = new Statsinfo();
@@ -253,7 +253,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         banksubledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他支出单",BaseContextHolder.getCompanyId());
 
         //资金
-        Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode());
+        Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode(), BaseContextHolder.getCompanyId());
         //取从表金额
         List<Othspendingsdetail> othspendingsdetailList = othspendingsdetailMapper.selectByPrimaryKey(id);
         Iterator isList = othspendingsdetailList.iterator();
@@ -282,22 +282,22 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
          * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
          * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
          */
-        if (othspendings.getOs_vendid() != null && othspendings.getOs_vendid() != 0) {
-            Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
-            Double preamount = vendorData.getVe_preamount() == null ? new Double(0) : vendorData.getVe_preamount();
-            Double beginapamount = vendorData.getVe_beginapamount() == null ? new Double(0) : vendorData.getVe_beginapamount();
-            Double beginprepayamount = vendorData.getVe_beginprepayamount() == null ? new Double(0) : vendorData.getVe_beginprepayamount();
-            Double payamount = vendorData.getVe_payamount() == null ? new Double(0) : vendorData.getVe_payamount();
-
-            Vendor vendor = new Vendor();
-            vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
-            vendor.setVe_preamount(preamount);
-            vendor.setVe_payamount(payamount + bk_amount);
-            vendor.setVe_leftamount(beginapamount - beginprepayamount + payamount + bk_amount - preamount);
-            paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
-
-            subledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他支出单",BaseContextHolder.getCompanyId());
-        }
+//        if (othspendings.getOs_vendid() != null && othspendings.getOs_vendid() != 0) {
+//            Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
+//            Double preamount = vendorData.getVe_preamount() == null ? new Double(0) : vendorData.getVe_preamount();
+//            Double beginapamount = vendorData.getVe_beginapamount() == null ? new Double(0) : vendorData.getVe_beginapamount();
+//            Double beginprepayamount = vendorData.getVe_beginprepayamount() == null ? new Double(0) : vendorData.getVe_beginprepayamount();
+//            Double payamount = vendorData.getVe_payamount() == null ? new Double(0) : vendorData.getVe_payamount();
+//
+//            Vendor vendor = new Vendor();
+//            vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
+//            vendor.setVe_preamount(preamount);
+//            vendor.setVe_payamount(payamount + bk_amount);
+//            vendor.setVe_leftamount(beginapamount - beginprepayamount + payamount + bk_amount - preamount);
+//            paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
+//
+//            subledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他支出单",BaseContextHolder.getCompanyId());
+//        }
 
 
         //计算期间金额
@@ -425,14 +425,11 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
             banksubledger.setBl_assid(othspendings.getOs_vendid());
             banksubledger.setBl_asscode(othspendings.getOs_vendcode());
             banksubledger.setBl_assname(othspendings.getOs_vendname());
-            banksubledger.setBl_income(othspendingsdetail.getOsd_nowbalance());
+            banksubledger.setBl_spending(othspendingsdetail.getOsd_nowbalance());
             banksubledger.setBl_remark(othspendingsdetail.getOsd_remark());
             banksubledger.setBl_orderamount(othspendingsdetail.getOsd_nowbalance() * -1);
-            if (banksubledgerMapper.selectCode(banksubledger.getBl_code()) == null){
-                banksubledgerMapper.insertSelective(banksubledger);
-            }else {
-                banksubledgerMapper.updateByPrimaryKeySelective(banksubledger);
-            }
+            banksubledger.setBl_item(othspendingsdetail.getOsd_type());
+            banksubledgerMapper.insertSelective(banksubledger);
         }
     }
 

+ 8 - 31
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java

@@ -173,22 +173,6 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
                 }
             }
         }
-        //付款金额合计
-        Double amountTotal = new Double(0);
-        for (Paybalancedet det: paybalancedet) {
-            amountTotal = amountTotal + det.getPd_amount();
-        }
-        //更新本次预付款金额
-        Paybalance updatePay = new Paybalance();
-        updatePay.setId(paybalance.getId());
-
-        //折扣
-        Double discounts = paybalance.getPb_discounts();
-        if(discounts == null){
-            discounts = 0.0;
-        }
-        updatePay.setPb_preamount(amountTotal + discounts - nowbalanceTotal);
-        paybalanceMapper.updateByPrimaryKeySelective(updatePay);
     }
 
     @Override
@@ -562,19 +546,19 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         subledger.setSl_ym(DateUtils.getYm(paybalance.getPb_date()));
         Double pdamount = paybalance.getPb_pdamount()==null?new Double(0):paybalance.getPb_pdamount();
         Double preamount = paybalance.getPb_preamount()==null?new Double(0):paybalance.getPb_preamount();
-        Double pbdamount = new Double(0);
-        subledger.setSl_amount(-pdamount);
-        subledger.setSl_yamount(preamount);
+        Double pbdamount = paybalance.getPb_pbdamount()==null?new Double(0):paybalance.getPb_pbdamount();
+        subledger.setSl_amount(-pbdamount);
         subledger.setSl_orderamount(pdamount);
 
         if(preamount!=0){
-            pbdamount = paybalance.getPb_pbdamount()==null?new Double(0):paybalance.getPb_pbdamount();
+            subledger.setSl_yamount(pbdamount);
+            subledger.setSl_namount(pdamount-pbdamount);
+        }else{
+            subledger.setSl_yamount(new Double(0));
+            subledger.setSl_namount(pdamount);
         }
-        subledger.setSl_namount(pdamount-pbdamount);
         subledger.setSl_remark(subledger.getSl_remark());
         subledger.setSl_preamount(preamount);
-
-
         subledgerMapper.insertSelective(subledger);
     }
 
@@ -605,14 +589,7 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
             banksubledger.setBl_manname(paybalance.getPb_manname());
             banksubledger.setBl_remark(paybalancedet.getPd_remark());
             banksubledger.setBl_orderamount(paybalancedet.getPd_amount() * -1);
-
-            List<String> bankList = banksubledgerMapper.selectCode(banksubledger.getBl_code());
-            if (bankList.size() == 0){
-                banksubledgerMapper.insertSelective(banksubledger);
-            }else {
-                banksubledgerMapper.updateByPrimaryKeySelective(banksubledger);
-            }
-
+            banksubledgerMapper.insertSelective(banksubledger);
         }
     }
 

+ 17 - 30
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java

@@ -21,6 +21,7 @@ import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
 import java.util.Date;
@@ -53,6 +54,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
     private CommonService commonService;
 
     @Override
+    @Transactional
     public DocBaseDTO insert(Rec rec) {
         Recbalance recbalance = rec.getMain();
         List<Recbalancedet> recbalancedet = rec.getItems1();
@@ -164,32 +166,17 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             }
         }
         //不能选择重复的源单
-        for  ( int  i  =   0 ; i  <  recbalancedetail.size()  -   1 ; i ++ )  {
-            for  ( int  j  =  recbalancedetail.size()  -   1 ; j  >  i; j -- )  {
-                if  (recbalancedetail.get(j).getRbd_slcode().equals(recbalancedetail.get(i).getRbd_slcode()))  {
+        for  ( int  i  =   0 ; i  <  recbalancedetail.size()  -   1 ; i ++ ) {
+            for (int j = recbalancedetail.size() - 1; j > i; j--) {
+                if (recbalancedetail.get(j).getRbd_slcode().equals(recbalancedetail.get(i).getRbd_slcode())) {
                     throw new BizException(500, BizExceptionCode.PAYBALANCE_UNIQUESOURCECODE.getMessage());
                 }
             }
         }
-        //付款金额合计
-        Double amountTotal = new Double(0);
-        for (Recbalancedet det: recbalancedet) {
-            amountTotal = amountTotal + det.getRd_amount();
-        }
-        //更新本次预付款金额
-        Recbalance updatePay = new Recbalance();
-        updatePay.setId(recbalance.getId());
-
-        //折扣
-        Double discount = recbalance.getRb_discounts();
-        if (discount == null){
-            discount = 0.0;
-        }
-        updatePay.setRb_preamount(amountTotal + discount - nowbalanceTotal);
-        recbalanceMapper.updateByPrimaryKeySelective(updatePay);
     }
 
     @Override
+    @Transactional
     public void delete(int id) {
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
 
@@ -214,6 +201,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
     }
 
     @Override
+    @Transactional
     public void deleteItem(int id) {
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         recbalancedetMapper.deleteItem(id);
@@ -223,6 +211,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
     }
 
     @Override
+    @Transactional
     public void deleteItems(int id) {
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         recbalancedetailMapper.deleteItem(id);
@@ -232,6 +221,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
     }
 
     @Override
+    @Transactional
     public DocBaseDTO audit(Rec rec) {
         Long companyId = BaseContextHolder.getCompanyId();
         Recbalance recbalance = rec.getMain();
@@ -566,15 +556,17 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         subledger.setSl_ym(DateUtils.getYm(recbalance.getRb_date()));
         Double rdamount = recbalance.getRb_rdamount()==null?new Double(0):recbalance.getRb_rdamount();
         Double preamount = recbalance.getRb_preamount()==null?new Double(0):recbalance.getRb_preamount();
-        Double pbdamount = new Double(0);
-        subledger.setSl_amount(-rdamount);
-        subledger.setSl_yamount(preamount);
+        Double rbdamount = recbalance.getRb_rbdamount()==null?new Double(0):recbalance.getRb_rbdamount();
+        subledger.setSl_amount(-rbdamount);
         subledger.setSl_orderamount(rdamount);
 
         if(preamount!=0){
-            pbdamount = recbalance.getRb_rbdamount()==null?new Double(0):recbalance.getRb_rbdamount();
+            subledger.setSl_yamount(rbdamount);
+            subledger.setSl_namount(rdamount-rbdamount);
+        }else{
+            subledger.setSl_yamount(new Double(0));
+            subledger.setSl_namount(rdamount);
         }
-        subledger.setSl_namount(rdamount-pbdamount);
         subledger.setSl_remark(subledger.getSl_remark());
         subledger.setSl_preamount(preamount);
 
@@ -609,12 +601,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             banksubledger.setBl_manname(recbalance.getRb_manname());
             banksubledger.setBl_remark(recbalancedet.getRd_remark());
             banksubledger.setBl_orderamount(amount);
-            if (banksubledgerMapper.selectCode(banksubledger.getBl_code()) == null){
-                banksubledgerMapper.insertSelective(banksubledger);
-            }else {
-                banksubledgerMapper.updateByPrimaryKeySelective(banksubledger);
-            }
-
+            banksubledgerMapper.insertSelective(banksubledger);
         }
     }
     private DocBaseDTO getBaseDTOById(Long id) {

+ 47 - 37
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java

@@ -21,6 +21,7 @@ import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.VerificationService;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
@@ -286,11 +287,13 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         Double amount1 = verification.getVc_amount1()==null?new Double(0):verification.getVc_amount1();
         Double amount2 = verification.getVc_amount2()==null?new Double(0):verification.getVc_amount2();
         subledger.setSl_date(verification.getVc_date());
+        subledger.setSl_ym(DateUtils.getYm(verification.getVc_date()));
         subledger.setSl_amount(-amount2);
         subledger.setSl_orderamount(new Double(0));
         subledger.setSl_yamount(new Double(0));
         subledger.setSl_remark(verification.getVc_remark());
         subledger.setSl_discount(new Double(0));
+        subledger.setSl_ym(DateUtils.getYm(verification.getVc_date()));
         if(kind.equals("receipts_offset_receivable") || kind.equals("prepaid_offset_payable")){
             subledger.setSl_preamount(-amount1);
         }else{
@@ -305,17 +308,19 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
      */
     private void updateAuditSubledeger(Long id , Double nowBalance){
         Subledger subledger = subledgerMapper.selectByPrimaryKey(Math.toIntExact(id));
-        Subledger newSubledeger = new Subledger();
-        newSubledeger.setId(id);
-        Double newNamout = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount()-nowBalance;
-        Double newYamout = subledger.getSl_yamount()==null?new Double(0):subledger.getSl_yamount()+nowBalance;
-        newSubledeger.setSl_yamount(newYamout);
-        newSubledeger.setSl_namount(newNamout);
-        newSubledeger.setCompanyId(BaseContextHolder.getCompanyId());
-        newSubledeger.setUpdaterName(BaseContextHolder.getUserName());
-        newSubledeger.setUpdaterId(BaseContextHolder.getUserId());
-        newSubledeger.setUpdateTime(new Date());
-        subledgerMapper.updateByPrimaryKeySelective(newSubledeger);
+        if (subledger != null) {
+            Subledger newSubledeger = new Subledger();
+            newSubledeger.setId(id);
+            Double newNamout = subledger.getSl_namount() == null ? new Double(0) : subledger.getSl_namount() - nowBalance;
+            Double newYamout = subledger.getSl_yamount() == null ? new Double(0) : subledger.getSl_yamount() + nowBalance;
+            newSubledeger.setSl_yamount(newYamout);
+            newSubledeger.setSl_namount(newNamout);
+            newSubledeger.setCompanyId(BaseContextHolder.getCompanyId());
+            newSubledeger.setUpdaterName(BaseContextHolder.getUserName());
+            newSubledeger.setUpdaterId(BaseContextHolder.getUserId());
+            newSubledeger.setUpdateTime(new Date());
+            subledgerMapper.updateByPrimaryKeySelective(newSubledeger);
+        }
     }
     /**
      * 反审核更新来源单据的已核销,未核销
@@ -324,17 +329,19 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
      */
     private void updateResAuditSubledeger(Long id , Double nowBalance){
         Subledger subledger = subledgerMapper.selectByPrimaryKey(Math.toIntExact(id));
-        Subledger newSubledeger = new Subledger();
-        newSubledeger.setId(Long.valueOf(String.valueOf(id)));
-        Double newNamout = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount()+nowBalance;
-        Double newYamout = subledger.getSl_yamount()==null?new Double(0):subledger.getSl_yamount()-nowBalance;
-        newSubledeger.setSl_yamount(newYamout);
-        newSubledeger.setSl_namount(newNamout);
-        newSubledeger.setCompanyId(BaseContextHolder.getCompanyId());
-        newSubledeger.setUpdaterName(BaseContextHolder.getUserName());
-        newSubledeger.setUpdaterId(BaseContextHolder.getUserId());
-        newSubledeger.setUpdateTime(new Date());
-        subledgerMapper.updateByPrimaryKeySelective(newSubledeger);
+        if(subledger != null) {
+            Subledger newSubledeger = new Subledger();
+            newSubledeger.setId(Long.valueOf(String.valueOf(id)));
+            Double newNamout = subledger.getSl_namount() == null ? new Double(0) : subledger.getSl_namount() + nowBalance;
+            Double newYamout = subledger.getSl_yamount() == null ? new Double(0) : subledger.getSl_yamount() - nowBalance;
+            newSubledeger.setSl_yamount(newYamout);
+            newSubledeger.setSl_namount(newNamout);
+            newSubledeger.setCompanyId(BaseContextHolder.getCompanyId());
+            newSubledeger.setUpdaterName(BaseContextHolder.getUserName());
+            newSubledeger.setUpdaterId(BaseContextHolder.getUserId());
+            newSubledeger.setUpdateTime(new Date());
+            subledgerMapper.updateByPrimaryKeySelective(newSubledeger);
+        }
     }
     /**
      * 转换核销单类型
@@ -528,19 +535,14 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
 
     @Override
     public DocBaseDTO audit(VerificationFormDTO formData) {
-        Long id = null;
+
         DocBaseDTO baseDTO = new DocBaseDTO();
-        if (null != formData) {
-            id = formData.getMain().getId();
-            if (StringUtils.isEmpty(id)) {
-                baseDTO = saveFormData(formData);
-                id = baseDTO.getId();
-            }
-            Verification verification = new Verification();
-            verification.setVc_status(Status.AUDITED.getDisplay());
-            verification.setVc_statuscode(Status.AUDITED.name());
-            verification.setVc_id(Integer.valueOf(String.valueOf(id)));
-            verificationMapper.updateByPrimaryKeySelective(verification);
+        formData.getMain().setVc_status(Status.AUDITED.getDisplay());
+        formData.getMain().setVc_statuscode(Status.AUDITED.name());
+        formData.getMain().setVc_auditman(BaseContextHolder.getUserName());
+        formData.getMain().setVc_auditdate(new Date());
+        baseDTO = this.saveFormData(formData);
+        Long id = baseDTO.getId();
 
 
             VerificationDTO verificationDTO = formData.getMain();
@@ -568,7 +570,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
                     updateAuditSubledeger(detail.getVcd_slid(),nowbalanceDet);
                 }
             }
-        }
+
         //更新出入库状态
         this.updateProdInoutStatus(id);
 
@@ -786,9 +788,14 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         verification.setVc_statuscode(Status.UNAUDITED.name());
         verification.setUpdateTime(new Date());
         verification.setUpdaterId(BaseContextHolder.getUserId());
+        verification.setVc_auditdate(null);
+        verification.setVc_auditman(null);
         //更新存在字段
         verificationMapper.updateByPrimaryKeySelective(verification);
 
+        subledgerMapper.deleteByPrimaryKey(nowverification.getVc_code(),nowverification.getVc_kind(),
+                BaseContextHolder.getCompanyId());
+
         //更新出入库状态
         this.updateProdInoutStatus(id);
 
@@ -977,7 +984,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             Long id = docBaseDTO.getId();
 
             //更新客户或者供应商的金额
-            Verification nowverification = verificationMapper.selectByPrimaryKey(id);
+            Verification nowverification = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
             VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
             updateAuditCustomer(verificationDTO);
             updateAuditVendor(verificationDTO);
@@ -1018,7 +1025,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             Long id = docBaseDTO.getId();
 
             //更新客户或者供应商的金额
-            Verification nowverification = verificationMapper.selectByPrimaryKey(id);
+            Verification nowverification = verificationMapper.selectByPrimaryKey(Math.toIntExact(id));
             VerificationDTO verificationDTO = BeanMapper.map(nowverification,VerificationDTO.class);
             updateResAuditCustomer(verificationDTO);
             updateResAuditVendor(verificationDTO);
@@ -1046,6 +1053,9 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             verification.setUpdateTime(new Date());
             verificationMapper.updateByPrimaryKeySelective(verification);
 
+            subledgerMapper.deleteByPrimaryKey(nowverification.getVc_code(),nowverification.getVc_kind(),
+                    BaseContextHolder.getCompanyId());
+
             this.updateProdInoutStatus(id);
         }
     }

+ 1 - 1
applications/money/money-server/src/main/resources/config/application-docker-prod.yml

@@ -13,7 +13,7 @@ spring:
     username: saas
     password: select123***
   datasource:
-    url: jdbc:mysql://10.10.100.18:3306/saas_biz?characterEncoding=utf-8&useSSL=false
+    url: jdbc:mysql://10.10.100.18:3306/saas_biz?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
     username: saas
     password: select111***
   redis:

+ 12 - 0
applications/money/money-server/src/main/resources/config/application-docker-test.yml

@@ -0,0 +1,12 @@
+eureka:
+  instance:
+    hostname: saas-money-server-test
+    prefer-ip-address: false
+  client:
+    serviceUrl:
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@saas-eureka-server-test:8515/eureka/
+spring:
+  rabbitmq:
+    virtual-host: test
+server:
+  port: 8895

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно