Commit 20c70720 authored by suhuiguang's avatar suhuiguang

feat(jg):更新null值调整

parents 3a71b1f6 cccc4d3d
...@@ -325,5 +325,6 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> { ...@@ -325,5 +325,6 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
*/ */
List<CountDto> countBizNumAfterUseRegBatchProjectContraption(@Param("projectContraptionIds") List<Long> projectContraptionIds); List<CountDto> countBizNumAfterUseRegBatchProjectContraption(@Param("projectContraptionIds") List<Long> projectContraptionIds);
List<Map<String, String>> gdEquOnJgServiceOperationRecords(@Param("record") String record);
} }
...@@ -3131,4 +3131,33 @@ ...@@ -3131,4 +3131,33 @@
) )
group by projectContraptionId group by projectContraptionId
</select> </select>
<select id="gdEquOnJgServiceOperationRecords" resultType="java.util.Map">
SELECT
tjri.sequence_nbr AS sequenceNbr,
tjri.business_type AS businessType,
tjri.apply_no AS applyNo,
tjri.rec_user_id AS recUserId,
tjri.rec_user_name AS recUserName,
DATE_FORMAT ( rec_date, '%Y-%m-%d %H:%i:%s' ) AS recDate,
tjri.approval_unit AS approvalUnit,
tjri.status,
tjri.route_path AS routePath
FROM
tzs_jg_resume_info tjri
JOIN (
SELECT tjri2.apply_no,
MAX ( tjri2.rec_date ) AS max_rec_date
FROM
tzs_jg_resume_info
tjri2 LEFT JOIN tzs_jg_installation_notice tjin ON tjri2.equ_id = tjin.project_contraption_id
LEFT JOIN tzs_jg_installation_notice_eq tjineq ON tjin.sequence_nbr = tjineq.equip_transfer_id
WHERE
tjineq.equ_id = 'c005586e-0065-4ee8-b89a-5fcad85d4868'
GROUP BY
tjri2.apply_no
) AS latest ON tjri.apply_no = latest.apply_no
AND tjri.rec_date = latest.max_rec_date
ORDER BY
tjri.rec_date ASC
</select>
</mapper> </mapper>
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
<select id="getListPage" resultType="java.util.Map"> <select id="getListPage" resultType="java.util.Map">
SELECT * FROM ( SELECT * FROM (
-- 查询 equListCode = '8000' 的情况 -- 查询 equListCode != '8000' 的情况
SELECT * SELECT *
FROM ( FROM (
<include refid="page-list-sub-select"/> <include refid="page-list-sub-select"/>
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
</where> </where>
UNION ALL UNION ALL
-- 查询 equListCode != '8000' 的情况 -- 查询 equListCode == '8000' 的情况
SELECT * SELECT *
FROM ( FROM (
<include refid="page-list-sub-pipline"/> <include refid="page-list-sub-pipline"/>
......
...@@ -283,4 +283,40 @@ public class DataHandlerController extends BaseController { ...@@ -283,4 +283,40 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(dataHandlerService.initFactoryCarNumber2Es()); return ResponseHelper.buildResponse(dataHandlerService.initFactoryCarNumber2Es());
} }
/**
* @apiNote 删除ES和数据库中状态≠已认领的设备
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "删除ES和数据库中状态≠已认领的设备(备份后谨慎操作,不可恢复)", notes = "删除ES和数据库中状态≠已认领的设备(备份后谨慎操作,不可恢复)")
@PutMapping(value = "/equip/deleteEquipWithStatusNotInClaimed")
public ResponseModel<Integer> deleteEquipWithStatusNotInClaimed(@RequestParam(value = "indices",defaultValue = "idx_biz_view_jg_all") String indices,
@RequestParam(value = "isDelete",defaultValue = "false") boolean isDelete) throws InterruptedException {
return ResponseHelper.buildResponse(dataHandlerService.deleteEquipWithStatusNotInClaimed(indices, isDelete));
}
/**
* @apiNote 删除数据库中状态≠已认领的设备
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "删除数据库中状态≠已认领的设备", notes = "删除数据库中状态≠已认领的设备")
@PutMapping(value = "/equip/deleteEquipExistDB")
public ResponseModel<Integer> deleteEquipExistDB(@RequestParam(value = "isDelete",defaultValue = "false") boolean isDelete) {
return ResponseHelper.buildResponse(dataHandlerService.deleteEquipExistDB(isDelete));
}
/**
* @apiNote 修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "PUT", value = "修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据", notes = "修改SupervisionInfo中ORG_BRANCH_CODE=%50*X%的数据")
@PutMapping(value = "/equip/deleteEquipExistDB")
public ResponseModel<Integer> deleteEquipExistDB2(@RequestParam(value = "isDelete",defaultValue = "false") boolean isDelete) {
return ResponseHelper.buildResponse(dataHandlerService.deleteEquipExistDB(isDelete));
}
} }
\ No newline at end of file
...@@ -786,6 +786,9 @@ public class CommonEquipDataProcessService { ...@@ -786,6 +786,9 @@ public class CommonEquipDataProcessService {
IdxBizJgConstructionInfo constructionInfo = jgUseRegistrationService.getIdxBizJgConstructionInfoService().queryNewestDetailByRecord(record); IdxBizJgConstructionInfo constructionInfo = jgUseRegistrationService.getIdxBizJgConstructionInfoService().queryNewestDetailByRecord(record);
BaseTechParamsFieldDto techParamsFieldDto = this.buildTechParamInfo(registerInfo, record); BaseTechParamsFieldDto techParamsFieldDto = this.buildTechParamInfo(registerInfo, record);
re.putAll(BeanUtil.beanToMap(useInfo)); re.putAll(BeanUtil.beanToMap(useInfo));
// 移除useInfo中的施工(安装)单位code和name,避免对constructionInfo数据产生影响
re.remove("USC_UNIT_NAME");
re.remove("USC_UNIT_CREDIT_CODE");
re.putAll(BeanUtil.beanToMap(registerInfo)); re.putAll(BeanUtil.beanToMap(registerInfo));
re.putAll(BeanUtil.beanToMap(factoryInfo)); re.putAll(BeanUtil.beanToMap(factoryInfo));
re.putAll(BeanUtil.beanToMap(otherInfo)); re.putAll(BeanUtil.beanToMap(otherInfo));
......
...@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity; import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum; import com.yeejoin.amos.boot.module.common.api.enums.CylinderTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant; import com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta; import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
...@@ -32,6 +34,7 @@ import java.io.IOException; ...@@ -32,6 +34,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
/** /**
* 单个维护设备-策略实现类 * 单个维护设备-策略实现类
...@@ -48,6 +51,8 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy ...@@ -48,6 +51,8 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
private final RestHighLevelClient restHighLevelClient; private final RestHighLevelClient restHighLevelClient;
private final EsEquipmentDao esEquipmentDao;
@Override @Override
public HandleResult handle(Map<String, Object> changeData, String record) { public HandleResult handle(Map<String, Object> changeData, String record) {
...@@ -149,6 +154,16 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy ...@@ -149,6 +154,16 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
esUpdateService.updateEsData(record, factoryInfoNew); esUpdateService.updateEsData(record, factoryInfoNew);
esUpdateService.updateEsData(record, idxBizJgSupervisionInfoNew); esUpdateService.updateEsData(record, idxBizJgSupervisionInfoNew);
if("50*X".equals(idxBizJgSupervisionInfoOld.getOrgBranchCode()) && !"50*X".equals(idxBizJgSupervisionInfoNew.getOrgBranchCode())){
Optional<ESEquipmentInfo> esEquipmentDto = esEquipmentDao.findById(record);
if (esEquipmentDto.isPresent()) {
ESEquipmentInfo esEquipmentInfo = esEquipmentDto.get();
esEquipmentInfo.setORG_BRANCH_CODE(idxBizJgSupervisionInfoNew.getOrgBranchCode());
esEquipmentInfo.setORG_BRANCH_NAME(idxBizJgSupervisionInfoNew.getOrgBranchName());
esEquipmentDao.save(esEquipmentInfo);
}
}
// 如果是气瓶则按照证更新其他同证下的气瓶字段 // 如果是气瓶则按照证更新其他同证下的气瓶字段
this.updateOtherEquipInSameCert(useInfoNew, registerInfoNew, registerInfoOld, allChangeColumns); this.updateOtherEquipInSameCert(useInfoNew, registerInfoNew, registerInfoOld, allChangeColumns);
// 设备技术参数入库处理 // 设备技术参数入库处理
......
...@@ -2506,12 +2506,14 @@ public class CommonServiceImpl implements ICommonService { ...@@ -2506,12 +2506,14 @@ public class CommonServiceImpl implements ICommonService {
// equips.stream().mapToDouble(e -> Optional.ofNullable(e.get("nominalWorkingPressure")).map(v -> Double.valueOf(v.toString())).orElse(0.0)).sum() // equips.stream().mapToDouble(e -> Optional.ofNullable(e.get("nominalWorkingPressure")).map(v -> Double.valueOf(v.toString())).orElse(0.0)).sum()
formData.put("workPressure", equips.stream().mapToDouble(e -> Optional.ofNullable(e.get("nominalWorkingPressure")).map(v -> Double.valueOf(v.toString())).orElse(0.0)).max().getAsDouble()); formData.put("workPressure", equips.stream().mapToDouble(e -> Optional.ofNullable(e.get("nominalWorkingPressure")).map(v -> Double.valueOf(v.toString())).orElse(0.0)).max().getAsDouble());
formData.put("volume", equips.stream().mapToDouble(e -> Optional.ofNullable(e.get("singleBottleVolume")).map(v -> Double.valueOf(v.toString())).orElse(0.0)).sum()); formData.put("volume", equips.stream().mapToDouble(e -> Optional.ofNullable(e.get("singleBottleVolume")).map(v -> Double.valueOf(v.toString())).orElse(0.0)).sum());
// BUG 30344 【生产问题】车用气瓶使用登记时,同一车辆可以选择多个充装介质不同的气瓶发起使用登记
Set<String> chargingMedium = equips.stream().map(e -> String.valueOf(e.get("chargingMedium"))).collect(Collectors.toSet()); Set<String> chargingMedium = equips.stream().map(e -> String.valueOf(e.get("chargingMedium"))).collect(Collectors.toSet());
if (chargingMedium.size() > 1) { formData.put("chargingMedium", String.join(",", chargingMedium));
throw new BadRequest("充装介质仅可选择同一类型"); // if (chargingMedium.size() > 1) {
} else { // throw new BadRequest("充装介质仅可选择同一类型");
formData.put("chargingMedium", equips.get(0).get("chargingMedium")); // } else {
} // formData.put("chargingMedium", equips.get(0).get("chargingMedium"));
// }
} }
} }
......
...@@ -54,6 +54,8 @@ import lombok.RequiredArgsConstructor; ...@@ -54,6 +54,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -61,19 +63,18 @@ import org.springframework.util.ObjectUtils; ...@@ -61,19 +63,18 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.lang.reflect.Method;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString; import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE; import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE;
import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE_NAME; import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNoticeServiceImpl.CONSTRUCTION_TYPE_NAME;
...@@ -85,7 +86,12 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNot ...@@ -85,7 +86,12 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNot
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class DataHandlerServiceImpl { public class DataHandlerServiceImpl {
public static final String IDX_BIZ_VIEW_JG_ALL = "idx_biz_view_jg_all";
public static final String IDX_BIZ_EQUIPMENT_INFO = "idx_biz_equipment_info";
public static final String STATUS = "STATUS";
public static final String record = "record";
public static final String SEQUENCE_NBR = "SEQUENCE_NBR";
private static final int BATCH_SIZE = 1000;
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
private final JgRegistrationHistoryServiceImpl registrationHistoryService; private final JgRegistrationHistoryServiceImpl registrationHistoryService;
private final JgInstallationNoticeServiceImpl installationNoticeService; private final JgInstallationNoticeServiceImpl installationNoticeService;
...@@ -147,6 +153,12 @@ public class DataHandlerServiceImpl { ...@@ -147,6 +153,12 @@ public class DataHandlerServiceImpl {
@Value("${jyjc.open.online: true}") @Value("${jyjc.open.online: true}")
private Boolean onlineJyjc; private Boolean onlineJyjc;
private final JgUseRegistrationManageServiceImpl registrationManageService;
private final SuperviseInfoMapper superviseInfoMapper;
private final IdxBizJgOtherInfoMapper otherInfoMapper;
/** /**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式 * 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
...@@ -1828,4 +1840,147 @@ public class DataHandlerServiceImpl { ...@@ -1828,4 +1840,147 @@ public class DataHandlerServiceImpl {
watch.stop(); watch.stop();
log.info("增量添加ORG_BRANCH_CODE为50X综合搜索数据-设备信息入库结束,耗时:{}秒", watch.getTotalTimeSeconds()); log.info("增量添加ORG_BRANCH_CODE为50X综合搜索数据-设备信息入库结束,耗时:{}秒", watch.getTotalTimeSeconds());
} }
public Integer deleteEquipWithStatusNotInClaimed(String indices, boolean isDelete) throws InterruptedException {
if (!Arrays.asList(IDX_BIZ_VIEW_JG_ALL, IDX_BIZ_EQUIPMENT_INFO).contains(indices)) {
throw new IllegalArgumentException("非法索引名,只允许使用 idx_biz_view_jg_all 或 idx_biz_equipment_info");
}
List<?> esList;
List<String> records;
if (IDX_BIZ_VIEW_JG_ALL.equals(indices)) {
esList = queryUnclaimedEquipments(indices, ESEquipmentCategoryDto.class);
} else {
esList = queryUnclaimedEquipments(indices, ESEquipmentInfo.class);
}
if (CollectionUtils.isEmpty(esList)) {
return 0;
}
records = extractSequenceNbr(esList);
if (records.isEmpty()) {
return 0;
}
if (isDelete) {
List<String> successDeleteList = Collections.synchronizedList(new ArrayList<>());
List<List<String>> allDataList = Lists.partition(records, BATCH_SIZE);
ExecutorService executor = new ThreadPoolExecutor(
10, // 核心线程数
20, // 最大线程数
60L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(1000), // 队列最多允许1000个任务
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略(可换成其他)
);
CountDownLatch latch = new CountDownLatch(allDataList.size());
for (List<String> batch : allDataList) {
executor.submit(() -> {
try {
superviseInfoMapper.deleteDataAll(batch);
successDeleteList.addAll(batch);
} catch (Exception e) {
log.error("批次删除失败: {}", batch, e);
} finally {
latch.countDown();
}
});
}
latch.await();
executor.shutdown();
if (!successDeleteList.isEmpty()) {
List<?> successEsList = esList.stream()
.filter(e -> successDeleteList.contains(getSequenceNbr(e)))
.collect(Collectors.toList());
if (IDX_BIZ_VIEW_JG_ALL.equals(indices)) {
esEquipmentCategory.deleteAll((List<ESEquipmentCategoryDto>) successEsList);
} else {
esEquipmentDao.deleteAll((List<ESEquipmentInfo>) successEsList);
}
}
return successDeleteList.size();
}
return records.size();
}
private String getSequenceNbr(Object e) {
try {
if (e instanceof ESEquipmentCategoryDto) {
return ((ESEquipmentCategoryDto) e).getSEQUENCE_NBR();
} else if (e instanceof ESEquipmentInfo) {
return ((ESEquipmentInfo) e).getSEQUENCE_NBR();
}
} catch (Exception ex) {
log.warn("无法获取sequenceNbr: {}", e, ex);
}
return null;
}
private <T> List<T> queryUnclaimedEquipments(String index, Class<T> clazz) {
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
BoolQueryBuilder statusFilter = QueryBuilders.boolQuery()
.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery(STATUS, "已认领")))
.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery(STATUS)))
.should(QueryBuilders.termQuery(STATUS, ""))
.minimumShouldMatch(1);
boolQuery.must(statusFilter);
try {
return registrationManageService.searchResponse(
index,
boolQuery,
hit -> {
JSONObject json = JSONObject.parseObject(hit.getSourceAsString(), JSONObject.class);
json.put(SEQUENCE_NBR, Objects.toString(json.get(SEQUENCE_NBR), ""));
return json.toJavaObject(clazz);
}
);
} catch (Exception ex) {
log.error("查询未认领设备异常:", ex);
return Collections.emptyList();
}
}
private <T> List<String> extractSequenceNbr(List<T> list) {
return list.stream()
.map(item -> {
try {
Method method = item.getClass().getMethod("getSEQUENCE_NBR");
Object value = method.invoke(item);
return Objects.toString(value, null);
} catch (Exception e) {
log.warn("反射获取 SEQUENCE_NBR 失败", e);
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
public Integer deleteEquipExistDB(boolean isDelete) {
LambdaQueryWrapper<IdxBizJgOtherInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(IdxBizJgOtherInfo::getRecord)
.notIn(IdxBizJgOtherInfo::getClaimStatus, "已认领", "");
List<IdxBizJgOtherInfo> jgOtherInfos = otherInfoMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(jgOtherInfos)) {
return 0;
}
List<String> records = jgOtherInfos.stream()
.map(IdxBizJgOtherInfo::getRecord)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!records.isEmpty() && isDelete) {
superviseInfoMapper.deleteDataAll(records);
}
return records.size();
}
} }
...@@ -1807,18 +1807,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1807,18 +1807,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 新增页面选择无设备代码后,在审批通过后自动生成设备代码 // 新增页面选择无设备代码后,在审批通过后自动生成设备代码
this.justGenerateEquCode(lambda, registerInfo, jgUseRegistration.getReceiveCompanyCode(), mapData, jgRegistrationHistory); this.justGenerateEquCode(lambda, registerInfo, jgUseRegistration.getReceiveCompanyCode(), mapData, jgRegistrationHistory);
idxBizJgRegisterInfoService.update(lambda); idxBizJgRegisterInfoService.update(lambda);
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName())
.businessId(jgUseRegistration.getSequenceNbr() + "")
.equId((String) mapData.get("equipId"))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.changeContent(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName() + "业务办理")
.status("正常")
.routePath(taskV2Model.getRoutePath())
.build());
} }
jgResumeInfoService.createWithModel(JgResumeInfoDto.builder()
.applyNo(jgUseRegistration.getApplyNo())
.businessType(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName())
.businessId(jgUseRegistration.getSequenceNbr() + "")
.equId((String) mapData.get("equipId"))
.approvalUnit(jgUseRegistration.getReceiveOrgName())
.approvalUnitCode(jgUseRegistration.getReceiveCompanyCode())
.changeContent(BusinessTypeEnum.JG_USAGE_REGISTRATION.getName() + "业务办理")
.status("正常")
.routePath(taskV2Model.getRoutePath())
.build());
} }
// 使用信息 // 使用信息
LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda(); LambdaQueryWrapper<IdxBizJgUseInfo> lambda = new QueryWrapper<IdxBizJgUseInfo>().lambda();
...@@ -4325,13 +4325,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -4325,13 +4325,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.map(parts -> parts[1]) .map(parts -> parts[1])
.orElse(null)); .orElse(null));
useInfo.setPhone(String.valueOf(map.get("phone"))); useInfo.setPhone(String.valueOf(map.get("phone")));
useInfo.setSafetyManager(String.valueOf(Optional.ofNullable(map.get("safetyManager")) useInfo.setSafetyManager(map.getString("safetyManagerName"));
.map(Object::toString) useInfo.setSafetyManagerId(map.getString("safetyManagerId"));
.filter(s -> s.contains("_"))
.map(s -> s.split("_", 2))
.filter(parts -> parts.length == 2)
.map(parts -> parts[0])
.orElse(null)));
useInfo.setUseDate(String.valueOf(map.get("useDate"))); useInfo.setUseDate(String.valueOf(map.get("useDate")));
useInfo.setLongitudeLatitude(JSON.toJSONString(map.get("longitudeLatitude"))); useInfo.setLongitudeLatitude(JSON.toJSONString(map.get("longitudeLatitude")));
useInfo.setUsePlace((String) map.get("usePlace")); useInfo.setUsePlace((String) map.get("usePlace"));
......
...@@ -236,9 +236,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -236,9 +236,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists"); List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists");
if (SUBMIT_TYPE_FLOW.equals(submit)) { if (SUBMIT_TYPE_FLOW.equals(submit)) {
if (CollectionUtils.isEmpty(equipmentLists) || // 不限制一个车只能使用一个充装介质的气瓶
equipmentLists.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() != 1) { if (CollectionUtils.isEmpty(equipmentLists)) {
throw new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!"); throw new BadRequest("请选择设备信息!");
} }
// 检查设备是否已经在使用 // 检查设备是否已经在使用
// 个人主体的身份证(6600_620422199903010258) 特殊处理 只取_后的身份证号码 // 个人主体的身份证(6600_620422199903010258) 特殊处理 只取_后的身份证号码
...@@ -1144,13 +1144,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1144,13 +1144,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
// 更新设备监管部门 // 更新设备监管部门
IdxBizJgSupervisionInfo idxBizJgSupervisionInfo = new IdxBizJgSupervisionInfo(); IdxBizJgSupervisionInfo idxBizJgSupervisionInfo = new IdxBizJgSupervisionInfo();
if (map.containsKey("orgBranchCode") && !ObjectUtils.isEmpty(map.get("orgBranchCode"))) { if (!ObjectUtils.isEmpty(jgVehicleInformation.getOrgBranchCode())) {
String[] data = String.valueOf(map.getString("orgBranchCode")).split("_"); HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(jgVehicleInformation.getOrgBranchCode()).getResult();
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(data[0]).getResult();
// 目前平台返回key为compnay(存在拼写错误) // 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(parentMessage.get("compnay")), CompanyModel.class); CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(parentMessage.get("compnay")), CompanyModel.class);
idxBizJgSupervisionInfo.setOrgBranchCode(data[0]); idxBizJgSupervisionInfo.setOrgBranchCode(jgVehicleInformation.getOrgBranchCode());
idxBizJgSupervisionInfo.setOrgBranchName(data[1]); idxBizJgSupervisionInfo.setOrgBranchName(jgVehicleInformation.getOrgBranchName());
idxBizJgSupervisionInfo.setCompanyOrgBranchCode(parentModel.getCompanyCode()); idxBizJgSupervisionInfo.setCompanyOrgBranchCode(parentModel.getCompanyCode());
LambdaQueryWrapper<IdxBizJgSupervisionInfo> eq = new QueryWrapper<IdxBizJgSupervisionInfo>().lambda().eq(IdxBizJgSupervisionInfo::getRecord, map.get("record")); LambdaQueryWrapper<IdxBizJgSupervisionInfo> eq = new QueryWrapper<IdxBizJgSupervisionInfo>().lambda().eq(IdxBizJgSupervisionInfo::getRecord, map.get("record"));
idxBizJgSupervisionInfoMapper.update(idxBizJgSupervisionInfo, eq); idxBizJgSupervisionInfoMapper.update(idxBizJgSupervisionInfo, eq);
...@@ -1878,10 +1877,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1878,10 +1877,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
.convertValue(map.get("equipmentLists"), new TypeReference<List<Map<String, Object>>>() { .convertValue(map.get("equipmentLists"), new TypeReference<List<Map<String, Object>>>() {
}); });
// 设备列表判空 + 选择同一充装介质的设备 // 设备列表判空 + 选择同一充装介质的设备
// 20250801修改为不限制一个车只能使用一个充装介质的气瓶
Optional.ofNullable(equipmentLists) Optional.ofNullable(equipmentLists)
.filter(list -> !list.isEmpty()) .filter(list -> !list.isEmpty())
.filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1) // .filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1)
.orElseThrow(() -> new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!")); .orElseThrow(() -> new BadRequest("请选择设备信息!"));
// 确保车用气瓶使用信息中填写的【使用登记证编号】【车辆VIN】与列表所选择设备的一致 // 确保车用气瓶使用信息中填写的【使用登记证编号】【车辆VIN】与列表所选择设备的一致
Optional.of(equipmentLists) Optional.of(equipmentLists)
.filter(eqLists -> { .filter(eqLists -> {
...@@ -2230,10 +2230,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2230,10 +2230,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class);
JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class); JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class);
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists"); List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists");
// 20250801修改为不限制一个车只能使用一个充装介质的气瓶
Optional.ofNullable(equipmentLists) Optional.ofNullable(equipmentLists)
.filter(list -> !list.isEmpty()) .filter(list -> !list.isEmpty())
.filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1) // .filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1)
.orElseThrow(() -> new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!")); .orElseThrow(() -> new BadRequest("请选择设备信息!"));
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
vehicleInfoDto.setCreateDate(new Date()); vehicleInfoDto.setCreateDate(new Date());
......
...@@ -230,4 +230,10 @@ public class TzsUserInfo extends BaseEntity { ...@@ -230,4 +230,10 @@ public class TzsUserInfo extends BaseEntity {
*/ */
@TableField(value = "create_date") @TableField(value = "create_date")
protected Date createDate; protected Date createDate;
@TableField(value = "practice_registration")
private String practiceRegistration;
@TableField(value = "labor_contract")
private String laborContract;
} }
...@@ -27,9 +27,9 @@ public enum ConditionEnum { ...@@ -27,9 +27,9 @@ public enum ConditionEnum {
dateLt("小于", "lt", TechnicalParameter.ParamType.DATE), dateLt("小于", "lt", TechnicalParameter.ParamType.DATE),
dateGe("大于等于", "gte", TechnicalParameter.ParamType.DATE), dateGe("大于等于", "gte", TechnicalParameter.ParamType.DATE),
dateLe("小于等于", "lte", TechnicalParameter.ParamType.DATE), dateLe("小于等于", "lte", TechnicalParameter.ParamType.DATE),
in("包含","in", null), in("包含", "in", null),
notIn("不包含","notIn", null), notIn("不包含", "notIn", null),
eq("等于","eq", null), eq("等于", "eq", null),
; ;
...@@ -49,4 +49,17 @@ public enum ConditionEnum { ...@@ -49,4 +49,17 @@ public enum ConditionEnum {
} }
return jsonArray; return jsonArray;
} }
public static JSONArray getByCode(String code, TechnicalParameter.ParamType paramType) {
JSONArray jsonArray = new JSONArray();
for (ConditionEnum value : values()) {
if (value.code == code && value.paramType == paramType) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("label", value.name);
jsonObject.put("value", value.code);
jsonArray.add(jsonObject);
}
}
return jsonArray;
}
} }
...@@ -87,8 +87,10 @@ public enum EquipAdvanceSearchEnum { ...@@ -87,8 +87,10 @@ public enum EquipAdvanceSearchEnum {
if ("技术参数".equals(item.name)) { if ("技术参数".equals(item.name)) {
jsonObject.put("type", "select2"); jsonObject.put("type", "select2");
jsonObject.put("method", "POST"); jsonObject.put("method", "POST");
jsonObject.put("conditions", ConditionEnum.getByCode("eq",item.paramType));
} else {
jsonObject.put("conditions", ConditionEnum.getByCode(item.paramType));
} }
jsonObject.put("conditions", ConditionEnum.getByCode(item.paramType));
jsonObject.put("url", item.url); jsonObject.put("url", item.url);
jsonArray.add(jsonObject); jsonArray.add(jsonObject);
} }
......
...@@ -25,7 +25,15 @@ public interface TzsCustomFilterMapper extends BaseMapper<TzsCustomFilter> { ...@@ -25,7 +25,15 @@ public interface TzsCustomFilterMapper extends BaseMapper<TzsCustomFilter> {
JSONArray queryEquCategory(@Param("type") String type, @Param("description") String description); JSONArray queryEquCategory(@Param("type") String type, @Param("description") String description);
Page<String> selectRecords(Page<String> page); Page<String> selectGasRecords(Page<String> page);
List<String> selectRecords(@Param("code") String code, @Param("limit") long limit);
void addGas(@Param("refreshRecords")List<String> refreshRecords); void addGas(@Param("refreshRecords")List<String> refreshRecords);
Integer selectRecordCount(String code);
void setOrgBranchCodeIsNullByRecords(@Param("records") List<String> records);
void updateOrgBranchCodeByRecords(@Param("dataList") List<Map<String, Object>> dataList);
} }
package com.yeejoin.amos.boot.module.statistics.api.vo; package com.yeejoin.amos.boot.module.statistics.api.vo;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List; import java.util.List;
@Data @Data
public class TzsUserInfoVo { public class TzsUserInfoVo {
/** /**
* 主键
*/
@TableId(value = "sequence_nbr")
protected Long sequenceNbr;
/**
* 姓名 * 姓名
*/ */
@TableField("name") @TableField("name")
...@@ -119,6 +124,13 @@ public class TzsUserInfoVo { ...@@ -119,6 +124,13 @@ public class TzsUserInfoVo {
*/ */
@TableField("unit_name") @TableField("unit_name")
private String unitName; private String unitName;
/**
* 单位code
*/
@TableField("unit_code")
private String unitCode;
/** /**
* 头像 * 头像
*/ */
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<select id="selectEquipmentCategoryCountByParentId" resultType="java.lang.Integer"> <select id="selectEquipmentCategoryCountByParentId" resultType="java.lang.Integer">
select count(1) from tz_equipment_category where is_delete = 0 and parent_id = #{parentId} select count(1) from tz_equipment_category where is_delete = 0 and parent_id = #{parentId}
</select> </select>
<select id="selectRecords" resultType="java.lang.String"> <select id="selectGasRecords" resultType="java.lang.String">
SELECT SELECT
ibjui."RECORD" ibjui."RECORD"
FROM FROM
...@@ -50,6 +50,58 @@ ...@@ -50,6 +50,58 @@
AND "CLAIM_STATUS" = '已认领' AND "CLAIM_STATUS" = '已认领'
order by ibjui."RECORD" desc order by ibjui."RECORD" desc
</select> </select>
<select id="selectRecords" resultType="java.lang.String">
SELECT
ibjsi."RECORD"
FROM
amos_tzs_biz.idx_biz_jg_supervision_info ibjsi
LEFT JOIN amos_tzs_biz.idx_biz_jg_register_info ibjri ON ibjsi."RECORD" = ibjri."RECORD"
WHERE
"ORG_BRANCH_CODE" = '50*X'
<if test="code != '2300'">
AND ibjri."EQU_LIST" = #{code}
<if test="code == '2000'">
AND ibjri."EQU_CATEGORY" != '2300'
</if>
</if>
<if test="code == '2300'">
AND ibjri."EQU_CATEGORY" = #{code}
</if>
limit #{limit}
</select>
<select id="selectRecordCount" resultType="java.lang.Integer">
SELECT
count(1)
FROM
amos_tzs_biz.idx_biz_jg_supervision_info ibjsi
LEFT JOIN amos_tzs_biz.idx_biz_jg_register_info ibjri ON ibjsi."RECORD" = ibjri."RECORD"
WHERE
"ORG_BRANCH_CODE" = '50*X'
<if test="code != '2300'">
AND ibjri."EQU_LIST" = #{code}
<if test="code == '2000'">
AND ibjri."EQU_CATEGORY" != '2300'
</if>
</if>
<if test="code == '2300'">
AND ibjri."EQU_CATEGORY" = #{code}
</if>
</select>
<update id="setOrgBranchCodeIsNullByRecords">
update amos_tzs_biz.idx_biz_jg_supervision_info set "ORG_BRANCH_CODE" = null where "RECORD" in
<foreach collection="records" separator="," item="record" open="(" close=");">
#{record}
</foreach>
</update>
<update id="updateOrgBranchCodeByRecords">
<foreach collection="dataList" item="data" separator=";">
update amos_tzs_biz.idx_biz_jg_supervision_info
set "ORG_BRANCH_CODE" = #{data.orgBranchCode}
where "RECORD" = #{data.record}
</foreach>
</update>
<insert id="addGas"> <insert id="addGas">
INSERT INTO "amos_tzs_biz"."idx_biz_jg_supervision_info" ("SEQUENCE_NBR", "RECORD") INSERT INTO "amos_tzs_biz"."idx_biz_jg_supervision_info" ("SEQUENCE_NBR", "RECORD")
......
...@@ -496,4 +496,16 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController { ...@@ -496,4 +496,16 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
public ResponseModel<JSONArray> queryInspectionDate() { public ResponseModel<JSONArray> queryInspectionDate() {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryInspectionDate()); return ResponseHelper.buildResponse(statisticalAnalysisService.queryInspectionDate());
} }
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/updateDataByOrgBranchCode")
@ApiOperation(httpMethod = "GET", value = "修改ORG_BRANCH_CODE为50*X综合搜索数据-设备", notes = "修改ORG_BRANCH_CODE为50*X综合搜索数据-设备")
public ResponseModel<Object> updateDataByOrgBranchCode(@RequestParam(value = "code") String code, @RequestParam(value = "limit") Integer limit) {
return ResponseHelper.buildResponse(statisticalAnalysisService.updateDataByOrgBranchCode(code, limit));
}
} }
...@@ -432,8 +432,9 @@ public class JGDPStatisticsController extends BaseController { ...@@ -432,8 +432,9 @@ public class JGDPStatisticsController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "common/equOnJgServiceOperationRecords") @GetMapping(value = "common/equOnJgServiceOperationRecords")
@ApiOperation(httpMethod = "GET", value = "查询设备在jg业务中的记录", notes = "查询设备在jg业务中的记录") @ApiOperation(httpMethod = "GET", value = "查询设备在jg业务中的记录", notes = "查询设备在jg业务中的记录")
public ResponseModel<List<Map<String, String>>> equOnJgServiceOperationRecords(@RequestParam(value = "record") String record) { public ResponseModel<List<Map<String, String>>> equOnJgServiceOperationRecords(@RequestParam(value = "record") String record,
return ResponseHelper.buildResponse(statisticsService.equOnJgServiceOperationRecords(record)); @RequestParam(value = "equipType", required = false) String equipType) {
return ResponseHelper.buildResponse(statisticsService.equOnJgServiceOperationRecords(record,equipType));
} }
/** /**
......
...@@ -17,6 +17,7 @@ import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil; ...@@ -17,6 +17,7 @@ import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl; import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RequestContextWrapper; import com.yeejoin.amos.boot.biz.common.utils.RequestContextWrapper;
import com.yeejoin.amos.boot.module.common.api.dao.EsEquipmentDao;
import com.yeejoin.amos.boot.module.common.api.dto.TechParamItem; import com.yeejoin.amos.boot.module.common.api.dto.TechParamItem;
import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo; import com.yeejoin.amos.boot.module.common.api.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.common.api.enums.UnitTypeNewEnum; import com.yeejoin.amos.boot.module.common.api.enums.UnitTypeNewEnum;
...@@ -126,6 +127,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -126,6 +127,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private final String or = "or"; private final String or = "or";
private final String and = "and"; private final String and = "and";
private final EsEquipmentDao esEquipmentDao;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
...@@ -1656,11 +1659,17 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1656,11 +1659,17 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private void addTechParam(JSONObject techParam, JSONObject paramRange, EnhancedDynamicQueryBuilder builder) { private void addTechParam(JSONObject techParam, JSONObject paramRange, EnhancedDynamicQueryBuilder builder) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(techParam)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(techParam));
JSONObject js = (JSONObject) jsonObject.get("value"); String field = jsonObject.getString("value");
String field = js.getString("value"); JSONObject js = (JSONObject) jsonObject.get("skillConfig");
String fieldType = js.getString("fieldType"); String fieldType = js.getString("fieldType");
String itemCondition = paramRange.getString("itemCondition"); String itemCondition = paramRange.getString("itemCondition");
Object value = paramRange.get("value"); Object value = null;
if (paramRange.get("value") instanceof JSONObject) {
JSONObject jsValue = (JSONObject) paramRange.get("value");
value = jsValue.get("value");
} else {
value = paramRange.get("value");
}
String andOr = paramRange.getString("andOr"); String andOr = paramRange.getString("andOr");
getParamQuery(field, itemCondition, value, fieldType, true, null, builder, andOr); getParamQuery(field, itemCondition, value, fieldType, true, null, builder, andOr);
} }
...@@ -1894,7 +1903,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -1894,7 +1903,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
builder.add(existsQuery, and); builder.add(existsQuery, and);
} }
} }
} else if (field.equals("issueDate")) { } else if (field.equals("issueDate")) {
BoolQueryBuilder query = QueryBuilders.boolQuery(); BoolQueryBuilder query = QueryBuilders.boolQuery();
switch (itemCondition) { switch (itemCondition) {
case "eq": case "eq":
...@@ -2807,7 +2816,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -2807,7 +2816,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
public JSONArray queryTypeZYXM(String type) { public JSONArray queryTypeZYXM(String type) {
JSONArray result = new JSONArray(); JSONArray result = new JSONArray();
if ("特种设备安全管理和作业人员证".equals(type)) { if ("特种设备安全管理和作业人员证".equals(type)) {
...@@ -4035,7 +4043,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -4035,7 +4043,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
for (int j = 0; j <= times; j++) { for (int j = 0; j <= times; j++) {
recordDtoPage.setCurrent(j + 1); recordDtoPage.setCurrent(j + 1);
recordDtoPage.setSize(5000); recordDtoPage.setSize(5000);
Page<String> refreshRecords = tzsCustomFilterMapper.selectRecords(recordDtoPage); Page<String> refreshRecords = tzsCustomFilterMapper.selectGasRecords(recordDtoPage);
if (!ObjectUtils.isEmpty(refreshRecords) && refreshRecords.getRecords().size() > 0) { if (!ObjectUtils.isEmpty(refreshRecords) && refreshRecords.getRecords().size() > 0) {
total += refreshRecords.getRecords().size(); total += refreshRecords.getRecords().size();
tzsCustomFilterMapper.addGas(refreshRecords.getRecords()); tzsCustomFilterMapper.addGas(refreshRecords.getRecords());
...@@ -4043,4 +4051,65 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -4043,4 +4051,65 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
return total; return total;
} }
public Object updateDataByOrgBranchCode(String code, Integer limit) {
SearchRequest request = new SearchRequest();
request.indices(StatisticalAnalysisEnum.equip.getKey());
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 1、从数据库查询对应设备类型下50*X得数据record
Integer count = tzsCustomFilterMapper.selectRecordCount(code);
if (count == 0) {
return "数据库中该数据分类下无需要修改的数据";
}
limit = count > limit ? limit : count;
List<String> records = tzsCustomFilterMapper.selectRecords(code, limit);
// 2、从es中查询对应record的数据
boolMust.must(QueryBuilders.termsQuery("SEQUENCE_NBR.keyword", records));
builder.query(boolMust);
builder.from(0);
builder.size(limit);
request.source(builder);
// 数据库和es中都为50*X的数据集合
List<String> allNotDateList = new ArrayList<>();
// 数据库中为50*X的数据集合,但es中不为50*X的数据集合
List<Map<String, Object>> dataList = new ArrayList<>();
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto = jsonObject.getJSONObject("sourceAsMap");
if (dto.containsKey("ORG_BRANCH_CODE")) {
//3、判断查询回来的数据中是否为50*X,如果是50*X,则记录下来进行做置空处理/如果不为50*X,则记录下来进行数据库修复
if ("50*X".equals(dto.getString("ORG_BRANCH_CODE"))) {
allNotDateList.add(dto.getString("SEQUENCE_NBR"));
} else {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("record", dto.getString("SEQUENCE_NBR"));
dataMap.put("orgBranchCode", dto.getString("ORG_BRANCH_CODE"));
dataList.add(dataMap);
}
}
}
//4、是50*X的进行es和数据库的双向修改/不是50*X的只需要做数据库修改
if(!ObjectUtils.isEmpty(allNotDateList)){
tzsCustomFilterMapper.setOrgBranchCodeIsNullByRecords(allNotDateList);
Iterable<ESEquipmentInfo> allById = esEquipmentDao.findAllById(allNotDateList);
if(!ObjectUtils.isEmpty(allById)){
for (ESEquipmentInfo esEquipmentInfo : allById) {
esEquipmentInfo.setORG_BRANCH_CODE("");
}
}
esEquipmentDao.saveAll(allById);
}
// 修改为es中的数据
if(!ObjectUtils.isEmpty(dataList)){
tzsCustomFilterMapper.updateOrgBranchCodeByRecords(dataList);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return records;
}
} }
\ No newline at end of file
...@@ -236,7 +236,7 @@ public class DPSubServiceImpl { ...@@ -236,7 +236,7 @@ public class DPSubServiceImpl {
// 气瓶区分车用和非车用 // 气瓶区分车用和非车用
if ("2300".equals(param.getString("EQU_CATEGORY_CODE"))){ if ("2300".equals(param.getString("EQU_CATEGORY_CODE"))){
keyParams = JsonValueUtils.getValueByKey(content, "keyinfo", "keyinfo.keyParams_2300_" + keyParams = JsonValueUtils.getValueByKey(content, "keyinfo", "keyinfo.keyParams_2300_" +
("1".equals(param.getString("WHETHER_VEHICLE_CYLINDER")) ? "true" : "false")); ("否".equals(param.getString("WHETHER_VEHICLE_CYLINDER")) || "0".equals(param.getString("WHETHER_VEHICLE_CYLINDER")) ? "true" : "false"));
keyinfo.remove("keyParams_2300_true"); keyinfo.remove("keyParams_2300_true");
keyinfo.remove("keyParams_2300_false"); keyinfo.remove("keyParams_2300_false");
} else { } else {
...@@ -254,7 +254,7 @@ public class DPSubServiceImpl { ...@@ -254,7 +254,7 @@ public class DPSubServiceImpl {
((JSONArray) keyParams).stream().forEach(x -> { ((JSONArray) keyParams).stream().forEach(x -> {
JSONObject xobj = (JSONObject) x; JSONObject xobj = (JSONObject) x;
xobj.put("type", "text"); xobj.put("type", "text");
xobj.put("value", "param".equals(xobj.getString("source")) ? param.get(xobj.getString("key")) : result.get(xobj.getString("key"))); xobj.put("value", "param".equals(xobj.getString("source")) || "EQU_LIST".equals(xobj.getString("key")) ? param.get(xobj.getString("key")) : result.get(xobj.getString("key")));
}); });
this.processQRCodeWidget(content.getJSONObject("keyinfo").getJSONObject("qrcode"), result); this.processQRCodeWidget(content.getJSONObject("keyinfo").getJSONObject("qrcode"), result);
...@@ -776,7 +776,20 @@ public class DPSubServiceImpl { ...@@ -776,7 +776,20 @@ public class DPSubServiceImpl {
)); ));
jsonObject.put("value", fieldMap.get(value)); jsonObject.put("value", fieldMap.get(value));
} }
} else if("tableToTable".equals(xObj.getString("componentKey"))){ } else if ("selectTree".equals(xObj.getString("componentKey"))) {
String name = null;
if (!ValidationUtil.isEmpty(visualParams.getJSONObject("api")) && StrUtil.isNotEmpty(visualParams.getJSONObject("api").getString("apiPath"))) {
ResponseModel selectResult = this.getApiResult(visualParams.getJSONObject("api"), null, apiResult);
if (!ValidationUtil.isEmpty(selectResult) && selectResult.getStatus() == 200 && !ValidationUtil.isEmpty(value)) {
JSONArray result = (JSONArray) selectResult.getResult();
// 递归处理树形结构
name = getTreeNameById(result, value.toString());
}
} else if (!CollectionUtils.isEmpty(visualParams.getJSONArray("data"))) {
name = getTreeNameById(visualParams.getJSONArray("data"), value.toString());
}
jsonObject.put("value", name);
} else if ("tableToTable".equals(xObj.getString("componentKey"))) {
} }
} }
...@@ -786,6 +799,29 @@ public class DPSubServiceImpl { ...@@ -786,6 +799,29 @@ public class DPSubServiceImpl {
return datas; return datas;
} }
private String getTreeNameById(JSONArray jsonArray, String value) {
final String[] name = new String[1];
if (!ObjectUtils.isEmpty(jsonArray)) {
List<Object> collect = jsonArray.stream().filter(y -> value.equals(JsonValueUtils.getValueByKey(y, "id", "id"))).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
collect.stream().findFirst().ifPresent(z -> name[0] = ((JSONObject) z).getString("name"));
} else {
for (Object object : jsonArray) {
JSONObject object1 = (JSONObject) object;
if (!ObjectUtils.isEmpty(object1.get("children"))) {
name[0] = getTreeNameById(object1.getJSONArray("children"), value);
if (name[0] != null) {
return name[0];
}
}
}
}
} else {
return null;
}
return name[0];
}
public JSONObject buildSubFormData(JSONObject map, int i, JSONObject yObj, Object apiResult) { public JSONObject buildSubFormData(JSONObject map, int i, JSONObject yObj, Object apiResult) {
JSONArray subs = map.getJSONArray("subs"); JSONArray subs = map.getJSONArray("subs");
JSONArray children = yObj.getJSONArray("children"); JSONArray children = yObj.getJSONArray("children");
...@@ -903,6 +939,7 @@ public class DPSubServiceImpl { ...@@ -903,6 +939,7 @@ public class DPSubServiceImpl {
} }
} }
result = isRefactor ? resultMap : result; result = isRefactor ? resultMap : result;
responseModel.setResult(result);
} else if (result instanceof JSONArray) { } else if (result instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) result; JSONArray jsonArray = (JSONArray) result;
...@@ -916,8 +953,8 @@ public class DPSubServiceImpl { ...@@ -916,8 +953,8 @@ public class DPSubServiceImpl {
} }
} }
result = isRefactor ? jsonArray : result; result = isRefactor ? jsonArray : result;
responseModel.setResult(result);
} }
responseModel.setResult(result);
} }
return responseModel; return responseModel;
} }
......
...@@ -2135,8 +2135,14 @@ public class JGDPStatisticsServiceImpl { ...@@ -2135,8 +2135,14 @@ public class JGDPStatisticsServiceImpl {
} }
} }
public List<Map<String, String>> equOnJgServiceOperationRecords(String record) { public List<Map<String, String>> equOnJgServiceOperationRecords(String record, String equipType) {
return commonMapper.equOnJgServiceOperationRecords(record).stream() List<Map<String, String>> maps = new ArrayList<>();
if ("8000".equals(equipType)) {
maps = commonMapper.gdEquOnJgServiceOperationRecords(record);
} else {
maps = commonMapper.equOnJgServiceOperationRecords(record);
}
return maps.stream()
.map(x -> { .map(x -> {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("operatingTime", x.get("recDate")); map.put("operatingTime", x.get("recDate"));
......
...@@ -23,7 +23,6 @@ import org.springframework.beans.BeanUtils; ...@@ -23,7 +23,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -67,7 +66,7 @@ public class UserBizByTCMServiceImpl { ...@@ -67,7 +66,7 @@ public class UserBizByTCMServiceImpl {
Map<String, Object> maps = new HashMap<>(); Map<String, Object> maps = new HashMap<>();
TzsUserInfo tzsUserInfo = tzsUserInfoMapper.selectById(id); TzsUserInfo tzsUserInfo = tzsUserInfoMapper.selectById(id);
TzsUserInfoVo tzsUserInfoVo = new TzsUserInfoVo(); TzsUserInfoVo tzsUserInfoVo = new TzsUserInfoVo();
BeanUtils.copyProperties(tzsUserInfo, tzsUserInfoVo, "identification", "profile", "post", "permissionItem", "appointDoc"); BeanUtils.copyProperties(tzsUserInfo, tzsUserInfoVo, "identification", "profile", "post", "permissionItem", "appointDoc","practiceRegistration","laborContract");
if (!ObjectUtils.isEmpty(tzsUserInfo.getPost())) { if (!ObjectUtils.isEmpty(tzsUserInfo.getPost())) {
tzsUserInfoVo.setPost(JSON.parseArray(tzsUserInfo.getPost())); tzsUserInfoVo.setPost(JSON.parseArray(tzsUserInfo.getPost()));
} }
...@@ -83,13 +82,15 @@ public class UserBizByTCMServiceImpl { ...@@ -83,13 +82,15 @@ public class UserBizByTCMServiceImpl {
tzsUserInfoVo.setIdentification(ObjectUtils.isEmpty(tzsUserInfo.getIdentification()) ? null : JSON.parseArray(tzsUserInfo.getIdentification())); tzsUserInfoVo.setIdentification(ObjectUtils.isEmpty(tzsUserInfo.getIdentification()) ? null : JSON.parseArray(tzsUserInfo.getIdentification()));
tzsUserInfoVo.setProfile(ObjectUtils.isEmpty(tzsUserInfo.getProfile()) ? null : JSON.parseArray(tzsUserInfo.getProfile())); tzsUserInfoVo.setProfile(ObjectUtils.isEmpty(tzsUserInfo.getProfile()) ? null : JSON.parseArray(tzsUserInfo.getProfile()));
tzsUserInfoVo.setAppointDoc(ObjectUtils.isEmpty(tzsUserInfo.getAppointDoc()) ? null : JSON.parseArray(tzsUserInfo.getAppointDoc())); tzsUserInfoVo.setAppointDoc(ObjectUtils.isEmpty(tzsUserInfo.getAppointDoc()) ? null : JSON.parseArray(tzsUserInfo.getAppointDoc()));
tzsUserInfoVo.setPracticeRegistration(ObjectUtils.isEmpty(tzsUserInfo.getPracticeRegistration()) ? null : JSON.parseArray(tzsUserInfo.getPracticeRegistration()));
tzsUserInfoVo.setLaborContract(ObjectUtils.isEmpty(tzsUserInfo.getLaborContract()) ? null : JSON.parseArray(tzsUserInfo.getLaborContract()));
tzsUserInfoVo.setOtherAccessories(ObjectUtils.isEmpty(tzsUserInfo.getOtherAccessories()) ? null : JSON.parseArray(tzsUserInfo.getOtherAccessories())); tzsUserInfoVo.setOtherAccessories(ObjectUtils.isEmpty(tzsUserInfo.getOtherAccessories()) ? null : JSON.parseArray(tzsUserInfo.getOtherAccessories()));
tzsUserInfoVo.setBirthday(tzsUserInfo.getBirthday() != null ? DateUtils.longStrDate(tzsUserInfo.getBirthday()): null); tzsUserInfoVo.setBirthday(tzsUserInfo.getBirthday() != null ? DateUtils.longStrDate(tzsUserInfo.getBirthday()): null);
tzsUserInfoVo.setSpeciality_required(tzsUserInfo.getSpeciality()); tzsUserInfoVo.setSpeciality_required(tzsUserInfo.getSpeciality());
tzsUserInfoVo.setEducation_required(tzsUserInfo.getEducation()); tzsUserInfoVo.setEducation_required(tzsUserInfo.getEducation());
tzsUserInfoVo.setJobTitle_required(tzsUserInfo.getJobTitle()); tzsUserInfoVo.setJobTitle_required(tzsUserInfo.getJobTitle());
String companyType = getUnitType(tzsUserInfo.getUnitCode());
tzsUserInfoVo.setBirthday(tzsUserInfo.getBirthday() != null ? DateUtils.longStrDate(tzsUserInfo.getBirthday()): null); tzsUserInfoVo.setBirthday(tzsUserInfo.getBirthday() != null ? DateUtils.longStrDate(tzsUserInfo.getBirthday()): null);
String companyType = getUnitType();
tzsUserInfoVo.setCompanyType(companyType.contains("个人主体") ? "individual" : "no-individual"); tzsUserInfoVo.setCompanyType(companyType.contains("个人主体") ? "individual" : "no-individual");
Map<String, Object> userInfoMap = BeanUtil.beanToMap(tzsUserInfoVo); Map<String, Object> userInfoMap = BeanUtil.beanToMap(tzsUserInfoVo);
// userInfoMap.putAll(this.getPermissionDataJson(tzsUserInfo.getPermissionData())); // userInfoMap.putAll(this.getPermissionDataJson(tzsUserInfo.getPermissionData()));
...@@ -100,12 +101,12 @@ public class UserBizByTCMServiceImpl { ...@@ -100,12 +101,12 @@ public class UserBizByTCMServiceImpl {
return maps; return maps;
} }
public String getUnitType() { public String getUnitType(String unitCode) {
List<CompanyModel> companyModels = FeignUtil.remoteCall(() -> Privilege.companyClient.queryListByChild(RequestContext.getExeUserId())); CompanyModel companyModel = FeignUtil.remoteCall(() -> Privilege.companyClient.queryByCompanyCode(unitCode));
if (companyModels.isEmpty()) { if (ObjectUtils.isEmpty(companyModel)) {
return ""; return "";
} }
return companyModels.get(0).getCompanyType(); return companyModel.getCompanyType();
} }
/** /**
......
...@@ -89,7 +89,8 @@ ...@@ -89,7 +89,8 @@
"httpMethod":"GET", "httpMethod":"GET",
"apiPath":"/statistics/dp/jg/common/equOnJgServiceOperationRecords", "apiPath":"/statistics/dp/jg/common/equOnJgServiceOperationRecords",
"params": { "params": {
"record": "{record}" "record": "{record}",
"equipType": "8000"
}, },
"ruleData": { "ruleData": {
"responseSuccess": "data.result", "responseSuccess": "data.result",
......
...@@ -324,7 +324,7 @@ ...@@ -324,7 +324,7 @@
FROM FROM
"tzs_user_info" u "tzs_user_info" u
left join tzs_user_permission p on u.sequence_nbr = p.user_seq left join tzs_user_permission p on u.sequence_nbr = p.user_seq
left join tz_base_enterprise_info e on u.unit_code = e.use_unit_code left join tz_base_enterprise_info e on u.unit_code = e.use_code
<where> <where>
u.is_delete = false u.is_delete = false
<if test="filter.orgCode != null and filter.orgCode != ''"> <if test="filter.orgCode != null and filter.orgCode != ''">
......
...@@ -31,6 +31,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -31,6 +31,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil; import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.common.api.dto.UserPermissionDto; import com.yeejoin.amos.boot.module.common.api.dto.UserPermissionDto;
import com.yeejoin.amos.boot.module.common.api.enums.UnitDataSourceEnum; import com.yeejoin.amos.boot.module.common.api.enums.UnitDataSourceEnum;
import com.yeejoin.amos.boot.module.common.api.enums.UserPostEnum;
import com.yeejoin.amos.boot.module.common.biz.event.CommonPublisher; import com.yeejoin.amos.boot.module.common.biz.event.CommonPublisher;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent; import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.tcm.api.dto.*; import com.yeejoin.amos.boot.module.tcm.api.dto.*;
...@@ -1089,12 +1090,15 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -1089,12 +1090,15 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
throw new BadRequest("本单位下用户证件号码重复,请核对!"); throw new BadRequest("本单位下用户证件号码重复,请核对!");
} }
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>() // 当人员类型仅为主要负责人时,不校验是否被其他单位绑定
.eq(TzsUserInfo::getCertificateType, tzsUserInfo.getCertificateType()) if (!JSON.toJSONString(Collections.singletonList(UserPostEnum.ZYFZR.getCode())).equals(tzsUserInfo.getNewPost())) {
.eq(TzsUserInfo::getCertificateNum, tzsUserInfo.getCertificateNum()) if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
.ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode()) .eq(TzsUserInfo::getCertificateType, tzsUserInfo.getCertificateType())
.eq(TzsUserInfo::getIsDelete, false)) > 0) { .eq(TzsUserInfo::getCertificateNum, tzsUserInfo.getCertificateNum())
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!"); .ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode())
.eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!");
}
} }
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>() if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
...@@ -1214,13 +1218,15 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -1214,13 +1218,15 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
.eq(TzsUserInfo::getIsDelete, false)) > 0) { .eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("本单位下用户证件号码重复,请核对!"); throw new BadRequest("本单位下用户证件号码重复,请核对!");
} }
// 当人员类型仅为主要负责人时,不校验是否被其他单位绑定
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>() if (!JSON.toJSONString(Collections.singletonList(UserPostEnum.ZYFZR.getCode())).equals(tzsUserInfoDto.getNewPost())) {
.eq(TzsUserInfo::getCertificateType, tzsUserInfoDto.getCertificateType()) if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
.eq(TzsUserInfo::getCertificateNum, tzsUserInfoDto.getCertificateNum()) .eq(TzsUserInfo::getCertificateType, tzsUserInfoDto.getCertificateType())
.ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode()) .eq(TzsUserInfo::getCertificateNum, tzsUserInfoDto.getCertificateNum())
.eq(TzsUserInfo::getIsDelete, false)) > 0) { .ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode())
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!"); .eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!");
}
} }
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>() if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
...@@ -2393,8 +2399,8 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -2393,8 +2399,8 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (!ObjectUtils.isEmpty(roleGroup) && roleGroup.getExtend() != null) { if (!ObjectUtils.isEmpty(roleGroup) && roleGroup.getExtend() != null) {
Privilege.groupUserClient.create(Long.valueOf(roleGroup.getExtend()), userIds); Privilege.groupUserClient.create(Long.valueOf(roleGroup.getExtend()), userIds);
} }
// 绑定两个规定用户组
if (post != null) { if (post != null) {
// 绑定两个规定用户组
post = post.replace("[", "").replace("]", "").replace("\"", ""); post = post.replace("[", "").replace("]", "").replace("\"", "");
for (String code : post.split(",")) { for (String code : post.split(",")) {
DataDictionary groupId = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getCode, code).likeRight(DataDictionary::getType, QYRYGW)); DataDictionary groupId = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getCode, code).likeRight(DataDictionary::getType, QYRYGW));
......
...@@ -44,6 +44,8 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> { ...@@ -44,6 +44,8 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
List<Integer> selectExceedElevatorCodeList(Integer start,String prefix); List<Integer> selectExceedElevatorCodeList(Integer start,String prefix);
List<Integer> selectExceedElevatorSequenceCodeList(Integer start,String prefix);
Integer selectCode(Integer start, Integer end, String prefix); Integer selectCode(Integer start, Integer end, String prefix);
/** /**
......
...@@ -26,21 +26,24 @@ ...@@ -26,21 +26,24 @@
SELECT CODE96333 code SELECT CODE96333 code
FROM biz_jg_supervisory_code bjsc FROM biz_jg_supervisory_code bjsc
WHERE CODE96333 LIKE CONCAT(#{elevatorCode}, '%') WHERE CODE96333 LIKE CONCAT(#{elevatorCode}, '%')
AND CODE96333 ~ '^\d+$' -- 确保是纯数字
<if test="status != null and status != ''"> <if test="status != null and status != ''">
and status = #{status} and status = #{status}
</if> </if>
<if test="status != 2 ">ORDER BY CODE96333 DESC LIMIT 1 </if> <if test="status != 2 ">ORDER BY CODE96333::BIGINT DESC LIMIT 1 </if>
<if test="status == 2 ">ORDER BY CODE96333 ASC LIMIT 1 </if> <if test="status == 2 ">ORDER BY CODE96333::BIGINT ASC LIMIT 1 </if>
</select> </select>
<select id="selectElevatorCodeMaxValue" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.KV"> <select id="selectElevatorCodeMaxValue" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.KV">
WITH ElevatorResults AS ( WITH ElevatorResults AS (
SELECT ROW_NUMBER() OVER (PARTITION BY SUBSTRING (CODE96333 FROM 1 FOR 2) ORDER BY CODE96333 DESC) AS row_num, SELECT ROW_NUMBER() OVER (PARTITION BY SUBSTRING (CODE96333 FROM 1 FOR 2) ORDER BY CODE96333::BIGINT DESC) AS row_num,
CODE96333 CODE96333
FROM biz_jg_supervisory_code FROM biz_jg_supervisory_code
WHERE CREATE_STATUS = 1 WHERE CREATE_STATUS = 1
AND CODE96333 IS NOT NULL AND CODE96333 IS NOT NULL
AND CODE96333 <![CDATA[<> '']]>) AND CODE96333 <![CDATA[<> '']]>
AND CODE96333 ~ '^\d+$' -- 确保是纯数字
)
SELECT '96333_' || SUBSTRING(CODE96333 FROM 1 FOR 2) AS name, SELECT '96333_' || SUBSTRING(CODE96333 FROM 1 FOR 2) AS name,
CODE96333 AS value CODE96333 AS value
FROM ElevatorResults WHERE row_num = 1 FROM ElevatorResults WHERE row_num = 1
...@@ -174,11 +177,13 @@ ...@@ -174,11 +177,13 @@
<select id="selectExceedElevatorCodeList" resultType="java.lang.Integer"> <select id="selectExceedElevatorCodeList" resultType="java.lang.Integer">
SELECT CODE96333 code SELECT CODE96333 code
FROM biz_jg_supervisory_code bjsc FROM biz_jg_supervisory_code bjsc
WHERE code LIKE CONCAT(#{prefix}, '%') WHERE
CODE96333 ~ '^\d+$' -- 确保是纯数字
AND CODE96333 LIKE CONCAT(#{prefix}, '%')
<if test="start != null and start != ''"> <if test="start != null and start != ''">
AND code <![CDATA[ >= ]]> #{start} AND CODE96333::BIGINT <![CDATA[ >= ]]> #{start}::BIGINT -- 数值比较
</if> </if>
ORDER BY code ORDER BY CODE96333::BIGINT -- 数值排序
</select> </select>
<select id="selectCode" resultType="java.lang.Integer"> <select id="selectCode" resultType="java.lang.Integer">
...@@ -198,6 +203,18 @@ ...@@ -198,6 +203,18 @@
SELECT CODE96333 code SELECT CODE96333 code
FROM biz_jg_supervisory_code FROM biz_jg_supervisory_code
WHERE CODE96333 = #{elevatorCode} WHERE CODE96333 = #{elevatorCode}
ORDER BY code ORDER BY code::BIGINT;
</select>
<select id="selectExceedElevatorSequenceCodeList" resultType="java.lang.Integer">
SELECT SUBSTRING(CODE96333 FROM 3) AS code
FROM biz_jg_supervisory_code bjsc
WHERE
CODE96333 ~ '^\d+$' -- 确保是纯数字
AND CODE96333 LIKE CONCAT(#{prefix}, '%')
<if test="start != null and start != ''">
AND CODE96333::BIGINT <![CDATA[ >= ]]> #{start}::BIGINT -- 数值比较
</if>
ORDER BY CODE96333::BIGINT -- 数值排序
</select> </select>
</mapper> </mapper>
...@@ -273,6 +273,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -273,6 +273,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private ESElavtorRepository esElavtorRepository; private ESElavtorRepository esElavtorRepository;
@Value("${regulator.unit.code}") @Value("${regulator.unit.code}")
private String code; private String code;
// 仅测试时使用该起始序列号,默认为空。正式环境不配置该属性时使用枚举里的值
@Value("${ymt.createCode.96333.startCode:}")
private String startCode;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
// 一码通checkCode中redis key过期时间 // 一码通checkCode中redis key过期时间
...@@ -718,7 +723,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -718,7 +723,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
log.info("生成码成功"); log.info("生成码成功");
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo(); SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionCode)); SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisorCode.toString()));
// 将生成的码添加到码表中,码的使用状态为初始状态 // 将生成的码添加到码表中,码的使用状态为初始状态
String equState = EquipmentCategoryEnum.CSZT.getCode(); String equState = EquipmentCategoryEnum.CSZT.getCode();
supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode)); supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode));
...@@ -882,16 +887,26 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -882,16 +887,26 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) { if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
Integer start = Integer.valueOf(prefix + EquipmentCategoryEnum.getCode.get(prefix)); // 改为都只拿序列号查找比较
Integer end = Integer.valueOf(elevatorOtherInfo.getCode()); int start = Integer.parseInt(ValidationUtil.isEmpty(startCode) ? EquipmentCategoryEnum.getCode.get(prefix) : startCode);
List<Integer> allCodeList = IntStream.rangeClosed(start, end) int end = Integer.parseInt(elevatorOtherInfo.getCode().substring(2));
.boxed()
.collect(Collectors.toList()); List<Integer> codeList = categoryOtherInfoMapper.selectExceedElevatorSequenceCodeList(Integer.valueOf(prefix + start), prefix);
List<Integer> codeList = categoryOtherInfoMapper.selectExceedElevatorCodeList(start, prefix); // 使用TreeSet便于快速查找和排序
List<Integer> resultList = getDiffrent(allCodeList, codeList); TreeSet<Integer> usedCodes = new TreeSet<>(codeList);
if (!ObjectUtils.isEmpty(resultList)) {
Integer firstAvailableCode = null;
// 从start开始查找第一个未使用的编码
for (int i = start; i <= end; i++) {
if (!usedCodes.contains(i)) {
firstAvailableCode = i;
break;
}
}
if (firstAvailableCode != null) {
elevatorCode.setLength(0); elevatorCode.setLength(0);
elevatorCode.append(resultList.get(0)); elevatorCode.append(prefix).append(firstAvailableCode);
} else { } else {
//// 获取补零位长度 //// 获取补零位长度
//String elevatorCode1 = elevatorOtherInfo.getCode().substring(2); //String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
......
...@@ -35,6 +35,8 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -35,6 +35,8 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory"; private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory";
private static final String SEQUENCE_TYPE_UR = "%05d"; private static final String SEQUENCE_TYPE_UR = "%05d";
private static final String SEQUENCE_TYPE = "%08d"; private static final String SEQUENCE_TYPE = "%08d";
private static final String SUPERVISOR_SEQUENCE_TYPE = "%07d";
private final RedisTemplate<String, String> redisTemplate; private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate stringRedisTemplate; private final StringRedisTemplate stringRedisTemplate;
private final CategoryOtherInfoMapper categoryOtherInfoMapper; private final CategoryOtherInfoMapper categoryOtherInfoMapper;
...@@ -93,6 +95,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -93,6 +95,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
} }
@Override @Override
@Deprecated
public boolean reduceElevatorCode(String key) { public boolean reduceElevatorCode(String key) {
return reduceSequence(key, SEQUENCE_TYPE, LOCK_KEY_ELEVATOR); return reduceSequence(key, SEQUENCE_TYPE, LOCK_KEY_ELEVATOR);
} }
...@@ -127,7 +130,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -127,7 +130,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr); log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++; currentSequence++;
// 生成顺序码 // 生成顺序码
String formattedSequence = String.format(GenerateCodeServiceImpl.SEQUENCE_TYPE, currentSequence); String formattedSequence = String.format(GenerateCodeServiceImpl.SUPERVISOR_SEQUENCE_TYPE, currentSequence);
log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence); log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码 // 更新顺序码
valueOps.set(sequenceKey, formattedSequence); valueOps.set(sequenceKey, formattedSequence);
...@@ -294,13 +297,19 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -294,13 +297,19 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, initialCode); log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, initialCode);
return initialCode; return initialCode;
} }
// currentSequenceStr截取前两位作为prefix
Long currentSequence = Long.parseLong(currentSequenceStr); String prefix = currentSequenceStr.substring(0, 2);
// 截取剩余的数字作为顺序码
currentSequenceStr = currentSequenceStr.substring(2);
long currentSequence = Long.parseLong(currentSequenceStr);
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr); log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++; currentSequence++;
currentSequence = Long.parseLong(prefix + currentSequence);
// 生成顺序码 // 生成顺序码
String formattedSequence = String.format(sequenceType, currentSequence); String formattedSequence = String.format(sequenceType, currentSequence);
// 去除先导0字符
formattedSequence = formattedSequence.replaceFirst("^0+", "");
log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence); log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码 // 更新顺序码
valueOps.set(sequenceKey, formattedSequence); valueOps.set(sequenceKey, formattedSequence);
......
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