feat: 客户管理
parent
9152c9927e
commit
d22c5eb9e3
|
|
@ -191,18 +191,21 @@ drop table if exists `eval_customer`;
|
||||||
create table `eval_customer` (
|
create table `eval_customer` (
|
||||||
`id` bigint not null comment '主键',
|
`id` bigint not null comment '主键',
|
||||||
`org_id` bigint not null comment '评价机构id',
|
`org_id` bigint not null comment '评价机构id',
|
||||||
`customer_name` varchar(200) not null comment '客户(被评价企业)名称',
|
`customer_name` varchar(200) not null comment '企业名称/客户名称',
|
||||||
`credit_code` varchar(18) default null comment '统一社会信用代码',
|
`credit_code` varchar(18) default null comment '统一社会信用代码',
|
||||||
`district_code` varchar(32) default null comment '所属区县编码',
|
`district_code` varchar(32) default null comment '属地编码(重庆市区级,见ChongqingDistrictEnum)',
|
||||||
`district_name` varchar(50) default null comment '所属区县名称',
|
`industry_code` varchar(64) default null comment '所属行业编码(见IndustryEnum)',
|
||||||
`address` varchar(500) default null comment '地址',
|
`business_address` varchar(500) default null comment '经营地址',
|
||||||
`contact_name` varchar(50) default null comment '联系人',
|
`longitude` varchar(32) default null comment '经度',
|
||||||
`contact_phone` varchar(20) default null comment '联系电话',
|
`latitude` varchar(32) default null comment '纬度',
|
||||||
`industry_code` varchar(32) default null comment '行业编码',
|
`enterprise_status_code` int default null comment '企业状态编码(见EnterpriseStatusEnum)',
|
||||||
`industry_name` varchar(100) default null comment '行业名称',
|
`principal_name` varchar(50) default null comment '主要负责人',
|
||||||
|
`principal_phone` varchar(20) default null comment '负责人电话',
|
||||||
|
`legal_representative` varchar(50) default null comment '法定代表人',
|
||||||
|
`legal_representative_phone` varchar(20) default null comment '法人电话',
|
||||||
|
`enterprise_scale_code` varchar(32) default null comment '企业规模编码(见EnterpriseScaleEnum)',
|
||||||
`eval_expire_date` date default null comment '评价到期日(供预警)',
|
`eval_expire_date` date default null comment '评价到期日(供预警)',
|
||||||
`customer_status_code` int default null comment '客户状态编码(1正常2停用)',
|
`customer_status_code` int default 1 comment '客户状态编码(见CustomerStatusEnum,1正常2停用)',
|
||||||
`customer_status_name` varchar(50) default null comment '客户状态名称',
|
|
||||||
`delete_enum` varchar(32) default null comment '删除标识true false',
|
`delete_enum` varchar(32) default null comment '删除标识true false',
|
||||||
`remarks` varchar(255) default null comment '备注',
|
`remarks` varchar(255) default null comment '备注',
|
||||||
`create_name` varchar(50) default null comment '创建人姓名',
|
`create_name` varchar(50) default null comment '创建人姓名',
|
||||||
|
|
@ -217,7 +220,9 @@ create table `eval_customer` (
|
||||||
primary key (`id`),
|
primary key (`id`),
|
||||||
key `idx_eval_customer_org` (`org_id`),
|
key `idx_eval_customer_org` (`org_id`),
|
||||||
key `idx_eval_customer_credit` (`credit_code`),
|
key `idx_eval_customer_credit` (`credit_code`),
|
||||||
key `idx_eval_customer_name` (`customer_name`)
|
key `idx_eval_customer_name` (`customer_name`),
|
||||||
|
key `idx_eval_customer_district` (`district_code`),
|
||||||
|
key `idx_eval_customer_industry` (`industry_code`)
|
||||||
) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='安评客户表';
|
) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='安评客户表';
|
||||||
|
|
||||||
drop table if exists `eval_project`;
|
drop table if exists `eval_project`;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.qinan.safetyeval.client.api.institution.EvalCustomerApi;
|
import org.qinan.safetyeval.client.api.institution.EvalCustomerApi;
|
||||||
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
||||||
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerEnumsCO;
|
||||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
||||||
|
|
@ -53,4 +54,10 @@ public class EvalCustomerController {
|
||||||
public PageResponse<EvalCustomerCO> page(@Validated EvalCustomerPageQuery query) {
|
public PageResponse<EvalCustomerCO> page(@Validated EvalCustomerPageQuery query) {
|
||||||
return evalCustomerApi.page(query);
|
return evalCustomerApi.page(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("客户管理枚举映射")
|
||||||
|
@GetMapping("/enums")
|
||||||
|
public SingleResponse<EvalCustomerEnumsCO> enums() {
|
||||||
|
return evalCustomerApi.enums();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package org.qinan.safetyeval.app.convertor;
|
||||||
|
|
||||||
|
import org.mapstruct.AfterMapping;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.MappingTarget;
|
||||||
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
||||||
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
||||||
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerModifyCmd;
|
||||||
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerPageQuery;
|
||||||
|
import org.qinan.safetyeval.domain.constant.ChongqingDistrictEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.CustomerStatusEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.EnterpriseScaleEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.EnterpriseStatusEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.IndustryEnum;
|
||||||
|
import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
||||||
|
import org.qinan.safetyeval.domain.query.EvalCustomerQuery;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安评客户命令转换
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface EvalCustomerCmdConvertor {
|
||||||
|
|
||||||
|
@Mapping(target = "id", ignore = true)
|
||||||
|
@Mapping(target = "orgId", ignore = true)
|
||||||
|
@Mapping(target = "tenantId", ignore = true)
|
||||||
|
EvalCustomerEntity convertAddCmdToE(EvalCustomerAddCmd cmd);
|
||||||
|
|
||||||
|
@Mapping(target = "id", expression = "java(cmd.getId() == null ? null : Long.parseLong(cmd.getId()))")
|
||||||
|
@Mapping(target = "orgId", ignore = true)
|
||||||
|
@Mapping(target = "tenantId", ignore = true)
|
||||||
|
EvalCustomerEntity convertModifyCmdToE(EvalCustomerModifyCmd cmd);
|
||||||
|
|
||||||
|
@Mapping(target = "pageNum", source = "current")
|
||||||
|
@Mapping(target = "pageSize", source = "size")
|
||||||
|
@Mapping(target = "orgId", ignore = true)
|
||||||
|
EvalCustomerQuery convertPageQueryToQ(EvalCustomerPageQuery query);
|
||||||
|
|
||||||
|
@Mapping(target = "id", expression = "java(entity.getId() == null ? null : String.valueOf(entity.getId()))")
|
||||||
|
@Mapping(target = "districtName", ignore = true)
|
||||||
|
@Mapping(target = "industryName", ignore = true)
|
||||||
|
@Mapping(target = "enterpriseStatusName", ignore = true)
|
||||||
|
@Mapping(target = "enterpriseScaleName", ignore = true)
|
||||||
|
@Mapping(target = "customerStatusName", ignore = true)
|
||||||
|
@Mapping(target = "projectCount", ignore = true)
|
||||||
|
EvalCustomerCO convertEToCO(EvalCustomerEntity entity);
|
||||||
|
|
||||||
|
List<EvalCustomerCO> convertEListToCOList(List<EvalCustomerEntity> list);
|
||||||
|
|
||||||
|
@AfterMapping
|
||||||
|
default void fillEnumNames(EvalCustomerEntity entity, @MappingTarget EvalCustomerCO co) {
|
||||||
|
if (entity == null || co == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChongqingDistrictEnum district = ChongqingDistrictEnum.ofCode(entity.getDistrictCode());
|
||||||
|
if (district != null) {
|
||||||
|
co.setDistrictName(district.getValue());
|
||||||
|
}
|
||||||
|
IndustryEnum industry = IndustryEnum.ofCode(entity.getIndustryCode());
|
||||||
|
if (industry != null) {
|
||||||
|
co.setIndustryName(industry.getValue());
|
||||||
|
}
|
||||||
|
EnterpriseStatusEnum enterpriseStatus = EnterpriseStatusEnum.ofCode(entity.getEnterpriseStatusCode());
|
||||||
|
if (enterpriseStatus != null) {
|
||||||
|
co.setEnterpriseStatusName(enterpriseStatus.getValue());
|
||||||
|
}
|
||||||
|
EnterpriseScaleEnum scale = EnterpriseScaleEnum.ofCode(entity.getEnterpriseScaleCode());
|
||||||
|
if (scale != null) {
|
||||||
|
co.setEnterpriseScaleName(scale.getValue());
|
||||||
|
}
|
||||||
|
CustomerStatusEnum customerStatus = CustomerStatusEnum.ofCode(entity.getCustomerStatusCode());
|
||||||
|
if (customerStatus != null) {
|
||||||
|
co.setCustomerStatusName(customerStatus.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,20 @@
|
||||||
package org.qinan.safetyeval.app.executor.institution;
|
package org.qinan.safetyeval.app.executor.institution;
|
||||||
|
|
||||||
|
import org.qinan.safetyeval.app.convertor.EvalCustomerCmdConvertor;
|
||||||
import org.qinan.safetyeval.client.api.institution.EvalCustomerApi;
|
import org.qinan.safetyeval.client.api.institution.EvalCustomerApi;
|
||||||
|
import org.qinan.safetyeval.client.co.institution.EnumOptionCO;
|
||||||
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
||||||
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerEnumsCO;
|
||||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
||||||
import org.qinan.safetyeval.client.dto.institution.EvalCustomerModifyCmd;
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerModifyCmd;
|
||||||
import org.qinan.safetyeval.client.dto.institution.EvalCustomerPageQuery;
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerPageQuery;
|
||||||
|
import org.qinan.safetyeval.domain.constant.ChongqingDistrictEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.CustomerStatusEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.EnterpriseScaleEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.EnterpriseStatusEnum;
|
||||||
|
import org.qinan.safetyeval.domain.constant.IndustryEnum;
|
||||||
import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
||||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||||
import org.qinan.safetyeval.domain.query.EvalCustomerQuery;
|
import org.qinan.safetyeval.domain.query.EvalCustomerQuery;
|
||||||
|
|
@ -17,6 +25,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class EvalCustomerExecutor implements EvalCustomerApi {
|
public class EvalCustomerExecutor implements EvalCustomerApi {
|
||||||
|
|
||||||
|
|
@ -28,24 +39,17 @@ public class EvalCustomerExecutor implements EvalCustomerApi {
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private InstitutionOrgSupport institutionOrgSupport;
|
private InstitutionOrgSupport institutionOrgSupport;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Autowired(required = false)
|
||||||
|
private EvalCustomerCmdConvertor evalCustomerCmdConvertor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SingleResponse<EvalCustomerCO> save(EvalCustomerAddCmd cmd) {
|
public SingleResponse<EvalCustomerCO> save(EvalCustomerAddCmd cmd) {
|
||||||
Long orgId = institutionOrgSupport.resolveCurrentOrgId();
|
Long orgId = institutionOrgSupport.resolveCurrentOrgId();
|
||||||
EvalCustomerEntity entity = new EvalCustomerEntity();
|
EvalCustomerEntity entity = evalCustomerCmdConvertor.convertAddCmdToE(cmd);
|
||||||
entity.setOrgId(orgId);
|
entity.setOrgId(orgId);
|
||||||
entity.setCustomerName(cmd.getCustomerName());
|
|
||||||
entity.setCreditCode(cmd.getCreditCode());
|
|
||||||
entity.setDistrictCode(cmd.getDistrictCode());
|
|
||||||
entity.setDistrictName(cmd.getDistrictName());
|
|
||||||
entity.setAddress(cmd.getAddress());
|
|
||||||
entity.setContactName(cmd.getContactName());
|
|
||||||
entity.setContactPhone(cmd.getContactPhone());
|
|
||||||
entity.setIndustryCode(cmd.getIndustryCode());
|
|
||||||
entity.setIndustryName(cmd.getIndustryName());
|
|
||||||
entity.setEvalExpireDate(cmd.getEvalExpireDate());
|
|
||||||
entity.setCustomerStatusCode(cmd.getCustomerStatusCode());
|
|
||||||
EvalCustomerEntity result = evalCustomerDomainService.add(entity);
|
EvalCustomerEntity result = evalCustomerDomainService.add(entity);
|
||||||
return SingleResponse.success(toCO(result, null));
|
return SingleResponse.success(evalCustomerCmdConvertor.convertEToCO(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -53,28 +57,18 @@ public class EvalCustomerExecutor implements EvalCustomerApi {
|
||||||
EvalCustomerEntity entity = evalCustomerDomainService.get(id);
|
EvalCustomerEntity entity = evalCustomerDomainService.get(id);
|
||||||
institutionOrgSupport.assertOrgAccess(entity.getOrgId(), ErrorCode.EVAL_CUSTOMER_NOT_FOUND);
|
institutionOrgSupport.assertOrgAccess(entity.getOrgId(), ErrorCode.EVAL_CUSTOMER_NOT_FOUND);
|
||||||
long projectCount = evalCustomerDomainService.countProjects(id, entity.getOrgId());
|
long projectCount = evalCustomerDomainService.countProjects(id, entity.getOrgId());
|
||||||
return SingleResponse.success(toCO(entity, projectCount));
|
EvalCustomerCO co = evalCustomerCmdConvertor.convertEToCO(entity);
|
||||||
|
co.setProjectCount(projectCount);
|
||||||
|
return SingleResponse.success(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SingleResponse<EvalCustomerCO> modify(EvalCustomerModifyCmd cmd) {
|
public SingleResponse<EvalCustomerCO> modify(EvalCustomerModifyCmd cmd) {
|
||||||
EvalCustomerEntity existing = evalCustomerDomainService.get(Long.parseLong(cmd.getId()));
|
EvalCustomerEntity existing = evalCustomerDomainService.get(Long.parseLong(cmd.getId()));
|
||||||
institutionOrgSupport.assertOrgAccess(existing.getOrgId(), ErrorCode.EVAL_CUSTOMER_NOT_FOUND);
|
institutionOrgSupport.assertOrgAccess(existing.getOrgId(), ErrorCode.EVAL_CUSTOMER_NOT_FOUND);
|
||||||
EvalCustomerEntity entity = new EvalCustomerEntity();
|
EvalCustomerEntity entity = evalCustomerCmdConvertor.convertModifyCmdToE(cmd);
|
||||||
entity.setId(Long.parseLong(cmd.getId()));
|
|
||||||
entity.setCustomerName(cmd.getCustomerName());
|
|
||||||
entity.setCreditCode(cmd.getCreditCode());
|
|
||||||
entity.setDistrictCode(cmd.getDistrictCode());
|
|
||||||
entity.setDistrictName(cmd.getDistrictName());
|
|
||||||
entity.setAddress(cmd.getAddress());
|
|
||||||
entity.setContactName(cmd.getContactName());
|
|
||||||
entity.setContactPhone(cmd.getContactPhone());
|
|
||||||
entity.setIndustryCode(cmd.getIndustryCode());
|
|
||||||
entity.setIndustryName(cmd.getIndustryName());
|
|
||||||
entity.setEvalExpireDate(cmd.getEvalExpireDate());
|
|
||||||
entity.setCustomerStatusCode(cmd.getCustomerStatusCode());
|
|
||||||
EvalCustomerEntity result = evalCustomerDomainService.modify(entity);
|
EvalCustomerEntity result = evalCustomerDomainService.modify(entity);
|
||||||
return SingleResponse.success(toCO(result, null));
|
return SingleResponse.success(evalCustomerCmdConvertor.convertEToCO(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -87,39 +81,32 @@ public class EvalCustomerExecutor implements EvalCustomerApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<EvalCustomerCO> page(EvalCustomerPageQuery query) {
|
public PageResponse<EvalCustomerCO> page(EvalCustomerPageQuery query) {
|
||||||
EvalCustomerQuery domainQuery = new EvalCustomerQuery();
|
EvalCustomerQuery domainQuery = evalCustomerCmdConvertor.convertPageQueryToQ(query);
|
||||||
domainQuery.setPageNum(query.getCurrent());
|
|
||||||
domainQuery.setPageSize(query.getSize());
|
|
||||||
domainQuery.setOrgId(institutionOrgSupport.resolveCurrentOrgId());
|
domainQuery.setOrgId(institutionOrgSupport.resolveCurrentOrgId());
|
||||||
domainQuery.setCustomerName(query.getCustomerName());
|
|
||||||
domainQuery.setContactName(query.getContactName());
|
|
||||||
domainQuery.setDistrictCode(query.getDistrictCode());
|
|
||||||
domainQuery.setDistrictName(query.getDistrictName());
|
|
||||||
PageResult<EvalCustomerEntity> pageResult = evalCustomerDomainService.page(domainQuery);
|
PageResult<EvalCustomerEntity> pageResult = evalCustomerDomainService.page(domainQuery);
|
||||||
return PageResponse.of(
|
return PageResponse.of(
|
||||||
pageResult.getRecords().stream().map(e -> toCO(e, null)).collect(java.util.stream.Collectors.toList()),
|
evalCustomerCmdConvertor.convertEListToCOList(pageResult.getRecords()),
|
||||||
pageResult.getTotal());
|
pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
private EvalCustomerCO toCO(EvalCustomerEntity entity, Long projectCount) {
|
@Override
|
||||||
if (entity == null) {
|
public SingleResponse<EvalCustomerEnumsCO> enums() {
|
||||||
return null;
|
EvalCustomerEnumsCO co = new EvalCustomerEnumsCO();
|
||||||
}
|
co.setDistrict(Arrays.stream(ChongqingDistrictEnum.values())
|
||||||
EvalCustomerCO co = new EvalCustomerCO();
|
.map(e -> new EnumOptionCO(e.getCode(), e.getValue()))
|
||||||
co.setId(entity.getId() != null ? String.valueOf(entity.getId()) : null);
|
.collect(Collectors.toList()));
|
||||||
co.setCustomerName(entity.getCustomerName());
|
co.setIndustry(Arrays.stream(IndustryEnum.values())
|
||||||
co.setCreditCode(entity.getCreditCode());
|
.map(e -> new EnumOptionCO(e.getCode(), e.getValue()))
|
||||||
co.setDistrictCode(entity.getDistrictCode());
|
.collect(Collectors.toList()));
|
||||||
co.setDistrictName(entity.getDistrictName());
|
co.setEnterpriseStatus(Arrays.stream(EnterpriseStatusEnum.values())
|
||||||
co.setAddress(entity.getAddress());
|
.map(e -> new EnumOptionCO(String.valueOf(e.getCode()), e.getValue()))
|
||||||
co.setContactName(entity.getContactName());
|
.collect(Collectors.toList()));
|
||||||
co.setContactPhone(entity.getContactPhone());
|
co.setEnterpriseScale(Arrays.stream(EnterpriseScaleEnum.values())
|
||||||
co.setIndustryCode(entity.getIndustryCode());
|
.map(e -> new EnumOptionCO(e.getCode(), e.getValue()))
|
||||||
co.setIndustryName(entity.getIndustryName());
|
.collect(Collectors.toList()));
|
||||||
co.setEvalExpireDate(entity.getEvalExpireDate());
|
co.setCustomerStatus(Arrays.stream(CustomerStatusEnum.values())
|
||||||
co.setCustomerStatusCode(entity.getCustomerStatusCode());
|
.map(e -> new EnumOptionCO(String.valueOf(e.getCode()), e.getValue()))
|
||||||
co.setCustomerStatusName(entity.getCustomerStatusName());
|
.collect(Collectors.toList()));
|
||||||
co.setProjectCount(projectCount);
|
return SingleResponse.success(co);
|
||||||
return co;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.qinan.safetyeval.client.api.institution;
|
package org.qinan.safetyeval.client.api.institution;
|
||||||
|
|
||||||
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerCO;
|
||||||
|
import org.qinan.safetyeval.client.co.institution.EvalCustomerEnumsCO;
|
||||||
import org.qinan.safetyeval.client.dto.PageResponse;
|
import org.qinan.safetyeval.client.dto.PageResponse;
|
||||||
import org.qinan.safetyeval.client.dto.SingleResponse;
|
import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
import org.qinan.safetyeval.client.dto.institution.EvalCustomerAddCmd;
|
||||||
|
|
@ -18,4 +19,6 @@ public interface EvalCustomerApi {
|
||||||
SingleResponse<Void> delete(Long id);
|
SingleResponse<Void> delete(Long id);
|
||||||
|
|
||||||
PageResponse<EvalCustomerCO> page(EvalCustomerPageQuery query);
|
PageResponse<EvalCustomerCO> page(EvalCustomerPageQuery query);
|
||||||
|
|
||||||
|
SingleResponse<EvalCustomerEnumsCO> enums();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.qinan.safetyeval.client.co.institution;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EnumOptionCO {
|
||||||
|
|
||||||
|
@ApiModelProperty("编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
|
@ -16,35 +16,57 @@ public class EvalCustomerCO {
|
||||||
|
|
||||||
@ApiModelProperty("统一社会信用代码")
|
@ApiModelProperty("统一社会信用代码")
|
||||||
private String creditCode;
|
private String creditCode;
|
||||||
|
@ApiModelProperty("属地编码")
|
||||||
@ApiModelProperty("所属区县编码")
|
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
|
|
||||||
@ApiModelProperty("所属区县名称")
|
@ApiModelProperty("属地名称")
|
||||||
private String districtName;
|
private String districtName;
|
||||||
|
|
||||||
@ApiModelProperty("地址")
|
@ApiModelProperty("所属行业编码")
|
||||||
private String address;
|
|
||||||
|
|
||||||
@ApiModelProperty("联系人")
|
|
||||||
private String contactName;
|
|
||||||
|
|
||||||
@ApiModelProperty("联系电话")
|
|
||||||
private String contactPhone;
|
|
||||||
|
|
||||||
@ApiModelProperty("行业编码")
|
|
||||||
private String industryCode;
|
private String industryCode;
|
||||||
|
|
||||||
@ApiModelProperty("行业名称")
|
@ApiModelProperty("所属行业名称")
|
||||||
private String industryName;
|
private String industryName;
|
||||||
|
|
||||||
|
@ApiModelProperty("经营地址")
|
||||||
|
private String businessAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty("经度")
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
@ApiModelProperty("纬度")
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "企业状态编码:1正常经营 2停产整改 3停业 4注销", example = "1")
|
||||||
|
private Integer enterpriseStatusCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业状态名称")
|
||||||
|
private String enterpriseStatusName;
|
||||||
|
|
||||||
|
@ApiModelProperty("主要负责人")
|
||||||
|
private String principalName;
|
||||||
|
@ApiModelProperty("负责人电话")
|
||||||
|
private String principalPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("法定代表人")
|
||||||
|
private String legalRepresentative;
|
||||||
|
|
||||||
|
@ApiModelProperty("法人电话")
|
||||||
|
private String legalRepresentativePhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业规模编码")
|
||||||
|
private String enterpriseScaleCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业规模名称")
|
||||||
|
private String enterpriseScaleName;
|
||||||
|
|
||||||
@ApiModelProperty("评价到期日")
|
@ApiModelProperty("评价到期日")
|
||||||
private LocalDate evalExpireDate;
|
private LocalDate evalExpireDate;
|
||||||
|
|
||||||
@ApiModelProperty(value = "客户状态编码:1正常 2停用", example = "1")
|
@ApiModelProperty(value = "客户状态编码:1正常 2停用", example = "1")
|
||||||
private Integer customerStatusCode;
|
private Integer customerStatusCode;
|
||||||
|
|
||||||
@ApiModelProperty(value = "客户状态名称:正常/停用", example = "正常")
|
@ApiModelProperty("客户状态名称")
|
||||||
private String customerStatusName;
|
private String customerStatusName;
|
||||||
|
|
||||||
@ApiModelProperty("服务项目数")
|
@ApiModelProperty("服务项目数")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.qinan.safetyeval.client.co.institution;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EvalCustomerEnumsCO {
|
||||||
|
|
||||||
|
@ApiModelProperty("属地(重庆市区级)")
|
||||||
|
private List<EnumOptionCO> district;
|
||||||
|
|
||||||
|
@ApiModelProperty("所属行业")
|
||||||
|
private List<EnumOptionCO> industry;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业状态")
|
||||||
|
private List<EnumOptionCO> enterpriseStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业规模")
|
||||||
|
private List<EnumOptionCO> enterpriseScale;
|
||||||
|
|
||||||
|
@ApiModelProperty("客户状态")
|
||||||
|
private List<EnumOptionCO> customerStatus;
|
||||||
|
}
|
||||||
|
|
@ -8,32 +8,44 @@ import java.time.LocalDate;
|
||||||
@Data
|
@Data
|
||||||
public class EvalCustomerAddCmd {
|
public class EvalCustomerAddCmd {
|
||||||
|
|
||||||
@ApiModelProperty("客户名称")
|
@ApiModelProperty("企业名称/客户名称")
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
@ApiModelProperty("统一社会信用代码")
|
@ApiModelProperty("统一社会信用代码")
|
||||||
private String creditCode;
|
private String creditCode;
|
||||||
|
|
||||||
@ApiModelProperty("所属区县编码")
|
@ApiModelProperty("属地编码(重庆市区级)")
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
|
|
||||||
@ApiModelProperty("所属区县名称")
|
@ApiModelProperty("所属行业编码(IndustryEnum)")
|
||||||
private String districtName;
|
|
||||||
|
|
||||||
@ApiModelProperty("地址")
|
|
||||||
private String address;
|
|
||||||
|
|
||||||
@ApiModelProperty("联系人")
|
|
||||||
private String contactName;
|
|
||||||
|
|
||||||
@ApiModelProperty("联系电话")
|
|
||||||
private String contactPhone;
|
|
||||||
|
|
||||||
@ApiModelProperty("行业编码")
|
|
||||||
private String industryCode;
|
private String industryCode;
|
||||||
|
|
||||||
@ApiModelProperty("行业名称")
|
@ApiModelProperty("经营地址")
|
||||||
private String industryName;
|
private String businessAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty("经度")
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
@ApiModelProperty("纬度")
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "企业状态编码:1正常经营 2停产整改 3停业 4注销", example = "1")
|
||||||
|
private Integer enterpriseStatusCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("主要负责人")
|
||||||
|
private String principalName;
|
||||||
|
|
||||||
|
@ApiModelProperty("负责人电话")
|
||||||
|
private String principalPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("法定代表人")
|
||||||
|
private String legalRepresentative;
|
||||||
|
|
||||||
|
@ApiModelProperty("法人电话")
|
||||||
|
private String legalRepresentativePhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业规模编码(LARGE/MEDIUM/SMALL/MICRO)")
|
||||||
|
private String enterpriseScaleCode;
|
||||||
|
|
||||||
@ApiModelProperty("评价到期日")
|
@ApiModelProperty("评价到期日")
|
||||||
private LocalDate evalExpireDate;
|
private LocalDate evalExpireDate;
|
||||||
|
|
|
||||||
|
|
@ -11,32 +11,41 @@ public class EvalCustomerModifyCmd {
|
||||||
@ApiModelProperty("主键ID")
|
@ApiModelProperty("主键ID")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@ApiModelProperty("客户名称")
|
@ApiModelProperty("企业名称/客户名称")
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
@ApiModelProperty("统一社会信用代码")
|
@ApiModelProperty("统一社会信用代码")
|
||||||
private String creditCode;
|
private String creditCode;
|
||||||
|
@ApiModelProperty("属地编码(重庆市区级)")
|
||||||
@ApiModelProperty("所属区县编码")
|
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
|
|
||||||
@ApiModelProperty("所属区县名称")
|
@ApiModelProperty("所属行业编码(IndustryEnum)")
|
||||||
private String districtName;
|
|
||||||
|
|
||||||
@ApiModelProperty("地址")
|
|
||||||
private String address;
|
|
||||||
|
|
||||||
@ApiModelProperty("联系人")
|
|
||||||
private String contactName;
|
|
||||||
|
|
||||||
@ApiModelProperty("联系电话")
|
|
||||||
private String contactPhone;
|
|
||||||
|
|
||||||
@ApiModelProperty("行业编码")
|
|
||||||
private String industryCode;
|
private String industryCode;
|
||||||
|
|
||||||
@ApiModelProperty("行业名称")
|
@ApiModelProperty("经营地址")
|
||||||
private String industryName;
|
private String businessAddress;
|
||||||
|
|
||||||
|
@ApiModelProperty("经度")
|
||||||
|
private String longitude;
|
||||||
|
@ApiModelProperty("纬度")
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "企业状态编码:1正常经营 2停产整改 3停业 4注销", example = "1")
|
||||||
|
private Integer enterpriseStatusCode;
|
||||||
|
|
||||||
|
@ApiModelProperty("主要负责人")
|
||||||
|
private String principalName;
|
||||||
|
@ApiModelProperty("负责人电话")
|
||||||
|
private String principalPhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("法定代表人")
|
||||||
|
private String legalRepresentative;
|
||||||
|
|
||||||
|
@ApiModelProperty("法人电话")
|
||||||
|
private String legalRepresentativePhone;
|
||||||
|
|
||||||
|
@ApiModelProperty("企业规模编码(LARGE/MEDIUM/SMALL/MICRO)")
|
||||||
|
private String enterpriseScaleCode;
|
||||||
|
|
||||||
@ApiModelProperty("评价到期日")
|
@ApiModelProperty("评价到期日")
|
||||||
private LocalDate evalExpireDate;
|
private LocalDate evalExpireDate;
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,9 @@ public class EvalCustomerPageQuery extends BasePageQuery {
|
||||||
@ApiModelProperty("客户名称")
|
@ApiModelProperty("客户名称")
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
@ApiModelProperty("联系人")
|
@ApiModelProperty("主要负责人")
|
||||||
private String contactName;
|
private String principalName;
|
||||||
|
|
||||||
@ApiModelProperty("所属区县编码")
|
@ApiModelProperty("属地编码")
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
|
|
||||||
@ApiModelProperty("所属区县名称")
|
|
||||||
private String districtName;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.qinan.safetyeval.domain.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重庆市属地(区级)枚举
|
||||||
|
*/
|
||||||
|
public enum ChongqingDistrictEnum {
|
||||||
|
|
||||||
|
WANZHOU("500101", "万州区"),
|
||||||
|
FULING("500102", "涪陵区"),
|
||||||
|
YUZHONG("500103", "渝中区"),
|
||||||
|
DADUKOU("500104", "大渡口区"),
|
||||||
|
JIANGBEI("500105", "江北区"),
|
||||||
|
SHAPINGBA("500106", "沙坪坝区"),
|
||||||
|
JIULONGPO("500107", "九龙坡区"),
|
||||||
|
NANAN("500108", "南岸区"),
|
||||||
|
BEIBEI("500109", "北碚区"),
|
||||||
|
QIJIANG("500110", "綦江区"),
|
||||||
|
DAZU("500111", "大足区"),
|
||||||
|
YUBEI("500112", "渝北区"),
|
||||||
|
BANAN("500113", "巴南区"),
|
||||||
|
QIANJIANG("500114", "黔江区"),
|
||||||
|
CHANGSHOU("500115", "长寿区"),
|
||||||
|
JIANGJIN("500116", "江津区"),
|
||||||
|
HECHUAN("500117", "合川区"),
|
||||||
|
YONGCHUAN("500118", "永川区"),
|
||||||
|
NANCHUAN("500119", "南川区"),
|
||||||
|
BISHAN("500120", "璧山区"),
|
||||||
|
TONGLIANG("500151", "铜梁区"),
|
||||||
|
TONGNAN("500152", "潼南区"),
|
||||||
|
RONGCHANG("500153", "荣昌区"),
|
||||||
|
KAIZHOU("500154", "开州区"),
|
||||||
|
LIANGPING("500155", "梁平区"),
|
||||||
|
WULONG("500156", "武隆区"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
ChongqingDistrictEnum(String code, String value) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ChongqingDistrictEnum ofCode(String code) {
|
||||||
|
if (code == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (ChongqingDistrictEnum item : values()) {
|
||||||
|
if (item.code.equals(code)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package org.qinan.safetyeval.domain.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安评客户状态枚举(档案启停)
|
||||||
|
*/
|
||||||
|
public enum CustomerStatusEnum {
|
||||||
|
|
||||||
|
NORMAL(1, "正常"),
|
||||||
|
DISABLED(2, "停用"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
CustomerStatusEnum(int code, String value) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomerStatusEnum ofCode(Integer code) {
|
||||||
|
if (code == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (CustomerStatusEnum item : values()) {
|
||||||
|
if (item.code == code) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.qinan.safetyeval.domain.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业规模枚举(安评客户)
|
||||||
|
*/
|
||||||
|
public enum EnterpriseScaleEnum {
|
||||||
|
|
||||||
|
LARGE("LARGE", "大型企业"),
|
||||||
|
MEDIUM("MEDIUM", "中型企业"),
|
||||||
|
SMALL("SMALL", "小型企业"),
|
||||||
|
MICRO("MICRO", "微型企业"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
EnterpriseScaleEnum(String code, String value) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnterpriseScaleEnum ofCode(String code) {
|
||||||
|
if (code == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (EnterpriseScaleEnum item : values()) {
|
||||||
|
if (item.code.equals(code)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.qinan.safetyeval.domain.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业状态枚举(安评客户)
|
||||||
|
*/
|
||||||
|
public enum EnterpriseStatusEnum {
|
||||||
|
|
||||||
|
NORMAL_OPERATING(1, "正常经营"),
|
||||||
|
STOP_RECTIFY(2, "停产整改"),
|
||||||
|
CLOSED(3, "停业"),
|
||||||
|
CANCELLED(4, "注销"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
EnterpriseStatusEnum(int code, String value) {
|
||||||
|
this.code = code;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnterpriseStatusEnum ofCode(Integer code) {
|
||||||
|
if (code == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (EnterpriseStatusEnum item : values()) {
|
||||||
|
if (item.code == code) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,20 +6,22 @@ import java.time.LocalDate;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EvalCustomerEntity {
|
public class EvalCustomerEntity {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private Long orgId;
|
private Long orgId;
|
||||||
private String customerName;
|
private String customerName;
|
||||||
private String creditCode;
|
private String creditCode;
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
private String districtName;
|
|
||||||
private String address;
|
|
||||||
private String contactName;
|
|
||||||
private String contactPhone;
|
|
||||||
private String industryCode;
|
private String industryCode;
|
||||||
private String industryName;
|
private String businessAddress;
|
||||||
|
private String longitude;
|
||||||
|
private String latitude;
|
||||||
|
private Integer enterpriseStatusCode;
|
||||||
|
private String principalName;
|
||||||
|
private String principalPhone;
|
||||||
|
private String legalRepresentative;
|
||||||
|
private String legalRepresentativePhone;
|
||||||
|
private String enterpriseScaleCode;
|
||||||
private LocalDate evalExpireDate;
|
private LocalDate evalExpireDate;
|
||||||
private Integer customerStatusCode;
|
private Integer customerStatusCode;
|
||||||
private String customerStatusName;
|
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ public class EvalCustomerQuery {
|
||||||
private Long pageSize;
|
private Long pageSize;
|
||||||
private Long orgId;
|
private Long orgId;
|
||||||
private String customerName;
|
private String customerName;
|
||||||
private String contactName;
|
private String principalName;
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
private String districtName;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.qinan.safetyeval.domain.service;
|
package org.qinan.safetyeval.domain.service;
|
||||||
|
|
||||||
|
import org.qinan.safetyeval.domain.constant.CustomerStatusEnum;
|
||||||
import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
||||||
import org.qinan.safetyeval.domain.exception.BizException;
|
import org.qinan.safetyeval.domain.exception.BizException;
|
||||||
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||||
|
|
@ -21,7 +22,7 @@ public class EvalCustomerDomainService {
|
||||||
private EvalProjectGateway evalProjectGateway;
|
private EvalProjectGateway evalProjectGateway;
|
||||||
|
|
||||||
public EvalCustomerEntity add(EvalCustomerEntity entity) {
|
public EvalCustomerEntity add(EvalCustomerEntity entity) {
|
||||||
fillCustomerStatusName(entity);
|
fillDefaultCustomerStatus(entity);
|
||||||
return evalCustomerGateway.save(entity);
|
return evalCustomerGateway.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ public class EvalCustomerDomainService {
|
||||||
|
|
||||||
public EvalCustomerEntity modify(EvalCustomerEntity entity) {
|
public EvalCustomerEntity modify(EvalCustomerEntity entity) {
|
||||||
EvalCustomerEntity existing = get(entity.getId());
|
EvalCustomerEntity existing = get(entity.getId());
|
||||||
fillCustomerStatusName(entity);
|
fillDefaultCustomerStatus(entity);
|
||||||
entity.setOrgId(existing.getOrgId());
|
entity.setOrgId(existing.getOrgId());
|
||||||
return evalCustomerGateway.modify(entity);
|
return evalCustomerGateway.modify(entity);
|
||||||
}
|
}
|
||||||
|
|
@ -61,14 +62,9 @@ public class EvalCustomerDomainService {
|
||||||
return customer;
|
return customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillCustomerStatusName(EvalCustomerEntity entity) {
|
private void fillDefaultCustomerStatus(EvalCustomerEntity entity) {
|
||||||
if (entity.getCustomerStatusCode() == null) {
|
if (entity.getCustomerStatusCode() == null) {
|
||||||
entity.setCustomerStatusCode(1);
|
entity.setCustomerStatusCode(CustomerStatusEnum.NORMAL.getCode());
|
||||||
}
|
|
||||||
if (entity.getCustomerStatusCode() == 1) {
|
|
||||||
entity.setCustomerStatusName("正常");
|
|
||||||
} else if (entity.getCustomerStatusCode() == 2) {
|
|
||||||
entity.setCustomerStatusName("停用");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.qinan.safetyeval.infrastructure.convertor;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.EvalCustomerDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 安评客户 Entity ↔ DO
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring")
|
||||||
|
public interface EvalCustomerDoConvertor {
|
||||||
|
|
||||||
|
EvalCustomerDO convertEToDo(EvalCustomerEntity entity);
|
||||||
|
|
||||||
|
EvalCustomerEntity convertDoToE(EvalCustomerDO dataObject);
|
||||||
|
}
|
||||||
|
|
@ -15,17 +15,20 @@ public class EvalCustomerDO {
|
||||||
private String customerName;
|
private String customerName;
|
||||||
private String creditCode;
|
private String creditCode;
|
||||||
private String districtCode;
|
private String districtCode;
|
||||||
private String districtName;
|
|
||||||
private String address;
|
|
||||||
private String contactName;
|
|
||||||
private String contactPhone;
|
|
||||||
private String industryCode;
|
private String industryCode;
|
||||||
private String industryName;
|
private String businessAddress;
|
||||||
|
private String longitude;
|
||||||
|
private String latitude;
|
||||||
|
/** 企业状态编码:1正常经营 2停产整改 3停业 4注销 */
|
||||||
|
private Integer enterpriseStatusCode;
|
||||||
|
private String principalName;
|
||||||
|
private String principalPhone;
|
||||||
|
private String legalRepresentative;
|
||||||
|
private String legalRepresentativePhone;
|
||||||
|
private String enterpriseScaleCode;
|
||||||
private LocalDate evalExpireDate;
|
private LocalDate evalExpireDate;
|
||||||
/** 客户状态编码:1正常 2停用,示例:1 */
|
/** 客户状态编码:1正常 2停用 */
|
||||||
private Integer customerStatusCode;
|
private Integer customerStatusCode;
|
||||||
/** 客户状态名称:正常/停用,示例:正常 */
|
|
||||||
private String customerStatusName;
|
|
||||||
private String deleteEnum;
|
private String deleteEnum;
|
||||||
private String remarks;
|
private String remarks;
|
||||||
private String createName;
|
private String createName;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.qinan.safetyeval.domain.entity.EvalCustomerEntity;
|
||||||
import org.qinan.safetyeval.domain.gateway.EvalCustomerGateway;
|
import org.qinan.safetyeval.domain.gateway.EvalCustomerGateway;
|
||||||
import org.qinan.safetyeval.domain.query.EvalCustomerQuery;
|
import org.qinan.safetyeval.domain.query.EvalCustomerQuery;
|
||||||
import org.qinan.safetyeval.domain.query.PageResult;
|
import org.qinan.safetyeval.domain.query.PageResult;
|
||||||
|
import org.qinan.safetyeval.infrastructure.convertor.EvalCustomerDoConvertor;
|
||||||
import org.qinan.safetyeval.infrastructure.dataobject.EvalCustomerDO;
|
import org.qinan.safetyeval.infrastructure.dataobject.EvalCustomerDO;
|
||||||
import org.qinan.safetyeval.infrastructure.mapper.EvalCustomerMapper;
|
import org.qinan.safetyeval.infrastructure.mapper.EvalCustomerMapper;
|
||||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
|
|
@ -24,12 +25,16 @@ public class EvalCustomerGatewayImpl implements EvalCustomerGateway {
|
||||||
@Resource
|
@Resource
|
||||||
private EvalCustomerMapper evalCustomerMapper;
|
private EvalCustomerMapper evalCustomerMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EvalCustomerDoConvertor evalCustomerDoConvertor;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OrgContextResolver orgContextResolver;
|
private OrgContextResolver orgContextResolver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EvalCustomerEntity save(EvalCustomerEntity entity) {
|
public EvalCustomerEntity save(EvalCustomerEntity entity) {
|
||||||
EvalCustomerDO dataObject = toDO(entity);
|
EvalCustomerDO dataObject = evalCustomerDoConvertor.convertEToDo(entity);
|
||||||
|
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||||
InsertFieldDefaults.apply(dataObject);
|
InsertFieldDefaults.apply(dataObject);
|
||||||
evalCustomerMapper.insert(dataObject);
|
evalCustomerMapper.insert(dataObject);
|
||||||
entity.setId(dataObject.getId());
|
entity.setId(dataObject.getId());
|
||||||
|
|
@ -42,13 +47,14 @@ public class EvalCustomerGatewayImpl implements EvalCustomerGateway {
|
||||||
if (dataObject == null || !"false".equals(dataObject.getDeleteEnum())) {
|
if (dataObject == null || !"false".equals(dataObject.getDeleteEnum())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return toEntity(dataObject);
|
return evalCustomerDoConvertor.convertDoToE(dataObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EvalCustomerEntity modify(EvalCustomerEntity entity) {
|
public EvalCustomerEntity modify(EvalCustomerEntity entity) {
|
||||||
EvalCustomerDO dataObject = toDO(entity);
|
EvalCustomerDO dataObject = evalCustomerDoConvertor.convertEToDo(entity);
|
||||||
dataObject.setId(entity.getId());
|
dataObject.setId(entity.getId());
|
||||||
|
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
||||||
InsertFieldDefaults.applyForUpdate(dataObject);
|
InsertFieldDefaults.applyForUpdate(dataObject);
|
||||||
evalCustomerMapper.updateById(dataObject);
|
evalCustomerMapper.updateById(dataObject);
|
||||||
return get(entity.getId());
|
return get(entity.getId());
|
||||||
|
|
@ -64,7 +70,7 @@ public class EvalCustomerGatewayImpl implements EvalCustomerGateway {
|
||||||
Page<EvalCustomerDO> page = new Page<>(query.getPageNum(), query.getPageSize());
|
Page<EvalCustomerDO> page = new Page<>(query.getPageNum(), query.getPageSize());
|
||||||
IPage<EvalCustomerDO> result = evalCustomerMapper.selectPage(page, buildQueryWrapper(query));
|
IPage<EvalCustomerDO> result = evalCustomerMapper.selectPage(page, buildQueryWrapper(query));
|
||||||
List<EvalCustomerEntity> entities = result.getRecords().stream()
|
List<EvalCustomerEntity> entities = result.getRecords().stream()
|
||||||
.map(this::toEntity)
|
.map(evalCustomerDoConvertor::convertDoToE)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return PageResult.of(entities, result.getTotal(), result.getCurrent(), result.getSize());
|
return PageResult.of(entities, result.getTotal(), result.getCurrent(), result.getSize());
|
||||||
}
|
}
|
||||||
|
|
@ -78,58 +84,13 @@ public class EvalCustomerGatewayImpl implements EvalCustomerGateway {
|
||||||
if (StringUtils.hasText(query.getCustomerName())) {
|
if (StringUtils.hasText(query.getCustomerName())) {
|
||||||
wrapper.like(EvalCustomerDO::getCustomerName, query.getCustomerName());
|
wrapper.like(EvalCustomerDO::getCustomerName, query.getCustomerName());
|
||||||
}
|
}
|
||||||
if (StringUtils.hasText(query.getContactName())) {
|
if (StringUtils.hasText(query.getPrincipalName())) {
|
||||||
wrapper.like(EvalCustomerDO::getContactName, query.getContactName());
|
wrapper.like(EvalCustomerDO::getPrincipalName, query.getPrincipalName());
|
||||||
}
|
}
|
||||||
if (StringUtils.hasText(query.getDistrictCode())) {
|
if (StringUtils.hasText(query.getDistrictCode())) {
|
||||||
wrapper.eq(EvalCustomerDO::getDistrictCode, query.getDistrictCode());
|
wrapper.eq(EvalCustomerDO::getDistrictCode, query.getDistrictCode());
|
||||||
}
|
}
|
||||||
if (StringUtils.hasText(query.getDistrictName())) {
|
|
||||||
wrapper.like(EvalCustomerDO::getDistrictName, query.getDistrictName());
|
|
||||||
}
|
|
||||||
wrapper.orderByDesc(EvalCustomerDO::getCreateTime);
|
wrapper.orderByDesc(EvalCustomerDO::getCreateTime);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EvalCustomerDO toDO(EvalCustomerEntity entity) {
|
|
||||||
EvalCustomerDO dataObject = new EvalCustomerDO();
|
|
||||||
dataObject.setOrgId(orgContextResolver.resolveOrgId(entity.getOrgId()));
|
|
||||||
dataObject.setCustomerName(entity.getCustomerName());
|
|
||||||
dataObject.setCreditCode(entity.getCreditCode());
|
|
||||||
dataObject.setDistrictCode(entity.getDistrictCode());
|
|
||||||
dataObject.setDistrictName(entity.getDistrictName());
|
|
||||||
dataObject.setAddress(entity.getAddress());
|
|
||||||
dataObject.setContactName(entity.getContactName());
|
|
||||||
dataObject.setContactPhone(entity.getContactPhone());
|
|
||||||
dataObject.setIndustryCode(entity.getIndustryCode());
|
|
||||||
dataObject.setIndustryName(entity.getIndustryName());
|
|
||||||
dataObject.setEvalExpireDate(entity.getEvalExpireDate());
|
|
||||||
dataObject.setCustomerStatusCode(entity.getCustomerStatusCode());
|
|
||||||
dataObject.setCustomerStatusName(entity.getCustomerStatusName());
|
|
||||||
dataObject.setTenantId(entity.getTenantId());
|
|
||||||
return dataObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
private EvalCustomerEntity toEntity(EvalCustomerDO dataObject) {
|
|
||||||
if (dataObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
EvalCustomerEntity entity = new EvalCustomerEntity();
|
|
||||||
entity.setId(dataObject.getId());
|
|
||||||
entity.setOrgId(dataObject.getOrgId());
|
|
||||||
entity.setCustomerName(dataObject.getCustomerName());
|
|
||||||
entity.setCreditCode(dataObject.getCreditCode());
|
|
||||||
entity.setDistrictCode(dataObject.getDistrictCode());
|
|
||||||
entity.setDistrictName(dataObject.getDistrictName());
|
|
||||||
entity.setAddress(dataObject.getAddress());
|
|
||||||
entity.setContactName(dataObject.getContactName());
|
|
||||||
entity.setContactPhone(dataObject.getContactPhone());
|
|
||||||
entity.setIndustryCode(dataObject.getIndustryCode());
|
|
||||||
entity.setIndustryName(dataObject.getIndustryName());
|
|
||||||
entity.setEvalExpireDate(dataObject.getEvalExpireDate());
|
|
||||||
entity.setCustomerStatusCode(dataObject.getCustomerStatusCode());
|
|
||||||
entity.setCustomerStatusName(dataObject.getCustomerStatusName());
|
|
||||||
entity.setTenantId(dataObject.getTenantId());
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue