Commit c9ddd67b authored by tianyiming's avatar tianyiming

单位注册校验修改

parent 2f8e3a67
......@@ -32,7 +32,7 @@ public interface IRegUnitInfoService {
* @param unitType 单位类型
* @return RegUnitInfoDto
*/
RegUnitInfoDto unitCheck(String unitCode, String unitType, String companyName);
RegUnitInfoDto unitCheck(String unitCode, String unitType, String companyName,String registerType, String cardType);
/**
* 单位类型列表字典
......
......@@ -115,12 +115,14 @@ public class RegUnitInfoController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "单位注册校验", notes = "单位注册校验")
public ResponseModel<RegUnitInfoDto> unitCheck(@PathVariable String unitCode,
@RequestParam String unitType,
@RequestParam String registerType,
@RequestParam(required = false) String cardType,
@RequestParam(required = false) String companyName) {
if (ValidationUtil.isEmpty(unitCode)) {
throw new BadRequest("单位编码不能为空");
throw new BadRequest("注册编码不能为空");
}
try {
RegUnitInfoDto regUnitInfoDto = iRegUnitInfoService.unitCheck(unitCode, unitType, companyName);
RegUnitInfoDto regUnitInfoDto = iRegUnitInfoService.unitCheck(unitCode, unitType, companyName,registerType,cardType);
return ResponseHelper.buildResponse(regUnitInfoDto);
} catch (Exception e) {
ResponseModel<RegUnitInfoDto> response = new ResponseModel<>();
......
......@@ -347,23 +347,22 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
@Override
public RegUnitInfoDto unitCheck(String unitCode, String unitType,String companyName) {
public RegUnitInfoDto unitCheck(String unitCode, String unitType,String companyName,String registerType, String cardType) {
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
startPlatformTokenService.getToken();
if (!ValidationUtil.isEmpty(companyName)) {
FeignClientResult<CompanyModel> result =Privilege.companyClient.queryByCompanyName(companyName);
if(result.getResult()!=null)
{
throw new BadRequest("重复的公司名称");
// if (!ValidationUtil.isEmpty(companyName)) {
// FeignClientResult<CompanyModel> result = Privilege.companyClient.queryByCompanyName(companyName);
// if (result.getResult() != null) {
// throw new BadRequest("重复的公司名称");
// }
// }
if (!ValidationUtil.isEmpty(unitCode)) {
unitCode = ObjectUtils.isEmpty(cardType) ? unitCode : cardType + "_" + unitCode;
FeignClientResult<CompanyModel> result = Privilege.companyClient.queryByCompanyCode(unitCode);
if (result.getResult() != null) {
throw new BadRequest("重复的注册编码");
}
}
if (!ValidationUtil.isEmpty(unitCode)) {
FeignClientResult<CompanyModel> result =Privilege.companyClient.queryByCompanyCode(unitCode);
if(result.getResult()!=null)
{
throw new BadRequest("重复的公司编码");
}
}
// 1.校验重复性
// RegUnitInfo regUnitInfo = this
// .getOne(new LambdaQueryWrapper<RegUnitInfo>().eq(RegUnitInfo::getUnitCode, unitCode));
......@@ -371,65 +370,67 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
// throw new RuntimeException("该单位已注册,请联系企业管理员!");
// }
// 2.组织返回数据
//2.1 工商信息查询
Map<String, Object> resultMap = accessFeignService.getData(unitCode).getResult();
if (resultMap == null){
throw new BadRequest("工商信息接口查询失败,请稍后再试!");
}
if (ObjectUtils.isEmpty(resultMap)) {
throw new BadRequest("未查询到企业信息,请核对!");
}
if(!ValidationUtil.isEmpty(resultMap)){
// 2.2 工商信息组装
String area = String.valueOf(resultMap.get("area"));
String city = area.substring(0,area.indexOf("市")+1);
String district = area.substring(city.length());
if("高新区".equals(district)){
district = "雁塔区";
}
regUnitInfoDto.setCity(city);
regUnitInfoDto.setDistrict(district);
regUnitInfoDto.setStree(String.valueOf(resultMap.get("street")));
regUnitInfoDto.setCommunity(String.valueOf(resultMap.get("community")));
regUnitInfoDto.setAddress(String.valueOf(resultMap.get("address")));
regUnitInfoDto.setUnitCode(String.valueOf(resultMap.get("creditCode")));
regUnitInfoDto.setName(String.valueOf(resultMap.get("unitName")));
regUnitInfoDto.setLegalPerson(String.valueOf(resultMap.get("legalPeople")));
String industryName = "";
if(ObjectUtils.isNotEmpty(resultMap.get("industryCode"))){
List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
Optional<DataDictionary> op = dictionaries.stream().filter(d->d.getCode() != null && d.getType() !=null && d.getCode().equals(String.valueOf(resultMap.get("industryCode")))&& "HYXLDM".equals(d.getType())).findFirst();
if(op.isPresent()) {
DataDictionary dataDictionary = op.get();
industryName = dataDictionary.getName();
if(ObjectUtils.isEmpty(registerType)){
//2.1 工商信息查询
Map<String, Object> resultMap = accessFeignService.getData(unitCode).getResult();
if (resultMap == null){
throw new BadRequest("工商信息接口查询失败,请稍后再试!");
}
if (ObjectUtils.isEmpty(resultMap)) {
throw new BadRequest("未查询到企业信息,请核对!");
}
if(!ValidationUtil.isEmpty(resultMap)){
// 2.2 工商信息组装
String area = String.valueOf(resultMap.get("area"));
String city = area.substring(0,area.indexOf("市")+1);
String district = area.substring(city.length());
if("高新区".equals(district)){
district = "雁塔区";
}
regUnitInfoDto.setCity(city);
regUnitInfoDto.setDistrict(district);
regUnitInfoDto.setStree(String.valueOf(resultMap.get("street")));
regUnitInfoDto.setCommunity(String.valueOf(resultMap.get("community")));
regUnitInfoDto.setAddress(String.valueOf(resultMap.get("address")));
regUnitInfoDto.setUnitCode(String.valueOf(resultMap.get("creditCode")));
regUnitInfoDto.setName(String.valueOf(resultMap.get("unitName")));
regUnitInfoDto.setLegalPerson(String.valueOf(resultMap.get("legalPeople")));
String industryName = "";
if(ObjectUtils.isNotEmpty(resultMap.get("industryCode"))){
List<DataDictionary> dictionaries = this.initAllDataDictionaryList();
Optional<DataDictionary> op = dictionaries.stream().filter(d->d.getCode() != null && d.getType() !=null && d.getCode().equals(String.valueOf(resultMap.get("industryCode")))&& "HYXLDM".equals(d.getType())).findFirst();
if(op.isPresent()) {
DataDictionary dataDictionary = op.get();
industryName = dataDictionary.getName();
}
}
}
String approveDate = String.valueOf(resultMap.get("approval_time"));
approveDate = approveDate.contains("年")?approveDate.replace("年","-"):approveDate;
approveDate = approveDate.contains("月")?approveDate.replace("月","-"):approveDate;
approveDate = approveDate.contains("日")?approveDate.replace("日","-"):approveDate;
RegUnitIcDto regUnitIcDto = new RegUnitIcDto();
regUnitIcDto.setUnitCode(regUnitInfoDto.getUnitCode());
try {
regUnitIcDto.setApprovedDate(DateUtils.dateParse(approveDate,"yyyy-MM-dd"));
} catch (ParseException e) {
e.printStackTrace();
}
regUnitIcDto.setUnitName(regUnitInfoDto.getName());
regUnitIcDto.setRegisteredOrgan(String.valueOf(resultMap.get("registration_authority")));
regUnitIcDto.setBusinessState(String.valueOf(resultMap.get("operating_status")));
regUnitIcDto.setProvince("陕西省");
regUnitIcDto.setCity(regUnitInfoDto.getCity());
regUnitIcDto.setDistrict(regUnitInfoDto.getDistrict());
regUnitIcDto.setStree(regUnitInfoDto.getStree());
regUnitIcDto.setCommunity(regUnitInfoDto.getCommunity());
regUnitIcDto.setAddress(regUnitInfoDto.getAddress());
regUnitIcDto.setLegalPerson(regUnitInfoDto.getLegalPerson());
regUnitIcDto.setIndustryName(industryName);
regUnitInfoDto.setRegUnitIc(regUnitIcDto);
} else {
regUnitInfoDto.setRegUnitIc(new RegUnitIcDto());
String approveDate = String.valueOf(resultMap.get("approval_time"));
approveDate = approveDate.contains("年")?approveDate.replace("年","-"):approveDate;
approveDate = approveDate.contains("月")?approveDate.replace("月","-"):approveDate;
approveDate = approveDate.contains("日")?approveDate.replace("日","-"):approveDate;
RegUnitIcDto regUnitIcDto = new RegUnitIcDto();
regUnitIcDto.setUnitCode(regUnitInfoDto.getUnitCode());
try {
regUnitIcDto.setApprovedDate(DateUtils.dateParse(approveDate,"yyyy-MM-dd"));
} catch (ParseException e) {
e.printStackTrace();
}
regUnitIcDto.setUnitName(regUnitInfoDto.getName());
regUnitIcDto.setRegisteredOrgan(String.valueOf(resultMap.get("registration_authority")));
regUnitIcDto.setBusinessState(String.valueOf(resultMap.get("operating_status")));
regUnitIcDto.setProvince("陕西省");
regUnitIcDto.setCity(regUnitInfoDto.getCity());
regUnitIcDto.setDistrict(regUnitInfoDto.getDistrict());
regUnitIcDto.setStree(regUnitInfoDto.getStree());
regUnitIcDto.setCommunity(regUnitInfoDto.getCommunity());
regUnitIcDto.setAddress(regUnitInfoDto.getAddress());
regUnitIcDto.setLegalPerson(regUnitInfoDto.getLegalPerson());
regUnitIcDto.setIndustryName(industryName);
regUnitInfoDto.setRegUnitIc(regUnitIcDto);
} else {
regUnitInfoDto.setRegUnitIc(new RegUnitIcDto());
}
}
// 2.3 许可信息组装
......
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