Commit 2849528f authored by hezhuozhi's avatar hezhuozhi

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

parents 941d7052 469ff0f2
package com.yeejoin.amos.boot.module.jg.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum RegistrationTypeEnum {
新设备首次启用("新设备首次启用","DJ_SY"),
历史无证设备登记("历史无证设备登记","SP_TT");
private String name;
private String code;
public static String getNameByType(String code) {
String name = null;
for (RegistrationTypeEnum enumOne : RegistrationTypeEnum.values()) {
if (enumOne.getCode().equals(code)) {
name = enumOne.getName();
break;
}
}
return name;
}
}
......@@ -4,6 +4,7 @@ import lombok.Getter;
/**
* 业务类型枚举
* 枚举code需同字典表中问题类型(type=ISSUE_TYPE)code保持一致
*
* @author Administrator
*/
......@@ -18,7 +19,7 @@ public enum SafetyProblemTypeEnum {
WBCQ("1", "维保超期", "设备维保超期", "safetyProblemTracing/wb/cq", "outOfMaintenanceRecords"),
WBBA("11", "维保合同备案", "设备维保合同备案", "safetyProblemTracing/wb/ba", null),
XKCQ("3", "许可超期", "企业许可超期", "safetyProblemTracing/xk/cq", null),
ZZCQ("4", "人员资质超期", "人员资质超期", "safetyProblemTracing/zz/cq", null);
ZZCQ("9", "资质超期", "人员资质超期", "safetyProblemTracing/zz/cq", null);
private final String code;
......
......@@ -92,6 +92,8 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
List<Map<String,Object>> getUseRegisterCount(@Param("orgCode")String orgCode);
List<Map<String,Object>> getUseRegisterCountTotal();
List<Map<String, Object>> getElevatorModeList(@Param("equIds") List<String> equIds);
List<Map<String, Object>> getCylinderInfoList(@Param("records") List<String> records);
......
......@@ -2561,7 +2561,7 @@
ei.unit_type unitType,
ei.supervise_org_code superviseOrgCode,
ei.supervise_org_name superviseOrgName,
ul.sequence_nbr licenceSeq,
ul.sequence_nbr problemSourceId,
ul.cert_no certNo,
ul.expiry_date expiryDate,
ul.item_code itemCode,
......@@ -2625,7 +2625,7 @@
ei.unit_type unitType,
ei.supervise_org_code superviseOrgCode,
ei.supervise_org_name superviseOrgName,
tup.sequence_nbr permissionSeq,
tup.sequence_nbr problemSourceId,
tup.cert_no certNo,
tup.expiry_date expiryDate,
tui.name userName,
......
......@@ -74,14 +74,14 @@
AND isn.use_unit_credit_code = #{param.useUnitCreditCode}
</if>
<if test="param.orgBranchCode != null and param.orgBranchCode != ''">
<choose>
<when test="client == 'jgAudit'">
AND isn.org_branch_code= #{param.orgBranchCode}
</when>
<otherwise>
AND isn.org_branch_code LIKE concat(#{param.orgBranchCode},'%')
</otherwise>
</choose>
<choose>
<when test="client == 'jgLook'">
AND isn.org_branch_code LIKE concat(#{param.orgBranchCode},'%')
</when>
<otherwise>
AND isn.org_branch_code= #{param.orgBranchCode}
</otherwise>
</choose>
</if>
</if>
<if test="type == 'supervision'">
......
......@@ -267,13 +267,11 @@
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgAudit'">
and supervisionOrgCode = #{dto.orgBranchCode}
<when test="client == 'jgLook'">
and supervisionOrgCode like concat(#{dto.orgBranchCode},'%')
</when>
<otherwise>
and supervisionOrgCode like concat(#{dto.orgBranchCode},'%')
and supervisionOrgCode = #{dto.orgBranchCode}
</otherwise>
</choose>
</if>
......@@ -350,11 +348,11 @@
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgAudit'">
and supervision_org_code = #{dto.orgBranchCode}
<when test="client == 'jgLook'">
and supervisionOrgCode like concat(#{dto.orgBranchCode},'%')
</when>
<otherwise>
and supervision_org_code like concat(#{dto.orgBranchCode},'%')
and supervisionOrgCode = #{dto.orgBranchCode}
</otherwise>
</choose>
</if>
......@@ -524,6 +522,7 @@
NEXT_INSPECT_DATE as nextInspectDate,
INSPECT_REPORT as inspectReport,
INSPECT_ORG_CODE as inspectOrgCode,
INSPECT_REPORT_NO as inspectReportNo,
SEQUENCE_NBR as jySeq
from idx_biz_jg_inspection_detection_info
where
......@@ -606,7 +605,8 @@
INSPECT_DATE as inspectDate,
INSPECT_STAFF as inspectStaff,
NEXT_INSPECT_DATE as nextInspectDate,
INSPECT_REPORT as inspectReport
INSPECT_REPORT as inspectReport,
INSPECT_REPORT_NO as inspectReportNo
FROM "idx_biz_jg_inspection_detection_info"
where
RECORD = #{id}
......@@ -1306,4 +1306,20 @@
)
</update>
<select id="getUseRegisterCountTotal" resultType="java.util.Map">
SELECT
date_format(A.audit_pass_date, '%Y-%m') AS time,
A.supervision_org_code AS supervisionOrgCode
FROM
"tzs_jg_use_registration_eq" ae
JOIN tzs_jg_use_registration A ON A.sequence_nbr = ae.equip_transfer_id
JOIN "idx_biz_jg_use_info" u ON ae.equ_id = u."RECORD"
JOIN idx_biz_jg_register_info ri ON u."RECORD" = ri."RECORD"
WHERE
ae.equ_id = u."RECORD"
AND ri.EQU_CATEGORY = '2300'
AND A.status = '已完成'
AND A.is_delete = 0
AND A.supervision_org_code is not null
</select>
</mapper>
......@@ -36,21 +36,20 @@
and tjvi.use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.dataType == 'supervision' and client == 'jgAudit' ">
AND tjvi.receive_company_code = #{dto.useUnitCreditCode}
AND tjvi.receive_company_code = #{dto.useUnitCreditCode}
AND tjvi.status <![CDATA[<>]]> '使用单位待提交'
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
and tjvi.org_branch_code = #{dto.orgBranchCode}
</if>
</if>
<if test="dto.dataType == 'company' ">
and tjvi.use_unit_credit_code = #{dto.useUnitCreditCode}
<if test="dto.dataType == 'supervision' and client != 'jgAudit' ">
AND tjvi.org_branch_code LIKE CONCAT(#{dto.orgBranchCode}, '%')
</if>
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
<choose>
<when test="client == 'jgAudit'">
and tjvi.org_branch_code = #{dto.orgBranchCode}
</when>
<otherwise>
AND tjvi.org_branch_codeLIKE CONCAT(#{dto.orgBranchCode}, '%')
</otherwise>
</choose>
<if test="dto.dataType == 'company'">
and tjvi.use_unit_credit_code = #{dto.useUnitCreditCode}
<if test="dto.orgBranchCode != null and dto.orgBranchCode != ''">
and tjvi.org_branch_code = #{dto.orgBranchCode}
</if>
</if>
</where>
order by
......
......@@ -55,7 +55,7 @@
and spt.principal_unit like CONCAT('%', #{problemModel.principalUnit}, '%')
</if>
<if test="problemModel.principalUnitType != null and problemModel.principalUnitType != ''">
and spt.principal_unit_type = #{problemModel.principalUnitType}
and spt.principal_unit_type = like CONCAT('%', #{problemModel.principalUnitType}, '%')
</if>
<if test="problemModel.hiddenDangersLevel != null and problemModel.hiddenDangersLevel != ''">
and spt.problem_status_code = #{problemModel.hiddenDangersLevel}
......
......@@ -144,7 +144,9 @@ public class JgVehicleInformationController extends BaseController {
dto.setDataType(BaseController.COMPANY_TYPE_COMPANY);
} else {
dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION);
dto.setOrgBranchCode(dto.getOrgBranchCode() != null ? dto.getOrgBranchCode() : info.getCompany().getOrgCode());
if("jgLook".equals(client)){
dto.setOrgBranchCode(dto.getOrgBranchCode() != null ? dto.getOrgBranchCode() : info.getCompany().getOrgCode());
}
}
Page<Map<String, Object>> list = jgVehicleInformationServiceImpl.getPageList(dto,sort, page, dto.getRoleIds(), client);
list.getRecords().forEach(x -> {
......
......@@ -251,20 +251,19 @@ public class SafetyProblemTracingController extends BaseController {
safetyProblemTracingGenService.executeMaintenanceCheck();
return ResponseHelper.buildResponse("success");
}
/**
* test3
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "生成维保超期数据", notes = "生成维保超期数据")
@ApiOperation(httpMethod = "GET", value = "生成人员资质超期数据", notes = "生成人员资质超期数据")
@GetMapping(value = "/gen/test4")
public ResponseModel<String> test4() {
safetyProblemTracingGenService.executePersonnalCertificationCheck();
return ResponseHelper.buildResponse("success");
}
/**
* update3 -- 修复
*
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemSourceTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.event.SafetyProblemEvent;
import com.yeejoin.amos.boot.module.jg.api.event.handler.SafetyProblemEventHandler;
......@@ -38,6 +39,12 @@ public class XKCQEventHandler implements SafetyProblemEventHandler {
}
private void generateProblem(JSONArray jsonArray) {
jsonArray.forEach(item -> {
JSONObject problemObj = (JSONObject) item;
problemObj.put("sourceType", SafetyProblemSourceTypeEnum.UNIT.getName());
problemObj.put("sourceTypeCode", SafetyProblemSourceTypeEnum.UNIT.getCode());
problemObj.put("problemDesc", "证书编号:" + problemObj.get("certNo") + SafetyProblemTypeEnum.XKCQ.getName());
});
SafetyProblemTopicMessage.generateUnitProblem(jsonArray, SafetyProblemTypeEnum.XKCQ, safetyProblemTracingService);
}
}
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.handler;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemSourceTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.event.SafetyProblemEvent;
import com.yeejoin.amos.boot.module.jg.api.event.handler.SafetyProblemEventHandler;
......@@ -38,6 +39,12 @@ public class ZZCQEventHandler implements SafetyProblemEventHandler {
}
private void generateProblem(JSONArray jsonArray) {
jsonArray.forEach(item -> {
JSONObject problemObj = (JSONObject) item;
problemObj.put("sourceType", SafetyProblemSourceTypeEnum.PERSONNEL.getName());
problemObj.put("sourceTypeCode", SafetyProblemSourceTypeEnum.PERSONNEL.getCode());
problemObj.put("problemDesc", "证书编号:" + problemObj.getOrDefault("certNo", "") + SafetyProblemTypeEnum.ZZCQ.getName());
});
SafetyProblemTopicMessage.generatePersonnelProblem(jsonArray, SafetyProblemTypeEnum.ZZCQ, safetyProblemTracingService);
}
}
......
......@@ -151,6 +151,10 @@ public class SafetyProblemTopicMessage extends EmqxListener {
}
public static void generateUnitProblem(JSONArray jsonArray, SafetyProblemTypeEnum problemTypeEnum, SafetyProblemTracingServiceImpl safetyProblemTracingService) {
generateProblem2(jsonArray, problemTypeEnum, safetyProblemTracingService);
}
private static void generateProblem2(JSONArray jsonArray, SafetyProblemTypeEnum problemTypeEnum, SafetyProblemTracingServiceImpl safetyProblemTracingService) {
if (jsonArray == null || problemTypeEnum == null) {
throw new IllegalArgumentException("jsonObject and problemTypeEnum must not be null.");
}
......@@ -163,10 +167,10 @@ public class SafetyProblemTopicMessage extends EmqxListener {
SafetyProblemTracing safetyProblemTracing = new SafetyProblemTracing();
safetyProblemTracing.setProblemType(problemTypeEnum.getName());
safetyProblemTracing.setProblemTypeCode(problemTypeEnum.getCode());
safetyProblemTracing.setProblemDesc(problemTypeEnum.getDesc() + "-" + json.getOrDefault("itemName", "") + "-" + json.getOrDefault("subItemName", ""));
safetyProblemTracing.setSourceType(SafetyProblemSourceTypeEnum.UNIT.getName());
safetyProblemTracing.setSourceTypeCode(SafetyProblemSourceTypeEnum.UNIT.getCode());
safetyProblemTracing.setSourceId(json.getOrDefault("licenceSeq", "").toString());
safetyProblemTracing.setProblemDesc(json.getString("problemDesc"));
safetyProblemTracing.setSourceType(json.getString("sourceType"));
safetyProblemTracing.setSourceTypeCode(json.getString("sourceTypeCode"));
safetyProblemTracing.setSourceId(json.getString("problemSourceId"));
safetyProblemTracing.setProblemTime(new Date());
safetyProblemTracing.setPrincipalUnit(json.getOrDefault("useUnit", "").toString());
safetyProblemTracing.setPrincipalUnitCode(json.getOrDefault("useUnitCode", "").toString());
......@@ -187,39 +191,7 @@ public class SafetyProblemTopicMessage extends EmqxListener {
}
public static void generatePersonnelProblem(JSONArray jsonArray, SafetyProblemTypeEnum problemTypeEnum, SafetyProblemTracingServiceImpl safetyProblemTracingService) {
if (jsonArray == null || problemTypeEnum == null) {
throw new IllegalArgumentException("jsonObject and problemTypeEnum must not be null.");
}
if (!ValidationUtil.isEmpty(jsonArray)) {
List<SafetyProblemTracing> safetyProblemTracingList = jsonArray.stream().map(item -> {
if (!(item instanceof JSONObject)) {
throw new IllegalArgumentException("item is not a JSONObject.");
}
JSONObject json = (JSONObject) item;
SafetyProblemTracing safetyProblemTracing = new SafetyProblemTracing();
safetyProblemTracing.setProblemType(problemTypeEnum.getName());
safetyProblemTracing.setProblemTypeCode(problemTypeEnum.getCode());
safetyProblemTracing.setProblemDesc(problemTypeEnum.getDesc() + "-" + json.getOrDefault("userName", "") + "-" + json.getOrDefault("certNo", ""));
safetyProblemTracing.setSourceType(SafetyProblemSourceTypeEnum.PERSONNEL.getName());
safetyProblemTracing.setSourceTypeCode(SafetyProblemSourceTypeEnum.PERSONNEL.getCode());
safetyProblemTracing.setSourceId(json.getOrDefault("permissionSeq", "").toString());
safetyProblemTracing.setProblemTime(new Date());
safetyProblemTracing.setPrincipalUnit(json.getOrDefault("useUnit", "").toString());
safetyProblemTracing.setPrincipalUnitCode(json.getOrDefault("useUnitCode", "").toString());
safetyProblemTracing.setPrincipalUnitType(json.getOrDefault("unitType", "").toString());
safetyProblemTracing.setGoverningBody(json.getOrDefault("superviseOrgName", "").toString());
safetyProblemTracing.setGoverningBodyCode(json.getOrDefault("useUnitCode", "").toString());
safetyProblemTracing.setGoverningBodyOrgCode(json.getOrDefault("superviseOrgCode", "").toString());
safetyProblemTracing.setCreateDate(new Date());
safetyProblemTracing.setProblemStatus(SafetyProblemStatusEnum.UNHANDLED.getName());
safetyProblemTracing.setProblemStatusCode(SafetyProblemStatusEnum.UNHANDLED.getCode());
return safetyProblemTracing;
}).collect(Collectors.toList());
safetyProblemTracingService.saveOrUpdateBatchByColumns(safetyProblemTracingList,
safetyProblemTracing -> new QueryWrapper<>()
.eq("problem_type_code", safetyProblemTracing.getProblemTypeCode())
.eq("source_id", safetyProblemTracing.getSourceId())
.eq("problem_status_code", SafetyProblemStatusEnum.UNHANDLED.getCode()));}
generateProblem2(jsonArray, problemTypeEnum, safetyProblemTracingService);
}
public String buildTopic(String topic) {
......
......@@ -2261,6 +2261,10 @@ public class CommonServiceImpl implements ICommonService {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
Pattern timePattern = Pattern.compile("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}");
//登记类型
if (jsonObject.containsKey("type")){
formData.put("registrationType",RegistrationTypeEnum.getNameByType(jsonObject.getString("type")));
}
for (String key : formData.keySet()) {
if (key.contains("Date") && timePattern.matcher(formData.getString(key)).matches()){
// 解析原始日期时间字符串
......@@ -2276,10 +2280,10 @@ public class CommonServiceImpl implements ICommonService {
}
//施工单位及检测监管部门赋值 车用气瓶模版
if (formData.containsKey("installUnitCode") && formData.getString("installUnitCode").contains("_")){
formData.put("installUnitName",formData.getString("installUnitCode").split("_")[0]);
formData.put("installUnitName",formData.getString("installUnitCode").split("_")[1]);
}
if (formData.containsKey("inspectUnitCreditCode") && formData.getString("inspectUnitCreditCode").contains("_")){
formData.put("inspectUnitName",formData.getString("inspectUnitCreditCode").split("_")[0]);
formData.put("inspectUnitName",formData.getString("inspectUnitCreditCode").split("_")[1]);
}
//管理员赋值 车用气瓶模版
if (formData.containsKey("safetyManagerId") && formData.getString("safetyManagerId").contains("_")){
......@@ -2307,7 +2311,7 @@ public class CommonServiceImpl implements ICommonService {
formData.put("productName", formData.getString("projectContraption"));
}
//单位模版 部分字段需从设备列表中获取
if (formData.containsKey("equipmentLists")){
if (formData.containsKey("equipmentLists") ){
JSONArray equipmentLists = formData.getJSONArray("equipmentLists");
List<Map<String, Object>> equips = equipmentLists.stream()
.filter(obj -> obj instanceof Map)
......@@ -2337,7 +2341,6 @@ public class CommonServiceImpl implements ICommonService {
productName = String.join(",", sortedProductNameList);
}
formData.put("productName",productName);
}else if (manageType.equals(VEHICLE) && !CollectionUtils.isEmpty(equips)){
//气瓶数量
formData.put("gasNum",equips.size());
......
......@@ -316,11 +316,15 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
*/
private void delRepeatUseEquipData(JgChangeRegistrationName notice) {
if (NOT_FLOWING_STATE.contains(notice.getAuditStatus())) {
LambdaQueryWrapper<JgChangeRegistrationNameEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgChangeRegistrationNameEq::getNameChangeRegistrationId, notice.getSequenceNbr());
List<JgChangeRegistrationNameEq> noticeEqList = jgChangeRegistrationNameEqMapper.selectList(queryWrapper);
noticeEqList.forEach(noticeEq -> EquipUsedCheckStrategyContext.getUsedStrategy(CHANGE_NAME_KEY)
.delDataForCheckEquipRepeatUsed(Collections.singletonList(noticeEq.getCertificateSeq()), notice.getUseUnitCreditCode())
final String creditCode = notice.getUseUnitCreditCode().contains("_")
? notice.getUseUnitCreditCode().substring(notice.getUseUnitCreditCode().indexOf("_") + 1)
: notice.getUseUnitCreditCode();
jgChangeRegistrationNameEqMapper.selectList(
new LambdaQueryWrapper<JgChangeRegistrationNameEq>()
.eq(JgChangeRegistrationNameEq::getNameChangeRegistrationId, notice.getSequenceNbr())
).forEach(noticeEq ->
EquipUsedCheckStrategyContext.getUsedStrategy(CHANGE_NAME_KEY)
.delDataForCheckEquipRepeatUsed(Collections.singletonList(noticeEq.getCertificateSeq()), creditCode)
);
}
}
......
......@@ -2524,10 +2524,12 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (CollectionUtils.isNotEmpty(equipmentLists)) {
equipmentLists.stream()
.map(obj -> (JSONObject) obj)
.peek(equipmentItem -> equipmentItem.put("useDate", timeToMonths(useDateValue)))
.filter(equipmentItem -> this.checkEquStatusInUse(equipmentItem.getString("record")))
.filter(equipmentItem -> addedEquCodes.add(equipmentItem.getString("equCode")))
.forEach(allEquipment::add);
.forEach(item ->{
item.put("useDate", timeToMonths(useDateValue));
allEquipment.add(item);
addedEquCodes.add(item.getString("equCode"));
});
}
});
total = allEquipment.size();
......@@ -2853,7 +2855,6 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if (!ObjectUtils.isEmpty(maintenanceDetail)) {
jsonObject.putAll(maintenanceDetail);
}
}
public void fillLastEquipBaseInfo(JSONObject jsonObject, String record) {
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -14,7 +15,6 @@ import com.yeejoin.amos.boot.module.jg.api.enums.SafetyProblemTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgOtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.eclipse.paho.client.mqttv3.MqttException;
......@@ -57,8 +57,6 @@ public class SafetyProblemTracingGenServiceImpl{
private SafetyProblemTracingServiceImpl safetyProblemTracingService;
@Autowired
TzBaseEnterpriseInfoMapper baseEnterpriseInfoMapper;
@Autowired
TzsUserInfoMapper tzsUserInfoMapper;
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "executeSafetyProblemCheck", lockAtMostFor = "PT5H", lockAtLeastFor = "PT10M")
......@@ -67,8 +65,9 @@ public class SafetyProblemTracingGenServiceImpl{
executeInspectionCheck();
executeEnterpriseQualificationCheck();
}
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "executeSafetyProblemCheck", lockAtMostFor = "PT5H", lockAtLeastFor = "PT10M")
@SchedulerLock(name = "executePersonnalCertification", lockAtMostFor = "PT5H", lockAtLeastFor = "PT10M")
public void executePersonnalCertification() {
executePersonnalCertificationCheck();
}
......@@ -185,11 +184,13 @@ public class SafetyProblemTracingGenServiceImpl{
*/
private void sendSafetyProblemMessage(List<Map<String, Object>> mapList, SafetyProblemTypeEnum safetyProblemTypeEnum) {
JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(mapList));
try {
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage());
throw new RuntimeException(e);
if (CollectionUtil.isNotEmpty(jsonArray)){
try {
emqKeeper.getMqttClient().publish(safetyProblemTypeEnum.getTopic(), jsonArray.toString().getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
logger.error("发送安全追溯问题设备信息消息失败---->{}", e.getMessage());
throw new RuntimeException(e);
}
}
}
}
\ No newline at end of file
......@@ -1344,7 +1344,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
String test = QueryParser.escape(map.getString("USE_INNER_CODE"));
boolMust.must(QueryBuilders.matchPhraseQuery("USE_INNER_CODE", test));
}
this.setFilterOfInFlowing(boolMust, map.getString("EQU_LIST_CODE"), map.getString("inspectionType"));
this.setFilterOfInFlowing(boolMust, map.getString("EQU_LIST_CODE"), map.getString("inspectionType"), map.getString("EQU_CATEGORY_CODE"));
builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
builder.from((pageNumber - 1) * size);
......@@ -1382,14 +1382,16 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 过滤条件去掉流程中的设备,
*
* @param boolMust 条件
* @param boolMust 条件
* @param equCategoryCode
*/
private void setFilterOfInFlowing(BoolQueryBuilder boolMust, String equListCode, String inspectionType) {
private void setFilterOfInFlowing(BoolQueryBuilder boolMust, String equListCode, String inspectionType, String equCategoryCode) {
Set<String> records = this.getEquipInFlowing();
if (records != null && !records.isEmpty()) {
boolMust.mustNot(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records));
}
if ("5000".equals(equListCode) && JYJCBusinessTypeEnum.SCJY.getCode().equals(inspectionType)) {
// 流动时起重机械及厂车可直接做首检
if (("5000".equals(equListCode) || "4400".equals(equCategoryCode)) && JYJCBusinessTypeEnum.SCJY.getCode().equals(inspectionType)) {
boolMust.must(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", false));
} else {
BoolQueryBuilder shouldBuilder = QueryBuilders.boolQuery();
......
package com.yeejoin.amos.boot.module.statistics.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @author system_generator
* @date 2025-02-21
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="CylinderBusinessStatisticsDto", description="")
public class CylinderBusinessStatisticsDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "年月")
private String time;
@ApiModelProperty(value = "总数")
private Long num;
@ApiModelProperty(value = "机构代码")
private String supervisionOrgCode;
}
package com.yeejoin.amos.boot.module.statistics.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
*
*
* @author system_generator
* @date 2025-02-21
*/
@Data
@Accessors(chain = true)
@TableName("tzs_cylinder_business_statistics")
public class CylinderBusinessStatistics implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(
value = "SEQUENCE_NBR",
type = IdType.ID_WORKER
)
protected Long sequenceNbr;
/**
* 年月
*/
@TableField("time")
private String time;
/**
* 总数
*/
@TableField("num")
private Long num;
/**
* 机构代码
*/
@TableField("supervision_org_code")
private String supervisionOrgCode;
public CylinderBusinessStatistics(String time, String supervisionOrgCode) {
this.time = time;
this.supervisionOrgCode = supervisionOrgCode;
}
}
package com.yeejoin.amos.boot.module.statistics.api.mapper;
import com.yeejoin.amos.boot.module.statistics.api.entity.CylinderBusinessStatistics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
*
* @author system_generator
* @date 2025-02-21
*/
public interface CylinderBusinessStatisticsMapper extends BaseMapper<CylinderBusinessStatistics> {
void deleteAll();
void insertBatch(@Param("list") List<CylinderBusinessStatistics> cylinderBusinessStatisticsList);
List<Map<String,Object>> getUseRegisterCount(@Param("orgCode")String orgCode);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper">
<insert id="insertBatch" parameterType="com.yeejoin.amos.boot.module.statistics.api.entity.CylinderBusinessStatistics">
insert into tzs_cylinder_business_statistics
(sequence_nbr, time, supervision_org_code, update_time) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.sequenceNbr},
#{item.time},
#{item.supervisionOrgCode},
CURRENT_TIMESTAMP
)
</foreach>
</insert>
<delete id="deleteAll">
delete from tzs_cylinder_business_statistics
</delete>
<select id="getUseRegisterCount" resultType="java.util.Map">
SELECT
C.time, -- 月份
COUNT(1) AS num -- 每月的记录数
FROM
tzs_cylinder_business_statistics C
WHERE
C.supervision_org_code LIKE '50%' -- 仅过滤 '50%' 开头的监管机构代码
GROUP BY
C.time -- 按月份分组
</select>
</mapper>
package com.yeejoin.amos.boot.module.statistcs.biz.job;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.statistics.api.entity.CylinderBusinessStatistics;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 定时任务统计
*
* @author LiuLin
*/
@EnableScheduling
@Component
@Slf4j
public class MonthCylinderBusinessStatisticsJob {
private final JgUseRegistrationMapper useRegistrationMapper;
private final CylinderBusinessStatisticsMapper businessStatisticsMapper;
public MonthCylinderBusinessStatisticsJob(JgUseRegistrationMapper useRegistrationMapper,
CylinderBusinessStatisticsMapper businessStatisticsMapper) {
this.useRegistrationMapper = useRegistrationMapper;
this.businessStatisticsMapper = businessStatisticsMapper;
}
@Scheduled(cron = "0 */5 * * * ?")
@SchedulerLock(name = "cylinderBusinessStatisticsJob", lockAtMostFor = "PT1H")
public void cylinderBusinessStatisticsJob() {
List<Map<String, Object>> useRegisterCountList = useRegistrationMapper.getUseRegisterCountTotal();
if (!CollectionUtils.isEmpty(useRegisterCountList)) {
businessStatisticsMapper.deleteAll();
List<CylinderBusinessStatistics> statisticsList = useRegisterCountList.stream()
.map(item -> new CylinderBusinessStatistics(
(String) item.get("time"),
(String) item.get("supervisionOrgCode")
))
.collect(Collectors.toList());
businessStatisticsMapper.insertBatch(statisticsList);
}
}
}
......@@ -306,11 +306,11 @@ public class CylinderDPStatisticsServiceImpl {
public Map<String, Object> getCylinderStatisticsDataByCityForTotal(DPFilterParamDto dpFilterParamDto) {
Map<String, Object> result = new HashMap<>();
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
getCylinderMapCount(orgCode, result);
getCylinderMapCount(orgCode, result, dpFilterParamDto.getCityCode());
return result;
}
private Map<String, Object> getCylinderMapCount(String orgCode, Map<String, Object> result) {
private void getCylinderMapCount(String orgCode, Map<String, Object> result, String cityCode) {
if (StringUtils.isNotEmpty(orgCode)) {
Long cylindersCount = this.countForCylinderNum(orgCode);
Long automotiveGasCount = this.countForCylinderNumForVehicleUsed(orgCode);
......@@ -330,15 +330,38 @@ public class CylinderDPStatisticsServiceImpl {
// 检验超期气瓶数
result.put("jycqsbCount", this.countForCylinderOverdueInspect(orgCode));
// 充气量
Long fillingVolumeCount = cylinderStatisticsMapper.countFillingVolumeCount(orgCode);
result.put("fillingVolumeCount", fillingVolumeCount == null ? 0L : new BigDecimal(fillingVolumeCount).divide(new BigDecimal("10000000")).setScale(3,RoundingMode.HALF_UP).toString());
// Long fillingVolumeCount = cylinderStatisticsMapper.countFillingVolumeCount(orgCode);
Double fillingVolumeCount = this.countFillingVolumeCount(cityCode);
BigDecimal value = new BigDecimal(fillingVolumeCount);
value = value.divide(new BigDecimal("1000"), 3, RoundingMode.HALF_UP);
String unit = (fillingVolumeCount == 0) ? "吨" : (fillingVolumeCount > 10000 ? "万吨" : "吨");
BigDecimal resultValue = (fillingVolumeCount > 10000000) ? value.divide(new BigDecimal("10000000"), 3, RoundingMode.HALF_UP) : value;
result.put("fillingVolumeCount", resultValue );
// 卸液量
Long dischargeVolumeCount = cylinderStatisticsMapper.countDischargeVolumeCount(orgCode);
result.put("dischargeVolumeCount", dischargeVolumeCount == null ? 0L : new BigDecimal(dischargeVolumeCount).divide(new BigDecimal("10000000")).setScale(3,RoundingMode.HALF_UP).toString());
} else {
this.setDefaultValueIfNoData(result, "cylindersCount", "stationCount", "operatorCount", "liquefiedGasCount", "automotiveGasCount", "industrialGasCount", "useRegistrationQuantityCount", "jylqsbCount", "jycqsbCount","fillingVolumeCount","dischargeVolumeCount");
}
return result;
}
/**
* 从ES查询总量
* @param cityCode
* @return
*/
private Double countFillingVolumeCount(String cityCode) {
DPFilterParamForDetailDto dpFilterParamForDetailDto = new DPFilterParamForDetailDto();
dpFilterParamForDetailDto.setCityCode(cityCode);
List<Map<String, Object>> list = this.getFillingQuantity(dpFilterParamForDetailDto, null, null);
return list.isEmpty()
? 0L
: list.stream()
.mapToDouble(e -> Optional.ofNullable(e.get("fillingQuantity"))
.map(f -> Double.parseDouble(f.toString()))
.orElse(0.0))
.sum();
}
/**
......@@ -422,7 +445,7 @@ public class CylinderDPStatisticsServiceImpl {
Map<String, Object> item = new HashMap<>();
item.put("regionCode", r.getRegionCode());
item.put("regionName", r.getRegionName());
getCylinderMapCount(orgCode, item);
getCylinderMapCount(orgCode, item, dpFilterParamDto.getCityCode());
return item;
}).collect(Collectors.toList());
}
......
......@@ -35,6 +35,7 @@ import com.yeejoin.amos.boot.module.jg.api.entity.SafetyProblemTracing;
import com.yeejoin.amos.boot.module.jg.api.enums.*;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.statistcs.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CylinderBusinessStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.JGStatisticsMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.ZLStatisticsMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
......@@ -180,6 +181,8 @@ public class JGDPStatisticsServiceImpl {
private JgUseRegistrationMapper useRegistrationMapper;
private CylinderBusinessStatisticsMapper businessStatisticsMapper;
private JgEnableDisableMapper enableDisableMapper;
private JgScrapCancelMapper scrapCancelMapper;
......@@ -277,8 +280,10 @@ public class JGDPStatisticsServiceImpl {
IdxBizJgTechParamsPipelineMapper idxBizJgTechParamsPipelineMapper,
IdxBizJgTechParamsElevatorMapper idxBizJgTechParamsElevatorMapper,
DataDictionaryServiceImpl iDataDictionaryService,
SafetyProblemTracingMapper safetyProblemTracingMapper) {
SafetyProblemTracingMapper safetyProblemTracingMapper,
CylinderBusinessStatisticsMapper businessStatisticsMapper) {
this.useRegistrationMapper = useRegistrationMapper;
this.businessStatisticsMapper = businessStatisticsMapper;
this.enableDisableMapper = enableDisableMapper;
this.scrapCancelMapper = scrapCancelMapper;
this.restHighLevelClient = restHighLevelClient;
......@@ -512,7 +517,7 @@ public class JGDPStatisticsServiceImpl {
List<Object> scrappedDeviceList = new ArrayList();
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM");
String orgCode = stCommonService.getAndSetOrgCode(dpFilterParamDto.getCityCode());
List<Map<String,Object>> useRegisterCountList = useRegistrationMapper.getUseRegisterCount(orgCode);
List<Map<String,Object>> useRegisterCountList = businessStatisticsMapper.getUseRegisterCount(orgCode);
List<Map<String,Object>> scrappedDeviceCountList = scrapCancelMapper.getScrappedDeviceCount(dpFilterParamDto);
Map<String,Object> useRegisterCount = new HashMap<>();
Map<String,Object> scrappedDeviceCount = new HashMap<>();
......
......@@ -2538,60 +2538,112 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*
* @param paramMap 更新的参数
*/
@Override
// @Override
// public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) {
// if (paramMap.isEmpty()) {
// return null;
// }
// String oldUscUnitCreditCode = "";
// String oldUscUnitName = "";
// Map<String, Object> resultMap = new HashMap<>();
// for (Map.Entry<String, Map<String, Object>> entry : paramMap.entrySet()) {
// String record = entry.getKey();
// Map<String, Object> childMap = entry.getValue();
// if (!childMap.isEmpty()) {
// ESEquipmentCategoryDto oldData = null;
// // 获取Es中旧的数据
// Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
// if (!ObjectUtils.isEmpty(optional)) {
// oldData = optional.get();
// oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE();
// oldUscUnitName = oldData.getUSC_UNIT_NAME();
// }
// // 获取Es中新的参数
// ESEquipmentCategoryDto newData = JSON.parseObject(toJSONString(childMap), ESEquipmentCategoryDto.class);
// String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
// String newUscUnitName = newData.getUSC_UNIT_NAME();
//
// // 删除Es中旧的数据
// if (!ObjectUtils.isEmpty(oldData)) {
// esEquipmentCategory.deleteById(record);
// // 整合新旧数据
// Bean.copyExistPropertis(newData, oldData);
// // 处理施工单位信息[去重]
// if (!ValidationUtil.isEmpty(newUscUnitCreditCode)) {
// // if (!ValidationUtil.isEmpty(oldUscUnitCreditCode)) {
// // if (!oldUscUnitCreditCode.contains(newUscUnitCreditCode)) {
// // oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode + "," + newUscUnitCreditCode);
// // oldData.setUSC_UNIT_NAME(oldUscUnitName + "," + newUscUnitName);
// // }
// // } else {
// oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
// oldData.setUSC_UNIT_NAME(newUscUnitName);
// // }
// }
//
// }
// if (!ObjectUtils.isEmpty(oldData)) {
// oldData.setREC_DATE(System.currentTimeMillis());
// ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
//
// // 组装返回数据
// resultMap.put(record, saveData);
// }
// }
//
// }
// return resultMap;
// }
@Override
public Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap) {
if (paramMap.isEmpty()) {
return null;
}
String oldUscUnitCreditCode = "";
String oldUscUnitName = "";
Map<String, Object> resultMap = new HashMap<>();
Map<String, ESEquipmentCategoryDto> oldDataMap = new HashMap<>();
List<ESEquipmentCategoryDto> saveList = new ArrayList<>();
// 批量获取旧数据
for (String record : paramMap.keySet()) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
optional.ifPresent(dto -> oldDataMap.put(record, dto));
}
for (Map.Entry<String, Map<String, Object>> entry : paramMap.entrySet()) {
String record = entry.getKey();
Map<String, Object> childMap = entry.getValue();
if (!childMap.isEmpty()) {
ESEquipmentCategoryDto oldData = null;
// 获取Es中旧的数据
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if (!ObjectUtils.isEmpty(optional)) {
oldData = optional.get();
oldUscUnitCreditCode = oldData.getUSC_UNIT_CREDIT_CODE();
oldUscUnitName = oldData.getUSC_UNIT_NAME();
}
// 获取Es中新的参数
ESEquipmentCategoryDto newData = JSON.parseObject(toJSONString(childMap), ESEquipmentCategoryDto.class);
String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
String newUscUnitName = newData.getUSC_UNIT_NAME();
// 删除Es中旧的数据
if (!ObjectUtils.isEmpty(oldData)) {
esEquipmentCategory.deleteById(record);
// 整合新旧数据
ESEquipmentCategoryDto oldData = oldDataMap.get(record);
ESEquipmentCategoryDto newData = JSON.parseObject(JSON.toJSONString(childMap), ESEquipmentCategoryDto.class);
if (oldData != null) {
Bean.copyExistPropertis(newData, oldData);
// 处理施工单位信息[去重]
String newUscUnitCreditCode = newData.getUSC_UNIT_CREDIT_CODE();
String newUscUnitName = newData.getUSC_UNIT_NAME();
if (!ValidationUtil.isEmpty(newUscUnitCreditCode)) {
// if (!ValidationUtil.isEmpty(oldUscUnitCreditCode)) {
// if (!oldUscUnitCreditCode.contains(newUscUnitCreditCode)) {
// oldData.setUSC_UNIT_CREDIT_CODE(oldUscUnitCreditCode + "," + newUscUnitCreditCode);
// oldData.setUSC_UNIT_NAME(oldUscUnitName + "," + newUscUnitName);
// }
// } else {
oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(newUscUnitName);
// }
oldData.setUSC_UNIT_CREDIT_CODE(newUscUnitCreditCode);
oldData.setUSC_UNIT_NAME(newUscUnitName);
}
}
if (!ObjectUtils.isEmpty(oldData)) {
oldData.setREC_DATE(System.currentTimeMillis());
ESEquipmentCategoryDto saveData = esEquipmentCategory.save(oldData);
// 组装返回数据
resultMap.put(record, saveData);
saveList.add(oldData);
}
}
}
// 批量删除旧数据
esEquipmentCategory.deleteAll(oldDataMap.values());
// 批量保存新数据
Iterable<ESEquipmentCategoryDto> savedData = esEquipmentCategory.saveAll(saveList);
// 组装返回数据
Map<String, Object> resultMap = new HashMap<>();
savedData.forEach(dto -> resultMap.put(dto.getSEQUENCE_NBR(), dto));
return resultMap;
}
......
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