Commit 16df87ff authored by suhuiguang's avatar suhuiguang

1.人员导入

parent 64ee542e
package com.yeejoin.amos.boot.module.tcm.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class CertificateTypeConverter implements Converter<String> {
private static final Map<String, String> CODE_MAP = new HashMap<>();
static {
CODE_MAP.put("身份证", "344");
CODE_MAP.put("军官证", "345");
}
@Override
public Class supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
String cellDataStr = cellData.getStringValue();
return CODE_MAP.getOrDefault(cellDataStr, "344");
}
@Override
public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
return null;
}
}
package com.yeejoin.amos.boot.module.tcm.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class EducationConverter implements Converter<String> {
private static final Map<String,String> CODE_MAP = new HashMap<>();
static {
CODE_MAP.put("其他","6545");
CODE_MAP.put("专科","6544");
CODE_MAP.put("本科","6543");
CODE_MAP.put("硕士研究生","6542");
CODE_MAP.put("博士研究生","6541");
}
@Override
public Class supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
String cellDataStr = cellData.getStringValue();
return CODE_MAP.get(cellDataStr);
}
@Override
public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
return null;
}
}
package com.yeejoin.amos.boot.module.tcm.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class EquipTypeConverter implements Converter<String> {
private static final Map<String, String> CODE_MAP = new HashMap<>();
static {
CODE_MAP.put("锅炉", "1000");
CODE_MAP.put("压力容器", "2000");
CODE_MAP.put("电梯", "3000");
CODE_MAP.put("起重机械", "4000");
CODE_MAP.put("场(厂)内专用机动车辆", "5000");
CODE_MAP.put("大型游乐设施", "6000");
CODE_MAP.put("压力管道", "8000");
CODE_MAP.put("客运索道", "9000");
}
@Override
public Class supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
String cellDataStr = cellData.getStringValue();
return CODE_MAP.get(cellDataStr);
}
@Override
public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
return null;
}
}
package com.yeejoin.amos.boot.module.tcm.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class GenderConverter implements Converter<String> {
private static final Map<String,String> CODE_MAP = new HashMap<>();
static {
CODE_MAP.put("男","1");
CODE_MAP.put("女","0");
}
@Override
public Class supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return CODE_MAP.get(cellData.getStringValue());
}
@Override
public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
return null;
}
}
package com.yeejoin.amos.boot.module.tcm.api.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class PostTypeConverter implements Converter<String> {
private static final Map<String, String> CODE_MAP = new HashMap<>();
static {
CODE_MAP.put("安全员", "6549");
CODE_MAP.put("主要负责人", "6548");
CODE_MAP.put("安全总监", "6547");
CODE_MAP.put("普通员工", "6546");
CODE_MAP.put("作业人员", "6552");
CODE_MAP.put("质量安全员", "6551");
CODE_MAP.put("质量安全总监", "6550");
CODE_MAP.put("业务办理人员", "6616");
CODE_MAP.put("安改维负责人", "6553");
CODE_MAP.put("安全管理员", "6617");
CODE_MAP.put("维保人员", "6618");
CODE_MAP.put("检验人员", "66151");
CODE_MAP.put("检测人员", "66152");
CODE_MAP.put("质量保证体系人员", "6619");
}
@Override
public Class supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
String cellDataStr = cellData.getStringValue();
return CODE_MAP.getOrDefault(cellDataStr, "6546");
}
@Override
public CellData convertToExcelData(String value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
return null;
}
}
package com.yeejoin.amos.boot.module.tcm.api.customer;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD,ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = CustomerEquipTypeValidator.class)
public @interface CustomerEquipTypeCheck {
String message();
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
package com.yeejoin.amos.boot.module.tcm.api.customer;
import com.yeejoin.amos.boot.module.tcm.api.dto.UserImportDto;
import org.apache.commons.lang3.StringUtils;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CustomerEquipTypeValidator implements ConstraintValidator<CustomerEquipTypeCheck, UserImportDto> {
/**
* 需要填写设备类型的单位类型(字符串汉字数据库如此)及人员类型
*/
private static final Map<String, List<String>> NEED_EQUIP_TYPE_UNIT_TYPE = new HashMap<>();
static {
// ("安全总监", "6547");
// ("安全员", "6549");
// ("质量安全总监", "6550");
// ("质量安全员", "6551");
NEED_EQUIP_TYPE_UNIT_TYPE.put("使用单位", Arrays.asList("6547", "6549"));
NEED_EQUIP_TYPE_UNIT_TYPE.put("安装改造维修单位", Arrays.asList("6550", "6551"));
}
@Override
public boolean isValid(UserImportDto userImportDto, ConstraintValidatorContext context) {
if (NEED_EQUIP_TYPE_UNIT_TYPE.containsKey(userImportDto.getUnitType())) {
List<String> postTypes = NEED_EQUIP_TYPE_UNIT_TYPE.get(userImportDto.getUnitType());
// 单位类型是指定的且设备类型未空时校验不通过
return !postTypes.contains(userImportDto.getPost()) || !StringUtils.isEmpty(userImportDto.getEquipType());
} else {
return true;
}
}
}
package com.yeejoin.amos.boot.module.tcm.api.dto;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.yeejoin.amos.boot.module.tcm.api.converter.*;
import com.yeejoin.amos.boot.module.tcm.api.customer.CustomerEquipTypeCheck;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
@Data
public class UserImportDto {
@NotBlank(message = "单位名称不能为空")
@ExcelProperty(value = "单位名称")
private String unitName;
@NotBlank(message = "单位统一信用代码不能为空")
@ExcelProperty(value = "单位统一信用代码")
private String unitCode;
@NotBlank(message = "单位类型不能为空")
@ExcelProperty(value = "单位类型")
private String unitType;
@NotBlank(message = "姓名不能为空")
@ExcelProperty(value = "姓名")
private String name;
@NotBlank(message = "联系电话不能为空")
@ExcelProperty(value = "联系电话")
private String phone;
@NotBlank(message = "证件类型不能为空")
@ExcelProperty(value = "证件类型", converter = CertificateTypeConverter.class)
private String certificateType;
@NotBlank(message = "证件编号不能为空")
@ExcelProperty(value = "证件编号")
private String certificateNum;
@NotBlank(message = "人员类型不能为空")
@ExcelProperty(value = "人员类型", converter = PostTypeConverter.class)
private String post;
@CustomerEquipTypeCheck(message = "设备类型不能为空")
@ExcelProperty(value = "设备类型", converter = EquipTypeConverter.class)
private String equipType;
@ExcelProperty(value = "性别", converter = GenderConverter.class)
private String gender;
@ExcelProperty(value = "出生日期")
@DateTimeFormat("yyyy-MM-dd")
private Date birthday;
@ExcelProperty(value = "学历", converter = EducationConverter.class)
private String education;
@ExcelProperty(value = "住址")
private String address;
@ExcelProperty(value = "邮箱")
private String email;
@ExcelProperty(value = "职称")
private String jobTitle;
@ExcelProperty(value = "专业")
private String speciality;
/**
* 存放单位类型:List人员类型的对象
*/
@ExcelIgnore
private Map<String, Set<String>> unitTypePostMap;
@ExcelProperty
private Long seq;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserImportDto that = (UserImportDto) o;
return Objects.equals(phone, that.phone);
}
@Override
public int hashCode() {
return Objects.hash(phone);
}
}
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tcm.api.dto.EquEnterDto; import com.yeejoin.amos.boot.module.tcm.api.dto.EquEnterDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.TzBaseEnterpriseInfoDto; import com.yeejoin.amos.boot.module.tcm.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo; import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -43,6 +44,9 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -43,6 +44,9 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
TzBaseEnterpriseInfo selectByUseUnit(String useUnit); TzBaseEnterpriseInfo selectByUseUnit(String useUnit);
CompanyModel getOneByCompanyCode(String companyCode);
IPage<TzBaseEnterpriseInfoDto> page(Page<TzBaseEnterpriseInfoDto> page, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto); IPage<TzBaseEnterpriseInfoDto> page(Page<TzBaseEnterpriseInfoDto> page, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto);
IPage<TzBaseEnterpriseInfoDto> pageList(Page<TzBaseEnterpriseInfoDto> page, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto, List orgCodeList); IPage<TzBaseEnterpriseInfoDto> pageList(Page<TzBaseEnterpriseInfoDto> page, TzBaseEnterpriseInfoDto tzBaseEnterpriseInfoDto, List orgCodeList);
......
...@@ -9,6 +9,8 @@ import com.yeejoin.amos.boot.module.tcm.api.dto.TzsEquipListDto; ...@@ -9,6 +9,8 @@ import com.yeejoin.amos.boot.module.tcm.api.dto.TzsEquipListDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.TzsUserInfoDto; import com.yeejoin.amos.boot.module.tcm.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserInfo; import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserQualifications; import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserQualifications;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
...@@ -62,4 +64,11 @@ public interface ITzsUserInfoService extends IService<TzsUserInfo> { ...@@ -62,4 +64,11 @@ public interface ITzsUserInfoService extends IService<TzsUserInfo> {
TzIndividualityDto updateIndividualityInfo(TzIndividualityDto individualityDto); TzIndividualityDto updateIndividualityInfo(TzIndividualityDto individualityDto);
void userInfoExport(HttpServletResponse response, List<String> ids); void userInfoExport(HttpServletResponse response, List<String> ids);
/**
* 批量导入人员
* @param file 导入的文件
* @return 失败时返回失败信息,提供时返回success
*/
ResponseModel<?> importUserBatch(MultipartFile file);
} }
...@@ -175,5 +175,8 @@ ...@@ -175,5 +175,8 @@
<select id="getProblemInfoBySourceId" resultType="java.util.Map"> <select id="getProblemInfoBySourceId" resultType="java.util.Map">
select * from tzs_safety_problem_tracing where source_id = #{sourceId} order by rec_date desc limit 1 select * from tzs_safety_problem_tracing where source_id = #{sourceId} order by rec_date desc limit 1
</select> </select>
<select id="getOneByCompanyCode" resultType="com.yeejoin.amos.feign.privilege.model.CompanyModel">
select sequence_nbr, org_code, company_code, company_name, company_type from privilege_company where company_code = #{companyCode} and is_deleted = false limit 1
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.tcm.biz.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
@Configuration
public class ValidationConfig {
@Bean
public Validator validator() {
ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
return validatorFactory.getValidator();
}
}
...@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -36,6 +37,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -36,6 +37,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.*; import java.util.*;
...@@ -351,4 +353,11 @@ public class TzsUserInfoController extends BaseController { ...@@ -351,4 +353,11 @@ public class TzsUserInfoController extends BaseController {
List<JGUserInfoVo> exportData = JSON.parseArray(JSON.toJSONString(userPermissionDtos.getRecords()), JGUserInfoVo.class); List<JGUserInfoVo> exportData = JSON.parseArray(JSON.toJSONString(userPermissionDtos.getRecords()), JGUserInfoVo.class);
ExcelUtil.createTemplate(response, "人员列表数据", "人员列表", exportData, JGUserInfoVo.class, null, false); ExcelUtil.createTemplate(response, "人员列表数据", "人员列表", exportData, JGUserInfoVo.class, null, false);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/import")
@ApiOperation(value = "人员导入",httpMethod = "POST")
public ResponseModel<?> importUser(@RequestBody MultipartFile file) {
return tzsUserInfoService.importUserBatch(file);
}
} }
...@@ -141,9 +141,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -141,9 +141,6 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Autowired @Autowired
TzsBaseInstitutionMapper tzsBaseInstitutionMapper; TzsBaseInstitutionMapper tzsBaseInstitutionMapper;
@Autowired
TzsUserInfoServiceImpl tzsUserInfoService;
private final Logger logger = LogManager.getLogger(RegUnitInfoServiceImpl.class); private final Logger logger = LogManager.getLogger(RegUnitInfoServiceImpl.class);
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment