Commit 93dd0010 authored by chenzhao's avatar chenzhao

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://36.40.66.175:5000/moa/amos-boot-biz into develop_tzs_register
parents 8aa370d7 21539aa5
......@@ -12,10 +12,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.privilege.model.*;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.commons.lang3.ObjectUtils;
......@@ -41,10 +38,12 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* controller层切面 用于用户数据缓存 供 sql自动填充使用 (使用粒度过大的Aop会创建大量代理对象,影响性能,占用内存,考虑使用
......@@ -283,6 +282,14 @@ public class ControllerAop {
stopWatch5.stop();
logger.info("获取用户信息====>{}s", stopWatch5.getTotalTimeSeconds());
List<String> appCodes = new ArrayList<>();
try {
List<ApplicationModel> applicationModelList = Privilege.agencyUserClient.listApps(userList.get(0).getUserId()).getResult();
appCodes = applicationModelList.stream().map(ApplicationModel::getAppCode).collect(Collectors.toList());
} catch (Exception e) {
throw new RuntimeException("获取listApps失败");
}
userList.get(0).setAppCodes(appCodes);
ReginParams regionParams = new ReginParams();
regionParams.setCompany(company);
regionParams.setRole(role);
......
......@@ -17,6 +17,6 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
List<Map<String, Object>> getUnitListByType(String type);
List<Map<String, Object>> getSecurityAdmin(String companyCode);
List<Map<String, Object>> getSecurityAdmin(String companyCode, String type);
}
......@@ -21,6 +21,7 @@
"tzs_user_info"
WHERE
unit_code = #{companyCode}
AND post_name LIKE '%安全管理员%'
AND post_name LIKE CONCAT('%',#{type},'%')
AND is_delete = 'f'
</select>
</mapper>
......@@ -80,7 +80,7 @@ public class CommonController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getSecurityAdmin")
@ApiOperation(httpMethod = "GET", value = "查找当前公司下所属的安全管理员", notes = "查找当前公司下所属的安全管理员")
public ResponseModel<List<Map<String,Object>>> getSecurityAdmin() {
return ResponseHelper.buildResponse(commonService.getSecurityAdmin());
public ResponseModel<List<Map<String, Object>>> getSecurityAdmin(@RequestParam(value = "type") String type) {
return ResponseHelper.buildResponse(commonService.getSecurityAdmin(type));
}
}
......@@ -25,5 +25,5 @@ public interface ICommonService {
List<Map<String,Object>> getUnitListByType(String type);
List<Map<String,Object>> getSecurityAdmin();
List<Map<String,Object>> getSecurityAdmin(String type);
}
......@@ -15,6 +15,8 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgFactoryInfoMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -169,11 +171,21 @@ public class CommonServiceImpl implements ICommonService {
}
@Override
public List<Map<String, Object>> getSecurityAdmin() {
public List<Map<String, Object>> getSecurityAdmin(String type) {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
String companyCode = company.getCompanyCode();
return commonMapper.getSecurityAdmin(companyCode);
String postName = null;
if (type.equals("use")) {
postName = "安全管理员";
}
if (type.equals("jyjc")) {
postName = "检验检测人员";
}
if (type.equals("agw")) {
postName = "安改维负责人";
}
return ObjectUtils.isEmpty(postName) ? new ArrayList<>() : commonMapper.getSecurityAdmin(companyCode, postName);
}
/**
......
......@@ -7,6 +7,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
/**
*
*
......@@ -45,4 +48,10 @@ public class JyjcInspectionResultAttachment extends BaseEntity {
@TableField("remark")
private String remark;
/**
* 附件地址
*/
@TableField(exist = false)
private List<Object> attachmentUrlList;
}
......@@ -128,9 +128,6 @@ public class JyjcInspectionResultModel extends BaseModel {
@ApiModelProperty(value = "检验结果技术参数")
private Map<String,Object> resultParamModelMap;
@ApiModelProperty(value = "检验结果附件")
private List<Map<String,Object>> resultAttachmentModelList;
@ApiModelProperty(value = "附件类型(特种设备检验报告:1,监检证书:2)")
private String attachmentType;
}
......@@ -144,10 +144,11 @@ public class JyjcInspectionResultController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/updateResult")
@ApiOperation(httpMethod = "PUT", value = "检验结果-上传结果和编辑结果", notes = "检验结果-上传结果和编辑结果")
public ResponseModel<JyjcInspectionResultModel> updateJyjcInspectionResult(@RequestBody JyjcInspectionResultModel model) {
public ResponseModel<JyjcInspectionResultModel> updateJyjcInspectionResult(@RequestBody Map<String, Map<String, Object>> model) {
return ResponseHelper.buildResponse(jyjcInspectionResultServiceImpl.updateJyjcInspectionResult(model));
}
/**
* 获取设备种类列表
*
......
package com.yeejoin.amos.boot.module.jyjc.biz.controller;
import cn.hutool.core.map.MapBuilder;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcOpeningApplication;
import com.yeejoin.amos.boot.module.jyjc.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcOpeningApplicationRequstDto;
......@@ -205,8 +206,8 @@ public class JyjcOpeningApplicationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "撤回业务开通申请", notes = "撤回业务开通申请")
@GetMapping(value = "/rollBackFlow")
public void overflow( @RequestParam("instanceId") String instanceId) {
jyjcOpeningApplicationServiceImpl.stopFlow(instanceId);
public ResponseModel<JSONObject> overflow(@RequestParam("sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(jyjcOpeningApplicationServiceImpl.stopFlow(sequenceNbr));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -2,10 +2,12 @@ package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jyjc.api.common.StringUtil;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultAttachment;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultParam;
......@@ -17,6 +19,7 @@ import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionResultParamS
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionResultService;
import com.yeejoin.amos.boot.module.jyjc.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -62,6 +65,11 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
@Autowired
private RedisUtils redisUtils;
@Autowired
CategoryOtherInfoMapper categoryOtherInfoMapper;
// @Autowired
// InspectionDetectionInfoServiceImpl inspectionDetectionInfoService;
/**
* 检验检测单位分页查询
*/
......@@ -89,24 +97,63 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
}
public JyjcInspectionResultModel updateJyjcInspectionResult(JyjcInspectionResultModel model) {
public JyjcInspectionResultModel updateJyjcInspectionResult(Map<String, Map<String, Object>> tableModel) {
Map<String, Object> map = tableModel.get("inspectResult");
JyjcInspectionResultModel model = BeanUtil.mapToBean(map, JyjcInspectionResultModel.class, true);
updateWithModel(model);
if (!CollectionUtils.isEmpty(model.getResultAttachmentModelList())){
JyjcInspectionResultAttachment attachment = new JyjcInspectionResultAttachment();
attachment.setResultSeq(model.getSequenceNbr());
attachment.setAttachmentUrl(JSON.toJSONString(model.getResultAttachmentModelList()));
attachment.setAttachmentType(model.getAttachmentType());
attachmentService.save(attachment);
List<JyjcInspectionResultAttachment> attachmentList = new ArrayList<>();
map.forEach((k, v) -> {
if (k.contains("JYJC_") && !ObjectUtils.isEmpty(map.get(k))) {
JyjcInspectionResultAttachment attachment = new JyjcInspectionResultAttachment();
attachment.setResultSeq(model.getSequenceNbr());
attachment.setAttachmentUrl(JSON.toJSONString(map.get(k)));
attachment.setAttachmentType(k);
attachmentList.add(attachment);
}
});
if (!CollectionUtils.isEmpty(attachmentList)) {
attachmentService.saveBatch(attachmentList);
}
if (!CollectionUtils.isEmpty(model.getResultParamModelMap())){
JyjcInspectionResultParam resultParam = new JyjcInspectionResultParam();
resultParam.setResultSeq(model.getSequenceNbr());
resultParam.setParamJson(JSON.toJSONString(model.getResultParamModelMap()));
resultParamService.save(resultParam);
}
// InspectionDetectionInfo info = new InspectionDetectionInfo();
// QueryWrapper<InspectionDetectionInfo> wrapper = new QueryWrapper<>();
// wrapper.lambda().eq(InspectionDetectionInfo::getInspectReportNo,model.getResultNo());
// List<InspectionDetectionInfo> list = inspectionDetectionInfoService.list(wrapper);
// if(CollectionUtils.isEmpty(list)){
// QueryWrapper<CategoryOtherInfo> queryWrapper = new QueryWrapper<>();
// queryWrapper.lambda().eq(CategoryOtherInfo::getSupervisoryCode,model.getEquipUnicode());
// List<CategoryOtherInfo> otherInfos = categoryOtherInfoMapper.selectList(queryWrapper);
// if(!CollectionUtils.isEmpty(otherInfos)){
// info.setRecord(otherInfos.get(0).getRecord());
// }
// }else{
// info = list.get(0);
// }
// extracted(model, info);
// inspectionDetectionInfoService.save(info);
return model;
}
// private void extracted(JyjcInspectionResultModel model, InspectionDetectionInfo info) {
// info.setInspectType(model.getInspectionType());
// info.setInspectOrgName(model.getInspectionUnitCode());
//// info.setInspectReport(JSON.toJSONString(model.getResultAttachmentModelList()));
// info.setInspectDate(model.getInspectionDate());
// info.setInspectConclusion(model.getInspectionConclusion());
// info.setProblemRemark(model.getNonConformance());
// info.setNextInspectDate(model.getNextInspectionDate());
// info.setSequenceCode(model.getEquipUnicode());
// info.setInspectOrgCode(model.getUseUnitCreditCode());
// info.setInspectReportNo(model.getResultNo());
// }
/**
* 列表查询 示例
*/
......@@ -126,7 +173,12 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
// 获取附件
List<JyjcInspectionResultAttachment> attachmentList = iJyjcInspectionResultAttachmentService.getObjByResultSeq(sequenceNbr);
if (!CollectionUtils.isEmpty(attachmentList)) {
Map<String, Object> attachmentMap = attachmentList.stream().collect(Collectors.toMap(JyjcInspectionResultAttachment::getAttachmentType, JyjcInspectionResultAttachment::getAttachmentUrl));
Map<String, Object> attachmentMap = attachmentList.stream().map(obj -> {
if (StringUtil.isNotEmpty(obj.getAttachmentUrl())) {
obj.setAttachmentUrlList(JSONArray.parseArray(obj.getAttachmentUrl()));
}
return obj;
}).collect(Collectors.toMap(JyjcInspectionResultAttachment::getAttachmentType, JyjcInspectionResultAttachment::getAttachmentUrlList));
map.putAll(attachmentMap);
}
......
......@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.netflix.loadbalancer.RetryRule;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
......@@ -193,9 +194,9 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
public Page<JyjcOpeningApplicationModel> querypageForCompany(Page<JyjcOpeningApplication> page, JyjcOpeningApplicationRequstDto jyjcOpeningApplicationRequstDto) {
//根据申请单中的单位信息对于列表数据进行过滤
CompanyBo companyBo = commonserviceImpl.getReginParamsOfCurrentUser().getCompany();
if (companyBo.getLevel().equals("company")) {
// if (companyBo.getLevel().equals("company")) {
jyjcOpeningApplicationRequstDto.setUnitCode(companyBo.getCompanyCode());
}
// }
String applyStartTime = "";
String applyEndTime = "";
......@@ -292,15 +293,24 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
dto.setProcessDefinitionKey(processDefinitionKey);
dto.setBusinessKey(StringUtils.defaultString(businessKey, "1"));
// dto.setCompleteFirstTask(true);
FeignClientResult ajaxResult = Workflow.taskV2Client.startByVariable(dto);
// FeignClientResult ajaxResult = Workflow.taskV2Client.startByVariable(dto);
//
// if (log.isDebugEnabled()) {
// log.debug("开启工作流结果:{}", ajaxResult);
// }
// if (ajaxResult == null || 200 != ajaxResult.getStatus()) {
// throw new BaseException("开启工作流错误");
// }
// return ((Map) ajaxResult.getResult()).get("id").toString();
// V1
AjaxResult ajaxResult = Workflow.taskClient.startByVariable(dto);
if (log.isDebugEnabled()) {
log.debug("开启工作流结果:{}", ajaxResult);
}
if (ajaxResult == null || 200 != ajaxResult.getStatus()) {
if (ajaxResult == null || (ajaxResult.get(AjaxResult.CODE_TAG) != null && !"200".equals(ajaxResult.get(AjaxResult.CODE_TAG).toString()))) {
throw new BaseException("开启工作流错误");
}
return ((Map) ajaxResult.getResult()).get("id").toString();
return ((Map) ajaxResult.get("data")).get("id").toString();
}
/**
......@@ -349,17 +359,20 @@ public class JyjcOpeningApplicationServiceImpl extends BaseService<JyjcOpeningAp
/**
* 撤回流程办理单
*/
public void stopFlow(String instanceId) {
public JSONObject stopFlow(String sequenceNbr) {
JSONObject jsonObject= new JSONObject();
JyjcOpeningApplication jyjcOpeningApplication = jyjcOpeningApplicationMapper.selectById(sequenceNbr);
try {
//撤回流程
JSONObject jsonObject = workflowFeignClient.rollBack(instanceId);
jsonObject = workflowFeignClient.rollBack(jyjcOpeningApplication.getWorkflowProstanceId());
if (ObjectUtils.isEmpty(jsonObject)) {
}
updateModelByInstanceId(instanceId, FlowStatusEnum.ROLLBACK.getCode() + "");
updateModelByInstanceId(jyjcOpeningApplication.getWorkflowProstanceId(), FlowStatusEnum.ROLLBACK.getCode() + "");
} catch (Exception e) {
e.printStackTrace();
throw new BadRequest("撤回流程失败,请联系管理员!");
}
return jsonObject;
}
private String getWorkflowStatus(JSONObject dataObject) {
......
package com.yeejoin.amos.boot.module.tcm.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@AllArgsConstructor
@Getter
public enum PersonManageRoleEnum {
/**
* 人员管理角色枚举
*/
code("人员管理角色字典code", 6616L),
use("使用单位", 1735591519093547010L),
agw("安装改造维修单位", 1735591458058035201L),
jyjc("检验检测机构", 1735590873120399362L);
String name;
Long id;
public static Map<Long, String> getName = new HashMap<>();
public static Map<String, Long> getId = new HashMap<>();
static {
for (PersonManageRoleEnum e : PersonManageRoleEnum.values()) {
getName.put(e.id, e.name);
getId.put(e.name, e.id);
}
}
}
......@@ -31,4 +31,8 @@ public interface TzsUserInfoMapper extends BaseMapper<TzsUserInfo> {
List<GroupAndPersonInfoDto> getUnitInfoByUserId(Long groupId);
String selectPostNameByUserId(String userId);
List<Map<String, Object>> getUserTypeList(@Param(value = "typeList") List<String> typeList);
String selectCompanyTypeById(Long companySeq);
}
......@@ -211,4 +211,21 @@
<select id="selectPostNameByUserId" resultType="java.lang.String">
SELECT post_name FROM "tzs_user_info" WHERE amos_user_id = #{userId}
</select>
<select id="getUserTypeList" resultType="java.util.Map">
SELECT
*
FROM
"cb_data_dictionary"
WHERE
type in
<foreach collection="typeList" separator="," item="type" open="(" close=")">
#{type}
</foreach>
</select>
<select id="selectCompanyTypeById" resultType="java.lang.String">
select company_type from privilege_company where sequence_nbr = #{companySeq}
</select>
</mapper>
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
......@@ -82,7 +83,7 @@ public class TzsUserInfoController extends BaseController {
if (ObjectUtils.isEmpty(reginParams)) {
return null;
}
CompanyModel companyModel = reginParams.getUserModel().getCompanys().get(0);
CompanyBo companyModel = reginParams.getCompany();
if(ObjectUtils.isEmpty(companyModel)){
throw new BadRequest("未指定人员归属单位信息");
}
......@@ -218,11 +219,11 @@ public class TzsUserInfoController extends BaseController {
if (ObjectUtils.isEmpty(reginParams)) {
return null;
}
CompanyModel companyModel = reginParams.getUserModel().getCompanys().get(0);
if(ObjectUtils.isEmpty(companyModel)){
CompanyBo company = reginParams.getCompany();
if(ObjectUtils.isEmpty(company)){
throw new BadRequest("未指定人员归属单位信息");
}
dto.setUnitCode(companyModel.getCompanyCode());
dto.setUnitCode(company.getCompanyCode());
Page<TzsUserInfoDto> page = new Page<>();
page.setCurrent(Long.parseLong(current));
page.setSize(Long.parseLong(size));
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
......@@ -15,6 +16,7 @@ import com.yeejoin.amos.boot.module.tcm.api.dto.TzsEquipListDto;
import com.yeejoin.amos.boot.module.tcm.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.tcm.api.entity.*;
import com.yeejoin.amos.boot.module.tcm.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.PersonManageRoleEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.TwoStipulateGroupEnum;
import com.yeejoin.amos.boot.module.tcm.api.enums.UnitTypeEnum;
import com.yeejoin.amos.boot.module.tcm.api.mapper.TzsUserEquipMapper;
......@@ -262,6 +264,22 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
}
});
//添加人员管理角色
TzsUserInfo tzsUserInfo = tzsUserInfoMapper.selectById(sequenceNbr);
String post = tzsUserInfo.getPost();
if(post.contains(PersonManageRoleEnum.code.getId().toString())){
String companyType = tzsUserInfoMapper.selectCompanyTypeById(companySeq);
if(companyType.contains(PersonManageRoleEnum.jyjc.getName())){
roleIds.add(PersonManageRoleEnum.jyjc.getId());
}
if(companyType.contains(PersonManageRoleEnum.use.getName())){
roleIds.add(PersonManageRoleEnum.use.getId());
}
if(companyType.contains(PersonManageRoleEnum.agw.getName())){
roleIds.add(PersonManageRoleEnum.agw.getId());
}
}
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
roleSeqMap.put(companySeq, roleIds);
......@@ -271,7 +289,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
agencyUserModel.setOrgRoleSeqs(roleSeqMap);
userResult = Privilege.agencyUserClient.create(agencyUserModel);
if (userResult.getStatus() == 200) {
TzsUserInfo tzsUserInfo = tzsUserInfoMapper.selectById(sequenceNbr);
tzsUserInfo.setAmosUserId(userResult.getResult().getUserId());
tzsUserInfo.setAmosUserName(userResult.getResult().getUserName());
tzsUserInfo.setLockStatus(status);
......@@ -284,7 +302,6 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
Privilege.groupUserClient.create(Long.valueOf(roleGroup.getExtend()), userIds);
}
//绑定两个规定用户组
String post = tzsUserInfo.getPost();
post = post.replace("[", "").replace("]", "").replace("\"", "");
for (String code : post.split(",")) {
DataDictionary groupId = iDataDictionaryService
......@@ -366,6 +383,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
boolean productCompany = false;
boolean useCompany = false;
boolean installCompany = false;
boolean inspectionCompany = false;
for (CompanyModel companyModel : companyModels) {
String companyType = companyModel.getCompanyType();
if (companyType.contains("使用单位") || companyType.contains("个人主体")) {
......@@ -377,19 +395,23 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (companyType.contains("安装改造维修单位")){
installCompany = true;
}
if (companyType.contains("检验检测机构")){
inspectionCompany = true;
}
}
String companyType = null;
StringBuilder companyType = new StringBuilder();
if (useCompany) {
companyType = "use";
companyType.append("use-");
}
if (productCompany) {
companyType = "pro";
}
if (useCompany && productCompany) {
companyType = "useAndPro";
companyType.append("pro-");
}
if (installCompany) {
companyType = companyType + "AndInstall";
companyType.append("install-");
}
if (inspectionCompany) {
companyType.append("inspection");
}
result.put("companyType", companyType);
return result;
......@@ -526,18 +548,21 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
@Override
public List<Map<String, Object>> getUserType(String unitType) {
if (unitType.equals("pro")) {
return tzsUserInfoMapper.getUserType("QYRYGW-SCDW", null);
} else if (unitType.equals("use")) {
return tzsUserInfoMapper.getUserType("QYRYGW-SYDW", null);
} else if (unitType.equals("useAndInstall")){
return tzsUserInfoMapper.getUserType("QYRYGW-SYDW", "QYRYGW-INSTALL");
} else if (unitType.equals("proAndInstall")){
return tzsUserInfoMapper.getUserType("QYRYGW-SCDW", "QYRYGW-INSTALL");
}else {
return tzsUserInfoMapper.getUserType(null, null);
List<String> type = new ArrayList<>();
type.add("QYRYGW");
if (unitType.contains("use")) {
type.add("QYRYGW-SYDW");
}
if (unitType.contains("pro")) {
type.add("QYRYGW-SCDW");
}
if (unitType.contains("install")) {
type.add("QYRYGW-INSTALL");
}
if (unitType.contains("inspection")) {
type.add("QYRYGW-INSPECTION");
}
return tzsUserInfoMapper.getUserTypeList(type);
}
public List<LinkedHashMap> screenData(List<LinkedHashMap> result, List<LinkedHashMap> data, String id) {
......
......@@ -63,4 +63,28 @@
// public ResponseModel<String> createURCode(@RequestParam("key") String key) {
// return ResponseHelper.buildResponse(createCodeService.createUseRegistrationCode(key));
// }
//
// /**
// * 96333顺序码生成
// * @param key key
// * @return String
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @PostMapping(value = "/elevatorCode")
// @ApiOperation(httpMethod = "POST", value = "96333顺序码生成", notes = "96333顺序码生成")
// public ResponseModel<String> elevatorCode(@RequestParam("key") String key) {
// return ResponseHelper.buildResponse(createCodeService.createElevatorCode(key));
// }
//
// /**
// * 监管顺序码生成
// * @param key key
// * @return String
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @PostMapping(value = "/sequenceKeyCode")
// @ApiOperation(httpMethod = "POST", value = "监管顺序码生成", notes = "监管顺序码生成")
// public ResponseModel<String> sequenceKeyCode(@RequestParam("key") String key) {
// return ResponseHelper.buildResponse(createCodeService.createSupervisoryCode(key));
// }
//}
......@@ -46,13 +46,19 @@ public enum EquipmentCategoryEnum {
public static Map<String, String> getName = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>();
public static Map<String, String> getValue = new HashMap<>();
private static final Map<String, String> valueToCodeMap = new HashMap<>();
static {
for (EquipmentCategoryEnum e : EquipmentCategoryEnum.values()) {
getName.put(e.code, e.name);
getCode.put(e.value, e.code);
getValue.put(e.value, e.code);
valueToCodeMap.put("96333_"+ e.value, e.getValue() + e.getCode());
}
}
// 根据value获取对应的code
public static String getCodeByValue(String value) {
return valueToCodeMap.get(value);
}
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.KV;
import com.yeejoin.amos.boot.module.ymt.api.entity.CategoryOtherInfo;
import lombok.NonNull;
import org.apache.ibatis.annotations.Param;
......@@ -44,4 +45,16 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
List<Integer> selectExceedElevatorCodeList(Integer start,String prefix);
Integer selectCode(Integer start, Integer end, String prefix);
/**
* 查询96333码,根据区域+类别分组后,取最大顺序码
* @return list
*/
List<KV> selectElevatorCodeMaxValue();
/**
* 查询监管码,根据区域+类别分组后,取最大顺序码
* @return list
*/
List<KV> selectSupervisorCodeMaxValue();
}
......@@ -17,7 +17,6 @@ public interface ICreateCodeService {
*/
List<String> createApplicationFormCode(String type, int batchSize);
/**
* 生成设备注册编码(20位)
* @param key key
......@@ -32,4 +31,24 @@ public interface ICreateCodeService {
*/
String createUseRegistrationCode(String key);
/**
* 96333编码生成(7位)
* @param key key
* @return 96333顺序码
*/
String createElevatorCode(String key);
/**
* 回退顺序码
* @param key redisKey
* @return bool
*/
boolean reduceElevatorCode(String key);
/**
* 监管编码生成(7位)
* @param key key
* @return 7位监管编码生成
*/
String createSupervisoryCode(String key);
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.ymt.api.service.impl;
import com.yeejoin.amos.boot.module.ymt.api.common.DateUtils;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum;
import com.yeejoin.amos.boot.module.ymt.api.service.ICreateCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -26,7 +27,10 @@ public class CreateCodeServiceImpl implements ICreateCodeService {
private static final String LOCK_KEY_DR = "sequence_lock_dr";
private static final String SEQUENCE_TYPE_DR = "%04d";
private static final String LOCK_KEY_UR = "sequence_lock_ur";
private static final String LOCK_KEY_ELEVATOR = "sequence_lock_elevator";
private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory";
private static final String SEQUENCE_TYPE_UR = "%05d";
private static final String SEQUENCE_TYPE = "%07d";
private final RedisTemplate<String, String> redisTemplate;
private String rulePrefix;
......@@ -58,7 +62,7 @@ public class CreateCodeServiceImpl implements ICreateCodeService {
*/
@Override
public String createDeviceRegistrationCode(String key) {
return generateSequence(key, SEQUENCE_TYPE_DR, LOCK_KEY_DR);
return (key.length() == 16) ? generateSequence(key, SEQUENCE_TYPE_DR, LOCK_KEY_DR) : "生成码规则不对!";
}
/**
......@@ -73,6 +77,48 @@ public class CreateCodeServiceImpl implements ICreateCodeService {
return generateSequence(key, SEQUENCE_TYPE_UR, LOCK_KEY_UR);
}
@Override
public String createElevatorCode(String key) {
return (key.length() == 8) ? generateElevatorSequence(key, SEQUENCE_TYPE, LOCK_KEY_ELEVATOR) : "生成码规则不对!";
}
@Override
public boolean reduceElevatorCode(String key) {
return reduceSequence(key, SEQUENCE_TYPE, LOCK_KEY_ELEVATOR);
}
@Override
public String createSupervisoryCode(String key) {
return (key.length() == 5) ? generateSupervisorySequence(key) : "生成码规则不对!";
}
private String generateSupervisorySequence(String sequenceKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(CreateCodeServiceImpl.LOCK_KEY_SUPERVISORY);
if (Boolean.TRUE.equals(lockAcquired)) {
try {
// 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey);
// 如果为空,则初始化为0
Long currentSequence = (currentSequenceStr != null) ? Long.parseLong(currentSequenceStr) : 0L;
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++;
// 生成顺序码
String formattedSequence = String.format(CreateCodeServiceImpl.SEQUENCE_TYPE, currentSequence);
log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码
valueOps.set(sequenceKey, formattedSequence);
return sequenceKey + "-" + formattedSequence;
} finally {
releaseLock(CreateCodeServiceImpl.LOCK_KEY_SUPERVISORY);
}
} else {
throw new RuntimeException("Failed to acquire lock for sequence generation");
}
}
/**
* 校验枚举合法性
*
......@@ -129,7 +175,7 @@ public class CreateCodeServiceImpl implements ICreateCodeService {
}
/**
* 批量生成顺序码
* 生成顺序码
*
* @param sequenceKey redisKey
* @param sequenceType 生成码类型
......@@ -173,6 +219,90 @@ public class CreateCodeServiceImpl implements ICreateCodeService {
}
/**
* 生成顺序码
*
* @param sequenceKey redisKey
* @param sequenceType 生成码类型
* @param lockKey redis锁
* @return s
*/
public String generateElevatorSequence(String sequenceKey, String sequenceType, String lockKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(lockKey);
if (Boolean.TRUE.equals(lockAcquired)) {
try {
// 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey);
// 如果为空,则初始化为0
if (currentSequenceStr == null) {
currentSequenceStr = EquipmentCategoryEnum.getCodeByValue(sequenceKey);
log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, currentSequenceStr);
return currentSequenceStr;
}
Long currentSequence = Long.parseLong(currentSequenceStr);
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++;
// 生成顺序码
String formattedSequence = String.format(sequenceType, currentSequence);
log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码
valueOps.set(sequenceKey, formattedSequence);
return formattedSequence;
} finally {
releaseLock(lockKey);
}
} else {
throw new RuntimeException("Failed to acquire lock for sequence generation");
}
}
/**
* 回退顺序码
*
* @param sequenceKey redisKey
* @param sequenceType 码类型
* @param lockKey 分布锁
* @return 操作是否成功
*/
public boolean reduceSequence(String sequenceKey, String sequenceType, String lockKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(lockKey);
if (Boolean.TRUE.equals(lockAcquired)) {
try {
// 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey);
// 如果为空,则初始化为0
long currentSequence = (currentSequenceStr != null) ? Long.parseLong(currentSequenceStr) : 0L;
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
// 判断是否有可回退的操作
if (currentSequence > 0) {
currentSequence--;
// 生成顺序码
String formattedSequence = String.format(sequenceType, currentSequence);
log.info("===================>回退《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码
valueOps.set(sequenceKey, String.valueOf(formattedSequence));
return true; // 回退成功
} else {
log.warn("===================>无法回退《{}》顺序码,当前顺序码已为0<===================", sequenceKey);
return false; // 无法回退,当前顺序码已为0
}
} finally {
releaseLock(lockKey);
}
} else {
throw new RuntimeException("Failed to acquire lock for sequence generation");
}
}
/**
* 分布式锁
*
* @param lockKey lockKey
......
......@@ -33,6 +33,26 @@
<if test="status == 2 ">ORDER BY CODE96333 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,
CODE96333
FROM biz_jg_supervisory_code
WHERE 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
</select>
<select id="selectSupervisorCodeMaxValue" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.KV">
WITH SupervisorResults AS (
SELECT supervisory_code, ROW_NUMBER() OVER (PARTITION BY SUBSTRING(supervisory_code FROM 1 FOR 5) ORDER BY supervisory_code DESC) AS row_num
FROM biz_jg_supervisory_code WHERE supervisory_code IS NOT NULL AND supervisory_code <![CDATA[<> '')]]>
SELECT SUBSTRING(supervisory_code FROM 1 FOR 5) AS name,
SUBSTRING(supervisory_code FROM 7 FOR 7) AS value
FROM SupervisorResults WHERE row_num = 1
</select>
<select id="selectEquipInfo" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.EquInfoDto">
SELECT "CITY",
"COUNTY",
......
package com.yeejoin.amos.boot.module.ymt.biz.config;
import com.yeejoin.amos.boot.module.ymt.api.dto.KV;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 初始化监管码和96333码
*
* @author LiuLin
* @date 2023年12月15日 17:47
*/
@Component
public class SupervisionCacheInitializer implements ApplicationRunner {
private static final Logger log = LoggerFactory.getLogger(SupervisionCacheInitializer.class);
private final CategoryOtherInfoMapper categoryOtherInfoMapper;
private final StringRedisTemplate stringRedisTemplate;
@Autowired
public SupervisionCacheInitializer(CategoryOtherInfoMapper categoryOtherInfoMapper, StringRedisTemplate stringRedisTemplate) {
this.categoryOtherInfoMapper = categoryOtherInfoMapper;
this.stringRedisTemplate = stringRedisTemplate;
}
@Override
public void run(ApplicationArguments args) {
preloadCache(categoryOtherInfoMapper.selectElevatorCodeMaxValue());
preloadCache(categoryOtherInfoMapper.selectSupervisorCodeMaxValue());
log.info(">>>>>>>>>>>>>>>>服务启动执行Redis缓存预加载96333和监管数据完成!>>>>>>>>>>>>>>>>");
}
/**
* 预加载缓存
*
* @param codeList 待加载的代码列表
*/
private void preloadCache(List<KV> codeList) {
codeList.forEach(vo -> stringRedisTemplate.opsForValue().set(vo.getName(), (String) vo.getValue()));
}
}
......@@ -27,7 +27,7 @@
<springcloud.version>Hoxton.SR8</springcloud.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<tyboot-version>1.1.23-SNAPSHOT</tyboot-version>
<amos.version>1.7.10-SNAPSHOT</amos.version>
<amos.version>1.8.6</amos.version>
<itext.version>7.1.1</itext.version>
<elasticsearch.version>7.15.2</elasticsearch.version>
</properties>
......
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