Commit a19bf30b authored by 刘林's avatar 刘林

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents aa2cf5f1 d59e8ca3
package com.yeejoin.amos.boot.module.tcm.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.tcm.api.entity.BaseUnitLicence;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.BaseUnitLicenceServiceImpl;
import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.RegUnitInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@Api(tags = "临时api")
@RequestMapping(value = "/temporary")
public class TemporaryController extends BaseController {
@Autowired
RegUnitInfoServiceImpl regUnitInfoService;
@Autowired
BaseUnitLicenceServiceImpl baseUnitLicenceService;
/**
* 刷新许可信息表中的发证机关code
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "刷新许可信息表中的发证机关code", notes = "刷新许可信息表中的发证机关code")
@GetMapping(value = "/brushData")
public ResponseModel<String> brushData() {
Map<?, ?> dictOfDJJGMap = regUnitInfoService.dictOfDJJG();
// 许可信息
List<BaseUnitLicence> unitLicences = baseUnitLicenceService.list(new LambdaQueryWrapper<BaseUnitLicence>().isNull(BaseUnitLicence::getApprovedOrganCode));
List<BaseUnitLicence> updatedLicenses = unitLicences.stream().peek(licence -> {
String approvedOrgan = licence.getApprovedOrgan();
String approvedOrganCode = (String) dictOfDJJGMap.getOrDefault(approvedOrgan, null);
licence.setApprovedOrganCode(approvedOrganCode);
}).collect(Collectors.toList());
baseUnitLicenceService.saveOrUpdateBatch(updatedLicenses);
return ResponseHelper.buildResponse("ok");
}
}
......@@ -21,8 +21,10 @@ import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -118,22 +120,26 @@ public class TzsBaseInstitutionServiceImpl extends BaseService<TzsBaseInstitutio
if (!ObjectUtils.isEmpty(regUnitInfo.getAdminTel())){
regUnitInfo.setContactPersonTel(regUnitInfo.getAdminTel());
}
if(!ValidationUtil.isEmpty(dto.getUnitLicences())){
//添加不在字典中的登记机关
regUnitInfoService.addNotInDJJGDictionary(dto.getUnitLicences());
}
regUnitInfoService.save(regUnitInfo);
// 3.插入单位注册许可信息表:tz_base_unit_licence
Map<?, ?> dictOfDJJGMap = regUnitInfoService.dictOfDJJG();
List<BaseUnitLicence> baseUnitLicences = dto.getUnitLicences().stream().map(s -> {
s.setUnitCode(dto.getUnitCode());
s.setUnitName(dto.getName());
BaseUnitLicence target = new BaseUnitLicence();
Bean.copyExistPropertis(s, target);
target.setApprovedOrganCode((String) dictOfDJJGMap.get(target.getApprovedOrgan()));
return target;
}).collect(Collectors.toList());
if (!baseUnitLicences.isEmpty()) {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences);
//添加不在字典中的登记机关
regUnitInfoService.addNotInDJJGDictionary(baseUnitLicences);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
log.error("awds:"+e.getMessage(), e);
try {
// 失败后回滚:删除已经创建的企业信息
if (StringUtils.isNotEmpty(dto.getAmosCompanySeq())) {
......
......@@ -185,24 +185,28 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
this.createCompanyAndUser(regUnitInfo);
// 2.异步调用ugp,同步公司数据
FutureTask<ResponseModel<Boolean>> future = getResponseModelFutureTask(model);
//添加不在字典中的登记机关
if (!ValidationUtil.isEmpty(model.getUnitLicences())){
this.addNotInDJJGDictionary(model.getUnitLicences());
}
// 3.插入单位注册许可信息表:tz_base_unit_licence
// 3.1先删除已有许可信息 (2024-04-02放开企业许可信息编辑功能)
LambdaQueryWrapper<BaseUnitLicence> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BaseUnitLicence::getUnitCode, model.getUnitCode());
baseUnitLicenceService.remove(queryWrapper);
// 3.2再插入新许可信息
Map<?, ?> dictOfDJJGMap = this.dictOfDJJG();
List<BaseUnitLicence> baseUnitLicences = model.getUnitLicences().stream().map(s -> {
s.setUnitCode(model.getUnitCode());
s.setUnitName(model.getName());
BaseUnitLicence target = new BaseUnitLicence();
Bean.copyExistPropertis(s, target);
target.setSequenceNbr(null);
target.setApprovedOrganCode((String) dictOfDJJGMap.get(target.getApprovedOrgan()));
return target;
}).collect(Collectors.toList());
if (!baseUnitLicences.isEmpty()) {
baseUnitLicenceService.saveOrUpdateBatch(baseUnitLicences);
//添加不在字典中的登记机关
this.addNotInDJJGDictionary(baseUnitLicences);
}
// 4.插入工商单位信息表:tz_flc_reg_unit_ic
RegUnitIc regUnitIc = new RegUnitIc();
......@@ -262,12 +266,26 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
/**
* 获取登记机关的map
* @return map:key-》机关名称 value-》机关code
*/
public Map<?, ?> dictOfDJJG() {
List<DataDictionary> allDictionaryList = this.initAllDataDictionaryList();
return allDictionaryList.stream()
.filter(d -> DICT_TYPE_DJJG.equals(d.getType()))
.collect(Collectors.toMap(
DataDictionary::getName,
DataDictionary::getCode,
(code1, code2) -> code1));
}
/**
* 添加不在字典中的登记机关
* @param baseUnitLicences baseUnitLicences
*/
public void addNotInDJJGDictionary(List<BaseUnitLicence> baseUnitLicences) {
public void addNotInDJJGDictionary(List<BaseUnitLicenceDto> baseUnitLicences) {
List<String> approvedOrganList = baseUnitLicences.stream()
.map(BaseUnitLicence::getApprovedOrgan)
.map(BaseUnitLicenceDto::getApprovedOrgan)
.distinct()
.collect(Collectors.toList());
List<DataDictionary> allDictionaryList = this.initAllDataDictionaryList();
......
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