浏览代码

Merge remote-tracking branch 'origin/master'

caozj 1 年之前
父节点
当前提交
decda82c90

+ 22 - 2
hx-account/src/main/java/com/fjhx/account/entity/account/po/AccountPaymentRecords.java

@@ -6,6 +6,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * <p>
@@ -26,9 +27,28 @@ public class AccountPaymentRecords extends BasePo {
     private Long accountPaymentId;
 
     /**
+     * 打款账户id
+     */
+    private Long accountManagementId;
+    /**
+     * 币种
+     */
+    private String currency;
+    /**
      * 打款金额
      */
-    private BigDecimal
-            amount;
+    private BigDecimal amount;
+    /**
+     * 打款时间
+     */
+    private Date expensesTime;
+    /**
+     * 是否往来
+     */
+    private Integer isTransaction;
+    /**
+     * 摘要
+     */
+    private String remark;
 
 }

+ 5 - 0
hx-account/src/main/java/com/fjhx/account/entity/account/po/AccountRunningWater.java

@@ -105,4 +105,9 @@ public class AccountRunningWater extends BasePo {
     @TableField(exist = false)
     private Integer count;
 
+    /**
+     * 打款记录id
+     */
+    private Long accountPaymentRecordsId;
+
 }

+ 21 - 12
hx-account/src/main/java/com/fjhx/account/service/account/impl/AccountPaymentServiceImpl.java

@@ -136,19 +136,19 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
         AccountPayment AccountPayment = baseMapper.detail(id);
         AccountPaymentVo result = BeanUtil.toBean(AccountPayment, AccountPaymentVo.class);
 
-        if (ObjectUtil.isNotEmpty(result.getAccountManagementId())){
+        if (ObjectUtil.isNotEmpty(result.getAccountManagementId())) {
             //查询实际打款的付款账户名称;
             AccountManagement accountManagement = accountManagementService.getById(result.getAccountManagementId());
-            if (ObjectUtil.isNotEmpty(accountManagement)){
+            if (ObjectUtil.isNotEmpty(accountManagement)) {
                 result.setAccountManagementName(accountManagement.getName());
             }
 
         }
 
-        if (ObjectUtil.isNotEmpty(result.getBusinessManagementId())){
+        if (ObjectUtil.isNotEmpty(result.getBusinessManagementId())) {
             //查询业务中选中的付款账户名称;
             AccountManagement accountManagement = accountManagementService.getById(result.getBusinessManagementId());
-            if (ObjectUtil.isNotEmpty(accountManagement)){
+            if (ObjectUtil.isNotEmpty(accountManagement)) {
                 result.setBusinessManagementName(accountManagement.getName());
             }
 
@@ -158,6 +158,7 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
 
     /**
      * 打款功能
+     *
      * @param accountPaymentDto
      */
     @Override
@@ -197,12 +198,19 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
         }
         //赋值已打款金额
         oldAccountPayment.setAmount(add);
+        //赋值最后一次打款时间
+        oldAccountPayment.setExpensesTime(accountPaymentDto.getExpensesTime());
         updateById(oldAccountPayment);
 
         //创建打款记录
         AccountPaymentRecords accountPaymentRecords = new AccountPaymentRecords();
         accountPaymentRecords.setAccountPaymentId(accountPaymentDto.getId());
         accountPaymentRecords.setAmount(accountPaymentDto.getAmount());
+
+        accountPaymentRecords.setAccountManagementId(accountPaymentDto.getAccountManagementId());
+        accountPaymentRecords.setCurrency(accountPaymentDto.getCurrency());
+        accountPaymentRecords.setExpensesTime(accountPaymentDto.getExpensesTime());
+        accountPaymentRecords.setRemark(accountPaymentDto.getRemark());
         accountPaymentRecordsService.save(accountPaymentRecords);
 
         // 赋值变更金额
@@ -214,10 +222,10 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
         accountRemainderService.updateById(accountRemainder);
 
         // 添加附件信息
-        ObsFileUtil.saveFile(accountPaymentDto.getFileList(), accountPaymentDto.getId());
+        ObsFileUtil.saveFile(accountPaymentDto.getFileList(), accountPaymentRecords.getId());
 
         // 添加资金流水表的数据
-        addAccountRunningWater(accountPaymentDto);
+        addAccountRunningWater(accountPaymentDto, accountPaymentRecords);
     }
 
     @Override
@@ -233,20 +241,21 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
     /**
      * 添加资金流水表的数据
      */
-    private void  addAccountRunningWater(AccountPaymentDto accountPaymentDto){
+    private void addAccountRunningWater(AccountPaymentDto accountPaymentDto, AccountPaymentRecords accountPaymentRecords) {
 
         AccountRunningWater accountRunningWater = new AccountRunningWater();
-        accountRunningWater.setAccountManagementId(accountPaymentDto.getAccountManagementId());
+        accountRunningWater.setAccountManagementId(accountPaymentRecords.getAccountManagementId());
         //打款的状态都是支出
         accountRunningWater.setStatus("20");
-        accountRunningWater.setAmount(accountPaymentDto.getAmount());
-        accountRunningWater.setCurrency(accountPaymentDto.getCurrency());
+        accountRunningWater.setAmount(accountPaymentRecords.getAmount());
+        accountRunningWater.setCurrency(accountPaymentRecords.getCurrency());
         accountRunningWater.setOpeningBank(accountPaymentDto.getOpeningBank());
         accountRunningWater.setAccountOpening(accountPaymentDto.getAccountOpening());
         accountRunningWater.setName(accountPaymentDto.getName());
-        accountRunningWater.setTransactionTime(accountPaymentDto.getExpensesTime());
-        accountRunningWater.setRemarks(accountPaymentDto.getRemark());
+        accountRunningWater.setTransactionTime(accountPaymentRecords.getExpensesTime());
+        accountRunningWater.setRemarks(accountPaymentRecords.getRemark());
         accountRunningWater.setBusinessId(accountPaymentDto.getId());
+        accountRunningWater.setAccountPaymentRecordsId(accountPaymentRecords.getId());
         //添加流水类型
         accountRunningWater.setType("10");
         accountRunningWaterService.save(accountRunningWater);

+ 37 - 23
hx-account/src/main/java/com/fjhx/account/service/write/impl/WriteOffRecordsServiceImpl.java

@@ -5,17 +5,13 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fjhx.account.entity.account.po.AccountPayment;
-import com.fjhx.account.entity.account.po.AccountRemainder;
-import com.fjhx.account.entity.account.po.AccountRunningWater;
+import com.fjhx.account.entity.account.po.*;
 import com.fjhx.account.entity.write.dto.WriteOffRecordsDto;
 import com.fjhx.account.entity.write.dto.WriteOffRecordsSelectDto;
 import com.fjhx.account.entity.write.po.WriteOffRecords;
 import com.fjhx.account.entity.write.vo.WriteOffRecordsVo;
 import com.fjhx.account.mapper.write.WriteOffRecordsMapper;
-import com.fjhx.account.service.account.AccountPaymentService;
-import com.fjhx.account.service.account.AccountRemainderService;
-import com.fjhx.account.service.account.AccountRunningWaterService;
+import com.fjhx.account.service.account.*;
 import com.fjhx.account.service.write.WriteOffRecordsService;
 import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.common.utils.Assert;
@@ -26,6 +22,7 @@ import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 
@@ -47,6 +44,10 @@ public class WriteOffRecordsServiceImpl extends ServiceImpl<WriteOffRecordsMappe
     private AccountRemainderService accountRemainderService;
     @Autowired
     private AccountRunningWaterService accountRunningWaterService;
+    @Autowired
+    private AccountPaymentRecordsService accountPaymentRecordsService;
+    @Autowired
+    private AccountManagementService accountManagementService;
 
     @Override
     public Page<WriteOffRecordsVo> getPage(WriteOffRecordsSelectDto dto) {
@@ -73,28 +74,41 @@ public class WriteOffRecordsServiceImpl extends ServiceImpl<WriteOffRecordsMappe
         Assert.notEmpty(accountPayment, "查询不到打款信息");
         //修改打款状态为未打款
         accountPayment.setStatus("20");
+        //清空已打款金额
+        accountPayment.setAmount(BigDecimal.ZERO);
         accountPaymentService.updateById(accountPayment);
-        //清理历史附件
-        ObsFileUtil.removeFile(accountPayment.getId());
-        //赋值之前的打款时间
+
+        //赋值最后一次打款时间
         writeOffRecordsDto.setAccountPaymentDate(accountPayment.getExpensesTime());
         this.save(writeOffRecordsDto);
-        //根据币种回滚余额
-        AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
-                .eq(AccountRemainder::getAccountManagementId, accountPayment.getAccountManagementId())
-                .eq(AccountRemainder::getCurrency, accountPayment.getCurrency()));
-        // 如果不存在这条数据则返回币种不存在
-        if (ObjectUtil.isEmpty(accountRemainder)) {
-            throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
-        }
-        accountRemainderService.update(q -> q
-                .eq(AccountRemainder::getId, accountRemainder.getId())
-                .setSql("remainder = remainder + " + accountPayment.getAmount())
+
+        List<AccountPaymentRecords> accountPaymentRecordsList = accountPaymentRecordsService.list(
+                q -> q.eq(AccountPaymentRecords::getAccountPaymentId, accountPayment.getId())
         );
+        for (AccountPaymentRecords accountPaymentRecords : accountPaymentRecordsList) {
+            //清理历史附件
+            ObsFileUtil.removeFile(accountPaymentRecords.getId());
+            AccountManagement accountManagement = accountManagementService.getById(accountPaymentRecords.getAccountManagementId());
+            if (ObjectUtil.isEmpty(accountManagement)) {
+                throw new ServiceException("资金账户不存在:" + accountPaymentRecords.getAccountManagementId());
+            }
+            //根据币种回滚余额
+            AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
+                    .eq(AccountRemainder::getAccountManagementId, accountPaymentRecords.getAccountManagementId())
+                    .eq(AccountRemainder::getCurrency, accountPaymentRecords.getCurrency()));
+            // 如果不存在这条数据则返回币种不存在
+            if (ObjectUtil.isEmpty(accountRemainder)) {
+                String format = String.format("账户%s不存在币种(%s),请前往资金账户添加", accountManagement.getName(), accountPaymentRecords.getCurrency());
+                throw new ServiceException(format);
+            }
+            accountRemainderService.update(q -> q
+                    .eq(AccountRemainder::getId, accountRemainder.getId())
+                    .setSql("remainder = remainder + " + accountPaymentRecords.getAmount())
+            );
+        }
         //删除打款对应的流水
-        AccountRunningWater accountRunningWater = accountRunningWaterService.getOne(q -> q.eq(AccountRunningWater::getBusinessId, accountPayment.getId()));
-        Assert.notEmpty(accountRunningWater, "查询不到打款流水信息");
-        accountRunningWaterService.removeById(accountRunningWater);
+        List<AccountRunningWater> accountRunningWaterList = accountRunningWaterService.list(q -> q.eq(AccountRunningWater::getBusinessId, accountPayment.getId()));
+        Assert.notEmpty(accountRunningWaterList, "查询不到打款流水信息");
     }
 
 }

+ 24 - 21
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -27,7 +27,6 @@ import com.fjhx.common.entity.contract.po.ContractTemplate;
 import com.fjhx.common.entity.corporation.po.Corporation;
 import com.fjhx.common.entity.currency.po.CurrencyRate;
 import com.fjhx.common.entity.documentary.bo.DocumentaryData;
-import com.fjhx.common.entity.documentary.po.Documentary;
 import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.service.contract.ContractTemplateService;
 import com.fjhx.common.service.corporation.CorporationService;
@@ -61,7 +60,6 @@ import com.fjhx.sale.entity.contract.dto.ContractDto;
 import com.fjhx.sale.entity.contract.dto.ContractSelectDto;
 import com.fjhx.sale.entity.contract.dto.DecisionAidDto;
 import com.fjhx.sale.entity.contract.dto.PayDecisionAidDto;
-import com.fjhx.sale.entity.contract.enums.DocumentaryTypeEnum;
 import com.fjhx.sale.entity.contract.po.*;
 import com.fjhx.sale.entity.contract.vo.*;
 import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
@@ -91,7 +89,6 @@ import com.ruoyi.framework.config.ThreadPoolConfig;
 import com.ruoyi.system.service.ISysUserService;
 import com.ruoyi.system.utils.UserUtil;
 import org.apache.commons.collections4.MapUtils;
-import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.core.context.SecurityContext;
@@ -270,7 +267,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         wrapper.orderByDesc("t1", Contract::getCreateTime);
         if (StringUtils.isNotEmpty(dto.getStatus())) {
             wrapper.eq("t1", Contract::getStatus, dto.getStatus());
-        }else{
+        } else {
             wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
             wrapper.ne("t1", Contract::getIsShow, 1);
             wrapper.between("t1", Contract::getStatus, FlowStatusEnum1.DRAFT.getKey(), FlowStatusEnum1.CANCELLATION.getKey() - 1);
@@ -757,7 +754,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      */
     @Override
     public Page<ContractVo> getSalesTotalList(Page<Object> page, Long id) {
-        return baseMapper.getSalesTotalList(page,id);
+        return baseMapper.getSalesTotalList(page, id);
     }
 
     /**
@@ -1863,6 +1860,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
 
     /**
      * 外销跟单分页
+     *
      * @param dto
      * @return
      */
@@ -1878,14 +1876,14 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
         wrapper.orderByDesc("t1", Contract::getCreateTime);
         wrapper.eq("t1", Contract::getIsChange, "0");//列表只展示未变更得数据
-        wrapper.ne("t1",Contract::getIsShow,1);
+        wrapper.ne("t1", Contract::getIsShow, 1);
         wrapper.eq("t1", Contract::getStatus, FlowStatusEnum1.PASS.getKey());
         wrapper.eq("t1.orderStatus", dto.getOrderStatus());
-        if(dto.getDocumentarySearch()==1&&ObjectUtil.isNotEmpty(dto.getDocumentaryType())){//无记录
-            wrapper.eq("t1.documentaryCount",0);
+        if (dto.getDocumentarySearch() == 1 && ObjectUtil.isNotEmpty(dto.getDocumentaryType())) {//无记录
+            wrapper.eq("t1.documentaryCount", 0);
         }
-        if(dto.getDocumentarySearch()==2&&ObjectUtil.isNotEmpty(dto.getDocumentaryType())){//无记录
-            wrapper.gt("t1.documentaryCount",0);
+        if (dto.getDocumentarySearch() == 2 && ObjectUtil.isNotEmpty(dto.getDocumentaryType())) {//无记录
+            wrapper.gt("t1.documentaryCount", 0);
         }
         if (StringUtils.isNotEmpty(dto.getKeyword())) {
             //归属公司
@@ -1898,9 +1896,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                     .or().in("t1", Contract::getBuyCorporationId, customerIds)
             );
         }
-        Page<ContractVo> page = baseMapper.getExportCopyList(dto.getPage(), wrapper,dto.getDocumentaryType());
+        Page<ContractVo> page = baseMapper.getExportCopyList(dto.getPage(), wrapper, dto.getDocumentaryType());
         List<ContractVo> list = page.getRecords();
-        if(CollectionUtils.isNotEmpty(list)){
+        if (CollectionUtils.isNotEmpty(list)) {
             List<Long> customerIds = list.stream().map(Contract::getBuyCorporationId).collect(Collectors.toList());
             List<Customer> customerList = customerService.list(Wrappers.<Customer>query().lambda().in(Customer::getId, customerIds));
             Map<Long, List<Customer>> cusMap = customerList.stream().distinct().collect(Collectors.groupingBy(Customer::getId));
@@ -1910,19 +1908,22 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             // 获取包装附件
             Map<Long, List<FileInfoVo>> packageFileMap = ObsFileUtil.getFileMap(ids, 2);
             //合同产品
-            List<ContractProduct> contractProductList = contractProductService.list(Wrappers.<ContractProduct>query().lambda().in(ContractProduct::getContractId,ids));
-            Map<Long,List<ContractProduct>> contractProductMap = contractProductList.stream().collect(Collectors.groupingBy(ContractProduct::getContractId));
+            List<ContractProduct> contractProductList = contractProductService.list(Wrappers.<ContractProduct>query().lambda().in(ContractProduct::getContractId, ids));
+            Map<Long, List<ContractProduct>> contractProductMap = contractProductList.stream().collect(Collectors.groupingBy(ContractProduct::getContractId));
             //采购合同
-            List<EhsdPurchase> ehsdPurchaseList = ehsdPurchaseService.list(Wrappers.<EhsdPurchase>query().lambda().in(EhsdPurchase::getDataResourceId,ids));
+            List<EhsdPurchase> ehsdPurchaseList = ehsdPurchaseService.list(Wrappers.<EhsdPurchase>query().lambda()
+                    .in(EhsdPurchase::getDataResourceId, ids)
+                    .in(EhsdPurchase::getStatus, 30, 60)//过滤审批通过和变更中的采购单
+            );
             List<Long> purchaseIds = ehsdPurchaseList.stream().map(EhsdPurchase::getId).collect(Collectors.toList());
             //查询采购跟单列表
-            List<ContractDocumentary> contractDocumentaryList = contractDocumentaryService.list(Wrappers.<ContractDocumentary>query().lambda().in(ContractDocumentary::getBusinessId,CollectionUtils.isEmpty(purchaseIds)?Arrays.asList("0"):purchaseIds));
-            Map<Long,List<ContractDocumentary>> contractDocumentaryMap = contractDocumentaryList.stream().collect(Collectors.groupingBy(ContractDocumentary::getBusinessId));
+            List<ContractDocumentary> contractDocumentaryList = contractDocumentaryService.list(Wrappers.<ContractDocumentary>query().lambda().in(ContractDocumentary::getBusinessId, CollectionUtils.isEmpty(purchaseIds) ? Arrays.asList("0") : purchaseIds));
+            Map<Long, List<ContractDocumentary>> contractDocumentaryMap = contractDocumentaryList.stream().collect(Collectors.groupingBy(ContractDocumentary::getBusinessId));
             //赋值采购合同供应商
             supplierInfoService.attributeAssign(ehsdPurchaseList, EhsdPurchase::getSellCorporationId, (item, supplierInfo) -> {
                 item.setSupplyName(supplierInfo.getName());
             });
-            Map<Long,List<EhsdPurchase>> ehsdPurchaseMap = ehsdPurchaseList.stream().collect(Collectors.groupingBy(EhsdPurchase::getDataResourceId));
+            Map<Long, List<EhsdPurchase>> ehsdPurchaseMap = ehsdPurchaseList.stream().collect(Collectors.groupingBy(EhsdPurchase::getDataResourceId));
             for (ContractVo p : list) {
                 // 客户
                 if (MapUtils.isNotEmpty(cusMap)) {
@@ -1949,9 +1950,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
                 // 赋值采购单信息
                 if (MapUtils.isNotEmpty(ehsdPurchaseMap)) {
                     List<EhsdPurchase> purchases = ehsdPurchaseMap.get(p.getId());
-                    if(ObjectUtil.isNotEmpty(purchases)){
-                        for(EhsdPurchase e : purchases){
-                            e.setPurchaseDocumentary(contractDocumentaryMap.getOrDefault(e.getId(),null));
+                    if (ObjectUtil.isNotEmpty(purchases)) {
+                        for (EhsdPurchase e : purchases) {
+                            e.setPurchaseDocumentary(contractDocumentaryMap.getOrDefault(e.getId(), null));
                         }
                     }
                     p.setPurchaseList(purchases);
@@ -1968,8 +1969,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         //查询合同产品
         return page;
     }
+
     /**
      * 外销跟单添加备注
+     *
      * @param contractVo
      */
     @DSTransactional

+ 1 - 0
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -293,6 +293,7 @@
                  LEFT JOIN bytesailing_account.account_management am
                            ON arw.account_management_id = am.id AND am.del_flag = 0
         WHERE c.id = #{contractId}
+        group by arfd.id
         UNION ALL
         SELECT arw.id,
                arw.create_time,