Showing
17 changed files
with
206 additions
and
4 deletions
| ... | ... | @@ -971,6 +971,7 @@ CREATE TABLE `tbl_recapitalize` ( |
| 971 | 971 | `returned_amount` decimal(15,4) DEFAULT NULL COMMENT '回笼金额', |
| 972 | 972 | `dept_id` varchar(32) DEFAULT NULL COMMENT '办事处ID', |
| 973 | 973 | `factory_type` varchar(50) DEFAULT NULL COMMENT '厂别', |
| 974 | + `type` varchar(50) DEFAULT NULL COMMENT '贸易类型:外贸: OUTSIDE 内贸:INSIDE', | |
| 974 | 975 | `create_by_id` varchar(32) NOT NULL COMMENT '创建人ID', |
| 975 | 976 | `create_by` varchar(20) NOT NULL COMMENT '创建人', |
| 976 | 977 | `update_by_id` varchar(32) NOT NULL COMMENT '更新人ID', | ... | ... |
| ... | ... | @@ -74,6 +74,12 @@ public class GetRecapitalizeBo extends BaseBo<Recapitalize> { |
| 74 | 74 | @ApiModelProperty("厂别名称") |
| 75 | 75 | private String factoryTypeName; |
| 76 | 76 | |
| 77 | + /** | |
| 78 | + * 贸易类型:外贸: OUTSIDE 内贸:INSIDE | |
| 79 | + */ | |
| 80 | + @ApiModelProperty("贸易类型") | |
| 81 | + private String type; | |
| 82 | + | |
| 77 | 83 | public GetRecapitalizeBo() { |
| 78 | 84 | |
| 79 | 85 | } | ... | ... |
| ... | ... | @@ -74,6 +74,12 @@ public class QueryRecapitalizeBo extends BaseBo<Recapitalize> { |
| 74 | 74 | @ApiModelProperty("厂别名称") |
| 75 | 75 | private String factoryTypeName; |
| 76 | 76 | |
| 77 | + /** | |
| 78 | + * 贸易类型:外贸: OUTSIDE 内贸:INSIDE | |
| 79 | + */ | |
| 80 | + @ApiModelProperty("贸易类型") | |
| 81 | + private String type; | |
| 82 | + | |
| 77 | 83 | public QueryRecapitalizeBo() { |
| 78 | 84 | |
| 79 | 85 | } | ... | ... |
| ... | ... | @@ -138,10 +138,12 @@ public class RecapitalizeController extends DefaultBaseController { |
| 138 | 138 | @HasPermission({"account-manage:recoup-funds:import"}) |
| 139 | 139 | @PostMapping("/import") |
| 140 | 140 | public InvokeResult<Void> importExcel(@NotBlank(message = "ID不能为空") String id, |
| 141 | - @NotNull(message = "请上传文件") MultipartFile file) { | |
| 141 | + @NotNull(message = "请上传文件") MultipartFile file, | |
| 142 | + @NotBlank(message = "贸易类型不能为空") String type) { | |
| 142 | 143 | |
| 143 | 144 | RecapitalizeImportListener listener = new RecapitalizeImportListener(); |
| 144 | 145 | listener.setTaskId(id); |
| 146 | + listener.setType(type); | |
| 145 | 147 | ExcelUtil.read(file, RecapitalizeImportModel.class, listener).sheet().doRead(); |
| 146 | 148 | |
| 147 | 149 | return InvokeResultBuilder.success(); | ... | ... |
| ... | ... | @@ -22,11 +22,18 @@ import java.util.List; |
| 22 | 22 | |
| 23 | 23 | @Slf4j |
| 24 | 24 | public class RecapitalizeImportListener extends ExcelImportListener<RecapitalizeImportModel> { |
| 25 | + //用于接收贸易类型 | |
| 26 | + private String type; | |
| 27 | + | |
| 28 | + public void setType(String type) { | |
| 29 | + this.type = type; | |
| 30 | + } | |
| 25 | 31 | |
| 26 | 32 | @Override |
| 27 | 33 | protected void doInvoke(RecapitalizeImportModel data, AnalysisContext context) { |
| 28 | 34 | CustomerService customerService = ApplicationUtil.getBean(CustomerService.class); |
| 29 | 35 | SysDeptService sysDeptService = ApplicationUtil.getBean(SysDeptService.class); |
| 36 | + data.setType(this.type); | |
| 30 | 37 | if (StringUtil.isBlank(data.getRecapitalizeDateStr())) { |
| 31 | 38 | throw new DefaultClientException( |
| 32 | 39 | "第" + context.readRowHolder().getRowIndex() + "行“资金回笼日期”不能为空"); |
| ... | ... | @@ -89,7 +96,7 @@ public class RecapitalizeImportListener extends ExcelImportListener<Recapitalize |
| 89 | 96 | } else { |
| 90 | 97 | if (deptByName.size() > 1) { |
| 91 | 98 | throw new DefaultClientException( |
| 92 | - "第" + context.readRowHolder().getRowIndex() + "行“办事处”存在多个同名区域"); | |
| 99 | + "第" + context.readRowHolder().getRowIndex() + "行“办事处”存在多个同名办事处"); | |
| 93 | 100 | } else { |
| 94 | 101 | SysDept sysDept = deptByName.get(0); |
| 95 | 102 | data.setDeptId(sysDept.getId()); |
| ... | ... | @@ -125,6 +132,7 @@ public class RecapitalizeImportListener extends ExcelImportListener<Recapitalize |
| 125 | 132 | vo.setReturnedAmount(data.getReturnedAmount()); |
| 126 | 133 | vo.setDeptId(data.getDeptId()); |
| 127 | 134 | vo.setFactoryType(data.getFactoryType()); |
| 135 | + vo.setType(data.getType()); | |
| 128 | 136 | recapitalizeService.create(vo); |
| 129 | 137 | this.setSuccessProcess(i); |
| 130 | 138 | } | ... | ... |
| ... | ... | @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.impl.ledger; |
| 3 | 3 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 4 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 5 | 5 | import com.github.pagehelper.PageInfo; |
| 6 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 7 | +import com.lframework.starter.common.utils.StringUtil; | |
| 6 | 8 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 7 | 9 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 8 | 10 | import com.lframework.starter.web.core.utils.OpLogUtil; |
| ... | ... | @@ -15,19 +17,38 @@ import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; |
| 15 | 17 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 16 | 18 | import com.lframework.starter.common.utils.ObjectUtil; |
| 17 | 19 | import com.lframework.starter.common.utils.Assert; |
| 20 | +import com.lframework.xingyun.basedata.entity.CustomerShort; | |
| 21 | +import com.lframework.xingyun.basedata.service.customer.CustomerShortService; | |
| 22 | +import com.lframework.xingyun.basedata.vo.customer.QueryCustomerShortVo; | |
| 23 | +import com.lframework.xingyun.sc.entity.CustomerCredit; | |
| 18 | 24 | import com.lframework.xingyun.sc.entity.Recapitalize; |
| 25 | +import com.lframework.xingyun.sc.entity.ReceiptLedgerInfo; | |
| 19 | 26 | import com.lframework.xingyun.sc.mappers.RecapitalizeMapper; |
| 27 | +import com.lframework.xingyun.sc.service.customer.CustomerCreditService; | |
| 20 | 28 | import com.lframework.xingyun.sc.service.ledger.RecapitalizeService; |
| 29 | +import com.lframework.xingyun.sc.service.ledger.ReceiptLedgerInfoService; | |
| 21 | 30 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.CreateRecapitalizeVo; |
| 22 | 31 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.QueryRecapitalizeVo; |
| 23 | 32 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.UpdateRecapitalizeVo; |
| 33 | +import com.lframework.xingyun.sc.vo.ledger.receipt.CreateReceiptLedgerInfoVo; | |
| 34 | +import com.lframework.xingyun.sc.vo.ledger.receipt.QueryReceiptLedgerInfoVo; | |
| 35 | +import com.lframework.xingyun.sc.vo.ledger.receipt.UpdateReceiptLedgerInfoVo; | |
| 24 | 36 | import org.springframework.transaction.annotation.Transactional; |
| 25 | 37 | import org.springframework.stereotype.Service; |
| 26 | - | |
| 38 | +import javax.annotation.Resource; | |
| 39 | +import java.math.BigDecimal; | |
| 40 | +import java.util.Comparator; | |
| 27 | 41 | import java.util.List; |
| 42 | +import java.util.stream.Collectors; | |
| 28 | 43 | |
| 29 | 44 | @Service |
| 30 | 45 | public class RecapitalizeServiceImpl extends BaseMpServiceImpl<RecapitalizeMapper, Recapitalize> implements RecapitalizeService { |
| 46 | + @Resource | |
| 47 | + private ReceiptLedgerInfoService receiptLedgerInfoService; | |
| 48 | + @Resource | |
| 49 | + private CustomerShortService customerShortService; | |
| 50 | + @Resource | |
| 51 | + private CustomerCreditService customerCreditService; | |
| 31 | 52 | |
| 32 | 53 | @Override |
| 33 | 54 | public PageResult<Recapitalize> query(Integer pageIndex, Integer pageSize, QueryRecapitalizeVo vo) { |
| ... | ... | @@ -65,9 +86,71 @@ public class RecapitalizeServiceImpl extends BaseMpServiceImpl<RecapitalizeMappe |
| 65 | 86 | data.setReturnedAmount(vo.getReturnedAmount()); |
| 66 | 87 | data.setDeptId(vo.getDeptId()); |
| 67 | 88 | data.setFactoryType(vo.getFactoryType()); |
| 89 | + data.setType(vo.getType()); | |
| 68 | 90 | |
| 69 | 91 | getBaseMapper().insert(data); |
| 70 | - //todo fys 需要对台账处理 | |
| 92 | + //订货单位、厂别、办事处、贸易类型匹配台账数据 | |
| 93 | + QueryReceiptLedgerInfoVo vo1 = new QueryReceiptLedgerInfoVo(); | |
| 94 | + vo1.setCustomerId(vo.getOrderingUnit()); | |
| 95 | + vo1.setFactoryType(vo.getFactoryType()); | |
| 96 | + vo1.setDeptId(vo.getDeptId()); | |
| 97 | + vo1.setType(vo.getType()); | |
| 98 | + List<ReceiptLedgerInfo> query = receiptLedgerInfoService.query(vo1); | |
| 99 | + if (CollectionUtil.isNotEmpty(query)) { | |
| 100 | + //不为空代表有欠款-需要平账 | |
| 101 | + //期初应收款=回笼资金 有多条占用天数多的先平账 | |
| 102 | + List<ReceiptLedgerInfo> result = query.stream() | |
| 103 | + // 1. 过滤:startAccountReceivable 等于 returnedAmount | |
| 104 | + .filter(item -> { | |
| 105 | + BigDecimal start = item.getStartAccountReceivable(); | |
| 106 | + return start != null | |
| 107 | + && vo.getReturnedAmount() != null | |
| 108 | + && start.compareTo(vo.getReturnedAmount()) == 0; | |
| 109 | + }) | |
| 110 | + // 2. 排序:按 shipmentDate 升序(早的在前) | |
| 111 | + .sorted(Comparator.comparing(ReceiptLedgerInfo::getShipmentDate)) | |
| 112 | + .collect(Collectors.toList()); | |
| 113 | + if (CollectionUtil.isNotEmpty(result)) { | |
| 114 | + //平账 | |
| 115 | + UpdateReceiptLedgerInfoVo updateVo = new UpdateReceiptLedgerInfoVo(); | |
| 116 | + updateVo.setReturnedAmount(vo.getReturnedAmount()); | |
| 117 | + updateVo.setActualReturnedDate(vo.getRecapitalizeDate()); | |
| 118 | + updateVo.setEndAccountReceivable(BigDecimal.ZERO); | |
| 119 | + updateVo.setId(result.get(0).getId()); | |
| 120 | + receiptLedgerInfoService.reconciliation(updateVo); | |
| 121 | + } else { | |
| 122 | + throw new DefaultClientException("没有匹配的台账明细数据!"); | |
| 123 | + } | |
| 124 | + } else { | |
| 125 | + //为空保存为存款 | |
| 126 | + CreateReceiptLedgerInfoVo createVo = new CreateReceiptLedgerInfoVo(); | |
| 127 | + QueryCustomerShortVo vo2 = new QueryCustomerShortVo(); | |
| 128 | + vo2.setCustomerId(vo.getOrderingUnit()); | |
| 129 | + List<CustomerShort> customerShortList = customerShortService.query(vo2); | |
| 130 | + if (CollectionUtil.isNotEmpty(customerShortList)) { | |
| 131 | + createVo.setCustomerShortId(customerShortList.get(0).getId()); | |
| 132 | + } | |
| 133 | + CustomerCredit customerCredit = customerCreditService.getByCustomerId(vo.getOrderingUnit()); | |
| 134 | + if (customerCredit != null) { | |
| 135 | + //额度 | |
| 136 | + if (StringUtil.isNotEmpty(customerCredit.getCompanyCreditLimit())) { | |
| 137 | + createVo.setQuota(new BigDecimal(customerCredit.getCompanyCreditLimit())); | |
| 138 | + } | |
| 139 | + //结算期限 | |
| 140 | + if (StringUtil.isNotEmpty(customerCredit.getCompanySettlementPeriod())) { | |
| 141 | + createVo.setSettleTerm(customerCredit.getCompanySettlementPeriod()); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + createVo.setDeptId(vo.getDeptId()); | |
| 145 | + createVo.setCustomerId(vo.getOrderingUnit()); | |
| 146 | + createVo.setFactoryType(vo.getFactoryType()); | |
| 147 | + createVo.setFactoryType(vo.getFactoryType()); | |
| 148 | + createVo.setActualReturnedDate(vo.getRecapitalizeDate()); | |
| 149 | + createVo.setReturnedAmount(vo.getReturnedAmount()); | |
| 150 | + createVo.setEndAccountReceivable(vo.getReturnedAmount().negate()); | |
| 151 | + createVo.setDebtStatus("DEPOSIT"); | |
| 152 | + receiptLedgerInfoService.create(createVo); | |
| 153 | + } | |
| 71 | 154 | |
| 72 | 155 | OpLogUtil.setVariable("id", data.getId()); |
| 73 | 156 | OpLogUtil.setExtra(vo); | ... | ... |
| ... | ... | @@ -151,6 +151,7 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
| 151 | 151 | data.setFourthCoordinateDate(vo.getFourthCoordinateDate()); |
| 152 | 152 | data.setFifthCoordinateDate(vo.getFifthCoordinateDate()); |
| 153 | 153 | data.setDescription(vo.getDescription()); |
| 154 | + data.setDebtStatus(vo.getDebtStatus()); | |
| 154 | 155 | getBaseMapper().insert(data); |
| 155 | 156 | |
| 156 | 157 | OpLogUtil.setVariable("id", data.getId()); |
| ... | ... | @@ -587,4 +588,24 @@ public class ReceiptLedgerInfoServiceImpl extends BaseMpServiceImpl<ReceiptLedge |
| 587 | 588 | OpLogUtil.setVariable("id", data.getId()); |
| 588 | 589 | OpLogUtil.setExtra(data.getId()); |
| 589 | 590 | } |
| 591 | + | |
| 592 | + @OpLog(type = OtherOpLogType.class, name = "平账,ID:{}", params = {"#id"}) | |
| 593 | + @Transactional(rollbackFor = Exception.class) | |
| 594 | + @Override | |
| 595 | + public void reconciliation(UpdateReceiptLedgerInfoVo vo) { | |
| 596 | + ReceiptLedgerInfo data = getBaseMapper().selectById(vo.getId()); | |
| 597 | + if (ObjectUtil.isNull(data)) { | |
| 598 | + throw new DefaultClientException("应收款台账明细不存在!"); | |
| 599 | + } | |
| 600 | + LambdaUpdateWrapper<ReceiptLedgerInfo> updateWrapper = Wrappers.lambdaUpdate(ReceiptLedgerInfo.class) | |
| 601 | + .set(ReceiptLedgerInfo::getActualReturnedDate, vo.getActualReturnedDate() == null ? null : vo.getActualReturnedDate()) | |
| 602 | + .set(ReceiptLedgerInfo::getReturnedAmount, vo.getReturnedAmount() == null ? null : vo.getReturnedAmount()) | |
| 603 | + .set(ReceiptLedgerInfo::getEndAccountReceivable, vo.getEndAccountReceivable() == null ? null : vo.getEndAccountReceivable()) | |
| 604 | + .set(ReceiptLedgerInfo::getDebtStatus, "SETTLE_UP") | |
| 605 | + .eq(ReceiptLedgerInfo::getId, vo.getId()); | |
| 606 | + | |
| 607 | + getBaseMapper().update(updateWrapper); | |
| 608 | + OpLogUtil.setVariable("id", data.getId()); | |
| 609 | + OpLogUtil.setExtra(vo); | |
| 610 | + } | |
| 590 | 611 | } | ... | ... |
| ... | ... | @@ -105,4 +105,11 @@ public interface ReceiptLedgerInfoService extends BaseMpService<ReceiptLedgerInf |
| 105 | 105 | * @param debtStatus 清欠状态 |
| 106 | 106 | */ |
| 107 | 107 | void updateCoordinateDate(String id, LocalDate coordinateDate, String debtStatus); |
| 108 | + | |
| 109 | + /** | |
| 110 | + * 平账 | |
| 111 | + * | |
| 112 | + * @param vo 数据 | |
| 113 | + */ | |
| 114 | + void reconciliation(UpdateReceiptLedgerInfoVo vo); | |
| 108 | 115 | } | ... | ... |
| ... | ... | @@ -59,4 +59,10 @@ public class CreateRecapitalizeVo implements BaseVo, Serializable { |
| 59 | 59 | @Length(message = "厂别最多允许50个字符!") |
| 60 | 60 | private String factoryType; |
| 61 | 61 | |
| 62 | + /** | |
| 63 | + * 贸易类型:外贸: OUTSIDE 内贸:INSIDE | |
| 64 | + */ | |
| 65 | + @ApiModelProperty("贸易类型") | |
| 66 | + private String type; | |
| 67 | + | |
| 62 | 68 | } | ... | ... |
| ... | ... | @@ -47,4 +47,10 @@ public class QueryRecapitalizeVo extends PageVo implements BaseVo, Serializable |
| 47 | 47 | @ApiModelProperty("厂别") |
| 48 | 48 | private String factoryType; |
| 49 | 49 | |
| 50 | + /** | |
| 51 | + * 贸易类型:外贸: OUTSIDE 内贸:INSIDE | |
| 52 | + */ | |
| 53 | + @ApiModelProperty("贸易类型") | |
| 54 | + private String type; | |
| 55 | + | |
| 50 | 56 | } | ... | ... |
| 1 | 1 | package com.lframework.xingyun.sc.vo.ledger.receipt; |
| 2 | 2 | |
| 3 | +import com.lframework.starter.web.core.components.validation.IsNumberPrecision; | |
| 3 | 4 | import lombok.Data; |
| 4 | 5 | import javax.validation.constraints.NotBlank; |
| 6 | +import java.math.BigDecimal; | |
| 5 | 7 | import java.time.LocalDate; |
| 6 | 8 | import com.lframework.starter.web.core.vo.BaseVo; |
| 7 | 9 | import javax.validation.constraints.NotNull; |
| ... | ... | @@ -46,4 +48,30 @@ public class UpdateReceiptLedgerInfoVo implements BaseVo, Serializable { |
| 46 | 48 | @Length(message = "说明最多允许200个字符!") |
| 47 | 49 | private String description; |
| 48 | 50 | |
| 51 | + /** | |
| 52 | + * 实际回笼日期 | |
| 53 | + */ | |
| 54 | + @ApiModelProperty(value = "实际回笼日期", required = true) | |
| 55 | + @NotNull(message = "请输入实际回笼日期!") | |
| 56 | + @TypeMismatch(message = "实际回笼日期格式有误!") | |
| 57 | + private LocalDate actualReturnedDate; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 回笼金额 | |
| 61 | + */ | |
| 62 | + @ApiModelProperty(value = "回笼金额", required = true) | |
| 63 | + @NotNull(message = "请输入回笼金额!") | |
| 64 | + @TypeMismatch(message = "回笼金额格式有误!") | |
| 65 | + @IsNumberPrecision(message = "回笼金额最多允许4位小数!", value = 4) | |
| 66 | + private BigDecimal returnedAmount; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 期末应收账款 | |
| 70 | + */ | |
| 71 | + @ApiModelProperty(value = "期末应收账款", required = true) | |
| 72 | + @NotNull(message = "请输入期末应收账款!") | |
| 73 | + @TypeMismatch(message = "期末应收账款格式有误!") | |
| 74 | + @IsNumberPrecision(message = "期末应收账款最多允许4位小数!", value = 4) | |
| 75 | + private BigDecimal endAccountReceivable; | |
| 76 | + | |
| 49 | 77 | } | ... | ... |
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | <result column="dept_id" property="deptId"/> |
| 12 | 12 | <result column="dept_name" property="deptName"/> |
| 13 | 13 | <result column="factory_type" property="factoryType"/> |
| 14 | + <result column="type" property="type"/> | |
| 14 | 15 | <result column="create_by_id" property="createById"/> |
| 15 | 16 | <result column="create_by" property="createBy"/> |
| 16 | 17 | <result column="update_by_id" property="updateById"/> |
| ... | ... | @@ -29,6 +30,7 @@ |
| 29 | 30 | tb.dept_id, |
| 30 | 31 | d.name AS dept_name, |
| 31 | 32 | tb.factory_type, |
| 33 | + tb.type, | |
| 32 | 34 | tb.create_by_id, |
| 33 | 35 | tb.create_by, |
| 34 | 36 | tb.update_by_id, |
| ... | ... | @@ -66,6 +68,9 @@ |
| 66 | 68 | <if test="vo.factoryType != null and vo.factoryType != ''"> |
| 67 | 69 | AND tb.factory_type = #{vo.factoryType} |
| 68 | 70 | </if> |
| 71 | + <if test="vo.type != null and vo.type != ''"> | |
| 72 | + AND tb.type = #{vo.type} | |
| 73 | + </if> | |
| 69 | 74 | </where> |
| 70 | 75 | ORDER BY tb.create_time DESC |
| 71 | 76 | </select> | ... | ... |
| ... | ... | @@ -101,6 +101,9 @@ |
| 101 | 101 | <if test="vo.type != null and vo.type != ''"> |
| 102 | 102 | AND tb.type = #{vo.type} |
| 103 | 103 | </if> |
| 104 | + <if test="vo.factoryType != null and vo.factoryType != ''"> | |
| 105 | + AND tb.factory_type = #{vo.factoryType} | |
| 106 | + </if> | |
| 104 | 107 | <if test="vo.customerShortId != null and vo.customerShortId != ''"> |
| 105 | 108 | AND tb.customer_short_id = #{vo.customerShortId} |
| 106 | 109 | </if> | ... | ... |