Commit 021497d0 authored by suhuiguang's avatar suhuiguang

1.检验检测消息功能开发

parent e339736a
......@@ -186,7 +186,7 @@ public class DataDictionaryController extends BaseController {
}
}
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getDataDictionary/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典", notes = "根据字典类型查询字典")
public ResponseModel<Object> getDataDictionary(@PathVariable String type) throws Exception {
......
package com.yeejoin.amos.api.openapi.controller;
import com.yeejoin.amos.api.openapi.feign.TzsTcmServiceFeignClient;
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.PathVariable;
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.ResponseModel;
/**
* @author Administrator
*/
@RestController
@RequestMapping(value = "/data-dict")
public class DataDictionaryController {
@Autowired
TzsTcmServiceFeignClient tzsTcmServiceFeignClient;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/{dictCode}/list")
@ApiOperation(httpMethod = "POST", value = "查询指定的字典列表", notes = "查询指定的字典列表")
public ResponseModel<Object> dictList(@PathVariable String dictCode) {
return tzsTcmServiceFeignClient.getDataDictionary(dictCode);
}
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.api.openapi.feign;
import com.yeejoin.amos.api.openapi.config.FeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -21,4 +22,13 @@ public interface TzsTcmServiceFeignClient {
@RequestMapping(value = "/baseEnterprise/getUnitLicenceMessage", method = RequestMethod.GET)
ResponseModel<Object> getLicenceByUnitCode(@RequestParam String unitCode);
/**
* 字段列表查询
* @param dictCode 字段类型
* @return 列表
*/
@RequestMapping(value = "/getDataDictionary/{dictCode}", method = RequestMethod.GET)
ResponseModel<Object> getDataDictionary(@PathVariable String dictCode);
}
......@@ -34,11 +34,11 @@ public class InspectionEquipData {
@ApiModelProperty(value = "使用/施工地址")
private String address;
@ApiModelProperty(value = "施工单位信用代码")
private String uscUnitCreditCode;
@ApiModelProperty(value = "使用/施工单位信用代码")
private String unitCreditCode;
@ApiModelProperty(value = "施工单位名称")
private String uscUnitCreditName;
@ApiModelProperty(value = "使用/施工单位名称")
private String unitCreditName;
@ApiModelProperty(value = "技术参数")
private Map<String, Object> techParams;
......
......@@ -26,6 +26,10 @@
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.yeejoin.amos;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -36,7 +37,7 @@ import java.net.UnknownHostException;
@EnableAsync
@EnableSwagger2WebMvc
@EnableEurekaClient
//@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "10m")
@MapperScan({"org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*",
"org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*",
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper"})
......
......@@ -175,7 +175,7 @@ public class CommonController extends BaseController {
@ApiOperation(httpMethod = "PUT", value = "检验消息提醒", notes = "检验消息提醒")
@PutMapping(value = "/test-tip")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel<String> testMsgTip(){
regularlyRemindJob.sendReminderMessage();
return ResponseHelper.buildResponse("succese");
......
......@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.jyjc.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcOpeningApplication;
......@@ -11,7 +10,6 @@ import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcOpeningApplicationRequstD
import com.yeejoin.amos.boot.module.jyjc.biz.config.BaseException;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcOpeningApplicationServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
......@@ -19,7 +17,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
......@@ -268,30 +265,6 @@ public class JyjcOpeningApplicationController extends BaseController {
}
/**
* 自动作废
*
* @param
* @return {@link ResponseModel< List< TzBaseEnterpriseInfo>>}
* @throws
* @author yangyang
* @date 2023/12/22 16:13
*/
@Scheduled(cron = "0 0 0 * * ?")
public void timingDiscard() {
List<Long> longs = jyjcOpeningApplicationServiceImpl.selectOverdueData();
if (CollectionUtils.isNotEmpty(longs)) {
for (Long aLong : longs) {
String remark = "到期作废";
jyjcOpeningApplicationServiceImpl.doDiscard(aLong, remark);
}
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/unit/list")
@ApiOperation(httpMethod = "GET", value = "查询指定设备所在地的检测机构", notes = "查询指定设备所在地的检测机构")
......
......@@ -181,10 +181,10 @@ public class InspectionApplicationPushEventListener implements ApplicationListen
private Map<String, Object> populateEquipInfoWithTechParams(String equList, String record) {
EquipCategoryEnum productType = EquipCategoryEnum.of(Integer.parseInt(equList));
switch (Objects.requireNonNull(productType)) {
// 锅炉 - 暂时之前的 需求未出
// 锅炉 - 监管未调整
case IDX_BIZ_JG_TECH_PARAMS_BOILER:
return BeanUtil.beanToMap(equipTechParamBoilerMapper.queryTechParamInUse(record));
// 压力容器 - 暂时之前的 需求未出
// 压力容器 - 监管未调整
case IDX_BIZ_JG_TECH_PARAMS_VESSEL:
return BeanUtil.beanToMap(equipTechParamVesselMapper.queryTechParamInUse(record));
// 电梯
......@@ -199,7 +199,7 @@ public class InspectionApplicationPushEventListener implements ApplicationListen
// 大型游乐设施
case IDX_BIZ_JG_TECH_PARAMS_RIDES:
return BeanUtil.beanToMap(equipTechParamRidesMapper.queryTechParamInUse(record));
// 压力管道 - 暂时之前的 需求未出
// 压力管道 - 监管未调整
case IDX_BIZ_JG_TECH_PARAMS_PIPELINE:
return BeanUtil.beanToMap(equipTechParamPipelineMapper.queryTechParamInUse(record));
// 客运索道
......@@ -227,8 +227,8 @@ public class InspectionApplicationPushEventListener implements ApplicationListen
wrapper.last("limit 1");
IdxBizJgConstructionInfo jgConstructionInfo = constructionInfoMapper.selectOne(wrapper);
if (jgConstructionInfo != null) {
equipData.setUscUnitCreditCode(jgConstructionInfo.getUscUnitCreditCode());
equipData.setUscUnitCreditName(jgConstructionInfo.getUscUnitName());
equipData.setUnitCreditCode(jgConstructionInfo.getUscUnitCreditCode());
equipData.setUnitCreditName(jgConstructionInfo.getUscUnitName());
}
}
......
......@@ -16,6 +16,10 @@ import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -25,7 +29,8 @@ import java.util.stream.Collectors;
/**
* @author Administrator
*/
@Service
@EnableScheduling
@Component
@Slf4j
public class InspectionExpireRemindJob {
......@@ -65,7 +70,8 @@ public class InspectionExpireRemindJob {
this.jyjcBaseMapper = jyjcBaseMapper;
}
@Scheduled(cron = "${inspection.expire.remind.job.cron:0 0 8 * * ?}")
@SchedulerLock(name = "sendReminderMessageJob", lockAtMostFor = "PT1H")
public void sendReminderMessage() {
// 1.查询临期和超期的设备
List<NeedTipEquipInfo> needTipEquipList = getNeedTipEquipList();
......@@ -80,7 +86,7 @@ public class InspectionExpireRemindJob {
// 查询需要进行消息提醒的设备集合
List<String> statusList = new ArrayList<>();
statusList.add(EquimentEnum.ZAIYONG.getCode().toString());
List<UseInfoModel> needTipEquipList = useInfoMapper.selecEquipInfotList(statusList, 30);
List<UseInfoModel> needTipEquipList = useInfoMapper.queryEquipOfExpireInspection(statusList, 30);
// 对象转换及管辖机构集合填充
return this.buildTipEquipInfoList(needTipEquipList);
}
......@@ -150,13 +156,19 @@ public class InspectionExpireRemindJob {
private void createTask(List<NeedTipEquipInfo> needTipEquipList) {
List<MessageModel> messageModels = new LinkedList<>();
needTipEquipList.parallelStream().forEach(e -> messageModels.add(this.buildTaskModel(e)));
needTipEquipList.forEach(e -> messageModels.add(this.buildTaskModel(e)));
String token = amosRequestContext.getToken();
String product = amosRequestContext.getProduct();
String appKey = amosRequestContext.getAppKey();
// 多线程messageModels.parallelStream().forEach平台无反应所以使用单线程
messageModels.forEach(m -> {
RequestContext.setToken(amosRequestContext.getToken());
RequestContext.setProduct(amosRequestContext.getProduct());
RequestContext.setAppKey(amosRequestContext.getAppKey());
// 多线程时设置,单线程可提到外层
RequestContext.setToken(token);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
log.info("开始调用平台创建消息:{}", JSONObject.toJSONString(m));
Systemctl.messageClient.create(m);
log.info("结束调用平台创建消息");
});
}
......
package com.yeejoin.amos.boot.module.jyjc.biz.job;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcOpeningApplicationServiceImpl;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author Administrator
*/
@EnableScheduling
@Component
@Slf4j
public class OpenApplicationTimingDiscardJob {
private JyjcOpeningApplicationServiceImpl jyjcOpeningApplicationServiceImpl;
public OpenApplicationTimingDiscardJob(JyjcOpeningApplicationServiceImpl jyjcOpeningApplicationServiceImpl) {
this.jyjcOpeningApplicationServiceImpl = jyjcOpeningApplicationServiceImpl;
}
/**
* 自动作废
*
* @author yangyang
* @date 2023/12/22 16:13
*/
@SchedulerLock(name = "timingDiscard", lockAtMostFor = "PT1H")
@Scheduled(cron = "0 0 0 * * ?")
public void timingDiscard() {
List<Long> longs = jyjcOpeningApplicationServiceImpl.selectOverdueData();
if (CollectionUtils.isNotEmpty(longs)) {
for (Long aLong : longs) {
String remark = "到期作废";
jyjcOpeningApplicationServiceImpl.doDiscard(aLong, remark);
}
}
}
}
......@@ -16,7 +16,13 @@ import java.util.List;
*/
public interface UseInfoMapper extends BaseMapper<UseInfo> {
List<UseInfoModel> selecEquipInfotList(@Param("statusList") List<String> statusList, @Param("interval") int interval);
/**
* 查询检验临期及超期的设备
* @param statusList 设备状态
* @param interval 间隔天
* @return 使用信息
*/
List<UseInfoModel> queryEquipOfExpireInspection(@Param("statusList") List<String> statusList, @Param("interval") int interval);
void updateByRecord(String record, Date nextInspectDate, String lastInspectType, String lastInspectReportNo);
}
......@@ -13,30 +13,38 @@
</update>
<select id="selecEquipInfotList" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.UseInfoModel">
SELECT
<select id="queryEquipOfExpireInspection" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.UseInfoModel">
select
a.*,
CASE (NEXT_INSPECT_DATE > CURRENT_DATE)
WHEN true THEN 1
ELSE 2
END as status
from
(SELECT
use.RECORD,
use.USE_UNIT_CREDIT_CODE,
register.EQU_CODE,
register.EQU_LIST,
use.NEXT_INSPECT_DATE as nextInspectDate,
supervision.ORG_BRANCH_CODE,
CASE (NEXT_INSPECT_DATE > CURRENT_DATE)
WHEN true THEN 1
ELSE 2
END as status
FROM
idx_biz_jg_use_info use
LEFT JOIN idx_biz_jg_register_info register on register.RECORD = use.RECORD
LEFT JOIN idx_biz_jg_supervision_info supervision on supervision.RECORD = use.RECORD
<where>
(select date_format(di.NEXT_INSPECT_DATE, 'yyyy-mm-dd') from idx_biz_jg_inspection_detection_info di where di."RECORD" = register."RECORD" and di.NEXT_INSPECT_DATE is not null and di."INSPECT_TYPE" <![CDATA[<>]]> '' order by di.NEXT_INSPECT_DATE desc limit 1) as NEXT_INSPECT_DATE
FROM
idx_biz_jg_use_info use
LEFT JOIN idx_biz_jg_register_info register on register.RECORD = use.RECORD
LEFT JOIN idx_biz_jg_supervision_info supervision on supervision.RECORD = use.RECORD
where
use."USE_UNIT_CREDIT_CODE" <![CDATA[<>]]> ''
and register.EQU_CODE <![CDATA[<>]]> ''
and supervision.ORG_BRANCH_CODE <![CDATA[<>]]> ''
and use."DATA_SOURCE" = 'jg'
<if test="statusList.size() > 0">
and EQU_STATE in
and use.EQU_STATE in
<foreach collection="statusList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
and (NEXT_INSPECT_DATE - CURRENT_DATE <![CDATA[<=]]> #{interval} or NEXT_INSPECT_DATE > CURRENT_DATE)
</where>
) a
where
NEXT_INSPECT_DATE - CURRENT_DATE <![CDATA[<=]]> #{interval} or NEXT_INSPECT_DATE > CURRENT_DATE
</select>
</mapper>
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