Showing
4 changed files
with
241 additions
and
19 deletions
| @@ -11,6 +11,8 @@ import javax.validation.constraints.NotBlank; | @@ -11,6 +11,8 @@ import javax.validation.constraints.NotBlank; | ||
| 11 | import com.lframework.xingyun.sc.bo.ledger.recapitalize.GetRecapitalizeBo; | 11 | import com.lframework.xingyun.sc.bo.ledger.recapitalize.GetRecapitalizeBo; |
| 12 | import com.lframework.xingyun.sc.bo.ledger.recapitalize.QueryRecapitalizeBo; | 12 | import com.lframework.xingyun.sc.bo.ledger.recapitalize.QueryRecapitalizeBo; |
| 13 | import com.lframework.xingyun.sc.entity.Recapitalize; | 13 | import com.lframework.xingyun.sc.entity.Recapitalize; |
| 14 | +import com.lframework.xingyun.sc.excel.ledger.RecapitalizeImportListener; | ||
| 15 | +import com.lframework.xingyun.sc.excel.ledger.RecapitalizeImportModel; | ||
| 14 | import com.lframework.xingyun.sc.service.ledger.RecapitalizeService; | 16 | import com.lframework.xingyun.sc.service.ledger.RecapitalizeService; |
| 15 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.CreateRecapitalizeVo; | 17 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.CreateRecapitalizeVo; |
| 16 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.QueryRecapitalizeVo; | 18 | import com.lframework.xingyun.sc.vo.ledger.recapitalize.QueryRecapitalizeVo; |
| @@ -125,23 +127,23 @@ public class RecapitalizeController extends DefaultBaseController { | @@ -125,23 +127,23 @@ public class RecapitalizeController extends DefaultBaseController { | ||
| 125 | return InvokeResultBuilder.success(); | 127 | return InvokeResultBuilder.success(); |
| 126 | } | 128 | } |
| 127 | 129 | ||
| 128 | -// @ApiOperation("下载导入模板") | ||
| 129 | -// @HasPermission({"account-manage:recoup-funds:import"}) | ||
| 130 | -// @GetMapping("/import/template") | ||
| 131 | -// public void downloadImportTemplate(HttpServletResponse response) throws IOException { | ||
| 132 | -// ExcelUtil.exportXls("回笼资金导入模板", CustomerCreditChangeImportModel.class); | ||
| 133 | -// } | ||
| 134 | -// | ||
| 135 | -// @ApiOperation("导入") | ||
| 136 | -// @HasPermission({"account-manage:recoup-funds:import"}) | ||
| 137 | -// @PostMapping("/import") | ||
| 138 | -// public InvokeResult<Void> importExcel(@NotBlank(message = "ID不能为空") String id, | ||
| 139 | -// @NotNull(message = "请上传文件") MultipartFile file) { | ||
| 140 | -// | ||
| 141 | -// CustomerCreditChangeImportListener listener = new CustomerCreditChangeImportListener(); | ||
| 142 | -// listener.setTaskId(id); | ||
| 143 | -// ExcelUtil.read(file, CustomerCreditChangeImportModel.class, listener).sheet().doRead(); | ||
| 144 | -// | ||
| 145 | -// return InvokeResultBuilder.success(); | ||
| 146 | -// } | 130 | + @ApiOperation("下载导入模板") |
| 131 | + @HasPermission({"account-manage:recoup-funds:import"}) | ||
| 132 | + @GetMapping("/import/template") | ||
| 133 | + public void downloadImportTemplate(HttpServletResponse response) throws IOException { | ||
| 134 | + ExcelUtil.exportXls("回笼资金导入模板", RecapitalizeImportModel.class); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + @ApiOperation("导入") | ||
| 138 | + @HasPermission({"account-manage:recoup-funds:import"}) | ||
| 139 | + @PostMapping("/import") | ||
| 140 | + public InvokeResult<Void> importExcel(@NotBlank(message = "ID不能为空") String id, | ||
| 141 | + @NotNull(message = "请上传文件") MultipartFile file) { | ||
| 142 | + | ||
| 143 | + RecapitalizeImportListener listener = new RecapitalizeImportListener(); | ||
| 144 | + listener.setTaskId(id); | ||
| 145 | + ExcelUtil.read(file, RecapitalizeImportModel.class, listener).sheet().doRead(); | ||
| 146 | + | ||
| 147 | + return InvokeResultBuilder.success(); | ||
| 148 | + } | ||
| 147 | } | 149 | } |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/ledger/RecapitalizeImportListener.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.excel.ledger; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.context.AnalysisContext; | ||
| 4 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | ||
| 5 | +import com.lframework.starter.common.utils.StringUtil; | ||
| 6 | +import com.lframework.starter.web.core.components.excel.ExcelImportListener; | ||
| 7 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | ||
| 8 | +import com.lframework.starter.web.inner.entity.SysDept; | ||
| 9 | +import com.lframework.starter.web.inner.service.system.SysDeptService; | ||
| 10 | +import com.lframework.xingyun.basedata.entity.Customer; | ||
| 11 | +import com.lframework.xingyun.basedata.service.customer.CustomerService; | ||
| 12 | +import com.lframework.xingyun.sc.service.ledger.RecapitalizeService; | ||
| 13 | +import com.lframework.xingyun.sc.vo.ledger.recapitalize.CreateRecapitalizeVo; | ||
| 14 | +import lombok.extern.slf4j.Slf4j; | ||
| 15 | +import org.apache.commons.collections.CollectionUtils; | ||
| 16 | + | ||
| 17 | +import java.math.BigDecimal; | ||
| 18 | +import java.time.LocalDate; | ||
| 19 | +import java.time.format.DateTimeFormatter; | ||
| 20 | +import java.time.format.DateTimeParseException; | ||
| 21 | +import java.util.List; | ||
| 22 | + | ||
| 23 | +@Slf4j | ||
| 24 | +public class RecapitalizeImportListener extends ExcelImportListener<RecapitalizeImportModel> { | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + protected void doInvoke(RecapitalizeImportModel data, AnalysisContext context) { | ||
| 28 | + CustomerService customerService = ApplicationUtil.getBean(CustomerService.class); | ||
| 29 | + SysDeptService sysDeptService = ApplicationUtil.getBean(SysDeptService.class); | ||
| 30 | + if (StringUtil.isBlank(data.getRecapitalizeDateStr())) { | ||
| 31 | + throw new DefaultClientException( | ||
| 32 | + "第" + context.readRowHolder().getRowIndex() + "行“资金回笼日期”不能为空"); | ||
| 33 | + } else { | ||
| 34 | + String dateStr = data.getRecapitalizeDateStr().trim(); | ||
| 35 | + try { | ||
| 36 | + LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")); | ||
| 37 | + data.setRecapitalizeDate(localDate); | ||
| 38 | + } catch (DateTimeParseException e) { | ||
| 39 | + try { | ||
| 40 | + LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy/M/d")); | ||
| 41 | + data.setRecapitalizeDate(localDate); | ||
| 42 | + } catch (DateTimeParseException ex) { | ||
| 43 | + try { | ||
| 44 | + // 支持 "2025年12月3日" 或 "2025年12月03日" | ||
| 45 | + LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy'年'M'月'd'日'")); | ||
| 46 | + data.setRecapitalizeDate(localDate); | ||
| 47 | + } catch (DateTimeParseException ex2) { | ||
| 48 | + throw new DefaultClientException( | ||
| 49 | + "第" + context.readRowHolder().getRowIndex() + "行”资金回笼日期“格式错误!"); | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + if (StringUtil.isBlank(data.getOrderingUnitName())) { | ||
| 56 | + throw new DefaultClientException( | ||
| 57 | + "第" + context.readRowHolder().getRowIndex() + "行“订货单位名称”不能为空"); | ||
| 58 | + } else { | ||
| 59 | + Customer customer = customerService.getByName(data.getOrderingUnitName()); | ||
| 60 | + if (customer == null) { | ||
| 61 | + throw new DefaultClientException( | ||
| 62 | + "第" + context.readRowHolder().getRowIndex() + "行“订货单位名称”不存在"); | ||
| 63 | + } else { | ||
| 64 | + data.setOrderingUnit(customer.getId()); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + if (StringUtil.isBlank(data.getReturnedAmountStr())) { | ||
| 69 | + throw new DefaultClientException( | ||
| 70 | + "第" + context.readRowHolder().getRowIndex() + "行“回笼金额”不能为空"); | ||
| 71 | + } else { | ||
| 72 | + try { | ||
| 73 | + BigDecimal bigDecimal = new BigDecimal(data.getReturnedAmountStr()); | ||
| 74 | + data.setReturnedAmount(bigDecimal); | ||
| 75 | + } catch (NumberFormatException e) { | ||
| 76 | + throw new DefaultClientException( | ||
| 77 | + "第" + context.readRowHolder().getRowIndex() + "行“回笼金额”格式错误"); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + if (StringUtil.isBlank(data.getDeptName())) { | ||
| 82 | + throw new DefaultClientException( | ||
| 83 | + "第" + context.readRowHolder().getRowIndex() + "行“办事处名称”不能为空"); | ||
| 84 | + } else { | ||
| 85 | + List<SysDept> deptByName = sysDeptService.getDeptByName(data.getDeptName()); | ||
| 86 | + if (CollectionUtils.isEmpty(deptByName)) { | ||
| 87 | + throw new DefaultClientException( | ||
| 88 | + "第" + context.readRowHolder().getRowIndex() + "行“办事处”不存在"); | ||
| 89 | + } else { | ||
| 90 | + if (deptByName.size() > 1) { | ||
| 91 | + throw new DefaultClientException( | ||
| 92 | + "第" + context.readRowHolder().getRowIndex() + "行“办事处”存在多个同名区域"); | ||
| 93 | + } else { | ||
| 94 | + SysDept sysDept = deptByName.get(0); | ||
| 95 | + data.setDeptId(sysDept.getId()); | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + if (StringUtil.isBlank(data.getFactoryTypeName())) { | ||
| 101 | + throw new DefaultClientException( | ||
| 102 | + "第" + context.readRowHolder().getRowIndex() + "行“厂别”不能为空"); | ||
| 103 | + } else { | ||
| 104 | + if (data.getFactoryTypeName().equals("安徽楚江高精铜带有限公司")) { | ||
| 105 | + data.setFactoryType("GJ"); | ||
| 106 | + } else if (data.getFactoryTypeName().equals("安徽楚江科技新材料股份有限公司")) { | ||
| 107 | + data.setFactoryType("XC"); | ||
| 108 | + } else { | ||
| 109 | + throw new DefaultClientException( | ||
| 110 | + "第" + context.readRowHolder().getRowIndex() + "行“厂别”不存在"); | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + @Override | ||
| 117 | + protected void afterAllAnalysed(AnalysisContext context) { | ||
| 118 | + RecapitalizeService recapitalizeService = ApplicationUtil.getBean(RecapitalizeService.class); | ||
| 119 | + List<RecapitalizeImportModel> datas = this.getDatas(); | ||
| 120 | + for (int i = 0; i < datas.size(); i++) { | ||
| 121 | + RecapitalizeImportModel data = datas.get(i); | ||
| 122 | + CreateRecapitalizeVo vo = new CreateRecapitalizeVo(); | ||
| 123 | + vo.setRecapitalizeDate(data.getRecapitalizeDate()); | ||
| 124 | + vo.setOrderingUnit(data.getOrderingUnit()); | ||
| 125 | + vo.setReturnedAmount(data.getReturnedAmount()); | ||
| 126 | + vo.setDeptId(data.getDeptId()); | ||
| 127 | + vo.setFactoryType(data.getFactoryType()); | ||
| 128 | + recapitalizeService.create(vo); | ||
| 129 | + this.setSuccessProcess(i); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + @Override | ||
| 134 | + protected void doComplete() { | ||
| 135 | + } | ||
| 136 | +} |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/ledger/RecapitalizeImportModel.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.excel.ledger; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.annotation.ExcelIgnore; | ||
| 4 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 5 | +import com.lframework.starter.web.core.annotations.excel.ExcelRequired; | ||
| 6 | +import com.lframework.starter.web.core.components.excel.ExcelModel; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.math.BigDecimal; | ||
| 10 | +import java.time.LocalDate; | ||
| 11 | + | ||
| 12 | +@Data | ||
| 13 | +public class RecapitalizeImportModel implements ExcelModel { | ||
| 14 | + | ||
| 15 | + @ExcelIgnore | ||
| 16 | + private String id; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 资金回笼日期 | ||
| 20 | + */ | ||
| 21 | + @ExcelRequired | ||
| 22 | + @ExcelProperty("资金回笼日期") | ||
| 23 | + private String recapitalizeDateStr; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 资金回笼日期 | ||
| 27 | + */ | ||
| 28 | + @ExcelIgnore | ||
| 29 | + private LocalDate recapitalizeDate; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 订货单位名称 | ||
| 33 | + */ | ||
| 34 | + @ExcelRequired | ||
| 35 | + @ExcelProperty("订货单位名称") | ||
| 36 | + private String orderingUnitName; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 订货单位ID | ||
| 40 | + */ | ||
| 41 | + @ExcelIgnore | ||
| 42 | + private String orderingUnit; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 回笼金额 | ||
| 46 | + */ | ||
| 47 | + @ExcelRequired | ||
| 48 | + @ExcelProperty("回笼金额") | ||
| 49 | + private String returnedAmountStr; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 回笼金额 | ||
| 53 | + */ | ||
| 54 | + @ExcelIgnore | ||
| 55 | + private BigDecimal returnedAmount; | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 办事处名称 | ||
| 59 | + */ | ||
| 60 | + @ExcelRequired | ||
| 61 | + @ExcelProperty("办事处名称") | ||
| 62 | + private String deptName; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 办事处ID | ||
| 66 | + */ | ||
| 67 | + @ExcelIgnore | ||
| 68 | + private String deptId; | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 厂别 | ||
| 72 | + */ | ||
| 73 | + @ExcelRequired | ||
| 74 | + @ExcelProperty("厂别") | ||
| 75 | + private String factoryTypeName; | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 厂别编码 | ||
| 79 | + */ | ||
| 80 | + @ExcelIgnore | ||
| 81 | + private String factoryType; | ||
| 82 | + | ||
| 83 | +} |
| @@ -67,6 +67,7 @@ public class RecapitalizeServiceImpl extends BaseMpServiceImpl<RecapitalizeMappe | @@ -67,6 +67,7 @@ public class RecapitalizeServiceImpl extends BaseMpServiceImpl<RecapitalizeMappe | ||
| 67 | data.setFactoryType(vo.getFactoryType()); | 67 | data.setFactoryType(vo.getFactoryType()); |
| 68 | 68 | ||
| 69 | getBaseMapper().insert(data); | 69 | getBaseMapper().insert(data); |
| 70 | + //todo fys 需要对台账处理 | ||
| 70 | 71 | ||
| 71 | OpLogUtil.setVariable("id", data.getId()); | 72 | OpLogUtil.setVariable("id", data.getId()); |
| 72 | OpLogUtil.setExtra(vo); | 73 | OpLogUtil.setExtra(vo); |