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

客户期初设置代码提交

hy 6 жил өмнө
parent
commit
8639c60e5d
22 өөрчлөгдсөн 1492 нэмэгдсэн , 92 устгасан
  1. 2 2
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  2. 0 55
      applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendApamountDTO.java
  3. 0 22
      applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendApamountListDTO.java
  4. 139 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustAramount.java
  5. 69 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustAramountList.java
  6. 80 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/VendApamount.java
  7. 0 2
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/VendApamountList.java
  8. 70 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustAramountController.java
  9. 32 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustAramountMapper.java
  10. 4 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustomerMapper.java
  11. 0 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendApamountMapper.java
  12. 28 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustAramountService.java
  13. 316 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustAramountServiceImpl.java
  14. 5 8
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendApamountServiceImpl.java
  15. 303 0
      applications/document/document-server/src/main/resources/mapper/CustAramountMapper.xml
  16. 13 0
      applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml
  17. 113 0
      frontend/saas-web/app/view/document/custaramount/AddWindow.js
  18. 177 0
      frontend/saas-web/app/view/document/custaramount/BasePanel.js
  19. 10 0
      frontend/saas-web/app/view/document/custaramount/BasePanelController.js
  20. 9 0
      frontend/saas-web/app/view/document/custaramount/BasePanelModel.js
  21. 117 0
      frontend/saas-web/app/view/document/custaramount/Window.js
  22. 5 0
      frontend/saas-web/resources/json/navigation.json

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

@@ -44,11 +44,11 @@ public enum BizExceptionCode implements BaseExceptionCode {
     BIZ_IMPORT_ERROREXCEL(79318, "请导入对应的单据数据"),
     BIZ_ENABLE_B2B(79350, "未启用B2B"),
     BIZ_TURNPURCHASE_BEFORE(79351, "请先获取UU号(供应商:<u>%s</u>),再进行下单操作"),
-    BIZ_NOVENDOR_SAVE(79352, "选择的供应商不存在或未启用"),
+    BIZ_NOVENDOR_SAVE(79352, "选择的供应商不存在或已禁用"),
     BIZ_NOCURRENCY_SAVE(79353, "选择的币别不存在"),
     BIZ_NOPERIOD_UPDATE(79354, "期初日期所在期间未结账,不能修改期初金额"),
     BIZ_NOPERIOD_DELETE(79355, "期初日期所在期间未结账,不能删除"),
-    BIZ_NOVENDOR_IMPORT(79356, "选择的供应商不存在或未启用"),
+    BIZ_NOCUST_SAVE(79356, "选择的客户不存在或已禁用"),
 
     NO_OPRATIONDATA(79400,"无可操作单据"),
     NULL_DATA(23232,"无数据"),

+ 0 - 55
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendApamountDTO.java

@@ -1,55 +0,0 @@
-package com.usoftchina.saas.document.dto;
-
-import com.usoftchina.saas.base.dto.CommonBaseDTO;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-@Data
-public class VendApamountDTO extends CommonBaseDTO implements Serializable{
-
-
-    /**
-     * 供应商id
-     */
-    private long va_vendid;
-
-    /**
-     * 供应商编号
-     */
-    private String va_vendcode;
-    /**
-     * 供应商名称
-     */
-    private String va_vendname;
-    /**
-     * 币别
-     */
-    private String va_currency;
-    /**
-     * 期初日期
-     */
-    private Date va_begindate;
-    /**
-     * 期初应付
-     */
-    private Double va_beginapamount;
-    /**
-     * 期初预付
-     */
-    private Double va_beginprepayamount;
-    /**
-     * 应付金额
-     */
-    private Double va_payamount;
-    /**
-     * 预付金额
-     */
-    private Double va_preamount;
-    /**
-     * 应付余额
-     */
-    private Double va_leftamount;
-
-}

+ 0 - 22
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/VendApamountListDTO.java

@@ -1,22 +0,0 @@
-package com.usoftchina.saas.document.dto;
-
-import com.usoftchina.saas.commons.dto.BaseFormDTO;
-import com.usoftchina.saas.document.entities.VendApamount;
-import com.usoftchina.saas.document.entities.Vendor;
-import com.usoftchina.saas.document.entities.Vendorcontact;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class VendApamountListDTO extends BaseFormDTO implements Serializable {
-
-    private VendApamount main;
-
-    public VendApamount getMain() {
-        return main;
-    }
-
-    public void setMain(VendApamount main) {
-        this.main = main;
-    }
-}

+ 139 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustAramount.java

@@ -0,0 +1,139 @@
+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 hey
+ * @Date 2019/03/11
+ */
+
+@Data
+public class CustAramount extends CommonBaseEntity implements Serializable{
+
+    /**
+     * 客户id
+     */
+    private long ca_custid;
+
+    /**
+     * 客户编号
+     */
+    private String ca_custcode;
+    /**
+     * 客户名称
+     */
+    private String ca_custname;
+    /**
+     * 币别
+     */
+    private String ca_currency;
+    /**
+     * 期初日期
+     */
+    private Date ca_begindate;
+    /**
+     * 期初应收
+     */
+    private Double ca_beginaramount;
+    /**
+     * 期初预收
+     */
+    private Double ca_beginprerecamount;
+    /**
+     * 应收金额
+     */
+    private Double ca_recamount;
+    /**
+     * 预收金额
+     */
+    private Double ca_preamount;
+    /**
+     * 应付余额
+     */
+    private Double ca_leftamount;
+
+    public long getCa_custid() {
+        return ca_custid;
+    }
+
+    public void setCa_custid(long ca_custid) {
+        this.ca_custid = ca_custid;
+    }
+
+    public String getCa_custcode() {
+        return ca_custcode;
+    }
+
+    public void setCa_custcode(String ca_custcode) {
+        this.ca_custcode = ca_custcode;
+    }
+
+    public String getCa_custname() {
+        return ca_custname;
+    }
+
+    public void setCa_custname(String ca_custname) {
+        this.ca_custname = ca_custname;
+    }
+
+    public String getCa_currency() {
+        return ca_currency;
+    }
+
+    public void setCa_currency(String ca_currency) {
+        this.ca_currency = ca_currency;
+    }
+
+    public Date getCa_begindate() {
+        return ca_begindate;
+    }
+
+    public void setCa_begindate(Date ca_begindate) {
+        this.ca_begindate = ca_begindate;
+    }
+
+    public Double getCa_beginaramount() {
+        return ca_beginaramount;
+    }
+
+    public void setCa_beginaramount(Double ca_beginaramount) {
+        this.ca_beginaramount = ca_beginaramount;
+    }
+
+    public Double getCa_beginprerecamount() {
+        return ca_beginprerecamount;
+    }
+
+    public void setCa_beginprerecamount(Double ca_beginprerecamount) {
+        this.ca_beginprerecamount = ca_beginprerecamount;
+    }
+
+    public Double getCa_recamount() {
+        return ca_recamount;
+    }
+
+    public void setCa_recamount(Double ca_recamount) {
+        this.ca_recamount = ca_recamount;
+    }
+
+    public Double getCa_preamount() {
+        return ca_preamount;
+    }
+
+    public void setCa_preamount(Double ca_preamount) {
+        this.ca_preamount = ca_preamount;
+    }
+
+    public Double getCa_leftamount() {
+        return ca_leftamount;
+    }
+
+    public void setCa_leftamount(Double ca_leftamount) {
+        this.ca_leftamount = ca_leftamount;
+    }
+}

+ 69 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustAramountList.java

@@ -0,0 +1,69 @@
+package com.usoftchina.saas.document.entities;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class CustAramountList implements Serializable {
+
+    /* 主表字段 */
+    private Long id;
+
+    /**
+     * 客户id
+     */
+    private long ca_custid;
+
+    /**
+     * 客户编号
+     */
+    private String ca_custcode;
+    /**
+     * 客户名称
+     */
+    private String ca_custname;
+    /**
+     * 币别
+     */
+    private String ca_currency;
+    /**
+     * 期初日期
+     */
+    private Date ca_begindate;
+    /**
+     * 期初应收
+     */
+    private Double ca_beginaramount;
+    /**
+     * 期初预收
+     */
+    private Double ca_beginprerecamount;
+    /**
+     * 应收金额
+     */
+    private Double ca_recamount;
+    /**
+     * 预收金额
+     */
+    private Double ca_preamount;
+    /**
+     * 应付余额
+     */
+    private Double ca_leftamount;
+
+    private Integer companyId;
+
+    private Integer updaterId;
+
+    private Date updateTime;
+
+    private String creatorName;
+
+    private Integer creatorId;
+
+    private Date createTime;
+
+    private String updaterName;
+}

+ 80 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/VendApamount.java

@@ -56,4 +56,84 @@ public class VendApamount extends CommonBaseEntity implements Serializable{
      * 应付余额
      */
     private Double va_leftamount;
+
+    public long getVa_vendid() {
+        return va_vendid;
+    }
+
+    public void setVa_vendid(long va_vendid) {
+        this.va_vendid = va_vendid;
+    }
+
+    public String getVa_vendcode() {
+        return va_vendcode;
+    }
+
+    public void setVa_vendcode(String va_vendcode) {
+        this.va_vendcode = va_vendcode;
+    }
+
+    public String getVa_vendname() {
+        return va_vendname;
+    }
+
+    public void setVa_vendname(String va_vendname) {
+        this.va_vendname = va_vendname;
+    }
+
+    public String getVa_currency() {
+        return va_currency;
+    }
+
+    public void setVa_currency(String va_currency) {
+        this.va_currency = va_currency;
+    }
+
+    public Date getVa_begindate() {
+        return va_begindate;
+    }
+
+    public void setVa_begindate(Date va_begindate) {
+        this.va_begindate = va_begindate;
+    }
+
+    public Double getVa_beginapamount() {
+        return va_beginapamount;
+    }
+
+    public void setVa_beginapamount(Double va_beginapamount) {
+        this.va_beginapamount = va_beginapamount;
+    }
+
+    public Double getVa_beginprepayamount() {
+        return va_beginprepayamount;
+    }
+
+    public void setVa_beginprepayamount(Double va_beginprepayamount) {
+        this.va_beginprepayamount = va_beginprepayamount;
+    }
+
+    public Double getVa_payamount() {
+        return va_payamount;
+    }
+
+    public void setVa_payamount(Double va_payamount) {
+        this.va_payamount = va_payamount;
+    }
+
+    public Double getVa_preamount() {
+        return va_preamount;
+    }
+
+    public void setVa_preamount(Double va_preamount) {
+        this.va_preamount = va_preamount;
+    }
+
+    public Double getVa_leftamount() {
+        return va_leftamount;
+    }
+
+    public void setVa_leftamount(Double va_leftamount) {
+        this.va_leftamount = va_leftamount;
+    }
 }

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

@@ -11,8 +11,6 @@ public class VendApamountList implements Serializable {
     /* 主表字段 */
     private Long id;
 
-    private Integer va_id;
-
     private Integer va_vendid;
 
     private String va_vendcode;

+ 70 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustAramountController.java

@@ -0,0 +1,70 @@
+package com.usoftchina.saas.document.controller;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.document.entities.CustAramount;
+import com.usoftchina.saas.document.entities.CustAramountList;
+import com.usoftchina.saas.document.service.CustAramountService;
+import com.usoftchina.saas.page.PageRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/custaramount")
+public class CustAramountController {
+
+    @Autowired
+    private CustAramountService custAramountService;
+
+    /**
+     * 获取 客户期初列表数据,包含客户期初表数据
+     * @param listReqDTO
+     * @return
+     */
+    @GetMapping("/list")
+    public Result<PageInfo<CustAramountList>> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO){
+        return Result.success(custAramountService.getListDataByCondition(page, listReqDTO));
+    }
+
+    /**
+     * 保存
+     * @param custAramount
+     * @return
+     */
+    @PostMapping("/save")
+    public Result save(@RequestBody CustAramount custAramount){
+        return Result.success(custAramountService.saveData(custAramount));
+    }
+
+    /**
+     * 删除
+     * @param id
+     * @return
+     */
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id){
+        custAramountService.deleteById(id);
+        return Result.success();
+    }
+
+    /**
+     * 批量删除
+     * @param baseDTOs
+     * @return
+     */
+    @PostMapping("/batchDelete")
+    public Result batchDelete(@RequestBody BatchDealBaseDTO baseDTOs){
+        custAramountService.batchDelete(baseDTOs);
+        return Result.success();
+    }
+
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        custAramountService.saveToFormal(id, update);
+        return Result.success();
+    }
+
+}

+ 32 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustAramountMapper.java

@@ -0,0 +1,32 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.document.entities.CustAramount;
+import com.usoftchina.saas.document.entities.CustAramountList;
+import com.usoftchina.saas.document.entities.VendApamount;
+import com.usoftchina.saas.document.entities.VendApamountList;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface CustAramountMapper extends CommonBaseMapper<CustAramount> {
+
+    List<CustAramountList> getListDataByCondition(@Param("condition") String condition, @Param("companyId") Long companyId);
+
+    int hasCustCode(@Param("name") String name, @Param("companyId") Long companyId);
+
+    int hasCurrency(@Param("name") String name, @Param("companyId") Long companyId);
+
+    int validCustCodeAndCurrency(@Param("custCode") String custCode, @Param("companyId") Long companyId, @Param("currency") String currency, @Param("id") Long id);
+
+    void check(Map<String, Object> map);
+
+    String selectPeriod(@Param("companyId") Long companyId);
+
+    int checkBeginData(@Param("pd_detno") String pd_detno, @Param("companyId") Long companyId);
+
+    CustAramount getCustAramount(@Param("id") Long id, @Param("companyId") Long companyId);
+
+    int hasCustNameByCode(@Param("custCode") String custCode, @Param("companyId") Long companyId, @Param("custName") String custName);
+}

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

@@ -2,6 +2,7 @@ package com.usoftchina.saas.document.mapper;
 
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.commons.dto.ComboDTO;
+import com.usoftchina.saas.document.dto.CustomerDTO;
 import com.usoftchina.saas.document.entities.Customer;
 import org.apache.ibatis.annotations.Param;
 
@@ -38,5 +39,7 @@ public interface CustomerMapper extends CommonBaseMapper<Customer> {
 
     Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
 
-    int updateCustleftamountByPrimaryKey(Integer cu_id);
+    int updateCustleftamountByPrimaryKey(Long cu_id);
+
+    List<Customer> getCustomersByCondition(@Param("condition") String condition, @Param("companyId") Long companyId);
 }

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

@@ -1,12 +1,10 @@
 package com.usoftchina.saas.document.mapper;
 
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
-import com.usoftchina.saas.document.dto.VendApamountDTO;
 import com.usoftchina.saas.document.entities.VendApamount;
 import com.usoftchina.saas.document.entities.VendApamountList;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 

+ 28 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustAramountService.java

@@ -0,0 +1,28 @@
+package com.usoftchina.saas.document.service;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.base.service.CommonBaseService;
+import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.document.entities.CustAramount;
+import com.usoftchina.saas.document.entities.CustAramountList;
+import com.usoftchina.saas.document.entities.VendApamount;
+import com.usoftchina.saas.document.entities.VendApamountList;
+import com.usoftchina.saas.document.mapper.CustAramountMapper;
+import com.usoftchina.saas.document.mapper.VendApamountMapper;
+import com.usoftchina.saas.page.PageRequest;
+
+
+public interface CustAramountService extends CommonBaseService<CustAramountMapper, CustAramount>{
+
+    PageInfo<CustAramountList> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO);
+
+    DocBaseDTO saveData(CustAramount custAramount);
+
+    boolean batchDelete(BatchDealBaseDTO baseDTOs);
+
+    void deleteById(Long id);
+
+    void saveToFormal(Integer id, boolean update);
+}

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

@@ -0,0 +1,316 @@
+package com.usoftchina.saas.document.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.account.api.CompanyApi;
+import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.commons.api.MessageLogService;
+import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.po.DataImportDetail;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.entities.*;
+import com.usoftchina.saas.document.entities.CustAramount;
+import com.usoftchina.saas.document.entities.CustAramountList;
+import com.usoftchina.saas.document.mapper.*;
+import com.usoftchina.saas.document.service.CustAramountService;
+import com.usoftchina.saas.document.service.CustAramountService;
+import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.page.PageRequest;
+import com.usoftchina.saas.utils.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author hey
+ * @Date 2019/03/11
+ */
+@Service
+public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountMapper, CustAramount> implements CustAramountService {
+
+    @Autowired
+    private MessageLogService messageLogService;
+    @Autowired
+    private CustomerMapper customerMapper;
+    @Autowired
+    private DataImportMapper dataImportMapper;
+    @Autowired
+    private CompanyApi companyApi;
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(CustAramountServiceImpl.class);
+
+    public PageInfo<CustAramountList> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO){
+        //设置分页
+        if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
+            page = new PageRequest();
+            page.setNumber(1);
+            page.setSize(10);
+        }
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        //取分页信息
+        String condition = listReqDTO.getFinalCondition();
+        List<CustAramountList> list = getMapper().getListDataByCondition(condition, BaseContextHolder.getCompanyId());
+        PageInfo<CustAramountList> pageInfo = new PageInfo<CustAramountList>(list);
+        return pageInfo;
+    }
+
+    @Override
+    public boolean batchDelete(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return false;
+        }
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            deleteById(base.getId());
+        }
+        return true;
+    }
+
+    public void deleteById(Long id) {
+        if(id != null && id > 0){
+            CustAramount custAramount = getMapper().getCustAramount(id,BaseContextHolder.getCompanyId());
+            validMoney(custAramount);
+            SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+            //判断本次期间是否已结账,结账了就不能删除
+            int checkBeginData = getMapper().checkBeginData(sdf.format(custAramount.getCa_begindate()),BaseContextHolder.getCompanyId());
+            if(checkBeginData > 0){
+                throw new BizException(BizExceptionCode.BIZ_NOPERIOD_DELETE);
+            }
+
+            getMapper().deleteByPrimaryKey(id);
+            //记录LOG
+            messageLogService.delete(generateMsgObj(id));
+        }
+    }
+
+    public void validMoney(CustAramount custAramount){
+        //校验是否可以修改或新增客户期初
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("v_id",custAramount.getCa_custid());//客户ID
+        map.put("v_code", custAramount.getCa_custcode());//客户编号
+        map.put("v_type","custCurrency");
+        map.put("v_currency",custAramount.getCa_currency());
+        map.put("v_companyid",BaseContextHolder.getCompanyId());
+        map.put("v_res","");
+        getMapper().check(map);
+        Object result =  map.get("v_res");
+        if(!StringUtils.isEmpty(result)){
+            throw new BizException(-999999,result.toString());
+        }
+    }
+
+    public DocBaseDTO saveData(CustAramount custAramount){
+        DocBaseDTO docBaseDTO = null;
+        if(custAramount.getCa_recamount()==null){custAramount.setCa_recamount(0.00);}
+        if(custAramount.getCa_beginaramount()==null){custAramount.setCa_beginaramount(0.00);}
+        if(custAramount.getCa_beginprerecamount()==null){custAramount.setCa_beginprerecamount(0.00);}
+        if(custAramount.getCa_preamount()==null){custAramount.setCa_preamount(0.00);}
+        //判断是否已存在数据
+        boolean hasData = hasData(custAramount.getCa_custcode(),custAramount.getCa_currency(),custAramount.getId());
+        if(hasData){
+            validMoney(custAramount);
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+        //更新余额
+        custAramount.setCa_leftamount(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()+custAramount.getCa_recamount()-custAramount.getCa_preamount());
+
+        if(custAramount.getId() == 0){
+            //新增
+            custAramount.setCompanyId(BaseContextHolder.getCompanyId());
+            custAramount.setCreatorId(BaseContextHolder.getUserId());
+            custAramount.setCreateTime(new Date());
+            custAramount.setCreatorName(BaseContextHolder.getUserName());
+
+            //获取当前期间
+            String now = getMapper().selectPeriod(BaseContextHolder.getCompanyId());
+            Date date = null;
+            try {
+                date = sdf.parse(now);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(date);
+            calendar.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
+            custAramount.setCa_begindate(calendar.getTime());
+
+            getMapper().insertSelective(custAramount);
+            //记录LOG
+            docBaseDTO = generateMsgObj(custAramount.getId());
+            messageLogService.save(docBaseDTO);
+        }else{
+            //修改
+            custAramount.setUpdaterId(BaseContextHolder.getUserId());
+            custAramount.setUpdateTime(new Date());
+            //期初日期是否已结账
+            int checkBeginData = getMapper().checkBeginData(sdf.format(custAramount.getCa_begindate()),BaseContextHolder.getCompanyId());
+            if(checkBeginData > 0){
+                throw new BizException(BizExceptionCode.BIZ_NOPERIOD_UPDATE);
+            }
+            getMapper().updateByPrimaryKeySelective(custAramount);
+            //记录LOG
+            docBaseDTO = generateMsgObj(custAramount.getId());
+            messageLogService.update(docBaseDTO);
+        }
+        //调用更新
+        customerMapper.updateCustleftamountByPrimaryKey(custAramount.getCa_custid());
+        return docBaseDTO;
+    }
+
+
+    private boolean hasData(String custCode, String currency,Long id){
+        int hasCustCode = getMapper().hasCustCode(custCode, BaseContextHolder.getCompanyId());
+        if (hasCustCode == 0){
+            throw new BizException(BizExceptionCode.BIZ_NOCUST_SAVE);
+        }
+        int hasCurrency = getMapper().hasCurrency(currency, BaseContextHolder.getCompanyId());
+        if (hasCurrency == 0){
+            throw new BizException(BizExceptionCode.BIZ_NOCURRENCY_SAVE);
+        }
+        int count = getMapper().validCustCodeAndCurrency(custCode, BaseContextHolder.getCompanyId(), currency,id);
+        if (count > 0){
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 构造 记录日志对象
+     * @param id
+     * @return
+     */
+    private DocBaseDTO generateMsgObj(Long id){
+        return new DocBaseDTO(id, "", "CustAramount");
+    }
+
+    /**
+     * 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;
+    }
+
+    @Override
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        StringBuilder err = new StringBuilder();
+        List<CustAramount> list = new ArrayList<>();
+        CustAramount listDTO = null;
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        if (!CollectionUtils.isEmpty(details)) {
+            int i = 0;
+            for (DataImportDetail detail : details) {
+                //数据验证
+                if (StringUtils.isEmpty(detail)) {
+                    throw new BizException(BizExceptionCode.BIZ_REPORT_NOTCORRECT);
+                }
+                CustAramount custAramount = JSONObject.parseObject(detail.getDd_maindata(), CustAramount.class);
+                if(custAramount.getId()==null){custAramount.setId(0L);}
+                if(custAramount.getCa_recamount()==null){custAramount.setCa_recamount(0.00);}
+                if(custAramount.getCa_beginaramount()==null){custAramount.setCa_beginaramount(0.00);}
+                if(custAramount.getCa_beginprerecamount()==null){custAramount.setCa_beginprerecamount(0.00);}
+                if(custAramount.getCa_preamount()==null){custAramount.setCa_preamount(0.00);}
+                //判断是否已存在数据
+                List<Customer> customers = customerMapper.getCustomersByCondition("cu_statuscode = 'ENABLE' AND cu_code = '"+custAramount.getCa_custcode()+"'",BaseContextHolder.getCompanyId());
+                if (customers.size() == 0){
+                    err.append("第" + (i + 3) + "行 : 客户编号不存在或该客户状态为禁用!<br/> ");
+                }else{
+                    int hasCustNameByCode = getMapper().hasCustNameByCode(custAramount.getCa_custcode(),BaseContextHolder.getCompanyId(),custAramount.getCa_custname());
+                    if(hasCustNameByCode==0){
+                        err.append("第" + (i + 3) + "行 : 客户名称与编号不匹配!<br/> ");
+                    }
+                    custAramount.setCa_custid(customers.get(0).getId());
+                }
+                int hasCurrency = getMapper().hasCurrency(custAramount.getCa_currency(), BaseContextHolder.getCompanyId());
+                if (hasCurrency == 0){
+                    err.append("第" + (i + 3) + "行 : 币别不存在!<br/> ");
+                }
+                int count = getMapper().validCustCodeAndCurrency(custAramount.getCa_custcode(), BaseContextHolder.getCompanyId(), custAramount.getCa_currency(),0L);
+                if (count > 0){
+                    //校验是否可以修改或新增客户期初
+                    Map<String, Object> map = new HashMap<String, Object>();
+                    map.put("v_id",custAramount.getCa_custid());//客户ID
+                    map.put("v_code", custAramount.getCa_custcode());//客户编号
+                    map.put("v_type","custCurrency");
+                    map.put("v_currency",custAramount.getCa_currency());
+                    map.put("v_companyid",BaseContextHolder.getCompanyId());
+                    map.put("v_res","");
+                    getMapper().check(map);
+                    Object result =  map.get("v_res");
+                    if(!StringUtils.isEmpty(result)){
+                        err.append("第" + (i + 3) + "行 : "+result.toString()+"<br/> ");
+                    }
+                }
+                list.add(custAramount);
+                i++;
+            }
+            if (err.length() > 0) {
+                dataImportMapper.updateDataImportError(err.toString(), id);
+                throw new BizException(12345, err.toString());
+            }
+            for (CustAramount  custAramount : list) {
+                //新增
+                custAramount.setCompanyId(BaseContextHolder.getCompanyId());
+                custAramount.setCreatorId(BaseContextHolder.getUserId());
+                custAramount.setCreateTime(new Date());
+                custAramount.setCreatorName(BaseContextHolder.getUserName());
+                SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+                //更新余额
+                custAramount.setCa_leftamount(custAramount.getCa_beginaramount()-custAramount.getCa_beginprerecamount()+custAramount.getCa_recamount()-custAramount.getCa_preamount());
+                //获取当前期间
+                String now = getMapper().selectPeriod(BaseContextHolder.getCompanyId());
+                Date date = null;
+                try {
+                    date = sdf.parse(now);
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(date);
+                calendar.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
+                custAramount.setCa_begindate(calendar.getTime());
+                getMapper().insertSelective(custAramount);
+                customerMapper.updateCustleftamountByPrimaryKey(custAramount.getCa_custid());
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+}

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

@@ -14,8 +14,6 @@ import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.DataImportDetail;
 import com.usoftchina.saas.context.BaseContextHolder;
-import com.usoftchina.saas.document.dto.ProductListDTO;
-import com.usoftchina.saas.document.dto.VendApamountListDTO;
 import com.usoftchina.saas.document.entities.*;
 import com.usoftchina.saas.document.mapper.*;
 import com.usoftchina.saas.document.service.VendApamountService;
@@ -41,8 +39,6 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
     @Autowired
     private MessageLogService messageLogService;
     @Autowired
-    private VendApamountMapper vendApamountMapper;
-    @Autowired
     private VendorMapper vendorMapper;
     @Autowired
     private DataImportMapper dataImportMapper;
@@ -113,7 +109,6 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
 
     public DocBaseDTO saveData(VendApamount vendApamount){
         DocBaseDTO docBaseDTO = null;
-        if(vendApamount.getId()==null){vendApamount.setId(0L);}
         if(vendApamount.getVa_payamount()==null){vendApamount.setVa_payamount(0.00);}
         if(vendApamount.getVa_beginapamount()==null){vendApamount.setVa_beginapamount(0.00);}
         if(vendApamount.getVa_beginprepayamount()==null){vendApamount.setVa_beginprepayamount(0.00);}
@@ -127,7 +122,7 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
         //更新余额
         vendApamount.setVa_leftamount(vendApamount.getVa_beginapamount()-vendApamount.getVa_beginprepayamount()+vendApamount.getVa_payamount()-vendApamount.getVa_preamount());
 
-        if(vendApamount.getId() == 0 || vendApamount.getId() == null){
+        if(vendApamount.getId() == 0){
             //新增
             vendApamount.setCompanyId(BaseContextHolder.getCompanyId());
             vendApamount.setCreatorId(BaseContextHolder.getUserId());
@@ -254,7 +249,7 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
                 //判断是否已存在数据
                 List<VendorDTO> vendors = vendorMapper.getVendorsByCondition("ve_statuscode = 'ENABLE' AND ve_code = '"+vendApamount.getVa_vendcode()+"'",BaseContextHolder.getCompanyId());
                 if (vendors.size() == 0){
-                    err.append("第" + (i + 3) + "行 : 供应商编号不存在或该供应商状态未启用!<br/> ");
+                    err.append("第" + (i + 3) + "行 : 供应商编号不存在或该供应商已禁用!<br/> ");
                 }else{
                     int hasVendNameByCode = getMapper().hasVendNameByCode(vendApamount.getVa_vendcode(),BaseContextHolder.getCompanyId(),vendApamount.getVa_vendname());
                     if(hasVendNameByCode==0){
@@ -296,6 +291,8 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
                 vendApamount.setCreateTime(new Date());
                 vendApamount.setCreatorName(BaseContextHolder.getUserName());
                 SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
+                //更新余额
+                vendApamount.setVa_leftamount(vendApamount.getVa_beginapamount()-vendApamount.getVa_beginprepayamount()+vendApamount.getVa_payamount()-vendApamount.getVa_preamount());
                 //获取当前期间
                 String now = getMapper().selectPeriod(BaseContextHolder.getCompanyId());
                 Date date = null;
@@ -308,8 +305,8 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
                 calendar.setTime(date);
                 calendar.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
                 vendApamount.setVa_begindate(calendar.getTime());
-
                 getMapper().insertSelective(vendApamount);
+                vendorMapper.updateVendleftamountByPrimaryKey(vendApamount.getVa_vendid());
             }
             dataImportMapper.updateDataImport(id);
         }

+ 303 - 0
applications/document/document-server/src/main/resources/mapper/CustAramountMapper.xml

@@ -0,0 +1,303 @@
+<?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.CustAramountMapper">
+
+    <resultMap id="CustAramountResultMapper" type="com.usoftchina.saas.document.entities.CustAramount">
+        <id column="ca_id" jdbcType="INTEGER" property="id" />
+        <result column="ca_custid" jdbcType="INTEGER" property="ca_custid" />
+        <result column="ca_custcode" jdbcType="VARCHAR" property="ca_custcode" />
+        <result column="ca_custname" jdbcType="VARCHAR" property="ca_custname" />
+        <result column="ca_currency" jdbcType="VARCHAR" property="ca_currency" />
+        <result column="ca_begindate" jdbcType="TIMESTAMP" property="ca_begindate" />
+        <result column="ca_beginaramount" jdbcType="DOUBLE" property="ca_beginaramount" />
+        <result column="ca_beginprerecamount" jdbcType="DOUBLE" property="ca_beginprerecamount" />
+        <result column="ca_recamount" jdbcType="DOUBLE" property="ca_recamount" />
+        <result column="ca_preamount" jdbcType="DOUBLE" property="ca_preamount" />
+        <result column="ca_leftamount" jdbcType="DOUBLE" property="ca_leftamount" />
+        <result column="companyId" jdbcType="INTEGER" property="companyId" />
+        <result column="updaterId" jdbcType="INTEGER" property="updaterId" />
+        <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
+        <result column="creatorName" jdbcType="VARCHAR" property="creatorName" />
+        <result column="creatorId" jdbcType="INTEGER" property="creatorId" />
+        <result column="createTime" jdbcType="TIMESTAMP" property="createTime" />
+        <result column="updaterName" jdbcType="VARCHAR" property="updaterName" />
+    </resultMap>
+
+    <resultMap id="CustAramountListResultMapper" type="com.usoftchina.saas.document.entities.CustAramountList">
+        <id column="ca_id" jdbcType="INTEGER" property="id" />
+        <result column="ca_custid" jdbcType="INTEGER" property="ca_custid" />
+        <result column="ca_custcode" jdbcType="VARCHAR" property="ca_custcode" />
+        <result column="ca_custname" jdbcType="VARCHAR" property="ca_custname" />
+        <result column="ca_currency" jdbcType="VARCHAR" property="ca_currency" />
+        <result column="ca_begindate" jdbcType="TIMESTAMP" property="ca_begindate" />
+        <result column="ca_beginaramount" jdbcType="DOUBLE" property="ca_beginaramount" />
+        <result column="ca_beginprerecamount" jdbcType="DOUBLE" property="ca_beginprerecamount" />
+        <result column="ca_recamount" jdbcType="DOUBLE" property="ca_recamount" />
+        <result column="ca_preamount" jdbcType="DOUBLE" property="ca_preamount" />
+        <result column="ca_leftamount" jdbcType="DOUBLE" property="ca_leftamount" />
+    </resultMap>
+
+    <select id="getListDataByCondition" resultMap="CustAramountListResultMapper">
+        SELECT * FROM CustAramount
+        <where>
+            <if test="condition!=null">
+                ${condition}
+            </if>
+            AND CustAramount.COMPANYID = #{companyId}
+            AND CustAramount.ca_BEGINDATE IS NOT NULL
+        </where>
+        order by ca_ID DESC
+    </select>
+
+    <sql id="Base_Column_List">
+        ca_id, ca_custid, ca_custcode, ca_custname, ca_currency, ca_begindate, ca_beginaramount,
+        ca_beginprerecamount, ca_recamount, ca_preamount, ca_leftamount, companyId, updaterId,
+        updateTime, creatorName, creatorId, createTime, updaterName
+    </sql>
+
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="CustAramountResultMapper">
+        select
+        <include refid="Base_Column_List" />
+        from CustAramount
+        where ca_id = #{id}
+    </select>
+
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete from CustAramount
+        where ca_id = #{id}
+    </delete>
+
+    <select id="selectPeriod" resultType="string">
+        select PD_DETNO from periodsdetail where companyid=#{companyId} and pd_detno is not null and pd_status=0 order by PD_DETNO LIMIT 1;
+    </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_companyid" jdbcType="INTEGER" mode="IN" />
+        <parameter property="v_res" jdbcType="VARCHAR" mode="OUT" />
+    </parameterMap>
+
+    <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.CustAramount">
+        <selectKey resultType="java.lang.Long" keyProperty="id">
+            SELECT LAST_INSERT_ID() AS ID
+        </selectKey>
+        insert into CustAramount
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="ca_custid != null">
+                ca_custid,
+            </if>
+            <if test="ca_custcode != null">
+                ca_custcode,
+            </if>
+            <if test="ca_custname != null">
+                ca_custname,
+            </if>
+            <if test="ca_currency != null">
+                ca_currency,
+            </if>
+            <if test="ca_begindate != null">
+                ca_begindate,
+            </if>
+            <if test="ca_beginaramount != null">
+                ca_beginaramount,
+            </if>
+            <if test="ca_beginprerecamount != null">
+                ca_beginprerecamount,
+            </if>
+            <if test="ca_recamount != null">
+                ca_recamount,
+            </if>
+            <if test="ca_preamount != null">
+                ca_preamount,
+            </if>
+            <if test="ca_leftamount != null">
+                ca_leftamount,
+            </if>
+            <if test="companyId != null">
+                companyId,
+            </if>
+            <if test="updaterId != null">
+                updaterId,
+            </if>
+            <if test="updateTime != null">
+                updateTime,
+            </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="ca_custid != null">
+                #{ca_custid,jdbcType=INTEGER},
+            </if>
+            <if test="ca_custcode != null">
+                #{ca_custcode,jdbcType=VARCHAR},
+            </if>
+            <if test="ca_custname != null">
+                #{ca_custname,jdbcType=VARCHAR},
+            </if>
+            <if test="ca_currency != null">
+                #{ca_currency,jdbcType=VARCHAR},
+            </if>
+            <if test="ca_begindate != null">
+                #{ca_begindate,jdbcType=TIMESTAMP},
+            </if>
+            <if test="ca_beginaramount != null">
+                #{ca_beginaramount,jdbcType=DOUBLE},
+            </if>
+            <if test="ca_beginprerecamount != null">
+                #{ca_beginprerecamount,jdbcType=DOUBLE},
+            </if>
+            <if test="ca_recamount != null">
+                #{ca_recamount,jdbcType=DOUBLE},
+            </if>
+            <if test="ca_preamount != null">
+                #{ca_preamount,jdbcType=DOUBLE},
+            </if>
+            <if test="ca_leftamount != null">
+                #{ca_leftamount,jdbcType=DOUBLE},
+            </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="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.document.entities.CustAramount">
+        update CustAramount
+        <set>
+            <if test="ca_beginaramount != null">
+                ca_beginaramount = #{ca_beginaramount,jdbcType=DOUBLE},
+            </if>
+            <if test="ca_beginprerecamount != null">
+                ca_beginprerecamount = #{ca_beginprerecamount,jdbcType=DOUBLE},
+            </if>
+            <if test="updaterId != null">
+                updaterId = #{updaterId,jdbcType=INTEGER},
+            </if>
+            <if test="updateTime != null">
+                updateTime = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updaterName != null">
+                updaterName = #{updaterName,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where ca_id = #{id}
+    </update>
+
+    <select id="checkBeginData" resultType="int">
+        SELECT COUNT(*) FROM periodsdetail
+        <where>
+            pd_status = 99
+            <if test="pd_detno!=null">
+                and pd_detno=#{pd_detno}
+            </if>
+            <if test="companyId!=0 and companyId!=null">
+                and COMPANYID=#{companyId}
+            </if>
+        </where>
+    </select>
+
+    <select id="hasCustNameByCode" resultType="int">
+        SELECT COUNT(*) FROM customer
+        <where>
+            cu_statuscode = 'ENABLE'
+            <if test="custCode!=null">
+                and cu_code=#{custCode}
+            </if>
+            <if test="custName!=null">
+                and cu_Name=#{custName}
+            </if>
+            <if test="companyId!=0 and companyId!=null">
+                and COMPANYID=#{companyId}
+            </if>
+        </where>
+    </select>
+
+    <select id="getCustAramount" resultMap="CustAramountResultMapper">
+        SELECT * FROM CustAramount
+        <where>
+            <if test="id!=null">
+                and ca_id=#{id}
+            </if>
+            <if test="companyId!=0 and companyId!=null">
+                and COMPANYID=#{companyId}
+            </if>
+        </where>
+    </select>
+
+    <select id="hasCustCode" resultType="int">
+        SELECT COUNT(*) FROM Customer
+        <where>
+            cu_statuscode = 'ENABLE'
+            <if test="name!=null">
+                and cu_CODE=#{name}
+            </if>
+            <if test="companyId!=0 and companyId!=null">
+                and COMPANYID=#{companyId}
+            </if>
+        </where>
+    </select>
+
+    <select id="hasCurrency" resultType="int">
+        SELECT COUNT(*) FROM currencys
+        <where>
+            <if test="name!=null">
+                and cr_name=#{name}
+            </if>
+            <if test="companyId!=0 and companyId!=null">
+                and COMPANYID=#{companyId}
+            </if>
+        </where>
+    </select>
+
+    <select id="validCustCodeAndCurrency" resultType="int">
+        SELECT COUNT(*) FROM CustAramount
+        <where>
+            <if test="custCode!=null">
+                and ca_custcode=#{custCode}
+            </if>
+            <if test="currency!=null">
+                and ca_currency=#{currency}
+            </if>
+            <if test="id!=0">
+                and ca_id!=#{id}
+            </if>
+            <if test="companyId!=0 and companyId!=null">
+                and COMPANYID=#{companyId}
+            </if>
+        </where>
+    </select>
+
+</mapper>

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

@@ -411,4 +411,17 @@
         </set>
         where cu_id = #{cu_id,jdbcType=INTEGER}
     </update>
+
+  <select id="getCustomersByCondition" resultMap="BaseResultMap">
+    SELECT * FROM CUSTOMER
+    <where>
+      <if test="condition!=null">
+        ${condition}
+      </if>
+      <if test="companyId!=null">
+        AND companyId = #{companyId}
+      </if>
+    </where>
+    ORDER BY CU_ID DESC
+  </select>
 </mapper>

+ 113 - 0
frontend/saas-web/app/view/document/custaramount/AddWindow.js

@@ -0,0 +1,113 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.document.custaramount.AddWindow', {
+    extend: 'saas.view.document.kind.ChildForm',
+    xtype: 'document-custaramount-addwindow',
+    dataKind:'custaramountadd',//类型标识
+    belong:{
+        columns: [{
+            dataIndex: 'ca_custid'
+        },{
+            dataIndex: 'ca_custcode'
+        },{
+            dataIndex: 'ca_custname'
+        },{
+            dataIndex: 'ca_currency'
+        },{
+            dataIndex: 'ca_beginaramount'
+        },{
+            dataIndex: 'ca_beginprerecamount'
+        },{
+            dataIndex: 'ca_begindate'
+        },{
+            dataIndex: 'ca_recamount'
+        },{
+            dataIndex: 'ca_preamount'
+        },{
+            dataIndex: 'ca_leftamount'
+        }],
+        keyField:'id',
+        reqUrl:'/api/document/custaramount/save'
+    },
+    etc:{
+        custaramountadd:{
+            items:[{
+                xtype:'hidden',
+                name:'id'
+            },{
+                xtype:'hidden',
+                name:'ca_custid'
+            },{
+                xtype:'hidden',
+                name:'ca_begindate'
+            },{
+                defaultValue:0,
+                xtype:'hidden',
+                name:'ca_recamount'
+            },{
+                defaultValue:0,
+                xtype:'hidden',
+                name:'ca_preamount'
+            },{
+                defaultValue:0,
+                xtype:'hidden',
+                name:'ca_leftamount'
+            },{
+                xtype:'customerDbfindTrigger',
+                name:'ca_custcode',
+                allowBlank:false,
+                fieldLabel:'客户编号',
+                maxLength: 20,
+                dbfinds:[{
+                    from:'id',to:'ca_custid',ignore:true
+                },{
+                    from:'cu_name',to:'ca_custname'
+                },{
+                    from:'cu_code',to:'ca_custcode'
+                }]
+            },{
+                xtype:'textfield',
+                readOnly:true,
+                editable:false,
+                name:'ca_custname',
+                allowBlank:false,
+                fieldLabel:'客户名称',
+                maxLength: 20
+            },{
+                xtype:'currencyDbfindTrigger',
+                name:'ca_currency',
+                allowBlank:false,
+                fieldLabel:'币别',
+                maxLength: 20,
+                dbfinds:[{
+                    from:'cr_name',to:'ca_currency'
+                }]
+            },{
+                xtype:'numberfield',
+                hideTrigger:true,
+                name:'ca_beginaramount',
+                allowBlank:true,
+                fieldLabel:'期初应收(元)',
+                maxLength: 20,
+                minValue:0,
+                maxValue:999999999999999999999,
+                defaultValue: 0,
+                decimalPrecision: 2,
+                beforeLabelTextTpl:""
+            },{
+                beforeLabelTextTpl:"",
+                xtype:'numberfield',
+                hideTrigger:true,
+                name:'ca_beginprerecamount',
+                allowBlank:true,
+                fieldLabel:'期初预收(元)',
+                maxLength: 20,
+                minValue:0,
+                maxValue:999999999999999999999,
+                defaultValue: 0,
+                decimalPrecision: 2,
+            }]
+        }
+    }
+});

+ 177 - 0
frontend/saas-web/app/view/document/custaramount/BasePanel.js

@@ -0,0 +1,177 @@
+Ext.define('saas.view.document.custaramount.BasePanel', {
+    extend: 'saas.view.core.base.BasePanel',
+    xtype: 'document-custaramount-basepanel',
+    controller: 'document-custaramount-basepanel',
+    viewModel: 'document-custaramount-basepanel',
+
+    viewName: 'document-custaramount-basepanel',
+
+    deleteMoreMsg: '删除的客户期初将不能恢复,请确认是否删除?',
+    deleteOneMsg: '删除的客户期初将不能恢复,请确认是否删除?',
+
+    initComponent: function () {
+        Ext.apply(this, {
+            searchField: [{
+                xtype: "textfield",
+                name: "ca_custcode",
+                columnWidth: 0.2,
+                emptyText: '请输入客户编号或名称',
+                getCondition: function (v) {
+                    return "(upper(CONCAT(ca_custcode,'#',ca_custname)) like '%" + v.toUpperCase() + "%' )";
+                }
+            },{
+                margin:'0 15 0 10',
+                xtype: "textfield",
+                name: "ca_currency",
+                columnWidth: 0.15,
+                emptyText: '请输入币别名称'
+            }],
+
+            //字段属性
+            caller: 'CustAramount',
+            _formXtype: 'document-custaramount-formpanel',
+            _title: '客户期初',
+            _deleteUrl: '/api/document/custaramount/delete',
+            _batchDeleteUrl: '/api/document/custaramount/batchDelete',
+
+            gridConfig: {
+                idField: 'id',
+                codeField: 've_code',
+                statusCodeField: 've_statuscode',
+                dataUrl: '/api/document/custaramount/list',
+                caller: 'custaramount',
+                turnAdd:function(form){
+                    this.dialog = form.ownerCt.add({
+                        xtype: 'document-custaramount-addwindow',
+                        bind: {
+                            title: '新增客户期初'
+                        },
+                        _parent:form.items.items[0],
+                        record:null,
+                        session: true
+                    });
+                    this.dialog.show();
+                },
+                onItemClick: function(form, grid, record,a,index,c) {
+                    var classList = c.target.classList;
+                    if(classList.contains('fa-pencil')){
+                        var config = {};
+                        config.initId = record.get('id');
+                        this.dialog = form.ownerCt.add({
+                            xtype: 'document-custaramount-window',
+                            bind: {
+                                title: '修改客户期初'
+                            },
+                            _parent:form.items.items[0],
+                            record:record,
+                            session: true
+                        });
+                        this.dialog.show();
+                    }else if(classList.contains('fa-trash-o')){
+                        //删除
+                        var id = record.get('id');
+                        if(id){
+                            saas.util.BaseUtil.showConfirm('警告', form.deleteOneMsg)
+                            .then(function(yes) {
+                                if(yes == 'yes') {
+                                    saas.util.BaseUtil.request({
+                                        url: form._deleteUrl+'/'+id,
+                                        method: 'POST',
+                                    })
+                                    .then(function(localJson) {
+                                        if(localJson.success){
+                                            //解析参数
+                                            saas.util.BaseUtil.showSuccessToast('删除成功');
+                                            grid.store.load();
+                                        }
+                                    })
+                                    .catch(function(e) {
+                                        saas.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
+                                    });
+                                }
+                            });
+                        }
+                    }
+                },
+                columns: [{
+                    text: "id",
+                    hidden: true,
+                    dataIndex: "id",
+                    xtype: "numbercolumn",
+                },{
+                    text: "客户id",
+                    hidden: true,
+                    dataIndex: "ca_custid",
+                    xtype: "numbercolumn",
+                }, {
+                    text: "客户编号",
+                    width: 150.0,
+                    dataIndex: "ca_custcode"
+                },  {
+                    text: "客户名称",
+                    width: 150.0,
+                    dataIndex: "ca_custname"
+                }, {
+                    text: '币别',
+                    dataIndex: 'ca_currency',
+                    align: 'center',
+                    width: 65
+                }, {
+                    xtype:'datecolumn',
+                    text: '期初日期',
+                    format:'Y-m-d',
+                    dataIndex: 'ca_begindate',
+                    width: 110
+                },{
+                    text: "期初应收",
+                    xtype: 'numbercolumn',
+                    dataIndex: "ca_beginaramount",
+                    width: 110.0,
+                    renderer: function(v, m, r) {
+                        return saas.util.BaseUtil.numberFormat(v, 2, false);
+                    }
+                },{
+                    text: "期初预收",
+                    xtype: 'numbercolumn',
+                    dataIndex: "ca_beginprerecamount",
+                    width: 110.0,
+                    renderer: function(v, m, r) {
+                        return saas.util.BaseUtil.numberFormat(v, 2, false);
+                    }
+                },{
+                    hidden:true,
+                    text: "应收金额",
+                    xtype: 'numbercolumn',
+                    dataIndex: "ca_recamount",
+                    width: 110.0,
+                    renderer: function(v, m, r) {
+                        return saas.util.BaseUtil.numberFormat(v, 2, false);
+                    }
+                },{
+                    hidden:true,
+                    text: "预收金额",
+                    xtype: 'numbercolumn',
+                    dataIndex: "ca_preamount",
+                    width: 110.0,
+                    renderer: function(v, m, r) {
+                        return saas.util.BaseUtil.numberFormat(v, 2, false);
+                    }
+                },{
+                    hidden:true,
+                    text: "应收余额",
+                    xtype: 'numbercolumn',
+                    dataIndex: "ca_leftamount",
+                    width: 110.0,
+                    renderer: function(v, m, r) {
+                        return saas.util.BaseUtil.numberFormat(v, 2, false);
+                    }
+                }]
+            },
+        });
+        this.callParent(arguments);
+    },
+
+    refresh: function () {
+        this.items.items[0].store.load()
+    }
+});

+ 10 - 0
frontend/saas-web/app/view/document/custaramount/BasePanelController.js

@@ -0,0 +1,10 @@
+Ext.define('saas.view.document.custaramount.BasePanelController', {
+    extend: 'saas.view.core.base.BasePanelController',
+    alias: 'controller.document-custaramount-basepanel',
+
+    init: function (form) {
+        var me = this;
+        this.control({
+        });
+    }
+});

+ 9 - 0
frontend/saas-web/app/view/document/custaramount/BasePanelModel.js

@@ -0,0 +1,9 @@
+Ext.define('saas.view.document.custaramount.BasePanelModel', {
+    extend: 'saas.view.core.base.BasePanelModel',
+    alias: 'viewmodel.document-custaramount-basepanel',
+
+    data: {
+        enableClose: false,
+        configurable: true
+    }
+});

+ 117 - 0
frontend/saas-web/app/view/document/custaramount/Window.js

@@ -0,0 +1,117 @@
+/**
+ * Created by zhouy on 2018/10/18.
+ */
+Ext.define('saas.view.document.custaramount.Window', {
+    extend: 'saas.view.document.kind.ChildForm',
+    xtype: 'document-custaramount-window',
+    dataKind:'custaramount',//类型标识
+    belong:{
+        columns: [{
+            dataIndex: 'ca_custid'
+        },{
+            dataIndex: 'ca_custcode'
+        },{
+            dataIndex: 'ca_custname'
+        },{
+            dataIndex: 'ca_currency'
+        },{
+            dataIndex: 'ca_beginaramount'
+        },{
+            dataIndex: 'ca_beginprerecamount'
+        },{
+            dataIndex: 'ca_begindate'
+        },{
+            dataIndex: 'ca_recamount'
+        },{
+            dataIndex: 'ca_preamount'
+        },{
+            dataIndex: 'ca_leftamount'
+        }],
+        keyField:'id',
+        reqUrl:'/api/document/custaramount/save'
+    },
+    etc:{
+        custaramount:{
+            items:[{
+                xtype:'hidden',
+                name:'id'
+            },{
+                xtype:'hidden',
+                name:'ca_custid'
+            },{
+                xtype:'hidden',
+                name:'ca_begindate'
+            },{
+                defaultValue:0,
+                xtype:'hidden',
+                name:'ca_payamount'
+            },{
+                defaultValue:0,
+                xtype:'hidden',
+                name:'ca_preamount'
+            },{
+                defaultValue:0,
+                xtype:'hidden',
+                name:'ca_leftamount'
+            },{
+                xtype:'customerDbfindTrigger',
+                name:'ca_custcode',
+                allowBlank:false,
+                readOnly:true,
+                editable:false,
+                fieldLabel:'客户编号',
+                maxLength: 20,
+                dbfinds:[{
+                    from:'id',to:'ca_custid',ignore:true
+                },{
+                    from:'ve_name',to:'ca_custname'
+                },{
+                    from:'ve_code',to:'ca_custcode'
+                }]
+            },{
+                xtype:'textfield',
+                readOnly:true,
+                editable:false,
+                name:'ca_custname',
+                allowBlank:false,
+                fieldLabel:'客户名称',
+                maxLength: 20
+            },{
+                readOnly:true,
+                editable:false,
+                xtype:'currencyDbfindTrigger',
+                name:'ca_currency',
+                allowBlank:false,
+                fieldLabel:'币别',
+                maxLength: 20,
+                dbfinds:[{
+                    from:'cr_name',to:'ca_currency'
+                }]
+            },,{
+                xtype:'numberfield',
+                hideTrigger:true,
+                name:'ca_beginaramount',
+                allowBlank:true,
+                fieldLabel:'期初应收(元)',
+                maxLength: 20,
+                minValue:0,
+                maxValue:999999999999999999999,
+                defaultValue: 0,
+                decimalPrecision: 2,
+                beforeLabelTextTpl:""
+            },{
+                beforeLabelTextTpl:"",
+                xtype:'numberfield',
+                hideTrigger:true,
+                name:'ca_beginprerecamount',
+                allowBlank:true,
+                fieldLabel:'期初预收(元)',
+                maxLength: 20,
+                minValue:0,
+                maxValue:999999999999999999999,
+                defaultValue: 0,
+                decimalPrecision: 2,
+            }]
+        }
+    }
+});

+ 5 - 0
frontend/saas-web/resources/json/navigation.json

@@ -272,6 +272,11 @@
             "viewType": "document-customer-basepanel",
             "addType":"document-customer-formpanel",
             "leaf": true
+        },{
+            "id":"custaramount-list-formpanel",
+            "text": "客户期初设置",
+            "viewType": "document-custaramount-basepanel",
+            "leaf": true
         }, {
             "b2b":true,
             "id": "document-uusetting",