Browse Source

代码合并

chenw 7 years ago
parent
commit
5328a09353
100 changed files with 3846 additions and 718 deletions
  1. 12 0
      applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/CommonService.java
  2. 2 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  3. 102 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Configs.java
  4. 2 2
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Operation.java
  5. 14 3
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/CommonController.java
  6. 49 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ConfigsController.java
  7. 1 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/CommonMapper.java
  8. 26 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/ConfigsMapper.java
  9. 1 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/CommonService.java
  10. 19 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/ConfigsService.java
  11. 40 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/CommonServiceImpl.java
  12. 101 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/ConfigsServiceImpl.java
  13. 1 0
      applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/MessageLogServiceImpl.java
  14. 1 0
      applications/commons/commons-server/src/main/resources/i18n/messages.properties
  15. 5 0
      applications/commons/commons-server/src/main/resources/mapper/CommonMapper.xml
  16. 184 0
      applications/commons/commons-server/src/main/resources/mapper/ConfigsMapper.xml
  17. 29 22
      applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml
  18. 2 0
      applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/CustomerDTO.java
  19. 19 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bankinformation.java
  20. 195 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Banksubledger.java
  21. 141 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Subledger.java
  22. 1 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BankinformationMapper.java
  23. 33 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BanksubledgerMapper.java
  24. 4 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerMapper.java
  25. 39 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/SubledgerMapper.java
  26. 3 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendorMapper.java
  27. 82 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BankinformationServiceImpl.java
  28. 178 85
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java
  29. 8 4
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/EmployeeServiceImpl.java
  30. 7 3
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java
  31. 108 9
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java
  32. 26 1
      applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml
  33. 345 0
      applications/document/document-server/src/main/resources/mapper/BanksubledgerMapper.xml
  34. 10 1
      applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml
  35. 277 0
      applications/document/document-server/src/main/resources/mapper/SubledgerMapper.xml
  36. 9 0
      applications/document/document-server/src/main/resources/mapper/VendorMapper.xml
  37. 31 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/BankinformationMapper.java
  38. 50 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Fundtransfer.java
  39. 30 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othreceipts.java
  40. 32 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othspendings.java
  41. 5 5
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othspendingsdetail.java
  42. 101 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Paybalance.java
  43. 103 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Recbalance.java
  44. 97 33
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/FundtransferServiceImpl.java
  45. 78 14
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java
  46. 105 15
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthspendingsServiceImpl.java
  47. 29 15
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java
  48. 29 14
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  49. 351 0
      applications/money/money-server/src/main/resources/mapper/BankinformationMapper.xml
  50. 18 7
      applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml
  51. 14 8
      applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml
  52. 16 6
      applications/money/money-server/src/main/resources/mapper/OthspendingsMapper.xml
  53. 13 13
      applications/money/money-server/src/main/resources/mapper/OthspendingsdetailMapper.xml
  54. 23 6
      applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml
  55. 23 5
      applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml
  56. 0 3
      applications/money/money-server/src/main/resources/mapper/RecbalancedetMapper.xml
  57. 0 3
      applications/money/money-server/src/main/resources/mapper/RecbalancedetailMapper.xml
  58. 2 2
      applications/money/money-server/src/main/resources/mapper/StatsinfoMapper.xml
  59. 2 0
      applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/ProdInOutDTO.java
  60. 5 0
      applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseDTO.java
  61. 2 0
      applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseDetailDTO.java
  62. 1 0
      applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseListDTO.java
  63. 1 5
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java
  64. 0 4
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdInOutMapper.java
  65. 4 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/PurchaseMapper.java
  66. 2 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/ProdInOut.java
  67. 4 1
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/Purchase.java
  68. 2 0
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/PurchaseDetail.java
  69. 6 2
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/PurchaseList.java
  70. 3 1
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/report/PurchasePay.java
  71. 58 44
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java
  72. 54 44
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/PurchaseServiceImpl.java
  73. 3 88
      applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml
  74. 9 4
      applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutListMapper.xml
  75. 42 99
      applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutMapper.xml
  76. 7 2
      applications/purchase/purchase-server/src/main/resources/mapper/PurchaseListMapper.xml
  77. 42 27
      applications/purchase/purchase-server/src/main/resources/mapper/PurchaseMapper.xml
  78. 6 6
      applications/purchase/purchase-server/src/main/resources/mapper/PurchaseReportMapper.xml
  79. 16 3
      applications/purchase/purchase-server/src/main/resources/mapper/PurchasedetailMapper.xml
  80. 2 1
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/SaleApplication.java
  81. 4 1
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/SaleMapper.java
  82. 2 1
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/SaleList.java
  83. 6 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SaleProfitView.java
  84. 23 23
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java
  85. 2 7
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleReportServiceImpl.java
  86. 22 19
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java
  87. 6 11
      applications/sale/sale-server/src/main/resources/mapper/ProdIODetailMapper.xml
  88. 1 0
      applications/sale/sale-server/src/main/resources/mapper/ProdInOutListMapper.xml
  89. 6 4
      applications/sale/sale-server/src/main/resources/mapper/SaleMapper.xml
  90. 3 0
      applications/sale/sale-server/src/main/resources/mapper/SaleProfitViewMapper.xml
  91. 2 0
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOut.java
  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. 85 11
      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. 43 5
      base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/AccountApi.java
  99. 70 0
      base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/CompanyApi.java
  100. 22 7
      base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/cache/AccountCache.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("table") String table, @RequestParam("keyvalue") String keyvalue, @RequestParam("status") String status,
+                                      @RequestParam("statuscode") String statuscode, @RequestParam("auditdate") String auditdate, @RequestParam("auditman") String auditman);
+}

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

@@ -42,7 +42,9 @@ public enum BizExceptionCode implements BaseExceptionCode {
     PRODUCT_HAS_WAREHOUSE(79502, "存在物料默认仓库资料为该仓库资料,无法删除"),
     PRODUCTWH_HAS_WAREHOUSE(79503, "该仓库资料存在库存,无法删除"),
     ACCOUNT_EXISTS(79503, "账号已存在"),
+    USING_EXISTS(79504, ""),
     DEAL_FAILED(79800, "编号:<u>%s</u>处理失败,%s"),
+    USING_EXISTS(79504, ""),
 
 
 

+ 102 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Configs.java

@@ -0,0 +1,102 @@
+package com.usoftchina.saas.commons.po;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+
+import java.util.Date;
+
+/** 系统参数
+ * @author: guq
+ * @create: 2018-11-16 11:19
+ **/
+public class Configs {
+
+    private Long id;
+
+    private String code;
+
+    private String description;
+
+    private String data;
+
+    private Long companyId;
+
+    private String creatorName;
+
+    private Integer creatorId;
+
+    private Date createTime;
+
+    private String updaterName;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code == null ? null : code.trim();
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description == null ? null : description.trim();
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data == null ? null : data.trim();
+    }
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
+    public String getCreatorName() {
+        return creatorName;
+    }
+
+    public void setCreatorName(String creatorName) {
+        this.creatorName = creatorName == null ? null : creatorName.trim();
+    }
+
+    public Integer getCreatorId() {
+        return creatorId;
+    }
+
+    public void setCreatorId(Integer creatorId) {
+        this.creatorId = creatorId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdaterName() {
+        return updaterName;
+    }
+
+    public void setUpdaterName(String updaterName) {
+        this.updaterName = updaterName == null ? null : updaterName.trim();
+    }
+}

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

@@ -65,12 +65,12 @@ public enum Operation {
     /**
      * 转采购验收单
      */
-    TURNPURCCHECKIN("msg.TurnPurcCheckin", "msg.TurnPurcCheckinSuccess"),
+    PURCHASEIN("msg.TurnPurcCheckin", "msg.TurnPurcCheckinSuccess"),
 
     /**
      * 转采购验退单
      */
-    TURNPURCCHECKOUT("msg.TurnPurcCheckout", "msg.TurnPurcCheckoutSuccess"),
+    PURCHASEOUT("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("table") String table, @RequestParam("keyvalue") String keyvalue, @RequestParam("status") String status,
+                                      @RequestParam("statuscode") String statuscode, @RequestParam("auditdate") String auditdate, @RequestParam("auditman") String auditman) {
+
+        DeferredResult<String> deferredResult = new DeferredResult<>();
+        CompletableFuture.supplyAsync(() -> commonService.commonAudit(table, keyvalue, status, statuscode, auditdate, auditman))
+                .whenCompleteAsync((result, throwable) -> deferredResult.setResult(result));
+        return deferredResult;
+    }
+
 }

+ 49 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/ConfigsController.java

@@ -0,0 +1,49 @@
+package com.usoftchina.saas.commons.controller;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.po.Configs;
+import com.usoftchina.saas.commons.service.ConfigsService;
+import com.usoftchina.saas.page.PageRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author: guq
+ * @create: 2018-11-16 10:05
+ **/
+@RestController
+@RequestMapping("/configs")
+public class ConfigsController {
+
+    @Autowired
+    private ConfigsService configsService;
+
+    @GetMapping("/list")
+    public Result<Configs> getListData(PageRequest page, ListReqDTO req) {
+        PageInfo<Configs> listData = configsService.getListData(page, req);
+        return Result.success(listData);
+    }
+
+    @GetMapping("/getConfigByCode")
+    public Result<Configs> getConfigByCode(String code) {
+        Configs data = configsService.getConfigByCode(code);
+        return Result.success(data);
+    }
+
+    @PostMapping("/save")
+    public Result<DocBaseDTO> save(Configs data) {
+        DocBaseDTO baseDTO = configsService.save(data);
+        return Result.success(baseDTO);
+    }
+
+    @PostMapping("/update")
+    public Result update(@RequestBody List<Configs> data) {
+        configsService.update(data);
+        return Result.success();
+    }
+}

+ 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);
 }

+ 26 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/ConfigsMapper.java

@@ -0,0 +1,26 @@
+package com.usoftchina.saas.commons.mapper;
+
+import com.usoftchina.saas.commons.po.Configs;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ConfigsMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(Configs record);
+
+    int insertSelective(Configs record);
+
+    Configs selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(Configs record);
+
+    int updateByPrimaryKey(Configs record);
+
+    List<Configs> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
+
+    void updateCreator(@Param("userId") Long userId, @Param("userName") String userName, @Param("id") Long id);
+
+    void updateByCodeSelective(Configs con);
+}

+ 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);
 }

+ 19 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/ConfigsService.java

@@ -0,0 +1,19 @@
+package com.usoftchina.saas.commons.service;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.po.Configs;
+import com.usoftchina.saas.page.PageRequest;
+
+import java.util.List;
+
+public interface ConfigsService {
+    PageInfo getListData(PageRequest page, ListReqDTO req);
+
+    Configs getConfigByCode(String code);
+
+    DocBaseDTO save(Configs data);
+
+    void update(List<Configs> data);
+}

+ 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;
+    }
 }

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

@@ -0,0 +1,101 @@
+package com.usoftchina.saas.commons.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.mapper.ConfigsMapper;
+import com.usoftchina.saas.commons.po.Configs;
+import com.usoftchina.saas.commons.service.ConfigsService;
+import com.usoftchina.saas.commons.service.MessageLogService;
+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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+
+/**
+ * @author: guq
+ * @create: 2018-11-16 11:35
+ **/
+@Service
+public class ConfigsServiceImpl implements ConfigsService{
+
+    @Autowired
+    private ConfigsMapper configsMapper;
+    @Autowired
+    private MessageLogService messageLogService;
+
+
+    @Override
+    public PageInfo getListData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
+        Long companyId = BaseContextHolder.getCompanyId();
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        List<Configs> list = configsMapper.selectByCondition(req.getFinalCondition(), companyId);
+        //取分页信息
+        PageInfo<Configs> pageInfo = new PageInfo<Configs>(list);
+        return pageInfo;
+    }
+
+    @Override
+    public Configs getConfigByCode(String code) {
+        if (StringUtils.isEmpty(code)) {
+            return null;
+        }
+        List<Configs> list = configsMapper.selectByCondition(code, BaseContextHolder.getCompanyId());
+        if (null != list && list.size() > 0) {
+            return list.get(0);
+        }
+        return null;
+    }
+
+    @Override
+    public DocBaseDTO save(Configs formdata) {
+        if (null == formdata){
+            throw new BizException(50000, "数据为空,请填写后再保存");
+        }
+        //公司ID
+        Long companyId = BaseContextHolder.getCompanyId();
+        //人员Id
+        Long userId = BaseContextHolder.getUserId();
+        String name = BaseContextHolder.getUserName();
+        //返回对象
+        DocBaseDTO baseDTO = null;
+        Long id = formdata.getId();
+
+        //判断更新与保存动作
+        if (StringUtils.isEmpty(id) || "0".equals(id.toString())) {
+            //插入操作
+            formdata.setCompanyId(companyId);
+            configsMapper.insertSelective(formdata);
+            id = formdata.getId();
+            configsMapper.updateCreator(userId, name, id);
+            baseDTO = new DocBaseDTO(id, formdata.getCode(), "Configs");
+            //日志记录
+            messageLogService.save(baseDTO);
+            return baseDTO;
+        }
+
+        //更新操作
+        configsMapper.updateByPrimaryKeySelective(formdata);
+        baseDTO = new DocBaseDTO(id, formdata.getCode(), "Configs");
+        //日志
+        messageLogService.update(baseDTO);
+        return baseDTO;
+    }
+
+    @Override
+    public void update(List<Configs> data) {
+        if (StringUtils.isEmpty(data)) {
+            return;
+        }
+        for (Configs con : data) {
+            con.setCompanyId(BaseContextHolder.getCompanyId());
+            configsMapper.updateByCodeSelective(con);
+        }
+    }
+}

+ 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";
     }

+ 1 - 0
applications/commons/commons-server/src/main/resources/i18n/messages.properties

@@ -0,0 +1 @@
+msg.nullifySuccess=

+ 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>

+ 184 - 0
applications/commons/commons-server/src/main/resources/mapper/ConfigsMapper.xml

@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.commons.mapper.ConfigsMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.commons.po.Configs" >
+    <id column="id" property="id" jdbcType="INTEGER" />
+    <result column="code" property="code" jdbcType="VARCHAR" />
+    <result column="description" property="description" jdbcType="VARCHAR" />
+    <result column="data" property="data" jdbcType="VARCHAR" />
+    <result column="companyId" property="companyId" jdbcType="INTEGER" />
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="creatorId" property="creatorId" jdbcType="INTEGER" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    id, code, description, data, companyId, creatorName, creatorId, createTime, updaterName
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+    select
+    <include refid="Base_Column_List" />
+    from configs
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+    delete from configs
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.saas.commons.po.Configs" >
+    insert into configs (id, code, description,
+    data, companyId, creatorName,
+    creatorId, createTime, updaterName
+    )
+    values (#{id,jdbcType=INTEGER}, #{code,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
+    #{data,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER}, #{creatorName,jdbcType=VARCHAR},
+    #{creatorId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updaterName,jdbcType=VARCHAR}
+    )
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.commons.po.Configs" >
+    insert into configs
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        id,
+      </if>
+      <if test="code != null" >
+        code,
+      </if>
+      <if test="description != null" >
+        description,
+      </if>
+      <if test="data != null" >
+        data,
+      </if>
+      <if test="companyId != null" >
+        companyId,
+      </if>
+      <if test="creatorName != null" >
+        creatorName,
+      </if>
+      <if test="creatorId != null" >
+        creatorId,
+      </if>
+      <if test="createTime != null" >
+        createTime,
+      </if>
+      <if test="updaterName != null" >
+        updaterName,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="code != null" >
+        #{code,jdbcType=VARCHAR},
+      </if>
+      <if test="description != null" >
+        #{description,jdbcType=VARCHAR},
+      </if>
+      <if test="data != null" >
+        #{data,jdbcType=VARCHAR},
+      </if>
+      <if test="companyId != null" >
+        #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="creatorName != null" >
+        #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorId != null" >
+        #{creatorId,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updaterName != null" >
+        #{updaterName,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.commons.po.Configs" >
+    update configs
+    <set >
+      <if test="code != null" >
+        code = #{code,jdbcType=VARCHAR},
+      </if>
+      <if test="description != null" >
+        description = #{description,jdbcType=VARCHAR},
+      </if>
+      <if test="data != null" >
+        data = #{data,jdbcType=VARCHAR},
+      </if>
+      <if test="companyId != null" >
+        companyId = #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="creatorName != null" >
+        creatorName = #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorId != null" >
+        creatorId = #{creatorId,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null" >
+        createTime = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updaterName != null" >
+        updaterName = #{updaterName,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.commons.po.Configs" >
+    update configs
+    set code = #{code,jdbcType=VARCHAR},
+    description = #{description,jdbcType=VARCHAR},
+    data = #{data,jdbcType=VARCHAR},
+    companyId = #{companyId,jdbcType=INTEGER},
+    creatorName = #{creatorName,jdbcType=VARCHAR},
+    creatorId = #{creatorId,jdbcType=INTEGER},
+    createTime = #{createTime,jdbcType=TIMESTAMP},
+    updaterName = #{updaterName,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+
+  <select id="selectByCondition" resultMap="BaseResultMap">
+    select  *  from configs
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="companyId != null">
+        and  companyId = #{companyId}
+      </if>
+    </where>
+    order by id desc
+  </select>
+
+  <update id="updateCreator">
+    update configs set creatorId = #{userId} , creatorName=#{userName} where id=#{id}
+  </update>
+
+  <update id="updateByCodeSelective" parameterType="com.usoftchina.saas.commons.po.Configs" >
+    update configs
+    <set >
+      <if test="description != null" >
+        description = #{description,jdbcType=VARCHAR},
+      </if>
+      <if test="data != null" >
+        data = #{data,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorName != null" >
+        creatorName = #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorId != null" >
+        creatorId = #{creatorId,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null" >
+        createTime = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updaterName != null" >
+        updaterName = #{updaterName,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where code = #{code,jdbcType=VARCHAR} and companyid = #{companyId}
+  </update>
+
+</mapper>

+ 29 - 22
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(round(si_amount/10000,2),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 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='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=#{componyId} 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=#{componyId} 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;
 }

+ 19 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bankinformation.java

@@ -43,6 +43,25 @@ public class Bankinformation extends CommonBaseEntity implements Serializable {
 
     private String bk_remark;
 
+    private Double bk_income;
+    private Double bk_spending;
+
+    public Double getBk_income() {
+        return bk_income;
+    }
+
+    public void setBk_income(Double bk_income) {
+        this.bk_income = bk_income;
+    }
+
+    public Double getBk_spending() {
+        return bk_spending;
+    }
+
+    public void setBk_spending(Double bk_spending) {
+        this.bk_spending = bk_spending;
+    }
+
     public String getBk_bankcode() {
         return bk_bankcode;
     }

+ 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();
+    }
+
+}

+ 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 - 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);
+}

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

@@ -4,6 +4,8 @@ import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.document.entities.Customer;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Map;
+
 public interface CustomerMapper extends CommonBaseMapper<Customer> {
     int deleteByPrimaryKey(Long cu_id);
 
@@ -27,4 +29,6 @@ public interface CustomerMapper extends CommonBaseMapper<Customer> {
     int validNameAndCodeWhenUpdate(Customer record);
 
     int validFinish(@Param("id") Long id,@Param("companyId") Long companyId);
+
+    void check(Map<String, Object> map);
 }

+ 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);
+}

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

@@ -10,6 +10,7 @@ import com.usoftchina.saas.document.entities.VendorList;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface VendorMapper extends CommonBaseMapper<Vendor> {
 
@@ -28,4 +29,6 @@ public interface VendorMapper extends CommonBaseMapper<Vendor> {
     int getCountByName(@Param("name") String name, @Param("companyId") Long companyId);
 
     int validFinish(@Param("id") Long id,@Param("companyId") Long companyId);
+
+    void check(Map<String, Object> map);
 }

+ 82 - 2
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());
+        bankinformation.setBk_thisamount(bankinformation.getBk_beginamount());
+        bankinformation.setBk_income(new Double(0));
+        bankinformation.setBk_spending(new Double(0));
+
+        //判断编号
+        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;
+    }
 }

+ 178 - 85
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,9 +27,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * Created by zdw
@@ -58,6 +51,10 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
 
     @Autowired
     private MaxnumberService maxnumberService;
+    @Autowired
+    private SubledgerMapper subledgerMapper;
+    @Autowired
+    private CustomerMapper customerMapper;
 
 
     @Override
@@ -130,7 +127,9 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         //应付款余额
         Double beginapamount = main.getCu_beginaramount()==null?new Double(0):main.getCu_beginaramount();
         Double beginprepayamount = main.getCu_beginprerecamount()==null?new Double(0):main.getCu_beginprerecamount();
-        customer.setCu_leftamount(beginapamount-beginprepayamount);
+        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);
@@ -171,73 +170,114 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
             if (insertDetail2.size()>0) {
                 customeraddressMapper.batchInsert(insertDetail2);
             }
-            baseDTO = getBaseDTOById(cu_id);
-            //日志记录
-            messageLogService.save(baseDTO);
-            return baseDTO;
-        }
-        //检查名称和编号
-        int count = getMapper().validNameAndCodeWhenUpdate(customer);
-        if (count>0) {
-            throw new BizException(BizExceptionCode.REPEAT_CUSTOMERCODE);
-        }
-
-        //检查期初日期是否已结转
-        count = getMapper().validFinish(cu_id,companyId);
-        if (count>0) {
-            Customer cutpl = getMapper().selectByPrimaryKey(cu_id);
-            //期初应收
-            customer.setCu_beginaramount(cutpl.getCu_beginaramount());
-            //期初预收
-            customer.setCu_beginprerecamount(cutpl.getCu_beginprerecamount());
-        }
+        }else {
+            //检查名称和编号
+            int count = getMapper().validNameAndCodeWhenUpdate(customer);
+            if (count > 0) {
+                throw new BizException(BizExceptionCode.REPEAT_CUSTOMERCODE);
+            }
 
-        //更新操作
-        getMapper().updateByPrimaryKeySelective(customer);
-        //添加从表传输对象
-        for (CustomercontactDTO item : items1) {
-            Customercontact detail1 = BeanMapper.map(item,Customercontact.class);
-            detail1.setCc_cuid(cu_id);
-            detail1.setCompanyId(companyId);
-            detail1.setCreatorId(userId);
-            detail1.setCreateTime(new Date());
-            if (StringUtils.isEmpty(detail1.getId()) || "0".equals(detail1.getId().toString())) {
-                insertDetail1.add(detail1);
-            } else {
-                updateDetail1.add(detail1);
+            //检查期初日期是否已结转
+            count = getMapper().validFinish(cu_id, companyId);
+            if (count > 0) {
+                Customer cutpl = getMapper().selectByPrimaryKey(cu_id);
+                //期初应收
+                customer.setCu_beginaramount(cutpl.getCu_beginaramount());
+                //期初预收
+                customer.setCu_beginprerecamount(cutpl.getCu_beginprerecamount());
             }
-        }
-        //插入从表
-        if (insertDetail1.size()>0) {
-            customercontactMapper.batchInsert(insertDetail1);
-        }
-        //更新从表
-        if (updateDetail1.size()>0) {
-            customercontactMapper.batchUpdate(updateDetail1);
-        }
 
-        for (CustomeraddressDTO item : items2) {
-            Customeraddress detail2 = BeanMapper.map(item,Customeraddress.class);
-            detail2.setCa_cuid(cu_id);
-            detail2.setCompanyId(companyId);
-            detail2.setCreatorId(userId);
-            detail2.setCreateTime(new Date());
-            if (StringUtils.isEmpty(detail2.getId()) || "0".equals(detail2.getId().toString())) {
-                insertDetail2.add(detail2);
-            } else {
-                updateDetail2.add(detail2);
+            //更新操作
+            getMapper().updateByPrimaryKeySelective(customer);
+            //添加从表传输对象
+            for (CustomercontactDTO item : items1) {
+                Customercontact detail1 = BeanMapper.map(item, Customercontact.class);
+                detail1.setCc_cuid(cu_id);
+                detail1.setCompanyId(companyId);
+                detail1.setCreatorId(userId);
+                detail1.setCreateTime(new Date());
+                if (StringUtils.isEmpty(detail1.getId()) || "0".equals(detail1.getId().toString())) {
+                    insertDetail1.add(detail1);
+                } else {
+                    updateDetail1.add(detail1);
+                }
+            }
+            //插入从表
+            if (insertDetail1.size() > 0) {
+                customercontactMapper.batchInsert(insertDetail1);
+            }
+            //更新从表
+            if (updateDetail1.size() > 0) {
+                customercontactMapper.batchUpdate(updateDetail1);
             }
 
+            for (CustomeraddressDTO item : items2) {
+                Customeraddress detail2 = BeanMapper.map(item, Customeraddress.class);
+                detail2.setCa_cuid(cu_id);
+                detail2.setCompanyId(companyId);
+                detail2.setCreatorId(userId);
+                detail2.setCreateTime(new Date());
+                if (StringUtils.isEmpty(detail2.getId()) || "0".equals(detail2.getId().toString())) {
+                    insertDetail2.add(detail2);
+                } else {
+                    updateDetail2.add(detail2);
+                }
+
+            }
+            //插入从表
+            if (insertDetail2.size() > 0) {
+                customeraddressMapper.batchInsert(insertDetail2);
+            }
+            //更新从表
+            if (updateDetail2.size() > 0) {
+                customeraddressMapper.batchUpdate(updateDetail2);
+            }
         }
-        //插入从表
-        if (insertDetail2.size()>0) {
-            customeraddressMapper.batchInsert(insertDetail2);
-        }
-        //更新从表
-        if (updateDetail2.size()>0) {
-            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);
         //日志记录
@@ -254,13 +294,28 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
     private void singleDelete(Long id) {
         if (null!=id) {
             DocBaseDTO docBaseDTO = getBaseDTOById(id);
-            //主表删除
-            getMapper().deleteByPrimaryKey(id);
-            //从表删除
-            customercontactMapper.deleteByFK(id);
-            customeraddressMapper.deleteByFK(id);
-            //日志
-            messageLogService.delete(docBaseDTO);
+            Map<String, Object> map = new HashMap<String, Object>();
+            map.put("v_id",id);
+            map.put("v_code", docBaseDTO.getCode());
+            map.put("v_type","cust");
+            map.put("v_res","");
+            customerMapper.check(map);
+            Object result =  map.get("v_res");
+            if(!StringUtils.isEmpty(result)){
+                throw new BizException(BizExceptionCode.USING_EXISTS.getCode(),result.toString());
+            }else{
+                //主表删除
+                getMapper().deleteByPrimaryKey(id);
+                //从表删除
+                customercontactMapper.deleteByFK(id);
+                customeraddressMapper.deleteByFK(id);
+
+                //删除中间表
+                subledgerMapper.deleteCustomer("期初余额", "期初余额", Math.toIntExact(id));
+
+                //日志
+                messageLogService.delete(docBaseDTO);
+            }
         }
     }
 
@@ -295,7 +350,7 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
     }
 
     @Transactional
-    private DocBaseDTO singleClose(Long id) {
+    public DocBaseDTO singleClose(Long id) {
         DocBaseDTO docBaseDTO = null;
         if (null!=id) {
             Customer customer = getMapper().selectByPrimaryKey(id);
@@ -329,7 +384,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         }
     }
 
-    private DocBaseDTO singleOpen(Long id) {
+    @Transactional
+    public DocBaseDTO singleOpen(Long id) {
         DocBaseDTO docBaseDTO = null;
         if (null!=id) {
             Customer customer = getMapper().selectByPrimaryKey(id);
@@ -411,16 +467,53 @@ 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);
+        }else {
+            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);
+        }else {
+            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;
     }
 
 }

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

@@ -534,8 +534,12 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
             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.PRODUCT.getCaller()).getData();
+        String billCode = null;
+        synchronized (ProductServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                    getMapper().validateCodeWhenUpdate(code, id, companyId);
+            billCode = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PRODUCT.getCaller()).getData();
+        }
+        return billCode;
     }
 }

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

@@ -2,6 +2,7 @@ package com.usoftchina.saas.document.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
@@ -14,9 +15,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;
@@ -25,10 +28,10 @@ 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.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * @author chenwei
@@ -43,6 +46,10 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
     private MessageLogService messageLogService;
     @Autowired
     private MaxnumberService maxnumberService;
+    @Autowired
+    private SubledgerMapper subledgerMapper;
+    @Autowired
+    private VendorMapper vendorMapper;
 
     @Override
     public PageInfo<VendorDTO> getVendorsByCondition(PageRequest page, ListReqDTO listReqDTO) {
@@ -124,7 +131,9 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
             //更新应付款余额
             Double beginapamount = main.getVe_beginapamount()==null ? new Double(0):main.getVe_beginapamount();
             Double beginprepayamount = main.getVe_beginprepayamount()==null ? new Double(0):main.getVe_beginprepayamount();
-            main.setVe_leftamount(beginapamount-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
@@ -195,6 +204,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);
     }
 
@@ -205,11 +259,24 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
     @Override
     public void deleteById(Long id) {
         if(id != null && id > 0){
-            getMapper().deleteByPrimaryKey(id);
-            vendorcontactMapper.deleteByFK(id);
-            String code = getMapper().getCodeById(id, BaseContextHolder.getCompanyId());
-            //记录LOG
-            messageLogService.delete(generateMsgObj(id, code));
+            String code = getMapper().getCodeById(id, new Long(1));
+            Map<String, Object> map = new HashMap<String, Object>();
+            map.put("v_id",id);
+            map.put("v_code", code);
+            map.put("v_type","vend");
+            map.put("v_res","");
+            vendorMapper.check(map);
+            Object result =  map.get("v_res");
+            if(!StringUtils.isEmpty(result)){
+                throw new BizException(BizExceptionCode.USING_EXISTS.getCode(),result.toString());
+            }else{
+                getMapper().deleteByPrimaryKey(id);
+                vendorcontactMapper.deleteByFK(id);
+                //删除中间表
+                subledgerMapper.deleteVendor("期初余额", "期初余额", Math.toIntExact(id));
+                //记录LOG
+                messageLogService.delete(generateMsgObj(id, code));
+            }
         }
     }
 
@@ -355,4 +422,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;
+    }
 }

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

@@ -24,6 +24,8 @@
     <result column="bk_text4" property="bk_text4" jdbcType="VARCHAR" />
     <result column="bk_text5" property="bk_text5" jdbcType="VARCHAR" />
     <result column="bk_remark" property="bk_remark" jdbcType="VARCHAR" />
+    <result column="bk_spending" property="bk_spending" jdbcType="DOUBLE" />
+    <result column="bk_income" property="bk_income" jdbcType="DOUBLE" />
   </resultMap>
   <resultMap id="ResultMapWithBLOBs" type="com.usoftchina.saas.document.entities.Bankinformation" extends="BaseResultMap" >
     <result column="bk_remark" property="bk_remark" jdbcType="LONGVARCHAR" />
@@ -132,6 +134,12 @@
       <if test="bk_remark != null" >
         bk_remark,
       </if>
+      <if test="bk_spending != null" >
+        bk_spending,
+      </if>
+      <if test="bk_income != null" >
+        bk_income,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="bk_bankcode != null" >
@@ -197,6 +205,12 @@
       <if test="bk_remark != null" >
         #{bk_remark,jdbcType=LONGVARCHAR},
       </if>
+      <if test="bk_spending != null" >
+        #{bk_spending,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_income != null" >
+        #{bk_income,jdbcType=DOUBLE},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
@@ -265,6 +279,12 @@
       <if test="bk_remark != null" >
         bk_remark = #{bk_remark,jdbcType=LONGVARCHAR},
       </if>
+      <if test="bk_income != null" >
+        bk_income = #{bk_income,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_spending != null" >
+        bk_spending = #{bk_spending,jdbcType=DOUBLE},
+      </if>
     </set>
     where bk_id = #{id,jdbcType=INTEGER}
   </update>
@@ -309,9 +329,14 @@
       <if test="companyId != null">
         and   bankinformation.companyId = #{companyId}
       </if>
-    </where>  order by bk_id
+    </where>  order by bk_date desc, bk_id desc
   </select>
   <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>

+ 10 - 1
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, 
@@ -390,7 +391,15 @@
   select count(1) from periodsdetail where pd_status=99 and pd_detno=(select DATE_FORMAT(cu_begindate,'%Y%m') from customer where cu_id =#{id})
   and companyId =#{companyId};
   </select>
-
+  <select id="check" parameterMap="checkParamMap" statementType="CALLABLE">
+        CALL SP_LIMITBASE(?, ?, ?, ?)
+    </select>
+  <parameterMap id="checkParamMap" type="java.util.Map">
+    <parameter property="v_type" jdbcType="VARCHAR" mode="IN" />
+    <parameter property="v_id" jdbcType="INTEGER" mode="IN" />
+    <parameter property="v_code" jdbcType="VARCHAR" mode="IN" />
+    <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
+  </parameterMap>
 
 
 </mapper>

+ 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>

+ 9 - 0
applications/document/document-server/src/main/resources/mapper/VendorMapper.xml

@@ -477,5 +477,14 @@
         and companyId =#{companyId};
     </select>
 
+    <select id="check" parameterMap="checkParamMap" statementType="CALLABLE">
+        CALL SP_LIMITBASE(?, ?, ?, ?)
+    </select>
+    <parameterMap id="checkParamMap" type="java.util.Map">
+        <parameter property="v_type" jdbcType="VARCHAR" mode="IN" />
+        <parameter property="v_id" jdbcType="INTEGER" mode="IN" />
+        <parameter property="v_code" jdbcType="VARCHAR" mode="IN" />
+        <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
+    </parameterMap>
 </mapper>
 

+ 31 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/BankinformationMapper.java

@@ -0,0 +1,31 @@
+package com.usoftchina.saas.money.mapper;
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.commons.dto.ComboDTO;
+import com.usoftchina.saas.money.po.Bankinformation;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface BankinformationMapper extends CommonBaseMapper<Bankinformation> {
+    int deleteByPrimaryKey(Integer bkId);
+
+//    int insert(Bankinformation record);
+
+    int insertSelective(Bankinformation record);
+
+    Bankinformation selectByPrimaryKey(Integer bkId);
+
+    int updateByPrimaryKeySelective(Bankinformation record);
+
+    int updateByPrimaryKeyWithBLOBs(Bankinformation record);
+
+    List<Bankinformation> selectBankinformationBycondition(@Param("con") String con, @Param("companyId") Long companyId);
+
+    List<ComboDTO> getCombo(@Param("companyId") Long companyId);
+    String selectBankcode(String bk_bankcode);
+
+    void updateBankAmount(@Param("id") Integer id, @Param("bk_thisamount") Double bk_thisamount);
+    Double selectThisamount(Integer id);
+
+}

+ 50 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Fundtransfer.java

@@ -35,6 +35,16 @@ public class Fundtransfer extends CommonBaseEntity implements Serializable {
 
     private String ft_text5;
 
+    private String ftd_bankname;
+
+    private String ftd_inbankname;
+
+    private Double ftd_nowbalance;
+
+    private String ftd_paymethod;
+
+    private String ftd_paycode;
+
     public String getFt_code() {
         return ft_code;
     }
@@ -146,4 +156,44 @@ public class Fundtransfer extends CommonBaseEntity implements Serializable {
     public void setFt_text5(String ft_text5) {
         this.ft_text5 = ft_text5;
     }
+
+    public String getFtd_bankname() {
+        return ftd_bankname;
+    }
+
+    public void setFtd_bankname(String ftd_bankname) {
+        this.ftd_bankname = ftd_bankname;
+    }
+
+    public String getFtd_inbankname() {
+        return ftd_inbankname;
+    }
+
+    public void setFtd_inbankname(String ftd_inbankname) {
+        this.ftd_inbankname = ftd_inbankname;
+    }
+
+    public Double getFtd_nowbalance() {
+        return ftd_nowbalance;
+    }
+
+    public void setFtd_nowbalance(Double ftd_nowbalance) {
+        this.ftd_nowbalance = ftd_nowbalance;
+    }
+
+    public String getFtd_paymethod() {
+        return ftd_paymethod;
+    }
+
+    public void setFtd_paymethod(String ftd_paymethod) {
+        this.ftd_paymethod = ftd_paymethod;
+    }
+
+    public String getFtd_paycode() {
+        return ftd_paycode;
+    }
+
+    public void setFtd_paycode(String ftd_paycode) {
+        this.ftd_paycode = ftd_paycode;
+    }
 }

+ 30 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othreceipts.java

@@ -49,6 +49,12 @@ public class Othreceipts extends CommonBaseEntity implements Serializable {
 
     private String or_text5;
 
+    private String ord_type;
+
+    private Double ord_nowbalance;
+
+    private String ord_remark;
+
     public String getOr_code() {
         return or_code;
     }
@@ -217,6 +223,30 @@ public class Othreceipts extends CommonBaseEntity implements Serializable {
         this.or_text5 = or_text5;
     }
 
+    public String getOrd_type() {
+        return ord_type;
+    }
+
+    public void setOrd_type(String ord_type) {
+        this.ord_type = ord_type;
+    }
+
+    public Double getOrd_nowbalance() {
+        return ord_nowbalance;
+    }
+
+    public void setOrd_nowbalance(Double ord_nowbalance) {
+        this.ord_nowbalance = ord_nowbalance;
+    }
+
+    public String getOrd_remark() {
+        return ord_remark;
+    }
+
+    public void setOrd_remark(String ord_remark) {
+        this.ord_remark = ord_remark;
+    }
+
     @Override
     public String toString() {
         return "Othreceipts{" +

+ 32 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othspendings.java

@@ -50,6 +50,14 @@ public class Othspendings extends CommonBaseEntity implements Serializable {
 
     private String os_text5;
 
+    private String osd_type;
+
+    private Double osd_nowbalance;
+
+    private String osd_remark;
+
+
+
     public String getOs_code() {
         return os_code;
     }
@@ -217,4 +225,28 @@ public class Othspendings extends CommonBaseEntity implements Serializable {
     public void setOs_text5(String os_text5) {
         this.os_text5 = os_text5;
     }
+
+    public String getOsd_type() {
+        return osd_type;
+    }
+
+    public void setOsd_type(String osd_type) {
+        this.osd_type = osd_type;
+    }
+
+    public Double getOsd_nowbalance() {
+        return osd_nowbalance;
+    }
+
+    public void setOsd_nowbalance(Double osd_nowbalance) {
+        this.osd_nowbalance = osd_nowbalance;
+    }
+
+    public String getOsd_remark() {
+        return osd_remark;
+    }
+
+    public void setOsd_remark(String osd_remark) {
+        this.osd_remark = osd_remark;
+    }
 }

+ 5 - 5
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othspendingsdetail.java

@@ -7,7 +7,7 @@ import java.util.Date;
 
 public class Othspendingsdetail extends CommonBaseEntity implements Serializable {
 
-    private Integer osd_orid;
+    private Integer osd_osid;
 
     private Integer osd_detno;
 
@@ -41,12 +41,12 @@ public class Othspendingsdetail extends CommonBaseEntity implements Serializable
         this.os_date = os_date;
     }
 
-    public Integer getOsd_orid() {
-        return osd_orid;
+    public Integer getOsd_osid() {
+        return osd_osid;
     }
 
-    public void setOsd_orid(Integer osd_orid) {
-        this.osd_orid = osd_orid;
+    public void setOsd_osid(Integer osd_osid) {
+        this.osd_osid = osd_osid;
     }
 
     public Integer getOsd_detno() {

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

@@ -63,6 +63,27 @@ public class Paybalance extends CommonBaseEntity implements Serializable {
 
     private Double ve_leftamount;
 
+    private String pd_bankname;
+
+    private Double pd_amount;
+
+    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 +283,84 @@ 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;
+    }
+
+    public Double getPd_amount() {
+        return pd_amount;
+    }
+
+    public void setPd_amount(Double pd_amount) {
+        this.pd_amount = pd_amount;
+    }
+
+    public String getPd_paycode() {
+        return pd_paycode;
+    }
+
+    public void setPd_paycode(String pd_paycode) {
+        this.pd_paycode = pd_paycode;
+    }
 }

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

@@ -63,6 +63,29 @@ public class Recbalance extends CommonBaseEntity implements Serializable {
 
     private Double cu_leftamount;
 
+    private String rd_bankname;
+
+    private Double rd_amount;
+
+    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;
     }
@@ -262,4 +285,84 @@ public class Recbalance extends CommonBaseEntity implements Serializable {
     public void setCu_leftamount(Double cu_leftamount) {
         this.cu_leftamount = cu_leftamount;
     }
+
+    public String getRd_bankname() {
+        return rd_bankname;
+    }
+
+    public void setRd_bankname(String rd_bankname) {
+        this.rd_bankname = rd_bankname;
+    }
+
+    public Double getRd_amount() {
+        return rd_amount;
+    }
+
+    public void setRd_amount(Double rd_amount) {
+        this.rd_amount = rd_amount;
+    }
+
+    public String getRd_paymethod() {
+        return rd_paymethod;
+    }
+
+    public void setRd_paymethod(String rd_paymethod) {
+        this.rd_paymethod = rd_paymethod;
+    }
+
+    public String getRd_paycode() {
+        return rd_paycode;
+    }
+
+    public void setRd_paycode(String rd_paycode) {
+        this.rd_paycode = rd_paycode;
+    }
+
+    public String getRd_remark() {
+        return rd_remark;
+    }
+
+    public void setRd_remark(String rd_remark) {
+        this.rd_remark = rd_remark;
+    }
+
+    public String getRbd_slcode() {
+        return rbd_slcode;
+    }
+
+    public void setRbd_slcode(String rbd_slcode) {
+        this.rbd_slcode = rbd_slcode;
+    }
+
+    public String getRbd_slkind() {
+        return rbd_slkind;
+    }
+
+    public void setRbd_slkind(String rbd_slkind) {
+        this.rbd_slkind = rbd_slkind;
+    }
+
+    public Date getRbd_sldate() {
+        return rbd_sldate;
+    }
+
+    public void setRbd_sldate(Date rbd_sldate) {
+        this.rbd_sldate = rbd_sldate;
+    }
+
+    public Double getRbd_amount() {
+        return rbd_amount;
+    }
+
+    public void setRbd_amount(Double rbd_amount) {
+        this.rbd_amount = rbd_amount;
+    }
+
+    public Double getRbd_nowbalance() {
+        return rbd_nowbalance;
+    }
+
+    public void setRbd_nowbalance(Double rbd_nowbalance) {
+        this.rbd_nowbalance = rbd_nowbalance;
+    }
 }

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

@@ -42,6 +42,8 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
     private PaybalanceMapper paybalanceMapper;
     @Autowired
     private MessageLogService messageLogService;
+    @Autowired
+    private BankinformationMapper bankinformationMapper;
 
     @Override
     public DocBaseDTO insert(Fundtran fundtran) {
@@ -59,13 +61,21 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
 
         Long id = fundtransfer.getId();
 
-        if (fundtransfer.getId() > 0){
+        DocBaseDTO baseDTO = new DocBaseDTO();
+        if (id > 0){
             fundtransferMapper.updateByPrimaryKeySelective(fundtransfer);
+            baseDTO = getBaseDTOById(id);
+            //日志记录
+            messageLogService.update(baseDTO);
         }else {
             fundtransfer.setCompanyId(BaseContextHolder.getCompanyId());
             fundtransfer.setFt_recorder(BaseContextHolder.getUserName());
             fundtransferMapper.insertSelective(fundtransfer);
             id = fundtransfer.getId();
+
+            baseDTO = getBaseDTOById(id);
+            //日志记录
+            messageLogService.save(baseDTO);
         }
 
         Iterator isdet = fundtransferdetails.iterator();
@@ -80,9 +90,6 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
                 fundtransferdetailMapper.insertSelective(fundtransferdetail);
             }
         }
-        DocBaseDTO baseDTO = getBaseDTOById(id);
-        //日志记录
-        messageLogService.save(baseDTO);
         return baseDTO;
     }
 
@@ -96,38 +103,73 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
         this.changBankUntil(fundtran);
         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(), "+");
+            Double amount = fundtransferdetail.getFtd_nowbalance();
+            //收款
+            Banksubledger banksubledger = new Banksubledger();
+            banksubledger.setCompanyId(BaseContextHolder.getCompanyId());
+            banksubledger.setBl_ym(fundtransferdetail.getFtd_ym());
+            banksubledger.setBl_bankid(fundtransferdetail.getFtd_inbankid());
+            banksubledger.setBl_bankcode(fundtransferdetail.getFtd_inbankcode());
+            banksubledger.setBl_bankname(fundtransferdetail.getFtd_inbankname());
+            banksubledger.setBl_code(fundtransfer.getFt_code());
+            banksubledger.setBl_kind("资金转账");
+            banksubledger.setBl_date(fundtransfer.getFt_date());
+            banksubledger.setBl_income(fundtransferdetail.getFtd_nowbalance());
+            banksubledger.setBl_remark(fundtransferdetail.getFtd_remark());
+            banksubledgerMapper.insertSelective(banksubledger);
+
+            //付款
+            Banksubledger banksubledger1 = new Banksubledger();
+            banksubledger1.setCompanyId(BaseContextHolder.getCompanyId());
+            banksubledger1.setBl_ym(fundtransferdetail.getFtd_ym());
+            banksubledger1.setBl_bankid(fundtransferdetail.getFtd_bankid());
+            banksubledger1.setBl_bankcode(fundtransferdetail.getFtd_bankcode());
+            banksubledger1.setBl_bankname(fundtransferdetail.getFtd_bankname());
+            banksubledger1.setBl_code(fundtransfer.getFt_code());
+            banksubledger1.setBl_kind("资金转账");
+            banksubledger1.setBl_date(fundtransfer.getFt_date());
+            banksubledger1.setBl_spending(fundtransferdetail.getFtd_nowbalance());
+            banksubledger1.setBl_remark(fundtransferdetail.getFtd_remark());
+            banksubledgerMapper.insertSelective(banksubledger1);
 
             //资金账号表
             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);
+            Double bk_amount = fundtransferdetail.getFtd_nowbalance();
+            //付款方
+            Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
+            Double beginamount = bankinformation.getBk_beginamount() == null ? new Double(0) : bankinformation.getBk_beginamount();
+//            if (beginamount < bk_amount){
+//                throw new BizException(500, BizExceptionCode.BANK_AMOUNT_NOTENOUGH.getMessage());
+//            }
+            Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
+            Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
+            bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
+            bankinformation.setBk_income(incomme);
+            bankinformation.setBk_spending(spending + bk_amount);
+
+            //收款方
+            Bankinformation inbankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
+            Double inbeginamount = inbankinformation.getBk_beginamount()== null ? new Double(0) : inbankinformation.getBk_beginamount();
+            Double inspending = inbankinformation.getBk_spending() == null ? new Double(0) : inbankinformation.getBk_spending();
+            Double inincomme = inbankinformation.getBk_income() == null ? new Double(0) : inbankinformation.getBk_income();
+            inbankinformation.setBk_thisamount(inbeginamount + inincomme - inspending + bk_amount);
+            inbankinformation.setBk_income(inincomme + bk_amount);
+            inbankinformation.setBk_spending(inspending);
+
+            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+            bankinformationMapper.updateByPrimaryKeySelective(inbankinformation);
         }
         DocBaseDTO baseDTO = getBaseDTOById(id);
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.audit(baseDTO);
         return baseDTO;
     }
 
@@ -141,7 +183,7 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
 
         //删除中间表
         fundtransfer = fundtransferMapper.selectByPrimaryKey(id);
-        banksubledgerMapper.deleteByPrimaryKey(fundtransfer.getFt_code(), "其他收入单");
+        banksubledgerMapper.deleteByPrimaryKey(fundtransfer.getFt_code(), "资金转账");
 
         //资金
         //取从表金额
@@ -159,15 +201,33 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
             //资金账号表
             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);
+
+            Double bk_amount = fundtransferdetail.getFtd_nowbalance();
+            //付款方
+            Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
+            Double beginamount = bankinformation.getBk_beginamount()== null ? new Double(0) : bankinformation.getBk_beginamount();
+            Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
+            Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
+            bankinformation.setBk_thisamount(beginamount + incomme - spending + bk_amount);
+            bankinformation.setBk_income(incomme);
+            bankinformation.setBk_spending(spending - bk_amount);
+
+            //收款方
+            Bankinformation inbankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
+            Double inbeginamount = inbankinformation.getBk_beginamount()== null ? new Double(0) : inbankinformation.getBk_beginamount();
+            Double inspending = inbankinformation.getBk_spending() == null ? new Double(0) : inbankinformation.getBk_spending();
+            Double inincomme = inbankinformation.getBk_income() == null ? new Double(0) : inbankinformation.getBk_income();
+            inbankinformation.setBk_thisamount(inbeginamount + inincomme - inspending - bk_amount);
+            inbankinformation.setBk_income(inincomme - bk_amount);
+            inbankinformation.setBk_spending(inspending);
+
+            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+            bankinformationMapper.updateByPrimaryKeySelective(inbankinformation);
         }
 
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.unAudit(baseDTO);
     }
 
 
@@ -177,7 +237,7 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
         fundtransferdetailMapper.deleteByPrimaryKey(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.delete(baseDTO);
     }
 
     @Override
@@ -185,7 +245,7 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
         fundtransferdetailMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     @Override
@@ -257,9 +317,13 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? fundtransferMapper.validateCodeWhenInsert(code, companyId) :
-                fundtransferMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.FUNDTRANSFER.getCaller()).getData();
+        String codeString = null;
+        synchronized(FundtransferServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? fundtransferMapper.validateCodeWhenInsert(code, companyId) :
+                    fundtransferMapper.validateCodeWhenUpdate(code, id, companyId);
+            codeString = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.FUNDTRANSFER.getCaller()).getData();
+        }
+        return codeString;
     }
 
     private List<Fundtransfer> getListByMode(ListReqDTO req) {

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

@@ -3,6 +3,7 @@ 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.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -13,10 +14,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.OthreceiptsMapper;
-import com.usoftchina.saas.money.mapper.OthreceiptsdetailMapper;
-import com.usoftchina.saas.money.mapper.StatsinfoMapper;
+import com.usoftchina.saas.money.mapper.*;
 import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.OthreceiptsService;
 import com.usoftchina.saas.page.PageRequest;
@@ -46,6 +44,14 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
     private StatsinfoMapper statsinfoMapper;
     @Autowired
     private MessageLogService messageLogService;
+    @Autowired
+    private CommonService commonService;
+    @Autowired
+    private BankinformationMapper bankinformationMapper;
+    @Autowired
+    private RecbalanceMapper recbalanceMapper;
+    @Autowired
+    private SubledgerMapper subledgerMapper;
 
     @Override
     public DocBaseDTO insert(Othte othte) {
@@ -63,13 +69,20 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
 
         Long id = othreceipts.getId();
 
+        DocBaseDTO baseDTO = new DocBaseDTO();
         if (othreceipts.getId() > 0){
             othreceiptsMapper.updateByPrimaryKeySelective(othreceipts);
+            baseDTO = getBaseDTOById(id);
+            //日志记录
+            messageLogService.update(baseDTO);
         }else {
             othreceipts.setCompanyId(BaseContextHolder.getCompanyId());
             othreceipts.setOr_recorder(BaseContextHolder.getUserName());
             othreceiptsMapper.insertSelective(othreceipts);
             id = othreceipts.getId();
+            baseDTO = getBaseDTOById(id);
+            //日志记录
+            messageLogService.save(baseDTO);
         }
 
         Iterator isdet = othreceiptsdetail.iterator();
@@ -84,9 +97,6 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
                 othreceiptsdetailMapper.insertSelective(othreceiptsdetail1);
             }
         }
-        DocBaseDTO baseDTO = getBaseDTOById(id);
-        //日志记录
-        messageLogService.save(baseDTO);
         return baseDTO;
     }
 
@@ -108,8 +118,55 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
             Othreceiptsdetail othreceiptsdetail = (Othreceiptsdetail) isList.next();
             banksubledgerMapper.updateBankcode(amount, othreceiptsdetail.getOrd_nowbalance(),
                     othreceipts.getOr_bankcode(), "+");
+
         }
 
+        //资金账号表
+        int bk_inid = othreceipts.getOr_bankid();
+
+        Double or_amount = othreceipts.getOr_amount();
+        //收款
+        Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
+        Double beginamount = bankinformation.getBk_beginamount();
+        Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
+        Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
+        bankinformation.setBk_thisamount(beginamount + incomme - spending + or_amount);
+        bankinformation.setBk_income(incomme + or_amount);
+        bankinformation.setBk_spending(spending);
+        bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+
+        //客户付款
+        /**
+         * 更新客户资料
+         * cu_preamount=nvl(cu_preamount,0)+rb_preamount,
+         * cu_recamount=nvl(cu_recamount,0)-rb_rbdamount,
+         * cu_leftamount=cu_beginaramount-cu_beginprerecamount+cu_recamount-cu_preamount;
+         */
+        Customer customerData = recbalanceMapper.selectCustomerByPrimaryKey(othreceipts.getOr_custid());
+        Double preamount = customerData.getCu_preamount()==null?new Double(0):customerData.getCu_preamount();
+        Double beginapamount = customerData.getCu_beginaramount()==null?new Double(0):customerData.getCu_beginaramount();
+        Double beginprepayamount= customerData.getCu_beginprerecamount()==null?new Double(0):customerData.getCu_beginprerecamount();
+        Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
+
+        Customer customer = new Customer();
+        customer.setId(Long.valueOf(othreceipts.getOr_custid()));
+        customer.setCu_preamount(preamount);
+        customer.setCu_recamount(recamount-or_amount);
+        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-or_amount-preamount);
+        recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
+
+        //插入subledger中间表
+        Subledger subledger = new Subledger();
+        subledger.setSl_code(othreceipts.getOr_code());
+        subledger.setSl_kind("其他收入单");
+        subledger.setSl_custid(othreceipts.getOr_custid());
+        subledger.setSl_vendid(0);
+        subledger.setSl_date(othreceipts.getOr_date());
+        subledger.setSl_amount(or_amount);
+        subledger.setCompanyId(BaseContextHolder.getCompanyId());
+        subledgerMapper.insertSelective(subledger);
+
+
         //计算期间金额
         Statsinfo statsinfo = new Statsinfo();
         List<Integer> ymList = othreceiptsdetailMapper.selectYm(Math.toIntExact(id));
@@ -126,8 +183,11 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
         }
 
         DocBaseDTO baseDTO = getBaseDTOById(id);
+//        commonService.commonAudit(BillCodeSeq.RECBALANCE.getCaller(),
+//                "rb_id="+baseDTO.getId(),"rb_status","rb_statuscode",
+//                "rb_auditdate","rb_auditman");
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.audit(baseDTO);
         return baseDTO;
     }
 
@@ -168,7 +228,7 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
         }
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.unAudit(baseDTO);
     }
 
     @Override
@@ -177,14 +237,14 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
         othreceiptsdetailMapper.deleteByPrimaryKey(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.delete(baseDTO);
     }
 
     public void deleteItem(int id) {
         othreceiptsdetailMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     @Override
@@ -256,9 +316,13 @@ public class OthreceiptsServiceImpl extends CommonBaseServiceImpl<OthreceiptsMap
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? othreceiptsMapper.validateCodeWhenInsert(code, companyId) :
-                othreceiptsMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.OTHRECEIPTS.getCaller()).getData();
+        String codeString = null;
+        synchronized(OthreceiptsServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? othreceiptsMapper.validateCodeWhenInsert(code, companyId) :
+                    othreceiptsMapper.validateCodeWhenUpdate(code, id, companyId);
+            codeString = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.OTHRECEIPTS.getCaller()).getData();
+        }
+        return codeString;
     }
 
     private List<Othreceipts> getListByMode(ListReqDTO req) {

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

@@ -13,10 +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.OthspendingsMapper;
-import com.usoftchina.saas.money.mapper.OthspendingsdetailMapper;
-import com.usoftchina.saas.money.mapper.StatsinfoMapper;
+import com.usoftchina.saas.money.mapper.*;
 import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.OthspendingsService;
 import com.usoftchina.saas.page.PageRequest;
@@ -45,6 +42,12 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
     private StatsinfoMapper statsinfoMapper;
     @Autowired
     private MessageLogService messageLogService;
+    @Autowired
+    private BankinformationMapper bankinformationMapper;
+    @Autowired
+    private SubledgerMapper subledgerMapper;
+    @Autowired
+    private PaybalanceMapper paybalanceMapper;
 
     @Override
     public DocBaseDTO insert(Othsp othsp) {
@@ -61,19 +64,27 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         Long id = othspendings.getId();
 
 
+        DocBaseDTO baseDTO = new DocBaseDTO();
         if (othspendings.getId() > 0){
             othspendingsMapper.updateByPrimaryKeySelective(othspendings);
+            baseDTO = getBaseDTOById(id);
+            //日志记录
+            messageLogService.update(baseDTO);
         }else {
             othspendings.setCompanyId(BaseContextHolder.getCompanyId());
             othspendings.setOs_recorder(BaseContextHolder.getUserName());
             othspendingsMapper.insertSelective(othspendings);
             id = othspendings.getId();
+
+            baseDTO = getBaseDTOById(id);
+            //日志记录
+            messageLogService.save(baseDTO);
         }
 
         Iterator isdet = othspendingsdetails.iterator();
         while (isdet.hasNext()){
             Othspendingsdetail othspendingsdetail = (Othspendingsdetail) isdet.next();
-            othspendingsdetail.setOsd_orid(Math.toIntExact(id));
+            othspendingsdetail.setOsd_osid(Math.toIntExact(id));
             othspendingsdetail.setCompanyId(BaseContextHolder.getCompanyId());
             othspendingsdetail.setOs_date(othspendings.getOs_date());
             if (othspendingsdetail.getId() > 0 ){
@@ -82,9 +93,6 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
                 othspendingsdetailMapper.insertSelective(othspendingsdetail);
             }
         }
-        DocBaseDTO baseDTO = getBaseDTOById(id);
-        //日志记录
-        messageLogService.save(baseDTO);
         return baseDTO;
     }
 
@@ -94,7 +102,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         othspendingsdetailMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.delete(baseDTO);
     }
 
     @Override
@@ -102,7 +110,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         othspendingsdetailMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     @Override
@@ -149,6 +157,51 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
                     othspendings.getOs_bankcode(), "+");
         }
 
+        //资金账号表
+        int bk_id = othspendings.getOs_bankid();
+
+        Double bk_amount = othspendings.getOs_amount();
+        //付款方
+        Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
+        Double beginamount = bankinformation.getBk_beginamount() == null ? new Double(0) : bankinformation.getBk_beginamount();
+//        if (beginamount < bk_amount){
+//            throw new BizException(500, BizExceptionCode.BANK_AMOUNT_NOTENOUGH.getMessage());
+//        }
+        Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
+        Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
+        bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
+        bankinformation.setBk_income(incomme);
+        bankinformation.setBk_spending(spending + bk_amount);
+
+        /**
+         * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
+         * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
+         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+         */
+        Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
+        Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
+        Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
+        Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
+        Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
+
+        Vendor vendor = new Vendor();
+        vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
+        vendor.setVe_preamount(preamount);
+        vendor.setVe_payamount(payamount - bk_amount);
+        vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-bk_amount-preamount);
+        paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
+
+        //插入subledger中间表
+        Subledger subledger = new Subledger();
+        subledger.setSl_code(othspendings.getOs_code());
+        subledger.setSl_kind("其他支出单");
+        subledger.setSl_custid(0);
+        subledger.setSl_vendid(othspendings.getOs_vendid());
+        subledger.setSl_date(othspendings.getOs_date());
+        subledger.setSl_amount(bk_amount);
+        subledger.setCompanyId(BaseContextHolder.getCompanyId());
+        subledgerMapper.insertSelective(subledger);
+
         //计算期间金额
         Statsinfo statsinfo = new Statsinfo();
         List<Integer> ymList = othspendingsdetailMapper.selectYm(Math.toIntExact(id));
@@ -165,7 +218,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         }
         DocBaseDTO baseDTO = getBaseDTOById(id);
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.audit(baseDTO);
         return baseDTO;
     }
 
@@ -180,6 +233,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
         //删除中间表
         othspendings = othspendingsMapper.selectByPrimaryKey(id);
         banksubledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他收入单");
+        subledgerMapper.deleteByPrimaryKey(othspendings.getOs_code(), "其他支出单");
 
         //资金
         Double amount = banksubledgerMapper.selectThisamount(othspendings.getOs_bankcode());
@@ -192,6 +246,38 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
                     othspendings.getOs_bankcode(), "-");
         }
 
+        //资金账号表
+        int bk_id = othspendings.getOs_bankid();
+
+        Double bk_amount = othspendings.getOs_amount();
+        //付款方
+        Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
+        Double beginamount = bankinformation.getBk_beginamount();
+        Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
+        Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
+        bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
+        bankinformation.setBk_income(incomme);
+        bankinformation.setBk_spending(spending + bk_amount);
+
+        /**
+         * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
+         * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
+         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+         */
+        Vendor vendorData = paybalanceMapper.selectVendorByPrimaryKey(othspendings.getOs_vendid());
+        Double preamount = vendorData.getVe_preamount()==null?new Double(0):vendorData.getVe_preamount();
+        Double beginapamount = vendorData.getVe_beginapamount()==null?new Double(0):vendorData.getVe_beginapamount();
+        Double beginprepayamount= vendorData.getVe_beginprepayamount()==null?new Double(0):vendorData.getVe_beginprepayamount();
+        Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
+
+        Vendor vendor = new Vendor();
+        vendor.setId(Long.valueOf(othspendings.getOs_vendid()));
+        vendor.setVe_preamount(preamount);
+        vendor.setVe_payamount(payamount + bk_amount);
+        vendor.setVe_leftamount(beginapamount+beginprepayamount-payamount+bk_amount+preamount);
+        paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
+
+
         //计算期间金额
         Statsinfo statsinfo = new Statsinfo();
         List<Integer> ymList = othspendingsdetailMapper.selectYm(id);
@@ -209,7 +295,7 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
 
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.unAudit(baseDTO);
     }
 
     @Override
@@ -258,9 +344,13 @@ public class OthspendingsServiceImpl extends CommonBaseServiceImpl<OthspendingsM
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? othspendingsMapper.validateCodeWhenInsert(code, companyId) :
-                othspendingsMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.OTHSPENDINGS.getCaller()).getData();
+        String codeString = null;
+        synchronized(OthspendingsServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? othspendingsMapper.validateCodeWhenInsert(code, companyId) :
+                    othspendingsMapper.validateCodeWhenUpdate(code, id, companyId);
+            codeString = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.OTHSPENDINGS.getCaller()).getData();
+        }
+        return codeString;
     }
 
     private List<Othspendings> getListByMode(ListReqDTO req) {

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

@@ -3,6 +3,7 @@ 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.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -46,6 +47,9 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
     private StatsinfoMapper statsinfoMapper;
     @Autowired
     private MessageLogService messageLogService;
+//    @Autowired
+//    private CommonService commonService;
+
 
     public DocBaseDTO insert(Pay pay) {
         Paybalance paybalance = pay.getMain();
@@ -64,14 +68,21 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         //校验数据
         checkPaybalance(pay);
 
-        if (paybalance.getId() > 0){
+        DocBaseDTO baseDTO = new DocBaseDTO();
+
+        if (pbId > 0){
             paybalanceMapper.updateByPrimaryKeySelective(paybalance);
+            baseDTO = getBaseDTOById(pbId);
+            //日志记录
+            messageLogService.update(baseDTO);
         }else {
             paybalance.setCompanyId(BaseContextHolder.getCompanyId());
             paybalance.setPb_recorder(BaseContextHolder.getUserName());
             paybalanceMapper.insertSelective(paybalance);
             pbId = paybalance.getId();
-            System.out.println("rbid:" + pbId);
+            baseDTO = getBaseDTOById(pbId);
+            //日志记录
+            messageLogService.save(baseDTO);
         }
 
         Iterator isdet = paybalancedet.iterator();
@@ -99,9 +110,6 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
                 paybalancedetailMapper.insertSelective(paybalancedetail1);
             }
         }
-        DocBaseDTO baseDTO = getBaseDTOById(pbId);
-        //日志记录
-        messageLogService.save(baseDTO);
         return baseDTO;
     }
 
@@ -177,9 +185,9 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
     public DocBaseDTO audit(Pay pay) {
         Long companyId = BaseContextHolder.getCompanyId();
         Paybalance paybalance = pay.getMain();
+        paybalance.setCompanyId(companyId);
         paybalance.setPb_status(Status.AUDITED.getDisplay());
         paybalance.setPb_statuscode(Status.AUDITED.name());
-        paybalance.setCompanyId(companyId);
         Subledger subledger = this.changSubledgerUntil(paybalance);
         if (subledger.getSl_code() == null){
             subledgerMapper.insertSelective(subledger);
@@ -266,8 +274,11 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
             statsinfoMapper.update(statsinfo);
         }
         DocBaseDTO baseDTO = getBaseDTOById(id);
+//        commonService.commonAudit(BillCodeSeq.PAYBALANCE.getCaller(),
+//                "pb_id="+baseDTO.getId(),"pb_status","pb_statuscode",
+//                "pb_auditdate","pb_auditman");
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.audit(baseDTO);
         return baseDTO;
     }
 
@@ -350,17 +361,16 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         }
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.unAudit(baseDTO);
     }
 
-
     public void delete(int id){
         paybalanceMapper.deleteByPrimaryKey(id);
         paybalancedetailMapper.deleteByPrimaryKey(id);
         paybalancedetMapper.deleteByPrimaryKey(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.delete(baseDTO);
     }
 
     @Override
@@ -368,7 +378,7 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         paybalancedetMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     @Override
@@ -376,7 +386,7 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
         paybalancedetailMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     public Pay select(int id){
@@ -452,9 +462,13 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? paybalanceMapper.validateCodeWhenInsert(code, companyId) :
-                paybalanceMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PAYBALANCE.getCaller()).getData();
+        String codeString = null;
+        synchronized(PaybalanceServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? paybalanceMapper.validateCodeWhenInsert(code, companyId) :
+                    paybalanceMapper.validateCodeWhenUpdate(code, id, companyId);
+            codeString = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PAYBALANCE.getCaller()).getData();
+        }
+        return codeString;
     }
 
     private List<Paybalance> getListByMode(ListReqDTO req) {

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

@@ -3,6 +3,7 @@ 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.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -46,6 +47,8 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
     private StatsinfoMapper statsinfoMapper;
     @Autowired
     private MessageLogService messageLogService;
+    @Autowired
+    private CommonService commonService;
 
     @Override
     public DocBaseDTO insert(Rec rec) {
@@ -63,14 +66,22 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         //校验数据
         checkRecbalance(rec);
 
+        DocBaseDTO baseDTO = new DocBaseDTO();
         Long rbId = recbalance.getId();
         if (rbId > 0){
             recbalanceMapper.updateByPrimaryKeySelective(recbalance);
+            baseDTO = getBaseDTOById(rbId);
+            //日志记录
+            messageLogService.update(baseDTO);
         }else {
             recbalance.setCompanyId(BaseContextHolder.getCompanyId());
             recbalance.setRb_recorder(BaseContextHolder.getUserName());
             recbalanceMapper.insertSelective(recbalance);
             rbId = recbalance.getId();
+
+            baseDTO = getBaseDTOById(rbId);
+            //日志记录
+            messageLogService.save(baseDTO);
         }
 
         Iterator isdet = recbalancedet.iterator();
@@ -98,9 +109,6 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
                 recbalancedetailMapper.insertSelective(recbalancedetail1);
             }
         }
-        DocBaseDTO baseDTO = getBaseDTOById(rbId);
-        //日志记录
-        messageLogService.save(baseDTO);
         return baseDTO;
     }
 
@@ -178,7 +186,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         recbalancedetailMapper.deleteByPrimaryKey(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.delete(baseDTO);
     }
 
     @Override
@@ -198,7 +206,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         recbalancedetMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     @Override
@@ -206,16 +214,16 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         recbalancedetailMapper.deleteItem(id);
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.deleteDetail(baseDTO);
     }
 
     @Override
     public DocBaseDTO audit(Rec rec) {
         Long companyId = BaseContextHolder.getCompanyId();
         Recbalance recbalance = rec.getMain();
+        recbalance.setCompanyId(companyId);
         recbalance.setRb_status(Status.AUDITED.getDisplay());
         recbalance.setRb_statuscode(Status.AUDITED.name());
-        recbalance.setCompanyId(companyId);
         Subledger subledger = this.changSubledgerUntil(recbalance);
         if (subledger.getSl_code() == null){
             subledgerMapper.insertSelective(subledger);
@@ -248,7 +256,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         //更新主表pb_pbdamount=从表二金额合计
         Double amountTotal2 = new Double(0);
         for (Recbalancedetail detail : recbalancedetail){
-            amountTotal2 = amountTotal2 + detail.getRbd_amount();
+            amountTotal2 = amountTotal2 + detail.getRbd_nowbalance();
         }
         updateRay.setId(rec.getMain().getId());
         updateRay.setRb_rdamount(amountTotal);
@@ -303,8 +311,11 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             statsinfoMapper.update(statsinfo);
         }
         DocBaseDTO baseDTO = getBaseDTOById(id);
+//        commonService.commonAudit(BillCodeSeq.RECBALANCE.getCaller(),
+//                "rb_id="+baseDTO.getId(),"rb_status","rb_statuscode",
+//                "rb_auditdate","rb_auditman");
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.audit(baseDTO);
         return baseDTO;
     }
 
@@ -388,7 +399,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
         }
         DocBaseDTO baseDTO = getBaseDTOById(id);
         //日志记录
-        messageLogService.save(baseDTO);
+        messageLogService.unAudit(baseDTO);
     }
 
     public PageInfo<Recbalance> selectList(PageRequest page, ListReqDTO reqDTO) {
@@ -456,9 +467,13 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
         Long companyId = BaseContextHolder.getCompanyId();
-        Integer count = "0".equals(String.valueOf(id)) ? recbalanceMapper.validateCodeWhenInsert(code, companyId) :
-                recbalanceMapper.validateCodeWhenUpdate(code, id, companyId);
-        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.RECBALANCE.getCaller()).getData();
+        String codeString = null;
+        synchronized(RecbalanceServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? recbalanceMapper.validateCodeWhenInsert(code, companyId) :
+                    recbalanceMapper.validateCodeWhenUpdate(code, id, companyId);
+            codeString = maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.RECBALANCE.getCaller()).getData();
+        }
+        return codeString;
     }
 
     private List<Recbalance> getListByMode(ListReqDTO req) {
@@ -536,7 +551,7 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             banksubledger.setBl_date(recbalance.getRb_date());
 
             if (recbalance.getRb_custid() == null || recbalance.getRb_custid() != 0){
-                banksubledger.setBl_asstype("供应商往来");
+                banksubledger.setBl_asstype("客户往来");
             }
             banksubledger.setBl_assid(recbalance.getRb_custid());
             banksubledger.setBl_asscode(recbalance.getRb_custcode());

+ 351 - 0
applications/money/money-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -0,0 +1,351 @@
+<?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.BankinformationMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.money.po.Bankinformation" >
+    <id column="bk_id" property="id" jdbcType="INTEGER" />
+    <result column="bk_bankcode" property="bk_bankcode" jdbcType="VARCHAR" />
+    <result column="bk_bankname" property="bk_bankname" jdbcType="VARCHAR" />
+    <result column="bk_date" property="bk_date" jdbcType="TIMESTAMP" />
+    <result column="bk_type" property="bk_type" jdbcType="VARCHAR" />
+    <result column="bk_beginamount" property="bk_beginamount" jdbcType="DOUBLE" />
+    <result column="bk_thisamount" property="bk_thisamount" jdbcType="DOUBLE" />
+    <result column="bk_status" property="bk_status" jdbcType="VARCHAR" />
+    <result column="bk_statuscode" property="bk_statuscode" jdbcType="VARCHAR" />
+    <result column="bk_recorderid" property="bk_recorderid" jdbcType="INTEGER" />
+    <result column="bk_recorder" property="bk_recorder" jdbcType="VARCHAR" />
+    <result column="bk_recorddate" property="bk_recorddate" jdbcType="TIMESTAMP" />
+    <result column="bk_ym" property="bk_ym" jdbcType="INTEGER" />
+    <result column="companyid" property="companyId" jdbcType="INTEGER" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="bk_text1" property="bk_text1" jdbcType="VARCHAR" />
+    <result column="bk_text2" property="bk_text2" jdbcType="VARCHAR" />
+    <result column="bk_text3" property="bk_text3" jdbcType="VARCHAR" />
+    <result column="bk_text4" property="bk_text4" jdbcType="VARCHAR" />
+    <result column="bk_text5" property="bk_text5" jdbcType="VARCHAR" />
+    <result column="bk_remark" property="bk_remark" jdbcType="VARCHAR" />
+    <result column="bk_spending" property="bk_spending" jdbcType="DOUBLE" />
+    <result column="bk_income" property="bk_income" jdbcType="DOUBLE" />
+  </resultMap>
+  <resultMap id="ResultMapWithBLOBs" type="com.usoftchina.saas.money.po.Bankinformation" extends="BaseResultMap" >
+    <result column="bk_remark" property="bk_remark" jdbcType="LONGVARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    bk_id, bk_bankcode, bk_bankname, bk_date, bk_type, bk_beginamount, bk_thisamount, 
+    bk_status, bk_statuscode, bk_recorderid, bk_recorder, bk_recorddate, bk_ym, companyid, 
+    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_remark
+  </sql>
+  <sql id="Blob_Column_List" >
+    bk_remark
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
+    select 
+    <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
+    from bankinformation
+    where bk_id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+    delete from bankinformation
+    where bk_id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.saas.money.po.Bankinformation" >
+    insert into bankinformation (bk_id, bk_bankcode, bk_bankname, 
+      bk_date, bk_type, bk_beginamount, 
+      bk_thisamount, bk_status, bk_statuscode, 
+      bk_recorderid, bk_recorder, bk_recorddate, 
+      bk_ym, companyid, updaterId, 
+      updateTime, bk_text1, bk_text2, 
+      bk_text3, bk_text4, bk_text5, 
+      bk_remark)
+    values (#{bk_bankcode,jdbcType=VARCHAR}, #{bk_bankname,jdbcType=VARCHAR},
+      #{bk_date,jdbcType=TIMESTAMP}, #{bk_type,jdbcType=VARCHAR}, #{bk_beginamount,jdbcType=DOUBLE},
+      #{bk_thisamount,jdbcType=DOUBLE}, #{bk_status,jdbcType=VARCHAR}, #{bk_statuscode,jdbcType=VARCHAR},
+      #{bk_recorderid,jdbcType=INTEGER}, #{bk_recorder,jdbcType=VARCHAR}, #{bk_recorddate,jdbcType=TIMESTAMP},
+      #{bk_ym,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER},
+      #{updateTime,jdbcType=TIMESTAMP}, #{bk_text1,jdbcType=VARCHAR}, #{bk_text2,jdbcType=VARCHAR},
+      #{bk_text3,jdbcType=VARCHAR}, #{bk_text4,jdbcType=VARCHAR}, #{bk_text5,jdbcType=VARCHAR},
+      #{bk_remark,jdbcType=LONGVARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
+    insert into bankinformation
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="bk_bankcode != null" >
+        bk_bankcode,
+      </if>
+      <if test="bk_bankname != null" >
+        bk_bankname,
+      </if>
+      <if test="bk_date != null" >
+        bk_date,
+      </if>
+      <if test="bk_type != null" >
+        bk_type,
+      </if>
+      <if test="bk_beginamount != null" >
+        bk_beginamount,
+      </if>
+      <if test="bk_thisamount != null" >
+        bk_thisamount,
+      </if>
+      <if test="bk_status != null" >
+        bk_status,
+      </if>
+      <if test="bk_statuscode != null" >
+        bk_statuscode,
+      </if>
+      <if test="bk_recorderid != null" >
+        bk_recorderid,
+      </if>
+      <if test="bk_recorder != null" >
+        bk_recorder,
+      </if>
+      <if test="bk_recorddate != null" >
+        bk_recorddate,
+      </if>
+      <if test="bk_ym != null" >
+        bk_ym,
+      </if>
+      <if test="companyId != null" >
+        companyid,
+      </if>
+      <if test="updaterId != null" >
+        updaterId,
+      </if>
+      <if test="updateTime != null" >
+        updateTime,
+      </if>
+      <if test="bk_text1 != null" >
+        bk_text1,
+      </if>
+      <if test="bk_text2 != null" >
+        bk_text2,
+      </if>
+      <if test="bk_text3 != null" >
+        bk_text3,
+      </if>
+      <if test="bk_text4 != null" >
+        bk_text4,
+      </if>
+      <if test="bk_text5 != null" >
+        bk_text5,
+      </if>
+      <if test="bk_remark != null" >
+        bk_remark,
+      </if>
+      <if test="bk_spending != null" >
+        bk_spending,
+      </if>
+      <if test="bk_income != null" >
+        bk_income,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="bk_bankcode != null" >
+        #{bk_bankcode,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_bankname != null" >
+        #{bk_bankname,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_date != null" >
+        #{bk_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bk_type != null" >
+        #{bk_type,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_beginamount != null" >
+        #{bk_beginamount,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_thisamount != null" >
+        #{bk_thisamount,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_status != null" >
+        #{bk_status,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_statuscode != null" >
+        #{bk_statuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_recorderid != null" >
+        #{bk_recorderid,jdbcType=INTEGER},
+      </if>
+      <if test="bk_recorder != null" >
+        #{bk_recorder,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_recorddate != null" >
+        #{bk_recorddate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bk_ym != null" >
+        #{bk_ym,jdbcType=INTEGER},
+      </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="bk_text1 != null" >
+        #{bk_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text2 != null" >
+        #{bk_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text3 != null" >
+        #{bk_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text4 != null" >
+        #{bk_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text5 != null" >
+        #{bk_text5,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_remark != null" >
+        #{bk_remark,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="bk_spending != null" >
+        #{bk_spending,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_income != null" >
+        #{bk_income,jdbcType=DOUBLE},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
+    update bankinformation
+    <set >
+      <if test="bk_bankcode != null" >
+        bk_bankcode = #{bk_bankcode,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_bankname != null" >
+        bk_bankname = #{bk_bankname,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_date != null" >
+        bk_date = #{bk_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bk_type != null" >
+        bk_type = #{bk_type,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_beginamount != null" >
+        bk_beginamount = #{bk_beginamount,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_thisamount != null" >
+        bk_thisamount = #{bk_thisamount,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_status != null" >
+        bk_status = #{bk_status,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_statuscode != null" >
+        bk_statuscode = #{bk_statuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_recorderid != null" >
+        bk_recorderid = #{bk_recorderid,jdbcType=INTEGER},
+      </if>
+      <if test="bk_recorder != null" >
+        bk_recorder = #{bk_recorder,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_recorddate != null" >
+        bk_recorddate = #{bk_recorddate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bk_ym != null" >
+        bk_ym = #{bk_ym,jdbcType=INTEGER},
+      </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="bk_text1 != null" >
+        bk_text1 = #{bk_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text2 != null" >
+        bk_text2 = #{bk_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text3 != null" >
+        bk_text3 = #{bk_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text4 != null" >
+        bk_text4 = #{bk_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_text5 != null" >
+        bk_text5 = #{bk_text5,jdbcType=VARCHAR},
+      </if>
+      <if test="bk_remark != null" >
+        bk_remark = #{bk_remark,jdbcType=LONGVARCHAR},
+      </if>
+      <if test="bk_income != null" >
+        bk_income = #{bk_income,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_spending != null" >
+        bk_spending = #{bk_spending,jdbcType=DOUBLE},
+      </if>
+    </set>
+    where bk_id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoftchina.saas.money.po.Bankinformation" >
+    update bankinformation
+    set bk_bankcode = #{bkBankcode,jdbcType=VARCHAR},
+      bk_bankname = #{bkBankname,jdbcType=VARCHAR},
+      bk_date = #{bkDate,jdbcType=TIMESTAMP},
+      bk_type = #{bkType,jdbcType=VARCHAR},
+      bk_beginamount = #{bkBeginamount,jdbcType=DOUBLE},
+      bk_thisamount = #{bkThisamount,jdbcType=DOUBLE},
+      bk_status = #{bkStatus,jdbcType=VARCHAR},
+      bk_statuscode = #{bkStatuscode,jdbcType=VARCHAR},
+      bk_recorderid = #{bkRecorderid,jdbcType=INTEGER},
+      bk_recorder = #{bkRecorder,jdbcType=VARCHAR},
+      bk_recorddate = #{bkRecorddate,jdbcType=TIMESTAMP},
+      bk_ym = #{bkYm,jdbcType=INTEGER},
+      companyid = #{companyId,jdbcType=INTEGER},
+      updaterId = #{updaterId,jdbcType=INTEGER},
+      updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      bk_text1 = #{bkText1,jdbcType=VARCHAR},
+      bk_text2 = #{bkText2,jdbcType=VARCHAR},
+      bk_text3 = #{bkText3,jdbcType=VARCHAR},
+      bk_text4 = #{bkText4,jdbcType=VARCHAR},
+      bk_text5 = #{bkText5,jdbcType=VARCHAR},
+      bk_remark = #{bkRemark,jdbcType=LONGVARCHAR}
+    where bk_id = #{bkId,jdbcType=INTEGER}
+  </update>
+
+  <select id="selectAll" resultMap="BaseResultMap">
+    SELECT * FROM bankinformation
+  </select>
+
+  <select id="selectBankinformationBycondition" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from bankinformation
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="companyId != null">
+        and   bankinformation.companyId = #{companyId}
+      </if>
+    </where>  order by bk_id
+  </select>
+  <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>
+
+  <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_beginamount from bankinformation where bk_id = #{id,jdbcType=INTEGER}
+</select>
+</mapper>

+ 18 - 7
applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml

@@ -19,11 +19,19 @@
     <result column="ft_text3" property="ft_text3" jdbcType="VARCHAR" />
     <result column="ft_text4" property="ft_text4" jdbcType="VARCHAR" />
     <result column="ft_text5" property="ft_text5" jdbcType="VARCHAR" />
+    <result column="ftd_bankname" property="ftd_bankname" jdbcType="VARCHAR" />
+    <result column="ftd_inbankname" property="ftd_inbankname" jdbcType="VARCHAR" />
+    <result column="ftd_nowbalance" property="ftd_nowbalance" jdbcType="DOUBLE" />
+    <result column="ftd_paymethod" property="ftd_paymethod" jdbcType="VARCHAR" />
+    <result column="ftd_paycode" property="ftd_paycode" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     ft_id, ft_code, ft_date, ft_recorderid, ft_recorder, ft_recorddate, ft_status, ft_statuscode, 
-    ft_remark, companyId, updaterId, updatedate, ft_text1, ft_text2, ft_text3, ft_text4, 
-    ft_text5
+    ft_remark, fundtransfer.companyId, fundtransfer.updaterId, fundtransfer.updatedate,
+    ft_text1, ft_text2, ft_text3, ft_text4, ft_text5
+  </sql>
+  <sql id="Detail_Column_List" >
+    ftd_bankname,ftd_inbankname,ftd_nowbalance,ftd_paymethod,ftd_paycode
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
@@ -232,8 +240,10 @@
 
   <select id="selectFundtransferBycondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from Fundtransfer
+    <include refid="Base_Column_List" />,
+    <include refid="Detail_Column_List" />
+    from Fundtransfer left join fundtransferdetail on ftd_ftid=ft_id and
+    Fundtransfer.companyId= fundtransferdetail.companyId
     <where>
       <if test="con != null">
         ${con}
@@ -246,9 +256,10 @@
 
   <select id="selectFundtransferListByCondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from fundtransfer
-    left join fundtransferdetail on ft_id=ftd_ftid
+    <include refid="Base_Column_List" />,
+    <include refid="Detail_Column_List" />
+    from Fundtransfer left join fundtransferdetail on ftd_ftid=ft_id and
+    Fundtransfer.companyId= fundtransferdetail.companyId
     <where>
       <if test="con != null">
         ${con}

+ 14 - 8
applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml

@@ -26,12 +26,18 @@
     <result column="or_text3" property="or_text3" jdbcType="VARCHAR" />
     <result column="or_text4" property="or_text4" jdbcType="VARCHAR" />
     <result column="or_text5" property="or_text5" jdbcType="VARCHAR" />
+    <result column="ord_type" property="ord_type" jdbcType="VARCHAR" />
+    <result column="ord_nowbalance" property="ord_nowbalance" jdbcType="DOUBLE" />
+    <result column="ord_remark" property="ord_remark" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     or_id, or_code, or_date, or_custid, or_custcode, or_custname, or_bankcode, or_bankid, 
     or_bankname, or_amount, or_recorderid, or_recorder, or_recorddate, or_status, or_statuscode, 
-    or_remark, companyId, updaterId, updatedate, or_text1, or_text2, or_text3, or_text4, 
-    or_text5
+    or_remark, Othreceipts.companyId, Othreceipts.updaterId, Othreceipts.updatedate, or_text1,
+    or_text2, or_text3, or_text4, or_text5
+  </sql>
+  <sql id="Detail_Column_List" >
+    ord_type,ord_nowbalance,ord_remark
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
@@ -314,11 +320,11 @@
   <select id="validateCodeWhenUpdate" resultType="int" >
     select count(1) from othreceipts where or_code = #{code} and or_id != #{id} and companyId =#{companyId}
   </select>
-
   <select id="selectOthreceiptsBycondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from Othreceipts
+    <include refid="Base_Column_List" />,
+    <include refid="Detail_Column_List" />
+    from Othreceipts left join othreceiptsdetail on ord_orid=or_id and Othreceipts.companyId=othreceiptsdetail.companyId
     <where>
       <if test="con != null">
         ${con}
@@ -331,9 +337,9 @@
 
   <select id="selectOthreceiptsListByCondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from Othreceipts
-    left join othreceiptsdetail on or_id=ord_orid 
+    <include refid="Base_Column_List" />,
+    <include refid="Detail_Column_List" />
+    from Othreceipts left join othreceiptsdetail on ord_orid=or_id and Othreceipts.companyId=othreceiptsdetail.companyId
     <where>
       <if test="con != null">
         ${con}

+ 16 - 6
applications/money/money-server/src/main/resources/mapper/OthspendingsMapper.xml

@@ -26,13 +26,20 @@
     <result column="os_text3" property="os_text3" jdbcType="VARCHAR" />
     <result column="os_text4" property="os_text4" jdbcType="VARCHAR" />
     <result column="os_text5" property="os_text5" jdbcType="VARCHAR" />
+    <result column="osd_type" property="osd_type" jdbcType="VARCHAR" />
+    <result column="osd_nowbalance" property="osd_nowbalance" jdbcType="DOUBLE" />
+    <result column="osd_remark" property="osd_remark" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     os_id, os_code, os_date, os_vendid, os_vendcode, os_vendname, os_bankid, os_bankcode, 
     os_bankname, os_amount, os_recorderid, os_recorder, os_recorddate, os_status, os_statuscode, 
-    os_remark, companyId, updaterId, updatedate, os_text1, os_text2, os_text3, os_text4, 
+    os_remark, othspendings.companyId, othspendings.updaterId,
+    othspendings.updatedate, os_text1, os_text2, os_text3, os_text4,
     os_text5
   </sql>
+  <sql id="Detail_Column_List" >
+    osd_type,osd_nowbalance,osd_remark
+  </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
     <include refid="Base_Column_List" />
@@ -312,8 +319,10 @@
 
   <select id="selectOthspendingsBycondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from Othspendings
+    <include refid="Base_Column_List" />,
+    <include refid="Detail_Column_List" />
+    from Othspendings left join othspendingsdetail on osd_osid=os_id
+    and Othspendings.companyId=othspendingsdetail.companyId
     <where>
       <if test="con != null">
         ${con}
@@ -326,9 +335,10 @@
 
   <select id="selectOthspendingsListByCondition" resultMap="BaseResultMap">
     select
-    <include refid="Base_Column_List" />
-    from Othspendings
-    left join othspendingsdetail on os_id=osd_orid
+    <include refid="Base_Column_List" />,
+    <include refid="Detail_Column_List" />
+    from Othspendings left join othspendingsdetail on osd_osid=os_id
+    and Othspendings.companyId=othspendingsdetail.companyId
     <where>
       <if test="con != null">
         ${con}

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

@@ -3,7 +3,7 @@
 <mapper namespace="com.usoftchina.saas.money.mapper.OthspendingsdetailMapper" >
   <resultMap id="BaseResultMap" type="com.usoftchina.saas.money.po.Othspendingsdetail" >
     <id column="osd_id" property="id" jdbcType="INTEGER" />
-    <result column="osd_orid" property="osd_orid" jdbcType="INTEGER" />
+    <result column="osd_osid" property="osd_osid" jdbcType="INTEGER" />
     <result column="osd_detno" property="osd_detno" jdbcType="INTEGER" />
     <result column="osd_ym" property="osd_ym" jdbcType="INTEGER" />
     <result column="os_date" property="os_date" jdbcType="TIMESTAMP" />
@@ -20,18 +20,18 @@
     <result column="osd_text5" property="osd_text5" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
-    osd_id, osd_orid, osd_detno, osd_ym, osd_type, osd_nowbalance, osd_remark, companyId, 
+    osd_id, osd_osid, osd_detno, osd_ym, osd_type, osd_nowbalance, osd_remark, companyId,
     updaterId, updatedate, osd_text1, osd_text2, osd_text3, osd_text4, osd_text5
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
     <include refid="Base_Column_List" />
     from othspendingsdetail
-    where osd_orid = #{id,jdbcType=INTEGER}
+    where osd_osid = #{id,jdbcType=INTEGER}
   </select>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
     delete from othspendingsdetail
-    where osd_orid = #{id,jdbcType=INTEGER}
+    where osd_osid = #{id,jdbcType=INTEGER}
   </delete>
 
   <delete id="deleteItem" parameterType="java.lang.Integer" >
@@ -40,7 +40,7 @@
   </delete>
 
   <insert id="insert" parameterType="com.usoftchina.saas.money.po.Othspendingsdetail" >
-    insert into othspendingsdetail (osd_orid, osd_detno,
+    insert into othspendingsdetail (osd_osid, osd_detno,
       osd_ym, osd_type, osd_nowbalance, 
       osd_remark, companyId, updaterId, 
       updatedate, osd_text1, osd_text2, 
@@ -56,8 +56,8 @@
   <insert id="insertSelective" parameterType="com.usoftchina.saas.money.po.Othspendingsdetail" >
     insert into othspendingsdetail
     <trim prefix="(" suffix=")" suffixOverrides="," >
-      <if test="osd_orid != null" >
-        osd_orid,
+      <if test="osd_osid != null" >
+        osd_osid,
       </if>
       <if test="osd_detno != null" >
         osd_detno,
@@ -100,8 +100,8 @@
       </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
-      <if test="osd_orid != null" >
-        #{osd_orid,jdbcType=INTEGER},
+      <if test="osd_osid != null" >
+        #{osd_osid,jdbcType=INTEGER},
       </if>
       <if test="osd_detno != null" >
         #{osd_detno,jdbcType=INTEGER},
@@ -150,8 +150,8 @@
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.money.po.Othspendingsdetail" >
     update othspendingsdetail
     <set >
-      <if test="osd_orid != null" >
-        osd_orid = #{osd_orid,jdbcType=INTEGER},
+      <if test="osd_osid != null" >
+        osd_osid = #{osd_osid,jdbcType=INTEGER},
       </if>
       <if test="osd_detno != null" >
         osd_detno = #{osd_detno,jdbcType=INTEGER},
@@ -197,7 +197,7 @@
   </update>
   <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.money.po.Othspendingsdetail" >
     update othspendingsdetail
-    set osd_orid = #{osdOrid,jdbcType=INTEGER},
+    set osd_osid = #{osdOrid,jdbcType=INTEGER},
       osd_detno = #{osdDetno,jdbcType=INTEGER},
       osd_ym = #{osdYm,jdbcType=INTEGER},
       osd_type = #{osdType,jdbcType=VARCHAR},
@@ -215,6 +215,6 @@
   </update>
 
   <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
-    select osd_ym from othspendingsdetail where osd_orid = #{id,jdbcType=INTEGER}
+    select osd_ym from othspendingsdetail where osd_osid = #{id,jdbcType=INTEGER}
   </select>
 </mapper>

+ 23 - 6
applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml

@@ -30,6 +30,16 @@
     <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="pd_amount" jdbcType="DOUBLE" property="pd_amount" />
+    <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 +108,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 +433,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}
@@ -433,9 +449,10 @@
 
   <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}
@@ -588,7 +605,7 @@
   </update>
 
 <select id="selectThisamount" parameterType="java.lang.Integer" resultType="java.lang.Double">
-  select bk_thisamount from bankinformation where bk_id = #{id,jdbcType=INTEGER}
+  select bk_beginamount from bankinformation where bk_id = #{id,jdbcType=INTEGER}
 </select>
 
 <!-- 供应商-->

+ 23 - 5
applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml

@@ -30,6 +30,16 @@
     <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_amount" jdbcType="DOUBLE" property="rd_amount" />
+    <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 +108,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 +137,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}
@@ -136,9 +153,10 @@
 
   <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}

+ 0 - 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>

+ 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>

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

@@ -44,7 +44,7 @@
                 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
+                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_osid
                 where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
                 and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
             </if>
@@ -76,7 +76,7 @@
             </if>
             <if test="si_amount_otherpay != null" >
                 si_amount_otherpay =
-                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
+                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_osid
                 where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
                 and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
             </if>

+ 2 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/ProdInOutDTO.java

@@ -73,4 +73,6 @@ public class ProdInOutDTO extends CommonBaseDTO implements Serializable {
 
     private String pi_remark;
 
+    private Long pi_ioid;
+
 }

+ 5 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseDTO.java

@@ -64,4 +64,9 @@ public class PurchaseDTO extends CommonBaseDTO implements Serializable{
     private String pu_text5;
 
     private String pu_shipaddresscode;
+
+    private String pu_auditman;
+
+    private Date pu_auditdate;
+
 }

+ 2 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseDetailDTO.java

@@ -60,6 +60,8 @@ public class PurchaseDetailDTO extends CommonBaseDTO implements Serializable{
 
     private Double pd_yqty;
 
+    private String pd_remark;
+
     private ProductDTO productDTO;
 
 }

+ 1 - 0
applications/purchase/purchase-dto/src/main/java/com/usoftchina/saas/purchase/dto/PurchaseListDTO.java

@@ -116,4 +116,5 @@ public class PurchaseListDTO extends CommonBaseDTO implements Serializable {
 
     private Double pd_yqty;
 
+    private String pd_remark;
 }

+ 1 - 5
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java

@@ -17,15 +17,11 @@ public interface ProdIODetailMapper extends CommonBaseMapper<ProdIODetail> {
 
     int updateByPrimaryKeySelective(ProdIODetail record);
 
-    int updateByPrimaryKeyWithBLOBs(ProdIODetail record);
-
-    int updateByPrimaryKey(ProdIODetail record);
-
     void batchInsert(List<ProdIODetail> list);
 
     void batchUpdate(List<ProdIODetail> list);
 
-    void updatePurchaseYqty(Integer id);
+    void updatePurchaseYqty(Long id);
 
     List<ProdIODetail> selectByFK(Long id);
 

+ 0 - 4
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdInOutMapper.java

@@ -15,10 +15,6 @@ public interface ProdInOutMapper extends CommonBaseMapper<ProdInOut> {
 
     int updateByPrimaryKeySelective(ProdInOut record);
 
-    int updateByPrimaryKeyWithBLOBs(ProdInOut record);
-
-    int updateByPrimaryKey(ProdInOut record);
-
     Integer validateCodeWhenInsert(@Param("pi_inoutno") String pi_inoutno, @Param("companyId") Long companyId);
 
     Integer validateCodeWhenUpdate(@Param("pi_inoutno") String pi_inoutno, @Param("id") Long id,@Param("companyId") Long companyId);

+ 4 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/PurchaseMapper.java

@@ -14,6 +14,8 @@ public interface PurchaseMapper extends CommonBaseMapper<Purchase>{
 
     Purchase selectByPrimaryKey(Long id);
 
+    int updateByPrimaryKeySelective(Purchase record);
+
     String validateAudit(List<DocBaseDTO> list);
 
     String validateUnAudit(Long id);
@@ -28,4 +30,6 @@ public interface PurchaseMapper extends CommonBaseMapper<Purchase>{
     String selectCodeById(Long id);
 
     Integer checkTurnInstatus(Long id);
+
+    void updateCreator(@Param("userId") Long userId,@Param("userName") String userName,@Param("id") Long pu_id);
 }

+ 2 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/ProdInOut.java

@@ -68,4 +68,6 @@ public class ProdInOut extends CommonBaseEntity implements Serializable {
 
     private String pi_remark;
 
+    private Long pi_ioid;
+
 }

+ 4 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/Purchase.java

@@ -2,7 +2,6 @@ package com.usoftchina.saas.purchase.po;
 
 import com.usoftchina.saas.base.entity.CommonBaseEntity;
 import lombok.Data;
-import lombok.ToString;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -60,4 +59,8 @@ public class Purchase extends CommonBaseEntity implements Serializable {
 
     private String pu_shipaddresscode;
 
+    private String pu_auditman;
+
+    private Date pu_auditdate;
+
 }

+ 2 - 0
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/PurchaseDetail.java

@@ -56,5 +56,7 @@ public class PurchaseDetail extends CommonBaseEntity implements Serializable {
 
     private Double pd_yqty;
 
+    private  String pd_remark;
+
     private ProductDTO productDTO;
 }

+ 6 - 2
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/PurchaseList.java

@@ -2,7 +2,6 @@ package com.usoftchina.saas.purchase.po;
 
 
 import com.usoftchina.saas.base.entity.CommonBaseEntity;
-import com.usoftchina.saas.document.dto.ProductDTO;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -36,7 +35,6 @@ public class PurchaseList extends CommonBaseEntity implements Serializable {
 
     private Date pu_delivery;
 
-
     private Double pu_taxtotal;
 
     private Double pu_total;
@@ -69,6 +67,10 @@ public class PurchaseList extends CommonBaseEntity implements Serializable {
 
     private String pu_shipaddresscode;
 
+    private Date pu_auditdate;
+
+    private String pu_auditman;
+
     //从表字段
     private Long pd_id;
 
@@ -118,6 +120,8 @@ public class PurchaseList extends CommonBaseEntity implements Serializable {
 
     private Double pd_yqty;
 
+    private String pd_remark;
+
     //private ProductDTO productDTO;
     private Long pr_id;
     private String pr_code;

+ 3 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/po/report/PurchasePay.java

@@ -1,7 +1,9 @@
 package com.usoftchina.saas.purchase.po.report;
 
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -9,7 +11,7 @@ import java.util.Date;
  * @create: 2018-11-09 14:22
  **/
 @Data
-public class PurchasePay {
+public class PurchasePay  extends CommonBaseEntity implements Serializable {
     private Integer pb_id;
 
     private String pb_code;

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

@@ -14,7 +14,6 @@ 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;
@@ -30,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;
 
@@ -54,9 +54,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     private ProdInOutListMapper prodInOutListMapper;
     @Autowired
     private WarehouseApi warehouseApi;
-    @Autowired
-    private EmployeeApi employeeApi;
-
     @Autowired
     private MaxnumberService maxnumberService;
 
@@ -112,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(BizExceptionCode.EMPTY_DATA);
@@ -120,8 +117,8 @@ 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();
+        String userName = BaseContextHolder.getUserName();
 
         //获取主表信息
         ProdInOutDTO main = formdata.getMain();
@@ -130,28 +127,23 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         List<ProdIODetail> insertDetails = new ArrayList<>();
         //更新从表数据
         List<ProdIODetail> updateDetails = new ArrayList<>();
-        DocBaseDTO baseDTO = new DocBaseDTO();
         Long pi_id = main.getId();
         String pi_inoutno = main.getPi_inoutno();
         String pi_class = main.getPi_class();
         ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
-        prodInOut.setCompanyId(companyId);
-        prodInOut.setPi_recordmanid(userId.intValue());
-        prodInOut.setPi_recordman(emp.get("em_name").toString());
-        prodInOut.setCreatorId(userId);
-        prodInOut.setCreateTime(new Date());
-        prodInOut.setPi_date(new Date());
-        prodInOut.setPi_puid(main.getPi_puid());
-        prodInOut.setPi_pucode(main.getPi_pucode());
+
+        //编号获取
+        DocBaseDTO baseDTO = new DocBaseDTO();
         baseDTO.setCode(pi_inoutno);
         baseDTO.setId(pi_id);
         baseDTO.setName(pi_class);
-        //编号获取
         pi_inoutno = pushMaxnubmer(baseDTO);
         prodInOut.setPi_inoutno(pi_inoutno);
 
         //判断更新与保存动作
         if (StringUtils.isEmpty(pi_id) || "0".equals(pi_id.toString())){
+            prodInOut.setCompanyId(companyId);
+            //setCreateInfo(prodInOut);
             //插入操作
             getMapper().insertSelective(prodInOut);
             pi_id = prodInOut.getId();
@@ -177,19 +169,25 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             //日志记录
             messageLogService.save(baseDTO);
             return baseDTO;
+        }else{
+            //setUpdateInfo(prodInOut);
         }
         //更新操作
         getMapper().updateByPrimaryKeySelective(prodInOut);
         //添加从表传输对象
         for (ProdIODetailDTO item : items) {
             ProdIODetail detail = BeanMapper.map(item, ProdIODetail.class);
-            detail.setPd_piid(pi_id);
-            detail.setPd_inoutno(pi_inoutno);
-            detail.setPd_piclass(prodInOut.getPi_class());
-            detail.setCompanyId(companyId);
-            detail.setCreatorId(userId);
-            detail.setCreateTime(new Date());
+            detail.setUpdaterId(userId);
+            detail.setUpdateTime(new Date());
+//            detail.setUpdater(userName);
             if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
+                detail.setCompanyId(companyId);
+                detail.setCreatorId(userId);
+                detail.setCreateTime(new Date());
+
+                detail.setPd_piid(pi_id);
+                detail.setPd_inoutno(pi_inoutno);
+                detail.setPd_piclass(prodInOut.getPi_class());
                 insertDetails.add(detail);
             } else {
                 updateDetails.add(detail);
@@ -217,7 +215,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         updateYqty(prodInOut);
         //日志记录
         messageLogService.update(baseDTO);
-        messageLogService.customizeLog(baseDTO, Operation.TURNPURCCHECKOUT);
         return baseDTO;
     }
 
@@ -228,7 +225,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);;
             //删除主键
@@ -244,13 +242,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();
             }
@@ -260,7 +257,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();
@@ -408,7 +406,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if ("采购验收单".equals(prodInOut.getPi_class())){
             purchasedetailMapper.updatePurchaseYqty(prodInOut.getPi_puid());
         }else if ("采购验退单".equals(prodInOut.getPi_class())){
-            prodIODetailMapper.updatePurchaseYqty(prodInOut.getPi_puid());
+            prodIODetailMapper.updatePurchaseYqty(prodInOut.getPi_ioid());
         }
     }
 
@@ -417,6 +415,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         ProdInOut sourcePi = getMapper().selectByPrimaryKey(id);
         Integer count=0;
         double pdInqty=0, pdYqty=0;
+        Long userId = BaseContextHolder.getUserId();
+        String userName = BaseContextHolder.getUserName();
         List<ProdIODetail> sourcePids =prodIODetailMapper.selectByFK(id);
         //检查从表
         for (ProdIODetail prodIODetail : sourcePids) {
@@ -445,9 +445,15 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         targetPi.setPi_vendname(sourcePi.getPi_vendname());
         targetPi.setPi_puid(sourcePi.getPi_puid());
         targetPi.setPi_pucode(sourcePi.getPi_pucode());
+        targetPi.setPi_ioid(sourcePi.getId());
         //设置公司id
         targetPi.setCompanyId(sourcePi.getCompanyId());
         targetPi.setCreateTime(new Date());
+        targetPi.setCreatorId(userId);
+//        targetPi.setCreator(userName);
+        targetPi.setUpdaterId(userId);
+//        targetPi.setUpdater(userName);
+        targetPi.setUpdateTime(new Date());
 
         //保存数据
         getMapper().insertSelective(targetPi);
@@ -480,7 +486,11 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
                  //公司id
                  targetPid.setCompanyId(sourcePid.getCompanyId());
                  targetPid.setCreateTime(new Date());
-
+                 targetPid.setCreatorId(userId);
+//                 targetPid.setCreator(userName);
+                 targetPid.setUpdaterId(userId);
+//                 targetPid.setUpdater(userName);
+                 targetPid.setUpdateTime(new Date());
                  //本次转单数
                  targetPid.setPd_outqty(pdInqty-pdYqty);
                  prodIODetailMapper.insertSelective(targetPid);
@@ -493,10 +503,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
 //        getDefaultWarehouseByProduct(pi_id);
         //采购验退单相关计算
         calcProdInout(pi_id,"采购验退单");
-        DocBaseDTO baseDTO = new DocBaseDTO();
-        baseDTO.setId(pi_id);
-        baseDTO.setCode(piInoutno);
-        baseDTO.setName("采购验退单");
+        DocBaseDTO baseDTO = new DocBaseDTO(pi_id, piInoutno, BillCodeSeq.PURCHASEOUT.getName());
+        messageLogService.customizeLog(baseDTO, Operation.PURCHASEOUT);
         return Result.success(baseDTO);
     }
 
@@ -509,6 +517,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             }
             prodInOut.setPi_statuscode(Status.CLOSE.name());
             prodInOut.setPi_status(Status.CLOSE.getDisplay());
+            //setUpdateInfo(prodInOut);
             getMapper().updateByPrimaryKeySelective(prodInOut);
             docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class(),prodInOut.getPi_inoutno());
             //日志
@@ -543,6 +552,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             }
             prodInOut.setPi_statuscode(Status.OPEN.name());
             prodInOut.setPi_status(Status.OPEN.getDisplay());
+            //setUpdateInfo(prodInOut);
             getMapper().updateByPrimaryKeySelective(prodInOut);
             docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class(),prodInOut.getPi_inoutno());
             //日志
@@ -604,7 +614,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         return pushMaxnubmer(base);
     }
 
-    public synchronized String pushMaxnubmer(DocBaseDTO baseDTO) {
+    public String pushMaxnubmer(DocBaseDTO baseDTO) {
         String pi_inoutno = baseDTO.getCode();
         String pi_class = baseDTO.getName();
         Long id = baseDTO.getId();
@@ -612,14 +622,18 @@ 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.PURCHASEIN.getCaller();
-        }else if("采购验退单".equals(pi_class)) {
-            caller = BillCodeSeq.PURCHASEOUT.getCaller();
-        }
-        return maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
+        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;
     }
 }

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

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.commons.api.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -11,9 +12,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.ProductApi;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.exception.ExceptionCode;
@@ -34,7 +35,6 @@ import org.springframework.util.StringUtils;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 
 /**
@@ -53,8 +53,6 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     @Autowired
     private ProductApi productApi;
     @Autowired
-    private EmployeeApi employeeApi;
-    @Autowired
     private MaxnumberService maxnumberService;
     @Autowired
     private ProdInOutMapper prodInOutMapper;
@@ -64,7 +62,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     private MessageLogService messageLogService;
     @Autowired
     private ProdInOutService prodInOutService;
-
+    @Autowired
+    private CommonService commonService;
 
 
     @Override
@@ -111,11 +110,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
         Long userId = BaseContextHolder.getUserId();
-
-
-        Map<String,Object> emp = employeeApi.getEmployeeByAccount();
-
-
+        //人员名称
+        String userName = BaseContextHolder.getUserName();
         //获取主表信息
         PurchaseDTO main = formdata.getMain();
         List<PurchaseDetailDTO> items = formdata.getItems();
@@ -128,9 +124,6 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         Long pu_id = main.getId();
         String pu_code = main.getPu_code();
         Purchase purchase = BeanMapper.map(main, Purchase.class);
-        purchase.setCompanyId(companyId);
-        purchase.setCreatorId(userId);
-        purchase.setCreateTime(new Date());
 
         //编号校验
         pu_code = pushMaxnubmer(pu_code, pu_id);
@@ -138,9 +131,12 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         purchase.setPu_code(pu_code);
         //判断更新与保存动作
         if (StringUtils.isEmpty(pu_id) || "0".equals(pu_id.toString())) {
+            purchase.setCompanyId(companyId);
             //插入操作
             purchaseMapper.insertSelective(purchase);
             pu_id = purchase.getId();
+            //录入人
+            purchaseMapper.updateCreator(userId, userName, pu_id);
             //添加从表传输对象
             for (PurchaseDetailDTO item : items) {
                 PurchaseDetail detail = BeanMapper.map(item, PurchaseDetail.class);
@@ -151,6 +147,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
                 detail.setCompanyId(companyId);
                 detail.setCreatorId(userId);
                 detail.setCreateTime(new Date());
+                detail.setCreatorId(userId);
+                detail.setUpdateTime(new Date());
                 insertDetails.add(detail);
             }
             //插入从表
@@ -163,6 +161,8 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
             //日志记录
             messageLogService.save(baseDTO);
             return baseDTO;
+        }else{
+           // setUpdateInfo(purchase);
         }
         //更新操作
         purchaseMapper.updateByPrimaryKeySelective(purchase);
@@ -171,10 +171,13 @@ 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.setCompanyId(companyId);
-            detail.setCreatorId(userId);
-            detail.setCreateTime(new Date());
+            detail.setPd_delivery(item.getPd_delivery()==null?purchase.getPu_delivery():item.getPd_delivery());
+            detail.setUpdaterId(userId);
+            detail.setUpdateTime(new Date());
             if (StringUtils.isEmpty(detail.getId()) || "0".equals(detail.getId().toString())) {
+                detail.setCompanyId(companyId);
+                detail.setCreatorId(userId);
+                detail.setCreateTime(new Date());
                 insertDetails.add(detail);
             } else {
                 updateDetails.add(detail);
@@ -310,6 +313,10 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         purchase.setId(id);
         purchase.setPu_acceptstatuscode(Status.CLOSE.name());
         purchase.setPu_acceptstatus(Status.CLOSE.getDisplay());
+        //更新更新人信息
+//        purchase.setUpdater(BaseContextHolder.getUserName());
+        purchase.setUpdaterId(BaseContextHolder.getUserId());
+        purchase.setUpdateTime(new Date());
         purchaseMapper.updateByPrimaryKeySelective(purchase);
         DocBaseDTO docBaseDTO = getBaseDTOById(id);
         //日志
@@ -338,7 +345,6 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         Purchase purchase = purchaseMapper.selectByPrimaryKey(id);
         DocBaseDTO docBaseDTO = null;
         Double acceptqty=new Double(0),qty=new Double(0);
-
         if(!Status.CLOSE.name().equals(purchase.getPu_acceptstatuscode())){
             throw new BizException(BizExceptionCode.BIZ_OPEN);
         }
@@ -370,6 +376,10 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
                 purchase.setPu_acceptstatus(Status.TURNIN.getDisplay());
                 purchase.setPu_acceptstatuscode(Status.TURNIN.name());
             }
+            //更新更新人信息
+//            purchase.setUpdater(BaseContextHolder.getUserName());
+            purchase.setUpdaterId(BaseContextHolder.getUserId());
+            purchase.setUpdateTime(new Date());
             purchaseMapper.updateByPrimaryKeySelective(purchase);
             docBaseDTO = getBaseDTOById(id);
             //日志
@@ -391,9 +401,9 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
         Long userId = BaseContextHolder.getUserId();
-
+        //人员名
+        String userName = BaseContextHolder.getUserName();
         Purchase purchase = getMapper().selectByPrimaryKey(id);
-
         Integer count=0;
         double pdQty=0, pdYqty=0;
         //检查转单状态
@@ -402,9 +412,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         if ("CLOSED".equals(acceptstatus)){
             return Result.error(ExceptionCode.CLOSED_EXIST);
         }
-
         List<PurchaseDetail> purchaseDetails = purchasedetailMapper.selectByFK(id);
-
         //检查从表
         for (PurchaseDetail purchaseDetail : purchaseDetails) {
             pdQty = purchaseDetail.getPd_qty()==null?0:purchaseDetail.getPd_qty();
@@ -432,15 +440,15 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         prodInOut.setPi_vendname(purchase.getPu_vendname());
         prodInOut.setPi_puid(purchase.getId().intValue());
         prodInOut.setPi_pucode(purchase.getPu_code());
-        prodInOut.setCompanyId(purchase.getCompanyId());
-        prodInOut.setCreateTime(new Date());
-
-
         //设置公司id
         prodInOut.setCompanyId(purchase.getCompanyId());
-
+        prodInOut.setCreatorId(userId);
+        prodInOut.setCreateTime(new Date());
+//        prodInOut.setCreator(userName);
+        prodInOut.setUpdaterId(userId);
+//        prodInOut.setUpdater(userName);
+        prodInOut.setUpdateTime(new Date());
         prodInOutMapper.insertSelective(prodInOut);
-
         //插入验收单从表
         long pi_id = prodInOut.getId();
 
@@ -464,7 +472,12 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
                 prodIODetail.setPd_taxrate(purchaseDetail.getPd_taxrate());
                 //公司id
                 prodIODetail.setCompanyId(purchaseDetail.getCompanyId());
+                prodIODetail.setCreatorId(userId);
                 prodIODetail.setCreateTime(new Date());
+//                prodIODetail.setCreator(userName);
+                prodIODetail.setUpdaterId(userId);
+                prodIODetail.setUpdateTime(new Date());
+//                prodIODetail.setUpdater(userName);
                 //本次转单数
                 prodIODetail.setPd_inqty(pdQty-pdYqty);
                 prodIODetailMapper.insertSelective(prodIODetail);
@@ -474,14 +487,11 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
             }
         }
         //更新默认仓库
-        prodInOutService.getDefaultWarehouseByProduct(pi_id);
-
+//        prodInOutService.getDefaultWarehouseByProduct(pi_id);
         //采购验收单相关计算
         prodInOutService.calcProdInout(pi_id,"采购验收单");
-        DocBaseDTO baseDTO = new DocBaseDTO();
-        baseDTO.setId(pi_id);
-        baseDTO.setCode(piInoutno);
-        baseDTO.setName("采购验收单");
+        DocBaseDTO baseDTO = new DocBaseDTO(pi_id, piInoutno, BillCodeSeq.PURCHASEIN.getName());
+        messageLogService.customizeLog(baseDTO, Operation.PURCHASEIN);
         return Result.success(baseDTO);
     }
 
@@ -491,19 +501,16 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         Result result = Result.success(docBaseDTO);
         //检查最小包装数
         result.setMessage(purchasedetailMapper.checkzxbzs(id));
+        commonService.commonAudit("purchase", "pu_id=" + id, "pu_status",
+                "pu_statuscode", "pu_auditdate", "pu_auditman");
         Purchase purchase = new Purchase();
         //生成更新对象
         purchase.setId(id);
-        purchase.setPu_status(Status.AUDITED.getDisplay());
-        purchase.setPu_statuscode(Status.AUDITED.name());
         purchase.setPu_acceptstatus(Status.UNTURNIN.getDisplay());
         purchase.setPu_acceptstatuscode(Status.UNAUDITED.name());
         purchase.setUpdateTime(new Date());
         purchase.setUpdaterId(BaseContextHolder.getUserId());
         //更新存在字段
-        purchaseMapper.updateByPrimaryKeySelective(purchase);
-        //更新最新采购单价
-//        productApi.updateLatestPurchasePrice(id);
         //日志
         messageLogService.audit(docBaseDTO);
         return result;
@@ -521,8 +528,7 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
         purchase.setId(id);
         purchase.setPu_status(Status.UNAUDITED.getDisplay());
         purchase.setPu_statuscode(Status.UNAUDITED.name());
-        purchase.setUpdateTime(new Date());
-        purchase.setUpdaterId(BaseContextHolder.getUserId());
+        //setUpdateInfo(purchase);
         //更新存在字段
         purchaseMapper.updateByPrimaryKeySelective(purchase);
         DocBaseDTO docBaseDTO = getBaseDTOById(id);
@@ -565,14 +571,18 @@ public class PurchaseServiceImpl extends CommonBaseServiceImpl<PurchaseMapper, P
     * @Author: guq
     * @Date: 2018/10/19
     */
-    private synchronized 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)) ? 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;
     }
     
     /** 

+ 3 - 88
applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -465,91 +465,6 @@
     </set>
     where pd_id = #{id,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoftchina.saas.purchase.po.ProdIODetail">
-    update prodiodetail
-    set pd_piid = #{pd_piid,jdbcType=INTEGER},
-      pd_inoutno = #{pd_inoutno,jdbcType=VARCHAR},
-      pd_piclass = #{pd_piclass,jdbcType=VARCHAR},
-      pd_pdno = #{pd_pdno,jdbcType=INTEGER},
-      pd_ordercode = #{pd_ordercode,jdbcType=VARCHAR},
-      pd_orderdetno = #{pd_orderdetno,jdbcType=INTEGER},
-      pd_prodid = #{pd_prodid,jdbcType=INTEGER},
-      pd_prodcode = #{pd_prodcode,jdbcType=VARCHAR},
-      pd_unit = #{pd_unit,jdbcType=VARCHAR},
-      pd_inqty = #{pd_inqty,jdbcType=DOUBLE},
-      pd_outqty = #{pd_outqty,jdbcType=DOUBLE},
-      pd_orderprice = #{pd_orderprice,jdbcType=DOUBLE},
-      pd_sendprice = #{pd_sendprice,jdbcType=DOUBLE},
-      pd_price = #{pd_price,jdbcType=DOUBLE},
-      pd_total = #{pd_total,jdbcType=DOUBLE},
-      pd_taxrate = #{pd_taxrate,jdbcType=DOUBLE},
-      pd_netprice = #{pd_netprice,jdbcType=DOUBLE},
-      pd_nettotal = #{pd_nettotal,jdbcType=DOUBLE},
-      pd_whid = #{pd_whid,jdbcType=INTEGER},
-      pd_whcode = #{pd_whcode,jdbcType=VARCHAR},
-      pd_whname = #{pd_whname,jdbcType=VARCHAR},
-      pd_inwhid = #{pd_inwhid,jdbcType=INTEGER},
-      pd_inwhcode = #{pd_inwhcode,jdbcType=VARCHAR},
-      pd_inwhname = #{pd_inwhname,jdbcType=VARCHAR},
-      pd_orderid = #{pd_orderid,jdbcType=INTEGER},
-      pd_sdid = #{pd_sdid,jdbcType=INTEGER},
-      pd_status = #{pd_status,jdbcType=INTEGER},
-      companyid = #{companyid,jdbcType=INTEGER},
-      updaterid = #{updaterid,jdbcType=INTEGER},
-      updatetime = #{updatetime,jdbcType=TIMESTAMP},
-      pd_text1 = #{pd_text1,jdbcType=VARCHAR},
-      pd_text2 = #{pd_text2,jdbcType=VARCHAR},
-      pd_text3 = #{pd_text3,jdbcType=VARCHAR},
-      pd_text4 = #{pd_text4,jdbcType=VARCHAR},
-      pd_text5 = #{pd_text5,jdbcType=VARCHAR},
-      pd_ym = #{pd_ym,jdbcType=INTEGER},
-      pd_yqty = #{pd_yqty,jdbcType=DOUBLE},
-      pd_remark = #{pd_remark,jdbcType=LONGVARCHAR},
-      pd_ioid = #{pd_ioid,jdbcType=INTEGER}
-    where pd_id = #{pd_id,jdbcType=INTEGER}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.purchase.po.ProdIODetail">
-    update prodiodetail
-    set pd_piid = #{pd_piid,jdbcType=INTEGER},
-      pd_inoutno = #{pd_inoutno,jdbcType=VARCHAR},
-      pd_piclass = #{pd_piclass,jdbcType=VARCHAR},
-      pd_pdno = #{pd_pdno,jdbcType=INTEGER},
-      pd_ordercode = #{pd_ordercode,jdbcType=VARCHAR},
-      pd_orderdetno = #{pd_orderdetno,jdbcType=INTEGER},
-      pd_prodid = #{pd_prodid,jdbcType=INTEGER},
-      pd_prodcode = #{pd_prodcode,jdbcType=VARCHAR},
-      pd_unit = #{pd_unit,jdbcType=VARCHAR},
-      pd_inqty = #{pd_inqty,jdbcType=DOUBLE},
-      pd_outqty = #{pd_outqty,jdbcType=DOUBLE},
-      pd_orderprice = #{pd_orderprice,jdbcType=DOUBLE},
-      pd_sendprice = #{pd_sendprice,jdbcType=DOUBLE},
-      pd_price = #{pd_price,jdbcType=DOUBLE},
-      pd_total = #{pd_total,jdbcType=DOUBLE},
-      pd_taxrate = #{pd_taxrate,jdbcType=DOUBLE},
-      pd_netprice = #{pd_netprice,jdbcType=DOUBLE},
-      pd_nettotal = #{pd_nettotal,jdbcType=DOUBLE},
-      pd_whid = #{pd_whid,jdbcType=INTEGER},
-      pd_whcode = #{pd_whcode,jdbcType=VARCHAR},
-      pd_whname = #{pd_whname,jdbcType=VARCHAR},
-      pd_inwhid = #{pd_inwhid,jdbcType=INTEGER},
-      pd_inwhcode = #{pd_inwhcode,jdbcType=VARCHAR},
-      pd_inwhname = #{pd_inwhname,jdbcType=VARCHAR},
-      pd_orderid = #{pd_orderid,jdbcType=INTEGER},
-      pd_sdid = #{pd_sdid,jdbcType=INTEGER},
-      pd_status = #{pd_status,jdbcType=INTEGER},
-      companyid = #{companyid,jdbcType=INTEGER},
-      updaterid = #{updaterid,jdbcType=INTEGER},
-      updatetime = #{updatetime,jdbcType=TIMESTAMP},
-      pd_text1 = #{pd_text1,jdbcType=VARCHAR},
-      pd_text2 = #{pd_text2,jdbcType=VARCHAR},
-      pd_text3 = #{pd_text3,jdbcType=VARCHAR},
-      pd_text4 = #{pd_text4,jdbcType=VARCHAR},
-      pd_text5 = #{pd_text5,jdbcType=VARCHAR},
-      pd_ym = #{pd_ym,jdbcType=INTEGER},
-      pd_yqty = #{pd_yqty,jdbcType=DOUBLE},
-      pd_ioid = #{pd_ioid,jdbcType=INTEGER}
-    where pd_id = #{pd_id,jdbcType=INTEGER}
-  </update>
   <insert id="batchInsert" parameterType="java.util.List" >
     insert into prodiodetail (pd_piid, pd_inoutno,
     pd_piclass, pd_pdno, pd_ordercode,
@@ -722,11 +637,11 @@
     </foreach>
   </update>
 
-  <update id="updatePurchaseYqty" parameterType="java.lang.Integer">
+  <update id="updatePurchaseYqty" parameterType="long">
   update prodiodetail a
   set a.pd_yqty =ifnull((select  b.pd_outqty  from  (select pd_ioid,sum(pd_outqty) pd_outqty from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='采购验退单'
-  and pi_puid=#{id,jdbcType=INTEGER}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),0)
-  where a.pd_piid = (select pi_id from prodinout where pi_puid=#{id,jdbcType=INTEGER} and pi_class='采购验收单')
+  and pi_ioid=#{id,jdbcType=INTEGER}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),0)
+  where a.pd_piid = #{id,jdbcType=INTEGER}
   </update>
 
 

+ 9 - 4
applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutListMapper.xml

@@ -60,9 +60,13 @@
     <result column="pd_orderid" jdbcType="INTEGER" property="pd_orderid" />
     <result column="pd_sdid" jdbcType="INTEGER" property="pd_sdid" />
     <result column="pd_status" jdbcType="INTEGER" property="pd_status" />
-    <result column="companyid" jdbcType="INTEGER" property="companyId" />
-    <result column="updaterid" jdbcType="INTEGER" property="updaterId" />
-    <result column="updatetime" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="companyid" property="companyId" jdbcType="BIGINT" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="updaterName" jdbcType="VARCHAR" property="updaterName" />
+    <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
+    <result column="creatorName" jdbcType="VARCHAR" property="creatorName" />
+    <result column="createtime" property="createTime" jdbcType="TIMESTAMP" />
     <result column="pd_text1" jdbcType="VARCHAR" property="pd_text1" />
     <result column="pd_text2" jdbcType="VARCHAR" property="pd_text2" />
     <result column="pd_text3" jdbcType="VARCHAR" property="pd_text3" />
@@ -71,6 +75,7 @@
     <result column="pd_ym" jdbcType="INTEGER" property="pd_ym" />
     <result column="pd_yqty" jdbcType="DOUBLE" property="pd_yqty" />
     <result column="pd_ioid" jdbcType="INTEGER" property="pd_ioid" />
+    <result column="pd_remark" jdbcType="VARCHAR" property="pd_remark" />
     <result column="pr_id" property="pr_id"/>
     <result column="pr_code" property="pr_code"/>
     <result column="pr_detail" property="pr_detail"/>
@@ -114,7 +119,7 @@
   </select>
 
   <select id="selectProdInOutListByCondition"  resultMap="BaseResultMap">
-    select  *  from prodinout left join prodiodetail on pi_id = pd_piid
+    select  *  from prodinout left join prodiodetail on pi_id = pd_piid left join vendor on pi_vendid=ve_id
     left join product on pd_prodcode=pr_code
     <where>
       <if test="con != null">

+ 42 - 99
applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutMapper.xml

@@ -24,9 +24,11 @@
     <result column="pi_statuscode" jdbcType="VARCHAR" property="pi_statuscode" />
     <result column="pi_printstatus" jdbcType="VARCHAR" property="pi_printstatus" />
     <result column="pi_printstatuscode" jdbcType="VARCHAR" property="pi_printstatuscode" />
-    <result column="companyid" jdbcType="INTEGER" property="companyId" />
-    <result column="updaterid" jdbcType="INTEGER" property="updaterId" />
-    <result column="updatetime" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="companyid" property="companyId" jdbcType="BIGINT" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
+    <result column="createtime" property="createTime" jdbcType="TIMESTAMP" />
     <result column="pi_text1" jdbcType="VARCHAR" property="pi_text1" />
     <result column="pi_text2" jdbcType="VARCHAR" property="pi_text2" />
     <result column="pi_text3" jdbcType="VARCHAR" property="pi_text3" />
@@ -35,7 +37,7 @@
     <result column="pi_auditdate" jdbcType="TIMESTAMP" property="pi_auditdate" />
     <result column="pi_auditman" jdbcType="VARCHAR" property="pi_auditman" />
     <result column="pi_remark" jdbcType="VARCHAR" property="pi_remark" />
-
+    <result column="pi_ioid" jdbcType="INTEGER" property="pi_ioid" />
 
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.usoftchina.saas.purchase.po.ProdInOut">
@@ -48,8 +50,8 @@
     pi_id, pi_inoutno, pi_class, pi_date, pi_vendid, pi_vendcode, pi_vendname, pi_custid, 
     pi_custcode, pi_custname, pi_puid, pi_pucode, pi_said, pi_sacode, pi_total, pi_recordmanid, 
     pi_recordman, pi_recorddate, pi_status, pi_statuscode, pi_printstatus, pi_printstatuscode, 
-    companyid, updaterid, updatetime, pi_text1, pi_text2, pi_text3, pi_text4, pi_text5,pi_auditdate,
-    pi_auditman,pi_remark
+    companyid, updaterid, updatetime,creatorid,createtime, pi_text1, pi_text2, pi_text3, pi_text4, pi_text5,pi_auditdate,
+    pi_auditman,pi_remark,pi_ioid
   </sql>
   <sql id="Blob_Column_List">
     pi_address
@@ -62,6 +64,7 @@
     from prodinout
     where pi_id = #{pi_id,jdbcType=INTEGER}
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from prodinout
     where pi_id = #{pi_id,jdbcType=INTEGER}
@@ -122,9 +125,6 @@
       <if test="pi_recordman != null">
         pi_recordman,
       </if>
-      <if test="createTime != null">
-        pi_recorddate,
-      </if>
       <if test="pi_status != null">
         pi_status,
       </if>
@@ -137,14 +137,21 @@
       <if test="pi_printstatuscode != null">
         pi_printstatuscode,
       </if>
-      <if test="companyId != null">
+
+      <if test="companyId != null" >
         companyid,
       </if>
-      <if test="updaterId != null">
-        updaterid,
+      <if test="updaterId != null" >
+        updaterId,
+      </if>
+      <if test="updateTime != null" >
+        updateTime,
       </if>
-      <if test="updateTime != null">
-        updatetime,
+      <if test="creatorId != null" >
+        creatorId,
+      </if>
+      <if test="createTime != null" >
+        createTime,
       </if>
       <if test="pi_text1 != null">
         pi_text1,
@@ -173,6 +180,9 @@
       <if test="pi_remark != null">
         pi_remark,
       </if>
+      <if test="pi_ioid != null">
+        pi_ioid,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
 
@@ -224,9 +234,6 @@
       <if test="pi_recordman != null">
         #{pi_recordman,jdbcType=VARCHAR},
       </if>
-      <if test="createTime != null">
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
       <if test="pi_status != null">
         #{pi_status,jdbcType=VARCHAR},
       </if>
@@ -239,15 +246,22 @@
       <if test="pi_printstatuscode != null">
         #{pi_printstatuscode,jdbcType=VARCHAR},
       </if>
-      <if test="companyId != null">
+
+      <if test="companyId != null" >
         #{companyId,jdbcType=INTEGER},
       </if>
-      <if test="updaterId != null">
+      <if test="updaterId != null" >
         #{updaterId,jdbcType=INTEGER},
       </if>
-      <if test="updateTime != null">
+      <if test="updateTime != null" >
         #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="creatorId != null" >
+        #{creatorId,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="pi_text1 != null">
         #{pi_text1,jdbcType=VARCHAR},
       </if>
@@ -275,7 +289,9 @@
       <if test="pi_remark != null">
         #{pi_remark,jdbcType=VARCHAR},
       </if>
-
+      <if test="pi_ioid != null">
+        #{pi_ioid,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
 
@@ -345,14 +361,14 @@
       <if test="pi_printstatuscode != null">
         pi_printstatuscode = #{pi_printstatuscode,jdbcType=VARCHAR},
       </if>
-      <if test="companyId != null">
+      <if test="companyId != null" >
         companyid = #{companyId,jdbcType=INTEGER},
       </if>
-      <if test="updaterId != null">
-        updaterid = #{updaterId,jdbcType=INTEGER},
+      <if test="updaterId != null" >
+        updaterId = #{updaterId,jdbcType=INTEGER},
       </if>
-      <if test="updateTime != null">
-        updatetime = #{updateTime,jdbcType=TIMESTAMP},
+      <if test="updateTime != null" >
+        updateTime = #{updateTime,jdbcType=TIMESTAMP},
       </if>
       <if test="pi_text1 != null">
         pi_text1 = #{pi_text1,jdbcType=VARCHAR},
@@ -384,79 +400,6 @@
     </set>
     where pi_id = #{id,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoftchina.saas.purchase.po.ProdInOut">
-    update prodinout
-    set pi_inoutno = #{pi_inoutno,jdbcType=VARCHAR},
-      pi_class = #{pi_class,jdbcType=VARCHAR},
-      pi_date = #{pi_date,jdbcType=TIMESTAMP},
-      pi_vendid = #{pi_vendid,jdbcType=INTEGER},
-      pi_vendcode = #{pi_vendcode,jdbcType=VARCHAR},
-      pi_vendname = #{pi_vendname,jdbcType=VARCHAR},
-      pi_custid = #{pi_custid,jdbcType=INTEGER},
-      pi_custcode = #{pi_custcode,jdbcType=VARCHAR},
-      pi_custname = #{pi_custname,jdbcType=VARCHAR},
-      pi_puid = #{pi_puid,jdbcType=INTEGER},
-      pi_pucode = #{pi_pucode,jdbcType=VARCHAR},
-      pi_said = #{pi_said,jdbcType=INTEGER},
-      pi_sacode = #{pi_sacode,jdbcType=VARCHAR},
-      pi_total = #{pi_total,jdbcType=DOUBLE},
-      pi_recordmanid = #{pi_recordmanid,jdbcType=INTEGER},
-      pi_recordman = #{pi_recordman,jdbcType=VARCHAR},
-      pi_recorddate = #{createTime,jdbcType=TIMESTAMP},
-      pi_status = #{pi_status,jdbcType=VARCHAR},
-      pi_statuscode = #{pi_statuscode,jdbcType=VARCHAR},
-      pi_printstatus = #{pi_printstatus,jdbcType=VARCHAR},
-      pi_printstatuscode = #{pi_printstatuscode,jdbcType=VARCHAR},
-      companyid = #{companyid,jdbcType=INTEGER},
-      updaterid = #{updaterid,jdbcType=INTEGER},
-      updatetime = #{updatetime,jdbcType=TIMESTAMP},
-      pi_text1 = #{pi_text1,jdbcType=VARCHAR},
-      pi_text2 = #{pi_text2,jdbcType=VARCHAR},
-      pi_text3 = #{pi_text3,jdbcType=VARCHAR},
-      pi_text4 = #{pi_text4,jdbcType=VARCHAR},
-      pi_text5 = #{pi_text5,jdbcType=VARCHAR},
-      pi_address = #{pi_address,jdbcType=LONGVARCHAR},
-      pi_auditdate = #{pi_auditdate,jdbcType=TIMESTAMP},
-      pi_auditman = #{pi_auditman,jdbcType=VARCHAR},
-      pi_remark = #{pi_remark,jdbcType=VARCHAR}
-    where pi_id = #{pi_id,jdbcType=INTEGER}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.purchase.po.ProdInOut">
-    update prodinout
-    set pi_inoutno = #{pi_inoutno,jdbcType=VARCHAR},
-      pi_class = #{pi_class,jdbcType=VARCHAR},
-      pi_date = #{pi_date,jdbcType=TIMESTAMP},
-      pi_vendid = #{pi_vendid,jdbcType=INTEGER},
-      pi_vendcode = #{pi_vendcode,jdbcType=VARCHAR},
-      pi_vendname = #{pi_vendname,jdbcType=VARCHAR},
-      pi_custid = #{pi_custid,jdbcType=INTEGER},
-      pi_custcode = #{pi_custcode,jdbcType=VARCHAR},
-      pi_custname = #{pi_custname,jdbcType=VARCHAR},
-      pi_puid = #{pi_puid,jdbcType=INTEGER},
-      pi_pucode = #{pi_pucode,jdbcType=VARCHAR},
-      pi_said = #{pi_said,jdbcType=INTEGER},
-      pi_sacode = #{pi_sacode,jdbcType=VARCHAR},
-      pi_total = #{pi_total,jdbcType=DOUBLE},
-      pi_recordmanid = #{pi_recordmanid,jdbcType=INTEGER},
-      pi_recordman = #{pi_recordman,jdbcType=VARCHAR},
-      pi_recorddate = #{createTime,jdbcType=TIMESTAMP},
-      pi_status = #{pi_status,jdbcType=VARCHAR},
-      pi_statuscode = #{pi_statuscode,jdbcType=VARCHAR},
-      pi_printstatus = #{pi_printstatus,jdbcType=VARCHAR},
-      pi_printstatuscode = #{pi_printstatuscode,jdbcType=VARCHAR},
-      companyid = #{companyId,jdbcType=INTEGER},
-      updaterid = #{updaterId,jdbcType=INTEGER},
-      updatetime = #{updateTime,jdbcType=TIMESTAMP},
-      pi_text1 = #{pi_text1,jdbcType=VARCHAR},
-      pi_text2 = #{pi_text2,jdbcType=VARCHAR},
-      pi_text3 = #{pi_text3,jdbcType=VARCHAR},
-      pi_text4 = #{pi_text4,jdbcType=VARCHAR},
-      pi_text5 = #{pi_text5,jdbcType=VARCHAR},
-      pi_auditdate = #{pi_auditdate,jdbcType=TIMESTAMP},
-      pi_auditman = #{pi_auditman,jdbcType=VARCHAR},
-      pi_remark = #{pi_remark,jdbcType=VARCHAR}
-    where pi_id = #{id,jdbcType=INTEGER}
-  </update>
 
   <select id="validateCodeWhenInsert"  resultType="int">
     select count(1) from prodinout where pi_inoutno = #{pi_inoutno} and companyid = #{companyId}

+ 7 - 2
applications/purchase/purchase-server/src/main/resources/mapper/PurchaseListMapper.xml

@@ -24,8 +24,12 @@
         <result column="PU_STATUSCODE" property="pu_statuscode" jdbcType="VARCHAR" />
         <result column="PU_STATUS" property="pu_status" jdbcType="VARCHAR" />
         <result column="companyid" property="companyId" jdbcType="BIGINT" />
-        <result column="updatemanid" property="updaterId" jdbcType="INTEGER" />
-        <result column="updatedate" property="updateTime" jdbcType="TIMESTAMP" />
+        <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+        <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+        <!--<result column="updater" jdbcType="VARCHAR" property="updater" />-->
+        <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
+        <result column="createtime" property="createTime" jdbcType="TIMESTAMP" />
+        <!--<result column="creator" property="creator" jdbcType="VARCHAR" />-->
         <result column="pu_text1" property="pu_text1" jdbcType="VARCHAR" />
         <result column="pu_text2" property="pu_text2" jdbcType="VARCHAR" />
         <result column="pu_text3" property="pu_text3" jdbcType="VARCHAR" />
@@ -54,6 +58,7 @@
         <result column="pd_text4" property="pd_text4" jdbcType="VARCHAR" />
         <result column="pd_text5" property="pd_text5" jdbcType="VARCHAR" />
         <result column="pd_yqty" property="pd_yqty" jdbcType="DOUBLE" />
+        <result column="pd_remark" property="pd_remark" jdbcType="VARCHAR"/>
         <result column="pr_id" property="pr_id"/>
         <result column="pr_code" property="pr_code"/>
         <result column="pr_detail" property="pr_detail"/>

+ 42 - 27
applications/purchase/purchase-server/src/main/resources/mapper/PurchaseMapper.xml

@@ -24,8 +24,14 @@
     <result column="PU_STATUSCODE" property="pu_statuscode" jdbcType="VARCHAR" />
     <result column="PU_STATUS" property="pu_status" jdbcType="VARCHAR" />
     <result column="companyid" property="companyId" jdbcType="BIGINT" />
-    <result column="updatemanid" property="updaterId" jdbcType="INTEGER" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
     <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="pu_auditman" property="pu_auditman" jdbcType="VARCHAR" />
+    <result column="pu_auditdate" property="pu_auditdate" jdbcType="TIMESTAMP" />
     <result column="pu_text1" property="pu_text1" jdbcType="VARCHAR" />
     <result column="pu_text2" property="pu_text2" jdbcType="VARCHAR" />
     <result column="pu_text3" property="pu_text3" jdbcType="VARCHAR" />
@@ -40,8 +46,8 @@
     pu_id, pu_code, pu_date, pu_vendid, PU_VENDCODE, PU_VENDNAME, PU_BUYERID, PU_BUYERCODE, 
     PU_BUYERNAME, PU_DELIVERY, PU_TAXTOTAL, PU_TOTAL, PU_REMARK, PU_TOTALUPPER, PU_INDATE, 
     PU_PRINTSTATUS, PU_PRINTSTATUSCODE, PU_ACCEPTSTATUSCODE, PU_ACCEPTSTATUS, PU_STATUSCODE, 
-    PU_STATUS, companyid, updaterId, updateTime, pu_text1, pu_text2, pu_text3, pu_text4,
-    pu_text5
+    PU_STATUS, companyid, updaterId,updaterName,updateTime,creatorid,creatorName,createtime, pu_text1, pu_text2, pu_text3, pu_text4,
+    pu_text5,pu_auditman,pu_auditdate
   </sql>
   <sql id="Blob_Column_List" >
     PU_SHIPADDRESSCODE
@@ -58,30 +64,7 @@
     delete from purchase
     where pu_id = #{id}
   </delete>
-  <insert id="insert" parameterType="com.usoftchina.saas.purchase.po.Purchase" >
-    insert into purchase (pu_id, pu_code, pu_date, 
-      pu_vendid, PU_VENDCODE, PU_VENDNAME, 
-      PU_BUYERID, PU_BUYERCODE, PU_BUYERNAME, 
-      PU_DELIVERY, PU_TAXTOTAL, PU_TOTAL, 
-      PU_REMARK, PU_TOTALUPPER, PU_INDATE, 
-      PU_PRINTSTATUS, PU_PRINTSTATUSCODE, PU_ACCEPTSTATUSCODE, 
-      PU_ACCEPTSTATUS, PU_STATUSCODE, PU_STATUS, 
-      companyid, updaterId, updateTime,
-      pu_text1, pu_text2, pu_text3, 
-      pu_text4, pu_text5, PU_SHIPADDRESSCODE
-      )
-    values (#{id,jdbcType=INTEGER}, #{puCode,jdbcType=VARCHAR}, #{puDate,jdbcType=TIMESTAMP},
-      #{puVendid,jdbcType=INTEGER}, #{puVendcode,jdbcType=VARCHAR}, #{puVendname,jdbcType=VARCHAR}, 
-      #{puBuyerid,jdbcType=INTEGER}, #{puBuyercode,jdbcType=VARCHAR}, #{puBuyername,jdbcType=VARCHAR}, 
-      #{puDelivery,jdbcType=TIMESTAMP}, #{puTaxtotal,jdbcType=DOUBLE}, #{puTotal,jdbcType=DOUBLE}, 
-      #{puRemark,jdbcType=VARCHAR}, #{puTotalupper,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
-      #{puPrintstatus,jdbcType=VARCHAR}, #{puPrintstatuscode,jdbcType=VARCHAR}, #{puAcceptstatuscode,jdbcType=VARCHAR}, 
-      #{puAcceptstatus,jdbcType=VARCHAR}, #{puStatuscode,jdbcType=VARCHAR}, #{puStatus,jdbcType=VARCHAR}, 
-      #{companyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP},
-      #{puText1,jdbcType=VARCHAR}, #{puText2,jdbcType=VARCHAR}, #{puText3,jdbcType=VARCHAR}, 
-      #{puText4,jdbcType=VARCHAR}, #{puText5,jdbcType=VARCHAR}, #{puShipaddresscode,jdbcType=LONGVARCHAR}
-      )
-  </insert>
+
   <insert id="insertSelective" parameterType="com.usoftchina.saas.purchase.po.Purchase" >
     <selectKey resultType="java.lang.Long" keyProperty="id">
       SELECT LAST_INSERT_ID() AS ID
@@ -154,9 +137,21 @@
       <if test="updaterId != null" >
         updaterId,
       </if>
+      <if test="updaterName != null" >
+        updaterName,
+      </if>
       <if test="updateTime != null" >
         updateTime,
       </if>
+      <if test="creatorId != null" >
+      creatorId,
+      </if>
+      <if test="creatorName != null" >
+        creatorName,
+      </if>
+      <if test="createTime != null" >
+      createTime,
+      </if>
       <if test="pu_text1 != null" >
         pu_text1,
       </if>
@@ -243,9 +238,20 @@
       <if test="updaterId != null" >
         #{updaterId,jdbcType=INTEGER},
       </if>
+      <if test="updaterName != null" >
+        #{updaterName,jdbcType=VARCHAR},
+      </if>
       <if test="updateTime != null" >
         #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="creatorId != null" >
+       #{creatorId,jdbcType=INTEGER},
+      </if><if test="createTime != null" >
+       #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="creatorName != null" >
+       #{creatorName,jdbcType=VARCHAR},
+      </if>
       <if test="pu_text1 != null" >
         #{pu_text1,jdbcType=VARCHAR},
       </if>
@@ -338,6 +344,9 @@
       <if test="updateTime != null" >
         updateTime = #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="updaterName != null" >
+        updaterName = #{updaterName,jdbcType=VARCHAR},
+      </if>
       <if test="pu_text1 != null" >
         pu_text1 = #{pu_text1,jdbcType=VARCHAR},
       </if>
@@ -384,6 +393,7 @@
       companyid = #{companyId,jdbcType=INTEGER},
       updaterId = #{updaterId,jdbcType=INTEGER},
       updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      updater = #{updater,jdbcType=VARCHAR},
       pu_text1 = #{pu_text1,jdbcType=VARCHAR},
       pu_text2 = #{pu_text2,jdbcType=VARCHAR},
       pu_text3 = #{pu_text3,jdbcType=VARCHAR},
@@ -427,4 +437,9 @@
     select count(1) from purchasedetail where PD_PUID=#{id} and PD_YQTY !=0;
 </select>
 
+  <update id="updateCreator">
+    update purchase set creatorId = #{userId} , creatorName=#{userName} where pu_id=#{id}
+  </update>
+
+
 </mapper>

+ 6 - 6
applications/purchase/purchase-server/src/main/resources/mapper/PurchaseReportMapper.xml

@@ -6,8 +6,6 @@
     <result column="pb_code" property="pb_code" jdbcType="VARCHAR" />
     <result column="pu_vendcode" property="pu_vendcode" jdbcType="VARCHAR" />
     <result column="pu_vendname" property="pu_vendname" jdbcType="VARCHAR" />
-    <result column="pb_recorder" property="pb_recorder" jdbcType="VARCHAR" />
-    <result column="pb_recorddate" property="pb_recorddate" jdbcType="TIMESTAMP" />
     <result column="pbd_slcode" property="pbd_slcode" jdbcType="VARCHAR" />
     <result column="pbd_slkind" property="pbd_slkind" jdbcType="VARCHAR" />
     <result column="pbd_amount" property="pbd_amount" jdbcType="DOUBLE" />
@@ -15,7 +13,11 @@
     <result column="pb_pbdamount" property="pb_pbdamount" jdbcType="DOUBLE" />
     <result column="pb_payrate" property="pb_payrate" jdbcType="DOUBLE" />
     <result column="pd_remark" property="pd_remark" jdbcType="VARCHAR" />
-    <result column="companyid" property="companyid" jdbcType="INTEGER" />
+    <result column="companyid" property="companyId" jdbcType="BIGINT" />
+
+    <result column="creatorid" property="creatorId" jdbcType="INTEGER"/>
+    <result column="createtime" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="creator" property="creator" jdbcType="VARCHAR" />
   </resultMap>
   <resultMap id="ListMap" type="com.usoftchina.saas.purchase.po.report.PurchaseReportDetail">
     <id column="pu_id" property="pu_id" jdbcType="INTEGER" />
@@ -40,8 +42,6 @@
     <result column="PU_STATUSCODE" property="pu_statuscode" jdbcType="VARCHAR" />
     <result column="PU_STATUS" property="pu_status" jdbcType="VARCHAR" />
     <result column="companyid" property="companyId" jdbcType="BIGINT" />
-    <result column="updatemanid" property="updaterId" jdbcType="INTEGER" />
-    <result column="updatedate" property="updateTime" jdbcType="TIMESTAMP" />
     <result column="pu_text1" property="pu_text1" jdbcType="VARCHAR" />
     <result column="pu_text2" property="pu_text2" jdbcType="VARCHAR" />
     <result column="pu_text3" property="pu_text3" jdbcType="VARCHAR" />
@@ -110,7 +110,7 @@
         and  companyId = #{companyId}
       </if>
     </where>
-    order by pb_recorddate desc
+    order by pb_id desc
   </select>
 
   <select id="selectDetailByCondition"  resultMap="ListMap">

+ 16 - 3
applications/purchase/purchase-server/src/main/resources/mapper/PurchasedetailMapper.xml

@@ -29,6 +29,7 @@
     <result column="pd_text4" property="pd_text4" jdbcType="VARCHAR" />
     <result column="pd_text5" property="pd_text5" jdbcType="VARCHAR" />
     <result column="pd_yqty" property="pd_yqty" jdbcType="DOUBLE" />
+    <result column="pd_remark" property="pd_remark" jdbcType="VARCHAR" />
     <association property="productDTO" javaType="com.usoftchina.saas.document.dto.ProductDTO">
       <id column="pr_id" property="id"/>
       <result column="pr_code" property="pr_code"/>
@@ -64,7 +65,7 @@
     PD_ID, PD_PUID, PD_CODE, PD_DETNO, PD_PRODID, PD_PRODCODE, PD_UNIT, PD_QTY, PD_PRICE,PD_TAXPRICE,
     PD_TOTAL, PD_TAXRATE,PD_TAXTOTAL, PD_ACCEPTQTY, PD_DELIVERY, PD_SALECODE, PD_SALEDETNO, PD_SDID,
     companyId, updaterId, updateTime, pd_text1, pd_text2, pd_text3, pd_text4, pd_text5,
-    pd_yqty
+    pd_yqty,pd_remark
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select
@@ -164,6 +165,9 @@
       <if test="pd_text5 != null">
         pd_text5,
       </if>
+      <if test="pd_remark != null">
+        pd_remark,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
 
@@ -245,6 +249,9 @@
       <if test="pd_text5 != null">
         #{pd_text5,jdbcType=VARCHAR},
       </if>
+      <if test="pd_remark !=null">
+        #{pd_remark,jdbcType=VARCHAR}
+      </if>
     </trim>
   </insert>
 
@@ -329,6 +336,9 @@
       <if test="pd_yqty != null" >
         pd_yqty = #{pd_yqty,jdbcType=DOUBLE},
       </if>
+      <if test="pd_remark != null" >
+        pd_remark = #{pd_remark,jdbcType=VARCHAR}
+      </if>
     </set>
     where PD_ID = #{id,jdbcType=INTEGER}
   </update>
@@ -342,7 +352,7 @@
     PD_SDID, companyId, updaterId,
     updateTime, pd_text1, pd_text2,
     pd_text3, pd_text4, pd_text5,
-    pd_yqty)
+    pd_yqty,pd_remark)
     values
     <foreach collection="list" item="item" index="index" open="" close="" separator=",">
       (
@@ -354,7 +364,7 @@
       #{item.pd_sdid,jdbcType=INTEGER}, #{item.companyId,jdbcType=INTEGER}, #{item.updaterId,jdbcType=INTEGER},
       #{item.updateTime,jdbcType=TIMESTAMP}, #{item.pd_text1,jdbcType=VARCHAR}, #{item.pd_text2,jdbcType=VARCHAR},
       #{item.pd_text3,jdbcType=VARCHAR}, #{item.pd_text4,jdbcType=VARCHAR}, #{item.pd_text5,jdbcType=VARCHAR},
-      #{item.pd_yqty,jdbcType=DOUBLE}
+      #{item.pd_yqty,jdbcType=DOUBLE}, #{item.pd_remark,jdbcType=VARCHAR}
       )
     </foreach>
   </insert>
@@ -436,6 +446,9 @@
       <if test="item.pd_yqty != null" >
         pd_yqty = #{item.pd_yqty,jdbcType=DOUBLE},
       </if>
+      <if test="item.pd_remark !=null">
+        pd_remark = #{item.pd_remark,jdbcType=VARCHAR}
+      </if>
       </set>
       where PD_ID = #{item.id,jdbcType=INTEGER}
     </foreach>

+ 2 - 1
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/SaleApplication.java

@@ -17,8 +17,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 @EnableEurekaClient
 @EnableFeignClients("com.usoftchina.saas")
 @EnableAuthClient
-public class SaleApplication{
+public class SaleApplication  {
     public static void main(String[] args) {
         SpringApplication.run(SaleApplication.class, args);
     }
+
 }

+ 4 - 1
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/SaleMapper.java

@@ -1,11 +1,12 @@
 package com.usoftchina.saas.sale.mapper;
 
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.sale.po.Sale;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
-public interface SaleMapper {
+public interface SaleMapper extends CommonBaseMapper<Sale> {
 
     int deleteByPrimaryKey(Long sa_id);
 
@@ -39,4 +40,6 @@ public interface SaleMapper {
     void updateNetTotal(Long id);
 
     Integer checkSendStatus(Long id);
+
+    void updateCreator(@Param("userId") Long userId, @Param("userName") String userName, @Param("id") Long id);
 }

+ 2 - 1
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/SaleList.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.sale.po;
 
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
 import com.usoftchina.saas.document.dto.ProductDTO;
 import lombok.Data;
 
@@ -11,7 +12,7 @@ import java.util.Date;
  * @create: 2018-10-22 14:38
  **/
 @Data
-public class SaleList implements Serializable{
+public class SaleList implements Serializable {
     private Integer sa_id;
 
     private String sa_code;

+ 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;
 }

+ 23 - 23
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;
@@ -171,7 +172,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //更新明细金额等
         setTotal(prodInOutNow);
         //日志
-       messageLogService.update(baseDTO);
+        messageLogService.update(baseDTO);
         return baseDTO;
 
     }
@@ -231,7 +232,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Override
-    @Transactional
     public DocBaseDTO audit(ProdInOutFormDTO formData) {
         Long id = null;
         DocBaseDTO baseDTO = new DocBaseDTO();
@@ -247,7 +247,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();
@@ -347,13 +349,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);
@@ -422,7 +418,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         targetPi.setPi_recordmanid(BaseContextHolder.getUserId());
         targetPi.setPi_recorddate(new Date());
         targetPi.setPi_recordman("TESTADMIN");
-
+        targetPi.setPi_ioid(id);
         targetPi.setPi_inoutno(piInoutno);
         targetPi.setPi_class(BillCodeSeq.SALEIN.getName());
         targetPi.setPi_date(new Date());
@@ -571,22 +567,26 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private synchronized String pushMaxnubmer(DocBaseDTO baseDTO) {
+    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 maxnumberService.pushMaxnubmer(count, code, caller).getData();
+        return billCode;
     }
 
     @Override
@@ -628,14 +628,14 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             if(prodInOut.getPi_said()!=null) {
                 prodIODetailMapper.updateSaleYqty(prodInOut.getPi_said());
             }
-        }else{//销售退货单z
+        }else{//销售退货单
             //更新明细
             prodIODetailMapper.updatePDSaleIN(id);
             //更新主表
             prodInOutMapper.updatePiTotal(id);
             //出货单已转数
-            if(prodInOut.getPi_said()!=null){
-                prodIODetailMapper.updateSaleOutYqty(prodInOut.getPi_said());
+            if(prodInOut.getPi_ioid()!= null) {
+                prodIODetailMapper.updateSaleOutYqty(prodInOut.getPi_ioid());
             }
         }
     }

+ 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 - 19
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java

@@ -2,6 +2,8 @@ package com.usoftchina.saas.sale.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.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
@@ -13,6 +15,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;
@@ -56,15 +59,11 @@ public class SaleServiceImpl implements SaleService{
     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);
@@ -101,8 +100,9 @@ public class SaleServiceImpl implements SaleService{
         Long companyId = BaseContextHolder.getCompanyId();
         //人员Id
         Long userId = BaseContextHolder.getUserId();
+        String name = BaseContextHolder.getUserName();
         //获取主表信息
-         SaleDTO main = formdata.getMain();
+        SaleDTO main = formdata.getMain();
         List<SaleDetailDTO> items = formdata.getItems();
         //插入从表数据
         List<SaleDetail> insertDetails = new ArrayList<>();
@@ -113,11 +113,6 @@ public class SaleServiceImpl implements SaleService{
         Long sa_id = main.getId();
         String sa_code = main.getSa_code();
         Sale sale = BeanMapper.map(main, Sale.class);
-        sale.setCompanyId(companyId);
-        sale.setCreatorId(userId);
-        sale.setCreateTime(new Date());
-        sale.setSa_recorderid(userId);
-        sale.setSa_recorder("test");
         sale.setSa_sendstatus(Status.UNTURNOUT.getDisplay());
         sale.setSa_sendstatuscode(Status.UNTURNOUT.name());
 
@@ -127,9 +122,11 @@ public class SaleServiceImpl implements SaleService{
         sale.setSa_code(sa_code);
         //判断更新与保存动作
         if (StringUtils.isEmpty(sa_id) || "0".equals(sa_id.toString())) {
+            sale.setCompanyId(companyId);
             //插入操作
             saleMapper.insertSelective(sale);
             sa_id = sale.getId();
+            saleMapper.updateCreator(userId, name, sa_id);
             //添加从表传输对象
             for (SaleDetailDTO item : items) {
                 SaleDetail detail = BeanMapper.map(item, SaleDetail.class);
@@ -232,7 +229,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());
@@ -242,7 +239,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);
         //更新从表总额
@@ -561,14 +560,18 @@ public class SaleServiceImpl implements SaleService{
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private synchronized 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)) ? 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;
     }
 
     /**

+ 6 - 11
applications/sale/sale-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -739,18 +739,13 @@
   </update>
 
   <update id="updateSaleOutYqty" parameterType="long">
-update prodiodetail a
-  set a.pd_yqty =ifnull((select  b.pd_inqty  from  (
+   update prodiodetail a
+   set a.pd_yqty =ifnull(
+	 (select  b.pd_inqty  from  (
 	select pd_ioid,sum(pd_inqty) pd_inqty from  prodiodetail left join prodinout on pd_piid = pi_id where pd_piclass='销售退货单'
-  and pi_said=#{id}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),0)
-  where a.pd_piid = (select pi_id from prodinout where pi_said=#{id} and pi_class='出货单');
-  </update>
-  <update id="updateSaleYqty" parameterType="long">
-
-    update saledetail a set a.sd_yqty =IFNULL( ( select b.pd_outqty from (
-    select pd_sdid,sum(pd_outqty) pd_outqty from prodiodetail left join
-    prodinout on pd_piid = pi_id where pd_piclass='出货单' and pi_said=#{id}
-    GROUP BY pd_sdid) b where IFNULL(b.pd_sdid ,0) = a.sd_id ),0) where a.sd_said =#{id}
+  and pi_ioid=#{id}  GROUP BY pd_ioid) b where ifnull(b.pd_ioid ,0)= a.pd_id ),
+	0)
+  where a.pd_piid =#{id}
   </update>
 
   <select id="selectByFK" parameterType="long" resultMap="BaseResultMap">

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

@@ -89,6 +89,7 @@
 
   <select id="selectProdInOutBycondition"  resultMap="BaseResultMap">
     select  *  from prodinout left join prodiodetail on pi_id = pd_piid left join product on pr_id = pd_prodid
+    left join customer on pi_custid=cu_id
       <where>
         <if test="con != null">
           ${con}

+ 6 - 4
applications/sale/sale-server/src/main/resources/mapper/SaleMapper.xml

@@ -33,6 +33,8 @@
     <result column="sa_seller" property="sa_seller" jdbcType="VARCHAR" />
     <result column="sa_sellercode" property="sa_sellercode" jdbcType="VARCHAR" />
     <result column="sa_date" property="sa_date" jdbcType="TIMESTAMP"/>
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     sa_id, sa_code, sa_custid, sa_custcode, sa_custname, sa_toplace, sa_total, sa_totalupper, 
@@ -42,10 +44,7 @@
     sa_seller,sa_sellercode,sa_date
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
-    select 
-    <include refid="Base_Column_List" />
-    from sale
-    where sa_id = #{id}
+    select * from sale where sa_id = #{id}
   </select>
   <delete id="deleteByPrimaryKey" parameterType="long" >
     delete from sale
@@ -419,4 +418,7 @@
     select count(1) from saledetail where sd_said = #{id}
     and ifnull(sd_yqty, 0) > 0;
   </select>
+  <update id="updateCreator">
+    update sale set creatorId = #{userId} , creatorName=#{userName} where sa_id=#{id}
+  </update>
 </mapper>

+ 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

+ 2 - 0
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOut.java

@@ -70,4 +70,6 @@ public class ProdInOut extends CommonBaseEntity implements Serializable {
     private String pi_auditman;
 
     private String pi_remark;
+
+    private Long pi_ioid;
 }

+ 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);
 }

+ 85 - 11
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;
 
@@ -252,21 +253,36 @@ 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();
+        //检验单审核状态
+        //检查审核状态
+        String ma_statuscode = make.getMa_statuscode();
+        if(StringUtils.isEmpty(ma_statuscode)||(!StringUtils.isEmpty(ma_statuscode)&&!ma_statuscode.equals(Status.UNAUDITED.name()))){
+            throw  new BizException(BizExceptionCode.BIZ_AUDITED);
+        };
+
         //2.校验库存是否足够
         validStorage(makeListDTO);
         //3.生成  完工入库单和领料单 并 过账
         generateProdIO(makeListDTO);
-
         //4.修改单据状态
         Make updateMake = new Make();
         updateMake.setId(make.getId());
@@ -280,9 +296,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.过账
@@ -510,7 +550,6 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
                 prodIODetailList.add(prodIODetail);
             }
             prodIODetailMapper.batchInsert(prodIODetailList);
-
             map.put("inoutNo", code);
             map.put("class", "完工入库单");
             map.put("commitid", BaseContextHolder.getUserId());
@@ -524,10 +563,21 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public DocBaseDTO resAudit(Long id) {
+        return singleUnAudit(id);
+    }
+
+
+
+    @Transactional(propagation = Propagation.REQUIRED)
+    public DocBaseDTO singleUnAudit(Long id) {
         //1.获取主从表数据
         Make make = getMapper().selectByPrimaryKey(id);
+        //检查审核状态
+        String ma_statuscode = make.getMa_statuscode();
+        if(StringUtils.isEmpty(ma_statuscode)||(!StringUtils.isEmpty(ma_statuscode)&&!ma_statuscode.equals(Status.AUDITED.name()))){
+            throw  new BizException(BizExceptionCode.BIZ_UNAUDITED);
+        };
         List<MakeMaterial> items = makeMaterialMapper.selectByFK(id, BaseContextHolder.getCompanyId());
         MakeListDTO makeListDTO = new MakeListDTO(make, items);
         //2.校验库存是否足够
@@ -549,6 +599,25 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
         return docBaseDTO;
     }
 
+
+    @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();
+                singleUnAudit(id);
+            }catch (Exception e) {
+                errorMsg.append("编号:" + base.getCode() + "处理失败," + e.getMessage());
+            }
+        }
+        return errorMsg.toString();
+    }
+
     @Override
     public String batchClose(BatchDealBaseDTO batchDealBaseDTO) {
         StringBuilder errorMsg = new StringBuilder();
@@ -589,6 +658,7 @@ public class MakeServiceImpl extends CommonBaseServiceImpl<MakeMapper, Make> imp
         return true;
     }
 
+
     /**
      * 1.查找制造单关联的出入库单据
      * 2.反过账
@@ -662,8 +732,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(BizExceptionCode.EMPTY_DATA);
@@ -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();
@@ -442,7 +443,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();
@@ -450,17 +451,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" />

+ 43 - 5
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/AccountApi.java

@@ -1,11 +1,12 @@
 package com.usoftchina.saas.account.api;
 
+import com.usoftchina.saas.account.dto.AccountCopyDTO;
 import com.usoftchina.saas.account.dto.AccountDTO;
+import com.usoftchina.saas.account.dto.AccountRegDTO;
+import com.usoftchina.saas.account.dto.AccountUpdateDTO;
 import com.usoftchina.saas.base.Result;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @author yingp
@@ -29,15 +30,52 @@ public interface AccountApi {
      * @param username
      * @return
      */
-    @GetMapping(value = "/account/read")
+    @GetMapping(value = "/account/read", params = "username")
     Result<AccountDTO> getAccount(@RequestParam(value = "username") String username);
 
+    /**
+     * 按用户uu查找账户
+     *
+     * @param uu
+     * @return
+     */
+    @GetMapping(value = "/account/read", params = "uu")
+    Result<AccountDTO> getAccountByUu(@RequestParam(value = "uu") Long uu);
+
     /**
      * 按用户名查找账户
      *
      * @param id
      * @return
      */
-    @GetMapping(value = "/account/{id}")
+    @GetMapping(value = "/account/read/{id}")
     Result<AccountDTO> getAccountById(@PathVariable("id") Long id);
+
+    /**
+     * 注册
+     *
+     * @param accountRegDTO
+     * @return
+     */
+    @PostMapping("/account/register")
+    Result register(@RequestBody AccountRegDTO accountRegDTO);
+
+    /**
+     * 从其他平台同步已注册用户信息
+     * 区别于普通注册:密码已经是加密后的密文
+     *
+     * @param accountSyncDTO
+     * @return
+     */
+    @PostMapping("/account/register/copy")
+    Result copyRegistration(@RequestBody AccountCopyDTO accountSyncDTO);
+
+    /**
+     * 修改
+     *
+     * @param accountUpdateDTO
+     * @return
+     */
+    @PostMapping("/account/update")
+    Result update(@RequestBody AccountUpdateDTO accountUpdateDTO);
 }

+ 70 - 0
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/api/CompanyApi.java

@@ -0,0 +1,70 @@
+package com.usoftchina.saas.account.api;
+
+import com.usoftchina.saas.account.dto.CompanyCopyDTO;
+import com.usoftchina.saas.account.dto.CompanyDTO;
+import com.usoftchina.saas.account.dto.CompanyRegDTO;
+import com.usoftchina.saas.base.Result;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author yingp
+ * @date 2018/11/15
+ */
+@FeignClient(name = "account-server")
+public interface CompanyApi {
+
+    /**
+     * 注册
+     *
+     * @param companyRegDTO
+     * @return
+     */
+    @PostMapping("/company/register")
+    Result register(@RequestBody CompanyRegDTO companyRegDTO);
+
+    /**
+     * 从其他平台复制已注册企业信息
+     *
+     * @param companyCopyDTO
+     * @return
+     */
+    @PostMapping("/company/register/copy")
+    Result copyRegistration(@RequestBody CompanyCopyDTO companyCopyDTO);
+
+    /**
+     * 按名称查找
+     *
+     * @param name
+     * @return
+     */
+    @GetMapping(path = "/company/read", params = "name")
+    Result<CompanyDTO> getCompanyByName(@RequestParam String name);
+
+    /**
+     * 按商业登记证号查找
+     *
+     * @param businessCode
+     * @return
+     */
+    @GetMapping(path = "/company/read", params = "businessCode")
+    Result<CompanyDTO> getCompanyByBusinessCode(@RequestParam String businessCode);
+
+    /**
+     * 按企业uu查找
+     *
+     * @param uu
+     * @return
+     */
+    @GetMapping(path = "/company/read", params = "uu")
+    Result<CompanyDTO> getCompanyByUu(@RequestParam Long uu);
+
+    /**
+     * 按ID查找
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping(path = "/company/read/{id}")
+    Result<CompanyDTO> getCompanyById(@PathVariable Long id);
+}

+ 22 - 7
base-servers/account/account-api/src/main/java/com/usoftchina/saas/account/cache/AccountCache.java

@@ -18,18 +18,26 @@ import java.util.function.Supplier;
  * @date 2018/11/1
  */
 public class AccountCache extends RedisHashCache<String, String, String> {
-    private final long id;
+    private Long id;
+    private Long uu;
 
     private static final RedisTemplate<String, String> REDIS_TEMPLATE = SpringContextHolder.getBean("redisTemplate", RedisTemplate.class);
     private AccountApi accountApi;
 
-    private AccountCache(long id) {
+    private AccountCache() {
         super(() -> REDIS_TEMPLATE);
-        this.id = id;
     }
 
     public static AccountCache of(long id) {
-        return new AccountCache(id);
+        AccountCache cache = new AccountCache();
+        cache.id = id;
+        return cache;
+    }
+
+    public static AccountCache uu(long uu) {
+        AccountCache cache = new AccountCache();
+        cache.uu = uu;
+        return cache;
     }
 
     /**
@@ -38,12 +46,12 @@ public class AccountCache extends RedisHashCache<String, String, String> {
      * @return
      */
     public static AccountCache current() {
-        return new AccountCache(BaseContextHolder.getUserId());
+        return of(BaseContextHolder.getUserId());
     }
 
     @Override
     protected String field() {
-        return String.valueOf(id);
+        return String.valueOf(null == id ? ("uu:" + uu) : ("id:" + id));
     }
 
     @Override
@@ -57,7 +65,14 @@ public class AccountCache extends RedisHashCache<String, String, String> {
             if (null == accountApi) {
                 accountApi = SpringContextHolder.getBean(AccountApi.class);
             }
-            Result<AccountDTO> result = accountApi.getAccountById(id);
+            Result<AccountDTO> result = null;
+            if (null != id && id > 0) {
+                result = accountApi.getAccountById(id);
+            } else if (null != uu) {
+                result = accountApi.getAccountByUu(uu);
+            } else {
+                return null;
+            }
             if (result.isSuccess()) {
                 return JsonUtils.toJsonString(result.getData());
             }

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