Commit dbf33c853924ec326635db1418ec11a27ede4881

Authored by 房远帅
1 parent e840bfe3

账期:资金协调手续-根据客户简称获取基础数据

@@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonFormat; @@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
4 import java.math.BigDecimal; 4 import java.math.BigDecimal;
5 import com.lframework.starter.common.constants.StringPool; 5 import com.lframework.starter.common.constants.StringPool;
6 import java.time.LocalDate; 6 import java.time.LocalDate;
  7 +import java.util.List;
7 import com.lframework.starter.web.core.bo.BaseBo; 8 import com.lframework.starter.web.core.bo.BaseBo;
  9 +import com.lframework.xingyun.sc.bo.ledger.rel.GetFundOrderingUnitBo;
8 import com.lframework.xingyun.sc.entity.FundCoordination; 10 import com.lframework.xingyun.sc.entity.FundCoordination;
9 import io.swagger.annotations.ApiModelProperty; 11 import io.swagger.annotations.ApiModelProperty;
10 12
@@ -120,6 +122,12 @@ public class GetFundCoordinationBo extends BaseBo<FundCoordination> { @@ -120,6 +122,12 @@ public class GetFundCoordinationBo extends BaseBo<FundCoordination> {
120 @ApiModelProperty("协调事由需求说明") 122 @ApiModelProperty("协调事由需求说明")
121 private String requirementSpecification; 123 private String requirementSpecification;
122 124
  125 + /**
  126 + * 协调事由需求说明
  127 + */
  128 + @ApiModelProperty("协调事由需求说明")
  129 + private List<GetFundOrderingUnitBo> fundOrderingUnitList;
  130 +
123 public GetFundCoordinationBo() { 131 public GetFundCoordinationBo() {
124 132
125 } 133 }
1 package com.lframework.xingyun.sc.bo.ledger.rel; 1 package com.lframework.xingyun.sc.bo.ledger.rel;
2 2
3 import com.lframework.starter.web.core.bo.BaseBo; 3 import com.lframework.starter.web.core.bo.BaseBo;
  4 +import com.lframework.xingyun.sc.bo.ledger.detail.GetFundOrderingUnitDetailBo;
4 import com.lframework.xingyun.sc.entity.FundOrderingUnit; 5 import com.lframework.xingyun.sc.entity.FundOrderingUnit;
5 import io.swagger.annotations.ApiModelProperty; 6 import io.swagger.annotations.ApiModelProperty;
6 -  
7 import lombok.Data; 7 import lombok.Data;
  8 +import java.util.List;
8 9
9 /** 10 /**
10 * <p> 11 * <p>
@@ -45,6 +46,9 @@ public class GetFundOrderingUnitBo extends BaseBo<FundOrderingUnit> { @@ -45,6 +46,9 @@ public class GetFundOrderingUnitBo extends BaseBo<FundOrderingUnit> {
45 @ApiModelProperty("备注") 46 @ApiModelProperty("备注")
46 private String remark; 47 private String remark;
47 48
  49 + @ApiModelProperty("资金协调手续订货单位应收款明细")
  50 + private List<GetFundOrderingUnitDetailBo> fundOrderingUnitDetailList;
  51 +
48 public GetFundOrderingUnitBo() { 52 public GetFundOrderingUnitBo() {
49 53
50 } 54 }
1 package com.lframework.xingyun.sc.bo.ledger.rel; 1 package com.lframework.xingyun.sc.bo.ledger.rel;
2 2
3 import com.lframework.starter.web.core.bo.BaseBo; 3 import com.lframework.starter.web.core.bo.BaseBo;
  4 +import com.lframework.xingyun.sc.bo.ledger.detail.GetFundOrderingUnitDetailBo;
4 import com.lframework.xingyun.sc.entity.FundOrderingUnit; 5 import com.lframework.xingyun.sc.entity.FundOrderingUnit;
5 import io.swagger.annotations.ApiModelProperty; 6 import io.swagger.annotations.ApiModelProperty;
6 -  
7 import lombok.Data; 7 import lombok.Data;
  8 +import java.util.List;
8 9
9 /** 10 /**
10 * <p> 11 * <p>
@@ -45,6 +46,9 @@ public class QueryFundOrderingUnitBo extends BaseBo<FundOrderingUnit> { @@ -45,6 +46,9 @@ public class QueryFundOrderingUnitBo extends BaseBo<FundOrderingUnit> {
45 @ApiModelProperty("备注") 46 @ApiModelProperty("备注")
46 private String remark; 47 private String remark;
47 48
  49 + @ApiModelProperty("资金协调手续订货单位应收款明细")
  50 + private List<GetFundOrderingUnitDetailBo> fundOrderingUnitDetailList;
  51 +
48 public QueryFundOrderingUnitBo() { 52 public QueryFundOrderingUnitBo() {
49 53
50 } 54 }
@@ -9,18 +9,25 @@ import com.lframework.starter.web.core.components.resp.InvokeResult; @@ -9,18 +9,25 @@ import com.lframework.starter.web.core.components.resp.InvokeResult;
9 import javax.annotation.Resource; 9 import javax.annotation.Resource;
10 import javax.validation.constraints.NotBlank; 10 import javax.validation.constraints.NotBlank;
11 import com.lframework.starter.web.inner.bo.system.user.QuerySysUserBo; 11 import com.lframework.starter.web.inner.bo.system.user.QuerySysUserBo;
  12 +import com.lframework.starter.web.inner.entity.SysDataDicItem;
12 import com.lframework.starter.web.inner.entity.SysDept; 13 import com.lframework.starter.web.inner.entity.SysDept;
13 import com.lframework.starter.web.inner.entity.SysUser; 14 import com.lframework.starter.web.inner.entity.SysUser;
  15 +import com.lframework.starter.web.inner.service.system.SysDataDicItemService;
14 import com.lframework.starter.web.inner.service.system.SysDeptService; 16 import com.lframework.starter.web.inner.service.system.SysDeptService;
15 import com.lframework.starter.web.inner.service.system.SysUserService; 17 import com.lframework.starter.web.inner.service.system.SysUserService;
16 import com.lframework.starter.web.inner.vo.system.user.QuerySysUserVo; 18 import com.lframework.starter.web.inner.vo.system.user.QuerySysUserVo;
  19 +import com.lframework.xingyun.sc.bo.ledger.detail.GetFundOrderingUnitDetailBo;
17 import com.lframework.xingyun.sc.bo.ledger.fund.GetFundCoordinationBo; 20 import com.lframework.xingyun.sc.bo.ledger.fund.GetFundCoordinationBo;
18 import com.lframework.xingyun.sc.bo.ledger.fund.QueryFundCoordinationBo; 21 import com.lframework.xingyun.sc.bo.ledger.fund.QueryFundCoordinationBo;
  22 +import com.lframework.xingyun.sc.bo.ledger.rel.GetFundOrderingUnitBo;
19 import com.lframework.xingyun.sc.entity.FundCoordination; 23 import com.lframework.xingyun.sc.entity.FundCoordination;
  24 +import com.lframework.xingyun.sc.entity.ReceiptLedgerInfo;
20 import com.lframework.xingyun.sc.service.ledger.FundCoordinationService; 25 import com.lframework.xingyun.sc.service.ledger.FundCoordinationService;
  26 +import com.lframework.xingyun.sc.service.ledger.ReceiptLedgerInfoService;
21 import com.lframework.xingyun.sc.vo.ledger.fund.CreateFundCoordinationVo; 27 import com.lframework.xingyun.sc.vo.ledger.fund.CreateFundCoordinationVo;
22 import com.lframework.xingyun.sc.vo.ledger.fund.QueryFundCoordinationVo; 28 import com.lframework.xingyun.sc.vo.ledger.fund.QueryFundCoordinationVo;
23 import com.lframework.xingyun.sc.vo.ledger.fund.UpdateFundCoordinationVo; 29 import com.lframework.xingyun.sc.vo.ledger.fund.UpdateFundCoordinationVo;
  30 +import com.lframework.xingyun.sc.vo.ledger.receipt.QueryReceiptLedgerInfoVo;
24 import io.swagger.annotations.ApiImplicitParam; 31 import io.swagger.annotations.ApiImplicitParam;
25 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; 32 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
26 import com.lframework.starter.common.exceptions.impl.DefaultClientException; 33 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
@@ -32,7 +39,12 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -32,7 +39,12 @@ import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.validation.annotation.Validated; 39 import org.springframework.validation.annotation.Validated;
33 import org.springframework.web.bind.annotation.*; 40 import org.springframework.web.bind.annotation.*;
34 import javax.validation.Valid; 41 import javax.validation.Valid;
  42 +import java.time.LocalDate;
  43 +import java.time.temporal.ChronoUnit;
  44 +import java.util.ArrayList;
  45 +import java.util.Comparator;
35 import java.util.List; 46 import java.util.List;
  47 +import java.util.Map;
36 import java.util.stream.Collectors; 48 import java.util.stream.Collectors;
37 49
38 /** 50 /**
@@ -51,6 +63,10 @@ public class FundCoordinationController extends DefaultBaseController { @@ -51,6 +63,10 @@ public class FundCoordinationController extends DefaultBaseController {
51 private SysDeptService sysDeptService; 63 private SysDeptService sysDeptService;
52 @Resource 64 @Resource
53 private SysUserService sysUserService; 65 private SysUserService sysUserService;
  66 + @Resource
  67 + private ReceiptLedgerInfoService receiptLedgerInfoService;
  68 + @Resource
  69 + private SysDataDicItemService sysDataDicItemService;
54 70
55 /** 71 /**
56 * 查询列表 72 * 查询列表
@@ -147,4 +163,87 @@ public class FundCoordinationController extends DefaultBaseController { @@ -147,4 +163,87 @@ public class FundCoordinationController extends DefaultBaseController {
147 } 163 }
148 return InvokeResultBuilder.success(results); 164 return InvokeResultBuilder.success(results);
149 } 165 }
  166 +
  167 + @ApiOperation("查询")
  168 + @PostMapping("/getBaseInfo")
  169 + public InvokeResult<List<GetFundCoordinationBo>> getBaseInfo(@RequestBody(required = false) List<String> ids) {
  170 + if (CollectionUtil.isEmpty(ids)) {
  171 + return InvokeResultBuilder.success(CollectionUtil.emptyList());
  172 + }
  173 + QueryReceiptLedgerInfoVo vo = new QueryReceiptLedgerInfoVo();
  174 + vo.setCustomerShortId(ids.get(0));
  175 + vo.setIncludeEndAccountReceivable(true);
  176 + List<ReceiptLedgerInfo> query = receiptLedgerInfoService.query(vo);
  177 + if (CollectionUtil.isEmpty(query)) {
  178 + return InvokeResultBuilder.success(CollectionUtil.emptyList());
  179 + }
  180 + List<GetFundCoordinationBo> data = new ArrayList<>();
  181 + GetFundCoordinationBo getFundCoordinationBo = new GetFundCoordinationBo();
  182 + ReceiptLedgerInfo receiptLedgerInfo = query.get(0);
  183 + //客户类型
  184 + getFundCoordinationBo.setCustomerType(receiptLedgerInfo.getCustomerType());
  185 +// SysDataDicItem type = sysDataDicItemService.findByCode("ENTERPRISE_TYPE", receiptLedgerInfo.getCustomerType());
  186 +// getFundCoordinationBo.setCustomerTypeName(type == null ? "" : type.getName());
  187 + //客户简称
  188 + getFundCoordinationBo.setCustomerShortId(receiptLedgerInfo.getCustomerShortId());
  189 + getFundCoordinationBo.setCustomerShortName(receiptLedgerInfo.getCustomerShortName());
  190 + //授权额度
  191 + if (receiptLedgerInfo.getQuota() != null) {
  192 + getFundCoordinationBo.setCreditLimit(receiptLedgerInfo.getQuota().stripTrailingZeros().toPlainString() + "万");
  193 + }
  194 + //结算期限
  195 + getFundCoordinationBo.setSettlementPeriod(receiptLedgerInfo.getSettleTerm());
  196 + Map<String, List<ReceiptLedgerInfo>> map = query.stream()
  197 + .collect(Collectors.groupingBy(ReceiptLedgerInfo::getCustomerId));
  198 + StringBuilder customerNameStr = new StringBuilder();
  199 + //订货单位集合
  200 + List<GetFundOrderingUnitBo> fundOrderingUnitList = new ArrayList<>();
  201 + for (Map.Entry<String, List<ReceiptLedgerInfo>> entry : map.entrySet()) {
  202 + String customerId = entry.getKey();
  203 + List<ReceiptLedgerInfo> receiptList = entry.getValue();
  204 + customerNameStr.append(receiptList.get(0).getCustomerName()).append("、");
  205 + GetFundOrderingUnitBo bo = new GetFundOrderingUnitBo();
  206 + bo.setOrderingUnit(customerId);
  207 + bo.setOrderingUnitName(receiptList.get(0).getCustomerName());
  208 + System.out.println("Customer ID: " + customerId);
  209 + //订货单位应收款明细
  210 + List<GetFundOrderingUnitDetailBo> fundOrderingUnitDetailList = new ArrayList<>();
  211 + for (ReceiptLedgerInfo receipt : receiptList) {
  212 + GetFundOrderingUnitDetailBo bo1 = new GetFundOrderingUnitDetailBo();
  213 + bo1.setDeliveryDate(receipt.getShipmentDate());
  214 + if (receipt.getStartAccountReceivable() != null) {
  215 + bo1.setAccountsReceivable(receipt.getStartAccountReceivable().stripTrailingZeros().toPlainString());
  216 + }
  217 + SysDataDicItem sysDataDicItem = sysDataDicItemService.findByCode("DEBT_STATUS", receipt.getDebtStatus());
  218 + if (!(sysDataDicItem != null && (sysDataDicItem.getCode().equals("FIRST_COORDINATE")
  219 + || sysDataDicItem.getCode().equals("SECOND") || sysDataDicItem.getCode().equals("CLEAR_DEBTS")))) {
  220 + continue;
  221 + }
  222 + bo1.setStatus(sysDataDicItem.getName());
  223 + bo1.setDueDate(receipt.getProcessedDate());
  224 + if (bo1.getDueDate() != null) {
  225 + long daysBetween = ChronoUnit.DAYS.between(bo1.getDueDate(), LocalDate.now());
  226 + bo1.setTimeout(String.valueOf(daysBetween));
  227 + }
  228 + fundOrderingUnitDetailList.add(bo1);
  229 + }
  230 + //排序
  231 + fundOrderingUnitDetailList.sort((a, b) -> {
  232 + Long aVal = a.getTimeout() == null ? null : Long.valueOf(a.getTimeout());
  233 + Long bVal = b.getTimeout() == null ? null : Long.valueOf(b.getTimeout());
  234 + return Comparator.<Long>reverseOrder().compare(aVal, bVal);
  235 + });
  236 + bo.setFundOrderingUnitDetailList(fundOrderingUnitDetailList);
  237 + fundOrderingUnitList.add(bo);
  238 + }
  239 + //订货单位名称
  240 + if (customerNameStr.length() > 0) {
  241 + customerNameStr.deleteCharAt(customerNameStr.length() - 1);
  242 + }
  243 + getFundCoordinationBo.setOrderingUnitName(customerNameStr.toString());
  244 + getFundCoordinationBo.setFundOrderingUnitList(fundOrderingUnitList);
  245 + data.add(getFundCoordinationBo);
  246 +
  247 + return InvokeResultBuilder.success(data);
  248 + }
150 } 249 }
@@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
35 <result column="fifth_coordinate_date" property="fifthCoordinateDate"/> 35 <result column="fifth_coordinate_date" property="fifthCoordinateDate"/>
36 <result column="description" property="description"/> 36 <result column="description" property="description"/>
37 <result column="del_flag" property="delFlag"/> 37 <result column="del_flag" property="delFlag"/>
  38 + <result column="debt_status" property="debtStatus"/>
38 <result column="create_by_id" property="createById"/> 39 <result column="create_by_id" property="createById"/>
39 <result column="update_by_id" property="updateById"/> 40 <result column="update_by_id" property="updateById"/>
40 <result column="create_time" property="createTime"/> 41 <result column="create_time" property="createTime"/>
@@ -75,6 +76,7 @@ @@ -75,6 +76,7 @@
75 tb.fifth_coordinate_date, 76 tb.fifth_coordinate_date,
76 tb.description, 77 tb.description,
77 tb.del_flag, 78 tb.del_flag,
  79 + tb.debt_status,
78 tb.create_by_id, 80 tb.create_by_id,
79 tb.update_by_id, 81 tb.update_by_id,
80 tb.create_time, 82 tb.create_time,
@@ -119,7 +121,7 @@ @@ -119,7 +121,7 @@
119 AND d.name LIKE CONCAT('%', #{vo.deptName}, '%') 121 AND d.name LIKE CONCAT('%', #{vo.deptName}, '%')
120 </if> 122 </if>
121 <if test="vo.includeEndAccountReceivable == true"> 123 <if test="vo.includeEndAccountReceivable == true">
122 - AND d.end_account_receivable >0 124 + AND tb.end_account_receivable >0
123 </if> 125 </if>
124 </where> 126 </where>
125 </select> 127 </select>