Commit 20abea74 authored by 刘林's avatar 刘林

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

parents 99b56ab6 fd03e46c
...@@ -113,6 +113,7 @@ public class BaseEnterpriseVideoServiceImpl extends BaseService<BaseEnterpriseVi ...@@ -113,6 +113,7 @@ public class BaseEnterpriseVideoServiceImpl extends BaseService<BaseEnterpriseVi
if (result.get("data") instanceof JSONObject) { if (result.get("data") instanceof JSONObject) {
JSONObject dataObj = (JSONObject) result.get("data"); JSONObject dataObj = (JSONObject) result.get("data");
String cameraUrl = dataObj.getString("url"); String cameraUrl = dataObj.getString("url");
video.setType(param.getString("protocol"));
video.setUrl(cameraUrl); video.setUrl(cameraUrl);
video.setType(param.getString("protocol")); video.setType(param.getString("protocol"));
} }
......
...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jg.api.dto; ...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jg.api.dto;
import lombok.Data; import lombok.Data;
import java.util.Set;
@Data @Data
public class BizRelationDataDto { public class BizRelationDataDto {
...@@ -30,4 +32,9 @@ public class BizRelationDataDto { ...@@ -30,4 +32,9 @@ public class BizRelationDataDto {
* 附件 * 附件
*/ */
private String changeAttachment; private String changeAttachment;
/**
* 变更的设备
*/
private Set<String> records;
} }
package com.yeejoin.amos.boot.module.jg.api.dto; package com.yeejoin.amos.boot.module.jg.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
/** /**
*
*
* @author system_generator * @author system_generator
* @date 2025-04-14 * @date 2025-04-14
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value="JgBizChangeLogDto", description="") @ApiModel(value = "JgBizChangeLogDto", description = "")
public class JgBizChangeLogDto extends BaseDto { public class JgBizChangeLogDto extends BaseDto {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "业务唯一标识") @ApiModelProperty(value = "业务唯一标识")
...@@ -36,4 +33,8 @@ public class JgBizChangeLogDto extends BaseDto { ...@@ -36,4 +33,8 @@ public class JgBizChangeLogDto extends BaseDto {
@ApiModelProperty(value = "变更附件") @ApiModelProperty(value = "变更附件")
private String changeAttachment; private String changeAttachment;
@ApiModelProperty(value = "触发的id(列入使用登记变化后,安装告知数据也变化,则记录两条:使用登记的oid为空,按照告知的为使用登记的id)")
private String oId;
} }
...@@ -52,4 +52,10 @@ public class JgBizChangeLog extends BaseEntity { ...@@ -52,4 +52,10 @@ public class JgBizChangeLog extends BaseEntity {
@TableField("change_attachment") @TableField("change_attachment")
private String changeAttachment; private String changeAttachment;
/**
* 触发的id(列入使用登记变化后,安装告知数据也变化,则记录两条:使用登记的oid为空,按照告知的为使用登记的id)
*/
@TableField("o_id")
private String oId;
} }
...@@ -10,14 +10,16 @@ import java.util.Map; ...@@ -10,14 +10,16 @@ import java.util.Map;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum EquipSourceEnum { public enum EquipSourceEnum {
jg_his("历史设备", "jg_his"), jg_his("历史设备", "jg_his", "his"),
jg_his_black("历史设备(无登记证)", "jg_his_black"), jg_his_black("历史设备(无登记证)", "jg_his_black", "black"),
jg("新设备", "jg"); jg("新设备", "jg", "new");
private final String name; private final String name;
private final String code; private final String code;
private final String type;
public static String getMessage(String code) { public static String getMessage(String code) {
for (EquipSourceEnum constants : values()) { for (EquipSourceEnum constants : values()) {
...@@ -30,6 +32,7 @@ public enum EquipSourceEnum { ...@@ -30,6 +32,7 @@ public enum EquipSourceEnum {
public static Map<Integer,String> getName=new HashMap<>(); public static Map<Integer,String> getName=new HashMap<>();
public static Map<String,Integer> getCode=new HashMap<>(); public static Map<String,Integer> getCode=new HashMap<>();
public static Map<String,Integer> getType=new HashMap<>();
static { static {
for (ConstructionEnum e : ConstructionEnum.values()){ for (ConstructionEnum e : ConstructionEnum.values()){
...@@ -39,14 +42,6 @@ public enum EquipSourceEnum { ...@@ -39,14 +42,6 @@ public enum EquipSourceEnum {
} }
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static String getDataSourceName(String dataSource) { public static String getDataSourceName(String dataSource) {
if(StringUtils.isEmpty(dataSource)){ if(StringUtils.isEmpty(dataSource)){
return EquipSourceEnum.jg_his.getName(); return EquipSourceEnum.jg_his.getName();
......
...@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Mapper 接口 * Mapper 接口
...@@ -66,4 +67,6 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat ...@@ -66,4 +67,6 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat
* @return 已完成但是未生成装置的施工信息的安装告知单据列表 * @return 已完成但是未生成装置的施工信息的安装告知单据列表
*/ */
List<JgInstallationNotice> selectNotInsertProjectConstructionInstallNoticeList(); List<JgInstallationNotice> selectNotInsertProjectConstructionInstallNoticeList();
Set<Long> queryListByEqsAndStatus(@Param("records") Set<String> records, @Param("noticeStatus") String noticeStatus);
} }
...@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Mapper 接口 * Mapper 接口
...@@ -38,4 +39,6 @@ public interface JgMaintenanceContractMapper extends BaseMapper<JgMaintenanceCon ...@@ -38,4 +39,6 @@ public interface JgMaintenanceContractMapper extends BaseMapper<JgMaintenanceCon
List<MaintenanceVo> queryMaintenanceInIds(@Param("ids") List<String> ids); List<MaintenanceVo> queryMaintenanceInIds(@Param("ids") List<String> ids);
String getNameByEquDefine(String equDefine); String getNameByEquDefine(String equDefine);
Set<Long> queryListByEqsAndStatus(@Param("records") Set<String> records, @Param("status") String status);
} }
package com.yeejoin.amos.boot.module.jg.api.mapper; package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationEqDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq; import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -19,4 +20,5 @@ public interface JgUseRegistrationEqMapper extends BaseMapper<JgUseRegistrationE ...@@ -19,4 +20,5 @@ public interface JgUseRegistrationEqMapper extends BaseMapper<JgUseRegistrationE
void batchInsert(@Param("equipTransferId") String equipTransferId, @Param("jgRelationEquipList") List<JgUseRegistrationEq> jgRelationEquipList); void batchInsert(@Param("equipTransferId") String equipTransferId, @Param("jgRelationEquipList") List<JgUseRegistrationEq> jgRelationEquipList);
List<JgUseRegistrationEqDto> queryEqListByApplyNo(@Param("applyNo") String applyNo);
} }
...@@ -2334,7 +2334,7 @@ ...@@ -2334,7 +2334,7 @@
WHERE tjvi."USE_UNIT_CREDIT_CODE" = #{useCode} WHERE tjvi."USE_UNIT_CREDIT_CODE" = #{useCode}
AND tjvi.is_delete = '0' AND tjvi.is_delete = '0'
</select> </select>
<select id="countEquipInUseTimesWithOutZF" resultType="java.lang.Integer"> <select id="countEquipInUseTimesWithOutZF" resultType="java.lang.Integer" flushCache="true">
select select
sum(inUseNumber) sum(inUseNumber)
from ( from (
......
...@@ -360,4 +360,22 @@ ...@@ -360,4 +360,22 @@
and n.project_contraption_id <![CDATA[ <> ]]> '' and n.project_contraption_id <![CDATA[ <> ]]> ''
and not EXISTS (select 1 from idx_biz_jg_project_construction c where c.record=n.sequence_nbr) and not EXISTS (select 1 from idx_biz_jg_project_construction c where c.record=n.sequence_nbr)
</select> </select>
<select id="queryListByEqsAndStatus"
resultType="java.lang.Long">
SELECT
distinct n.sequence_nbr as sequence_nbr
FROM
"tzs_jg_installation_notice" n,
tzs_jg_installation_notice_eq ne
WHERE
n.notice_status =#{noticeStatus}
and n.is_delete=0
and ne.equip_transfer_id = n.sequence_nbr
<if test='records != null'>
and ne.equ_id in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
</foreach>
</if>
</select>
</mapper> </mapper>
...@@ -195,4 +195,21 @@ ...@@ -195,4 +195,21 @@
ORDER BY ORDER BY
tjmc.create_date DESC, tjmc.apply_no DESC tjmc.create_date DESC, tjmc.apply_no DESC
</select> </select>
</mapper> <select id="queryListByEqsAndStatus" resultType="java.lang.Long">
SELECT
distinct n.sequence_nbr as sequence_nbr
FROM
tzs_jg_maintenance_contract n,
tzs_jg_maintenance_contract_eq ne
WHERE
n.status = #{status}
and n.is_delete=0
and ne.equip_transfer_id = n.sequence_nbr
<if test='records != null'>
and ne.equ_id in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
...@@ -9,4 +9,16 @@ ...@@ -9,4 +9,16 @@
(#{item.sequenceNbr},#{equipTransferId}, #{item.equId}) (#{item.sequenceNbr},#{equipTransferId}, #{item.equId})
</foreach> </foreach>
</insert> </insert>
<select id="queryEqListByApplyNo"
resultType="com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationEqDto">
SELECT
eq.equ_id,
eq.sequence_nbr
FROM
tzs_jg_use_registration_eq eq,
tzs_jg_use_registration u
where
u.sequence_nbr = eq.equip_transfer_id
and u.apply_no=#{applyNo}
</select>
</mapper> </mapper>
...@@ -14,7 +14,7 @@ import java.util.List; ...@@ -14,7 +14,7 @@ import java.util.List;
public class FlowingEquipRedisContext { public class FlowingEquipRedisContext {
private static ThreadLocal<List<FlowingEquipRedisKeyDTO>> threadLocal = new ThreadLocal<>(); private static final ThreadLocal<List<FlowingEquipRedisKeyDTO>> threadLocal = new ThreadLocal<>();
public static List<FlowingEquipRedisKeyDTO> getContext() { public static List<FlowingEquipRedisKeyDTO> getContext() {
if (threadLocal.get() == null) { if (threadLocal.get() == null) {
...@@ -29,9 +29,7 @@ public class FlowingEquipRedisContext { ...@@ -29,9 +29,7 @@ public class FlowingEquipRedisContext {
public static void clean() { public static void clean() {
log.info("FlowingEquipRedisContext clean begin"); log.info("FlowingEquipRedisContext clean begin");
if (threadLocal != null) { threadLocal.remove();
threadLocal.remove();
}
log.info("FlowingEquipRedisContext clean end"); log.info("FlowingEquipRedisContext clean end");
} }
} }
...@@ -364,8 +364,8 @@ public class CommonController extends BaseController { ...@@ -364,8 +364,8 @@ public class CommonController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询监管业务名称列表", notes = "查询监管业务名称列表") @ApiOperation(httpMethod = "GET", value = "查询监管业务名称列表", notes = "查询监管业务名称列表")
@GetMapping(value = "/superviseBusinessCategory") @GetMapping(value = "/superviseBusinessCategory")
public ResponseModel<Object> equipTree(@RequestParam(value = "businessType") String businessType) { public ResponseModel<Object> equipTree(@RequestParam(value = "businessType") String businessType, String dataSource) {
return ResponseHelper.buildResponse(commonService.superviseBusinessCategory(businessType)); return ResponseHelper.buildResponse(commonService.superviseBusinessCategory(businessType, dataSource));
} }
/** /**
......
package com.yeejoin.amos.boot.module.jg.biz.event.handler;
import org.springframework.context.ApplicationEvent;
public interface IChangeUpdateHandler<T extends ApplicationEvent> {
void handle(T event);
Boolean supports(T event);
}
package com.yeejoin.amos.boot.module.jg.biz.event.handler;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.ESDataChangeLogDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgBizChangeLog;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.service.IJgBizChangeLogService;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgBizChangeLogServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.UseRegisterDataChangeHandleImpl;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.Set;
@Component
@RequiredArgsConstructor
@Slf4j
public class InstallNoticeUpdateUpdateHandler implements IChangeUpdateHandler<ChangeDataEvent> {
private final JgInstallationNoticeServiceImpl jgInstallationNoticeService;
private final JgBizChangeLogServiceImpl jgBizChangeLogService;
@Override
@Async
public void handle(ChangeDataEvent event) {
log.info("开始更新安装告知json数据:{}", event);
// 查询关联的单据-未删除且已完成状态
Set<Long> installationNoticeIds = this.getRelationInstallNoticeList(event);
// 更新历史json
installationNoticeIds.forEach(seq -> {
// 更新json
JgInstallationNotice installationNotice = jgInstallationNoticeService.getById(seq);
// 查询之前数据json
JSONObject beforeData = jgInstallationNoticeService.getHisData(installationNotice);
jgInstallationNoticeService.saveHisDataBeforeUpdate(installationNotice);
// 查询之后数据json
JSONObject afterData = jgInstallationNoticeService.getHisData(installationNotice);
// es记录日志
this.log2es(beforeData, afterData, installationNotice, event);
});
}
private void log2es(JSONObject beforeData, JSONObject afterData, JgInstallationNotice installationNotice, ChangeDataEvent event) {
Date date = DateUtil.date();
JgBizChangeLog changeLog = new JgBizChangeLog();
BeanUtil.copyProperties(event.getBizRelationData(), changeLog);
changeLog.setBizTable("tzs_jg_installation_notice");
changeLog.setRecDate(date);
changeLog.setBizId(installationNotice.getApplyNo());
// todo 与原始编辑进行关联
changeLog.setOId(event.getRequestContext().getTraceId());
changeLog.setBizType("installationNotice");
changeLog.setRecUserId(event.getRequestContext().getExcutedUserId());
ESDataChangeLogDto changeLogDto = new ESDataChangeLogDto();
changeLogDto.setColumnKey("changeData");
changeLogDto.setColumnKeyLabel("历史json数据");
changeLogDto.setBeforeData(beforeData.toJSONString());
changeLogDto.setAfterData(afterData.toJSONString());
changeLogDto.setUserId(event.getRequestContext().getExcutedUserId());
changeLogDto.setCreateDate(date.getTime());
changeLogDto.setRequestDate(DateUtil.formatDateTime(date));
changeLogDto.setChangeId(installationNotice.getApplyNo());
changeLogDto.setColumnFamily("tzs_jg_installation_notice");
changeLogDto.setBizType(changeLog.getBizType());
changeLogDto.setBatchId(changeLog.getSequenceNbr() + "");
jgBizChangeLogService.save2DbAndEs(changeLog, Collections.singletonList(changeLogDto));
}
private Set<Long> getRelationInstallNoticeList(ChangeDataEvent event) {
// 变化的设备
Set<String> records = event.getBizRelationData().getRecords();
// 查询关联的单据-已完成时更新其json
return jgInstallationNoticeService.getBaseMapper().queryListByEqsAndStatus(records, FlowStatusEnum.TO_BE_FINISHED.getCode() + "");
}
@Override
public Boolean supports(ChangeDataEvent event) {
return event.getBizRelationData().getBizType().equals(UseRegisterDataChangeHandleImpl.BIZ_TYPE);
}
}
package com.yeejoin.amos.boot.module.jg.biz.event.handler;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.dto.ESDataChangeLogDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgBizChangeLog;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgMaintenanceContract;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgBizChangeLogServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgMaintenanceContractServiceImpl;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.UseRegisterDataChangeHandleImpl;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Date;
import java.util.Set;
@Component
@RequiredArgsConstructor
@Slf4j
public class MaintenanceContractUpdateUpdateHandler implements IChangeUpdateHandler<ChangeDataEvent> {
private final JgMaintenanceContractServiceImpl jgMaintenanceContractService;
private final JgBizChangeLogServiceImpl jgBizChangeLogService;
@Override
@Async
public void handle(ChangeDataEvent event) {
log.info("开始更新维保备案json数据:{}", event);
// 查询关联的单据-未删除且已完成状态
Set<Long> maintenanceContractList = this.getRelationMaintenanceContractList(event);
// 更新历史json
maintenanceContractList.forEach(seq -> {
// 更新json
JgMaintenanceContract maintenanceContract = jgMaintenanceContractService.getById(seq);
// 查询之前数据json
JSONArray beforeData = jgMaintenanceContractService.getHisData(maintenanceContract);
jgMaintenanceContractService.updateHisDataAfterEquipEdit(maintenanceContract);
// 查询之后数据json
JSONArray afterData = jgMaintenanceContractService.getHisData(maintenanceContract);
// es记录日志
this.log2es(beforeData, afterData, maintenanceContract, event);
});
}
private Set<Long> getRelationMaintenanceContractList(ChangeDataEvent event) {
// 变化的设备
Set<String> records = event.getBizRelationData().getRecords();
// 查询关联的单据-已完成时更新其json
return jgMaintenanceContractService.getBaseMapper().queryListByEqsAndStatus(records, FlowStatusEnum.TO_BE_FINISHED.getName());
}
@Override
public Boolean supports(ChangeDataEvent event) {
return event.getBizRelationData().getBizType().equals(UseRegisterDataChangeHandleImpl.BIZ_TYPE);
}
private void log2es(JSON beforeData, JSON afterData, JgMaintenanceContract maintenanceContract, ChangeDataEvent event) {
Date date = DateUtil.date();
JgBizChangeLog changeLog = new JgBizChangeLog();
BeanUtil.copyProperties(event.getBizRelationData(), changeLog);
changeLog.setBizTable("tzs_jg_maintenance_contract");
changeLog.setRecDate(date);
changeLog.setBizId(maintenanceContract.getApplyNo());
// todo 与原始编辑进行关联
changeLog.setOId(event.getRequestContext().getTraceId());
changeLog.setBizType("maintenanceContract");
changeLog.setRecUserId(event.getRequestContext().getExcutedUserId());
ESDataChangeLogDto changeLogDto = new ESDataChangeLogDto();
changeLogDto.setColumnKey("changeData");
changeLogDto.setColumnKeyLabel("历史json数据");
changeLogDto.setBeforeData(beforeData.toJSONString());
changeLogDto.setAfterData(afterData.toJSONString());
changeLogDto.setUserId(event.getRequestContext().getExcutedUserId());
changeLogDto.setCreateDate(date.getTime());
changeLogDto.setRequestDate(DateUtil.formatDateTime(date));
changeLogDto.setChangeId(maintenanceContract.getApplyNo());
changeLogDto.setColumnFamily("tzs_jg_maintenance_contract");
changeLogDto.setBizType(changeLog.getBizType());
changeLogDto.setBatchId(changeLog.getSequenceNbr() + "");
jgBizChangeLogService.save2DbAndEs(changeLog, Collections.singletonList(changeLogDto));
}
}
...@@ -53,12 +53,17 @@ public class CancellationEventListener { ...@@ -53,12 +53,17 @@ public class CancellationEventListener {
@PostConstruct @PostConstruct
public void init() { public void init() {
ExecutorService executorService = Executors.newFixedThreadPool(threadNumber); ExecutorService executorService = Executors.newFixedThreadPool(threadNumber, r -> {
Thread t = new Thread(r);
t.setName("CancellationWorker-" + t.getId());
return t;
});
for (int i = 0; i < threadNumber; i++) { for (int i = 0; i < threadNumber; i++) {
executorService.execute(() -> { executorService.execute(() -> {
while (true) { while (true) {
try { try {
String record = queue.take(); String record = queue.take();
log.info("线程 {} 开始处理 record: {}", Thread.currentThread().getName(), record);
this.dealData(record); this.dealData(record);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
...@@ -70,6 +75,7 @@ public class CancellationEventListener { ...@@ -70,6 +75,7 @@ public class CancellationEventListener {
} }
private void dealData(String record) { private void dealData(String record) {
log.info("开始检查设备的引用:{}", record);
// 所有业务单据(除去作废、删除状态单据),有在引用设备的则不修改设备纳管状态 // 所有业务单据(除去作废、删除状态单据),有在引用设备的则不修改设备纳管状态
Boolean inUsed = commonService.checkEquipIsUsed(record); Boolean inUsed = commonService.checkEquipIsUsed(record);
// 无引用则进行修改纳管状态为未纳管 // 无引用则进行修改纳管状态为未纳管
......
...@@ -12,8 +12,9 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgBizChangeLogServiceImp ...@@ -12,8 +12,9 @@ import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgBizChangeLogServiceImp
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;
import org.typroject.tyboot.core.foundation.context.RequestContextModel; import org.typroject.tyboot.core.foundation.context.RequestContextModel;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
...@@ -26,6 +27,7 @@ import java.util.concurrent.ExecutorService; ...@@ -26,6 +27,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
/** /**
* @author Administrator * @author Administrator
...@@ -33,7 +35,7 @@ import java.util.stream.Collectors; ...@@ -33,7 +35,7 @@ import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class ChangeDataEventListener { public class ChangeLogInsertListener {
private static final Map<String, String> bizTypeTableMap = new HashMap<>(); private static final Map<String, String> bizTypeTableMap = new HashMap<>();
...@@ -42,17 +44,19 @@ public class ChangeDataEventListener { ...@@ -42,17 +44,19 @@ public class ChangeDataEventListener {
bizTypeTableMap.put("singleManageEquipEdit", "idx_biz_jg_use_info"); bizTypeTableMap.put("singleManageEquipEdit", "idx_biz_jg_use_info");
} }
@Value("${changeData.deal.thread.number:1}") @Value("${change.data.deal.thread.number:1}")
private int threadNumber; private int threadNumber;
private final ESDataChangeLogDao esDataChangeLogDao; private final ESDataChangeLogDao esDataChangeLogDao;
private final JgBizChangeLogServiceImpl bizChangeLogService; private final JgBizChangeLogServiceImpl bizChangeLogService;
private final BlockingQueue<ChangeDataEvent> queue = new LinkedBlockingQueue<>(); private final BlockingQueue<ChangeDataEvent> queue = new LinkedBlockingQueue<>();
@EventListener(value = ChangeDataEvent.class) @TransactionalEventListener(value = ChangeDataEvent.class)
@Async
public void handleTransactionalEvent(ChangeDataEvent event) { public void handleTransactionalEvent(ChangeDataEvent event) {
log.info("收到用户变更业务数据消息:{}", JSONObject.toJSONString(event)); log.info("收到用户变更业务数据消息:{}", JSONObject.toJSONString(event));
queue.add(event); queue.add(event);
...@@ -61,27 +65,26 @@ public class ChangeDataEventListener { ...@@ -61,27 +65,26 @@ public class ChangeDataEventListener {
@PostConstruct @PostConstruct
public void init() { public void init() {
ExecutorService executorService = Executors.newFixedThreadPool(threadNumber); ExecutorService executorService = Executors.newFixedThreadPool(threadNumber);
for (int i = 0; i < threadNumber; i++) { IntStream.range(0, threadNumber).forEach(i -> {
executorService.execute(() -> { executorService.execute(() -> {
while (true) { while (true) {
try { try {
ChangeDataEvent event = queue.take(); ChangeDataEvent event = queue.take();
this.dealData(event); processEvent(event);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} }
}); });
});
}
} }
private void dealData(ChangeDataEvent event) { private void processEvent(ChangeDataEvent event) {
List<ChangeDataDto> changeDataDtos = event.getData(); List<ChangeDataDto> changeDataDtos = event.getData();
RequestContextModel requestContextModel = event.getRequestContext(); RequestContextModel requestContextModel = event.getRequestContext();
Date date = new Date(); Date date = new Date();
// 1.主表保存 // 1.主表保存
JgBizChangeLog changeLog = saveLog(event); JgBizChangeLog changeLog = saveLog(event);
// 2.子表字段保存 // 2.子表字段保存
List<ESDataChangeLogDto> logs = saveColumnsChange2Es(changeDataDtos, requestContextModel, date, changeLog); List<ESDataChangeLogDto> logs = saveColumnsChange2Es(changeDataDtos, requestContextModel, date, changeLog);
log.info("es 操作日志数据入库成功:{}条", logs.size()); log.info("es 操作日志数据入库成功:{}条", logs.size());
...@@ -103,7 +106,7 @@ public class ChangeDataEventListener { ...@@ -103,7 +106,7 @@ public class ChangeDataEventListener {
changeLogDto.setBatchId(changeLog.getSequenceNbr() + ""); changeLogDto.setBatchId(changeLog.getSequenceNbr() + "");
return changeLogDto; return changeLogDto;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if(!logs.isEmpty()){ if (!logs.isEmpty()) {
esDataChangeLogDao.saveAll(logs); esDataChangeLogDao.saveAll(logs);
} }
return logs; return logs;
...@@ -115,7 +118,9 @@ public class ChangeDataEventListener { ...@@ -115,7 +118,9 @@ public class ChangeDataEventListener {
changeLog.setBizTable(bizTypeTableMap.get(changeLog.getBizType())); changeLog.setBizTable(bizTypeTableMap.get(changeLog.getBizType()));
changeLog.setRecDate(new Date()); changeLog.setRecDate(new Date());
changeLog.setRecUserId(event.getRequestContext().getExcutedUserId()); changeLog.setRecUserId(event.getRequestContext().getExcutedUserId());
bizChangeLogService.save(changeLog); // todo 使用上下文这个作为id 便于其他业务和其进行关联
changeLog.setSequenceNbr(Long.parseLong(event.getRequestContext().getTraceId()));
bizChangeLogService.getBaseMapper().insert(changeLog);
return changeLog; return changeLog;
} }
} }
package com.yeejoin.amos.boot.module.jg.biz.event.listener;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
import com.yeejoin.amos.boot.module.jg.biz.event.handler.IChangeUpdateHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEvent;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.IntStream;
/**
* @author Administrator
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class RelationBizApplyUpdateListener {
@Value("${relation.data.deal.thread.number:1}")
private int threadNumber;
private final List<IChangeUpdateHandler<ApplicationEvent>> changeUpdateHandlers;
private final BlockingQueue<ChangeDataEvent> queue = new LinkedBlockingQueue<>();
@TransactionalEventListener(value = ChangeDataEvent.class)
@Async
public void handleTransactionalEvent(ChangeDataEvent event) {
log.info("收到用户变更业务数据消息:{}", JSONObject.toJSONString(event));
queue.add(event);
}
@PostConstruct
public void init() {
ExecutorService executorService = Executors.newFixedThreadPool(threadNumber);
IntStream.range(0, threadNumber).forEach(i -> {
executorService.execute(() -> {
while (true) {
try {
ChangeDataEvent event = queue.take();
processEvent(event);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
});
}
private void processEvent(ChangeDataEvent event) {
changeUpdateHandlers.stream().filter(h -> h.supports(event)).forEach(h -> h.handle(event));
}
}
...@@ -18,7 +18,6 @@ public class EventPublisher implements ApplicationEventPublisherAware { ...@@ -18,7 +18,6 @@ public class EventPublisher implements ApplicationEventPublisherAware {
this.publisher = applicationEventPublisher; this.publisher = applicationEventPublisher;
} }
@Async
public void publish(ApplicationEvent event) { public void publish(ApplicationEvent event) {
publisher.publishEvent(event); publisher.publishEvent(event);
} }
......
...@@ -64,7 +64,7 @@ public interface ICommonService { ...@@ -64,7 +64,7 @@ public interface ICommonService {
List<LinkedHashMap> creatApproveTree(); List<LinkedHashMap> creatApproveTree();
List<Map<String, Object>> superviseBusinessCategory(String businessType); List<Map<String, Object>> superviseBusinessCategory(String businessType, String dataSource);
List<Map<String, Object>> businessScenarios(String type); List<Map<String, Object>> businessScenarios(String type);
......
...@@ -85,6 +85,7 @@ import org.springframework.core.io.Resource; ...@@ -85,6 +85,7 @@ import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -732,7 +733,7 @@ public class CommonServiceImpl implements ICommonService { ...@@ -732,7 +733,7 @@ public class CommonServiceImpl implements ICommonService {
} }
@Override @Override
public List<Map<String, Object>> superviseBusinessCategory(String businessType) { public List<Map<String, Object>> superviseBusinessCategory(String businessType, String dataSource) {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(superviseBusinessCategory); Map<String, List<Map<String, Object>>> resourceJson = JsonUtils.getResourceJson(superviseBusinessCategory);
if (XZSB.equals(businessType) && CompanyTypeEnum.CONSTRUCTION.getName().equals(reginParams.getCompany().getCompanyType())) { if (XZSB.equals(businessType) && CompanyTypeEnum.CONSTRUCTION.getName().equals(reginParams.getCompany().getCompanyType())) {
...@@ -745,6 +746,11 @@ public class CommonServiceImpl implements ICommonService { ...@@ -745,6 +746,11 @@ public class CommonServiceImpl implements ICommonService {
} }
return resourceJson.get(businessType); return resourceJson.get(businessType);
} }
// 历史有证设备(气瓶、管道)只能通过导入进系统,不能按单位录入进系统
if (EquipSourceEnum.jg_his.getType().equals(dataSource)) {
resourceJson.get(businessType).removeIf(item -> item.get(CODE).equals(DW_LR));
return resourceJson.get(businessType);
}
return resourceJson.get(businessType); return resourceJson.get(businessType);
} }
...@@ -2152,6 +2158,7 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2152,6 +2158,7 @@ public class CommonServiceImpl implements ICommonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Boolean checkEquipIsUsed(String record) { public Boolean checkEquipIsUsed(String record) {
Integer useTime = commonMapper.countEquipInUseTimesWithOutZF(record); Integer useTime = commonMapper.countEquipInUseTimesWithOutZF(record);
log.info("检查设备是否被使用,设备:{},业务数:{}", record, useTime); log.info("检查设备是否被使用,设备:{},业务数:{}", record, useTime);
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.yeejoin.amos.boot.module.jg.api.dto.ESDataChangeLogDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgBizChangeLogDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgBizChangeLog; import com.yeejoin.amos.boot.module.jg.api.entity.JgBizChangeLog;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgBizChangeLogMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgBizChangeLogMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgBizChangeLogService; import com.yeejoin.amos.boot.module.jg.api.service.IJgBizChangeLogService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgBizChangeLogDto; import com.yeejoin.amos.boot.module.jg.biz.dao.ESDataChangeLogDao;
import org.typroject.tyboot.core.rdbms.service.BaseService; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List; import java.util.List;
/** /**
...@@ -16,18 +19,19 @@ import java.util.List; ...@@ -16,18 +19,19 @@ import java.util.List;
* @date 2025-04-14 * @date 2025-04-14
*/ */
@Service @Service
public class JgBizChangeLogServiceImpl extends BaseService<JgBizChangeLogDto,JgBizChangeLog,JgBizChangeLogMapper> implements IJgBizChangeLogService { @RequiredArgsConstructor
/** public class JgBizChangeLogServiceImpl extends BaseService<JgBizChangeLogDto, JgBizChangeLog, JgBizChangeLogMapper> implements IJgBizChangeLogService {
* 分页查询
*/
public Page<JgBizChangeLogDto> queryForJgBizChangeLogPage(Page<JgBizChangeLogDto> page) { private final ESDataChangeLogDao esDataChangeLogDao;
return this.queryForPage(page, null, false);
}
/** public void save2DbAndEs(JgBizChangeLog changeLog, List<ESDataChangeLogDto> esDataChangeLogDtos) {
* 列表查询 示例 this.save(changeLog);
*/ esDataChangeLogDtos.forEach(esDataChangeLogDto -> {
public List<JgBizChangeLogDto> queryForJgBizChangeLogList() { esDataChangeLogDto.setBatchId(changeLog.getSequenceNbr() + "");
return this.queryForList("" , false); });
if (!esDataChangeLogDtos.isEmpty()) {
esDataChangeLogDao.saveAll(esDataChangeLogDtos);
}
} }
} }
\ No newline at end of file
...@@ -1568,6 +1568,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1568,6 +1568,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(his), registerInfo.getRecord(), jgInstallationNotice.getSequenceNbr().toString()); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(his), registerInfo.getRecord(), jgInstallationNotice.getSequenceNbr().toString());
} }
public JSONObject getHisData(JgInstallationNotice jgInstallationNotice){
return commonService.queryHistoryData(jgInstallationNotice.getSequenceNbr());
}
private String getEquCode(IdxBizJgRegisterInfo registerInfo, String receiveCompanyCode) { private String getEquCode(IdxBizJgRegisterInfo registerInfo, String receiveCompanyCode) {
ProduceInfo produceInfo = produceInfoMapper.selectOne(new LambdaQueryWrapper<ProduceInfo>().eq(AbstractEquipBaseEntity::getRecord, registerInfo.getRecord())); ProduceInfo produceInfo = produceInfoMapper.selectOne(new LambdaQueryWrapper<ProduceInfo>().eq(AbstractEquipBaseEntity::getRecord, registerInfo.getRecord()));
CodeGenerateDto codeGenerateDto = new CodeGenerateDto(); CodeGenerateDto codeGenerateDto = new CodeGenerateDto();
...@@ -1604,11 +1608,11 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1604,11 +1608,11 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
idxBizJgUseInfoMapper.update(idxBizJgUseInfo, lambda); idxBizJgUseInfoMapper.update(idxBizJgUseInfo, lambda);
} }
private void saveHisDataBeforeUpdate(JgInstallationNotice jgInstallationNotice) { public void saveHisDataBeforeUpdate(JgInstallationNotice jgInstallationNotice) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()); queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr());
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper); List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
List<String> ids = jgInstallationNoticeEqs.stream().map(item -> item.getEquId()).collect(Collectors.toList()); List<String> ids = jgInstallationNoticeEqs.stream().map(JgInstallationNoticeEq::getEquId).collect(Collectors.toList());
List<Map<String, Object>> equipListMaps; List<Map<String, Object>> equipListMaps;
String equCategoryCode = jgInstallationNotice.getEquCategoryCode(); String equCategoryCode = jgInstallationNotice.getEquCategoryCode();
Map<String, Object> installationInfo = BeanUtil.beanToMap(jgInstallationNotice, false, true); Map<String, Object> installationInfo = BeanUtil.beanToMap(jgInstallationNotice, false, true);
...@@ -1631,6 +1635,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -1631,6 +1635,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(installationInfo), null, jgInstallationNotice.getSequenceNbr().toString()); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(installationInfo), null, jgInstallationNotice.getSequenceNbr().toString());
} }
private void saveHisDataBeforeUpdate(JgInstallationNotice jgInstallationNotice, String equId) { private void saveHisDataBeforeUpdate(JgInstallationNotice jgInstallationNotice, String equId) {
Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId); Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId);
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(map), equId, jgInstallationNotice.getSequenceNbr().toString()); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(map), equId, jgInstallationNotice.getSequenceNbr().toString());
......
...@@ -917,6 +917,12 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -917,6 +917,12 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_RECORD.getName(), JSON.parseArray(JSON.toJSONString(equipmentLists)), null, maintenanceContract.getSequenceNbr().toString()); commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_RECORD.getName(), JSON.parseArray(JSON.toJSONString(equipmentLists)), null, maintenanceContract.getSequenceNbr().toString());
} }
public void updateHisDataAfterEquipEdit(JgMaintenanceContract maintenanceContract) {
List<Map<String, Object>> list = maintenanceContractMapper.selectEquipList(maintenanceContract.getSequenceNbr());
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MAINTENANCE_RECORD.getName(), JSON.parseArray(JSON.toJSONString(list)), null, maintenanceContract.getSequenceNbr().toString());
}
@Override @Override
public boolean beforeCheck(JgMaintenanceContractDto jgMaintenanceContract) { public boolean beforeCheck(JgMaintenanceContractDto jgMaintenanceContract) {
return jgMaintenanceContract.getInstanceId() != null && !jgMaintenanceContract.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) &&!jgMaintenanceContract.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName()); return jgMaintenanceContract.getInstanceId() != null && !jgMaintenanceContract.getStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) &&!jgMaintenanceContract.getStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName());
...@@ -928,4 +934,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC ...@@ -928,4 +934,9 @@ public class JgMaintenanceContractServiceImpl extends BaseService<JgMaintenanceC
commonService.saveExecuteFlowData2Redis(jgMaintenanceContract.getInstanceId(), this.buildInstanceRuntimeData(jgMaintenanceContract)); commonService.saveExecuteFlowData2Redis(jgMaintenanceContract.getInstanceId(), this.buildInstanceRuntimeData(jgMaintenanceContract));
} }
public JSONArray getHisData(JgMaintenanceContract maintenanceContract){
return commonService.queryHistoryDataObj(maintenanceContract.getSequenceNbr());
}
} }
\ No newline at end of file
...@@ -32,6 +32,10 @@ public class JgUseRegistrationEqServiceImpl extends BaseService<JgUseRegistratio ...@@ -32,6 +32,10 @@ public class JgUseRegistrationEqServiceImpl extends BaseService<JgUseRegistratio
return this.queryForList("" , false); return this.queryForList("" , false);
} }
public List<JgUseRegistrationEqDto> queryForJgUseRegistrationEqList(String equipTransferId) {
return this.queryForList("" , false, equipTransferId);
}
public List<JgUseRegistrationEq> getListByEquIds(List<String> equIds) { public List<JgUseRegistrationEq> getListByEquIds(List<String> equIds) {
QueryWrapper<JgUseRegistrationEq> queryWrapper = new QueryWrapper<>(); QueryWrapper<JgUseRegistrationEq> queryWrapper = new QueryWrapper<>();
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.yeejoin.amos.boot.module.jg.api.dto.BizRelationDataDto; import com.yeejoin.amos.boot.module.jg.api.dto.BizRelationDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto; import com.yeejoin.amos.boot.module.jg.api.dto.ChangeDataDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationEqDto;
import com.yeejoin.amos.boot.module.jg.api.service.IBizDataChangeHandleStrategy; import com.yeejoin.amos.boot.module.jg.api.service.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.context.DataProcessStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.DataProcessStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent; import com.yeejoin.amos.boot.module.jg.biz.event.ChangeDataEvent;
...@@ -13,6 +14,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext; ...@@ -13,6 +14,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStrategy { public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStrategy {
...@@ -22,6 +24,8 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -22,6 +24,8 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
private final UseRegisterUpdateService useRegisterUpdateService; private final UseRegisterUpdateService useRegisterUpdateService;
public final static String BIZ_TYPE = "useRegister";
public UseRegisterDataChangeHandleImpl(EventPublisher publisher, UseRegisterUpdateService useRegisterUpdateService) { public UseRegisterDataChangeHandleImpl(EventPublisher publisher, UseRegisterUpdateService useRegisterUpdateService) {
this.publisher = publisher; this.publisher = publisher;
...@@ -31,7 +35,7 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -31,7 +35,7 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
@Override @Override
public String canHandleBizType() { public String canHandleBizType() {
return "useRegister"; return BIZ_TYPE;
} }
...@@ -57,9 +61,11 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -57,9 +61,11 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
} }
private void publishEvent2Logger(String applyNo, List<ChangeDataDto> allChangeColumns) { private void publishEvent2Logger(String applyNo, List<ChangeDataDto> allChangeColumns) {
List<JgUseRegistrationEqDto> eqDtos = useRegisterUpdateService.useRegistrationEqService.getBaseMapper().queryEqListByApplyNo(applyNo);
BizRelationDataDto bizRelationDataDto = new BizRelationDataDto(); BizRelationDataDto bizRelationDataDto = new BizRelationDataDto();
bizRelationDataDto.setBizId(applyNo); bizRelationDataDto.setBizId(applyNo);
bizRelationDataDto.setBizType(canHandleBizType()); bizRelationDataDto.setBizType(canHandleBizType());
bizRelationDataDto.setRecords(eqDtos.stream().map(JgUseRegistrationEqDto::getEquId).collect(Collectors.toSet()));
// 异步记录日志 // 异步记录日志
publisher.publish(new ChangeDataEvent(this, bizRelationDataDto, allChangeColumns, RequestContext.cloneRequestContext())); publisher.publish(new ChangeDataEvent(this, bizRelationDataDto, allChangeColumns, RequestContext.cloneRequestContext()));
} }
......
...@@ -14,6 +14,7 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.InformationManageTypeEnum; ...@@ -14,6 +14,7 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.InformationManageTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -24,23 +25,18 @@ import java.util.stream.Collectors; ...@@ -24,23 +25,18 @@ import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
@Service @Service
@RequiredArgsConstructor
public class UseRegisterUpdateService { public class UseRegisterUpdateService {
private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper; private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
private final JgUseRegistrationServiceImpl useRegistrationService; private final JgUseRegistrationServiceImpl useRegistrationService;
private final JgRegistrationHistoryServiceImpl jgRegistrationHistoryService; private final JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService; private final IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService;
public UseRegisterUpdateService(IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper, JgUseRegistrationServiceImpl useRegistrationService, JgRegistrationHistoryServiceImpl jgRegistrationHistoryService, IdxBizJgProjectContraptionServiceImpl idxBizJgProjectContraptionService) { protected final JgUseRegistrationEqServiceImpl useRegistrationEqService;
this.idxBizJgRegisterInfoMapper = idxBizJgRegisterInfoMapper;
this.useRegistrationService = useRegistrationService;
this.jgRegistrationHistoryService = jgRegistrationHistoryService;
this.idxBizJgProjectContraptionService = idxBizJgProjectContraptionService;
}
public void updateHisData(String applyNo) { public void updateHisData(String applyNo) {
JgUseRegistration jgUseRegistration = useRegistrationService.getOne(new LambdaQueryWrapper<JgUseRegistration>().eq(JgUseRegistration::getApplyNo, applyNo)); JgUseRegistration jgUseRegistration = useRegistrationService.getOne(new LambdaQueryWrapper<JgUseRegistration>().eq(JgUseRegistration::getApplyNo, applyNo));
......
package com.yeejoin.amos.patrol.dao.entity; package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -94,7 +91,7 @@ public class ESPlanTaskListDto { ...@@ -94,7 +91,7 @@ public class ESPlanTaskListDto {
private String omission; private String omission;
@Field(type = FieldType.Object) @Field(type = FieldType.Object)
private List points; private List<PlanTaskDetail> points;
} }
...@@ -113,7 +113,9 @@ public interface PlanTaskMapper extends BaseMapper { ...@@ -113,7 +113,9 @@ public interface PlanTaskMapper extends BaseMapper {
* @param planTaskId * @param planTaskId
* @return * @return
*/ */
List<PlanTaskPointInputItemBo> getPlanTaskPointInputItemByPlanTaskId(@Param(value = "planTaskId") Long planTaskId, @Param(value = "planTaskDetailStatus") String planTaskDetailStatus); List<PlanTaskPointInputItemBo> getPlanTaskPointInputItemByPlanTaskId(@Param(value = "planTaskId") Long planTaskId,
@Param(value = "planTaskDetailStatus") String planTaskDetailStatus,
@Param(value = "planTaskDetailIsFinish") String planTaskDetailIsFinish);
/** /**
* 条件查询数据 * 条件查询数据
......
...@@ -3,19 +3,20 @@ package com.yeejoin.amos.patrol.business.data; ...@@ -3,19 +3,20 @@ package com.yeejoin.amos.patrol.business.data;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil; import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.component.robot.AmosRequestContext; import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant; import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckInputMapper; import com.yeejoin.amos.patrol.business.dao.mapper.CheckInputMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper; import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskDetailMapper; import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskDetailMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper; import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.*; import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.patrol.business.dto.CheckRecordDataDto; import com.yeejoin.amos.patrol.business.dto.CheckRecordDataDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo; import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum; import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailIsFinishEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum; import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.patrol.dao.entity.*; import com.yeejoin.amos.patrol.dao.entity.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -125,7 +126,7 @@ public class CheckRecordDataConsumer implements Runnable { ...@@ -125,7 +126,7 @@ public class CheckRecordDataConsumer implements Runnable {
List<Check> checks = new ArrayList<>(); List<Check> checks = new ArrayList<>();
List<CheckInput> checkInputs = new ArrayList<>(); List<CheckInput> checkInputs = new ArrayList<>();
planTasks.forEach(planTask -> { planTasks.forEach(planTask -> {
List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.QUALIFIED.getValue()); List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.QUALIFIED.getValue(), Objects.toString(PlanTaskDetailIsFinishEnum.UNFINISHED.getValue()));
Map<Long, Check> checkMap = new HashMap<>(); Map<Long, Check> checkMap = new HashMap<>();
Map<String, String> deptMap = new HashMap<>(); Map<String, String> deptMap = new HashMap<>();
StringBuffer deptName = new StringBuffer(); StringBuffer deptName = new StringBuffer();
......
...@@ -599,7 +599,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -599,7 +599,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
*/ */
private void handleEsPlanTaskListPointsByIds(List<String> taskDetailIds, List<String> taskIds) { private void handleEsPlanTaskListPointsByIds(List<String> taskDetailIds, List<String> taskIds) {
taskIds.forEach(taskId -> esPlanTaskList.findById(taskId).ifPresent(esPlanTaskListDto -> { taskIds.forEach(taskId -> esPlanTaskList.findById(taskId).ifPresent(esPlanTaskListDto -> {
List<PlanTaskDetail> points = (List<PlanTaskDetail>) esPlanTaskListDto.getPoints(); List<PlanTaskDetail> points = esPlanTaskListDto.getPoints();
List<PlanTaskDetail> filterPoints = points.stream().filter(point -> !taskDetailIds.contains(Objects.toString(point.getId()))).collect(Collectors.toList()); List<PlanTaskDetail> filterPoints = points.stream().filter(point -> !taskDetailIds.contains(Objects.toString(point.getId()))).collect(Collectors.toList());
esPlanTaskList.deleteById(taskId); esPlanTaskList.deleteById(taskId);
if (!filterPoints.isEmpty()) { if (!filterPoints.isEmpty()) {
......
...@@ -404,7 +404,7 @@ public class JobService implements IJobService { ...@@ -404,7 +404,7 @@ public class JobService implements IJobService {
* @param planTask * @param planTask
*/ */
private void createOmissionCheckRecord(PlanTask planTask) { private void createOmissionCheckRecord(PlanTask planTask) {
List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.OMISSION.getValue()); List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.OMISSION.getValue(),Objects.toString(PlanTaskDetailIsFinishEnum.OVERTIME.getValue()));
Map<Long, Check> checkMap = new HashMap<>(); Map<Long, Check> checkMap = new HashMap<>();
Set<Long> checkIds = new HashSet<Long>(); Set<Long> checkIds = new HashSet<Long>();
Map<String, String> deptMap = new HashMap<>(); Map<String, String> deptMap = new HashMap<>();
...@@ -565,7 +565,7 @@ public class JobService implements IJobService { ...@@ -565,7 +565,7 @@ public class JobService implements IJobService {
* @param planTask * @param planTask
*/ */
public void createCheckRecord(PlanTask planTask, String userId) { public void createCheckRecord(PlanTask planTask, String userId) {
List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.QUALIFIED.getValue()); List<PlanTaskPointInputItemBo> planTaskPointInputItems = planTaskMapper.getPlanTaskPointInputItemByPlanTaskId(planTask.getId(), PlanTaskDetailStatusEnum.QUALIFIED.getValue(),null);
Map<Long, Check> checkMap = new HashMap<>(); Map<Long, Check> checkMap = new HashMap<>();
Map<String, String> deptMap = new HashMap<>(); Map<String, String> deptMap = new HashMap<>();
StringBuffer deptName = new StringBuffer(); StringBuffer deptName = new StringBuffer();
......
...@@ -534,6 +534,9 @@ ...@@ -534,6 +534,9 @@
WHERE WHERE
pptd.task_no = ptd.id pptd.task_no = ptd.id
AND ptd.id = #{planTaskId} and pptd.status = #{planTaskDetailStatus} AND ptd.id = #{planTaskId} and pptd.status = #{planTaskDetailStatus}
<if test="planTaskDetailIsFinish != null and planTaskDetailIsFinish !=''" >
and pptd.is_finish = #{planTaskDetailIsFinish}
</if>
) temp2 on(temp1.point_id = temp2.pointId ) temp2 on(temp1.point_id = temp2.pointId
AND temp1.route_id = temp2.routeId) AND temp1.route_id = temp2.routeId)
......
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