Commit a1c10465 authored by 刘林's avatar 刘林

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

parents 2208eb06 b2db7751
......@@ -325,5 +325,6 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
*/
List<CountDto> countBizNumAfterUseRegBatchProjectContraption(@Param("projectContraptionIds") List<Long> projectContraptionIds);
List<Map<String, String>> gdEquOnJgServiceOperationRecords(@Param("record") String record);
}
......@@ -3131,4 +3131,33 @@
)
group by projectContraptionId
</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>
......@@ -213,7 +213,7 @@
<select id="getListPage" resultType="java.util.Map">
SELECT * FROM (
-- 查询 equListCode = '8000' 的情况
-- 查询 equListCode != '8000' 的情况
SELECT *
FROM (
<include refid="page-list-sub-select"/>
......@@ -291,7 +291,7 @@
</where>
UNION ALL
-- 查询 equListCode != '8000' 的情况
-- 查询 equListCode == '8000' 的情况
SELECT *
FROM (
<include refid="page-list-sub-pipline"/>
......
......@@ -786,6 +786,9 @@ public class CommonEquipDataProcessService {
IdxBizJgConstructionInfo constructionInfo = jgUseRegistrationService.getIdxBizJgConstructionInfoService().queryNewestDetailByRecord(record);
BaseTechParamsFieldDto techParamsFieldDto = this.buildTechParamInfo(registerInfo, record);
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(factoryInfo));
re.putAll(BeanUtil.beanToMap(otherInfo));
......
......@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
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.jg.api.common.BizCommonConstant;
import com.yeejoin.amos.boot.module.jg.api.dto.FieldChangeMeta;
......@@ -32,6 +34,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 单个维护设备-策略实现类
......@@ -48,6 +51,8 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
private final RestHighLevelClient restHighLevelClient;
private final EsEquipmentDao esEquipmentDao;
@Override
public HandleResult handle(Map<String, Object> changeData, String record) {
......@@ -149,6 +154,16 @@ public class SingleEquipChangeProcess implements IEquipChangeDataProcessStrategy
esUpdateService.updateEsData(record, factoryInfoNew);
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);
// 设备技术参数入库处理
......
......@@ -765,7 +765,7 @@ public class EquipClaimServiceImpl {
useInfo.setIsIntoManagement(isIntoManagement);
useInfo.setUseUnitCreditCode(company.getCompanyCode());
useInfo.setUseUnitName(company.getCompanyName());
useInfo.setSequenceNbr(Objects.toString(equipInfo.get("USEINFO_SEQ")));
useInfo.setSequenceNbr(Objects.toString(equipInfo.get("USEINFO_SEQ"), null));
// 产权单位
if (!ObjectUtils.isEmpty(equipInfo.getString("estateUnitSeq"))) {
String estateUnitSeq = equipInfo.getString("estateUnitSeq");
......@@ -794,20 +794,20 @@ public class EquipClaimServiceImpl {
IdxBizJgDesignInfo designInfo = JSON.parseObject(toJSONString(equipInfo), IdxBizJgDesignInfo.class);
designInfo.setRecord(record);
designInfo.setRecDate(timestamp);
designInfo.setSequenceNbr(Objects.toString(equipInfo.get("DESIGNINFO_SEQ")));
designInfo.setSequenceNbr(Objects.toString(equipInfo.get("DESIGNINFO_SEQ"), null));
iIdxBizJgDesignInfoService.saveOrUpdateData(designInfo);
// 制造信息
IdxBizJgFactoryInfo factoryInfo = JSON.parseObject(toJSONString(equipInfo), IdxBizJgFactoryInfo.class);
factoryInfo.setRecord(record);
factoryInfo.setRecDate(timestamp);
factoryInfo.setProductQualityYieldProve(ValidationUtil.isEmpty(equipInfo.get("PRODUCT_QUALITY_YIELD_PROVE")) ? null : toJSONString(equipInfo.get("PRODUCT_QUALITY_YIELD_PROVE")));
factoryInfo.setSequenceNbr(Objects.toString(equipInfo.get("FACTORYINFO_SEQ")));
factoryInfo.setSequenceNbr(Objects.toString(equipInfo.get("FACTORYINFO_SEQ"), null));
iIdxBizJgFactoryInfoService.saveOrUpdateData(factoryInfo);
// 施工信息
IdxBizJgConstructionInfo constructionInfo = JSON.parseObject(toJSONString(equipInfo), IdxBizJgConstructionInfo.class);
constructionInfo.setRecord(record);
constructionInfo.setRecDate(timestamp);
constructionInfo.setSequenceNbr(Objects.toString(equipInfo.get("CONSTRUCTIONINFO_SEQ")));
constructionInfo.setSequenceNbr(Objects.toString(equipInfo.get("CONSTRUCTIONINFO_SEQ"), null));
if (!ObjectUtils.isEmpty(constructionInfo.getConstructionProvince())) {
constructionInfo.setConstructionProvinceName("陕西省");
}
......@@ -830,20 +830,20 @@ public class EquipClaimServiceImpl {
registerInfo.setUseOrgCode(Objects.toString(equipInfo.get("useRegistrationCode"), null));
registerInfo.setProductPhoto(ValidationUtil.isEmpty(equipInfo.get("PRODUCT_PHOTO")) ? null : toJSONString(equipInfo.get("PRODUCT_PHOTO")));
registerInfo.setOtherAccessoriesReg(ValidationUtil.isEmpty(equipInfo.get("OTHER_ACCESSORIES_REG")) ? null : toJSONString(equipInfo.get("OTHER_ACCESSORIES_REG")));
registerInfo.setSequenceNbr(Objects.toString(equipInfo.get("REGISTERINFO_SEQ")));
registerInfo.setSequenceNbr(Objects.toString(equipInfo.get("REGISTERINFO_SEQ"), null));
jgRegisterInfoService.saveOrUpdate(registerInfo);
// 监督管理
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(toJSONString(equipInfo), IdxBizJgSupervisionInfo.class);
supervisionInfo.setRecord(record);
supervisionInfo.setRecDate(timestamp);
supervisionInfo.setSequenceNbr(Objects.toString(equipInfo.get("SUPERVISIONINFO_SEQ")));
supervisionInfo.setSequenceNbr(Objects.toString(equipInfo.get("SUPERVISIONINFO_SEQ"), null));
iIdxBizJgSupervisionInfoService.saveOrUpdateData(supervisionInfo);
// 其他信息
IdxBizJgOtherInfo otherInfo = JSON.parseObject(toJSONString(equipInfo), IdxBizJgOtherInfo.class);
otherInfo.setRecord(record);
otherInfo.setClaimStatus("已认领");
otherInfo.setRecDate(timestamp);
otherInfo.setSequenceNbr(Objects.toString(equipInfo.get("OTHERINFO_SEQ")));
otherInfo.setSequenceNbr(Objects.toString(equipInfo.get("OTHERINFO_SEQ"), null));
iIdxBizJgOtherInfoService.saveOrUpdateData(otherInfo);
// 检验检测信息
IdxBizJgInspectionDetectionInfo inspectionDetectionInfo = JSON.parseObject(toJSONString(equipInfo), IdxBizJgInspectionDetectionInfo.class);
......@@ -856,7 +856,7 @@ public class EquipClaimServiceImpl {
if (inspectionDetectionInfo.getNextInspectDate() != null) {
inspectionDetectionInfo.setNextInspectDate(DateUtil.parse(DateUtil.format(inspectionDetectionInfo.getNextInspectDate(), DatePattern.NORM_DATE_PATTERN)));
}
inspectionDetectionInfo.setSequenceNbr(Objects.toString(equipInfo.get("INSPECTIONDETECTIONINFO_SEQ")));
inspectionDetectionInfo.setSequenceNbr(Objects.toString(equipInfo.get("INSPECTIONDETECTIONINFO_SEQ"), null));
iIdxBizJgInspectionDetectionInfoService.saveOrUpdateData(inspectionDetectionInfo);
// 技术参数
jgRegisterInfoService.saveOrUpdateEquParams(new LinkedHashMap<>(equipInfo), new LinkedHashMap<>(equipParams), equList, record, timestamp, "edit");
......
......@@ -4325,13 +4325,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
.map(parts -> parts[1])
.orElse(null));
useInfo.setPhone(String.valueOf(map.get("phone")));
useInfo.setSafetyManager(String.valueOf(Optional.ofNullable(map.get("safetyManager"))
.map(Object::toString)
.filter(s -> s.contains("_"))
.map(s -> s.split("_", 2))
.filter(parts -> parts.length == 2)
.map(parts -> parts[0])
.orElse(null)));
useInfo.setSafetyManager(map.getString("safetyManagerName"));
useInfo.setSafetyManagerId(map.getString("safetyManagerId"));
useInfo.setUseDate(String.valueOf(map.get("useDate")));
useInfo.setLongitudeLatitude(JSON.toJSONString(map.get("longitudeLatitude")));
useInfo.setUsePlace((String) map.get("usePlace"));
......
......@@ -1144,13 +1144,12 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
// 更新设备监管部门
IdxBizJgSupervisionInfo idxBizJgSupervisionInfo = new IdxBizJgSupervisionInfo();
if (map.containsKey("orgBranchCode") && !ObjectUtils.isEmpty(map.get("orgBranchCode"))) {
String[] data = String.valueOf(map.getString("orgBranchCode")).split("_");
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(data[0]).getResult();
if (!ObjectUtils.isEmpty(jgVehicleInformation.getOrgBranchCode())) {
HashMap<String, Object> parentMessage = (HashMap<String, Object>) Privilege.companyClient.queryByOrgcode(jgVehicleInformation.getOrgBranchCode()).getResult();
// 目前平台返回key为compnay(存在拼写错误)
CompanyModel parentModel = JSON.parseObject(JSON.toJSONString(parentMessage.get("compnay")), CompanyModel.class);
idxBizJgSupervisionInfo.setOrgBranchCode(data[0]);
idxBizJgSupervisionInfo.setOrgBranchName(data[1]);
idxBizJgSupervisionInfo.setOrgBranchCode(jgVehicleInformation.getOrgBranchCode());
idxBizJgSupervisionInfo.setOrgBranchName(jgVehicleInformation.getOrgBranchName());
idxBizJgSupervisionInfo.setCompanyOrgBranchCode(parentModel.getCompanyCode());
LambdaQueryWrapper<IdxBizJgSupervisionInfo> eq = new QueryWrapper<IdxBizJgSupervisionInfo>().lambda().eq(IdxBizJgSupervisionInfo::getRecord, map.get("record"));
idxBizJgSupervisionInfoMapper.update(idxBizJgSupervisionInfo, eq);
......
......@@ -25,7 +25,15 @@ public interface TzsCustomFilterMapper extends BaseMapper<TzsCustomFilter> {
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);
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;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class TzsUserInfoVo {
/**
* 主键
*/
@TableId(value = "sequence_nbr")
protected Long sequenceNbr;
/**
* 姓名
*/
@TableField("name")
......@@ -119,6 +124,13 @@ public class TzsUserInfoVo {
*/
@TableField("unit_name")
private String unitName;
/**
* 单位code
*/
@TableField("unit_code")
private String unitCode;
/**
* 头像
*/
......
......@@ -34,7 +34,7 @@
<select id="selectEquipmentCategoryCountByParentId" resultType="java.lang.Integer">
select count(1) from tz_equipment_category where is_delete = 0 and parent_id = #{parentId}
</select>
<select id="selectRecords" resultType="java.lang.String">
<select id="selectGasRecords" resultType="java.lang.String">
SELECT
ibjui."RECORD"
FROM
......@@ -50,6 +50,58 @@
AND "CLAIM_STATUS" = '已认领'
order by ibjui."RECORD" desc
</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 INTO "amos_tzs_biz"."idx_biz_jg_supervision_info" ("SEQUENCE_NBR", "RECORD")
......
......@@ -496,4 +496,16 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
public ResponseModel<JSONArray> 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 {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "common/equOnJgServiceOperationRecords")
@ApiOperation(httpMethod = "GET", value = "查询设备在jg业务中的记录", notes = "查询设备在jg业务中的记录")
public ResponseModel<List<Map<String, String>>> equOnJgServiceOperationRecords(@RequestParam(value = "record") String record) {
return ResponseHelper.buildResponse(statisticsService.equOnJgServiceOperationRecords(record));
public ResponseModel<List<Map<String, String>>> equOnJgServiceOperationRecords(@RequestParam(value = "record") String 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;
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.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.entity.ESEquipmentInfo;
import com.yeejoin.amos.boot.module.common.biz.utils.TechParamUtil;
......@@ -125,6 +126,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private final String or = "or";
private final String and = "and";
private final EsEquipmentDao esEquipmentDao;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
......@@ -4039,7 +4042,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
for (int j = 0; j <= times; j++) {
recordDtoPage.setCurrent(j + 1);
recordDtoPage.setSize(5000);
Page<String> refreshRecords = tzsCustomFilterMapper.selectRecords(recordDtoPage);
Page<String> refreshRecords = tzsCustomFilterMapper.selectGasRecords(recordDtoPage);
if (!ObjectUtils.isEmpty(refreshRecords) && refreshRecords.getRecords().size() > 0) {
total += refreshRecords.getRecords().size();
tzsCustomFilterMapper.addGas(refreshRecords.getRecords());
......@@ -4047,4 +4050,65 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
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
......@@ -2135,8 +2135,14 @@ public class JGDPStatisticsServiceImpl {
}
}
public List<Map<String, String>> equOnJgServiceOperationRecords(String record) {
return commonMapper.equOnJgServiceOperationRecords(record).stream()
public List<Map<String, String>> equOnJgServiceOperationRecords(String record, String equipType) {
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<String, String> map = new HashMap<>();
map.put("operatingTime", x.get("recDate"));
......
......@@ -23,7 +23,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.ArrayList;
......@@ -90,7 +89,7 @@ public class UserBizByTCMServiceImpl {
tzsUserInfoVo.setSpeciality_required(tzsUserInfo.getSpeciality());
tzsUserInfoVo.setEducation_required(tzsUserInfo.getEducation());
tzsUserInfoVo.setJobTitle_required(tzsUserInfo.getJobTitle());
String companyType = getUnitType();
String companyType = getUnitType(tzsUserInfo.getUnitCode());
tzsUserInfoVo.setCompanyType(companyType.contains("个人主体") ? "individual" : "no-individual");
Map<String, Object> userInfoMap = BeanUtil.beanToMap(tzsUserInfoVo);
// userInfoMap.putAll(this.getPermissionDataJson(tzsUserInfo.getPermissionData()));
......@@ -101,12 +100,12 @@ public class UserBizByTCMServiceImpl {
return maps;
}
public String getUnitType() {
List<CompanyModel> companyModels = FeignUtil.remoteCall(() -> Privilege.companyClient.queryListByChild(RequestContext.getExeUserId()));
if (companyModels.isEmpty()) {
public String getUnitType(String unitCode) {
CompanyModel companyModel = FeignUtil.remoteCall(() -> Privilege.companyClient.queryByCompanyCode(unitCode));
if (ObjectUtils.isEmpty(companyModel)) {
return "";
}
return companyModels.get(0).getCompanyType();
return companyModel.getCompanyType();
}
/**
......
......@@ -89,7 +89,8 @@
"httpMethod":"GET",
"apiPath":"/statistics/dp/jg/common/equOnJgServiceOperationRecords",
"params": {
"record": "{record}"
"record": "{record}",
"equipType": "8000"
},
"ruleData": {
"responseSuccess": "data.result",
......
......@@ -324,7 +324,7 @@
FROM
"tzs_user_info" u
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>
u.is_delete = false
<if test="filter.orgCode != null and filter.orgCode != ''">
......
......@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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.enums.UserPostEnum;
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.tcm.api.dto.*;
......@@ -1080,12 +1081,15 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
throw new BadRequest("本单位下用户证件号码重复,请核对!");
}
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
.eq(TzsUserInfo::getCertificateType, tzsUserInfo.getCertificateType())
.eq(TzsUserInfo::getCertificateNum, tzsUserInfo.getCertificateNum())
.ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode())
.eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!");
// 当人员类型仅为主要负责人时,不校验是否被其他单位绑定
if (!JSON.toJSONString(Collections.singletonList(UserPostEnum.ZYFZR.getCode())).equals(tzsUserInfo.getNewPost())) {
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
.eq(TzsUserInfo::getCertificateType, tzsUserInfo.getCertificateType())
.eq(TzsUserInfo::getCertificateNum, tzsUserInfo.getCertificateNum())
.ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode())
.eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!");
}
}
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
......@@ -1205,13 +1209,15 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
.eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("本单位下用户证件号码重复,请核对!");
}
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
.eq(TzsUserInfo::getCertificateType, tzsUserInfoDto.getCertificateType())
.eq(TzsUserInfo::getCertificateNum, tzsUserInfoDto.getCertificateNum())
.ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode())
.eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!");
// 当人员类型仅为主要负责人时,不校验是否被其他单位绑定
if (!JSON.toJSONString(Collections.singletonList(UserPostEnum.ZYFZR.getCode())).equals(tzsUserInfoDto.getNewPost())) {
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
.eq(TzsUserInfo::getCertificateType, tzsUserInfoDto.getCertificateType())
.eq(TzsUserInfo::getCertificateNum, tzsUserInfoDto.getCertificateNum())
.ne(TzsUserInfo::getUnitCode, companyModel.getCompanyCode())
.eq(TzsUserInfo::getIsDelete, false)) > 0) {
throw new BadRequest("该用户已被其他单位绑定,请联系原单位转出!");
}
}
if (tzsUserInfoMapper.selectCount(new LambdaQueryWrapper<TzsUserInfo>()
......
......@@ -44,6 +44,8 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
List<Integer> selectExceedElevatorCodeList(Integer start,String prefix);
List<Integer> selectExceedElevatorSequenceCodeList(Integer start,String prefix);
Integer selectCode(Integer start, Integer end, String prefix);
/**
......
......@@ -26,21 +26,24 @@
SELECT CODE96333 code
FROM biz_jg_supervisory_code bjsc
WHERE CODE96333 LIKE CONCAT(#{elevatorCode}, '%')
AND CODE96333 ~ '^\d+$' -- 确保是纯数字
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="status != 2 ">ORDER BY CAST(CODE96333 AS UNSIGNED) DESC LIMIT 1 </if>
<if test="status == 2 ">ORDER BY CAST(CODE96333 AS UNSIGNED) ASC LIMIT 1 </if>
<if test="status != 2 ">ORDER BY CODE96333::BIGINT DESC LIMIT 1 </if>
<if test="status == 2 ">ORDER BY CODE96333::BIGINT ASC LIMIT 1 </if>
</select>
<select id="selectElevatorCodeMaxValue" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.KV">
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
FROM biz_jg_supervisory_code
WHERE CREATE_STATUS = 1
AND CODE96333 IS NOT NULL
AND CODE96333 <![CDATA[<> '']]>)
AND CODE96333 <![CDATA[<> '']]>
AND CODE96333 ~ '^\d+$' -- 确保是纯数字
)
SELECT '96333_' || SUBSTRING(CODE96333 FROM 1 FOR 2) AS name,
CODE96333 AS value
FROM ElevatorResults WHERE row_num = 1
......@@ -174,11 +177,13 @@
<select id="selectExceedElevatorCodeList" resultType="java.lang.Integer">
SELECT CODE96333 code
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 != ''">
AND code <![CDATA[ >= ]]> #{start}
AND CODE96333::BIGINT <![CDATA[ >= ]]> #{start}::BIGINT -- 数值比较
</if>
ORDER BY code
ORDER BY CODE96333::BIGINT -- 数值排序
</select>
<select id="selectCode" resultType="java.lang.Integer">
......@@ -198,6 +203,18 @@
SELECT CODE96333 code
FROM biz_jg_supervisory_code
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>
</mapper>
......@@ -273,6 +273,11 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private ESElavtorRepository esElavtorRepository;
@Value("${regulator.unit.code}")
private String code;
// 仅测试时使用该起始序列号,默认为空。正式环境不配置该属性时使用枚举里的值
@Value("${ymt.createCode.96333.startCode:}")
private String startCode;
@Autowired
private RedisUtils redisUtils;
// 一码通checkCode中redis key过期时间
......@@ -718,7 +723,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
log.info("生成码成功");
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();
supervisoryCodeInfo.setCode96333(String.valueOf(elevatorCode));
......@@ -882,16 +887,26 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(elevatorOtherInfo) && elevatorOtherInfo.getCode() != null) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Integer start = Integer.valueOf(prefix + EquipmentCategoryEnum.getCode.get(prefix));
Integer end = Integer.valueOf(elevatorOtherInfo.getCode());
List<Integer> allCodeList = IntStream.rangeClosed(start, end)
.boxed()
.collect(Collectors.toList());
List<Integer> codeList = categoryOtherInfoMapper.selectExceedElevatorCodeList(start, prefix);
List<Integer> resultList = getDiffrent(allCodeList, codeList);
if (!ObjectUtils.isEmpty(resultList)) {
// 改为都只拿序列号查找比较
int start = Integer.parseInt(ValidationUtil.isEmpty(startCode) ? EquipmentCategoryEnum.getCode.get(prefix) : startCode);
int end = Integer.parseInt(elevatorOtherInfo.getCode().substring(2));
List<Integer> codeList = categoryOtherInfoMapper.selectExceedElevatorSequenceCodeList(Integer.valueOf(prefix + start), prefix);
// 使用TreeSet便于快速查找和排序
TreeSet<Integer> usedCodes = new TreeSet<>(codeList);
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.append(resultList.get(0));
elevatorCode.append(prefix).append(firstAvailableCode);
} else {
//// 获取补零位长度
//String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
......
......@@ -35,6 +35,8 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory";
private static final String SEQUENCE_TYPE_UR = "%05d";
private static final String SEQUENCE_TYPE = "%08d";
private static final String SUPERVISOR_SEQUENCE_TYPE = "%07d";
private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate stringRedisTemplate;
private final CategoryOtherInfoMapper categoryOtherInfoMapper;
......@@ -128,7 +130,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++;
// 生成顺序码
String formattedSequence = String.format(GenerateCodeServiceImpl.SEQUENCE_TYPE, currentSequence);
String formattedSequence = String.format(GenerateCodeServiceImpl.SUPERVISOR_SEQUENCE_TYPE, currentSequence);
log.info("===================>更新《{}》顺序码:{}<===================", 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