Commit d798eb54646adaf85531e3ae1ae7c64fda0ae2b9

Authored by 房远帅
1 parent e140d606

楚江ERP:客户资信取消、导入、审核结束监听

Showing 15 changed files with 679 additions and 96 deletions
... ... @@ -232,6 +232,12 @@ public class CustomerServiceImpl extends BaseMpServiceImpl<CustomerMapper, Custo
232 232 OpLogUtil.setExtra(vo);
233 233 }
234 234
  235 + @Override
  236 + public Customer getByName(String name) {
  237 +
  238 + return getBaseMapper().getByName(name);
  239 + }
  240 +
235 241 @CacheEvict(value = Customer.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
236 242 @Override
237 243 public void cleanCacheByKey(Serializable key) {
... ...
... ... @@ -40,4 +40,12 @@ public interface CustomerMapper extends BaseMapper<Customer> {
40 40 * @return
41 41 */
42 42 List<Customer> selector(@Param("vo") QueryCustomerSelectorVo vo);
  43 +
  44 + /**
  45 + * 根据名称查询
  46 + *
  47 + * @param name
  48 + * @return Customer
  49 + */
  50 + Customer getByName(@Param("name") String name);
43 51 }
... ...
... ... @@ -69,4 +69,11 @@ public interface CustomerService extends BaseMpService<Customer> {
69 69 * @param vo
70 70 */
71 71 void update(UpdateCustomerVo vo);
  72 +
  73 + /**
  74 + * 根据名称查询
  75 + *
  76 + * @param name
  77 + */
  78 + Customer getByName(String name);
72 79 }
... ...
... ... @@ -74,6 +74,18 @@
74 74 ORDER BY code
75 75 </select>
76 76
  77 + <select id="getByName" resultMap="CustomerDto">
  78 + SELECT DISTINCT
  79 + c.id,
  80 + c.name
  81 + FROM base_data_customer AS c
  82 + <where>
  83 + <if test="name != null and name != ''">
  84 + AND name = #{name}
  85 + </if>
  86 + </where>
  87 + </select>
  88 +
77 89 <select id="selector" resultMap="CustomerDto">
78 90 <include refid="CustomerDto_sql"/>
79 91 <where>
... ...
1 1 package com.lframework.xingyun.sc.bo.customer.credit;
2 2
3 3 import com.fasterxml.jackson.annotation.JsonFormat;
4   -import com.lframework.xingyun.basedata.entity.Customer;
  4 +import com.lframework.starter.web.core.dto.BaseDto;
5 5 import com.lframework.xingyun.sc.entity.CorePersonnel;
6 6 import com.lframework.xingyun.sc.entity.CustomerCredit;
7 7 import java.math.BigDecimal;
... ... @@ -24,7 +24,7 @@ import lombok.Data;
24 24 *
25 25 */
26 26 @Data
27   -public class GetCustomerCreditBo extends BaseBo<CustomerCredit> {
  27 +public class GetCustomerCreditBo extends BaseBo<CustomerCredit> implements BaseDto {
28 28
29 29 /**
30 30 * ID
... ...
1 1 package com.lframework.xingyun.sc.controller.customer;
2 2
3 3 import com.lframework.starter.common.utils.StringUtil;
  4 +import com.lframework.starter.mq.core.utils.ExportTaskUtil;
4 5 import com.lframework.starter.web.core.annotations.security.HasPermission;
5 6 import com.lframework.starter.web.core.controller.DefaultBaseController;
6 7 import com.lframework.starter.web.core.utils.ExcelUtil;
... ... @@ -16,6 +17,8 @@ import com.lframework.starter.web.core.components.resp.PageResult;
16 17 import com.lframework.starter.web.core.components.resp.InvokeResult;
17 18 import javax.annotation.Resource;
18 19 import javax.validation.constraints.NotBlank;
  20 +import com.lframework.xingyun.sc.enums.ExportType;
  21 +import com.lframework.xingyun.sc.excel.customerCredit.CustomerCreditExportTaskWorker;
19 22 import com.lframework.xingyun.sc.excel.customerCredit.CustomerCreditImportListener;
20 23 import com.lframework.xingyun.sc.excel.customerCredit.CustomerCreditImportModel;
21 24 import com.lframework.xingyun.sc.service.customer.CorePersonnelService;
... ... @@ -132,6 +135,21 @@ public class CustomerCreditController extends DefaultBaseController {
132 135 }
133 136
134 137 /**
  138 + * 取消
  139 + */
  140 + @ApiOperation("取消")
  141 + @HasPermission({"customer-credit-manage:customer-credit-plan:modify"})
  142 + @GetMapping("/cancel")
  143 + public InvokeResult<Void> cancel(@NotBlank(message = "id不能为空!") String id) {
  144 +
  145 + customerCreditService.cancel(id);
  146 +
  147 + customerCreditService.cleanCacheByKey(id);
  148 +
  149 + return InvokeResultBuilder.success();
  150 + }
  151 +
  152 + /**
135 153 * 根据ID删除
136 154 */
137 155 @ApiOperation("根据ID删除")
... ... @@ -208,6 +226,19 @@ public class CustomerCreditController extends DefaultBaseController {
208 226 return InvokeResultBuilder.success();
209 227 }
210 228
  229 + /**
  230 + * 导出
  231 + */
  232 + @ApiOperation("导出")
  233 + @HasPermission({"customer-dev-manage:customer-dev-plan:export"})
  234 + @PostMapping("/export")
  235 + public InvokeResult<Void> export(@Valid QueryCustomerCreditVo vo) {
  236 + vo.setExportType(ExportType.CUSTOMER_CREDIT.getCode());
  237 + ExportTaskUtil.exportTask("客户资信信息", CustomerCreditExportTaskWorker.class, vo);
  238 + return InvokeResultBuilder.success();
  239 + }
  240 +
  241 +
211 242
212 243 /**
213 244 * 封装客户资信数据
... ...
  1 +package com.lframework.xingyun.sc.excel.customerCredit;
  2 +
  3 +import com.alibaba.excel.annotation.ExcelProperty;
  4 +import com.fasterxml.jackson.annotation.JsonFormat;
  5 +import com.lframework.starter.common.constants.StringPool;
  6 +import com.lframework.starter.web.core.bo.BaseBo;
  7 +import com.lframework.starter.web.core.components.excel.ExcelModel;
  8 +import com.lframework.xingyun.sc.bo.customer.credit.GetCustomerCreditBo;
  9 +import com.lframework.xingyun.sc.entity.CorePersonnel;
  10 +import lombok.Data;
  11 +
  12 +import java.math.BigDecimal;
  13 +import java.time.LocalDate;
  14 +import java.time.LocalDateTime;
  15 +import java.util.List;
  16 +
  17 +
  18 +@Data
  19 +public class CustomerCreditExportModel extends BaseBo<GetCustomerCreditBo> implements ExcelModel {
  20 +
  21 + /**
  22 + * 编号
  23 + */
  24 + @ExcelProperty("编号")
  25 + private String serialNumber;
  26 +
  27 + /**
  28 + * 区域
  29 + */
  30 + @ExcelProperty("区域")
  31 + private String region;
  32 +
  33 + /**
  34 + * 登记日期
  35 + */
  36 + @ExcelProperty("登记日期")
  37 + @JsonFormat(pattern = StringPool.DATE_PATTERN)
  38 + private LocalDate registerDate;
  39 +
  40 + /**
  41 + * 客户简称
  42 + */
  43 + @ExcelProperty("客户简称")
  44 + private String customerShortName;
  45 +
  46 + /**
  47 + * 企业类型:经销商(distributor)、终端(terminal)
  48 + */
  49 + @ExcelProperty("企业类型")
  50 + private String enterpriseType;
  51 +
  52 + /**
  53 + * 单位名称(非持久化字段)
  54 + */
  55 + @ExcelProperty("单位名称")
  56 + private String companyName;
  57 +
  58 + /**
  59 + * 企业性质
  60 + */
  61 + @ExcelProperty("企业性质")
  62 + private String companyNature;
  63 +
  64 + /**
  65 + * 单位地址
  66 + */
  67 + @ExcelProperty("单位地址")
  68 + private String companyAddress;
  69 +
  70 + /**
  71 + * 注册资本(单位:万元)
  72 + */
  73 + @ExcelProperty("注册资本")
  74 + private BigDecimal registeredCapital;
  75 +
  76 + /**
  77 + * 账号
  78 + */
  79 + @ExcelProperty("账号")
  80 + private String bankAccount;
  81 +
  82 + /**
  83 + * 开户行
  84 + */
  85 + @ExcelProperty("开户行")
  86 + private String bankName;
  87 +
  88 + /**
  89 + * 税号
  90 + */
  91 + @ExcelProperty("税号")
  92 + private String taxNumber;
  93 +
  94 + /**
  95 + * 注册时间
  96 + */
  97 + @ExcelProperty("注册时间")
  98 + @JsonFormat(pattern = StringPool.DATE_PATTERN)
  99 + private LocalDate registrationTime;
  100 +
  101 + /**
  102 + * 经营年限(年)
  103 + */
  104 + @ExcelProperty("经营年限")
  105 + private String businessYears;
  106 +
  107 + /**
  108 + * 经营范围
  109 + */
  110 + @ExcelProperty("经营范围")
  111 + private String businessScope;
  112 +
  113 + /**
  114 + * 经营场地属性
  115 + */
  116 + @ExcelProperty("经营场地属性")
  117 + private String businessProperty;
  118 +
  119 + /**
  120 + * 占地面积(平方米)
  121 + */
  122 + @ExcelProperty("占地面积")
  123 + private String landArea;
  124 +
  125 + /**
  126 + * 仓储条件
  127 + */
  128 + @ExcelProperty("仓储条件")
  129 + private String storageConditions;
  130 +
  131 + /**
  132 + * 员工人数
  133 + */
  134 + @ExcelProperty("员工人数")
  135 + private Integer employeeCount;
  136 +
  137 + /**
  138 + * 设备属性
  139 + */
  140 + @ExcelProperty("设备属性")
  141 + private String equipmentAttributes;
  142 +
  143 + /**
  144 + * 资产评估
  145 + */
  146 + @ExcelProperty("资产评估")
  147 + private String assetEvaluation;
  148 +
  149 + /**
  150 + * 上年度销售额(万元)
  151 + */
  152 + @ExcelProperty("上年度销售额")
  153 + private String lastYearSales;
  154 +
  155 + /**
  156 + * 月均销量(万元)
  157 + */
  158 + @ExcelProperty("月均销量")
  159 + private String monthlyAvgSales;
  160 +
  161 + /**
  162 + * 销项发票所开品名与计量单位
  163 + */
  164 + @ExcelProperty("销项发票所开品名与计量单位")
  165 + private String invoiceItemUnit;
  166 +
  167 + /**
  168 + * 认证证书
  169 + */
  170 + @ExcelProperty("认证证书")
  171 + private String certificationCertificate;
  172 +
  173 + /**
  174 + * 我司售于产品与经营范围是否匹配
  175 + */
  176 + @ExcelProperty("我司售于产品与经营范围是否匹配")
  177 + private String productMatch;
  178 +
  179 + /**
  180 + * 主要客户
  181 + */
  182 + @ExcelProperty("主要客户")
  183 + private String majorCustomers;
  184 +
  185 + /**
  186 + * 主营项目
  187 + */
  188 + @ExcelProperty("主营项目")
  189 + private String mainProjects;
  190 +
  191 + /**
  192 + * 从事行业
  193 + */
  194 + @ExcelProperty("从事行业")
  195 + private String industryInvolved;
  196 +
  197 + /**
  198 + * 在该行业中的经验
  199 + */
  200 + @ExcelProperty("在该行业中的经验")
  201 + private String industryExperience;
  202 +
  203 + /**
  204 + * 是否与其他企业有经济纠纷 违规信息 拖欠员工薪资等
  205 + */
  206 + @ExcelProperty("是否与其他企业有经济纠纷 违规信息 拖欠员工薪资等")
  207 + private String hasDispute;
  208 +
  209 + /**
  210 + * 与我司合作时间
  211 + */
  212 + @ExcelProperty("与我司合作时间")
  213 + private String cooperationStartDate;
  214 +
  215 + /**
  216 + * 月均操作量
  217 + */
  218 + @ExcelProperty("月均操作量")
  219 + private String monthlyAvgVolume;
  220 +
  221 + /**
  222 + * 是否口头协议操作
  223 + */
  224 + @ExcelProperty("是否口头协议操作")
  225 + private String isVerbalAgreement;
  226 +
  227 + /**
  228 + * 是否签订其他协议(列举)
  229 + */
  230 + @ExcelProperty("是否签订其他协议(列举)")
  231 + private String otherAgreements;
  232 +
  233 + /**
  234 + * 与我司操作是否签订长年合同
  235 + */
  236 + @ExcelProperty("与我司操作是否签订长年合同")
  237 + private String hasLongTermContract;
  238 +
  239 + /**
  240 + * 合同类型
  241 + */
  242 + @ExcelProperty("合同类型")
  243 + private String contractType;
  244 +
  245 + /**
  246 + * 是否有过中断及中断原因
  247 + */
  248 + @ExcelProperty("是否有过中断及中断原因")
  249 + private String hasInterruption;
  250 +
  251 + /**
  252 + * 结算期限
  253 + */
  254 + @ExcelProperty("结算期限")
  255 + private String settlementPeriod;
  256 +
  257 + /**
  258 + * 加工操作方案
  259 + */
  260 + @ExcelProperty("加工操作方案")
  261 + private String materialSupplyPlan;
  262 +
  263 + /**
  264 + * 建议客户分类:AAA、AA、A、BBB、BB、B、C、D
  265 + */
  266 + @ExcelProperty("建议客户分类")
  267 + private String suggestedCategory;
  268 +
  269 + /**
  270 + * 授信额度(万元)
  271 + */
  272 + @ExcelProperty("授信额度")
  273 + private String creditLimit;
  274 +
  275 + /**
  276 + * 调查人名称(非持久化字段)
  277 + */
  278 + @ExcelProperty("调查人")
  279 + private String investigatorName;
  280 +
  281 + /**
  282 + * 主管审核名称(非持久化字段)
  283 + */
  284 + @ExcelProperty("主管审核")
  285 + private String supervisorReviewName;
  286 +
  287 + /**
  288 + * 年度总销量(万元)
  289 + */
  290 + @ExcelProperty("年度总销量")
  291 + private String annualTotalSales;
  292 +
  293 + /**
  294 + * 主要行业
  295 + */
  296 + @ExcelProperty("主要行业")
  297 + private String mainIndustry;
  298 +
  299 + /**
  300 + * 年度款料概况
  301 + */
  302 + @ExcelProperty("年度款料概况")
  303 + private String annualMaterialOverview;
  304 +
  305 + /**
  306 + * 结算期限
  307 + */
  308 + @ExcelProperty("结算期限")
  309 + private String companySettlementPeriod;
  310 +
  311 + /**
  312 + * 授信额度(万元)
  313 + */
  314 + @ExcelProperty("授信额度")
  315 + private String companyCreditLimit;
  316 +
  317 + /**
  318 + * 加工操作方案
  319 + */
  320 + @ExcelProperty("加工操作方案")
  321 + private String companyMaterialSupplyPlan;
  322 +
  323 + /**
  324 + * 客户分类:AAA、AA、A、BBB、BB、B、C、D
  325 + */
  326 + @ExcelProperty("客户分类")
  327 + private String companySuggestedCategory;
  328 +
  329 + /**
  330 + * 审核状态
  331 + */
  332 + @ExcelProperty("审核状态")
  333 + private String status;
  334 +
  335 + /**
  336 + * 工商信息文件名
  337 + */
  338 + @ExcelProperty(value = "工商信息文件名")
  339 + private String businessFileName;
  340 +
  341 + /**
  342 + * 股东信息文件名
  343 + */
  344 + @ExcelProperty(value = "股东信息文件名")
  345 + private String shareholderFileName;
  346 +
  347 + /**
  348 + * 核心人员
  349 + */
  350 + @ExcelProperty("核心人员")
  351 + private List<CorePersonnel> corePersonnelList;
  352 +
  353 +
  354 + public CustomerCreditExportModel() {
  355 +
  356 + }
  357 +
  358 + public CustomerCreditExportModel(GetCustomerCreditBo dto) {
  359 + super(dto);
  360 + }
  361 +
  362 + @Override
  363 + public BaseBo<GetCustomerCreditBo> convert(GetCustomerCreditBo dto) {
  364 + return super.convert(dto);
  365 + }
  366 +
  367 + @Override
  368 + protected void afterInit(GetCustomerCreditBo dto) {
  369 + if (dto.getEnterpriseType() != null) {
  370 + switch (dto.getEnterpriseType()) {
  371 + case "DEALER":
  372 + this.enterpriseType = "经销商";
  373 + break;
  374 + case "TERMINAL":
  375 + this.enterpriseType = "终端";
  376 + break;
  377 + default:
  378 + break;
  379 + }
  380 + }
  381 + }
  382 +}
... ...
  1 +package com.lframework.xingyun.sc.excel.customerCredit;
  2 +
  3 +import com.lframework.starter.common.utils.CollectionUtil;
  4 +import com.lframework.starter.mq.core.components.export.ExportTaskWorker;
  5 +import com.lframework.starter.web.core.components.resp.PageResult;
  6 +import com.lframework.starter.web.core.utils.ApplicationUtil;
  7 +import com.lframework.starter.web.core.utils.JsonUtil;
  8 +import com.lframework.starter.web.core.utils.PageResultUtil;
  9 +import com.lframework.xingyun.sc.bo.customer.credit.GetCustomerCreditBo;
  10 +import com.lframework.xingyun.sc.entity.CustomerCredit;
  11 +import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
  12 +import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo;
  13 +import java.util.List;
  14 +
  15 +public class CustomerCreditExportTaskWorker implements
  16 + ExportTaskWorker<QueryCustomerCreditVo, GetCustomerCreditBo, CustomerCreditExportModel> {
  17 +
  18 +
  19 + @Override
  20 + public QueryCustomerCreditVo parseParams(String json) {
  21 + return JsonUtil.parseObject(json, QueryCustomerCreditVo.class);
  22 + }
  23 +
  24 + @Override
  25 + public PageResult<GetCustomerCreditBo> getDataList(int pageIndex, int pageSize, QueryCustomerCreditVo params) {
  26 + CustomerCreditService customerCreditService = ApplicationUtil.getBean(CustomerCreditService.class);
  27 + PageResult<CustomerCredit> pageResult = customerCreditService.query(pageIndex, pageSize, params);
  28 + List<CustomerCredit> dataList = pageResult.getDatas();
  29 + List<GetCustomerCreditBo> results = null;
  30 + if (!CollectionUtil.isEmpty(dataList)) {
  31 + results = this.packCustomerCreditData(dataList);
  32 + }
  33 + return PageResultUtil.rebuild(pageResult, results);
  34 + }
  35 +
  36 + @Override
  37 + public CustomerCreditExportModel exportData(GetCustomerCreditBo data) {
  38 + return new CustomerCreditExportModel(data);
  39 + }
  40 +
  41 + @Override
  42 + public Class<CustomerCreditExportModel> getModelClass() {
  43 + return CustomerCreditExportModel.class;
  44 + }
  45 +
  46 +
  47 + /**
  48 + * 封装客户开发数据
  49 + *
  50 + * @param dataList 数据集
  51 + * @return List<GetCustomerCreditBo>
  52 + */
  53 + private List<GetCustomerCreditBo> packCustomerCreditData(List<CustomerCredit> dataList) {
  54 + // todo fys 处理关联数据
  55 + return null;
  56 + }
  57 +}
... ...
... ... @@ -5,16 +5,12 @@ import com.lframework.starter.common.exceptions.impl.DefaultClientException;
5 5 import com.lframework.starter.common.utils.StringUtil;
6 6 import com.lframework.starter.web.core.components.excel.ExcelImportListener;
7 7 import com.lframework.starter.web.core.utils.ApplicationUtil;
8   -import com.lframework.xingyun.sc.entity.CorePersonnel;
  8 +import com.lframework.xingyun.basedata.entity.Customer;
  9 +import com.lframework.xingyun.basedata.service.customer.CustomerService;
9 10 import com.lframework.xingyun.sc.entity.CustomerCredit;
10   -import com.lframework.xingyun.sc.service.customer.CorePersonnelService;
11 11 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
12   -import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelVo;
13   -import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo;
14   -import com.lframework.xingyun.sc.vo.customer.credit.UpdateCorePersonnelVo;
15   -import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo;
  12 +import com.lframework.xingyun.sc.vo.customer.credit.*;
16 13 import lombok.extern.slf4j.Slf4j;
17   -import org.springframework.beans.BeanUtils;
18 14 import org.apache.commons.collections.CollectionUtils;
19 15
20 16 import java.util.ArrayList;
... ... @@ -29,6 +25,7 @@ public class CustomerCreditImportListener extends ExcelImportListener<CustomerCr
29 25
30 26 @Override
31 27 protected void doInvoke(CustomerCreditImportModel data, AnalysisContext context) {
  28 + CustomerService customerService = ApplicationUtil.getBean(CustomerService.class);
32 29 List<String> validValues = Arrays.asList("AAA", "AA", "A", "BBB", "BB", "B", "C", "D");
33 30 if (StringUtil.isBlank(data.getCode())) {
34 31 throw new DefaultClientException(
... ... @@ -39,103 +36,77 @@ public class CustomerCreditImportListener extends ExcelImportListener<CustomerCr
39 36 "第" + context.readRowHolder().getRowIndex() + "行“编号”与第" + (checkList.indexOf(data.getCode()) + 1) + "行重复");
40 37 }
41 38 checkList.add(data.getCode());
  39 + if (StringUtil.isBlank(data.getName())) {
  40 + throw new DefaultClientException(
  41 + "第" + context.readRowHolder().getRowIndex() + "行“客户名称”不能为空");
  42 + } else {
  43 + Customer customer = customerService.getByName(data.getName());
  44 + if (customer == null) {
  45 + throw new DefaultClientException(
  46 + "第" + context.readRowHolder().getRowIndex() + "行“客户不存在”不能为空");
  47 + } else {
  48 + data.setCompanyId(customer.getId());
  49 + }
  50 + }
  51 + if (StringUtil.isBlank(data.getCompanySuggestedCategory())) {
  52 + throw new DefaultClientException(
  53 + "第" + context.readRowHolder().getRowIndex() + "行“客户分类”不能为空");
  54 + }
  55 + if (StringUtil.isNotEmpty(data.getCompanySuggestedCategory()) && !validValues.contains(data.getCompanySuggestedCategory())) {
  56 + throw new DefaultClientException(
  57 + "第" + context.readRowHolder().getRowIndex() + "行“客户分类”只能为:AAA、AA、A、BBB、BB、B、C、D");
  58 + }
  59 + if (StringUtil.isBlank(data.getCompanyCreditLimit())) {
  60 + throw new DefaultClientException(
  61 + "第" + context.readRowHolder().getRowIndex() + "行“授信额度”不能为空");
  62 + }
  63 + if (StringUtil.isBlank(data.getCompanyMaterialSupplyPlan())) {
  64 + throw new DefaultClientException(
  65 + "第" + context.readRowHolder().getRowIndex() + "行“加工操作方案”不能为空");
  66 + }
  67 + if (StringUtil.isBlank(data.getCompanySettlementPeriod())) {
  68 + throw new DefaultClientException(
  69 + "第" + context.readRowHolder().getRowIndex() + "行“结算期限”不能为空");
  70 + }
42 71 QueryCustomerCreditVo vo = new QueryCustomerCreditVo();
43 72 vo.setSerialNumber(data.getCode());
44 73 CustomerCreditService customerCreditService = ApplicationUtil.getBean(CustomerCreditService.class);
45 74 List<CustomerCredit> query = customerCreditService.query(vo);
46   - if (CollectionUtils.isEmpty(query)) {
  75 + if (CollectionUtils.isNotEmpty(query)) {
47 76 throw new DefaultClientException(
48   - "第" + context.readRowHolder().getRowIndex() + "行“编号”存在");
  77 + "第" + context.readRowHolder().getRowIndex() + "行“编号”系统中已存在");
49 78 }
50 79
51   - if (StringUtil.isNotEmpty(data.getCompanySuggestedCategory()) && !validValues.contains(data.getCompanySuggestedCategory())) {
52   - throw new DefaultClientException(
53   - "第" + context.readRowHolder().getRowIndex() + "行“客户分类”只能为:AAA、AA、A、BBB、BB、B、C、D");
54   - }
55 80 }
56 81
57 82 @Override
58 83 protected void afterAllAnalysed(AnalysisContext context) {
59   - CorePersonnelService corePersonnelService = ApplicationUtil.getBean(CorePersonnelService.class);
60 84 CustomerCreditService customerCreditService = ApplicationUtil.getBean(CustomerCreditService.class);
61 85 List<CustomerCreditImportModel> datas = this.getDatas();
62 86 for (int i = 0; i < datas.size(); i++) {
63 87 CustomerCreditImportModel data = datas.get(i);
64   - QueryCustomerCreditVo vo = new QueryCustomerCreditVo();
65   - vo.setSerialNumber(data.getCode());
66   - List<CustomerCredit> query = customerCreditService.query(vo);
67   - if (CollectionUtils.isNotEmpty(query)) {
68   - CustomerCredit customerCredit = query.get(0);
69 88
70   - UpdateCustomerCreditVo updateCustomerCreditVo = new UpdateCustomerCreditVo();
71   -// updateCustomerCreditVo.setId(customerCredit.getId());
  89 + CreateCustomerCreditVo createCustomerCreditVo = new CreateCustomerCreditVo();
  90 + //审核状态
  91 + createCustomerCreditVo.setStatus("PASS");
  92 + //编号
  93 + createCustomerCreditVo.setSerialNumber(data.getCode());
  94 + //客户id
  95 + createCustomerCreditVo.setCompanyId(data.getCompanyId());
  96 + //客户分类
  97 + createCustomerCreditVo.setCompanySuggestedCategory(data.getCompanySuggestedCategory());
  98 + //授信额度
  99 + createCustomerCreditVo.setCompanyCreditLimit(data.getCompanyCreditLimit());
  100 + //加工操作方案
  101 + createCustomerCreditVo.setCompanyMaterialSupplyPlan(data.getCompanyMaterialSupplyPlan());
  102 + //结算期限
  103 + createCustomerCreditVo.setCompanySettlementPeriod(data.getCompanySettlementPeriod());
  104 + //导入标识
  105 + createCustomerCreditVo.setImportType("IMPORT");
72 106
73   - BeanUtils.copyProperties(customerCredit, updateCustomerCreditVo);
74   - //客户分类
75   - if (StringUtil.isNotEmpty(data.getCompanySuggestedCategory())) {
76   - updateCustomerCreditVo.setCompanySuggestedCategory(data.getCompanySuggestedCategory());
77   - }
78   - //授信额度
79   - if (StringUtil.isNotEmpty(data.getCompanyCreditLimit())) {
80   - updateCustomerCreditVo.setCompanyCreditLimit(data.getCompanyCreditLimit());
81   - }
82   - //加工操作方案
83   - if (StringUtil.isNotEmpty(data.getCompanyMaterialSupplyPlan())) {
84   - updateCustomerCreditVo.setCompanyMaterialSupplyPlan(data.getCompanyMaterialSupplyPlan());
85   - }
86   - //结算期限
87   - if (StringUtil.isNotEmpty(data.getCompanySettlementPeriod())) {
88   - updateCustomerCreditVo.setCompanySettlementPeriod(data.getCompanySettlementPeriod());
89   - }
90   - //核心人员(不填更新的时候会被删除)
91   - QueryCorePersonnelVo queryCorePersonnelVo = new QueryCorePersonnelVo();
92   - queryCorePersonnelVo.setCreditId(customerCredit.getId());
93   - List<CorePersonnel> corePersonnelList = corePersonnelService.query(queryCorePersonnelVo);
94   - if (CollectionUtils.isNotEmpty(corePersonnelList)) {
95   - List<UpdateCorePersonnelVo> results = new ArrayList<>();
96   - for (CorePersonnel corePersonnel : corePersonnelList) {
97   - UpdateCorePersonnelVo personnelVo = new UpdateCorePersonnelVo();
98   - personnelVo.setId(corePersonnel.getId());
99   - personnelVo.setCreditId(corePersonnel.getCreditId());
100   - if (!StringUtil.isBlank(corePersonnel.getPersonId())) {
101   - personnelVo.setPersonId(corePersonnel.getPersonId());
102   - }
103   - if (!StringUtil.isBlank(corePersonnel.getName())) {
104   - personnelVo.setName(corePersonnel.getName());
105   - }
106   - if (!StringUtil.isBlank(corePersonnel.getSex())) {
107   - personnelVo.setSex(corePersonnel.getSex());
108   - }
109   - if (!StringUtil.isBlank(corePersonnel.getNativePlace())) {
110   - personnelVo.setNativePlace(corePersonnel.getNativePlace());
111   - }
112   - if (!StringUtil.isBlank(corePersonnel.getAge())) {
113   - personnelVo.setAge(corePersonnel.getAge());
114   - }
115   - if (!StringUtil.isBlank(corePersonnel.getPosition())) {
116   - personnelVo.setPosition(corePersonnel.getPosition());
117   - }
118   - if (!StringUtil.isBlank(corePersonnel.getMobile())) {
119   - personnelVo.setMobile(corePersonnel.getMobile());
120   - }
121   - if (!StringUtil.isBlank(corePersonnel.getPhone())) {
122   - personnelVo.setPhone(corePersonnel.getPhone());
123   - }
124   - if (!StringUtil.isBlank(corePersonnel.getEmail())) {
125   - personnelVo.setEmail(corePersonnel.getEmail());
126   - }
127   - if (!StringUtil.isBlank(corePersonnel.getAddress())) {
128   - personnelVo.setAddress(corePersonnel.getAddress());
129   - }
130   - results.add(personnelVo);
131   - }
132   - updateCustomerCreditVo.setCorePersonnelList(results);
133   - }
134   - customerCreditService.update(updateCustomerCreditVo);
135   - customerCreditService.cleanCacheByKey(customerCredit.getId());
  107 + customerCreditService.create(createCustomerCreditVo);
136 108
137   - this.setSuccessProcess(i);
138   - }
  109 + this.setSuccessProcess(i);
139 110 }
140 111 }
141 112
... ...
... ... @@ -16,6 +16,12 @@ public class CustomerCreditImportModel implements ExcelModel {
16 16 private String id;
17 17
18 18 /**
  19 + * companyId
  20 + */
  21 + @ExcelIgnore
  22 + private String companyId;
  23 +
  24 + /**
19 25 * 编号
20 26 */
21 27 @ExcelRequired
... ... @@ -23,26 +29,37 @@ public class CustomerCreditImportModel implements ExcelModel {
23 29 private String code;
24 30
25 31 /**
  32 + * 客户名称
  33 + */
  34 + @ExcelRequired
  35 + @ExcelProperty("客户名称")
  36 + private String name;
  37 +
  38 + /**
26 39 * 客户分类
27 40 */
  41 + @ExcelRequired
28 42 @ExcelProperty("客户分类")
29 43 private String companySuggestedCategory;
30 44
31 45 /**
32 46 * 授信额度
33 47 */
  48 + @ExcelRequired
34 49 @ExcelProperty("授信额度")
35 50 private String companyCreditLimit;
36 51
37 52 /**
38 53 * 加工操作方案
39 54 */
  55 + @ExcelRequired
40 56 @ExcelProperty("加工操作方案")
41 57 private String companyMaterialSupplyPlan;
42 58
43 59 /**
44 60 * 结算期限
45 61 */
  62 + @ExcelRequired
46 63 @ExcelProperty("结算期限")
47 64 private String companySettlementPeriod;
48 65
... ...
... ... @@ -32,6 +32,7 @@ import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService;
32 32 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
33 33 import com.lframework.xingyun.sc.vo.customer.credit.*;
34 34 import org.apache.commons.collections.CollectionUtils;
  35 +import org.apache.commons.lang3.StringUtils;
35 36 import org.springframework.cache.annotation.CacheEvict;
36 37 import org.springframework.cache.annotation.Cacheable;
37 38 import org.springframework.stereotype.Service;
... ... @@ -111,8 +112,12 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
111 112 if (!StringUtil.isBlank(vo.getCustomerShortName())) {
112 113 data.setCustomerShortName(vo.getCustomerShortName());
113 114 }
114   - data.setEnterpriseType(vo.getEnterpriseType());
115   - data.setCompanyId(vo.getCompanyId());
  115 + if (!StringUtil.isBlank(vo.getEnterpriseType())) {
  116 + data.setEnterpriseType(vo.getEnterpriseType());
  117 + }
  118 + if (!StringUtil.isBlank(vo.getCompanyId())) {
  119 + data.setCompanyId(vo.getCompanyId());
  120 + }
116 121 if (!StringUtil.isBlank(vo.getCompanyNature())) {
117 122 data.setCompanyNature(vo.getCompanyNature());
118 123 }
... ... @@ -215,7 +220,9 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
215 220 if (!StringUtil.isBlank(vo.getMaterialSupplyPlan())) {
216 221 data.setMaterialSupplyPlan(vo.getMaterialSupplyPlan());
217 222 }
218   - data.setSuggestedCategory(vo.getSuggestedCategory());
  223 + if (!StringUtil.isBlank(vo.getSuggestedCategory())) {
  224 + data.setSuggestedCategory(vo.getSuggestedCategory());
  225 + }
219 226 if (!StringUtil.isBlank(vo.getCreditLimit())) {
220 227 data.setCreditLimit(vo.getCreditLimit());
221 228 }
... ... @@ -243,7 +250,9 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
243 250 if (!StringUtil.isBlank(vo.getCompanyMaterialSupplyPlan())) {
244 251 data.setCompanyMaterialSupplyPlan(vo.getCompanyMaterialSupplyPlan());
245 252 }
246   - data.setCompanySuggestedCategory(vo.getCompanySuggestedCategory());
  253 + if (!StringUtil.isBlank(vo.getCompanySuggestedCategory())) {
  254 + data.setCompanySuggestedCategory(vo.getCompanySuggestedCategory());
  255 + }
247 256 data.setStatus(vo.getStatus());
248 257
249 258 getBaseMapper().insert(data);
... ... @@ -259,8 +268,11 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
259 268 }
260 269 }
261 270
262   - // 开启审核
263   - flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);
  271 + //导入不走审核流
  272 + if (!"IMPORT".equals(vo.getImportType())) {
  273 + // 开启审核
  274 + flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, data);
  275 + }
264 276
265 277 return data.getId();
266 278 }
... ... @@ -628,6 +640,32 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
628 640 flowInstanceWrapperService.startInstance(BPM_FLAG, data.getId(), BPM_FLAG, vo);
629 641 }
630 642
  643 + @OpLog(type = OtherOpLogType.class, name = "更新状态,ID:{}", params = {"#id"})
  644 + @Transactional(rollbackFor = Exception.class)
  645 + @Override
  646 + public void updateStatus(String id, String status) {
  647 + if (StringUtils.isBlank(id) || StringUtils.isBlank(status)) {
  648 + return;
  649 + }
  650 + LambdaUpdateWrapper<CustomerCredit> updateWrapper = Wrappers.lambdaUpdate(CustomerCredit.class)
  651 + .set(CustomerCredit::getStatus, status)
  652 + .eq(CustomerCredit::getId, id);
  653 + getBaseMapper().update(updateWrapper);
  654 + }
  655 +
  656 + @OpLog(type = OtherOpLogType.class, name = "取消,ID:{}", params = {"#id"})
  657 + @Transactional(rollbackFor = Exception.class)
  658 + @Override
  659 + public void cancel(String id) {
  660 + if (StringUtils.isBlank(id)) {
  661 + return;
  662 + }
  663 + LambdaUpdateWrapper<CustomerCredit> updateWrapper = Wrappers.lambdaUpdate(CustomerCredit.class)
  664 + .set(CustomerCredit::getStatus, "CANCEL")
  665 + .eq(CustomerCredit::getId, id);
  666 + getBaseMapper().update(updateWrapper);
  667 + }
  668 +
631 669 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"})
632 670 @Transactional(rollbackFor = Exception.class)
633 671 @Override
... ...
... ... @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.listeners.flow;
2 2
3 3 import com.lframework.starter.bpm.enums.FlowInstanceStatus;
4 4 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
  5 +import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
5 6 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService;
6 7 import lombok.extern.slf4j.Slf4j;
7 8 import org.apache.commons.collections4.MapUtils;
... ... @@ -20,6 +21,8 @@ public class NodeFinishListener implements Listener {
20 21
21 22 @Resource
22 23 private CustomerDevelopPlanService customerDevelopPlanService;
  24 + @Resource
  25 + private CustomerCreditService customerCreditService;
23 26
24 27
25 28 /**
... ... @@ -44,6 +47,9 @@ public class NodeFinishListener implements Listener {
44 47 case "CUSTOMER_DEVELOP":
45 48 handleCustomerDevelopData(flowStatus, businessId);
46 49 break;
  50 + case "CUSTOMER_CREDIT":
  51 + handleCustomerCreditData(flowStatus, businessId);
  52 + break;
47 53 default:
48 54 break;
49 55 }
... ... @@ -54,7 +60,7 @@ public class NodeFinishListener implements Listener {
54 60 /**
55 61 * 客户开发业务数据处理
56 62 *
57   - * @param businessId 业务ID
  63 + * @param businessId 业务ID
58 64 */
59 65 private void handleCustomerDevelopData(String flowStatus, String businessId) {
60 66 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)) {
... ... @@ -63,4 +69,17 @@ public class NodeFinishListener implements Listener {
63 69 customerDevelopPlanService.updateStatus(businessId, CustomerDevelopStatus.REFUSE);
64 70 }
65 71 }
66   -}
\ No newline at end of file
  72 +
  73 + /**
  74 + * 客户资信业务数据处理
  75 + *
  76 + * @param businessId 业务ID
  77 + */
  78 + private void handleCustomerCreditData(String flowStatus, String businessId) {
  79 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)) {
  80 + customerCreditService.updateStatus(businessId, "PASS");
  81 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)) {
  82 + customerCreditService.updateStatus(businessId, "REFUSE");
  83 + }
  84 + }
  85 +}
... ...
... ... @@ -48,6 +48,21 @@ public interface CustomerCreditService extends BaseMpService<CustomerCredit> {
48 48 */
49 49 void update(UpdateCustomerCreditVo vo);
50 50
  51 +
  52 + /**
  53 + * 更新状态
  54 + * @param id
  55 + * @param status
  56 + */
  57 + void updateStatus(String id, String status);
  58 +
  59 + /**
  60 + * 取消
  61 + *
  62 + * @param id
  63 + */
  64 + void cancel(String id);
  65 +
51 66 /**
52 67 * 根据ID删除
53 68 * @param id
... ...
... ... @@ -391,4 +391,10 @@ public class CreateCustomerCreditVo implements BaseVo, Serializable {
391 391 @ApiModelProperty("核心人员")
392 392 private List<CreateCorePersonnelVo> corePersonnelList;
393 393
  394 + /**
  395 + * 是否为导入(IMPORT)
  396 + */
  397 + @ApiModelProperty("是否为导入")
  398 + private String importType;
  399 +
394 400 }
... ...
... ... @@ -7,6 +7,7 @@ import com.lframework.starter.web.core.vo.BaseVo;
7 7 import com.lframework.starter.web.core.components.validation.TypeMismatch;
8 8 import io.swagger.annotations.ApiModelProperty;
9 9 import java.io.Serializable;
  10 +import java.util.List;
10 11
11 12 @Data
12 13 public class QueryCustomerCreditVo extends PageVo implements BaseVo, Serializable {
... ... @@ -14,6 +15,13 @@ public class QueryCustomerCreditVo extends PageVo implements BaseVo, Serializabl
14 15 private static final long serialVersionUID = 1L;
15 16
16 17 /**
  18 + * ID集合
  19 + */
  20 + @ApiModelProperty("ID集合")
  21 + private List<String> ids;
  22 +
  23 +
  24 + /**
17 25 * 登记开始日期
18 26 */
19 27 @ApiModelProperty("登记开始日期")
... ... @@ -49,4 +57,10 @@ public class QueryCustomerCreditVo extends PageVo implements BaseVo, Serializabl
49 57 @ApiModelProperty("资信编号")
50 58 private String serialNumber;
51 59
  60 + /**
  61 + * 导出类型
  62 + */
  63 + @ApiModelProperty("导出类型")
  64 + private String exportType;
  65 +
52 66 }
... ...