Commit e682aae7 authored by 麻笑宇's avatar 麻笑宇

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

parents f2a92fa0 185307ab
......@@ -622,8 +622,9 @@
tz_base_enterprise_info i
WHERE
i.app_id = f.app_id
AND f.filling_endtime >= concat(#{startTime}, ' 00:00:00')
AND f.filling_endtime >= concat(#{startTime}, ' 00:00:00')
AND i.org_code like concat(#{orgCode}, '%')
AND i.unit_type like '%充装单位%'
GROUP BY
filling_time
ORDER BY
......
......@@ -60,6 +60,15 @@ public class JgUseRegistrationDto extends BaseDto {
@ApiModelProperty(value = "终审通过时间")
private Date auditPassDate;
@ApiModelProperty(value = "办理日期范围")
private String auditPassDateRange;
@ApiModelProperty(value = "办理日期起始日期")
private Date auditPassDateStart;
@ApiModelProperty(value = "办理日期结束日期")
private Date auditPassDateEnd;
@ApiModelProperty(value = "登记类别")
private String regType;
......
......@@ -31,7 +31,7 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
@Param("dto") JgUseRegistrationDto dto,
@Param("roleIds") List<String> roleIds);
List<RegistrationVo> queryRegistrationInIds(@Param("ids") List<String> ids);
List<RegistrationVo> queryRegistrationInIds(@Param("dto") JgUseRegistrationDto dto);
Map<String, Object> getDetail(@Param("id") String id);
......
......@@ -14,49 +14,52 @@ public class RegistrationVo {
@ExcelProperty(value = "申请日期", index = 1)
String createDate;
@ExcelProperty(value = "登记证来源", index = 2)
String regType;
@ExcelProperty(value = "设备种类", index = 2)
@ExcelProperty(value = "设备种类", index = 3)
String equListName;
@ExcelProperty(value = "设备类别", index = 3)
@ExcelProperty(value = "设备类别", index = 4)
String equCategory;
@ExcelProperty(value = "设备品种", index = 4)
@ExcelProperty(value = "设备品种", index = 5)
String equDefine;
@ExcelProperty(value = "设备代码", index = 5)
@ExcelProperty(value = "设备代码", index = 6)
String equCode;
@ExcelProperty(value = "使用登记证编号", index = 6)
@ExcelProperty(value = "使用登记证编号", index = 7)
String useRegistrationCode;
@ExcelProperty(value = "96333识别码", index = 7)
@ExcelProperty(value = "96333识别码", index = 8)
String code96333;
@ExcelProperty(value = "监管码", index = 8)
@ExcelProperty(value = "监管码", index = 9)
String supervisoryCode;
@ExcelProperty(value = "设备地址", index = 9)
@ExcelProperty(value = "设备地址", index = 10)
String fullAddress;
@ExcelProperty(value = "详细地址", index = 10)
@ExcelProperty(value = "详细地址", index = 11)
String detailedAddress;
@ExcelProperty(value = "使用单位", index = 11)
@ExcelProperty(value = "使用单位", index = 12)
String useUnitName;
@ExcelProperty(value = "接收机构", index = 12)
@ExcelProperty(value = "接收机构", index = 13)
String receiveOrgName;
@ExcelProperty(value = "属地监管部门", index = 13)
@ExcelProperty(value = "属地监管部门", index = 14)
String orgBranchName;
@ExcelProperty(value = "作废原因", index = 14)
@ExcelProperty(value = "作废原因", index = 15)
String cancelReason;
@ExcelProperty(value = "办理状态", index = 15)
@ExcelProperty(value = "办理状态", index = 16)
String status;
@ExcelProperty(value = "办理日期", index = 16)
@ExcelProperty(value = "办理日期", index = 17)
String auditPassDate;
}
......@@ -86,7 +86,7 @@
idx_biz_jg_register_info jri
LEFT JOIN idx_biz_jg_other_info other on jri.RECORD = other.RECORD where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as supervisoryCode ,
(SELECT
group_concat(other.CODE96333)
group_concat(IFNULL(other.CODE96333, '') SEPARATOR ',')
from
idx_biz_jg_register_info jri
LEFT JOIN idx_biz_jg_other_info other on jri.RECORD = other.RECORD where jri.RECORD in (select re.equ_id from tzs_jg_use_registration_eq re where ur.sequence_nbr = re.equip_transfer_id)) as code96333 ,
......@@ -182,6 +182,9 @@
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
and use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND auditPassDate BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
AND (receive_company_code = #{dto.receiveCompanyCode} or transfer_to_user_ids LIKE concat ('%',
#{dto.currentUserId}, '%'))
......@@ -203,19 +206,73 @@
</select>
<select id="queryRegistrationInIds" resultType="com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.RegistrationVo">
<include refid="page-list"/>
select
*
from
(
<include refid="page-list-sub-select"/>
)
<where>
<if test='ids != null'>
and ur.sequence_nbr in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
is_delete = 0
<if test="dto.equList != null and dto.equList != ''">
and equListCode= #{dto.equList}
</if>
<if test="dto.equCategory != null and dto.equCategory != ''">
and equCategoryCode = #{dto.equCategory}
</if>
<if test="dto.equDefine != null and dto.equDefine != ''">
and equDefineCode = #{dto.equDefine}
</if>
<if test="dto.status != null and dto.status != ''">
and status = #{dto.status}
</if>
<if test="dto.applicationDate != null">
and create_date like concat('%',DATE_FORMAT(#{dto.applicationDate},'%Y-%m-%d'),'%')
</if>
<if test="dto.equCode != null and dto.equCode != ''">
and equCode like concat('%',#{dto.equCode},'%')
</if>
<if test="dto.code96333 != null and dto.code96333 != ''">
and code96333 like concat('%',#{dto.code96333},'%')
</if>
<if test="dto.supervisoryCode != null and dto.supervisoryCode != ''">
and supervisoryCode like concat('%',#{dto.supervisoryCode},'%')
</if>
<if test="dto.fullAddress != null and dto.fullAddress != ''">
AND fullAddress LIKE CONCAT('%', #{dto.fullAddress}, '%')
</if>
<if test="dto.receiveCompanyCode != null and dto.receiveCompanyCode != ''">
AND receive_company_code = #{dto.receiveCompanyCode}
</if>
<if test="dto.useUnitName != null and dto.useUnitName != ''">
and useUnitName like concat('%',#{dto.useUnitName},'%')
</if>
<if test="dto.applyNo != null and dto.applyNo != ''">
and applyNo like concat('%',#{dto.applyNo},'%')
</if>
<if test="dto.useRegistrationCode != null and dto.useRegistrationCode != ''">
and useRegistrationCode like concat('%',#{dto.useRegistrationCode},'%')
</if>
<if test="dto.useUnitCode != null and dto.useUnitCode != ''">
and use_unit_credit_code = #{dto.useUnitCode}
</if>
<if test="dto.auditPassDateStart != null and dto.auditPassDateEnd != null">
AND auditPassDate BETWEEN #{dto.auditPassDateStart} AND #{dto.auditPassDateEnd}
</if>
<if test="dto.dataType == 'supervision' ">
AND (receive_company_code = #{dto.receiveCompanyCode} or transfer_to_user_ids LIKE concat ('%',
#{dto.currentUserId}, '%'))
AND status <![CDATA[<>]]> '使用单位待提交'
</if>
<if test="dto.dataType == 'company' ">
AND (use_unit_credit_code = #{dto.unitCode} or transfer_to_user_ids LIKE concat ('%',#{dto.currentUserId}, '%'))
</if>
</where>
GROUP BY
re.equip_transfer_id
-- GROUP BY
-- re.equip_transfer_id
order by
ur.create_date DESC, ur.apply_no DESC
create_date DESC, applyNo DESC
</select>
<select id="getDetail" resultType="java.util.Map">
......
package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.biz.service.IJgTableDataExportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -91,9 +94,18 @@ public class JgTableDataExportController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/registration")
@ApiOperation(httpMethod = "GET", value = "使用登记列表数据导出", notes = "使用登记列表数据导出")
public void registrationExport(HttpServletResponse response, String ids) {
Assert.hasText(ids,"未选择导出数据");
iJgTableDataExportService.registration(response, Arrays.asList(ids.split(",")));
public void registrationExport(HttpServletResponse response, JgUseRegistrationDto dto) {
ReginParams info = getSelectedOrgInfo();
dto.setCurrentUserId(info.getUserModel().getUserId());
if (info.getCompany().getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)) {
dto.setDataType(BaseController.COMPANY_TYPE_COMPANY);
dto.setUnitCode(CompanyTypeEnum.INDIVIDUAL.getName().equals(info.getCompany().getCompanyType()) ?
info.getCompany().getCompanyCode().split("_")[1] : info.getCompany().getCompanyCode());
} else {
dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION);
dto.setReceiveCompanyCode(info.getCompany().getCompanyCode());
}
iJgTableDataExportService.registration(response, dto);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -27,6 +27,8 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
......@@ -111,6 +113,26 @@ public class JgUseRegistrationController extends BaseController {
dto.setDataType(BaseController.COMPANY_TYPE_SUPERVISION);
dto.setReceiveCompanyCode(info.getCompany().getCompanyCode());
}
if (dto.getAuditPassDateRange() != null && !dto.getAuditPassDateRange().isEmpty() && !dto.getAuditPassDateRange().equals("[, ]")) {
String dateRangeStr = dto.getAuditPassDateRange();
String[] dates = dateRangeStr.replace("[", "").replace("]", "").split(", ");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date start = null;
Date end = null;
try {
start = dateFormat.parse(dates[0]);
end = dateFormat.parse(dates[1]);
} catch (ParseException e) {
throw new RuntimeException(e);
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
calendar.add(Calendar.DAY_OF_MONTH, -1);
start = calendar.getTime();
dto.setAuditPassDateStart(start);
dto.setAuditPassDateEnd(end);
}
Page<Map<String, Object>> list = jgUseRegistrationServiceImpl.getList(dto, sort, page, dto.getRoleIds());
list.getRecords().forEach(x -> {
x.put("companyType", info.getCompany().getCompanyType());
......@@ -252,6 +274,7 @@ public class JgUseRegistrationController extends BaseController {
/**
* 使用登记流程错误数据处理
*
* @param applyNo applyNo
* @return s
*/
......@@ -260,7 +283,7 @@ public class JgUseRegistrationController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "使用登记流程错误数据处理", notes = "使用登记流程错误数据处理")
public ResponseModel<Object> handleErrorForm(@RequestParam("applyNo") String applyNo) {
jgUseRegistrationServiceImpl.handleErrorForm(applyNo);
return ResponseHelper.buildResponse("申请单【"+applyNo+"】处理成功");
return ResponseHelper.buildResponse("申请单【" + applyNo + "】处理成功");
}
......@@ -271,12 +294,13 @@ public class JgUseRegistrationController extends BaseController {
public ResponseModel<Object> saveHistoryEquip(@RequestBody JSONObject map) {
JSONObject firstMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("first")));
JSONObject secondMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("second")));
secondMap.put("type",firstMap.get("type"));
secondMap.put("type", firstMap.get("type"));
return ResponseHelper.buildResponse(jgUseRegistrationServiceImpl.saveHistoryEquip(secondMap));
}
/**
* 根据使用登记证查询工程装置名称
*
* @param useRegistrationCode 使用登记证
* @return projectContraption
*/
......@@ -287,7 +311,7 @@ public class JgUseRegistrationController extends BaseController {
ReginParams selectedOrgInfo = getSelectedOrgInfo();
String companyCode = selectedOrgInfo.getCompany().getCompanyCode();
String companyType = selectedOrgInfo.getCompany().getCompanyType();
String useUnitCreditCode = "个人主体".equals(companyType) && companyCode.contains("_")? companyCode.split("_", 2)[1]
String useUnitCreditCode = "个人主体".equals(companyType) && companyCode.contains("_") ? companyCode.split("_", 2)[1]
: companyCode;
HashMap<String, Object> map = new HashMap<>();
map.put("useRegistrationCode", useRegistrationCode);
......
package com.yeejoin.amos.boot.module.jg.biz.service;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -23,7 +25,7 @@ public interface IJgTableDataExportService {
void transfer(HttpServletResponse response, List<String> ids);
void registration(HttpServletResponse response, List<String> ids);
void registration(HttpServletResponse response, JgUseRegistrationDto dto);
void changeRegistrationUnit(HttpServletResponse response, List<String> ids);
......
......@@ -3012,9 +3012,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
esEquipmentDto.setUSE_INNER_CODE(useInfo.getUseInnerCode());
esEquipmentDto.setUSE_ORG_CODE(equipInfoDto.getUseOrgCode());
esEquipmentDto.setIS_INTO_MANAGEMENT("his".equals(equipInfoDto.getDataSource()));
if ("his".equals(equipInfoDto.getDataSource())) {
esEquipmentDto.setEQU_CODE(registerInfo.getEquCode());
}
esEquipmentDto.setEQU_CODE(registerInfo.getEquCode());
esEquipmentDto.setEQU_CATEGORY_CODE(equipInfoDto.getEquCategoryCode());
esEquipmentDto.setEQU_CATEGORY(equipInfoDto.getEquCategory());
esEquipmentDto.setEQU_LIST_CODE(equipInfoDto.getEquListCode());
......@@ -3362,21 +3360,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
checkNotBlank(data.getEquCodeType(), "是否有设备代码不能为空;", result);
if ("1".equals(data.getEquCodeType())) {
checkNotBlank(data.getEquCode(), "设备代码不能为空;", result);
String equCode = data.getEquCode();
if (equCode.matches("[a-zA-Z0-9]+")) {
if (equCode.length() <= 17) {
result.append("设备代码不能小于17位;");
}
if (equCode.length() >= 20) {
result.append("设备代码不能大于20位;");
}
} else {
result.append("设备代码不能包含特殊字符;");
}
if (equCodeList.contains(data.getEquCode())) {
result.append("设备代码不能重复;");
}
this.checkEquCodeUniqueness(data.getEquCode(), result);
Optional.ofNullable(data.getEquCode())
.ifPresent(equCode -> {
if (!equCode.matches("[a-zA-Z0-9]+")) {
result.append("设备代码不能包含特殊字符;");
} else {
Stream.of(equCode.length() <= 17 ? "设备代码不能小于17位;" : "",
equCode.length() >= 20 ? "设备代码不能大于20位;" : "",
equCodeList.contains(equCode) ? "设备代码不能重复;" : ""
).filter(msg -> !msg.isEmpty())
.forEach(result::append);
this.checkEquCodeUniqueness(equCode, result);
}
});
} else {
data.setEquCode("");
}
......@@ -3389,9 +3385,6 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
checkNotBlank(data.getProduceLicenseNum(), "制造许可编号不能为空;", result);
checkNotBlank(data.getFactoryNum(), "出厂编号/产品编码不能为空;", result);
if ("0".equals(data.getWhetherVehicleCylinder())) {
if (factoryNumList.contains(data.getFactoryNum())) {
result.append("出厂编号/产品编码不能重复;");
}
checkNotBlank(data.getCylinderCategory(), "气瓶分类不能为空;", result);
checkFactoryNumUnique(data.getFactoryNum(), data.getProduceUnitCreditCode(), result);
} else {
......
......@@ -942,12 +942,20 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
useRegistrationCodeList.add(String.valueOf(useRegistrationCode));
isUpdateRegistrationCode.set(true);
} else {
//如果是区内移装,判断是否为韩城,杨凌,需要变更证号,否则不变证号
// 判断区内移装是否需要变更证号,若为韩城、杨凌或西咸则需变更,否则不变
JSONObject newPosition = JSON.parseObject(historyData.getChangeData());
String county = newPosition.getString("transferCounty").split("_")[0];
JSONObject deviceInfo = JSON.parseObject(device.getDeviceInfo());
String deviceCity = Arrays.stream(((String) deviceInfo.get("USE_PLACE_CODE")).split("#"))
.skip(2)
.findFirst()
.orElseThrow(() -> new BadRequest("没有查询到地市信息"));
// 判断是否为韩城、杨凌或西咸的区内移装到其他城市或从其他城市移装到韩城、杨凌或西咸
boolean shouldUpdateCode = Arrays.stream(ReginStepEnum.values())
.map(ReginStepEnum::getCode)
.anyMatch(code -> code.equals(county));
.anyMatch(code -> code.equals(county) || code.equals(deviceCity));
if (shouldUpdateCode) {
Map<String, String> supervisoryCodeMap = this.createSupervisoryCode(historyData);
supervisoryCode = supervisoryCodeMap.get("superviseCode");
......
......@@ -1613,9 +1613,27 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
this.rollBackRegisterInfo(jgRelationEquip, idxBizJgRegisterInfo);
// 5.es 回退
this.rollBackEsInfo(jgRelationEquip, idxBizJgRegisterInfo);
//6.释放96333码为 未使用状态
this.release96333Code(jgRelationEquip);
});
}
/**
* 释放96333码为未使用状态
* @param jgRelationEquip jgRelationEquip
*/
private void release96333Code(JgInstallationNoticeEq jgRelationEquip) {
Optional.ofNullable(jgRelationEquip)
.map(JgInstallationNoticeEq::getEquId)
.map(equId -> tzsJgOtherInfoMapper.selectOne(
new LambdaQueryWrapper<OtherInfo>()
.eq(OtherInfo::getRecord, equId)
.select(OtherInfo::getSupervisoryCode)
))
.map(OtherInfo::getSupervisoryCode)
.ifPresent(code -> supervisoryCodeInfoMapper.updateStatus(Collections.singletonList(code)));
}
private void rollBackEsInfo(JgInstallationNoticeEq jgRelationEquip, IdxBizJgRegisterInfo idxBizJgRegisterInfo) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(jgRelationEquip.getEquId());
if (optional.isPresent()) {
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.*;
import com.yeejoin.amos.boot.module.jg.biz.service.IJgTableDataExportService;
......@@ -16,6 +17,10 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
......@@ -226,11 +231,37 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
* 使用登记列表数据导出
*
* @param response 响应
* @param ids 数据id
* @param dto 筛选面板数据
*/
@Override
public void registration(HttpServletResponse response, List<String> ids) {
List<RegistrationVo> exportData = registrationMapper.queryRegistrationInIds(ids);
public void registration(HttpServletResponse response, JgUseRegistrationDto dto) {
if (dto.getAuditPassDateRange() != null && !dto.getAuditPassDateRange().isEmpty() && !dto.getAuditPassDateRange().equals("[, ]")) {
String dateRangeStr = dto.getAuditPassDateRange();
String[] dates = dateRangeStr.replace("[", "").replace("]", "").split(", ");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date start = null;
Date end = null;
try {
start = dateFormat.parse(dates[0]);
end = dateFormat.parse(dates[1]);
} catch (ParseException e) {
throw new RuntimeException(e);
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(start);
calendar.add(Calendar.DAY_OF_MONTH, -1); // 减去一天
start = calendar.getTime();
dto.setAuditPassDateStart(start);
dto.setAuditPassDateEnd(end);
}
List<RegistrationVo> exportData = registrationMapper.queryRegistrationInIds(dto);
for (RegistrationVo vo : exportData) {
if (vo.getRegType()== null) {
vo.setRegType("新增登记");
} else if(vo.getRegType().equals("1")){
vo.setRegType("历史登记");
}
}
ExcelUtil.createTemplate(response, "使用登记列表数据", "使用登记列表", exportData, RegistrationVo.class, null, false);
}
......
......@@ -205,6 +205,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
private IdxBizJgConstructionInfoMapper constructionInfoMapper;
@Autowired
private SuperviseInfoMapper superviseInfoMapper;
@Autowired
SupervisoryCodeInfoMapper supervisoryCodeInfoMapper;
/**
* @param auditPassDate 通过时间
......@@ -2384,6 +2386,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
map.put("countyCode", useInfo.getCounty());
map.put("equCategory", registerInfo.getEquCategory());
map.put("isXiXian", dataMap.get("isXixian"));
//有96333码,不生成96333码,只生成监管码
if ("1".equals(otherInfo.getCode96333Type())) {
map.put("code96333", otherInfo.getCode96333());
}
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
Map<String, Object> result = code.getResult();
if (!ObjectUtils.isEmpty(result)) {
......@@ -2524,9 +2530,33 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
this.clearMainInfo(record);
// 删除检验检测信息
this.clearInspectionInfo(record);
// 释放96333码为 未使用状态
this.release96333Code(record);
}
}
/**
* 释放96333码为未使用状态
* @param record 记录值
*/
private void release96333Code(String record) {
Optional.ofNullable(
otherInfoMapper.selectOne(
new LambdaQueryWrapper<IdxBizJgOtherInfo>()
.eq(IdxBizJgOtherInfo::getRecord, record)
.select(IdxBizJgOtherInfo::getSupervisoryCode, IdxBizJgOtherInfo::getCode96333Type)
)
).ifPresent(otherInfo -> {
String supervisoryCode = otherInfo.getSupervisoryCode();
//手动输入直接删除
if ("0".equals(otherInfo.getCode96333Type())) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("SUPERVISORY_CODE", supervisoryCode));
} else {
supervisoryCodeInfoMapper.updateStatus(Collections.singletonList(supervisoryCode));
}
});
}
private void clearInspectionInfo(String record) {
inspectionDetectionInfoMapper.delete(new LambdaQueryWrapper<InspectionDetectionInfo>().eq(AbstractEquipBaseEntity::getRecord, record));
InspectionDetectionInfo inspectionDetectionInfo = new InspectionDetectionInfo();
......
......@@ -50,7 +50,7 @@
( T.filling_quantity )
FROM
tz_cylinder_filling_record T
INNER JOIN tz_base_enterprise_info E ON T.app_id = E.app_id
INNER JOIN tz_base_enterprise_info E ON T.app_id = E.app_id and E.unit_type like '%充装单位%'
WHERE
E.supervise_org_code LIKE concat ( #{orgCode}, '%' )
</select>
......@@ -60,7 +60,7 @@
( T.offloading_volume )
FROM
tz_cylinder_offloading T
INNER JOIN tz_base_enterprise_info E ON T.app_id = E.app_id
INNER JOIN tz_base_enterprise_info E ON T.app_id = E.app_id and E.unit_type like '%充装单位%'
WHERE
E.supervise_org_code LIKE concat ( #{orgCode}, '%' )
</select>
......@@ -69,7 +69,7 @@
( DISTINCT ( E.app_id ) )
FROM
tz_cylinder_filling_record
T INNER JOIN tz_base_enterprise_info E ON T.app_id = E.app_id
T INNER JOIN tz_base_enterprise_info E ON T.app_id = E.app_id and E.unit_type like '%充装单位%'
WHERE
E.supervise_org_code LIKE concat ( #{orgCode}, '%' )
</select>
......
......@@ -58,4 +58,12 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
*/
List<KV> selectSupervisorCodeMaxValue();
/**
* 查询电梯码是否重复
* @param elevatorCode 96333
* @param status 0 手动输入
* @return 0
*/
Integer checkElevatorCodeRepeat(@Param("elevatorCode") String elevatorCode, String status);
}
......@@ -45,4 +45,6 @@ public interface IEquipmentCategoryService {
void creatXiXian(String type);
Map<String, Object> commonUpdateEsDataByIds(Map<String, Map<String, Object>> paramMap);
String selectExceedElevatorCode(String prefix);
}
......@@ -38,7 +38,9 @@
SELECT ROW_NUMBER() OVER (PARTITION BY SUBSTRING (CODE96333 FROM 1 FOR 2) ORDER BY CODE96333 DESC) AS row_num,
CODE96333
FROM biz_jg_supervisory_code
WHERE CODE96333 IS NOT NULL AND CODE96333 <![CDATA[<> '']]>)
WHERE CREATE_STATUS = 1
AND CODE96333 IS NOT NULL
AND CODE96333 <![CDATA[<> '']]>)
SELECT '96333_' || SUBSTRING(CODE96333 FROM 1 FOR 2) AS name,
CODE96333 AS value
FROM ElevatorResults WHERE row_num = 1
......@@ -192,4 +194,11 @@
LIMIT 1
</select>
<select id="checkElevatorCodeRepeat" resultType="java.lang.Integer">
SELECT CODE96333 code
FROM biz_jg_supervisory_code
WHERE CODE96333 = #{elevatorCode} and create_status = #{status}
ORDER BY code
</select>
</mapper>
......@@ -106,7 +106,7 @@
and open_biz_type = #{tzBaseEnterpriseInfoDto.jyjcType}
</if>
group by unit_code,open_biz_type) t1
ON t1.unit_code = unit_code
ON t1.unit_code = use_code
</if>
<where>
<!-- <if-->
......
......@@ -632,4 +632,16 @@ public class EquipmentCategoryController extends BaseController {
public ResponseModel<Map<String, Object>> commonUpdateEsDataByIds(@RequestBody Map<String, Map<String, Object>> paramMap) {
return ResponseHelper.buildResponse(equipmentCategoryService.commonUpdateEsDataByIds(paramMap));
}
/**
* 根据前缀查询96333空余序列码
*
* @return s
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/selectExceedElevatorCode", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "根据前缀查询96333空余序列码", notes = "根据前缀查询96333空余序列码")
public ResponseModel<String> selectExceedElevatorCode(@RequestParam("prefix") String prefix) {
return ResponseHelper.buildResponse(equipmentCategoryService.selectExceedElevatorCode(prefix));
}
}
......@@ -692,7 +692,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
// 查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
// 如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? generateCodeService.createElevatorCode("96333_" + prefix) : categoryOtherInfo.getCode();
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? this.createElevatorCode(prefix) : categoryOtherInfo.getCode();
if (!ObjectUtils.isEmpty(categoryOtherInfo)) {
supervisoryCodeInfoMapper.delete(new QueryWrapper<SupervisoryCodeInfo>().eq("code96333", categoryOtherInfo.getCode()));
}
......@@ -747,6 +747,44 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return equipmentCategoryMapper.getAdministrativeDivision(type, county).get("code").toString();
}
/**
* 生成96333电梯识别码
*
* @param prefix 电梯码前缀
* @return 96333电梯识别码
*/
public String selectExceedElevatorCode(String prefix) {
StringBuilder elevatorCode = new StringBuilder();
// 生成生成96333电梯码前缀
elevatorCode.append(prefix);
String initCode = elevatorCode + EquipmentCategoryEnum.getValue.get(elevatorCode.toString());
CategoryOtherInfo initSupervisoryCode = categoryOtherInfoMapper.queryInitCode(initCode); // 查询是否已经生成过初始值
if (ValidationUtil.isEmpty(initSupervisoryCode)) {
elevatorCode.append(EquipmentCategoryEnum.getValue.get(prefix));
} else {
// 获取行政区划区县、市是否存在历史96333电梯码
CategoryOtherInfo elevatorOtherInfo = categoryOtherInfoMapper.selectElevatorCode(elevatorCode.toString(), null);
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)) {
elevatorCode.setLength(0);
elevatorCode.append(resultList.get(0));
}
stopWatch.stop();
}
}
return elevatorCode.toString();
}
/**
* 生成监管码
*
......@@ -795,7 +833,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* @param prefix 电梯码前缀
* @return 96333电梯识别码
*/
@Deprecated
public String createElevatorCode(String prefix) {
StringBuilder elevatorCode = new StringBuilder();
// 生成生成96333电梯码前缀
......@@ -821,20 +858,22 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
elevatorCode.setLength(0);
elevatorCode.append(resultList.get(0));
} else {
// 获取补零位长度
String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
long num = Long.parseLong(elevatorCode1) + 1;
int numLength = String.valueOf(num).length();
int a = 5 - numLength;
StringBuilder zero = new StringBuilder();
for (int i = 0; i < a; i++) {
zero.append(EquipmentCategoryEnum.BLW.getCode());
}
zero.append(num);
elevatorCode.append(zero);
//// 获取补零位长度
//String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
//long num = Long.parseLong(elevatorCode1) + 1;
//int numLength = String.valueOf(num).length();
//int a = 5 - numLength;
//StringBuilder zero = new StringBuilder();
//for (int i = 0; i < a; i++) {
// zero.append(EquipmentCategoryEnum.BLW.getCode());
//}
//zero.append(num);
//elevatorCode.append(zero);
do {
elevatorCode = new StringBuilder(generateCodeService.createElevatorCode("96333_" + prefix));
} while (categoryOtherInfoMapper.checkElevatorCodeRepeat(elevatorCode.toString(), "0") > 0);
}
stopWatch.stop();
}
}
return elevatorCode.toString();
......@@ -847,8 +886,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
*/
public List<JSONObject> getCompanyType() {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
List<CompanyModel> companys = reginParams.getUserModel().getCompanys();
......
......@@ -413,4 +413,15 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
long expirationTimeInSeconds = expirationDate.getTime() - System.currentTimeMillis();
redisTemplate.expire(key, expirationTimeInSeconds, TimeUnit.MILLISECONDS);
}
/**
* redis 设置不过期的 key
*
* @param key key
* @param value value
*/
public void setValueWithoutExpiration(String key, String value) {
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
valueOps.set(key, value);
}
}
\ No newline at end of file
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