Browse Source

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

jinsy 7 years ago
parent
commit
95d49fb2d1
100 changed files with 2677 additions and 348 deletions
  1. 12 0
      applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/CommonService.java
  2. 4 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  3. 12 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Operation.java
  4. 14 3
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/CommonController.java
  5. 1 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/CommonMapper.java
  6. 1 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/CommonService.java
  7. 40 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/CommonServiceImpl.java
  8. 1 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/MessageLogServiceImpl.java
  9. 5 0
      applications/commons/commons-server/src/main/resources/mapper/CommonMapper.xml
  10. 28 21
      applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml
  11. 2 0
      applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/CustomerDTO.java
  12. 195 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Banksubledger.java
  13. 10 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bom.java
  14. 141 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Subledger.java
  15. 1 3
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java
  16. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java
  17. 33 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BanksubledgerMapper.java
  18. 2 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductDetailMapper.java
  19. 39 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/SubledgerMapper.java
  20. 1 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/ProductService.java
  21. 80 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java
  22. 98 12
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java
  23. 8 4
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/EmployeeServiceImpl.java
  24. 53 7
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java
  25. 91 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java
  26. 1 1
      applications/document/document-server/src/main/resources/mapper/AddressMapper.xml
  27. 5 0
      applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml
  28. 345 0
      applications/document/document-server/src/main/resources/mapper/BanksubledgerMapper.xml
  29. 1 0
      applications/document/document-server/src/main/resources/mapper/BomMapper.xml
  30. 1 0
      applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml
  31. 1 1
      applications/document/document-server/src/main/resources/mapper/CustomerkindMapper.xml
  32. 1 1
      applications/document/document-server/src/main/resources/mapper/FundinouttypeMapper.xml
  33. 5 2
      applications/document/document-server/src/main/resources/mapper/ProductDetailMapper.xml
  34. 2 2
      applications/document/document-server/src/main/resources/mapper/ProductMapper.xml
  35. 1 1
      applications/document/document-server/src/main/resources/mapper/ProductbrandMapper.xml
  36. 1 1
      applications/document/document-server/src/main/resources/mapper/ProducttypeMapper.xml
  37. 1 1
      applications/document/document-server/src/main/resources/mapper/ProductunitMapper.xml
  38. 277 0
      applications/document/document-server/src/main/resources/mapper/SubledgerMapper.xml
  39. 1 1
      applications/document/document-server/src/main/resources/mapper/VendorkindMapper.xml
  40. 1 1
      applications/document/document-server/src/main/resources/mapper/WarehouseMapper.xml
  41. 2 2
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/FundtransferController.java
  42. 2 2
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/OthreceiptsController.java
  43. 2 2
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/OthspengdingsController.java
  44. 2 2
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/PaybalanceController.java
  45. 2 2
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/RecbalanceContorller.java
  46. 3 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/FundtransferMapper.java
  47. 4 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthreceiptsMapper.java
  48. 2 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthreceiptsdetailMapper.java
  49. 3 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthspendingsMapper.java
  50. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthspendingsdetailMapper.java
  51. 5 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalanceMapper.java
  52. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalancedetMapper.java
  53. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalanceMapper.java
  54. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalancedetMapper.java
  55. 14 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/StatsinfoMapper.java
  56. 83 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Paybalance.java
  57. 21 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Recbalance.java
  58. 71 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Statsinfo.java
  59. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/FundtransferService.java
  60. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/OthreceiptsService.java
  61. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/OthspendingsService.java
  62. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/PaybalanceService.java
  63. 1 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/RecbalanceService.java
  64. 64 21
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/FundtransferServiceImpl.java
  65. 68 23
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java
  66. 70 21
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthspendingsServiceImpl.java
  67. 68 12
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java
  68. 69 10
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  69. 9 2
      applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml
  70. 11 4
      applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml
  71. 4 0
      applications/money/money-server/src/main/resources/mapper/OthreceiptsdetailMapper.xml
  72. 9 2
      applications/money/money-server/src/main/resources/mapper/OthspendingsMapper.xml
  73. 4 0
      applications/money/money-server/src/main/resources/mapper/OthspendingsdetailMapper.xml
  74. 38 7
      applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml
  75. 4 0
      applications/money/money-server/src/main/resources/mapper/PaybalancedetMapper.xml
  76. 31 7
      applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml
  77. 3 3
      applications/money/money-server/src/main/resources/mapper/RecbalancedetMapper.xml
  78. 0 3
      applications/money/money-server/src/main/resources/mapper/RecbalancedetailMapper.xml
  79. 103 0
      applications/money/money-server/src/main/resources/mapper/StatsinfoMapper.xml
  80. 0 4
      applications/purchase/purchase-server/pom.xml
  81. 4 1
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java
  82. 46 37
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java
  83. 10 10
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/PurchaseServiceImpl.java
  84. 6 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SaleProfitView.java
  85. 2 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SalerecView.java
  86. 3 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/ProdInOutService.java
  87. 35 26
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java
  88. 2 7
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleReportServiceImpl.java
  89. 22 14
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java
  90. 3 0
      applications/sale/sale-server/src/main/resources/mapper/SaleProfitViewMapper.xml
  91. 1 0
      applications/sale/sale-server/src/main/resources/mapper/SalerecViewMapper.xml
  92. 1 0
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/report/ProdiodetailView.java
  93. 26 0
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/controller/MakeController.java
  94. 4 2
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/MakeService.java
  95. 71 9
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/MakeServiceImpl.java
  96. 20 15
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/ProdInOutServiceImpl.java
  97. 1 0
      applications/storage/storage-server/src/main/resources/mapper/ProdInOutReportMapper.xml
  98. 78 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/AccountRoleDTO.java
  99. 27 27
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/PowerDTO.java
  100. 18 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java

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

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.commons.api;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+@FeignClient("commons-server")
+public interface CommonService {
+
+    @PostMapping("/action/audit")
+    public String commonAudit(@RequestParam String table, @RequestParam String keyvalue, @RequestParam String status,
+                                      @RequestParam String statuscode, @RequestParam String auditdate, @RequestParam String auditman);
+}

+ 4 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -29,6 +29,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     BIZ_RELDELETE_UPDATE(79306,"存在关联单据,不允许更新编号"),
     BIZ_RELDELETE_UPDATEPROD(79307,"存在关联单据,不允许更新"),
     BIZ_RELDELETE_DELETEPROD(79308,"存在关联单据,不允许删除"),
+    BIZ_PRODWHCODE_REPEAT(79309, "明细仓库重复"),
     NO_OPRATIONDATA(79400,"无可操作单据"),
     BOM_SAVE(79401, "产品编号+版本号已存在"),
     REPEAT_NAME(79501, "名称重复"),
@@ -37,6 +38,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     ILLEGAL_ID(79999, "id不正确"),
     PRODUCT_HAS_WAREHOUSE(79502, "存在物料默认仓库资料为该仓库资料,无法删除"),
     PRODUCTWH_HAS_WAREHOUSE(79503, "该仓库资料存在库存,无法删除"),
+    ACCOUNT_EXISTS(79503, "账号已存在"),
 
 
 
@@ -61,6 +63,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
 
     RECALANCE_OUTNOWBALANCE(74003,"本次核销金额不能大于未核销金额"),
 
+    BANK_AMOUNT_NOTENOUGH(74004, "资金账号不足"),
+
 
 
     //库存

+ 12 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Operation.java

@@ -60,6 +60,18 @@ public enum Operation {
      * 反记账
      */
     UNENDPRODUCT("msg.unEndProduct", "msg.unEndProductSuccess"),
+
+
+    /**
+     * 转采购验收单
+     */
+    TURNPURCCHECKIN("msg.TurnPurcCheckin", "msg.TurnPurcCheckinSuccess"),
+
+    /**
+     * 转采购验退单
+     */
+    TURNPURCCHECKOUT("msg.TurnPurcCheckout", "msg.TurnPurcCheckoutSuccess"),
+
     /**
      * 转出货单
      */

+ 14 - 3
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/CommonController.java

@@ -3,9 +3,10 @@ package com.usoftchina.saas.commons.controller;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.commons.service.CommonService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.context.request.async.DeferredResult;
+
+import java.util.concurrent.CompletableFuture;
 
 @RestController
 public class CommonController {
@@ -23,4 +24,14 @@ public class CommonController {
         return Result.success(commonService.initCheck());
     }
 
+    @PostMapping("/action/audit")
+    public DeferredResult commonAudit(@RequestParam String table, @RequestParam String keyvalue, @RequestParam String status,
+                              @RequestParam String statuscode, @RequestParam String auditdate, @RequestParam String auditman) {
+
+        DeferredResult<String> deferredResult = new DeferredResult<>();
+        CompletableFuture.supplyAsync(() -> commonService.commonAudit(table, keyvalue, status, statuscode, auditdate, auditman))
+                .whenCompleteAsync((result, throwable) -> deferredResult.setResult(result));
+        return deferredResult;
+    }
+
 }

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

@@ -14,4 +14,5 @@ public interface CommonMapper {
 
     int getCountVendor(@Param("companyId") Long companyId);
 
+    void commonAudit(String sql);
 }

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

@@ -10,4 +10,5 @@ public interface CommonService {
      */
     InitStatusDTO initCheck();
 
+    String commonAudit(String table, String keyvalue, String status, String statuscode, String auditdate, String auditman);
 }

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

@@ -2,11 +2,16 @@ package com.usoftchina.saas.commons.service.impl;
 
 import com.usoftchina.saas.commons.dto.InitStatusDTO;
 import com.usoftchina.saas.commons.mapper.CommonMapper;
+import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.commons.service.CommonService;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.utils.DateUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+
 @Service
 public class CommonServiceImpl implements CommonService {
 
@@ -43,4 +48,39 @@ public class CommonServiceImpl implements CommonService {
         }
         return result;
     }
+
+    @Override
+    public String commonAudit(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 = praseSql(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();
+        if (!StringUtils.isEmpty(status)) {
+            sb.append(" " + status + " = '" + Status.AUDITED.getDisplay() + "',");
+        }
+        if (!StringUtils.isEmpty(statuscode)) {
+            sb.append(" " + statuscode + "='" + Status.AUDITED.name() + "',");
+        }
+        if (!StringUtils.isEmpty(auditdate)) {
+            sb.append(" " + auditdate + "='" + DateUtils.format(new Date(), "yyyy-MM-dd") + "',");
+        }
+        if (!StringUtils.isEmpty(auditman)) {
+            sb.append(" " + auditman + "='" + BaseContextHolder.getUserName() + "',");
+        }
+        if (sb.length() > 0) {
+            sql =  sql + sb.substring(0, sb.length() - 1) + " where " + keyvalue + " and companyId=" + companyId;
+            return sql;
+        }
+        return null;
+    }
 }

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

@@ -109,6 +109,7 @@ public class MessageLogServiceImpl extends CommonBaseServiceImpl<MessagelogMappe
         msg.setCreateTime(new Date());
         msg.setCreatorId(BaseContextHolder.getUserId());
         msg.setMl_keyvalue(baseDTO.getId());
+        msg.setMl_man(BaseContextHolder.getUserName());
         getMapper().insert(msg);
         return "success";
     }

+ 5 - 0
applications/commons/commons-server/src/main/resources/mapper/CommonMapper.xml

@@ -13,7 +13,12 @@
     <select id="getCountCustomer" resultType="int">
         SELECT COUNT(*) FROM CUSTOMER WHERE COMPANYID=#{companyId} AND CU_STATUSCODE = 'OPEN'
     </select>
+
     <select id="getCountVendor" resultType="int">
         SELECT COUNT(*) FROM VENDOR WHERE COMPANYID=#{companyId} AND VE_STATUSCODE = 'OPEN'
     </select>
+
+    <update id="commonAudit" parameterType="string">
+      ${value}
+    </update>
 </mapper>

+ 28 - 21
applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml

@@ -11,46 +11,47 @@
     </select>
 
     <select id="getPurchaseDataNow" parameterType="long" resultType="string">
-        select concat('[',GROUP_CONCAT(concat('{"x":"',si_vendname,'","y":',IFNULL(si_amount,0),'}')),']')  from statsinfo
-        where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='PURC' ORDER BY si_amount desc
+        select concat('[',GROUP_CONCAT(concat('{"x":"',ifnull(si_vendname,''),'","y":',IFNULL(round(si_amount/10000,2),0),'}')),']')  from (
+        select * from statsinfo
+        where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='PURC' ORDER BY si_amount desc limit 10) a
     </select>
 
     <select id="getPurchaseDataInSixMonth" parameterType="long" resultType="string">
     select concat('[',d1,',',d2,',',d3,',',d4,',',d5,',',d6,']') from (
-(select concat('{"x":',DATE_FORMAT(now(),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d1 from   statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='PURC' ORDER BY si_amount desc) data_1,
+(select concat('{"x":',DATE_FORMAT(now(),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d1 from   statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='PURC' ORDER BY si_amount desc) data_1,
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d2 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc)data_2,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d2 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc)data_2,
 
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d3 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc)data_3,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d3 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc)data_3,
 
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d4 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc) data_4,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d4 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc) data_4,
 
 
 (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d5 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m') and si_type='PURC' ORDER BY si_amount desc)data_5,
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/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='PURC' ORDER BY si_amount desc)data_6)
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/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='PURC' ORDER BY si_amount desc)data_6)
  </select>
 
 
     <select id="getStorageData" parameterType="long" resultType="string">
       select concat('[',d1,',',d2,',',d3,',',d4,',',d5,',',d6,']') from (
 
-(select concat('{"x":',DATE_FORMAT(now(),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d1 from   statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc) data_1,
+(select concat('{"x":',DATE_FORMAT(now(),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d1 from   statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc) data_1,
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d2 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc)data_2,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d2 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc)data_2,
 
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d3 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc)data_3,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d3 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc)data_3,
 
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d4 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc) data_4,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d4 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc) data_4,
 
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d5 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc)data_5,
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),'}') d5 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m') and si_type='STOCK' ORDER BY si_amount desc)data_5,
 
-(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%Y%m'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/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='STOCK' ORDER BY si_amount desc)data_6);
+(select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%c'),',"y":',ifnull(ROUND(sum((ifnull(si_amount/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='STOCK' ORDER BY si_amount desc)data_6);
     </select>
 
 
@@ -59,24 +60,30 @@
     </select>
 
     <select id="getSaleData" parameterType="long" resultType="string">
-        select concat('[',GROUP_CONCAT(concat('{"x":"',si_custname,'","y":',IFNULL(si_amount,0),'}')),']')  from statsinfo
-        where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='SALE' ORDER BY si_amount desc
+      select concat('[',five,',',other,']') from ((
+
+    select GROUP_CONCAT(concat('{"x":"',si_custname,'","y":',IFNULL(round(si_amount/10000,2),0),'}')) five from (
+    select * from statsinfo where companyid=1 and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='SALE' ORDER BY si_amount desc limit 0,5
+    ) c)d,(
+
+    select concat('{"x":"其它","y":',ifnull(round((all_sum - five_sum)/10000,2),0),'}') other from ( (select sum(si_amount) all_sum from statsinfo  where companyid=1 and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='SALE')a,
+    (select sum(si_amount) five_sum from statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='SALE' ORDER BY si_amount desc limit 0,5)b))e)
     </select>
 
     <select id="getSaleFutureData" parameterType="long" resultType="string">
        	select concat('[',d1,',',d2,',',d3,',',d4,',',d5,',',d6,']') from (
-        (select concat('{"x":',DATE_FORMAT(now(),'%Y%m'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d1 from   statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='SALE' ORDER BY si_amount desc) data_1,
+        (select concat('{"x":',DATE_FORMAT(now(),'%c'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d1 from   statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(now(),'%Y%m') and si_type='SALE' ORDER BY si_amount desc) data_1,
 
-        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d2 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_2,
+        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 1 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'),'}') d2 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 1 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_2,
 
 
-        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d3 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_3,
+        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 2 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'),'}') d3 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 2 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_3,
 
-        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d4 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc) data_4,
+        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 3 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'),'}') d4 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 3 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc) data_4,
 
 
-        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m'),',"sale":',ifnull(ROUND(sum((ifnull(si_amount/10000,0))),2),'0'),',"saleback":',ifnull(ROUND(sum((ifnull(si_amount_rec/10000,0))),2),'0'),'}') d5 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_5,
+        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 4 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'),'}') d5 from  statsinfo where companyid=#{componyId} and si_yearmonth=DATE_FORMAT(date_sub(now(),interval 4 MONTH),'%Y%m') and si_type='SALERETURN' ORDER BY si_amount desc)data_5,
 
-        (select concat('{"x":',DATE_FORMAT(date_sub(now(),interval 5 MONTH),'%Y%m'),',"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 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>
 </mapper>

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

@@ -61,4 +61,6 @@ public class CustomerDTO extends CommonBaseDTO implements Serializable {
     private Double cu_leftamount;
 
     private Double cu_recamount;
+
+    private Double cu_preamount;
 }

+ 195 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Banksubledger.java

@@ -0,0 +1,195 @@
+package com.usoftchina.saas.document.entities;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author hx
+ * @createtime 2018-10-19 15:58
+ */
+@Data
+public class Banksubledger extends CommonBaseEntity implements Serializable {
+    private Integer bl_id;  //ID
+
+    private Integer bl_ym;  //期间
+
+    private Integer bl_bankid;  //账户ID
+
+    private String bl_bankcode; //账户编号
+
+    private String bl_bankname;  //账户名称
+
+    private String bl_code;     //单据编号
+ 
+    private String bl_kind;     //单据类型
+
+    private Date bl_date;      //单据日期
+
+    private String bl_asstype;   //往来类型
+
+    private String bl_asscode;    //往来单位编号
+
+    private String bl_assname;    //往来单位名称
+
+    private Double bl_income;    //收入
+
+    private Double bl_spending;   //支出
+
+    private String bl_manname;    //收/付款人
+ 
+    private String bl_remark;    //备注
+
+    private Double bl_orderamount;
+
+    private Integer bl_assid;
+
+    private String bl_item;
+
+    public Double getBl_orderamount() {
+        return bl_orderamount;
+    }
+
+    public void setBl_orderamount(Double bl_orderamount) {
+        this.bl_orderamount = bl_orderamount;
+    }
+
+    public Integer getBl_assid() {
+        return bl_assid;
+    }
+
+    public void setBl_assid(Integer bl_assid) {
+        this.bl_assid = bl_assid;
+    }
+
+    public String getBl_item() {
+        return bl_item;
+    }
+
+    public void setBl_item(String bl_item) {
+        this.bl_item = bl_item;
+    }
+
+    public Integer getBl_id() {
+        return bl_id;
+    }
+
+    public void setBl_id(Integer bl_id) {
+        this.bl_id = bl_id;
+    }
+
+    public Integer getBl_ym() {
+        return bl_ym;
+    }
+
+    public void setBl_ym(Integer bl_ym) {
+        this.bl_ym = bl_ym;
+    }
+
+    public Integer getBl_bankid() {
+        return bl_bankid;
+    }
+
+    public void setBl_bankid(Integer bl_bankid) {
+        this.bl_bankid = bl_bankid;
+    }
+
+    public String getBl_bankcode() {
+        return bl_bankcode;
+    }
+
+    public void setBl_bankcode(String bl_bankcode) {
+        this.bl_bankcode = bl_bankcode == null ? null : bl_bankcode.trim();
+    }
+
+    public String getBl_bankname() {
+        return bl_bankname;
+    }
+
+    public void setBl_bankname(String bl_bankname) {
+        this.bl_bankname = bl_bankname == null ? null : bl_bankname.trim();
+    }
+
+    public String getBl_code() {
+        return bl_code;
+    }
+
+    public void setBl_code(String bl_code) {
+        this.bl_code = bl_code == null ? null : bl_code.trim();
+    }
+
+    public String getBl_kind() {
+        return bl_kind;
+    }
+
+    public void setBl_kind(String bl_kind) {
+        this.bl_kind = bl_kind == null ? null : bl_kind.trim();
+    }
+
+    public Date getBl_date() {
+        return bl_date;
+    }
+
+    public void setBl_date(Date bl_date) {
+        this.bl_date = bl_date;
+    }
+
+    public String getBl_asstype() {
+        return bl_asstype;
+    }
+
+    public void setBl_asstype(String bl_asstype) {
+        this.bl_asstype = bl_asstype == null ? null : bl_asstype.trim();
+    }
+
+    public String getBl_asscode() {
+        return bl_asscode;
+    }
+
+    public void setBl_asscode(String bl_asscode) {
+        this.bl_asscode = bl_asscode == null ? null : bl_asscode.trim();
+    }
+
+    public String getBl_assname() {
+        return bl_assname;
+    }
+
+    public void setBl_assname(String bl_assname) {
+        this.bl_assname = bl_assname == null ? null : bl_assname.trim();
+    }
+
+    public Double getBl_income() {
+        return bl_income;
+    }
+
+    public void setBl_income(Double bl_income) {
+        this.bl_income = bl_income;
+    }
+
+    public Double getBl_spending() {
+        return bl_spending;
+    }
+
+    public void setBl_spending(Double bl_spending) {
+        this.bl_spending = bl_spending;
+    }
+
+    public String getBl_manname() {
+        return bl_manname;
+    }
+
+    public void setBl_manname(String bl_manname) {
+        this.bl_manname = bl_manname == null ? null : bl_manname.trim();
+    }
+
+    public String getBl_remark() {
+        return bl_remark;
+    }
+
+    public void setBl_remark(String bl_remark) {
+        this.bl_remark = bl_remark == null ? null : bl_remark.trim();
+    }
+
+}

+ 10 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bom.java

@@ -41,6 +41,16 @@ public class Bom extends CommonBaseEntity implements Serializable {
 
     private String pr_orispeccode;
 
+    private String pr_unit;
+
+    public String getPr_unit() {
+        return pr_unit;
+    }
+
+    public void setPr_unit(String pr_unit) {
+        this.pr_unit = pr_unit;
+    }
+
     public String getPr_spec() {
         return pr_spec;
     }

+ 141 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Subledger.java

@@ -0,0 +1,141 @@
+package com.usoftchina.saas.document.entities;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+//中间表
+public class Subledger extends CommonBaseEntity implements Serializable {
+
+    private String sl_code;
+
+    private String sl_kind;
+
+    private Integer sl_custid;
+
+    private Integer sl_vendid;
+
+    private Date sl_date;
+
+    private Double sl_amount;
+
+    private Double sl_preamount;
+
+    private Double sl_yamount;
+
+    private Double sl_namount;
+
+    private String sl_remark;
+
+    private Double sl_orderamount;
+
+    private Double sl_discount;
+
+    private Integer sl_ym;
+
+    public String getSl_code() {
+        return sl_code;
+    }
+
+    public void setSl_code(String sl_code) {
+        this.sl_code = sl_code;
+    }
+
+    public String getSl_kind() {
+        return sl_kind;
+    }
+
+    public void setSl_kind(String sl_kind) {
+        this.sl_kind = sl_kind;
+    }
+
+    public Integer getSl_custid() {
+        return sl_custid;
+    }
+
+    public void setSl_custid(Integer sl_custid) {
+        this.sl_custid = sl_custid;
+    }
+
+    public Integer getSl_vendid() {
+        return sl_vendid;
+    }
+
+    public void setSl_vendid(Integer sl_vendid) {
+        this.sl_vendid = sl_vendid;
+    }
+
+    public Date getSl_date() {
+        return sl_date;
+    }
+
+    public void setSl_date(Date sl_date) {
+        this.sl_date = sl_date;
+    }
+
+    public Double getSl_amount() {
+        return sl_amount;
+    }
+
+    public void setSl_amount(Double sl_amount) {
+        this.sl_amount = sl_amount;
+    }
+
+    public Double getSl_preamount() {
+        return sl_preamount;
+    }
+
+    public void setSl_preamount(Double sl_preamount) {
+        this.sl_preamount = sl_preamount;
+    }
+
+    public Double getSl_yamount() {
+        return sl_yamount;
+    }
+
+    public void setSl_yamount(Double sl_yamount) {
+        this.sl_yamount = sl_yamount;
+    }
+
+    public Double getSl_namount() {
+        return sl_namount;
+    }
+
+    public void setSl_namount(Double sl_namount) {
+        this.sl_namount = sl_namount;
+    }
+
+    public String getSl_remark() {
+        return sl_remark;
+    }
+
+    public void setSl_remark(String sl_remark) {
+        this.sl_remark = sl_remark;
+    }
+
+
+    public Double getSl_orderamount() {
+        return sl_orderamount;
+    }
+
+    public void setSl_orderamount(Double sl_orderamount) {
+        this.sl_orderamount = sl_orderamount;
+    }
+
+    public Double getSl_discount() {
+        return sl_discount;
+    }
+
+    public void setSl_discount(Double sl_discount) {
+        this.sl_discount = sl_discount;
+    }
+
+    public Integer getSl_ym() {
+        return sl_ym;
+    }
+
+    public void setSl_ym(Integer sl_ym) {
+        this.sl_ym = sl_ym;
+    }
+}

+ 1 - 3
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/ProductController.java

@@ -99,9 +99,7 @@ public class ProductController {
 
     @GetMapping("/read/{id}")
     public Result getDataById(@PathVariable("id") Long id){
-        Map<String, Object> map = new HashMap<String, Object>();
-        map.put("main", productService.getDataById(id));
-        return Result.success(map);
+        return Result.success(productService.getDataById(id));
     }
 
     @GetMapping("/ReserveCost")

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

@@ -23,5 +23,6 @@ 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);
 
 }

+ 33 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BanksubledgerMapper.java

@@ -0,0 +1,33 @@
+package com.usoftchina.saas.document.mapper;
+
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.document.entities.Banksubledger;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author hx
+ * @createtime 2018-10-19 15:57
+ */
+public interface BanksubledgerMapper extends CommonBaseMapper<Banksubledger> {
+
+    int deleteByPrimaryKey(@Param("code") String code, @Param("kind") String kind);
+    void deleteByBankid(Integer bk_id);
+
+//    Long insert(Banksubledger record);
+
+    int insertSelective(Banksubledger record);
+    List<String> selectCode(String code);
+
+    Banksubledger selectByPrimaryKey(Integer bl_id);
+
+    int updateByPrimaryKeySelective(Banksubledger record);
+
+    int updateByPrimaryKey(Banksubledger record);
+
+    int updateBankcode(@Param("bk_thisamount") Double bk_thisamount, @Param("nowbalance") Double nowbalance,
+                       @Param("bankcode") String bankcode, @Param("symbol") String symbol);
+    Double selectThisamount(String bankcode);
+}

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

@@ -25,4 +25,6 @@ public interface ProductDetailMapper extends CommonBaseMapper<ProductDetail> {
     Long selectProdidByPrimaryKey(Long id);
 
     List<ProductDetail> selectByProdId(Long id);
+
+    boolean deleteByProdId(Long id);
 }

+ 39 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/SubledgerMapper.java

@@ -0,0 +1,39 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.document.entities.Subledger;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author heqw
+ * @date 2018/11/6 10:33
+ **/
+public interface SubledgerMapper {
+    int deleteByPrimaryKey(@Param("code") String code, @Param("kind") String kind);
+
+    int insert(Subledger record);
+
+    int insertSelective(Subledger record);
+
+    Subledger selectByPrimaryKey(Integer sl_id);
+    String selectCode(String code);
+
+    int updateByPrimaryKeySelective(Subledger record);
+
+    int updateByPrimaryKey(Subledger record);
+
+    List<Subledger> selectSubledgerBycondition(@Param("con") String con, @Param("companyId") Long companyId);
+
+    Subledger selectByKindCodeCustid(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
+                                     @Param("sl_custid") Integer sl_custid);
+
+    Subledger selectByKindCodeVendid(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
+                                     @Param("sl_vendid") Integer sl_vendid);
+
+    void deleteCustomer(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
+                        @Param("sl_custid") Integer sl_custid);
+
+    void deleteVendor(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
+                        @Param("sl_vendid") Integer sl_vendid);
+}

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

@@ -101,7 +101,7 @@ public interface ProductService extends CommonBaseService<ProductMapper, Product
      * @param id
      * @return
      */
-    Product getDataById(Long id);
+    ProductListDTO getDataById(Long id);
 
     /**
      * 物料库存数量金额表

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

@@ -5,15 +5,23 @@ import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.dto.ComboDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.entities.Bankinformation;
+import com.usoftchina.saas.document.entities.Banksubledger;
 import com.usoftchina.saas.document.mapper.BankinformationMapper;
+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 org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -24,24 +32,63 @@ import java.util.List;
 public class BankinformationServiceImpl extends CommonBaseServiceImpl<BankinformationMapper, Bankinformation> implements BankinformationService {
     @Autowired
     private BankinformationMapper bankinformationMapper;
+    @Autowired
+    private BanksubledgerMapper banksubledgerMapper;
 
+    @Transactional
     @Override
     public boolean save(Bankinformation bankinformation){
         bankinformation.setCompanyId(BaseContextHolder.getCompanyId());
         if (bankinformation.getBk_thisamount() == null || bankinformation.getBk_thisamount() == 0){
             bankinformation.setBk_thisamount(bankinformation.getBk_beginamount());
         }
+
+        //判断编号
+        String bktion = bankinformationMapper.selectBankcode(bankinformation.getBk_bankcode());
+        if (bktion != null){
+            throw new BizException(500, BizExceptionCode.ACCOUNT_EXISTS.getMessage());
+        }
+
+        //中间表
+        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){
             bankinformationMapper.insertSelective(bankinformation);
+            banksubledgerMapper.insertSelective(banksubledger);
         }else{
             bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+            banksubledgerMapper.updateByPrimaryKeySelective(banksubledger);
         }
         return true;
     }
 
+    @Transactional
     @Override
     public boolean removeByPrimaryKey(int id){
         bankinformationMapper.deleteByPrimaryKey(id);
+        banksubledgerMapper.deleteByBankid(id);
         return true;
     }
 
@@ -78,4 +125,37 @@ public class BankinformationServiceImpl extends CommonBaseServiceImpl<Bankinform
     public List<ComboDTO> getCombo() {
         return getMapper().getCombo(BaseContextHolder.getCompanyId());
     }
+
+
+    /**
+     * String转Date类型
+     *
+     * @param dateStr
+     *            时间字符串
+     * @return Date类型时间
+     * @throws Exception
+     *             异常
+     */
+    public static Date string2Date(String dateStr, String format) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        if (dateStr == null) {
+            return sdf.parse(dateStr);
+        }
+        return null;
+    }
+
+    /**
+     * Date转String
+     *
+     * @param date
+     *            Date类型时间
+     * @return 时间字符串
+     */
+    public static String date2String(Date date, String format) {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        if (date != null) {
+            return sdf.format(date);
+        }
+        return null;
+    }
 }

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

@@ -16,14 +16,8 @@ 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.entities.Customer;
-import com.usoftchina.saas.document.entities.CustomerList;
-import com.usoftchina.saas.document.entities.Customeraddress;
-import com.usoftchina.saas.document.entities.Customercontact;
-import com.usoftchina.saas.document.mapper.CustomerListMapper;
-import com.usoftchina.saas.document.mapper.CustomerMapper;
-import com.usoftchina.saas.document.mapper.CustomeraddressMapper;
-import com.usoftchina.saas.document.mapper.CustomercontactMapper;
+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;
@@ -33,6 +27,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -58,6 +53,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
 
     @Autowired
     private MaxnumberService maxnumberService;
+    @Autowired
+    private SubledgerMapper subledgerMapper;
 
 
     @Override
@@ -127,6 +124,12 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         customer.setCompanyId(companyId);
         customer.setCreatorId(userId);
         customer.setCreateTime(new Date());
+        //应付款余额
+        Double beginapamount = main.getCu_beginaramount()==null?new Double(0):main.getCu_beginaramount();
+        Double beginprepayamount = main.getCu_beginprerecamount()==null?new Double(0):main.getCu_beginprerecamount();
+        Double recamount = main.getCu_recamount()==null? new Double(0):main.getCu_recamount();
+        Double preamount = main.getCu_preamount()==null? new Double(0):main.getCu_preamount();
+        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-preamount);
 
         //编号校验
         cu_code = pushMaxnubmer(cu_code, cu_id);
@@ -234,6 +237,50 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
             customeraddressMapper.batchUpdate(updateDetail2);
         }
 
+        //更新应收余额
+        Customer customer1 = getMapper().selectByPrimaryKey(cu_id);
+        Double cu_leftamount = (customer1.getCu_beginaramount() == null ? new Double(0) :  customer1.getCu_beginaramount())-
+                (customer1.getCu_beginprerecamount() == null ? new Double(0) : customer1.getCu_beginprerecamount()) +
+                (customer1.getCu_recamount() == null ? new Double(0) : customer1.getCu_recamount()) -
+                (customer1.getCu_preamount() == null ? new Double(0) : customer1.getCu_preamount());
+        customer.setCu_leftamount(cu_leftamount);
+        getMapper().updateByPrimaryKeySelective(customer);
+
+        //插入中间表
+        Double amount = (customer.getCu_beginaramount() == null ? new Double(0) : customer.getCu_beginaramount())
+                - (customer.getCu_beginprerecamount() == null ? new Double(0) : customer.getCu_beginprerecamount());
+        if (amount != new Double(0)){
+            Subledger subledger = new Subledger();
+            subledger.setSl_code("期初余额");
+            subledger.setSl_kind("期初余额");
+            subledger.setSl_vendid(0);
+            subledger.setSl_custid(Math.toIntExact(customer.getId()));
+            subledger.setCompanyId(BaseContextHolder.getCompanyId());
+            String dates = date2String(customer.getCu_begindate(), "yyyy-mm");
+            dates = dates + "-01";
+            Date date = null;
+            try {
+                date = string2Date(dates, "yyyy-mm-dd");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            subledger.setSl_date(date);
+            if (amount > new Double(0)){
+                subledger.setSl_amount(amount);
+            }else {
+                subledger.setSl_preamount(amount);
+            }
+            subledger.setSl_orderamount(Math.abs(amount));
+            subledger.setSl_namount(amount);
+
+            Subledger subledger1 = subledgerMapper.selectByKindCodeCustid("期初余额","期初余额",
+                    Math.toIntExact(customer.getId()));
+            if (subledger1 == null) {
+                subledgerMapper.insertSelective(subledger);
+            }else {
+                subledgerMapper.updateByPrimaryKeySelective(subledger);
+            }
+        }
 
         baseDTO = getBaseDTOById(cu_id);
         //日志记录
@@ -255,6 +302,10 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
             //从表删除
             customercontactMapper.deleteByFK(id);
             customeraddressMapper.deleteByFK(id);
+
+            //删除中间表
+            subledgerMapper.deleteCustomer("期初余额", "期初余额", Math.toIntExact(id));
+
             //日志
             messageLogService.delete(docBaseDTO);
         }
@@ -408,16 +459,51 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return baseDTO;
     }
 
-    private String pushMaxnubmer(String code, Long id) {
+    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.CUSTOMER.getCaller()).getData();
+
+        String cu_code = null;
+        synchronized (CustomerServiceImpl.class){
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                    getMapper().validateCodeWhenUpdate(code, id, companyId);
+            cu_code =  maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.CUSTOMER.getCaller()).getData();
+        }
+        return cu_code;
     }
 
+    /**
+     * String转Date类型
+     *
+     * @param dateStr
+     *            时间字符串
+     * @return Date类型时间
+     * @throws Exception
+     *             异常
+     */
+    public static Date string2Date(String dateStr, String format) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        if (dateStr == null) {
+            return sdf.parse(dateStr);
+        }
+        return null;
+    }
 
+    /**
+     * Date转String
+     *
+     * @param date
+     *            Date类型时间
+     * @return 时间字符串
+     */
+    public static String date2String(Date date, String format) {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        if (date != null) {
+            return sdf.format(date);
+        }
+        return null;
+    }
 
 }

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

@@ -136,14 +136,18 @@ public class EmployeeServiceImpl extends CommonBaseServiceImpl<EmployeeMapper, E
         return new DocBaseDTO(id, code, "Employee");
     }
 
-    private String pushMaxnubmer(String code, Long id) {
+    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.EMPLOYEE.getCaller()).getData();
+        String em_code = null;
+        synchronized (EmployeeServiceImpl.class){
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                    getMapper().validateCodeWhenUpdate(code, id, companyId);
+            em_code =  maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.EMPLOYEE.getCaller()).getData();
+        }
+        return em_code;
     }
 
 }

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

@@ -25,6 +25,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.*;
@@ -75,20 +76,34 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public DocBaseDTO saveData(ProductListDTO productListDTO){
         Product product = productListDTO.getMain();
         List<ProductDetail> productDetailList = productListDTO.getItems();
         DocBaseDTO docBaseDTO = null;
+        Long companyId = BaseContextHolder.getCompanyId();
+        Long userId = BaseContextHolder.getUserId();
+
+        //校验明细仓库是否重复
+        validRepeatWarehouse(productDetailList);
+
         if(product.getId() == 0){
             //保存
             String code = pushMaxnubmer(product.getPr_code(), product.getId());
-            product.setCompanyId(BaseContextHolder.getCompanyId());
-            product.setCreatorId(BaseContextHolder.getUserId());
+            product.setCompanyId(companyId);
+            product.setCreatorId(userId);
             product.setCreateTime(new Date());
             //保存主表
             getMapper().insertSelective(product);
             //保存明细表数据
-            productDetailMapper.batchInsert(productDetailList);
+            if (productDetailList.size() > 0) {
+                for (ProductDetail productDetail : productDetailList){
+                    productDetail.setPd_prodid(product.getId());
+                    productDetail.setCompanyId(companyId);
+                }
+
+                productDetailMapper.batchInsert(productDetailList);
+            }
             //生成库存初始化数据并过账
             generateProdIOPost(product, productDetailList);
 
@@ -116,8 +131,12 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
                 List<ProductDetail> updateItems = new ArrayList<ProductDetail>();
                 for(ProductDetail productDetail : productDetailList){
                     if (productDetail.getId() == 0){
+                        productDetail.setUpdaterId(userId);
+                        productDetail.setUpdateTime(new Date());
                         insertItems.add(productDetail);
                     }else{
+                        productDetail.setUpdaterId(userId);
+                        productDetail.setUpdateTime(new Date());
                         updateItems.add(productDetail);
                     }
                 }
@@ -144,6 +163,27 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
         return docBaseDTO;
     }
 
+    /**
+     * 校验明细仓库是否重复
+     * @param productDetailList
+     */
+    private void validRepeatWarehouse(List<ProductDetail> productDetailList) {
+        if (productDetailList.size() > 0){
+            boolean flag = true;   //假设不重复
+            for (int i = 0; i < productDetailList.size() - 1; i ++){
+                for (int j = i + 1; j < productDetailList.size(); j++){
+                    if (productDetailList.get(i).getPd_whcode().equals(productDetailList.get(j).getPd_whcode())){
+                        flag = false;
+                        break;
+                    }
+                }
+            }
+            if (!flag){
+                throw new BizException(BizExceptionCode.BIZ_PRODWHCODE_REPEAT);
+            }
+        }
+    }
+
     /**
      * 物料发生过除库存初始化外的出入库单时,不能新增,修改,删除
      * @param id
@@ -331,6 +371,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
 
         String code = getMapper().getCodeById(id);
         getMapper().deleteByPrimaryKey(id);
+        productDetailMapper.deleteByProdId(id);
         DocBaseDTO docBaseDTO = generateMsgObj(id, code);
         //记录LOG
         messageLogService.delete(docBaseDTO);
@@ -403,8 +444,13 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     }
 
     @Override
-    public Product getDataById(Long id) {
-        return getMapper().selectByPrimaryKey(id);
+    public ProductListDTO getDataById(Long id) {
+        ProductListDTO productListDTO = new ProductListDTO();
+        Product product = getMapper().selectByPrimaryKey(id);
+        List<ProductDetail> productDetails = productDetailMapper.selectByProdId(id);
+        productListDTO.setMain(product);
+        productListDTO.setItems(productDetails);
+        return productListDTO;
     }
 
     @Override
@@ -426,7 +472,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
     public boolean deleteDetailById(Long id) {
         Long prodId = productDetailMapper.selectProdidByPrimaryKey(id);
         validProductOperation(prodId, BizExceptionCode.BIZ_RELDELETE_DELETEPROD);
-        String prCode = getMapper().selectByPrimaryKey(id).getPr_code();
+        String prCode = getMapper().selectByPrimaryKey(prodId).getPr_code();
         //找到原始单据,反过账并删除
         String inoutCode = getMapper().selectProdIOCode(prCode, BaseContextHolder.getCompanyId(), "库存初始化");
         if (!StringUtils.isEmpty(inoutCode)) {
@@ -480,7 +526,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
      * @Author: chenwei
      * @Date: 2018/10/26
      */
-    private String pushMaxnubmer(String code, Long id) {
+    private synchronized String pushMaxnubmer(String code, Long id) {
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }

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

@@ -14,9 +14,11 @@ import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 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.mapper.SubledgerMapper;
 import com.usoftchina.saas.document.mapper.VendorMapper;
 import com.usoftchina.saas.document.mapper.VendorcontactMapper;
 import com.usoftchina.saas.document.service.VendorService;
@@ -26,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -43,6 +46,8 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
     private MessageLogService messageLogService;
     @Autowired
     private MaxnumberService maxnumberService;
+    @Autowired
+    private SubledgerMapper subledgerMapper;
 
     @Override
     public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, ListReqDTO listReqDTO) {
@@ -121,6 +126,12 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
             }
             //保存主表信息
             main.setVe_code(code);
+            //更新应付款余额
+            Double beginapamount = main.getVe_beginapamount()==null ? new Double(0):main.getVe_beginapamount();
+            Double beginprepayamount = main.getVe_beginprepayamount()==null ? new Double(0):main.getVe_beginprepayamount();
+            Double payamount = main.getVe_payamount()==null? new Double(0):main.getVe_payamount();
+            Double preamount = main.getVe_preamount()==null? new Double(0):main.getVe_preamount();
+            main.setVe_leftamount(beginapamount-beginprepayamount+payamount-preamount);
             getMapper().insertSelective(main);
             Long mainId = main.getId();
             //更新明细表vc_veid
@@ -191,6 +202,51 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
             //记录LOG
             messageLogService.update(generateMsgObj(main.getId(), code));
         }
+
+        //更新应收款余额
+        Double ve_leftamount = (main.getVe_beginapamount() == null ? new Double(0) : main.getVe_beginapamount())
+                - (main.getVe_beginprepayamount() == null ? new Double(0) : main.getVe_beginprepayamount())
+                + (main.getVe_payamount() == null ? new Double(0) : main.getVe_payamount())
+                - (main.getVe_preamount() == null ? new Double(0) : main.getVe_preamount());
+        main.setVe_leftamount(ve_leftamount);
+        getMapper().updateByPrimaryKeySelective(main);
+
+        //插入中间表
+        Double amount = (main.getVe_beginapamount() == null ? new Double(0) : main.getVe_beginapamount())
+                - (main.getVe_beginprepayamount() == null ? new Double(0) : main.getVe_beginprepayamount());
+        if (amount != new Double(0)){
+            Subledger subledger = new Subledger();
+            subledger.setSl_code("期初余额");
+            subledger.setSl_kind("期初余额");
+            subledger.setSl_vendid(Math.toIntExact(main.getId()));
+            subledger.setSl_custid(0);
+            subledger.setCompanyId(BaseContextHolder.getCompanyId());
+            String dates = date2String(main.getVe_begindate(), "yyyy-mm");
+            dates = dates + "-01";
+            Date date = null;
+            try {
+                date = string2Date(dates, "yyyy-mm-dd");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            subledger.setSl_date(date);
+            if (amount > new Double(0)){
+                subledger.setSl_amount(amount);
+            }else {
+                subledger.setSl_preamount(amount);
+            }
+            subledger.setSl_orderamount(Math.abs(amount));
+            subledger.setSl_namount(amount);
+
+            Subledger subledger1 = subledgerMapper.selectByKindCodeVendid("期初余额","期初余额",
+                    Math.toIntExact(main.getId()));
+            if (subledger1 == null) {
+                subledgerMapper.insertSelective(subledger);
+            }else {
+                subledgerMapper.updateByPrimaryKeySelective(subledger);
+            }
+        }
+
         return generateMsgObj(main.getId(), code);
     }
 
@@ -204,6 +260,9 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
             getMapper().deleteByPrimaryKey(id);
             vendorcontactMapper.deleteByFK(id);
             String code = getMapper().getCodeById(id, BaseContextHolder.getCompanyId());
+
+            //删除中间表
+            subledgerMapper.deleteVendor("期初余额", "期初余额", Math.toIntExact(id));
             //记录LOG
             messageLogService.delete(generateMsgObj(id, code));
         }
@@ -349,4 +408,36 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
                 getMapper().validateCodeWhenUpdate(code, id, companyId);
         return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.VENDOR.getCaller()).getData();
     }
+
+    /**
+     * String转Date类型
+     *
+     * @param dateStr
+     *            时间字符串
+     * @return Date类型时间
+     * @throws Exception
+     *             异常
+     */
+    public static Date string2Date(String dateStr, String format) throws Exception {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        if (dateStr == null) {
+            return sdf.parse(dateStr);
+        }
+        return null;
+    }
+
+    /**
+     * Date转String
+     *
+     * @param date
+     *            Date类型时间
+     * @return 时间字符串
+     */
+    public static String date2String(Date date, String format) {
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        if (date != null) {
+            return sdf.format(date);
+        }
+        return null;
+    }
 }

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

@@ -179,7 +179,7 @@
     where ad_id in (#{ids,jdbcType=VARCHAR})
   </delete>
   <select id="selectAll" resultMap="ResultMapWithBLOBs">
-    SELECT * FROM ADDRESS where COMPANYID=#{companyId}
+    SELECT * FROM ADDRESS where COMPANYID=#{companyId} ORDER BY AD_ID DESC
   </select>
   <select id="selectCountByName" resultType="int">
     SELECT count(*) FROM ADDRESS

+ 5 - 0
applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -314,4 +314,9 @@
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
         SELECT CONCAT(bk_bankcode,' ',bk_bankname) display,bk_bankname value FROM bankinformation WHERE COMPANYID=#{companyId}
     </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>
 </mapper>

+ 345 - 0
applications/document/document-server/src/main/resources/mapper/BanksubledgerMapper.xml

@@ -0,0 +1,345 @@
+<?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.BanksubledgerMapper">
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Banksubledger">
+        <id column="bl_id" jdbcType="INTEGER" property="id" />
+        <result column="bl_ym" jdbcType="INTEGER" property="bl_ym" />
+        <result column="bl_bankid" jdbcType="INTEGER" property="bl_bankid" />
+        <result column="bl_bankcode" jdbcType="VARCHAR" property="bl_bankcode" />
+        <result column="bl_bankname" jdbcType="VARCHAR" property="bl_bankname" />
+        <result column="bl_code" jdbcType="VARCHAR" property="bl_code" />
+        <result column="bl_kind" jdbcType="VARCHAR" property="bl_kind" />
+        <result column="bl_date" jdbcType="TIMESTAMP" property="bl_date" />
+        <result column="bl_asstype" jdbcType="VARCHAR" property="bl_asstype" />
+        <result column="bl_asscode" jdbcType="VARCHAR" property="bl_asscode" />
+        <result column="bl_assname" jdbcType="VARCHAR" property="bl_assname" />
+        <result column="bl_income" jdbcType="DOUBLE" property="bl_income" />
+        <result column="bl_spending" jdbcType="DOUBLE" property="bl_spending" />
+        <result column="bl_manname" jdbcType="VARCHAR" property="bl_manname" />
+        <result column="bl_remark" jdbcType="VARCHAR" property="bl_remark" />
+        <result column="companyId" jdbcType="INTEGER" property="companyId" />
+        <result column="updaterId" jdbcType="INTEGER" property="updaterId" />
+        <result column="updatedate" jdbcType="TIMESTAMP" property="updatedate" />
+        <result column="bl_orderamount" property="bl_orderamount" jdbcType="DOUBLE" />
+        <result column="bl_assid" property="bl_assid" jdbcType="INTEGER" />
+        <result column="bl_item" property="bl_item" jdbcType="VARCHAR" />
+    </resultMap>
+    <sql id="Example_Where_Clause">
+        <where>
+            <foreach collection="oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" prefixOverrides="and" suffix=")">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
+            </foreach>
+        </where>
+    </sql>
+    <sql id="Update_By_Example_Where_Clause">
+        <where>
+            <foreach collection="example.oredCriteria" item="criteria" separator="or">
+                <if test="criteria.valid">
+                    <trim prefix="(" prefixOverrides="and" suffix=")">
+                        <foreach collection="criteria.criteria" item="criterion">
+                            <choose>
+                                <when test="criterion.noValue">
+                                    and ${criterion.condition}
+                                </when>
+                                <when test="criterion.singleValue">
+                                    and ${criterion.condition} #{criterion.value}
+                                </when>
+                                <when test="criterion.betweenValue">
+                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                                </when>
+                                <when test="criterion.listValue">
+                                    and ${criterion.condition}
+                                    <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                                        #{listItem}
+                                    </foreach>
+                                </when>
+                            </choose>
+                        </foreach>
+                    </trim>
+                </if>
+            </foreach>
+        </where>
+    </sql>
+    <sql id="Base_Column_List">
+    bl_id, bl_ym, bl_bankid, bl_bankcode, bl_bankname, bl_code, bl_kind, bl_date, bl_asstype, 
+    bl_asscode, bl_assname, bl_income, bl_spending, bl_manname, bl_remark, companyId, 
+    updaterId, updatedate, bl_orderamount, bl_assid, bl_item
+  </sql>
+    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from banksubledger
+        where bl_id = #{bl_id,jdbcType=INTEGER}
+    </select>
+
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from banksubledger
+    where bl_id = #{code,jdbcType=VARCHAR} and bl_kind = #{kind, jdbcType=VARCHAR}
+  </delete>
+
+    <delete id="deleteByBankid" parameterType="java.lang.Integer">
+    delete from banksubledger
+    where bl_id = #{bk_id,jdbcType=INTEGER}
+  </delete>
+
+    <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Banksubledger">
+    insert into banksubledger (bl_id, bl_ym, bl_bankid, 
+      bl_bankcode, bl_bankname, bl_code, 
+      bl_kind, bl_date, bl_asstype, 
+      bl_asscode, bl_assname, bl_income, 
+      bl_spending, bl_manname, bl_remark, 
+      companyId, updaterId, updatedate
+      )
+    values (#{bl_id,jdbcType=INTEGER}, #{bl_ym,jdbcType=INTEGER}, #{bl_bankid,jdbcType=INTEGER}, 
+      #{bl_bankcode,jdbcType=VARCHAR}, #{bl_bankname,jdbcType=VARCHAR}, #{bl_code,jdbcType=VARCHAR}, 
+      #{bl_kind,jdbcType=VARCHAR}, #{bl_date,jdbcType=TIMESTAMP}, #{bl_asstype,jdbcType=VARCHAR}, 
+      #{bl_asscode,jdbcType=VARCHAR}, #{bl_assname,jdbcType=VARCHAR}, #{bl_income,jdbcType=DOUBLE}, 
+      #{bl_spending,jdbcType=DOUBLE}, #{bl_manname,jdbcType=VARCHAR}, #{bl_remark,jdbcType=VARCHAR}, 
+      #{companyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER}, #{updatedate,jdbcType=TIMESTAMP}
+      )
+  </insert>
+    <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Banksubledger">
+        insert into banksubledger
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="bl_ym != null">
+                bl_ym,
+            </if>
+            <if test="bl_bankid != null">
+                bl_bankid,
+            </if>
+            <if test="bl_bankcode != null">
+                bl_bankcode,
+            </if>
+            <if test="bl_bankname != null">
+                bl_bankname,
+            </if>
+            <if test="bl_code != null">
+                bl_code,
+            </if>
+            <if test="bl_kind != null">
+                bl_kind,
+            </if>
+            <if test="bl_date != null">
+                bl_date,
+            </if>
+            <if test="bl_asstype != null">
+                bl_asstype,
+            </if>
+            <if test="bl_asscode != null">
+                bl_asscode,
+            </if>
+            <if test="bl_assname != null">
+                bl_assname,
+            </if>
+            <if test="bl_income != null">
+                bl_income,
+            </if>
+            <if test="bl_spending != null">
+                bl_spending,
+            </if>
+            <if test="bl_manname != null">
+                bl_manname,
+            </if>
+            <if test="bl_remark != null">
+                bl_remark,
+            </if>
+            <if test="companyId != null">
+                companyId,
+            </if>
+            <if test="updaterId != null">
+                updaterId,
+            </if>
+            <if test="updateTime != null">
+                updatedate,
+            </if>
+            <if test="bl_orderamount != null" >
+                bl_orderamount,
+            </if>
+            <if test="bl_assid != null" >
+                bl_assid,
+            </if>
+            <if test="bl_item != null" >
+                bl_item,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="bl_ym != null">
+                #{bl_ym,jdbcType=INTEGER},
+            </if>
+            <if test="bl_bankid != null">
+                #{bl_bankid,jdbcType=INTEGER},
+            </if>
+            <if test="bl_bankcode != null">
+                #{bl_bankcode,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_bankname != null">
+                #{bl_bankname,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_code != null">
+                #{bl_code,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_kind != null">
+                #{bl_kind,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_date != null">
+                #{bl_date,jdbcType=TIMESTAMP},
+            </if>
+            <if test="bl_asstype != null">
+                #{bl_asstype,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_asscode != null">
+                #{bl_asscode,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_assname != null">
+                #{bl_assname,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_income != null">
+                #{bl_income,jdbcType=DOUBLE},
+            </if>
+            <if test="bl_spending != null">
+                #{bl_spending,jdbcType=DOUBLE},
+            </if>
+            <if test="bl_manname != null">
+                #{bl_manname,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_remark != null">
+                #{bl_remark,jdbcType=VARCHAR},
+            </if>
+            <if test="companyId != null">
+                #{companyId,jdbcType=INTEGER},
+            </if>
+            <if test="updaterId != null">
+                #{updaterId,jdbcType=INTEGER},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="bl_orderamount != null" >
+                #{bl_orderamount,jdbcType=DOUBLE},
+            </if>
+            <if test="bl_assid != null" >
+                #{bl_assid,jdbcType=INTEGER},
+            </if>
+            <if test="bl_item != null" >
+                #{bl_item,jdbcType=VARCHAR},
+            </if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Banksubledger">
+        update banksubledger
+        <set>
+            <if test="bl_ym != null">
+                bl_ym = #{bl_ym,jdbcType=INTEGER},
+            </if>
+            <if test="bl_bankid != null">
+                bl_bankid = #{bl_bankid,jdbcType=INTEGER},
+            </if>
+            <if test="bl_bankcode != null">
+                bl_bankcode = #{bl_bankcode,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_bankname != null">
+                bl_bankname = #{bl_bankname,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_code != null">
+                bl_code = #{bl_code,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_kind != null">
+                bl_kind = #{bl_kind,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_date != null">
+                bl_date = #{bl_date,jdbcType=TIMESTAMP},
+            </if>
+            <if test="bl_asstype != null">
+                bl_asstype = #{bl_asstype,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_asscode != null">
+                bl_asscode = #{bl_asscode,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_assname != null">
+                bl_assname = #{bl_assname,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_income != null">
+                bl_income = #{bl_income,jdbcType=DOUBLE},
+            </if>
+            <if test="bl_spending != null">
+                bl_spending = #{bl_spending,jdbcType=DOUBLE},
+            </if>
+            <if test="bl_manname != null">
+                bl_manname = #{bl_manname,jdbcType=VARCHAR},
+            </if>
+            <if test="bl_remark != null">
+                bl_remark = #{bl_remark,jdbcType=VARCHAR},
+            </if>
+            <if test="companyId != null">
+                companyId = #{companyId,jdbcType=INTEGER},
+            </if>
+            <if test="updaterId != null">
+                updaterId = #{updaterId,jdbcType=INTEGER},
+            </if>
+            <if test="updateTime != null">
+                updatedate = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        where bl_id = #{id,jdbcType=INTEGER}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Banksubledger">
+    update banksubledger
+    set bl_ym = #{bl_ym,jdbcType=INTEGER},
+      bl_bankid = #{bl_bankid,jdbcType=INTEGER},
+      bl_bankcode = #{bl_bankcode,jdbcType=VARCHAR},
+      bl_bankname = #{bl_bankname,jdbcType=VARCHAR},
+      bl_code = #{bl_code,jdbcType=VARCHAR},
+      bl_kind = #{bl_kind,jdbcType=VARCHAR},
+      bl_date = #{bl_date,jdbcType=TIMESTAMP},
+      bl_asstype = #{bl_asstype,jdbcType=VARCHAR},
+      bl_asscode = #{bl_asscode,jdbcType=VARCHAR},
+      bl_assname = #{bl_assname,jdbcType=VARCHAR},
+      bl_income = #{bl_income,jdbcType=DOUBLE},
+      bl_spending = #{bl_spending,jdbcType=DOUBLE},
+      bl_manname = #{bl_manname,jdbcType=VARCHAR},
+      bl_remark = #{bl_remark,jdbcType=VARCHAR},
+      companyId = #{companyId,jdbcType=INTEGER},
+      updaterId = #{updaterId,jdbcType=INTEGER},
+      updatedate = #{updatedate,jdbcType=TIMESTAMP}
+    where bl_id = #{bl_id,jdbcType=INTEGER}
+  </update>
+    <select id="selectCode" parameterType="java.lang.String" resultType="java.lang.String">
+        select bl_code
+        from banksubledger
+        where bl_code = #{bl_code,jdbcType=VARCHAR}
+    </select>
+
+    <update id="updateBankcode">
+    update bankinformation
+    set bk_thisamount = (IFNULL(#{bk_thisamount,jdbcType=DOUBLE},0) ${symbol} #{nowbalance})
+    where bk_bankcode = #{bankcode,jdbcType=VARCHAR}
+  </update>
+
+    <select id="selectThisamount" resultType="java.lang.Double" parameterType="java.lang.String">
+   select bk_thisamount from bankinformation
+    where bk_bankcode = #{bankcode,jdbcType=VARCHAR}
+  </select>
+
+</mapper>

+ 1 - 0
applications/document/document-server/src/main/resources/mapper/BomMapper.xml

@@ -22,6 +22,7 @@
     <result column="bo_text5" property="bo_text5" jdbcType="VARCHAR" />
     <result column="pr_brand" property="pr_brand" jdbcType="VARCHAR" />
     <result column="pr_spec" property="pr_spec" jdbcType="VARCHAR" />
+    <result column="pr_unit" property="pr_unit" jdbcType="VARCHAR" />
     <result column="pr_orispeccode" property="pr_orispeccode" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >

+ 1 - 0
applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml

@@ -31,6 +31,7 @@
     <result column="cu_text5" jdbcType="VARCHAR" property="cu_text5" />
     <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" />
   </resultMap>
   <sql id="Base_Column_List">
     cu_id, cu_code, cu_name, cu_uu, cu_type, cu_begindate, cu_beginaramount, cu_beginprerecamount, 

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/CustomerkindMapper.xml

@@ -120,7 +120,7 @@
     where ck_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM CUSTOMERKIND WHERE COMPANYID=#{companyId}
+    SELECT * FROM CUSTOMERKIND WHERE COMPANYID=#{companyId} order by ck_id desc
   </select>
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
     SELECT ck_name display,ck_name value FROM CUSTOMERKIND WHERE COMPANYID=#{companyId}

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/FundinouttypeMapper.xml

@@ -140,7 +140,7 @@
     where ft_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM FUNDINOUTTYPE where companyId=#{companyId}
+    SELECT * FROM FUNDINOUTTYPE where companyId=#{companyId} ORDER BY FT_ID DESC
   </select>
   <select id="selectCountByName" resultType="int">
     SELECT COUNT(*) FROM FUNDINOUTTYPE

+ 5 - 2
applications/document/document-server/src/main/resources/mapper/ProductDetailMapper.xml

@@ -255,7 +255,7 @@
         )
         VALUES
         <foreach collection="list" item="item" index="index" open="" close="" separator=",">
-            values ( #{item.pd_prodid,jdbcType=INTEGER}, #{item.pd_prodcode,jdbcType=VARCHAR},
+            ( #{item.pd_prodid,jdbcType=INTEGER}, #{item.pd_prodcode,jdbcType=VARCHAR},
             #{item.pd_detno,jdbcType=INTEGER}, #{item.pd_whcode,jdbcType=VARCHAR}, #{item.pd_whname,jdbcType=VARCHAR},
             #{item.pd_whid,jdbcType=INTEGER}, #{item.pd_price,jdbcType=DOUBLE}, #{item.pd_amount,jdbcType=DOUBLE},
             #{item.companyId,jdbcType=INTEGER}, #{item.updaterId,jdbcType=INTEGER}, #{item.updateTime,jdbcType=TIMESTAMP},
@@ -324,9 +324,12 @@
         </foreach>
     </update>
     <select id="selectProdidByPrimaryKey" resultType="java.lang.Long">
-        SELECT PD_PRODID FROM PRODUCTDETAIL WHERE PD_ID=#{id}
+        SELECT PD_PRODID FROM PRODUCTDETAIL WHERE ID=#{id}
     </select>
     <select id="selectByProdId" resultType="com.usoftchina.saas.document.entities.ProductDetail">
         SELECT * FROM PRODUCTDETAIL WHERE PD_PRODID=#{id}
     </select>
+    <delete id="deleteByProdId" >
+        DELETE FROM PRODUCTDETAIL WHERE PD_PRODID=#{id}
+    </delete>
 </mapper>

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

@@ -903,9 +903,9 @@
         </where>
     </select>
 
-    <select id="selectOrderCountByProdCode" resultType="java.lang.Long">
+    <select id="selectOrderCountByProdCode" resultType="java.lang.Integer">
         SELECT COUNT(*) FROM PRODINOUT LEFT JOIN PRODIODETAIL ON PI_ID=PD_PIID AND PRODINOUT.COMPANYID=PRODIODETAIL.COMPANYID
-        WHERE COMPANYID = #{companyId} AND PD_PRODID = #{id}
+        WHERE PRODIODETAIL.COMPANYID = #{companyId} AND PD_PRODID = #{id}
     </select>
 
     <delete id="deleteProdIOByCode" >

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProductbrandMapper.xml

@@ -130,7 +130,7 @@
   </select>
 
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
-    SELECT PB_NAME display,PB_NAME value FROM PRODUCTBRAND WHERE COMPANYID=#{companyId}
+    SELECT PB_NAME display,PB_NAME value FROM PRODUCTBRAND WHERE COMPANYID=#{companyId} ORDER BY PB_ID DESC
   </select>
   <select id="selectCountByName" resultType="int">
     SELECT COUNT(*) FROM PRODUCTBRAND

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProducttypeMapper.xml

@@ -126,7 +126,7 @@
     where pt_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM PRODUCTTYPE where companyId=#{companyId}
+    SELECT * FROM PRODUCTTYPE where companyId=#{companyId} ORDER BY PT_ID DESC
   </select>
     <select id="selectCountByName" resultType="int">
         SELECT COUNT(*) FROM PRODUCTTYPE

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/ProductunitMapper.xml

@@ -120,7 +120,7 @@
     where pu_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM PRODUCTUNIT where companyId=#{companyId}
+    SELECT * FROM PRODUCTUNIT where companyId=#{companyId} ORDER BY PU_ID DESC
   </select>
     <select id="selectCountByName" resultType="int">
         SELECT COUNT(*) FROM productunit

+ 277 - 0
applications/document/document-server/src/main/resources/mapper/SubledgerMapper.xml

@@ -0,0 +1,277 @@
+<?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.SubledgerMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Subledger" >
+    <id column="sl_id" property="id" jdbcType="INTEGER" />
+    <result column="sl_code" property="sl_code" jdbcType="VARCHAR" />
+    <result column="sl_kind" property="sl_kind" jdbcType="VARCHAR" />
+    <result column="sl_custid" property="sl_custid" jdbcType="INTEGER" />
+    <result column="sl_vendid" property="sl_vendid" jdbcType="INTEGER" />
+    <result column="sl_date" property="sl_date" jdbcType="TIMESTAMP" />
+    <result column="sl_amount" property="sl_amount" jdbcType="DOUBLE" />
+    <result column="sl_preamount" property="sl_preamount" jdbcType="DOUBLE" />
+    <result column="sl_yamount" property="sl_yamount" jdbcType="DOUBLE" />
+    <result column="sl_namount" property="sl_namount" jdbcType="DOUBLE" />
+    <result column="sl_remark" property="sl_remark" jdbcType="VARCHAR" />
+    <result column="companyId" property="companyId" jdbcType="INTEGER" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="sl_orderamount" property="sl_orderamount" jdbcType="DOUBLE" />
+    <result column="sl_discount" property="sl_discount" jdbcType="DOUBLE" />
+    <result column="sl_ym" property="sl_ym" jdbcType="INTEGER" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    sl_id, sl_code, sl_kind, sl_custid, sl_vendid, sl_date, sl_amount, sl_preamount, 
+    sl_yamount, sl_namount, sl_remark, companyId, updaterId, updateTime, sl_orderamount, 
+    sl_discount, sl_ym
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+    select 
+    <include refid="Base_Column_List" />
+    from subledger
+    where sl_id = #{sl_id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
+    delete from subledger
+    where sl_code = #{code,jdbcType=VARCHAR} and sl_kind = #{kind, jdbcType=VARCHAR}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Subledger" >
+    insert into subledger (sl_id, sl_code, sl_kind, 
+      sl_custid, sl_vendid, sl_date, 
+      sl_amount, sl_preamount, sl_yamount, 
+      sl_namount, sl_remark, companyId, 
+      updaterId, updateTime, sl_orderamount, 
+      sl_discount, sl_ym)
+    values (#{sl_id,jdbcType=INTEGER}, #{sl_code,jdbcType=VARCHAR}, #{sl_kind,jdbcType=VARCHAR}, 
+      #{sl_custid,jdbcType=INTEGER}, #{sl_vendid,jdbcType=INTEGER}, #{sl_date,jdbcType=TIMESTAMP}, 
+      #{sl_amount,jdbcType=DOUBLE}, #{sl_preamount,jdbcType=DOUBLE}, #{sl_yamount,jdbcType=DOUBLE}, 
+      #{sl_namount,jdbcType=DOUBLE}, #{sl_remark,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, 
+      #{updaterId,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, #{sl_orderamount,jdbcType=DOUBLE}, 
+      #{sl_discount,jdbcType=DOUBLE}, #{sl_ym,jdbcType=INTEGER})
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Subledger" >
+    insert into subledger
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="sl_code != null" >
+        sl_code,
+      </if>
+      <if test="sl_kind != null" >
+        sl_kind,
+      </if>
+      <if test="sl_custid != null" >
+        sl_custid,
+      </if>
+      <if test="sl_vendid != null" >
+        sl_vendid,
+      </if>
+      <if test="sl_date != null" >
+        sl_date,
+      </if>
+      <if test="sl_amount != null" >
+        sl_amount,
+      </if>
+      <if test="sl_preamount != null" >
+        sl_preamount,
+      </if>
+      <if test="sl_yamount != null" >
+        sl_yamount,
+      </if>
+      <if test="sl_namount != null" >
+        sl_namount,
+      </if>
+      <if test="sl_remark != null" >
+        sl_remark,
+      </if>
+      <if test="companyId != null" >
+        companyId,
+      </if>
+      <if test="updaterId != null" >
+        updaterId,
+      </if>
+      <if test="updateTime != null" >
+        updateTime,
+      </if>
+      <if test="sl_orderamount != null" >
+        sl_orderamount,
+      </if>
+      <if test="sl_discount != null" >
+        sl_discount,
+      </if>
+      <if test="sl_ym != null" >
+        sl_ym,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="sl_code != null" >
+        #{sl_code,jdbcType=VARCHAR},
+      </if>
+      <if test="sl_kind != null" >
+        #{sl_kind,jdbcType=VARCHAR},
+      </if>
+      <if test="sl_custid != null" >
+        #{sl_custid,jdbcType=INTEGER},
+      </if>
+      <if test="sl_vendid != null" >
+        #{sl_vendid,jdbcType=INTEGER},
+      </if>
+      <if test="sl_date != null" >
+        #{sl_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="sl_amount != null" >
+        #{sl_amount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_preamount != null" >
+        #{sl_preamount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_yamount != null" >
+        #{sl_yamount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_namount != null" >
+        #{sl_namount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_remark != null" >
+        #{sl_remark,jdbcType=VARCHAR},
+      </if>
+      <if test="companyId != null" >
+        #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updateTime != null" >
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="sl_orderamount != null" >
+        #{sl_orderamount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_discount != null" >
+        #{sl_discount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_ym != null" >
+        #{sl_ym,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Subledger" >
+    update subledger
+    <set >
+      <if test="sl_code != null" >
+        sl_code = #{sl_code,jdbcType=VARCHAR},
+      </if>
+      <if test="sl_kind != null" >
+        sl_kind = #{sl_kind,jdbcType=VARCHAR},
+      </if>
+      <if test="sl_custid != null" >
+        sl_custid = #{sl_custid,jdbcType=INTEGER},
+      </if>
+      <if test="sl_vendid != null" >
+        sl_vendid = #{sl_vendid,jdbcType=INTEGER},
+      </if>
+      <if test="sl_date != null" >
+        sl_date = #{sl_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="sl_amount != null" >
+        sl_amount = #{sl_amount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_preamount != null" >
+        sl_preamount = #{sl_preamount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_yamount != null" >
+        sl_yamount = #{sl_yamount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_namount != null" >
+        sl_namount = #{sl_namount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_remark != null" >
+        sl_remark = #{sl_remark,jdbcType=VARCHAR},
+      </if>
+      <if test="companyId != null" >
+        companyId = #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        updaterId = #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updateTime != null" >
+        updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="sl_orderamount != null" >
+        sl_orderamount = #{sl_orderamount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_discount != null" >
+        sl_discount = #{sl_discount,jdbcType=DOUBLE},
+      </if>
+      <if test="sl_ym != null" >
+        sl_ym = #{sl_ym,jdbcType=INTEGER},
+      </if>
+    </set>
+    where sl_id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Subledger" >
+    update subledger
+    set sl_code = #{sl_code,jdbcType=VARCHAR},
+      sl_kind = #{sl_kind,jdbcType=VARCHAR},
+      sl_custid = #{sl_custid,jdbcType=INTEGER},
+      sl_vendid = #{sl_vendid,jdbcType=INTEGER},
+      sl_date = #{sl_date,jdbcType=TIMESTAMP},
+      sl_amount = #{sl_amount,jdbcType=DOUBLE},
+      sl_preamount = #{sl_preamount,jdbcType=DOUBLE},
+      sl_yamount = #{sl_yamount,jdbcType=DOUBLE},
+      sl_namount = #{sl_namount,jdbcType=DOUBLE},
+      sl_remark = #{sl_remark,jdbcType=VARCHAR},
+      companyId = #{companyId,jdbcType=INTEGER},
+      updaterId = #{updaterId,jdbcType=INTEGER},
+      updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      sl_orderamount = #{sl_orderamount,jdbcType=DOUBLE},
+      sl_discount = #{sl_discount,jdbcType=DOUBLE},
+      sl_ym = #{sl_ym,jdbcType=INTEGER}
+    where sl_id = #{sl_id,jdbcType=INTEGER}
+  </update>
+
+  <select id="selectSubledgerBycondition" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from subledger
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="companyId != null">
+        and   subledger.companyId = #{companyId}
+      </if>
+    </where>  order by sl_date desc
+  </select>
+
+  <select id="selectCode" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select sl_code
+        from subledger
+        where sl_code = #{sl_code,jdbcType=VARCHAR}
+    </select>
+
+  <select id="selectByKindCodeCustid" resultMap="BaseResultMap">
+  select
+  <include refid="Base_Column_List" />
+  from subledger
+  where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind,jdbcType=VARCHAR} and
+    sl_custid = #{sl_custid,jdbcType=INTEGER}
+  </select>
+
+  <select id="selectByKindCodeVendid" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from subledger
+    where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind,jdbcType=VARCHAR} and
+    sl_vendid = #{sl_vendid,jdbcType=INTEGER}
+  </select>
+
+  <delete id="deleteCustomer">
+    delete from subledger
+    where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind, jdbcType=VARCHAR} and
+    sl_custid = #{sl_custid,jdbcType=INTEGER}
+  </delete>
+
+  <delete id="deleteVendor">
+    delete from subledger
+    where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind, jdbcType=VARCHAR} and
+    sl_vendid = #{sl_vendid,jdbcType=INTEGER}
+  </delete>
+</mapper>

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/VendorkindMapper.xml

@@ -126,7 +126,7 @@
     where vk_id = #{id}
   </update>
   <select id="selectAll" resultMap="BaseResultMap">
-    SELECT * FROM VENDORKIND where companyId = #{companyId}
+    SELECT * FROM VENDORKIND where companyId = #{companyId} ORDER BY VK_ID DESC
   </select>
   <select id="getCombo" resultType="com.usoftchina.saas.commons.dto.ComboDTO">
     SELECT VK_NAME display, VK_NAME value FROM VENDORKIND WHERE COMPANYID=#{companyId}

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

@@ -347,7 +347,7 @@
     <select id="selectCountByCode" resultType="int">
         SELECT COUNT(*) FROM warehouse
         <where>
-            <if test="name!=null">
+            <if test="code!=null">
                 and wh_code=#{code}
             </if>
             <if test="companyId!=0 and companyId!=null">

+ 2 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/FundtransferController.java

@@ -80,8 +80,8 @@ public class FundtransferController {
     @Transactional
     @RequestMapping("/audit")
     public Result audit(@RequestBody Fundtran body){
-        fundtransferService.audit(body);
-        return Result.success();
+        DocBaseDTO docBaseDTO = fundtransferService.audit(body);
+        return Result.success(docBaseDTO);
     }
 
     @Transactional

+ 2 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/OthreceiptsController.java

@@ -59,8 +59,8 @@ public class OthreceiptsController {
     @Transactional
     @RequestMapping("/audit")
     public Result audit(@RequestBody Othte body){
-        othreceiptsService.audit(body);
-        return Result.success();
+        DocBaseDTO docBaseDTO = othreceiptsService.audit(body);
+        return Result.success(docBaseDTO);
     }
 
     @Transactional

+ 2 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/OthspengdingsController.java

@@ -62,8 +62,8 @@ public class OthspengdingsController {
     @Transactional
     @RequestMapping("/audit")
     public Result audit(@RequestBody Othsp body){
-        othspendingsService.audit(body);
-        return Result.success();
+        DocBaseDTO docBaseDTO = othspendingsService.audit(body);
+        return Result.success(docBaseDTO);
     }
 
     @Transactional

+ 2 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/PaybalanceController.java

@@ -65,8 +65,8 @@ public class PaybalanceController {
     @Transactional
     @RequestMapping("/audit")
     public Result audit(@RequestBody Pay body){
-        paybalanceService.audit(body);
-        return Result.success();
+        DocBaseDTO docBaseDTO = paybalanceService.audit(body);
+        return Result.success(docBaseDTO);
     }
 
     @Transactional

+ 2 - 2
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/RecbalanceContorller.java

@@ -66,8 +66,8 @@ public class RecbalanceContorller {
     @Transactional
     @RequestMapping("/audit")
     public Result audit(@RequestBody Rec body){
-        recbalanceService.audit(body);
-        return Result.success();
+        DocBaseDTO docBaseDTO = recbalanceService.audit(body);
+        return Result.success(docBaseDTO);
     }
 
     @Transactional

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

@@ -1,12 +1,14 @@
 package com.usoftchina.saas.money.mapper;
 
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.money.po.Fundtransfer;
 import com.usoftchina.saas.money.po.Othreceipts;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
-public interface FundtransferMapper {
+public interface FundtransferMapper extends CommonBaseMapper<Fundtransfer> {
+    String selectCodeById(Long id);
     int deleteByPrimaryKey(Integer ftId);
     int deleteItem(int id);
 

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

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.money.mapper;
 
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.money.po.Othreceipts;
 import com.usoftchina.saas.money.po.Recbalance;
 import com.usoftchina.saas.page.PageRequest;
@@ -7,7 +8,9 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
-public interface OthreceiptsMapper {
+public interface OthreceiptsMapper extends CommonBaseMapper<Othreceipts> {
+
+    String selectCodeById(Long id);
     int deleteByPrimaryKey(Integer orId);
 
     int insert(Othreceipts record);

+ 2 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthreceiptsdetailMapper.java

@@ -17,4 +17,6 @@ public interface OthreceiptsdetailMapper {
     int updateByPrimaryKeySelective(Othreceiptsdetail record);
 
     int updateByPrimaryKey(Othreceiptsdetail record);
+
+    List<Integer> selectYm(Integer id);
 }

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

@@ -1,12 +1,14 @@
 package com.usoftchina.saas.money.mapper;
 
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.money.po.Othreceipts;
 import com.usoftchina.saas.money.po.Othspendings;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
-public interface OthspendingsMapper {
+public interface OthspendingsMapper extends CommonBaseMapper<Othspendings> {
+    String selectCodeById(Long id);
     int deleteByPrimaryKey(Integer osId);
 
     int insert(Othspendings record);

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

@@ -17,4 +17,5 @@ public interface OthspendingsdetailMapper {
     int updateByPrimaryKeySelective(Othspendingsdetail record);
 
     int updateByPrimaryKey(Othspendingsdetail record);
+    List<Integer> selectYm(Integer id);
 }

+ 5 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalanceMapper.java

@@ -11,6 +11,7 @@ import java.util.List;
 
 public interface PaybalanceMapper extends CommonBaseMapper<Paybalance> {
 
+    String selectCodeById(Long id);
     int deleteByPrimaryKey(Integer pb_id);
 
 //    Long insert(Paybalance record);
@@ -38,4 +39,8 @@ public interface PaybalanceMapper extends CommonBaseMapper<Paybalance> {
     Vendor selectVendorByPrimaryKey(Integer bkId);
 
     int updateVendorByPrimaryKeySelective(Vendor record);
+
+    Double selectThisamount(Integer id);
+
+    void updateBankAmount(@Param("bk_thisamount") Double bk_thisamount, @Param("id") Integer id);
 }

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

@@ -19,5 +19,6 @@ public interface PaybalancedetMapper {
     int updateByPrimaryKeySelective(Paybalancedet record);
 
     int updateByPrimaryKey(Paybalancedet record);
+    List<Integer> selectYm(Integer id);
 
 }

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

@@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Param;
  * @createtime 2018-10-19 15:58
  */
 public interface RecbalanceMapper extends CommonBaseMapper<Recbalance> {
+    String selectCodeById(Long id);
     int countByExample(RecbalanceExample example);
 
     int deleteByExample(RecbalanceExample example);

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

@@ -23,4 +23,5 @@ public interface RecbalancedetMapper extends CommonBaseMapper<Recbalancedet> {
     int updateByPrimaryKeySelective(Recbalancedet record);
 
     int updateByPrimaryKey(Recbalancedet record);
+    List<Integer> selectYm(Integer id);
 }

+ 14 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/StatsinfoMapper.java

@@ -0,0 +1,14 @@
+package com.usoftchina.saas.money.mapper;
+
+import com.usoftchina.saas.money.po.Statsinfo;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author heqw
+ * @date 2018/11/14 16:13
+ **/
+public interface StatsinfoMapper {
+    Integer select(@Param("si_yearmonth") Integer si_yearmonth, @Param("companyid") Long companyid);
+    void update(Statsinfo statsinfo);
+    void insert(Statsinfo statsinfo);
+}

+ 83 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Paybalance.java

@@ -63,6 +63,25 @@ public class Paybalance extends CommonBaseEntity implements Serializable {
 
     private Double ve_leftamount;
 
+    private String pd_bankname;
+
+    private String pd_paymethod;
+
+    private String pd_paycode;
+
+    private String pd_remark;
+
+    private String pbd_slcode;
+
+    private String pbd_slkind;
+
+    private Date pbd_sldate;
+
+    private Double pbd_amount;
+
+    private Double pbd_nowbalance;
+
+
     public Date getUpdatedate() {
         return updatedate;
     }
@@ -262,4 +281,68 @@ public class Paybalance extends CommonBaseEntity implements Serializable {
     public void setVe_leftamount(Double ve_leftamount) {
         this.ve_leftamount = ve_leftamount;
     }
+
+    public String getPd_bankname() {
+        return pd_bankname;
+    }
+
+    public void setPd_bankname(String pd_bankname) {
+        this.pd_bankname = pd_bankname;
+    }
+
+    public String getPbd_slcode() {
+        return pbd_slcode;
+    }
+
+    public void setPbd_slcode(String pbd_slcode) {
+        this.pbd_slcode = pbd_slcode;
+    }
+
+    public String getPbd_slkind() {
+        return pbd_slkind;
+    }
+
+    public void setPbd_slkind(String pbd_slkind) {
+        this.pbd_slkind = pbd_slkind;
+    }
+
+    public Date getPbd_sldate() {
+        return pbd_sldate;
+    }
+
+    public void setPbd_sldate(Date pbd_sldate) {
+        this.pbd_sldate = pbd_sldate;
+    }
+
+    public Double getPbd_amount() {
+        return pbd_amount;
+    }
+
+    public void setPbd_amount(Double pbd_amount) {
+        this.pbd_amount = pbd_amount;
+    }
+
+    public Double getPbd_nowbalance() {
+        return pbd_nowbalance;
+    }
+
+    public void setPbd_nowbalance(Double pbd_nowbalance) {
+        this.pbd_nowbalance = pbd_nowbalance;
+    }
+
+    public String getPd_paymethod() {
+        return pd_paymethod;
+    }
+
+    public void setPd_paymethod(String pd_paymethod) {
+        this.pd_paymethod = pd_paymethod;
+    }
+
+    public String getPd_remark() {
+        return pd_remark;
+    }
+
+    public void setPd_remark(String pd_remark) {
+        this.pd_remark = pd_remark;
+    }
 }

+ 21 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Recbalance.java

@@ -63,6 +63,27 @@ public class Recbalance extends CommonBaseEntity implements Serializable {
 
     private Double cu_leftamount;
 
+    private String rd_bankname;
+
+    private String rd_paymethod;
+
+    private String rd_paycode;
+
+    private String rd_remark;
+
+    private String rbd_slcode;
+
+    private String rbd_slkind;
+
+    private Date rbd_sldate;
+
+    private Double rbd_amount;
+
+    private Double rbd_nowbalance;
+
+
+
+
     public Date getUpdatedate() {
         return updatedate;
     }

+ 71 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Statsinfo.java

@@ -0,0 +1,71 @@
+package com.usoftchina.saas.money.po;
+
+/**
+ * @author heqw
+ * @date 2018/11/14 16:02
+ **/
+public class Statsinfo {
+    private Double si_yearmonth;
+    private Double si_amount_pay;
+    private Double si_amount_otherpay;
+    private Double si_amount_rec;
+    private Double si_amount_otherrec;
+    private Long companyid;
+    private String si_type;
+
+    public Double getSi_yearmonth() {
+        return si_yearmonth;
+    }
+
+    public void setSi_yearmonth(Double si_yearmonth) {
+        this.si_yearmonth = si_yearmonth;
+    }
+
+    public Double getSi_amount_pay() {
+        return si_amount_pay;
+    }
+
+    public void setSi_amount_pay(Double si_amount_pay) {
+        this.si_amount_pay = si_amount_pay;
+    }
+
+    public Double getSi_amount_otherpay() {
+        return si_amount_otherpay;
+    }
+
+    public void setSi_amount_otherpay(Double si_amount_otherpay) {
+        this.si_amount_otherpay = si_amount_otherpay;
+    }
+
+    public Double getSi_amount_rec() {
+        return si_amount_rec;
+    }
+
+    public void setSi_amount_rec(Double si_amount_rec) {
+        this.si_amount_rec = si_amount_rec;
+    }
+
+    public Double getSi_amount_otherrec() {
+        return si_amount_otherrec;
+    }
+
+    public void setSi_amount_otherrec(Double si_amount_otherrec) {
+        this.si_amount_otherrec = si_amount_otherrec;
+    }
+
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    public String getSi_type() {
+        return si_type;
+    }
+
+    public void setSi_type(String si_type) {
+        this.si_type = si_type;
+    }
+}

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/FundtransferService.java

@@ -15,7 +15,7 @@ import com.usoftchina.saas.page.PageRequest;
 public interface FundtransferService {
     DocBaseDTO insert(Fundtran fundtran);
 
-    void audit(Fundtran fundtran);
+    DocBaseDTO audit(Fundtran fundtran);
 
     void unAudit(int id);
 

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/OthreceiptsService.java

@@ -17,7 +17,7 @@ import com.usoftchina.saas.page.PageRequest;
 public interface OthreceiptsService {
     DocBaseDTO insert(Othte othte);
 
-    void audit(Othte othte);
+    DocBaseDTO audit(Othte othte);
 
     void unAudit(int id);
 

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/OthspendingsService.java

@@ -26,7 +26,7 @@ public interface OthspendingsService {
 
     PageInfo<Othspendings> selectList(PageRequest page, ListReqDTO reqDTO);
 
-    void audit(Othsp othsp);
+    DocBaseDTO audit(Othsp othsp);
 
     void unAudit(int id);
 

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/PaybalanceService.java

@@ -16,7 +16,7 @@ import com.usoftchina.saas.page.PageRequest;
 public interface PaybalanceService {
     DocBaseDTO insert(Pay pay);
 
-    void audit(Pay pay);
+    DocBaseDTO audit(Pay pay);
 
     void unAudit(int id);
 

+ 1 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/RecbalanceService.java

@@ -24,7 +24,7 @@ public interface RecbalanceService {
 
     void deleteItems(int id);
 
-    void audit(Rec rec);
+    DocBaseDTO audit(Rec rec);
 
 
     void unAudit(Long id);

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

@@ -2,7 +2,9 @@ package com.usoftchina.saas.money.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.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
@@ -11,9 +13,7 @@ import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.exception.BizException;
-import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
-import com.usoftchina.saas.money.mapper.FundtransferMapper;
-import com.usoftchina.saas.money.mapper.FundtransferdetailMapper;
+import com.usoftchina.saas.money.mapper.*;
 import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.FundtransferService;
 import com.usoftchina.saas.page.PageRequest;
@@ -29,7 +29,7 @@ import java.util.List;
  * @date 2018/10/25 19:32
  **/
 @Service
-public class FundtransferServiceImpl implements FundtransferService {
+public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferMapper, Fundtransfer> implements FundtransferService {
     @Autowired
     private FundtransferMapper fundtransferMapper;
     @Autowired
@@ -38,6 +38,10 @@ public class FundtransferServiceImpl implements FundtransferService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private PaybalanceMapper paybalanceMapper;
+    @Autowired
+    private MessageLogService messageLogService;
 
     @Override
     public DocBaseDTO insert(Fundtran fundtran) {
@@ -76,43 +80,55 @@ public class FundtransferServiceImpl implements FundtransferService {
                 fundtransferdetailMapper.insertSelective(fundtransferdetail);
             }
         }
-        return new DocBaseDTO(id, ft_code, BillCodeSeq.FUNDTRANSFER.getCaller());
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
-    public void audit(Fundtran fundtran) {
+    public DocBaseDTO audit(Fundtran fundtran) {
         Long companyId = BaseContextHolder.getCompanyId();
-        int id = Math.toIntExact(fundtran.getMain().getId());
-        Fundtransfer fundtransfer = fundtransferMapper.selectByPrimaryKey(id);
+        Fundtransfer fundtransfer = fundtran.getMain();
         fundtransfer.setFt_status(Status.AUDITED.getDisplay());
         fundtransfer.setFt_statuscode(Status.AUDITED.name());
         fundtransfer.setCompanyId(companyId);
         this.changBankUntil(fundtran);
-        if ( fundtransfer == null || "".equals(fundtransfer)){
-            this.insert(fundtran);
-        }else {
-            fundtransferMapper.updateByPrimaryKeySelective(fundtransfer);
-            List<Fundtransferdetail> fundtransferdetailList = fundtran.getItems();
-            Iterator isList = fundtransferdetailList.iterator();
-            while (isList.hasNext()){
-                Fundtransferdetail fundtransferdetail = (Fundtransferdetail) isList.next();
-                fundtransferdetail.setFt_date(fundtransfer.getFt_date());
-                fundtransferdetailMapper.updateByPrimaryKeySelective(fundtransferdetail);
-            }
-        }
+        DocBaseDTO docBaseDTO = this.insert(fundtran);
+        Long id = docBaseDTO.getId();
+        String ft_code = docBaseDTO.getCode();
 
-        //取从表金额
+        //取从表金额更新中间表、资金账号表
         List<Fundtransferdetail> fundtransferdetailList = fundtran.getItems();
         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());
+
+            //中间表
             banksubledgerMapper.updateBankcode(amount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "-");
             banksubledgerMapper.updateBankcode(inamount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "+");
+
+            //资金账号表
+            int bk_id = fundtransferdetail.getFtd_bankid();
+            int bk_inid = fundtransferdetail.getFtd_inbankid();
+            Double bk_amount = paybalanceMapper.selectThisamount(bk_id) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_id);
+            Double bk_inamount = paybalanceMapper.selectThisamount(bk_inid) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_inid);
+
+            Double thisamount = bk_amount - fundtransferdetail.getFtd_nowbalance();
+            if (thisamount < 0){
+                throw new BizException(500, BizExceptionCode.BANK_AMOUNT_NOTENOUGH.getMessage());
+            }
+            paybalanceMapper.updateBankAmount(thisamount, bk_id);
+            paybalanceMapper.updateBankAmount(bk_inamount + fundtransferdetail.getFtd_nowbalance(), bk_inid);
         }
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
@@ -139,7 +155,19 @@ public class FundtransferServiceImpl implements FundtransferService {
                     fundtransferdetail.getFtd_bankcode(), "+");
             banksubledgerMapper.updateBankcode(inamount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "-");
+
+            //资金账号表
+            int bk_id = fundtransferdetail.getFtd_bankid();
+            int bk_inid = fundtransferdetail.getFtd_inbankid();
+            Double bk_amount = paybalanceMapper.selectThisamount(bk_id) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_id);
+            Double bk_inamount = paybalanceMapper.selectThisamount(bk_inid) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_inid);
+            paybalanceMapper.updateBankAmount(bk_amount + fundtransferdetail.getFtd_nowbalance(), bk_id);
+            paybalanceMapper.updateBankAmount(bk_inamount - fundtransferdetail.getFtd_nowbalance(), bk_inid);
         }
+
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
 
@@ -147,11 +175,17 @@ public class FundtransferServiceImpl implements FundtransferService {
     public void delete(int id) {
         fundtransferMapper.deleteByPrimaryKey(id);
         fundtransferdetailMapper.deleteByPrimaryKey(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
     public void deleteItem(int id) {
         fundtransferdetailMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
@@ -279,4 +313,13 @@ public class FundtransferServiceImpl implements FundtransferService {
             }
         }
     }
+
+    private DocBaseDTO getBaseDTOById(Long id) {
+        if (null == id) {
+            return null;
+        }
+        String code = getMapper().selectCodeById(id);
+        DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.FUNDTRANSFER.getCaller());
+        return baseDTO;
+    }
 }

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

@@ -2,7 +2,9 @@ package com.usoftchina.saas.money.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.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
@@ -14,10 +16,8 @@ import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
 import com.usoftchina.saas.money.mapper.OthreceiptsMapper;
 import com.usoftchina.saas.money.mapper.OthreceiptsdetailMapper;
-import com.usoftchina.saas.money.po.Banksubledger;
-import com.usoftchina.saas.money.po.Othreceipts;
-import com.usoftchina.saas.money.po.Othreceiptsdetail;
-import com.usoftchina.saas.money.po.Othte;
+import com.usoftchina.saas.money.mapper.StatsinfoMapper;
+import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.OthreceiptsService;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +32,7 @@ import java.util.List;
  * @date 2018/10/24 17:48
  **/
 @Service
-public class OthreceiptsServiceImpl implements OthreceiptsService {
+public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMapper, Othreceipts> implements OthreceiptsService {
 
     @Autowired
     private OthreceiptsMapper othreceiptsMapper;
@@ -42,6 +42,10 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
+    @Autowired
+    private MessageLogService messageLogService;
 
     @Override
     public DocBaseDTO insert(Othte othte) {
@@ -80,30 +84,21 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
                 othreceiptsdetailMapper.insertSelective(othreceiptsdetail1);
             }
         }
-        return new DocBaseDTO(id, or_code, BillCodeSeq.OTHRECEIPTS.getCaller());
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
-    public void audit(Othte othte) {
+    public DocBaseDTO audit(Othte othte) {
         Long companyId = BaseContextHolder.getCompanyId();
-        int id = Math.toIntExact(othte.getMain().getId());
-        Othreceipts othreceipts = othreceiptsMapper.selectByPrimaryKey(id);
+        Othreceipts othreceipts = othte.getMain();
         othreceipts.setOr_status(Status.AUDITED.getDisplay());
         othreceipts.setOr_statuscode(Status.AUDITED.name());
-        othreceipts.setCompanyId(companyId);
         this.changBankUntil(othte);
-        if ( othreceipts == null || "".equals(othreceipts)){
-            this.insert(othte);
-        }else {
-            othreceiptsMapper.updateByPrimaryKeySelective(othreceipts);
-            List<Othreceiptsdetail> othreceiptsdetailList = othte.getItems();
-            Iterator isList = othreceiptsdetailList.iterator();
-            while (isList.hasNext()){
-                Othreceiptsdetail fundtransferdetail = (Othreceiptsdetail) isList.next();
-                fundtransferdetail.setOr_date(othreceipts.getOr_date());
-                othreceiptsdetailMapper.updateByPrimaryKeySelective(fundtransferdetail);
-            }
-        }
+        DocBaseDTO docBaseDTO = this.insert(othte);
+        Long id = docBaseDTO.getId();
 
         Double amount = banksubledgerMapper.selectThisamount(othreceipts.getOr_bankcode());
         //取从表金额
@@ -114,6 +109,26 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
             banksubledgerMapper.updateBankcode(amount, othreceiptsdetail.getOrd_nowbalance(),
                     othreceipts.getOr_bankcode(), "+");
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othreceiptsdetailMapper.selectYm(Math.toIntExact(id));
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(companyId);
+        Integer yms = statsinfoMapper.select(ym, companyId);
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherrec(othreceipts.getOr_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
@@ -138,17 +153,38 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
                     othreceipts.getOr_bankcode(), "-");
         }
 
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othreceiptsdetailMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherrec(othreceipts.getOr_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
-
     @Override
     public void delete(int id) {
         othreceiptsMapper.deleteByPrimaryKey(id);
         othreceiptsdetailMapper.deleteByPrimaryKey(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     public void deleteItem(int id) {
         othreceiptsdetailMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
@@ -278,4 +314,13 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
             }
         }
     }
+
+    private DocBaseDTO getBaseDTOById(Long id) {
+        if (null == id) {
+            return null;
+        }
+        String code = getMapper().selectCodeById(id);
+        DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.OTHRECEIPTS.getCaller());
+        return baseDTO;
+    }
 }

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

@@ -2,7 +2,9 @@ package com.usoftchina.saas.money.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.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
@@ -14,10 +16,8 @@ import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
 import com.usoftchina.saas.money.mapper.OthspendingsMapper;
 import com.usoftchina.saas.money.mapper.OthspendingsdetailMapper;
-import com.usoftchina.saas.money.po.Banksubledger;
-import com.usoftchina.saas.money.po.Othsp;
-import com.usoftchina.saas.money.po.Othspendings;
-import com.usoftchina.saas.money.po.Othspendingsdetail;
+import com.usoftchina.saas.money.mapper.StatsinfoMapper;
+import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.OthspendingsService;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +32,7 @@ import java.util.List;
  * @date 2018/10/24 22:22
  **/
 @Service
-public class OthspendingsServiceImpl implements OthspendingsService {
+public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsMapper, Othspendings> implements OthspendingsService {
     @Autowired
     private OthspendingsMapper othspendingsMapper;
     @Autowired
@@ -41,6 +41,10 @@ public class OthspendingsServiceImpl implements OthspendingsService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
+    @Autowired
+    private MessageLogService messageLogService;
 
     @Override
     public DocBaseDTO insert(Othsp othsp) {
@@ -78,18 +82,27 @@ public class OthspendingsServiceImpl implements OthspendingsService {
                 othspendingsdetailMapper.insertSelective(othspendingsdetail);
             }
         }
-        return new DocBaseDTO(id, os_code, BillCodeSeq.OTHSPENDINGS.getCaller());
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
     public void delete(int id) {
         othspendingsMapper.deleteByPrimaryKey(id);
         othspendingsdetailMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
     public void deleteItem(int id) {
         othspendingsdetailMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
@@ -116,26 +129,15 @@ public class OthspendingsServiceImpl implements OthspendingsService {
     }
 
     @Override
-    public void audit(Othsp othsp) {
+    public DocBaseDTO audit(Othsp othsp) {
         Long companyId = BaseContextHolder.getCompanyId();
-        int id = Math.toIntExact(othsp.getMain().getId());
-        Othspendings othspendings = othspendingsMapper.selectByPrimaryKey(id);
+        Othspendings othspendings = othsp.getMain();
         othspendings.setOs_status(Status.AUDITED.getDisplay());
         othspendings.setOs_statuscode(Status.AUDITED.name());
         othspendings.setCompanyId(companyId);
         this.changBankUntil(othsp);
-        if ( othspendings == null || "".equals(othspendings)){
-            this.insert(othsp);
-        }else {
-            othspendingsMapper.updateByPrimaryKeySelective(othspendings);
-            List<Othspendingsdetail> othspendingsdetailList = othsp.getItems();
-            Iterator isList = othspendingsdetailList.iterator();
-            while (isList.hasNext()){
-                Othspendingsdetail othspendingsdetail = (Othspendingsdetail) isList.next();
-                othspendingsdetail.setOs_date(othspendings.getOs_date());
-                othspendingsdetailMapper.updateByPrimaryKeySelective(othspendingsdetail);
-            }
-        }
+        DocBaseDTO docBaseDTO = this.insert(othsp);
+        Long id = docBaseDTO.getId();
 
         Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode());
         //取从表金额
@@ -146,6 +148,25 @@ public class OthspendingsServiceImpl implements OthspendingsService {
             banksubledgerMapper.updateBankcode(amount, othspendingsdetail.getOsd_nowbalance(),
                     othspendings.getOs_bankcode(), "+");
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othspendingsdetailMapper.selectYm(Math.toIntExact(id));
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherpay(othspendings.getOs_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
@@ -170,6 +191,25 @@ public class OthspendingsServiceImpl implements OthspendingsService {
             banksubledgerMapper.updateBankcode(amount, othspendingsdetail.getOsd_nowbalance(),
                     othspendings.getOs_bankcode(), "-");
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othspendingsdetailMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherpay(othspendings.getOs_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
@@ -276,4 +316,13 @@ public class OthspendingsServiceImpl implements OthspendingsService {
             }
         }
     }
+
+    private DocBaseDTO getBaseDTOById(Long id) {
+        if (null == id) {
+            return null;
+        }
+        String code = getMapper().selectCodeById(id);
+        DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.OTHSPENDINGS.getCaller());
+        return baseDTO;
+    }
 }

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

@@ -2,7 +2,9 @@ package com.usoftchina.saas.money.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.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
@@ -27,7 +29,7 @@ import java.util.List;
  * @date 2018/10/22 14:28
  **/
 @Service
-public class PaybalanceServiceImpl implements PaybalanceService {
+public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMapper, Paybalance> implements PaybalanceService {
     @Autowired
     private PaybalanceMapper paybalanceMapper;
     @Autowired
@@ -40,6 +42,10 @@ public class PaybalanceServiceImpl implements PaybalanceService {
     private SubledgerMapper subledgerMapper;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
+    @Autowired
+    private MessageLogService messageLogService;
 
     public DocBaseDTO insert(Pay pay) {
         Paybalance paybalance = pay.getMain();
@@ -93,7 +99,10 @@ public class PaybalanceServiceImpl implements PaybalanceService {
                 paybalancedetailMapper.insertSelective(paybalancedetail1);
             }
         }
-        return new DocBaseDTO(pbId, pb_code, BillCodeSeq.PAYBALANCE.getCaller());
+        DocBaseDTO baseDTO = getBaseDTOById(pbId);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     /**
@@ -161,10 +170,9 @@ public class PaybalanceServiceImpl implements PaybalanceService {
     }
 
     @Override
-    public void audit(Pay pay) {
+    public DocBaseDTO audit(Pay pay) {
         Long companyId = BaseContextHolder.getCompanyId();
-        int id = Math.toIntExact(pay.getMain().getId());
-        Paybalance paybalance = paybalanceMapper.selectByPrimaryKey(Long.valueOf(id));
+        Paybalance paybalance = pay.getMain();
         paybalance.setPb_status(Status.AUDITED.getDisplay());
         paybalance.setPb_statuscode(Status.AUDITED.name());
         paybalance.setCompanyId(companyId);
@@ -175,12 +183,8 @@ public class PaybalanceServiceImpl implements PaybalanceService {
             subledgerMapper.updateByPrimaryKeySelective(subledger);
         }
         this.changBankUntil(pay);
-        System.out.println("新增");
-        if ( paybalance == null || "".equals(paybalance)){
-            this.insert(pay);
-        }else {
-            paybalanceMapper.updateByPrimaryKeySelective(paybalance);
-        }
+        DocBaseDTO docBaseDTO = this.insert(pay);
+        Long id = docBaseDTO.getId();
 
         Paybalance updatePay = new Paybalance();
         List<Paybalancedet> paybalancedet = pay.getItems1();
@@ -243,6 +247,24 @@ public class PaybalanceServiceImpl implements PaybalanceService {
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
 
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = paybalancedetMapper.selectYm(Math.toIntExact(id));
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_pay(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
@@ -308,7 +330,23 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         subledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
         banksubledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
 
-
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = paybalancedetMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_pay(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
 
@@ -316,16 +354,25 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         paybalanceMapper.deleteByPrimaryKey(id);
         paybalancedetailMapper.deleteByPrimaryKey(id);
         paybalancedetMapper.deleteByPrimaryKey(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
     public void deleteItem(int id) {
         paybalancedetMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
     public void deleteItems(int id) {
         paybalancedetailMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     public Pay select(int id){
@@ -503,4 +550,13 @@ public class PaybalanceServiceImpl implements PaybalanceService {
 
         }
     }
+
+    private DocBaseDTO getBaseDTOById(Long id) {
+        if (null == id) {
+            return null;
+        }
+        String code = getMapper().selectCodeById(id);
+        DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.PAYBALANCE.getCaller());
+        return baseDTO;
+    }
 }

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

@@ -2,7 +2,9 @@ package com.usoftchina.saas.money.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.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
@@ -27,7 +29,7 @@ import java.util.List;
  * @date 2018/10/23 16:18
  **/
 @Service
-public class RecbalanceServiceImpl implements RecbalanceService {
+public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMapper, Recbalance> implements RecbalanceService {
     @Autowired
     RecbalanceMapper recbalanceMapper;
     @Autowired
@@ -40,6 +42,10 @@ public class RecbalanceServiceImpl implements RecbalanceService {
     private BanksubledgerMapper banksubledgerMapper;
     @Autowired
     private SubledgerMapper subledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
+    @Autowired
+    private MessageLogService messageLogService;
 
     @Override
     public DocBaseDTO insert(Rec rec) {
@@ -92,7 +98,10 @@ public class RecbalanceServiceImpl implements RecbalanceService {
                 recbalancedetailMapper.insertSelective(recbalancedetail1);
             }
         }
-        return new DocBaseDTO(rbId, pu_code, BillCodeSeq.RECBALANCE.getCaller());
+        DocBaseDTO baseDTO = getBaseDTOById(rbId);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     /**
@@ -163,6 +172,9 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         recbalanceMapper.deleteByPrimaryKey(id);
         recbalancedetMapper.deleteByPrimaryKey(id);
         recbalancedetailMapper.deleteByPrimaryKey(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
@@ -180,18 +192,23 @@ public class RecbalanceServiceImpl implements RecbalanceService {
     @Override
     public void deleteItem(int id) {
         recbalancedetMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
     public void deleteItems(int id) {
         recbalancedetailMapper.deleteItem(id);
+        DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     @Override
-    public void audit(Rec rec) {
+    public DocBaseDTO audit(Rec rec) {
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer id = Math.toIntExact(rec.getMain().getId());
-        Recbalance recbalance = recbalanceMapper.selectByPrimaryKey(id);
+        Recbalance recbalance = rec.getMain();
         recbalance.setRb_status(Status.AUDITED.getDisplay());
         recbalance.setRb_statuscode(Status.AUDITED.name());
         recbalance.setCompanyId(companyId);
@@ -202,11 +219,8 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             subledgerMapper.updateByPrimaryKeySelective(subledger);
         }
         this.changBankUntil(rec);
-        if ( recbalance == null || "".equals(recbalance)){
-            this.insert(rec);
-        }else {
-            recbalanceMapper.updateByPrimaryKeySelective(recbalance);
-        }
+        DocBaseDTO docBaseDTO = this.insert(rec);
+        Long id = docBaseDTO.getId();
 
         Recbalance updateRay = new Recbalance();
         List<Recbalancedet> recbalancedet = rec.getItems1();
@@ -269,6 +283,25 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             subledger1.setSl_namount(namount-nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = recbalancedetMapper.selectYm(Math.toIntExact(id));
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_rec(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
+        return baseDTO;
     }
 
     @Override
@@ -334,6 +367,24 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             subledger1.setSl_namount(namount+nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = recbalancedetMapper.selectYm(Math.toIntExact(id));
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_rec(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+        DocBaseDTO baseDTO = getBaseDTOById(id);
+        //日志记录
+        messageLogService.save(baseDTO);
     }
 
     public PageInfo<Recbalance> selectList(PageRequest page, ListReqDTO reqDTO) {
@@ -498,4 +549,12 @@ public class RecbalanceServiceImpl implements RecbalanceService {
 
         }
     }
+    private DocBaseDTO getBaseDTOById(Long id) {
+        if (null == id) {
+            return null;
+        }
+        String code = getMapper().selectCodeById(id);
+        DocBaseDTO baseDTO = new DocBaseDTO(id, code, BillCodeSeq.RECBALANCE.getCaller());
+        return baseDTO;
+    }
 }

+ 9 - 2
applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml

@@ -241,7 +241,7 @@
       <if test="companyId != null">
         and   Fundtransfer.companyId = #{companyId}
       </if>
-    </where>  order by ft_date desc
+    </where>  order by ft_date desc, ft_code desc
   </select>
 
   <select id="selectFundtransferListByCondition" resultMap="BaseResultMap">
@@ -256,6 +256,13 @@
       <if test="companyId != null">
         and   fundtransfer.companyId = #{companyId}
       </if>
-    </where>  order by ft_date desc
+    </where>  order by ft_date desc, ft_code desc
+  </select>
+
+  <select id="selectCodeById" parameterType="java.lang.Long" resultType="string">
+    select
+    ft_code
+    from fundtransfer
+    where ft_id = #{id,jdbcType=INTEGER}
   </select>
 </mapper>

+ 11 - 4
applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml

@@ -324,9 +324,9 @@
         ${con}
       </if>
       <if test="companyId != null">
-        and   othreceipts.companyId = #{companyId}
+        and   othreceipts.companyId = #{companyId, jdbcType=INTEGER}
       </if>
-    </where>  order by or_date desc
+    </where>  order by or_date desc,or_code desc
   </select>
 
   <select id="selectOthreceiptsListByCondition" resultMap="BaseResultMap">
@@ -339,8 +339,15 @@
         ${con}
       </if>
       <if test="companyId != null">
-        and   othreceipts.companyId = #{companyId}
+        and   othreceipts.companyId = #{companyId, jdbcType=INTEGER}
       </if>
-    </where>  order by or_date desc
+    </where>  order by or_date desc, or_code desc
+  </select>
+
+  <select id="selectCodeById" parameterType="java.lang.Long" resultType="string">
+    select
+    or_code
+    from othreceipts
+    where or_id = #{id,jdbcType=INTEGER}
   </select>
 </mapper>

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/OthreceiptsdetailMapper.xml

@@ -207,4 +207,8 @@
       ord_text5 = #{ordText5,jdbcType=VARCHAR}
     where ord_id = #{ordId,jdbcType=INTEGER}
   </update>
+
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select ord_ym from othreceiptsdetail where ord_orid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 9 - 2
applications/money/money-server/src/main/resources/mapper/OthspendingsMapper.xml

@@ -321,7 +321,7 @@
       <if test="companyId != null">
         and   othspendings.companyId = #{companyId}
       </if>
-    </where>  order by os_date desc
+    </where>  order by os_date desc, os_code desc
   </select>
 
   <select id="selectOthspendingsListByCondition" resultMap="BaseResultMap">
@@ -336,6 +336,13 @@
       <if test="companyId != null">
         and   othspendings.companyId = #{companyId}
       </if>
-    </where>  order by os_date desc
+    </where>  order by os_date desc,os_code desc
+  </select>
+
+  <select id="selectCodeById" parameterType="java.lang.Long" resultType="string">
+    select
+    os_code
+    from othspendings
+    where os_id = #{id,jdbcType=INTEGER}
   </select>
 </mapper>

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/OthspendingsdetailMapper.xml

@@ -213,4 +213,8 @@
       osd_text5 = #{osdText5,jdbcType=VARCHAR}
     where osd_id = #{osdId,jdbcType=INTEGER}
   </update>
+
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select osd_ym from othspendingsdetail where osd_orid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 38 - 7
applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml

@@ -30,6 +30,15 @@
     <result column="pb_text4" jdbcType="VARCHAR" property="pb_text4" />
     <result column="pb_text5" jdbcType="VARCHAR" property="pb_text5" />
     <result column="ve_leftamount" jdbcType="DOUBLE" property="ve_leftamount" />
+    <result column="pd_bankname" jdbcType="VARCHAR" property="pd_bankname" />
+    <result column="pd_paymethod" jdbcType="VARCHAR" property="pd_paymethod" />
+    <result column="pd_paycode" jdbcType="VARCHAR" property="pd_paycode" />
+    <result column="pd_remark" jdbcType="VARCHAR" property="pd_remark" />
+    <result column="pbd_slcode" jdbcType="VARCHAR" property="pbd_slcode" />
+    <result column="pbd_slkind" jdbcType="VARCHAR" property="pbd_slkind" />
+    <result column="pbd_sldate" jdbcType="TIMESTAMP" property="pbd_sldate" />
+    <result column="pbd_amount" jdbcType="DOUBLE" property="pbd_amount" />
+    <result column="pbd_nowbalance" jdbcType="DOUBLE" property="pbd_nowbalance" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -98,6 +107,10 @@
   <sql id="left_Column_List">
     ve_leftamount
   </sql>
+  <sql id="detail_Column_List">
+    pd_bankname,pd_amount,pd_paymethod,pd_remark,pbd_slcode,pbd_slkind,
+    pbd_sldate,pbd_amount,pbd_nowbalance
+  </sql>
   <select id="selectList" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />
@@ -419,8 +432,10 @@
 
   <select id="selectPaybalanceBycondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from Paybalance
+    <include refid="Base_Column_List" />,
+    <include refid="detail_Column_List" />
+    from paybalance left join paybalancedet on pd_pbid=pb_id and paybalance.companyId=paybalancedet.companyId
+    left join paybalancedetail on pbd_pbid=pb_id and paybalancedetail.companyId=paybalance.companyId
     <where>
       <if test="con != null">
         ${con}
@@ -428,14 +443,15 @@
       <if test="companyId != null">
         and   paybalance.companyId = #{companyId}
       </if>
-    </where>  order by pb_id
+    </where>  order by pb_date desc, pb_code desc
   </select>
 
   <select id="selectPaybalanceListByCondition" resultMap="BaseResultMap">
   select
-  <include refid="Base_Column_List" />
-  from paybalance
-    left join paybalancedet on pb_id=pd_pbid left join paybalancedetail on pb_id=pbd_rbid
+    <include refid="Base_Column_List" />,
+    <include refid="detail_Column_List" />
+    from paybalance left join paybalancedet on pd_pbid=pb_id and paybalance.companyId=paybalancedet.companyId
+    left join paybalancedetail on pbd_pbid=pb_id and paybalancedetail.companyId=paybalance.companyId
     <where>
       <if test="con != null">
         ${con}
@@ -443,7 +459,7 @@
       <if test="companyId != null">
         and   paybalance.companyId = #{companyId}
       </if>
-    </where>  order by pb_id
+    </where>  order by pb_date desc,pb_code desc
   </select>
 
   <select id="validateCodeWhenInsert" resultType="int">
@@ -453,6 +469,12 @@
     select count(1) from paybalance where pb_code = #{code} and pb_id != #{id} and companyId =#{companyId}
   </select>
 
+  <select id="selectCodeById" parameterType="java.lang.Long" resultType="string">
+    select
+    pb_code
+    from paybalance
+    where pb_id = #{id,jdbcType=INTEGER}
+  </select>
 
   <!-- 银行账户-->
   <sql id="Bank_Column_List" >
@@ -576,6 +598,15 @@
     where bk_id = #{id,jdbcType=INTEGER}
   </update>
 
+  <update id="updateBankAmount" >
+    update bankinformation set bk_thisamount = #{bk_thisamount,jdbcType=DOUBLE}
+     where bk_id = #{id,jdbcType=INTEGER}
+  </update>
+
+<select id="selectThisamount" parameterType="java.lang.Integer" resultType="java.lang.Double">
+  select bk_thisamount from bankinformation where bk_id = #{id,jdbcType=INTEGER}
+</select>
+
 <!-- 供应商-->
   <resultMap id="VendorResultMapper" type="com.usoftchina.saas.money.po.Vendor">
     <id column="ve_id" property="id" jdbcType="INTEGER" />

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/PaybalancedetMapper.xml

@@ -287,4 +287,8 @@
       </if>
     </where>  order by pb_id
   </select>
+
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select pd_ym from paybalancedet where pd_pbid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 31 - 7
applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml

@@ -30,6 +30,15 @@
     <result column="rb_text4" jdbcType="VARCHAR" property="rb_text4" />
     <result column="rb_text5" jdbcType="VARCHAR" property="rb_text5" />
     <result column="cu_leftamount" jdbcType="DOUBLE" property="cu_leftamount" />
+    <result column="rd_bankname" jdbcType="VARCHAR" property="rd_bankname" />
+    <result column="rd_paymethod" jdbcType="VARCHAR" property="rd_paymethod" />
+    <result column="rd_paycode" jdbcType="VARCHAR" property="rd_paycode" />
+    <result column="rd_remark" jdbcType="VARCHAR" property="rd_remark" />
+    <result column="rbd_slcode" jdbcType="VARCHAR" property="rbd_slcode" />
+    <result column="rbd_slkind" jdbcType="VARCHAR" property="rbd_slkind" />
+    <result column="rbd_sldate" jdbcType="TIMESTAMP" property="rbd_sldate" />
+    <result column="rbd_amount" jdbcType="DOUBLE" property="rbd_amount" />
+    <result column="rbd_nowbalance" jdbcType="DOUBLE" property="rbd_nowbalance" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -98,6 +107,11 @@
   <sql id="left_Column_List">
     cu_leftamount
   </sql>
+  <sql id="detail_Column_List">
+      rd_bankname,rd_amount,rd_paymethod,rd_paycode,rd_remark,rbd_slcode,rbd_slkind,
+    rbd_sldate,rbd_amount,rbd_nowbalance
+  </sql>
+
   <select id="selectByExample" parameterType="com.usoftchina.saas.money.po.RecbalanceExample" resultMap="BaseResultMap">
     select
     <if test="distinct">
@@ -122,8 +136,10 @@
 
   <select id="selectRecbalanceBycondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from recbalance
+    <include refid="Base_Column_List" />,
+    <include refid="detail_Column_List" />
+    from recbalance left join recbalancedet on rd_rbid=rb_id and recbalance.companyId=recbalancedet.companyId
+    left join recbalancedetail on rbd_rbid=rb_id and recbalancedetail.companyId=recbalance.companyId
     <where>
       <if test="con != null">
         ${con}
@@ -131,14 +147,15 @@
       <if test="companyId != null">
         and   recbalance.companyId = #{companyId}
       </if>
-    </where>  order by rb_date desc
+    </where>  order by rb_date desc,rb_code desc
   </select>
 
   <select id="selectRecbalanceListByCondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from recbalance
-    left join recbalancedet on rb_id=rd_rbid left join recbalancedetail on rb_id=rbd_rbid
+    <include refid="Base_Column_List" />,
+    <include refid="detail_Column_List" />
+    from recbalance left join recbalancedet on rd_rbid=rb_id and recbalance.comranyId=recbalancedet.comranyId
+    left join recbalancedetail on rbd_rbid=rb_id and recbalancedetail.comranyId=recbalance.comranyId
     <where>
       <if test="con != null">
         ${con}
@@ -146,7 +163,7 @@
       <if test="companyId != null">
         and   recbalance.companyId = #{companyId}
       </if>
-    </where>  order by rb_date desc
+    </where>  order by rb_date desc, rb_code desc
   </select>
 
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
@@ -587,6 +604,13 @@
     select count(1) from recbalance where rb_code = #{code} and rb_id != #{id} and companyId =#{companyId}
   </select>
 
+  <select id="selectCodeById" parameterType="java.lang.Long" resultType="string">
+    select
+    rb_code
+    from recbalance
+    where rb_id = #{id,jdbcType=INTEGER}
+  </select>
+
   <!-- 银行账户-->
   <sql id="Bank_Column_List" >
     bk_id, bk_bankcode, bk_bankname, bk_date, bk_type, bk_beginamount, bk_thisamount,

+ 3 - 3
applications/money/money-server/src/main/resources/mapper/RecbalancedetMapper.xml

@@ -236,9 +236,6 @@
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.money.po.Recbalancedet">
     update recbalancedet
     <set>
-      <if test="id != null">
-        rd_rbid = #{id,jdbcType=INTEGER},
-      </if>
       <if test="rd_detno != null">
         rd_detno = #{rd_detno,jdbcType=INTEGER},
       </if>
@@ -294,4 +291,7 @@
     where rd_id = #{id,jdbcType=INTEGER}
   </update>
 
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select rd_ym from recbalancedet where rd_rbid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 0 - 3
applications/money/money-server/src/main/resources/mapper/RecbalancedetailMapper.xml

@@ -183,9 +183,6 @@
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.money.po.Recbalancedetail" >
     update recbalancedetail
     <set >
-      <if test="id != null" >
-        rbd_rbid = #{id,jdbcType=INTEGER},
-      </if>
       <if test="rbd_detno != null" >
         rbd_detno = #{rbd_detno,jdbcType=INTEGER},
       </if>

+ 103 - 0
applications/money/money-server/src/main/resources/mapper/StatsinfoMapper.xml

@@ -0,0 +1,103 @@
+<?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.money.mapper.StatsinfoMapper" >
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.money.po.Statsinfo">
+        <result column="si_yearmonth" jdbcType="DOUBLE" property="si_yearmonth" />
+        <result column="si_amount_pay" jdbcType="DOUBLE" property="si_amount_pay" />
+        <result column="si_amount_otherpay" jdbcType="DOUBLE" property="si_amount_otherpay" />
+        <result column="si_amount_rec" jdbcType="DOUBLE" property="si_amount_rec" />
+        <result column="si_amount_otherrec" jdbcType="DOUBLE" property="si_amount_otherrec" />
+        <result column="companyid" jdbcType="INTEGER" property="companyid" />
+        <result column="si_type" jdbcType="VARCHAR" property="si_type" />
+    </resultMap>
+
+    <insert id="insert" parameterType="com.usoftchina.saas.money.po.Statsinfo">
+        insert into statsinfo
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+        <if test="si_yearmonth != null" >
+            si_yearmonth,
+        </if>
+        <if test="si_amount_pay != null" >
+            si_amount_pay,
+        </if>
+        <if test="si_amount_otherpay != null" >
+            si_amount_otherpay,
+        </if>
+        <if test="si_amount_rec != null" >
+            si_amount_rec,
+        </if>
+        <if test="si_amount_otherrec != null" >
+            si_amount_otherrec,
+        </if>
+        <if test="companyid != null" >
+            companyid,
+        </if>
+            si_type,
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+            <if test="si_yearmonth != null" >
+                #{si_yearmonth,jdbcType=INTEGER},
+            </if>
+            <if test="si_amount_pay != null" >
+                select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
+                where paybalance.companyId= #{companyid,jdbcType=INTEGER}
+                and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED',
+            </if>
+            <if test="si_amount_otherpay != null" >
+                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
+                where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_rec != null" >
+                (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
+                where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
+                and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_otherrec != null" >
+                (select  sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
+                where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
+            </if>
+            <if test="companyid != null" >
+                #{companyid,jdbcType=INTEGER},
+            </if>
+                'FUND',
+        </trim>
+    </insert>
+
+    <update id="update" parameterType="com.usoftchina.saas.money.po.Statsinfo" >
+        update statsinfo
+        <set >
+            <if test="si_amount_pay != null" >
+                si_amount_pay =
+                (select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
+                where paybalance.companyId= #{companyid,jdbcType=INTEGER}
+                and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_otherpay != null" >
+                si_amount_otherpay =
+                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
+                where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_rec != null" >
+                si_amount_rec =
+                (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
+                where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
+                and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_otherrec != null" >
+                si_amount_otherrec =
+                (select  sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
+                where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
+            </if>
+        </set>
+        where si_yearmonth = #{si_yearmonth,jdbcType=INTEGER} and companyid = #{companyid,jdbcType=INTEGER}
+        and si_type = 'FUND'
+    </update>
+
+    <select id="select" resultType="java.lang.Integer">
+        select DISTINCT si_yearmonth from statsinfo where si_yearmonth =#{si_yearmonth,jdbcType=INTEGER} and companyid = #{companyid,jdbcType=INTEGER}
+    </select>
+</mapper>

+ 0 - 4
applications/purchase/purchase-server/pom.xml

@@ -81,10 +81,6 @@
             <groupId>com.usoftchina.saas</groupId>
             <artifactId>commons-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.usoftchina.saas</groupId>
-            <artifactId>document-api</artifactId>
-        </dependency>
     </dependencies>
 
     <build>

+ 4 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java

@@ -6,6 +6,7 @@ import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
 import com.usoftchina.saas.purchase.mapper.ProdInOutMapper;
@@ -77,7 +78,9 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
 
     void calcProdInout(Long pi_id, String pi_class);
 
-    String pushMaxnubmer(ProdInOut prodInOut);
+    //String pushMaxnubmer(DocBaseDTO baseDTO);
+
+    String getMaxnumber(BillCodeSeq bill);
 
     void getDefaultWarehouseByProduct(Long pi_id);
 }

+ 46 - 37
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -11,9 +11,9 @@ 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.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
-import com.usoftchina.saas.document.api.EmployeeApi;
 import com.usoftchina.saas.document.api.WarehouseApi;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
@@ -29,6 +29,7 @@ import com.usoftchina.saas.purchase.service.ProdInOutService;
 import com.usoftchina.saas.utils.BeanMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
@@ -53,9 +54,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     private ProdInOutListMapper prodInOutListMapper;
     @Autowired
     private WarehouseApi warehouseApi;
-    @Autowired
-    private EmployeeApi employeeApi;
-
     @Autowired
     private MaxnumberService maxnumberService;
 
@@ -111,7 +109,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Override
-    @Transactional
+    @Transactional(propagation = Propagation.REQUIRED)
     public DocBaseDTO saveFormData(ProdInOutFormDTO formdata) {
         if (null == formdata || null == formdata.getMain()){
             throw new BizException(500, "数据为空,请填写后再保存");
@@ -119,8 +117,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //公司ID
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
-        Map<String,Object>  emp= employeeApi.getEmployeeByAccount();
-        Long userId = Long.valueOf(String.valueOf(emp.get("em_id")));
+        Long userId = BaseContextHolder.getUserId();
 
         //获取主表信息
         ProdInOutDTO main = formdata.getMain();
@@ -136,14 +133,17 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
         prodInOut.setCompanyId(companyId);
         prodInOut.setPi_recordmanid(userId.intValue());
-        prodInOut.setPi_recordman(emp.get("em_name").toString());
+//        prodInOut.setPi_recordman(emp.get("em_name").toString());
         prodInOut.setCreatorId(userId);
-        prodInOut.setCreateTime(new Date());
-        prodInOut.setPi_date(new Date());
+        prodInOut.setCreateTime(prodInOut.getPi_recorddate()==null?new Date():prodInOut.getPi_recorddate());
+        prodInOut.setPi_date(prodInOut.getPi_date()==null?new Date():prodInOut.getPi_date());
         prodInOut.setPi_puid(main.getPi_puid());
         prodInOut.setPi_pucode(main.getPi_pucode());
+        baseDTO.setCode(pi_inoutno);
+        baseDTO.setId(pi_id);
+        baseDTO.setName(pi_class);
         //编号获取
-        pi_inoutno = pushMaxnubmer(prodInOut);
+        pi_inoutno = pushMaxnubmer(baseDTO);
         prodInOut.setPi_inoutno(pi_inoutno);
 
         //判断更新与保存动作
@@ -213,6 +213,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         updateYqty(prodInOut);
         //日志记录
         messageLogService.update(baseDTO);
+        messageLogService.customizeLog(baseDTO, Operation.TURNPURCCHECKOUT);
         return baseDTO;
     }
 
@@ -223,7 +224,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         singleDelete(id);
     }
 
-    private void singleDelete(Long id) {
+    @Transactional(propagation = Propagation.REQUIRED)
+    public void singleDelete(Long id) {
 
             ProdInOut prodInOut = checkAndReturnOrder(id);;
             //删除主键
@@ -239,13 +241,12 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
 
 
     @Override
-    @Transactional
     public DocBaseDTO audit(ProdInOutFormDTO formData) {
         Long id = null;
         DocBaseDTO baseDTO = new DocBaseDTO();
         if (null != formData) {
             id = formData.getMain().getId();
-            if (StringUtils.isEmpty(id)) {
+            if (StringUtils.isEmpty(id) ||"0".equals(String.valueOf(id))) {
                 baseDTO = saveFormData(formData);
                 id = baseDTO.getId();
             }
@@ -255,7 +256,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return baseDTO;
     }
 
-    private void singleAudit(ProdInOutDTO prodInOutDTO) {
+    @Transactional(propagation = Propagation.REQUIRED)
+    public void singleAudit(ProdInOutDTO prodInOutDTO) {
         String pi_class= prodInOutDTO.getPi_class();
         String pi_inoutno = prodInOutDTO.getPi_inoutno();
         String pi_statuscode = prodInOutDTO.getPi_statuscode();
@@ -426,7 +428,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //插入验退单主表
         ProdInOut targetPi = new ProdInOut();
         //生成单号
-        String piInoutno = maxnumberService.getMaxnumber(BillCodeSeq.PURCHASEOUT.getCaller(),true).getData();
+        String piInoutno = getMaxnumber(BillCodeSeq.PURCHASEOUT);
         targetPi.setPi_inoutno(piInoutno);
         targetPi.setPi_class(BillCodeSeq.PURCHASEOUT.getName());
         targetPi.setPi_date(new Date());
@@ -544,7 +546,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return docBaseDTO;
     }
 
-
     @Override
     public DocBaseDTO open(long id) {
         return singleOpen(id);
@@ -573,26 +574,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return baseDTO;
     }
 
-
-    public String pushMaxnubmer(ProdInOut prodInOut) {
-        String pi_inoutno = prodInOut.getPi_inoutno();
-        String pi_class = prodInOut.getPi_class();
-        Long id = prodInOut.getId();
-        if (null == pi_inoutno) {
-            throw new BizException(BizExceptionCode.NULL_CODE);
-        }
-        Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
-                getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
-        String caller ="";
-        if("采购验收单".equals(pi_class)){
-            caller = BillCodeSeq.PURCHASEIN.getCaller();
-        }else if("采购验退单".equals(pi_class)) {
-            caller = BillCodeSeq.PURCHASEOUT.getCaller();
-        }
-        return maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
-    }
-
     @Override
     @Transactional
     public void getDefaultWarehouseByProduct(Long pi_id) {
@@ -611,5 +592,33 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return prodInOut;
     }
 
+    @Override
+    public String getMaxnumber(BillCodeSeq bill) {
+        String code = maxnumberService.getMaxnumber(bill.getCaller(), false).getData();
+        DocBaseDTO base = new DocBaseDTO(0l, code, bill.getName());
+        return pushMaxnubmer(base);
+    }
 
+    public String pushMaxnubmer(DocBaseDTO baseDTO) {
+        String pi_inoutno = baseDTO.getCode();
+        String pi_class = baseDTO.getName();
+        Long id = baseDTO.getId();
+        if (null == pi_inoutno) {
+            throw new BizException(BizExceptionCode.NULL_CODE);
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        String billCode = null;
+        synchronized (ProdInOutServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
+                    getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
+            String caller ="";
+            if("采购验收单".equals(pi_class)){
+                caller = BillCodeSeq.PURCHASEIN.getCaller();
+            }else if("采购验退单".equals(pi_class)) {
+                caller = BillCodeSeq.PURCHASEOUT.getCaller();
+            }
+            billCode = maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
+        }
+        return billCode;
+    }
 }

+ 10 - 10
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/PurchaseServiceImpl.java

@@ -13,7 +13,6 @@ import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
-import com.usoftchina.saas.document.api.EmployeeApi;
 import com.usoftchina.saas.document.api.ProductApi;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
@@ -34,7 +33,6 @@ import org.springframework.util.StringUtils;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 
 /**
@@ -53,8 +51,6 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     @Autowired
     private ProductApi productApi;
     @Autowired
-    private EmployeeApi employeeApi;
-    @Autowired
     private MaxnumberService maxnumberService;
     @Autowired
     private ProdInOutMapper prodInOutMapper;
@@ -110,8 +106,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         //公司ID
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
-        Map<String,Object>  emp= employeeApi.getEmployeeByAccount();
-        Long userId = (Long)emp.get("em_id");
+        Long userId = BaseContextHolder.getUserId();
         //获取主表信息
         PurchaseDTO main = formdata.getMain();
         List<PurchaseDetailDTO> items = formdata.getItems();
@@ -167,6 +162,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
             PurchaseDetail detail = BeanMapper.map(item, PurchaseDetail.class);
             detail.setPd_puid(pu_id);
             detail.setPd_code(pu_code);
+            detail.setPd_delivery(item.getPd_delivery()==null?purchase.getPu_delivery():item.getPd_delivery());
             detail.setCompanyId(companyId);
             detail.setCreatorId(userId);
             detail.setCreateTime(new Date());
@@ -412,7 +408,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         //插入验收单主表
         ProdInOut prodInOut = new ProdInOut();
         //生成单号
-        String piInoutno =maxnumberService.getMaxnumber(BillCodeSeq.PURCHASEIN.getCaller(),true).getData();
+        String piInoutno = prodInOutService.getMaxnumber(BillCodeSeq.PURCHASEIN);
         prodInOut.setPi_inoutno(piInoutno);
         prodInOut.setPi_class("采购验收单");
         prodInOut.setPi_date(new Date());
@@ -562,9 +558,13 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? purchaseMapper.validateCodeWhenInsert(code, companyId) :
-                purchaseMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PURCHASE.getCaller()).getData();
+        String billCode = null;
+        synchronized (PurchaseServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? purchaseMapper.validateCodeWhenInsert(code, companyId) :
+                    purchaseMapper.validateCodeWhenUpdate(code, id, companyId);
+            billCode = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PURCHASE.getCaller()).getData();
+        }
+        return billCode;
     }
     
     /** 

+ 6 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SaleProfitView.java

@@ -49,5 +49,11 @@ public class SaleProfitView {
 
     private Double pd_profit;
 
+    private Double pd_price;
+
+    private Double pd_netprice;
+
+    private String pd_remark;
+
     private Double pd_profitpresent;
 }

+ 2 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SalerecView.java

@@ -34,5 +34,7 @@ public class SalerecView {
 
     private String rb_remark;
 
+    private Double rbd_amount;
+
     private Integer companyid;
 }

+ 3 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/ProdInOutService.java

@@ -7,6 +7,7 @@ import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.page.PageRequest;
 
 import com.usoftchina.saas.sale.dto.ProdInOutFormDTO;
@@ -119,4 +120,6 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
      * @param id
      */
     DocBaseDTO turnProdin(Long id);
+
+    String getMaxnumber(BillCodeSeq bill);
 }

+ 35 - 26
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java

@@ -17,6 +17,7 @@ import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.api.WarehouseApi;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
+import com.usoftchina.saas.page.PageDefault;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.sale.dto.ProdIODetailDTO;
 import com.usoftchina.saas.sale.dto.ProdInOutDTO;
@@ -99,8 +100,11 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if(prodInOut.getPi_date() == null){
             prodInOut.setPi_date(new Date());
         }
+        baseDTO.setName(pi_class);
+        baseDTO.setId(pi_id);
+        baseDTO.setCode(pi_inoutno);
         //编号获取
-        pi_inoutno = pushMaxnubmer(prodInOut);
+        pi_inoutno = pushMaxnubmer(baseDTO);
         prodInOut.setPi_inoutno(pi_inoutno);
         prodInOut.setPi_class(main.getPi_class());
         prodInOut.setPi_said(main.getPi_said());
@@ -227,7 +231,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Override
-    @Transactional
     public DocBaseDTO audit(ProdInOutFormDTO formData) {
         Long id = null;
         DocBaseDTO baseDTO = new DocBaseDTO();
@@ -243,7 +246,9 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         baseDTO.setCode(formData.getMain().getPi_inoutno());
         return baseDTO;
     }
-    private void singleAudit(ProdInOutDTO prodInOutDTO) {
+
+    @Transactional
+    public void singleAudit(ProdInOutDTO prodInOutDTO) {
         String pi_class= prodInOutDTO.getPi_class();
         String pi_inoutno = prodInOutDTO.getPi_inoutno();
         String pi_statuscode = prodInOutDTO.getPi_statuscode();
@@ -341,13 +346,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Override
-    public PageInfo<ProdInOutList> getListData(PageRequest page, ListReqDTO req) {
-        //设置默认分页
-        if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
-            page = new PageRequest();
-            page.setNumber(1);
-            page.setSize(10);
-        }
+    public PageInfo<ProdInOutList> getListData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
         PageHelper.startPage(page.getNumber(), page.getSize());
         //查询数据
         List<ProdInOutList> lists = getListByMode(req);
@@ -405,10 +404,10 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //插入销售退货单主表
         ProdInOut targetPi = new ProdInOut();
         //生成单号
-        String piInoutno  =
-                maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
+       /* String piInoutno  =
+                maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();*/
                // BillCodeSeq.SALEIN.getCaller()+Math.abs(Math.random()*100);
-
+        String piInoutno = getMaxnumber(BillCodeSeq.SALEIN);
         //设置公司id
         targetPi.setCompanyId(sourcePi.getCompanyId());
         targetPi.setCreateTime(new Date());
@@ -563,23 +562,33 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private String pushMaxnubmer(ProdInOut prodInOut) {
-        String code = prodInOut.getPi_inoutno();
-        Long id = prodInOut.getId();
-        String pi_class = prodInOut.getPi_class();
+    private String pushMaxnubmer(DocBaseDTO baseDTO) {
+        String code = baseDTO.getCode();
+        Long id = baseDTO.getId();
+        String pi_class = baseDTO.getName();
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
-        Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code,pi_class) :
-                prodInOutMapper.validateCodeWhenUpdate(code, id);
-        String caller ="";
-        if(pi_class.equals("出货单")){
-            caller = BillCodeSeq.SALEOUT.getCaller();
-        }else {//销售退货单
-            caller = BillCodeSeq.SALEIN.getCaller();
+        String billCode = null;
+        synchronized (ProdInOutServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(code,pi_class) :
+                    prodInOutMapper.validateCodeWhenUpdate(code, id);
+            String caller ="";
+            if(pi_class.equals("出货单")){
+                caller = BillCodeSeq.SALEOUT.getCaller();
+            }else {//销售退货单
+                caller = BillCodeSeq.SALEIN.getCaller();
+            }
+            billCode = maxnumberService.pushMaxnubmer(count, code, caller).getData();
         }
-        return //code;
-                maxnumberService.pushMaxnubmer(count, code, caller).getData();
+        return billCode;
+    }
+
+    @Override
+    public String getMaxnumber(BillCodeSeq bill) {
+        String code = maxnumberService.getMaxnumber(bill.getCaller(), false).getData();
+        DocBaseDTO base = new DocBaseDTO(0l, code, bill.getName());
+        return pushMaxnubmer(base);
     }
 
     /**

+ 2 - 7
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleReportServiceImpl.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.page.PageDefault;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.sale.mapper.SaleProfitViewMapper;
 import com.usoftchina.saas.sale.mapper.SalerecViewMapper;
@@ -35,13 +36,7 @@ public class SaleReportServiceImpl implements SaleReportService{
         return getListDATA(page, req, "SaleRec");
     }
 
-    private PageInfo getListDATA(PageRequest page, ListReqDTO req, String type) {
-        //设置默认分页
-        if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
-            page = new PageRequest();
-            page.setNumber(1);
-            page.setSize(10);
-        }
+    private PageInfo getListDATA(@PageDefault(size = 10) PageRequest page, ListReqDTO req, String type) {
         PageHelper.startPage(page.getNumber(), page.getSize());
         //查询数据
         List lists = getListByType(req, type);

+ 22 - 14
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java

@@ -2,6 +2,7 @@ package com.usoftchina.saas.sale.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.commons.api.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -13,6 +14,7 @@ import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.page.PageDefault;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.sale.dto.SaleDTO;
 import com.usoftchina.saas.sale.dto.SaleDetailDTO;
@@ -21,6 +23,7 @@ import com.usoftchina.saas.sale.mapper.*;
 import com.usoftchina.saas.sale.po.Sale;
 import com.usoftchina.saas.sale.po.SaleDetail;
 import com.usoftchina.saas.sale.po.SaleList;
+import com.usoftchina.saas.sale.service.ProdInOutService;
 import com.usoftchina.saas.sale.service.SaleService;
 import com.usoftchina.saas.storage.po.ProdIODetail;
 import com.usoftchina.saas.storage.po.ProdInOut;
@@ -53,15 +56,13 @@ public class SaleServiceImpl implements SaleService{
     private ProdInOutMapper prodInOutMapper;
     @Autowired
     private ProdIODetailMapper prodIODetailMapper;
+    @Autowired
+    private ProdInOutService prodInOutService;
+    @Autowired
+    private CommonService commonService;
 
     @Override
-    public PageInfo<SaleList> getListData(PageRequest page, ListReqDTO req) {
-        //设置默认分页
-        if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
-            page = new PageRequest();
-            page.setNumber(1);
-            page.setSize(10);
-        }
+    public PageInfo<SaleList> getListData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
         PageHelper.startPage(page.getNumber(), page.getSize());
         //查询数据
         List<SaleList> lists = getListByMode(req);
@@ -229,7 +230,7 @@ public class SaleServiceImpl implements SaleService{
     }
 
     private void singleAudit(Long id) {
-        Sale sale = new Sale();
+        /*Sale sale = new Sale();
         //生成更新对象
         sale.setId(id);
         sale.setSa_status(Status.AUDITED.getDisplay());
@@ -239,7 +240,9 @@ public class SaleServiceImpl implements SaleService{
         sale.setSa_auditman("TESTADMIN");
         sale.setSa_auditdate(new Date());
         //更新存在字段
-        saleMapper.updateByPrimaryKeySelective(sale);
+        saleMapper.updateByPrimaryKeySelective(sale);*/
+        commonService.commonAudit("sale", "sa_id=" + id, "sa_status",
+                "sa_statuscode", "sa_auditdate", "sa_auditman");
         //更新销售金额
         updateTotal(id);
         //更新从表总额
@@ -429,8 +432,9 @@ public class SaleServiceImpl implements SaleService{
         //插入验收单主表
         ProdInOut prodInOut = new ProdInOut();
         //生成单号
-        String pi_inoutno = maxnumberService.getMaxnumber(BillCodeSeq.SALEOUT.getCaller(),
-                true).getData();
+       /* String pi_inoutno = maxnumberService.getMaxnumber(BillCodeSeq.SALEOUT.getCaller(),
+                true).getData();*/
+        String pi_inoutno = prodInOutService.getMaxnumber(BillCodeSeq.SALEOUT);
         prodInOut.setPi_inoutno(pi_inoutno);
         prodInOut.setPi_class(BillCodeSeq.SALEOUT.getName());
         prodInOut.setPi_date(new Date());
@@ -558,9 +562,13 @@ public class SaleServiceImpl implements SaleService{
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? saleMapper.validateCodeWhenInsert(code, companyId) :
-                saleMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.SALE.getCaller()).getData();
+        String billCode = null;
+        synchronized(SaleServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? saleMapper.validateCodeWhenInsert(code, companyId) :
+                    saleMapper.validateCodeWhenUpdate(code, id, companyId);
+            billCode = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.SALE.getCaller()).getData();
+        }
+        return billCode;
     }
 
     /**

+ 3 - 0
applications/sale/sale-server/src/main/resources/mapper/SaleProfitViewMapper.xml

@@ -20,8 +20,11 @@
     <result column="pd_ordertotal" property="pd_ordertotal" jdbcType="DOUBLE" />
     <result column="pd_total" property="pd_total" jdbcType="DOUBLE" />
     <result column="pd_profit" property="pd_profit" jdbcType="DOUBLE" />
+    <result column="pd_price" property="pd_price" jdbcType="DOUBLE" />
+    <result column="pd_netprice" property="pd_netprice" jdbcType="DOUBLE" />
     <result column="pd_profitpresent" property="pd_profitpresent" jdbcType="DOUBLE" />
     <result column="companyid" property="companyid" jdbcType="INTEGER" />
+      <result column="pd_remark" property="pd_remark" jdbcType="VARCHAR" />
   </resultMap>
   <select id="selectByCondition" resultMap="BaseResultMap">
     select  *  from Sale_Profit_View

+ 1 - 0
applications/sale/sale-server/src/main/resources/mapper/SalerecViewMapper.xml

@@ -15,6 +15,7 @@
     <result column="rb_backrate" property="rb_backrate" jdbcType="DOUBLE" />
     <result column="rb_remark" property="rb_remark" jdbcType="VARCHAR" />
     <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="rbd_amount" property="rbd_amount" jdbcType="DOUBLE" />
   </resultMap>
   <select id="selectByCondition" resultMap="BaseResultMap">
     select  *  from Salerec_View

+ 1 - 0
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/report/ProdiodetailView.java

@@ -13,6 +13,7 @@ import java.util.Date;
 public class ProdiodetailView implements Serializable{
 
     private String pi_inoutno;
+    private String pd_ordercode;
     private String pi_class;
     private String bizcode;
     private String bizname;

+ 26 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/controller/MakeController.java

@@ -40,6 +40,32 @@ public class MakeController {
         return Result.success(docBaseDTO);
     }
 
+    /**
+     * 制造单批量审核
+     *
+     * @param baseDTOs
+     * @return
+     */
+    @PostMapping("/batchAudit")
+    public Result batchAudit(@RequestBody BatchDealBaseDTO baseDTOs) {
+        String res = makeService.batchAudit(baseDTOs);
+        return Result.success(res);
+    }
+
+    /**
+     * 制造单批量反审核
+     *
+     * @param baseDTOs
+     * @return
+     */
+    @PostMapping("/batchUnAudit")
+    public Result batchUnAudit(@RequestBody BatchDealBaseDTO baseDTOs) {
+        String res = makeService.batchUnAudit(baseDTOs);
+        return Result.success(res);
+    }
+
+
+
     @PostMapping("/save")
     public Result save(@RequestBody MakeListDTO makeListDTO){
         DocBaseDTO docBaseDTO = makeService.saveOrUpdate(makeListDTO);

+ 4 - 2
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/MakeService.java

@@ -11,8 +11,6 @@ import com.usoftchina.saas.storage.dto.MakeListDTO;
 import com.usoftchina.saas.storage.mapper.MakeMapper;
 import com.usoftchina.saas.storage.po.Make;
 
-import java.util.List;
-
 public interface MakeService extends CommonBaseService<MakeMapper, Make> {
 
     /**
@@ -100,4 +98,8 @@ public interface MakeService extends CommonBaseService<MakeMapper, Make> {
      * @return
      */
     boolean batchDelete(BatchDealBaseDTO batchDealBaseDTO);
+
+    String batchAudit(BatchDealBaseDTO baseDTOs);
+
+    String batchUnAudit(BatchDealBaseDTO baseDTOs);
 }

+ 71 - 9
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/MakeServiceImpl.java

@@ -27,6 +27,7 @@ import com.usoftchina.saas.storage.po.ProdInOut;
 import com.usoftchina.saas.storage.service.MakeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
@@ -246,21 +247,29 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public DocBaseDTO audit(MakeListDTO makeListDTO) {
-        //1.获取主从表数据
+        Long id = makeListDTO.getMain().getId();
+        DocBaseDTO baseDTO = new DocBaseDTO();
         Make make = makeListDTO.getMain();
-        List<MakeMaterial> items = makeListDTO.getItems();
         //如果ID为0,先执行保存
-        if (makeListDTO.getMain().getId() == 0){
+        if (make.getId() == 0 || StringUtils.isEmpty(id)){
             DocBaseDTO docBaseDTO = saveOrUpdate(makeListDTO);
             make.setId(docBaseDTO.getId());
         }
+        //审核
+        singleAudit(makeListDTO);
+        baseDTO = generateMsgObj(make.getId(), make.getMa_code());
+        return baseDTO;
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED)
+    public void singleAudit(MakeListDTO makeListDTO) {
+        //1.获取主从表数据
+        Make make = makeListDTO.getMain();
         //2.校验库存是否足够
         validStorage(makeListDTO);
         //3.生成  完工入库单和领料单 并 过账
         generateProdIO(makeListDTO);
-
         //4.修改单据状态
         Make updateMake = new Make();
         updateMake.setId(make.getId());
@@ -274,9 +283,33 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
         DocBaseDTO docBaseDTO = generateMsgObj(make.getId(), make.getMa_code());
         //5.记录LOG
         messageLogService.audit(docBaseDTO);
-        return docBaseDTO;
     }
 
+
+    @Override
+    public String batchAudit(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return "没有可审核单据。";
+        }
+        StringBuffer errorMsg = new StringBuffer();
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            try {
+                Long id =  base.getId();
+                Make make = getMapper().selectByPrimaryKey(id);
+                List<MakeMaterial> makeMaterials = makeMaterialMapper.selectByFK(id,BaseContextHolder.getCompanyId());
+                MakeListDTO makeListDTO = new MakeListDTO();
+                makeListDTO.setMain(make);
+                makeListDTO.setItems(makeMaterials);
+                singleAudit(makeListDTO);
+            } catch (Exception e){
+                errorMsg.append("编号:" + base.getCode() + "处理失败," + e.getMessage());
+            }
+        }
+        return errorMsg.toString();
+    }
+
+
     /**
      * 1.生成  完工入库单和生产领料单
      * 2.过账
@@ -543,6 +576,9 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
         return docBaseDTO;
     }
 
+
+
+
     @Override
     public String batchClose(BatchDealBaseDTO batchDealBaseDTO) {
         StringBuilder errorMsg = new StringBuilder();
@@ -581,6 +617,28 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
         return true;
     }
 
+
+
+    @Override
+    public String batchUnAudit(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return "无可反审核单据。";
+        }
+        StringBuffer errorMsg = new StringBuffer();
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            try {
+                Long id =  base.getId();
+
+//                ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut,ProdInOutDTO.class);
+//                singleUnAudit(prodInOutDTO);
+            }catch (Exception e) {
+                errorMsg.append("编号:" + base.getCode() + "处理失败," + e.getMessage());
+            }
+        }
+        return errorMsg.toString();
+    }
+
     /**
      * 1.查找制造单关联的出入库单据
      * 2.反过账
@@ -654,8 +712,12 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
             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.MAKE.getCaller()).getData();
+        String ma_code = null;
+        synchronized (MakeServiceImpl.class){
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                    getMapper().validateCodeWhenUpdate(code, id, companyId);
+            ma_code =  maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.MAKE.getCaller()).getData();
+        }
+        return ma_code;
     }
 }

+ 20 - 15
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/ProdInOutServiceImpl.java

@@ -29,6 +29,7 @@ import com.usoftchina.saas.storage.service.ProdInOutService;
 import com.usoftchina.saas.utils.BeanMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
@@ -102,7 +103,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Override
-    @Transactional
+    @Transactional(propagation = Propagation.REQUIRED)
     public DocBaseDTO saveFormData(ProdInOutFormDTO formdata) {
         if (null == formdata || null == formdata.getMain()){
             throw new BizException(500, "数据为空,请填写后再保存");
@@ -125,8 +126,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
         prodInOut.setCompanyId(companyId);
         prodInOut.setCreatorId(userId);
-        prodInOut.setCreateTime(new Date());
-        prodInOut.setPi_date(new Date());
+        prodInOut.setCreateTime(prodInOut.getPi_recorddate()==null?new Date():prodInOut.getPi_recorddate());
+        prodInOut.setPi_date(prodInOut.getPi_date()==null?new Date():prodInOut.getPi_date());
         prodInOut.setPi_puid(main.getPi_puid());
         prodInOut.setPi_pucode(main.getPi_pucode());
         //编号获取
@@ -217,7 +218,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
 
 
     @Override
-    @Transactional
     public DocBaseDTO audit(ProdInOutFormDTO formData) {
         Long id = null;
         DocBaseDTO baseDTO = new DocBaseDTO();
@@ -233,6 +233,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return baseDTO;
     }
 
+    @Transactional(propagation = Propagation.REQUIRED)
     private void singleAudit(ProdInOutDTO prodInOutDTO) {
         String pi_class= prodInOutDTO.getPi_class();
         String pi_inoutno = prodInOutDTO.getPi_inoutno();
@@ -440,7 +441,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return baseDTO;
     }
 
-    private String pushMaxnubmer(ProdInOut prodInOut) {
+    private  String pushMaxnubmer(ProdInOut prodInOut) {
         String pi_inoutno = prodInOut.getPi_inoutno();
         String pi_class = prodInOut.getPi_class();
         Long id = prodInOut.getId();
@@ -448,17 +449,21 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
-                getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
-        String caller ="";
-        if("其它入库单".equals(pi_class)){
-            caller = BillCodeSeq.OTHERIN.getCaller();
-        }else if("其它出库单".equals(pi_class)) {
-            caller = BillCodeSeq.OTHEROUT.getCaller();
-        }else if("调拨单".equals(pi_class)) {
-            caller = BillCodeSeq.APPROPRIATIONINOUT.getCaller();
+        String code = null;
+        synchronized (ProdInOutServiceImpl.class){
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(pi_inoutno, companyId) :
+                    getMapper().validateCodeWhenUpdate(pi_inoutno, id, companyId);
+            String caller ="";
+            if("其它入库单".equals(pi_class)){
+                caller = BillCodeSeq.OTHERIN.getCaller();
+            }else if("其它出库单".equals(pi_class)) {
+                caller = BillCodeSeq.OTHEROUT.getCaller();
+            }else if("调拨单".equals(pi_class)) {
+                caller = BillCodeSeq.APPROPRIATIONINOUT.getCaller();
+            }
+            code = maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
         }
-        return maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
+        return code;
     }
 
 

+ 1 - 0
applications/storage/storage-server/src/main/resources/mapper/ProdInOutReportMapper.xml

@@ -4,6 +4,7 @@
 
   <resultMap id="ProdiodetailMap" type="com.usoftchina.saas.storage.po.report.ProdiodetailView">
     <result column="pi_inoutno" jdbcType="VARCHAR" property="pi_inoutno" />
+    <result column="pd_ordercode" jdbcType="VARCHAR" property="pd_ordercode" />
     <result column="pi_class" jdbcType="VARCHAR" property="pi_class" />
     <result column="bizcode" jdbcType="VARCHAR" property="bizcode" />
     <result column="bizname" jdbcType="VARCHAR" property="bizname" />

+ 78 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/AccountRoleDTO.java

@@ -0,0 +1,78 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+
+public class AccountRoleDTO implements Serializable {
+
+    private Long accountId;
+    private String username;
+    private String realname;
+    private String email;
+    private String mobile;
+    private String roleNames;
+    private String roleIds;
+
+    public String getRoleNames() {
+        return roleNames;
+    }
+
+    public void setRoleNames(String roleNames) {
+        this.roleNames = roleNames;
+    }
+
+    public String getRoleIds() {
+        return roleIds;
+    }
+
+    public void setRoleIds(String roleIds) {
+        this.roleIds = roleIds;
+    }
+
+    public Long getId() {
+        return accountId;
+    }
+
+    public void setId(Long accountId) {
+        this.accountId = accountId;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getRealname() {
+        return realname;
+    }
+
+    public void setRealname(String realname) {
+        this.realname = realname;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public Long getAccountId() {
+        return accountId;
+    }
+
+    public void setAccountId(Long accountId) {
+        this.accountId = accountId;
+    }
+}

+ 27 - 27
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/PowerDTO.java

@@ -6,15 +6,15 @@ public class PowerDTO {
     private Long groupId;
     private String moduleName;
     private String groupName;
-    private boolean query;
-    private boolean add;
-    private boolean update;
-    private boolean delete;
-    private boolean audit;
-    private boolean unAudit;
-    private boolean print;
-    private boolean fileExport;
-    private boolean fileImport;
+    private Boolean query;
+    private Boolean add;
+    private Boolean update;
+    private Boolean delete;
+    private Boolean audit;
+    private Boolean unAudit;
+    private Boolean print;
+    private Boolean fileExport;
+    private Boolean fileImport;
     private List<OtherPowerDTO> other;
 
     public Long getGroupId() {
@@ -41,75 +41,75 @@ public class PowerDTO {
         this.moduleName = moduleName;
     }
 
-    public boolean getQuery() {
+    public Boolean getQuery() {
         return query;
     }
 
-    public void setQuery(boolean query) {
+    public void setQuery(Boolean query) {
         this.query = query;
     }
 
-    public boolean getAdd() {
+    public Boolean getAdd() {
         return add;
     }
 
-    public void setAdd(boolean add) {
+    public void setAdd(Boolean add) {
         this.add = add;
     }
 
-    public boolean getUpdate() {
+    public Boolean getUpdate() {
         return update;
     }
 
-    public void setUpdate(boolean update) {
+    public void setUpdate(Boolean update) {
         this.update = update;
     }
 
-    public boolean getDelete() {
+    public Boolean getDelete() {
         return delete;
     }
 
-    public void setDelete(boolean delete) {
+    public void setDelete(Boolean delete) {
         this.delete = delete;
     }
 
-    public boolean getAudit() {
+    public Boolean getAudit() {
         return audit;
     }
 
-    public void setAudit(boolean audit) {
+    public void setAudit(Boolean audit) {
         this.audit = audit;
     }
 
-    public boolean getUnAudit() {
+    public Boolean getUnAudit() {
         return unAudit;
     }
 
-    public void setUnAudit(boolean unAudit) {
+    public void setUnAudit(Boolean unAudit) {
         this.unAudit = unAudit;
     }
 
-    public boolean getPrint() {
+    public Boolean getPrint() {
         return print;
     }
 
-    public void setPrint(boolean print) {
+    public void setPrint(Boolean print) {
         this.print = print;
     }
 
-    public boolean getFileExport() {
+    public Boolean getFileExport() {
         return fileExport;
     }
 
-    public void setFileExport(boolean fileExport) {
+    public void setFileExport(Boolean fileExport) {
         this.fileExport = fileExport;
     }
 
-    public boolean getFileImport() {
+    public Boolean getFileImport() {
         return fileImport;
     }
 
-    public void setFileImport(boolean fileImport) {
+    public void setFileImport(Boolean fileImport) {
         this.fileImport = fileImport;
     }
 

+ 18 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java

@@ -251,6 +251,24 @@ public class AccountController {
         return Result.success();
     }
 
+    /**
+     * 个人账户绑定角色
+     * @param accountId
+     * @param roleIds
+     * @return
+     */
+    @PostMapping("/bind/roles")
+    public Result bindRoles(@RequestParam long accountId, @RequestParam String roleIds) {
+        accountService.bindRoles(accountId, roleIds);
+        accountService.clearCache(accountId);
+        return Result.success();
+    }
+
+    @GetMapping("/accountRole/list")
+    public Result getAccountRole(){
+        return Result.success(accountService.selectAccountRole());
+    }
+
     /**
      * 解除个人账户绑定角色
      *

Some files were not shown because too many files changed in this diff