Commit 8851fb12 authored by hcing's avatar hcing

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

parents 730b54dc cbd47b6d
......@@ -18,4 +18,6 @@ public class TZSCommonConstant {
public static final String CITY = "CITY";
public static final String REGION = "REGION";
public static final String STREET = "STREET";
public static final String PLATFORM_FEIGN_RESULT_KEY_COMPANY = "compnay";
}
......@@ -60,7 +60,7 @@
</if>
<if test="type == 'supervision'">
AND tjcr.instance_id <![CDATA[<>]]> ''
AND tjcr.receive_company_code = #{companyCode}
AND tjcr.receive_org_code = #{companyCode}
</if>
<if test="type == 'enterprise'">
AND tjcr.use_unit_code = #{dto.useUnitCode}
......
......@@ -135,7 +135,7 @@
AND (isn.receive_company_code = #{companyCode} or isn.transfer_to_user_ids like concat('%',#{userId},'%'))
</if>
<if test="type == 'company'">
AND (isn.install_unit_credit_code = #{param.useUnitCreditCode} or isn.transfer_to_user_ids like
AND (isn.install_unit_credit_code = #{companyCode} or isn.transfer_to_user_ids like
concat('%',#{userId},'%'))
</if>
<if test="orgCode != null and orgCode != ''">
......
......@@ -97,19 +97,19 @@
</foreach>
</if>
<if test="type == 'supervision'">
AND (tjtn.receive_company_code = #{orgCode} or tjtn.transfer_to_user_ids like
AND (tjtn.receive_company_code = #{companyCode} or tjtn.transfer_to_user_ids like
concat('%',#{param.transferToUserIds},'%'))
AND tjtn.instance_id <![CDATA[<>]]> ''
</if>
<if test="type == 'company'">
AND (tjtn.install_unit_credit_code = #{orgCode} or tjtn.transfer_to_user_ids like
AND (tjtn.install_unit_credit_code = #{companyCode} or tjtn.transfer_to_user_ids like
concat('%',#{param.transferToUserIds},'%'))
</if>
<if test="type == 'testAdmin'">
((AND tjtn.receive_company_code = #{orgCode}
((AND tjtn.receive_company_code = #{companyCode}
AND tjtn.instance_id <![CDATA[<>]]> '')
or
AND tjtn.install_unit_credit_code = #{orgCode})
AND tjtn.install_unit_credit_code = #{companyCode})
</if>
<if test="orgCode != null and orgCode != ''">
AND tjtn.instance_id <![CDATA[<>]]> ''
......
......@@ -17,11 +17,11 @@ public enum OpenBizTypeEnum {
JY("jy","检验业务"),
JC("jc","检测业务");
private String code;
private final String code;
private String name;
private final String name;
private OpenBizTypeEnum(String code,String name){
OpenBizTypeEnum(String code, String name){
this.code = code;
this.name = name;
}
......
......@@ -159,7 +159,7 @@ public class JyjcOpeningApplicationController extends BaseController {
Page<JyjcOpeningApplication> page = new Page<JyjcOpeningApplication>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(jyjcOpeningApplicationServiceImpl.queryForJyjcOpeningApplicationPage(page, jyjcOpeningApplicationRequstDto,client));
return ResponseHelper.buildResponse(jyjcOpeningApplicationServiceImpl.queryForJyjcOpeningApplicationPage(page, jyjcOpeningApplicationRequstDto, client));
}
/**
......@@ -183,8 +183,8 @@ public class JyjcOpeningApplicationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "POST", value = "流程节点执行", notes = "流程节点执行")
@PostMapping(value = "/execueFlow")
public ResponseModel<HashMap<String, String>> executeFlow(@RequestBody Map<String, Object> params) {
jyjcOpeningApplicationServiceImpl.executeFlow(params);
public ResponseModel<Map<String, String>> executeFlow(@RequestBody Map<String, Object> params) {
jyjcOpeningApplicationServiceImpl.executedFlow(params);
HashMap<String, String> result = new HashMap<>();
result.put("result", "success");
return ResponseHelper.buildResponse(result);
......
......@@ -19,7 +19,6 @@ import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionHistory;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultAttachment;
import com.yeejoin.amos.boot.module.jyjc.api.enums.OpenBizTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.PersonTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcBaseMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.InstanceRuntimeData;
......@@ -140,11 +139,15 @@ public class CommonServiceImpl {
userInfoQueryWrapper.and(w -> w.like(TzsUserInfo::getPost, jyUserPost).or().like(TzsUserInfo::getPost, jcUserPost).or().like(TzsUserInfo::getPost, chargeUserPost));
return;
}
if (personType.equals(OpenBizTypeEnum.JY.getCode())) {
if (personType.contains(PersonTypeEnum.jc.name()) && personType.contains(PersonTypeEnum.jy.name())) {
userInfoQueryWrapper.and(w -> w.like(TzsUserInfo::getPost, jyUserPost).or().like(TzsUserInfo::getPost, jcUserPost));
return;
}
if (personType.equals(PersonTypeEnum.jy.name())) {
userInfoQueryWrapper.like(TzsUserInfo::getPost, jyUserPost);
return;
}
if (personType.equals(OpenBizTypeEnum.JC.getCode())) {
if (personType.equals(PersonTypeEnum.jc.name())) {
userInfoQueryWrapper.like(TzsUserInfo::getPost, jcUserPost);
}
}
......
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplication;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplicationEquip;
import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionPlanModel;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Administrator
......@@ -25,21 +26,24 @@ import java.util.Optional;
@Service
public class InspectionPlanServiceImpl {
private JyjcInspectionApplicationServiceImpl inspectionApplicationService;
private final IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
private JyjcInspectionApplicationEquipServiceImpl applicationEquipService;
private final JyjcInspectionApplicationServiceImpl inspectionApplicationService;
private JyjcInspectionResultServiceImpl inspectionResultService;
private final JyjcInspectionApplicationEquipServiceImpl applicationEquipService;
private ESEquipmentCategory esEquipmentCategory;
private final JyjcInspectionResultServiceImpl inspectionResultService;
private final ESEquipmentCategory esEquipmentCategory;
public InspectionPlanServiceImpl(JyjcInspectionApplicationServiceImpl inspectionApplicationService,
JyjcInspectionApplicationEquipServiceImpl applicationEquipService,
JyjcInspectionResultServiceImpl inspectionResultService, ESEquipmentCategory esEquipmentCategory) {
JyjcInspectionResultServiceImpl inspectionResultService, ESEquipmentCategory esEquipmentCategory, IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper) {
this.inspectionApplicationService = inspectionApplicationService;
this.applicationEquipService = applicationEquipService;
this.inspectionResultService = inspectionResultService;
this.esEquipmentCategory = esEquipmentCategory;
this.idxBizJgProjectContraptionMapper = idxBizJgProjectContraptionMapper;
}
......@@ -66,33 +70,34 @@ public class InspectionPlanServiceImpl {
JSONObject jsonObject = inspectionApplication.getPlanData();
if (jsonObject == null) {
jsonObject = new JSONObject();
String address = this.getOneEquipAddress(applicationSeq);
String address = this.getOneEquipAddress(inspectionApplication);
jsonObject.put("address", address);
}
return jsonObject;
}
private String getOneEquipAddress(String applicationSeq) {
// 查询报检的设备,返回地址,目前是单台报检,applicationEquips长度只有1,后续会多个
List<JyjcInspectionApplicationEquip> applicationEquips = applicationEquipService.list(new LambdaQueryWrapper<JyjcInspectionApplicationEquip>().eq(JyjcInspectionApplicationEquip::getApplicationSeq, applicationSeq));
// 拼接地址
List<String> allAddress = new ArrayList<>();
applicationEquips.forEach(e -> {
String record = e.getEquipUnicode();
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
allAddress.add(this.concatDetailAddress(esEquipmentCategoryDto));
private String getOneEquipAddress(JyjcInspectionApplication application) {
// 压力管道取装置使用/安装地址
if (EquipmentClassifityEnum.YLGD.getCode().equals(application.getEquipClassify())) {
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionMapper.selectById(application.getProjectContraptionId());
return Stream.of(projectContraption.getProvinceName(), projectContraption.getCityName(), projectContraption.getCountyName(), projectContraption.getStreetName(), projectContraption.getAddress())
.map(value -> value == null ? "" : value)
.collect(Collectors.joining());
} else {
// 其他取第一个设备使用/安装地址
List<JyjcInspectionApplicationEquip> applicationEquips = applicationEquipService.list(new LambdaQueryWrapper<JyjcInspectionApplicationEquip>().eq(JyjcInspectionApplicationEquip::getApplicationSeq, application.getSequenceNbr()));
if (!applicationEquips.isEmpty()) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(applicationEquips.get(0).getEquipUnicode());
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
return this.concatDetailAddress(esEquipmentCategoryDto);
}
}
});
return String.join(",", allAddress);
return "";
}
}
private String concatDetailAddress(ESEquipmentCategoryDto esEquipmentCategoryDto) {
// 省、市、区
String usePlace = esEquipmentCategoryDto.getUSE_PLACE();
// 详细地址
String address = esEquipmentCategoryDto.getADDRESS();
return String.format("%s%s", usePlace, address);
return Stream.of(esEquipmentCategoryDto.getUSE_PLACE(), esEquipmentCategoryDto.getADDRESS()).map(a -> a == null ? "" : a.replace("/", "").trim()).collect(Collectors.joining());
}
}
......@@ -813,7 +813,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
queryWrapper.eq(JyjcOpeningApplication::getUnitCode, applicationModel.getInspectionUnitCode());
queryWrapper.eq(JyjcOpeningApplication::getStatus, FlowStatusEnum.TO_BE_FINISHED.getName());
queryWrapper.select(JyjcOpeningApplication::getResultType, BaseEntity::getSequenceNbr);
queryWrapper.orderByDesc(JyjcOpeningApplication::getAcceptDate);
queryWrapper.orderByDesc(JyjcOpeningApplication::getRecDate);
queryWrapper.last("limit 1");
List<JyjcOpeningApplication> applicationList = jyjcOpeningApplicationService.list(queryWrapper);
if (!applicationList.isEmpty()) {
......
......@@ -59,7 +59,6 @@ import com.yeejoin.amos.boot.module.ymt.api.vo.TzsUserInfoVo;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
......@@ -309,7 +308,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
public JyjcOpeningApplicationModel resubmit(JyjcOpeningApplicationModel model) {
model.setStatus(FlowStatusEnum.TO_BE_PROCESSED.getCode() + "");
model = this.updateWithModel(model);
executeFlow(MapBuilder.<String, Object>create()
executedFlow(MapBuilder.<String, Object>create()
.put("op", "0")
.put("instanceId", model.getWorkflowProstanceId())
.put("comments", "")
......@@ -345,11 +344,13 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
// 将历史同单位类型+同机构类别的开通申请作废掉
for (Long id : ids) {
JyjcInspectionHistory historyOpened = inspectionHistoryService.getBySSeq(id);
JSONObject hisDataOpened = historyOpened.getHistoryData();
List<BaseEnterpriseCertDto> certOpened = hisDataOpened.getJSONArray(BizCommonConstant.UNIT_LICENCE_KEY).toJavaList(BaseEnterpriseCertDto.class);
boolean matchHisOpened = certOpened.stream().anyMatch(c -> agencyTypeLast.contains(c.getAgencyType()));
if (matchHisOpened) {
filterIds.add(id);
if(historyOpened != null){
JSONObject hisDataOpened = historyOpened.getHistoryData();
List<BaseEnterpriseCertDto> certOpened = hisDataOpened.getJSONArray(BizCommonConstant.UNIT_LICENCE_KEY).toJavaList(BaseEnterpriseCertDto.class);
boolean matchHisOpened = certOpened.stream().anyMatch(c -> agencyTypeLast.contains(c.getAgencyType()));
if (matchHisOpened) {
filterIds.add(id);
}
}
}
if (!filterIds.isEmpty()) {
......@@ -758,7 +759,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
*/
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public JyjcOpeningApplication executeFlow(Map<String, Object> params) {
public void executedFlow(Map<String, Object> params) {
String instanceId = params.get("instanceId").toString();
String nextTaskId = params.get("nextTaskId").toString();
String lockKey = CommonServiceImpl.buildJcExecuteLockKey(instanceId);
......@@ -808,6 +809,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
jyjcOpeningApplication.setExpiryDate(DateUtil.parseDate(params.get("expiryDate").toString()));
jyjcOpeningApplication.setAgencyClassify(params.get("agencyClassify").toString());
jyjcOpeningApplication.setPromoter(RequestContext.getExeUserId());
jyjcOpeningApplication.setResultType(Optional.ofNullable(params.get("resultType")).map(Object::toString).orElse(""));
this.sendMsg2User(jyjcOpeningApplication);
// 更新json
commonService.saveOrUpdateHistory(jyjcOpeningApplication.getOpenBizType(), JSONObject.parseObject(JSONObject.toJSONString(params)), jyjcOpeningApplication.getSequenceNbr());
......@@ -844,6 +846,7 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
jyjcOpeningApplication.setNextExecuteUserIds("");
jyjcOpeningApplication.setExpiryDate(DateUtil.parseDate(params.get("expiryDate").toString()));
jyjcOpeningApplication.setAgencyClassify(params.get("agencyClassify").toString());
jyjcOpeningApplication.setResultType(Optional.ofNullable(params.get("resultType")).map(Object::toString).orElse(""));
// 更新json
commonService.saveOrUpdateHistory(jyjcOpeningApplication.getOpenBizType(), JSONObject.parseObject(JSONObject.toJSONString(params)), jyjcOpeningApplication.getSequenceNbr());
// 将审批通过的资质信息写入到企业资质表
......@@ -856,7 +859,6 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
}
// 更新流程中的流程数据
commonService.saveExecuteFlowData2Redis(jyjcOpeningApplication.getWorkflowProstanceId(), this.buildInstanceRuntimeData(jyjcOpeningApplication));
return jyjcOpeningApplication;
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
} finally {
......@@ -864,7 +866,6 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
lock.unlock();
}
}
return null;
}
private void restoreApplicationData(JyjcOpeningApplication jyjcOpeningApplication, Map<String, Object> params) {
......
......@@ -96,5 +96,7 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
List<String> selectCompanyBySupervisionOrgCode(String oldOrgCode);
void updateRedundantSupervisionOrgCode(String newOrgCode, String oldOrgCode);
void updateRedundantSupervisionOrgCodeUnit(String newOrgCode, String oldOrgCode);
void updateRedundantSupervisionOrgCodeStatistics(String newOrgCode, String oldOrgCode);
}
......@@ -263,50 +263,13 @@
where supervise_org_code LIKE CONCAT(#{oldOrgCode}, '%')
</select>
<update id="updateRedundantSupervisionOrgCode">
<update id="updateRedundantSupervisionOrgCodeUnit">
update tz_base_enterprise_info
set supervise_org_code = replace(supervise_org_code, #{oldOrgCode}, #{newOrgCode})
where supervise_org_code like concat(#{oldOrgCode}, '%');
update tz_base_enterprise_info
set org_code = replace(org_code, #{oldOrgCode}, #{newOrgCode})
where org_code like concat(#{oldOrgCode}, '%');
--三项制度因为会定时生成统计数据(刚好在层级调整后生成了统计数据,此时再单位层级树再调整会原有,根据该表的唯一约束会提示更新冲突),所以需要特殊处理(如果目标数据存在则不更新,并删除旧的统计数据)
WITH update_data AS (
SELECT
ctid,
REPLACE(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode}) AS new_code,
plan_type,
check_date
FROM tzs_three_systems
WHERE supervisory_unit_org_code LIKE concat(#{oldOrgCode}, '%')
),
conflicts AS (
SELECT u.ctid
FROM update_data u
JOIN tzs_three_systems t ON
t.supervisory_unit_org_code = u.new_code
AND t.plan_type = u.plan_type
AND t.check_date = u.check_date
),
updated AS (
UPDATE tzs_three_systems t
SET supervisory_unit_org_code = REPLACE(t.supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
FROM update_data u
WHERE t.ctid = u.ctid
AND t.ctid NOT IN (SELECT ctid FROM conflicts)
RETURNING t.ctid
)
DELETE FROM tzs_three_systems
WHERE supervisory_unit_org_code LIKE concat(#{oldOrgCode}, '%')
AND ctid NOT IN (SELECT ctid FROM updated);
update tzs_two_staffing
set supervisory_unit_orgcode = replace(supervisory_unit_orgcode, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_orgcode like concat(#{oldOrgCode}, '%');
update biz_jg_equipment_category_data
set org_branch_code = replace(org_branch_code, #{oldOrgCode}, #{newOrgCode})
where org_branch_code like concat(#{oldOrgCode}, '%');
update tzs_jg_vehicle_information
set org_branch_code = replace(org_branch_code, #{oldOrgCode}, #{newOrgCode})
......@@ -382,22 +345,6 @@
set org_code = replace(org_code, #{oldOrgCode}, #{newOrgCode})
where org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_dispatch_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_maintenance_unit_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_rescue_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_use_unit_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_feedback_suggestions
set supervise_org_code = replace(supervise_org_code, #{oldOrgCode}, #{newOrgCode})
where supervise_org_code like concat(#{oldOrgCode}, '%');
......@@ -409,4 +356,68 @@
set risk_disposal_unit_org_code = replace(risk_disposal_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where risk_disposal_unit_org_code like concat(#{oldOrgCode}, '%');
</update>
<update id="updateRedundantSupervisionOrgCodeStatistics">
--三项制度因为会定时生成统计数据(刚好在层级调整后生成了统计数据,此时再单位层级树再调整会原有,根据该表的唯一约束会提示更新冲突),所以需要特殊处理(如果目标数据存在则不更新,并删除旧的统计数据)
WITH potential_updates AS (
SELECT
ctid,
supervisory_unit_org_code AS old_code,
REPLACE(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode}) AS new_code,
plan_type,
check_date
FROM tzs_three_systems
WHERE supervisory_unit_org_code LIKE concat (#{oldOrgCode}, '%' )
),
conflict_check AS (
SELECT
pu.*,
EXISTS (
SELECT 1 FROM tzs_three_systems t
WHERE t.supervisory_unit_org_code = pu.new_code
AND t.plan_type = pu.plan_type
AND t.check_date = pu.check_date
) AS has_conflict
FROM potential_updates pu
),
updated AS (
UPDATE tzs_three_systems t
SET supervisory_unit_org_code = cc.new_code
FROM conflict_check cc
WHERE t.ctid = cc.ctid
AND NOT cc.has_conflict
RETURNING t.ctid, cc.old_code
)
DELETE FROM tzs_three_systems t
WHERE EXISTS (
SELECT 1 FROM conflict_check cc
WHERE cc.ctid = t.ctid
AND cc.has_conflict
AND t.supervisory_unit_org_code = cc.old_code
);
update tzs_two_staffing
set supervisory_unit_orgcode = replace(supervisory_unit_orgcode, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_orgcode like concat(#{oldOrgCode}, '%');
update biz_jg_equipment_category_data
set org_branch_code = replace(org_branch_code, #{oldOrgCode}, #{newOrgCode})
where org_branch_code like concat(#{oldOrgCode}, '%');
update tzs_alert_dispatch_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_maintenance_unit_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_rescue_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
update tzs_alert_use_unit_statistics
set supervisory_unit_org_code = replace(supervisory_unit_org_code, #{oldOrgCode}, #{newOrgCode})
where supervisory_unit_org_code like concat(#{oldOrgCode}, '%');
</update>
</mapper>
......@@ -3,15 +3,15 @@ package com.yeejoin.amos.boot.module.tcm.biz.controller;
import com.yeejoin.amos.boot.module.tcm.biz.service.impl.HistoryDataDealServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
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;
/**
* @author Administrator
*/
......@@ -47,11 +47,12 @@ public class HistoryDataDealController {
return ResponseHelper.buildResponse(historyDataDealService.unitOrgCodeUpdate(oldOrgCode, newOrgCode));
}
@Deprecated
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/handleCompanyHisOrgCode")
@ApiOperation(httpMethod = "PUT", value = "监管单位层级调整后,业务表(企业、设备、统计等)冗余的所有旧orgCode替换为新orgCode", notes = "监管单位层级调整后,业务表(企业、设备、统计等)冗余的所有旧orgCode替换为新orgCode")
public ResponseModel<String> handleCompanyHisOrgCode(@RequestParam String newOrgCode, @RequestParam String oldOrgCode) {
return ResponseHelper.buildResponse(historyDataDealService.handleCompanyHisOrgCode(newOrgCode, oldOrgCode));
@PostMapping(value = "/handleCompanyHisOrgCode")
@ApiOperation(httpMethod = "PUT", value = "监管单位层级调整后,业务表(企业、设备、统计等)冗余的所有旧orgCode替换为新orgCode,不更新平台表", notes = "监管单位层级调整后,业务表(企业、设备、统计等)冗余的所有旧orgCode替换为新orgCode,不更新平台表")
public ResponseModel<String> handleCompanyHisOrgCode(@RequestBody List<Map<String, Object>> orgCodeMap) {
return ResponseHelper.buildResponse(historyDataDealService.handleCompanyHisOrgCode(orgCodeMap));
}
}
......@@ -14,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
......@@ -79,7 +78,6 @@ public class PlatformUserTopicMessage extends EmqxListener {
log.info("平台推送消息同步完成");
}
@Async
protected void processOrgCodeUpdateMessage(MqttMessage message) {
try {
if (ValidationUtil.isEmpty(message)) {
......@@ -95,7 +93,6 @@ public class PlatformUserTopicMessage extends EmqxListener {
}
}
@Async
protected void processOpMessage(MqttMessage message) {
try {
if (ValidationUtil.isEmpty(message)) {
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.api.constant.TZSCommonConstant;
import com.yeejoin.amos.boot.module.common.api.entity.TzsUserPermission;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.boot.module.tcm.api.entity.TzsUserInfo;
......@@ -14,11 +15,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.*;
/**
* @author Administrator
......@@ -135,8 +134,23 @@ public class HistoryDataDealServiceImpl {
* @return
*/
@Transactional(rollbackFor = Exception.class)
public String handleCompanyHisOrgCode(String newOrgCode, String oldOrgCode) {
baseEnterpriseInfoService.refreshCompanyOrgCode(null, newOrgCode, oldOrgCode);
public String handleCompanyHisOrgCode(List<Map<String, Object>> orgCodeMap) {
log.info("用企业新orgCode替换各个表缓存orgCode开始");
if (ValidationUtil.isEmpty(orgCodeMap)) {
return "error";
}
orgCodeMap.forEach(map -> {
String newOrgCode = map.get("newOrgCode").toString();
String oldOrgCode = map.get("oldOrgCode").toString();
//1. 处理平台旧orgCode本身错误数据
@SuppressWarnings("unchecked")
HashMap<String, Object> platformCompanyInfo = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(oldOrgCode).getResult();
CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(platformCompanyInfo.get(TZSCommonConstant.PLATFORM_FEIGN_RESULT_KEY_COMPANY)), CompanyModel.class);
parentModel.setOrgCode(newOrgCode);
Privilege.companyClient.update(parentModel, parentModel.getSequenceNbr());
//2. 处理业务表旧orgCode错误数据
baseEnterpriseInfoService.refreshCompanyOrgCode(null, newOrgCode, oldOrgCode);
});
return "success";
}
}
......@@ -53,6 +53,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -1393,6 +1394,7 @@ public class TzBaseEnterpriseInfoServiceImpl
* @date 2025/7/3 14:03
*/
@Override
@Async
public void refreshCompanyInfo(JSONObject dataResult, String method) {
try {
CompanyBo companyBo = JSON.parseObject(dataResult.toJSONString(), CompanyBo.class);
......@@ -1443,6 +1445,7 @@ public class TzBaseEnterpriseInfoServiceImpl
*/
@Override
@Transactional
@Async
public void refreshCompanyOrgCode(JSONObject dataResult, String newOrgCode, String oldOrgCode) {
try {
if (!ValidationUtil.isEmpty(newOrgCode) && !ValidationUtil.isEmpty(oldOrgCode) && !newOrgCode.equals(oldOrgCode)) {
......@@ -1450,8 +1453,10 @@ public class TzBaseEnterpriseInfoServiceImpl
List<String> companySeqList = tzBaseEnterpriseInfoMapper.selectCompanyBySupervisionOrgCode(oldOrgCode);
// 2. 查询旧属地监管部门orgCode对应的所有设备
List<String> equipmentRecordList = tzBaseEnterpriseInfoMapper.selectEquipmentBySupervisionOrgCode(oldOrgCode);
// 3. 更新其他业务表冗余的监管单位orgCode
tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCode(newOrgCode, oldOrgCode);
// 3. 3.1 更新单位及业务表的监管单位orgCode
tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCodeUnit(newOrgCode, oldOrgCode);
// 3.2 更新业务表统计表冗余的监管单位orgCode
tzBaseEnterpriseInfoMapper.updateRedundantSupervisionOrgCodeStatistics(newOrgCode, oldOrgCode);
// 4. 发送数据刷新事件 - 内存分页处理
// 处理企业数据
publishDataRefreshEvents(companySeqList, DataRefreshEvent.DataType.enterprise, 1000);
......
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