Showing
12 changed files
with
523 additions
and
86 deletions
| ... | ... | @@ -67,7 +67,7 @@ create table if not exists `tbl_contract_framework` ( |
| 67 | 67 | `company` varchar(50) not null comment '所属单位', |
| 68 | 68 | `has_framework_agreement` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否签订框架合同', |
| 69 | 69 | `material_type_id` varchar(32) NOT NULL COMMENT '品种id', |
| 70 | - `validity_time` datetime comment '期限', | |
| 70 | + `validity_time` date comment '期限', | |
| 71 | 71 | `create_by_id` varchar(32) not null comment '创建人ID', |
| 72 | 72 | `create_by` varchar(20) not null comment '创建人', |
| 73 | 73 | `update_by_id` varchar(32) not null comment '更新人ID', | ... | ... |
| ... | ... | @@ -4,9 +4,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | 4 | import com.lframework.starter.common.constants.StringPool; |
| 5 | 5 | import com.lframework.starter.web.core.bo.BaseBo; |
| 6 | 6 | |
| 7 | -import java.time.LocalDateTime; | |
| 7 | +import java.time.LocalDate; | |
| 8 | 8 | |
| 9 | -import com.lframework.starter.web.core.components.validation.TypeMismatch; | |
| 10 | 9 | import com.lframework.xingyun.sc.entity.ContractFramework; |
| 11 | 10 | import io.swagger.annotations.ApiModelProperty; |
| 12 | 11 | |
| ... | ... | @@ -72,8 +71,8 @@ public class QueryContractFrameworkBo extends BaseBo<ContractFramework> { |
| 72 | 71 | * 期限 |
| 73 | 72 | */ |
| 74 | 73 | @ApiModelProperty("期限") |
| 75 | - @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | |
| 76 | - private LocalDateTime validityTime; | |
| 74 | + @JsonFormat(pattern = StringPool.DATE_PATTERN) | |
| 75 | + private LocalDate validityTime; | |
| 77 | 76 | |
| 78 | 77 | /** |
| 79 | 78 | * 是否签订框架合同 | ... | ... |
| ... | ... | @@ -2,73 +2,78 @@ package com.lframework.xingyun.sc.components.code; |
| 2 | 2 | |
| 3 | 3 | public interface GenerateCodeTypePool { |
| 4 | 4 | |
| 5 | - /** | |
| 6 | - * 采购订单 | |
| 7 | - */ | |
| 8 | - Integer PURCHASE_ORDER = 200; | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * 采购收货单 | |
| 12 | - */ | |
| 13 | - Integer RECEIVE_SHEET = 201; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * 采购退单 | |
| 17 | - */ | |
| 18 | - Integer PURCHASE_RETURN = 202; | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * 销售订单 | |
| 22 | - */ | |
| 23 | - Integer SALE_ORDER = 203; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 销售出库单 | |
| 27 | - */ | |
| 28 | - Integer SALE_OUT_SHEET = 204; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 销售退货单 | |
| 32 | - */ | |
| 33 | - Integer SALE_RETURN = 205; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 零售出库单 | |
| 37 | - */ | |
| 38 | - Integer RETAIL_OUT_SHEET = 206; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * 零售退货单 | |
| 42 | - */ | |
| 43 | - Integer RETAIL_RETURN = 207; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * 预先盘点单 | |
| 47 | - */ | |
| 48 | - Integer PRE_TAKE_STOCK_SHEET = 208; | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * 盘点任务 | |
| 52 | - */ | |
| 53 | - Integer TAKE_STOCK_PLAN = 209; | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 盘点单 | |
| 57 | - */ | |
| 58 | - Integer TAKE_STOCK_SHEET = 210; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * 库存调整单 | |
| 62 | - */ | |
| 63 | - Integer STOCK_ADJUST_SHEET = 212; | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * 仓库调拨单 | |
| 67 | - */ | |
| 68 | - Integer SC_TRANSFER_ORDER = 213; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * 物流单 | |
| 72 | - */ | |
| 73 | - Integer LOGISTICS_SHEET = 214; | |
| 5 | + /** | |
| 6 | + * 采购订单 | |
| 7 | + */ | |
| 8 | + Integer PURCHASE_ORDER = 200; | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * 采购收货单 | |
| 12 | + */ | |
| 13 | + Integer RECEIVE_SHEET = 201; | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 采购退单 | |
| 17 | + */ | |
| 18 | + Integer PURCHASE_RETURN = 202; | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 销售订单 | |
| 22 | + */ | |
| 23 | + Integer SALE_ORDER = 203; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 销售出库单 | |
| 27 | + */ | |
| 28 | + Integer SALE_OUT_SHEET = 204; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 销售退货单 | |
| 32 | + */ | |
| 33 | + Integer SALE_RETURN = 205; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 零售出库单 | |
| 37 | + */ | |
| 38 | + Integer RETAIL_OUT_SHEET = 206; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 零售退货单 | |
| 42 | + */ | |
| 43 | + Integer RETAIL_RETURN = 207; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 预先盘点单 | |
| 47 | + */ | |
| 48 | + Integer PRE_TAKE_STOCK_SHEET = 208; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 盘点任务 | |
| 52 | + */ | |
| 53 | + Integer TAKE_STOCK_PLAN = 209; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 盘点单 | |
| 57 | + */ | |
| 58 | + Integer TAKE_STOCK_SHEET = 210; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 库存调整单 | |
| 62 | + */ | |
| 63 | + Integer STOCK_ADJUST_SHEET = 212; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 仓库调拨单 | |
| 67 | + */ | |
| 68 | + Integer SC_TRANSFER_ORDER = 213; | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 物流单 | |
| 72 | + */ | |
| 73 | + Integer LOGISTICS_SHEET = 214; | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * 框架合同 | |
| 77 | + */ | |
| 78 | + Integer CONTRACT_FRAMEWORK = 401; | |
| 74 | 79 | } | ... | ... |
| 1 | 1 | package com.lframework.xingyun.sc.controller.contract; |
| 2 | 2 | |
| 3 | 3 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 4 | +import com.lframework.starter.common.utils.DateUtil; | |
| 5 | +import com.lframework.starter.common.utils.StringUtil; | |
| 6 | +import com.lframework.starter.mq.core.utils.ExportTaskUtil; | |
| 4 | 7 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 5 | 8 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| 9 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | |
| 6 | 10 | import com.lframework.starter.web.core.controller.DefaultBaseController; |
| 11 | +import com.lframework.starter.web.core.utils.ExcelUtil; | |
| 7 | 12 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 8 | 13 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 9 | 14 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 15 | +import com.lframework.starter.web.inner.bo.system.user.GetSysUserBo; | |
| 10 | 16 | import com.lframework.starter.web.inner.entity.SysDataDicItem; |
| 17 | +import com.lframework.starter.web.inner.entity.SysDept; | |
| 18 | +import com.lframework.starter.web.inner.entity.SysUser; | |
| 19 | +import com.lframework.starter.web.inner.service.GenerateCodeService; | |
| 11 | 20 | import com.lframework.starter.web.inner.service.system.SysDataDicItemService; |
| 21 | +import com.lframework.starter.web.inner.service.system.SysDeptService; | |
| 22 | +import com.lframework.starter.web.inner.service.system.SysUserService; | |
| 12 | 23 | import com.lframework.xingyun.basedata.entity.Customer; |
| 13 | 24 | import com.lframework.xingyun.basedata.entity.ProductVariety; |
| 14 | 25 | import com.lframework.xingyun.basedata.service.customer.CustomerService; |
| 15 | 26 | import com.lframework.xingyun.basedata.service.product.ProductVarietyService; |
| 16 | 27 | import com.lframework.xingyun.sc.bo.contract.QueryContractFrameworkBo; |
| 28 | +import com.lframework.xingyun.sc.components.code.GenerateCodeTypePool; | |
| 17 | 29 | import com.lframework.xingyun.sc.entity.ContractFramework; |
| 30 | +import com.lframework.xingyun.sc.excel.contract.ContractFrameworkExportTaskWorker; | |
| 31 | +import com.lframework.xingyun.sc.excel.contract.ContractFrameworkImportListener; | |
| 32 | +import com.lframework.xingyun.sc.excel.contract.ContractFrameworkImportModel; | |
| 18 | 33 | import com.lframework.xingyun.sc.service.contract.ContractFrameworkService; |
| 19 | 34 | import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractFrameworkVo; |
| 20 | 35 | import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractFrameworkVo; |
| ... | ... | @@ -28,9 +43,13 @@ import org.apache.commons.lang3.StringUtils; |
| 28 | 43 | import org.springframework.beans.factory.annotation.Autowired; |
| 29 | 44 | import org.springframework.validation.annotation.Validated; |
| 30 | 45 | import org.springframework.web.bind.annotation.*; |
| 46 | +import org.springframework.web.multipart.MultipartFile; | |
| 31 | 47 | |
| 32 | 48 | import javax.validation.Valid; |
| 33 | 49 | import javax.validation.constraints.NotBlank; |
| 50 | +import javax.validation.constraints.NotNull; | |
| 51 | +import java.time.LocalDate; | |
| 52 | +import java.time.format.DateTimeFormatter; | |
| 34 | 53 | import java.util.HashMap; |
| 35 | 54 | import java.util.List; |
| 36 | 55 | import java.util.Map; |
| ... | ... | @@ -54,8 +73,14 @@ public class ContractFrameworkController extends DefaultBaseController { |
| 54 | 73 | private CustomerService customerService; |
| 55 | 74 | @Autowired |
| 56 | 75 | private SysDataDicItemService sysDataDicItemService; |
| 76 | + @Autowired | |
| 77 | + private SysUserService sysUserService; | |
| 78 | + @Autowired | |
| 79 | + private SysDeptService sysDeptService; | |
| 80 | + @Autowired | |
| 81 | + private GenerateCodeService generateCodeService; | |
| 57 | 82 | |
| 58 | - private static final String SUPPLIER_DIC_CODE = "SUPPLIER"; | |
| 83 | + public static final String SUPPLIER_DIC_CODE = "SUPPLIER"; | |
| 59 | 84 | |
| 60 | 85 | /** |
| 61 | 86 | * 查询列表 |
| ... | ... | @@ -132,6 +157,31 @@ public class ContractFrameworkController extends DefaultBaseController { |
| 132 | 157 | return InvokeResultBuilder.success(contractFrameworkService.create(vo)); |
| 133 | 158 | } |
| 134 | 159 | |
| 160 | + @ApiOperation("获取code") | |
| 161 | + @HasPermission({"contractFramework:contractFramework:add"}) | |
| 162 | + @GetMapping("/code") | |
| 163 | + public InvokeResult<String> code(String company) { | |
| 164 | + StringBuilder stringBuilder = new StringBuilder(); | |
| 165 | + LocalDate now = LocalDate.now(); | |
| 166 | + stringBuilder.append(now.format(DateTimeFormatter.ofPattern("yy"))).append(company); | |
| 167 | + // 获取当前人员及所在部门 | |
| 168 | + String currentUserId = SecurityUtil.getCurrentUser().getId(); | |
| 169 | + SysUser sysUser = sysUserService.findById(currentUserId); | |
| 170 | + if (sysUser != null) { | |
| 171 | + GetSysUserBo getSysUserBo = new GetSysUserBo(sysUser); | |
| 172 | + //部门 | |
| 173 | + List<String> depts = getSysUserBo.getDepts(); | |
| 174 | + if (CollectionUtils.isNotEmpty(depts)) { | |
| 175 | + String deptId = depts.get(0); | |
| 176 | + SysDept sysDept = sysDeptService.findById(deptId); | |
| 177 | + stringBuilder.append(sysDept.getCode()); | |
| 178 | + } | |
| 179 | + } | |
| 180 | + | |
| 181 | + stringBuilder.append(generateCodeService.generate(GenerateCodeTypePool.CONTRACT_FRAMEWORK)); | |
| 182 | + return InvokeResultBuilder.success(stringBuilder.toString()); | |
| 183 | + } | |
| 184 | + | |
| 135 | 185 | /** |
| 136 | 186 | * 根据ID查询 |
| 137 | 187 | */ |
| ... | ... | @@ -173,4 +223,40 @@ public class ContractFrameworkController extends DefaultBaseController { |
| 173 | 223 | |
| 174 | 224 | return InvokeResultBuilder.success(); |
| 175 | 225 | } |
| 226 | + | |
| 227 | + /** | |
| 228 | + * 导出 | |
| 229 | + * | |
| 230 | + * @param vo | |
| 231 | + * @return | |
| 232 | + */ | |
| 233 | + @ApiOperation("导出") | |
| 234 | + @HasPermission({"contractFramework:contractFramework:export"}) | |
| 235 | + @PostMapping("/export") | |
| 236 | + public InvokeResult<Void> export(@Valid QueryContractFrameworkVo vo) { | |
| 237 | + | |
| 238 | + ExportTaskUtil.exportTask("合同框架", ContractFrameworkExportTaskWorker.class, vo); | |
| 239 | + | |
| 240 | + return InvokeResultBuilder.success(); | |
| 241 | + } | |
| 242 | + | |
| 243 | + @ApiOperation("下载导入模板") | |
| 244 | + @HasPermission({"contractFramework:contractFramework:import"}) | |
| 245 | + @GetMapping("/import/template") | |
| 246 | + public void downloadImportTemplate() { | |
| 247 | + ExcelUtil.exportXls("合同框架导入模板", ContractFrameworkImportModel.class); | |
| 248 | + } | |
| 249 | + | |
| 250 | + @ApiOperation("导入") | |
| 251 | + @HasPermission({"contractFramework:contractFramework:import"}) | |
| 252 | + @PostMapping("/import") | |
| 253 | + public InvokeResult<Void> importExcel(@NotBlank(message = "ID不能为空") String id, | |
| 254 | + @NotNull(message = "请上传文件") MultipartFile file) { | |
| 255 | + | |
| 256 | + ContractFrameworkImportListener listener = new ContractFrameworkImportListener(); | |
| 257 | + listener.setTaskId(id); | |
| 258 | + ExcelUtil.read(file, ContractFrameworkImportModel.class, listener).sheet().doRead(); | |
| 259 | + | |
| 260 | + return InvokeResultBuilder.success(); | |
| 261 | + } | |
| 176 | 262 | } | ... | ... |
| ... | ... | @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.entity; |
| 3 | 3 | import com.baomidou.mybatisplus.annotation.TableName; |
| 4 | 4 | import com.lframework.starter.web.core.dto.BaseDto; |
| 5 | 5 | |
| 6 | +import java.time.LocalDate; | |
| 6 | 7 | import java.time.LocalDateTime; |
| 7 | 8 | |
| 8 | 9 | import com.baomidou.mybatisplus.annotation.FieldFill; |
| ... | ... | @@ -56,7 +57,7 @@ public class ContractFramework extends BaseEntity implements BaseDto { |
| 56 | 57 | /** |
| 57 | 58 | * 期限 |
| 58 | 59 | */ |
| 59 | - private LocalDateTime validityTime; | |
| 60 | + private LocalDate validityTime; | |
| 60 | 61 | |
| 61 | 62 | /** |
| 62 | 63 | * 创建人ID | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/contract/ContractFrameworkExportModel.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.excel.contract; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | +import com.lframework.starter.common.utils.DateUtil; | |
| 5 | +import com.lframework.starter.web.core.bo.BaseBo; | |
| 6 | +import com.lframework.starter.web.core.components.excel.ExcelModel; | |
| 7 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 8 | +import com.lframework.starter.web.inner.dto.dic.city.DicCityDto; | |
| 9 | +import com.lframework.starter.web.inner.entity.SysDataDicItem; | |
| 10 | +import com.lframework.starter.web.inner.service.DicCityService; | |
| 11 | +import com.lframework.starter.web.inner.service.system.SysDataDicItemService; | |
| 12 | +import com.lframework.xingyun.basedata.entity.*; | |
| 13 | +import com.lframework.xingyun.basedata.enums.AddressEntityType; | |
| 14 | +import com.lframework.xingyun.basedata.service.customer.CustomerService; | |
| 15 | +import com.lframework.xingyun.basedata.service.member.MemberService; | |
| 16 | +import com.lframework.xingyun.basedata.service.product.ProductVarietyService; | |
| 17 | +import com.lframework.xingyun.basedata.service.shop.ShopService; | |
| 18 | +import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; | |
| 19 | +import com.lframework.xingyun.basedata.service.supplier.SupplierService; | |
| 20 | +import com.lframework.xingyun.sc.controller.contract.ContractFrameworkController; | |
| 21 | +import com.lframework.xingyun.sc.entity.ContractFramework; | |
| 22 | +import io.swagger.annotations.ApiModelProperty; | |
| 23 | +import lombok.Data; | |
| 24 | +import org.apache.commons.lang3.BooleanUtils; | |
| 25 | +import org.apache.commons.lang3.StringUtils; | |
| 26 | + | |
| 27 | +import java.time.format.DateTimeFormatter; | |
| 28 | +import java.util.Date; | |
| 29 | + | |
| 30 | +@Data | |
| 31 | +public class ContractFrameworkExportModel extends BaseBo<ContractFramework> implements ExcelModel { | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 框架合同编号 | |
| 35 | + */ | |
| 36 | + @ExcelProperty("框架合同编号") | |
| 37 | + private String code; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 客户名称 | |
| 41 | + */ | |
| 42 | + @ExcelProperty("客户名称") | |
| 43 | + private String customerName; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 所属单位名称 | |
| 47 | + */ | |
| 48 | + @ExcelProperty("所属单位") | |
| 49 | + private String companyName; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 是否签订框架合同 | |
| 53 | + */ | |
| 54 | + @ExcelProperty("是否签订") | |
| 55 | + private String hasFrameworkAgreementStr; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 品种名称 | |
| 59 | + */ | |
| 60 | + @ApiModelProperty("品种") | |
| 61 | + private String materialTypeName; | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * 授信截止日期 | |
| 65 | + */ | |
| 66 | + @ExcelProperty("授信截止日期") | |
| 67 | + private Date validityTime; | |
| 68 | + | |
| 69 | + public ContractFrameworkExportModel() { | |
| 70 | + | |
| 71 | + } | |
| 72 | + | |
| 73 | + public ContractFrameworkExportModel(ContractFramework dto) { | |
| 74 | + super(dto); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + protected void afterInit(ContractFramework dto) { | |
| 79 | + this.code = dto.getCode(); | |
| 80 | + if (StringUtils.isNotBlank(dto.getCustomerId())) { | |
| 81 | + CustomerService customerService = ApplicationUtil.getBean(CustomerService.class); | |
| 82 | + Customer customer = customerService.findById(dto.getCustomerId()); | |
| 83 | + this.customerName = customer != null ? customer.getName() : ""; | |
| 84 | + } | |
| 85 | + | |
| 86 | + if (StringUtils.isNotBlank(dto.getCompany())) { | |
| 87 | + SysDataDicItemService sysDataDicItemService = ApplicationUtil.getBean(SysDataDicItemService.class); | |
| 88 | + SysDataDicItem sysDataDicItem = sysDataDicItemService.findByCode(ContractFrameworkController.SUPPLIER_DIC_CODE, dto.getCompany()); | |
| 89 | + this.companyName = sysDataDicItem != null ? sysDataDicItem.getName() : ""; | |
| 90 | + } | |
| 91 | + | |
| 92 | + if (StringUtils.isNotBlank(dto.getMaterialTypeId())) { | |
| 93 | + ProductVarietyService productVarietyService = ApplicationUtil.getBean(ProductVarietyService.class); | |
| 94 | + ProductVariety productVariety = productVarietyService.findById(dto.getMaterialTypeId()); | |
| 95 | + this.materialTypeName = productVariety != null ? productVariety.getName() : ""; | |
| 96 | + } | |
| 97 | + | |
| 98 | + this.hasFrameworkAgreementStr = BooleanUtils.isTrue(dto.getHasFrameworkAgreement()) ? "是" : "否"; | |
| 99 | + | |
| 100 | + this.validityTime = dto.getValidityTime() != null ? DateUtil.toDate(dto.getValidityTime()) : null; | |
| 101 | + } | |
| 102 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.contract; | |
| 2 | + | |
| 3 | +import com.lframework.starter.mq.core.components.export.ExportTaskWorker; | |
| 4 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 5 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 6 | +import com.lframework.starter.web.core.utils.JsonUtil; | |
| 7 | +import com.lframework.xingyun.sc.entity.ContractFramework; | |
| 8 | +import com.lframework.xingyun.sc.service.contract.ContractFrameworkService; | |
| 9 | +import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractFrameworkVo; | |
| 10 | + | |
| 11 | +public class ContractFrameworkExportTaskWorker implements | |
| 12 | + ExportTaskWorker<QueryContractFrameworkVo, ContractFramework, ContractFrameworkExportModel> { | |
| 13 | + | |
| 14 | + @Override | |
| 15 | + public QueryContractFrameworkVo parseParams(String json) { | |
| 16 | + return JsonUtil.parseObject(json, QueryContractFrameworkVo.class); | |
| 17 | + } | |
| 18 | + | |
| 19 | + @Override | |
| 20 | + public PageResult<ContractFramework> getDataList(int pageIndex, int pageSize, QueryContractFrameworkVo queryContractFrameworkVo) { | |
| 21 | + ContractFrameworkService contractFrameworkService = ApplicationUtil.getBean(ContractFrameworkService.class); | |
| 22 | + return contractFrameworkService.query(pageIndex, pageSize, queryContractFrameworkVo); | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public ContractFrameworkExportModel exportData(ContractFramework contractFramework) { | |
| 27 | + return new ContractFrameworkExportModel(contractFramework); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public Class<ContractFrameworkExportModel> getModelClass() { | |
| 32 | + return ContractFrameworkExportModel.class; | |
| 33 | + } | |
| 34 | +} | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.contract; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.context.AnalysisContext; | |
| 4 | +import com.baomidou.mybatisplus.core.conditions.Wrapper; | |
| 5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 6 | +import com.lframework.starter.common.exceptions.impl.DefaultClientException; | |
| 7 | +import com.lframework.starter.common.utils.DateUtil; | |
| 8 | +import com.lframework.starter.web.core.components.excel.ExcelImportListener; | |
| 9 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | |
| 10 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 11 | +import com.lframework.starter.web.inner.bo.system.user.GetSysUserBo; | |
| 12 | +import com.lframework.starter.web.inner.entity.SysDataDicItem; | |
| 13 | +import com.lframework.starter.web.inner.entity.SysDept; | |
| 14 | +import com.lframework.starter.web.inner.entity.SysUser; | |
| 15 | +import com.lframework.starter.web.inner.service.GenerateCodeService; | |
| 16 | +import com.lframework.starter.web.inner.service.system.SysDataDicItemService; | |
| 17 | +import com.lframework.starter.web.inner.service.system.SysDeptService; | |
| 18 | +import com.lframework.starter.web.inner.service.system.SysUserService; | |
| 19 | +import com.lframework.xingyun.basedata.entity.Customer; | |
| 20 | +import com.lframework.xingyun.basedata.entity.ProductVariety; | |
| 21 | +import com.lframework.xingyun.basedata.service.customer.CustomerService; | |
| 22 | +import com.lframework.xingyun.basedata.service.product.ProductVarietyService; | |
| 23 | +import com.lframework.xingyun.sc.components.code.GenerateCodeTypePool; | |
| 24 | +import com.lframework.xingyun.sc.controller.contract.ContractFrameworkController; | |
| 25 | +import com.lframework.xingyun.sc.service.contract.ContractFrameworkService; | |
| 26 | +import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractFrameworkVo; | |
| 27 | +import lombok.extern.slf4j.Slf4j; | |
| 28 | +import org.apache.commons.collections4.CollectionUtils; | |
| 29 | +import org.apache.commons.lang3.StringUtils; | |
| 30 | + | |
| 31 | +import java.time.LocalDate; | |
| 32 | +import java.time.format.DateTimeFormatter; | |
| 33 | +import java.util.List; | |
| 34 | + | |
| 35 | +@Slf4j | |
| 36 | +public class ContractFrameworkImportListener extends ExcelImportListener<ContractFrameworkImportModel> { | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + protected void doInvoke(ContractFrameworkImportModel data, AnalysisContext context) { | |
| 40 | + CustomerService customerService = ApplicationUtil.getBean(CustomerService.class); | |
| 41 | + Wrapper<Customer> customerWrapper = Wrappers.lambdaQuery(Customer.class) | |
| 42 | + .eq(Customer::getName, data.getCustomerName()); | |
| 43 | + Customer customer = customerService.getOne(customerWrapper); | |
| 44 | + if (customer == null) { | |
| 45 | + throw new DefaultClientException("第" + context.readRowHolder().getRowIndex() + "行,客户[" + data.getCustomerName() | |
| 46 | + + "]不存在,请检查后再次导入!"); | |
| 47 | + } | |
| 48 | + | |
| 49 | + data.setCustomerId(customer.getId()); | |
| 50 | + | |
| 51 | + SysDataDicItemService sysDataDicItemService = ApplicationUtil.getBean(SysDataDicItemService.class); | |
| 52 | + List<SysDataDicItem> sysDataDicItemList = sysDataDicItemService.findByDicCode(ContractFrameworkController.SUPPLIER_DIC_CODE); | |
| 53 | + if (CollectionUtils.isEmpty(sysDataDicItemList)) { | |
| 54 | + throw new DefaultClientException("所属单位数据为空!"); | |
| 55 | + } | |
| 56 | + | |
| 57 | + SysDataDicItem sysDataDicItem = sysDataDicItemList.stream() | |
| 58 | + .filter(item -> item != null && StringUtils.isNotBlank(item.getName())) | |
| 59 | + .filter(item -> item.getName().equals(data.getCompanyName())) | |
| 60 | + .findFirst().orElse(null); | |
| 61 | + if (sysDataDicItem == null) { | |
| 62 | + throw new DefaultClientException("第" + context.readRowHolder().getRowIndex() + "行,所属单位[" + data.getCompanyName() | |
| 63 | + + "]不存在,请检查后再次导入!"); | |
| 64 | + } | |
| 65 | + | |
| 66 | + data.setCompany(sysDataDicItem.getCode()); | |
| 67 | + | |
| 68 | + if (!"是".equals(data.getHasFrameworkAgreementStr()) && !"否".equals(data.getHasFrameworkAgreementStr())) { | |
| 69 | + throw new DefaultClientException( | |
| 70 | + "第" + context.readRowHolder().getRowIndex() + "行“是否签订”只能填写“是、否”"); | |
| 71 | + } | |
| 72 | + | |
| 73 | + data.setHasFrameworkAgreement("是".equals(data.getHasFrameworkAgreementStr())); | |
| 74 | + | |
| 75 | + if (null == data.getValidityTime()) { | |
| 76 | + throw new DefaultClientException( | |
| 77 | + "第" + context.readRowHolder().getRowIndex() + "行授信截止日期不可为空"); | |
| 78 | + } | |
| 79 | + | |
| 80 | + ProductVarietyService productVarietyService = ApplicationUtil.getBean(ProductVarietyService.class); | |
| 81 | + Wrapper<ProductVariety> productVarietyWrapper = Wrappers.lambdaQuery(ProductVariety.class) | |
| 82 | + .eq(ProductVariety::getName, data.getMaterialTypeName()); | |
| 83 | + ProductVariety productVariety = productVarietyService.getOne(productVarietyWrapper); | |
| 84 | + if (productVariety == null) { | |
| 85 | + throw new DefaultClientException("第" + context.readRowHolder().getRowIndex() + "行,品种[" + data.getMaterialTypeName() | |
| 86 | + + "]不存在,请检查后再次导入!"); | |
| 87 | + } | |
| 88 | + | |
| 89 | + data.setMaterialTypId(productVariety.getId()); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @Override | |
| 93 | + protected void afterAllAnalysed(AnalysisContext context) { | |
| 94 | + ContractFrameworkService contractFrameworkService = ApplicationUtil.getBean(ContractFrameworkService.class); | |
| 95 | + List<ContractFrameworkImportModel> datas = this.getDatas(); | |
| 96 | + LocalDate now = LocalDate.now(); | |
| 97 | + String yearTwoDigit = now.format(DateTimeFormatter.ofPattern("yy")); | |
| 98 | + String currentUserId = SecurityUtil.getCurrentUser().getId(); | |
| 99 | + SysUserService sysUserService = ApplicationUtil.getBean(SysUserService.class); | |
| 100 | + SysDeptService sysDeptService = ApplicationUtil.getBean(SysDeptService.class); | |
| 101 | + SysUser sysUser = sysUserService.findById(currentUserId); | |
| 102 | + String deptCode = ""; | |
| 103 | + if (sysUser != null) { | |
| 104 | + GetSysUserBo getSysUserBo = new GetSysUserBo(sysUser); | |
| 105 | + //部门 | |
| 106 | + List<String> depts = getSysUserBo.getDepts(); | |
| 107 | + if (CollectionUtils.isNotEmpty(depts)) { | |
| 108 | + String deptId = depts.get(0); | |
| 109 | + SysDept sysDept = sysDeptService.findById(deptId); | |
| 110 | + deptCode = sysDept.getCode(); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + GenerateCodeService generateCodeService = ApplicationUtil.getBean(GenerateCodeService.class); | |
| 115 | + for (int i = 0; i < datas.size(); i++) { | |
| 116 | + String code = generateCodeService.generate(GenerateCodeTypePool.CONTRACT_FRAMEWORK); | |
| 117 | + ContractFrameworkImportModel data = datas.get(i); | |
| 118 | + CreateContractFrameworkVo createContractFrameworkVo = new CreateContractFrameworkVo(); | |
| 119 | + createContractFrameworkVo.setCode(yearTwoDigit + data.getCompany() + deptCode + code); | |
| 120 | + createContractFrameworkVo.setValidityTime(DateUtil.toLocalDate(data.getValidityTime())); | |
| 121 | + createContractFrameworkVo.setHasFrameworkAgreement(data.getHasFrameworkAgreement()); | |
| 122 | + createContractFrameworkVo.setCompany(data.getCompany()); | |
| 123 | + createContractFrameworkVo.setCustomerId(data.getCustomerId()); | |
| 124 | + createContractFrameworkVo.setMaterialTypeId(data.getMaterialTypId()); | |
| 125 | + | |
| 126 | + try { | |
| 127 | + contractFrameworkService.create(createContractFrameworkVo); | |
| 128 | + } catch (Exception e) { | |
| 129 | + throw new DefaultClientException( | |
| 130 | + "第" + (i + 1) + "行新增失败,失败原因:" + e.getMessage()); | |
| 131 | + } | |
| 132 | + | |
| 133 | + this.setSuccessProcess(i); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + @Override | |
| 138 | + protected void doComplete() { | |
| 139 | + | |
| 140 | + } | |
| 141 | +} | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/contract/ContractFrameworkImportModel.java
0 → 100644
| 1 | +package com.lframework.xingyun.sc.excel.contract; | |
| 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 io.swagger.annotations.ApiModelProperty; | |
| 8 | +import lombok.Data; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 13 | +@Data | |
| 14 | +public class ContractFrameworkImportModel implements ExcelModel { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 框架合同编号 | |
| 18 | + */ | |
| 19 | + @ExcelIgnore | |
| 20 | + private String code; | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 客户名称 | |
| 24 | + */ | |
| 25 | + @ExcelRequired | |
| 26 | + @ExcelProperty("客户名称") | |
| 27 | + private String customerName; | |
| 28 | + | |
| 29 | + @ExcelIgnore | |
| 30 | + private String customerId; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 所属单位名称 | |
| 34 | + */ | |
| 35 | + @ExcelRequired | |
| 36 | + @ExcelProperty("所属单位") | |
| 37 | + private String companyName; | |
| 38 | + | |
| 39 | + @ExcelIgnore | |
| 40 | + private String company; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 是否签订框架合同 | |
| 44 | + */ | |
| 45 | + @ExcelRequired | |
| 46 | + @ExcelProperty("是否签订") | |
| 47 | + private String hasFrameworkAgreementStr; | |
| 48 | + | |
| 49 | + @ExcelIgnore | |
| 50 | + private Boolean hasFrameworkAgreement; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 品种名称 | |
| 54 | + */ | |
| 55 | + @ExcelRequired | |
| 56 | + @ExcelProperty("品种") | |
| 57 | + private String materialTypeName; | |
| 58 | + | |
| 59 | + @ExcelIgnore | |
| 60 | + private String materialTypId; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 授信截止日期 | |
| 64 | + */ | |
| 65 | + @ExcelRequired | |
| 66 | + @ExcelProperty("授信截止日期") | |
| 67 | + private Date validityTime; | |
| 68 | + | |
| 69 | +} | ... | ... |
| ... | ... | @@ -2,7 +2,7 @@ package com.lframework.xingyun.sc.vo.contract.createVo; |
| 2 | 2 | |
| 3 | 3 | import javax.validation.constraints.NotBlank; |
| 4 | 4 | |
| 5 | -import java.time.LocalDateTime; | |
| 5 | +import java.time.LocalDate; | |
| 6 | 6 | |
| 7 | 7 | import com.lframework.starter.web.core.vo.BaseVo; |
| 8 | 8 | |
| ... | ... | @@ -59,7 +59,7 @@ public class CreateContractFrameworkVo implements BaseVo, Serializable { |
| 59 | 59 | @ApiModelProperty(value = "期限", required = true) |
| 60 | 60 | @NotNull(message = "请输入期限!") |
| 61 | 61 | @TypeMismatch(message = "期限格式有误!") |
| 62 | - private LocalDateTime validityTime; | |
| 62 | + private LocalDate validityTime; | |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * 品种id | ... | ... |
xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/contract/queryVo/QueryContractFrameworkVo.java
| ... | ... | @@ -5,7 +5,7 @@ import com.lframework.starter.common.constants.StringPool; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | import com.lframework.starter.web.core.vo.PageVo; |
| 7 | 7 | |
| 8 | -import java.time.LocalDateTime; | |
| 8 | +import java.time.LocalDate; | |
| 9 | 9 | |
| 10 | 10 | import com.lframework.starter.web.core.vo.BaseVo; |
| 11 | 11 | import com.lframework.starter.web.core.components.validation.TypeMismatch; |
| ... | ... | @@ -60,16 +60,16 @@ public class QueryContractFrameworkVo extends PageVo implements BaseVo, Serializ |
| 60 | 60 | */ |
| 61 | 61 | @ApiModelProperty("期限") |
| 62 | 62 | @TypeMismatch(message = "期限格式有误!") |
| 63 | - private LocalDateTime validityTime; | |
| 63 | + private LocalDate validityTime; | |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * 期限(查询) |
| 67 | 67 | */ |
| 68 | 68 | @ApiModelProperty("期限查询开始时间") |
| 69 | - @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | |
| 70 | - private LocalDateTime validityTimeStart; | |
| 69 | + @JsonFormat(pattern = StringPool.DATE_PATTERN) | |
| 70 | + private LocalDate validityTimeStart; | |
| 71 | 71 | |
| 72 | 72 | @ApiModelProperty("期限查询结束时间") |
| 73 | - @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN) | |
| 74 | - private LocalDateTime validityTimeEnd; | |
| 73 | + @JsonFormat(pattern = StringPool.DATE_PATTERN) | |
| 74 | + private LocalDate validityTimeEnd; | |
| 75 | 75 | } | ... | ... |
| ... | ... | @@ -3,7 +3,7 @@ package com.lframework.xingyun.sc.vo.contract.updateVo; |
| 3 | 3 | import lombok.Data; |
| 4 | 4 | |
| 5 | 5 | import javax.validation.constraints.NotBlank; |
| 6 | -import java.time.LocalDateTime; | |
| 6 | +import java.time.LocalDate; | |
| 7 | 7 | |
| 8 | 8 | import com.lframework.starter.web.core.vo.BaseVo; |
| 9 | 9 | |
| ... | ... | @@ -64,7 +64,7 @@ public class UpdateContractFrameworkVo implements BaseVo, Serializable { |
| 64 | 64 | @ApiModelProperty(value = "期限", required = true) |
| 65 | 65 | @TypeMismatch(message = "期限格式有误!") |
| 66 | 66 | @NotNull(message = "请输入期限!") |
| 67 | - private LocalDateTime validityTime; | |
| 67 | + private LocalDate validityTime; | |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * 品种id | ... | ... |