Commit 4548321e authored by kongfm's avatar kongfm

更新FLC相关代码

parent 182fe054
......@@ -349,4 +349,29 @@ public class DataDictionaryController extends BaseController {
return ResponseHelper.buildResponse(type);
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/gwmcDataDictionaryNotoken/{type}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据字典类型查询字典不验证token", notes = "根据字典类型查询字典不验证token")
public ResponseModel<Object> gwmcDataDictionaryNotoken(@PathVariable String type) throws Exception {
// 数据字典生成树方法 原先通过getCode做主键 现修改为 getSequenceNbr 后期数据字典parent字段保存id 而不要保存code by
// kongfm 2021-09-08
// 数据字典还原 by kongfm 2021-09-09
QueryWrapper<DataDictionary> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", type);
queryWrapper.orderByAsc("sort_num");
if (redisUtils.hasKey(RedisKey.DATA_DICTIONARY_CODE + type)) {
Object obj = redisUtils.get(RedisKey.DATA_DICTIONARY_CODE + type);
return ResponseHelper.buildResponse(obj);
} else {
Collection<DataDictionary> list = iDataDictionaryService.list(queryWrapper);
List<Menu> menus = TreeParser.getTree(null, list, DataDictionary.class.getName(), "getCode", 0, "getName",
"getParent", null);
redisUtils.set(RedisKey.DATA_DICTIONARY_CODE + type, JSON.toJSON(menus), time);
return ResponseHelper.buildResponse(menus);
}
}
}
......@@ -39,6 +39,9 @@ public class RedisKey {
/**联通CTIuser token */
public static final String CTI_USER_TOKEN = "cti_user_token";
/** 企业用户注册前缀 */
public static final String FLC_USER_TEL = "flc_tel_";
/** 驼峰转下划线(简单写法,效率低于 ) */
public static String humpToLine(String str) {
......
......@@ -37,4 +37,11 @@ public class TzsCommonParam {
public static final String APPJJ = "APPJJ";
public static final String DD = "DD";
public static final String JC = "JC";
public static final String LICENCE_PIC = "licencePic";
public static final String ADMIN_LICENSE_PIC = "adminLicensePic";
public static final String QR_CODE = "qrCode";
public static final String UNIT_TYPE = "UNIT_TYPE";
}
......@@ -36,6 +36,9 @@ public class UnitInfoChangeDto extends BaseDto {
@ApiModelProperty(value = "单位类型code")
private String unitTypeCode;
@ApiModelProperty(value = "组织机构编码")
private String organizationCode;
@ApiModelProperty(value = "主管部门")
private String comptentDept;
......
package com.yeejoin.amos.boot.module.tzs.flc.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 企业信息表
......@@ -25,10 +28,13 @@ public class UnitInfoDto extends BaseDto {
private String orgName;
@ApiModelProperty(value = "证照类型")
private String licenseType;
private String licenceType;
@ApiModelProperty(value = "证照类型code")
private String licenseTypeCode;
private String licenceTypeCode;
@ApiModelProperty(value = "组织机构编码")
private String organizationCode;
@ApiModelProperty(value = "单位类型")
private String unitType;
......@@ -94,10 +100,10 @@ public class UnitInfoDto extends BaseDto {
private Date createTime;
@ApiModelProperty(value = "单位法人")
private String legelPerson;
private String legalPerson;
@ApiModelProperty(value = "法人电话")
private String legelPersonTel;
private String legalPersonTel;
@ApiModelProperty(value = "单位联系人")
private String contactPerson;
......@@ -126,4 +132,30 @@ public class UnitInfoDto extends BaseDto {
@ApiModelProperty(value = "审批状态 0 审批中 1 审批结束 2 驳回")
private Integer unitStatus;
@ApiModelProperty(value = "证照图片")
private List<AttachmentDto> licencePic;
@ApiModelProperty(value = "管理员身份证")
private List<AttachmentDto> adminLicensePic;
@ApiModelProperty(value = "是否变更 0 未变更 1 变更中")
private Boolean isChange;
@ApiModelProperty(value = "提交时间开始")
private Date submitTimeStart ;
@ApiModelProperty(value = "接警时间结束")
private Date submitTimeEnd ;
@ApiModelProperty(value = "分类名称")
private String typeStr;
@ApiModelProperty(value = "状态名称")
private String statusStr;
@ApiModelProperty(value = "企业二维码")
private List<AttachmentDto> qrcode;
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
......@@ -31,14 +32,20 @@ public class UnitInfo extends BaseEntity {
/**
* 证照类型
*/
@TableField("license_type")
private String licenseType;
@TableField("licence_type")
private String licenceType;
/**
* 证照类型code
*/
@TableField("license_type_code")
private String licenseTypeCode;
@TableField("licence_type_code")
private String licenceTypeCode;
/**
* 组织机构编码
*/
@TableField("organization_code")
private String organizationCode;
/**
* 单位类型
......@@ -169,14 +176,14 @@ public class UnitInfo extends BaseEntity {
/**
* 单位法人
*/
@TableField("legel_person")
private String legelPerson;
@TableField("legal_person")
private String legalPerson;
/**
* 法人电话
*/
@TableField("legel_person_tel")
private String legelPersonTel;
@TableField("legal_person_tel")
private String legalPersonTel;
/**
* 单位联系人
......@@ -232,4 +239,10 @@ public class UnitInfo extends BaseEntity {
@TableField("unit_status")
private Integer unitStatus;
/**
* 是否变更 0 未变更 1 变更中
*/
@TableField(value = "is_change")
private Boolean isChange;
}
......@@ -31,14 +31,20 @@ public class UnitInfoChange extends BaseEntity {
/**
* 证照类型
*/
@TableField("license_type")
private String licenseType;
@TableField("licence_type")
private String licenceType;
/**
* 证照类型code
*/
@TableField("license_type_code")
private String licenseTypeCode;
@TableField("licence_type_code")
private String licenceTypeCode;
/**
* 组织机构编码
*/
@TableField("organization_code")
private String organizationCode;
/**
* 单位类型
......@@ -169,14 +175,14 @@ public class UnitInfoChange extends BaseEntity {
/**
* 单位法人
*/
@TableField("legel_person")
private String legelPerson;
@TableField("legal_person")
private String legalPerson;
/**
* 法人电话
*/
@TableField("legel_person_tel")
private String legelPersonTel;
@TableField("legal_person_tel")
private String legalPersonTel;
/**
* 单位联系人
......
package com.yeejoin.amos.boot.module.tzs.flc.api.service;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto;
/**
* 企业信息表接口类
*
......@@ -9,4 +12,12 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.service;
*/
public interface IUnitInfoService {
/**
* 审批企业注册信息
* @param approveDto
* @return
*/
UnitInfoDto approve(UnitInfoApproveDto approveDto);
UnitInfoDto getDtoById(Long sequenceNbr);
}
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.service.ISourceFileService;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledQueryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledRecordDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertHandlerDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertHandlerInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertPaperInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.DutySeatDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.FormValue;
import com.yeejoin.amos.boot.module.tzs.api.dto.WechatMyBusinessListDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.WechatMyBussinessDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchPaper;
import com.yeejoin.amos.boot.module.tzs.api.entity.DispatchTask;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.entity.VoiceRecordFile;
import com.yeejoin.amos.boot.module.tzs.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.tzs.api.enums.DispatchPaperEnums;
import com.yeejoin.amos.boot.module.tzs.api.enums.TzsCommonParam;
import com.yeejoin.amos.boot.module.tzs.api.mapper.AlertCalledMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IAlertCalledService;
import com.yeejoin.amos.boot.module.tzs.api.service.TzsAuthService;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.component.feign.config.TokenOperation;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
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.IdPasswordAuthModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 特种设备权限服务实现类
......@@ -70,6 +39,22 @@ import java.util.stream.Collectors;
@Service
public class TzsAuthServiceImpl implements TzsAuthService {
@Autowired
RedisUtils redisUtils;
@Value("${cti.user.name}")
private String ctiUserName;
@Value("${cti.user.pwd}")
private String ctiUserPwd;
/**
* saveUserRedis设置过期时间
*/
@Value("${redis.cache.failure.time}")
private Long redisRegionTimeSecond;
@Override
public List<String> getUserRegionCode() {
......@@ -154,4 +139,86 @@ public class TzsAuthServiceImpl implements TzsAuthService {
}
}
private void loginCtiUser() {
String passwd = DesUtil.encode(ctiUserPwd, "qaz");
IdPasswordAuthModel loninData = new IdPasswordAuthModel();
loninData.setLoginId(ctiUserName);
loninData.setPassword(passwd);
FeignClientResult loginResult = Privilege.authClient.idpassword(loninData);
if(loginResult.getStatus() == 200) {
HashMap resultMap = (HashMap) loginResult.getResult();
redisUtils.set(RedisKey.CTI_USER_TOKEN, resultMap.get("token").toString(), redisRegionTimeSecond);
}
}
public void setRequestContext() {
// 需要登录后台账号
RequestContext.setAppKey("AMOS_STUDIO");
RequestContext.setProduct("AMOS_STUDIO_WEB");
if(redisUtils.hasKey(RedisKey.CTI_USER_TOKEN)) {
// 验证token
boolean validToken = TokenOperation.refresh(redisUtils.get(RedisKey.CTI_USER_TOKEN).toString());
if(!validToken) { // 登陆
this.loginCtiUser();
}
} else { // 登陆
this.loginCtiUser();
}
String ctiToken = redisUtils.get(RedisKey.CTI_USER_TOKEN).toString();
RequestContext.setToken(ctiToken);
try {
FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.queryByUserName(ctiUserName);
AgencyUserModel userModel = agencyUserModel.getResult();
RequestContext.setExeUserId(userModel.getUserId());
if (userModel == null) {
throw new Exception("无法获取用户信息");
}
saveUserRedis(userModel, ctiToken);
} catch (Exception e) {
//删除失效token缓存
throw new RuntimeException(e.getMessage());
}
}
private void saveUserRedis(AgencyUserModel user, String token) {
String authToken = RedisKey.buildReginKey(user.getUserId(), token);
if (redisUtils.hasKey(authToken)) {
return;
}
CompanyBo company = new CompanyBo();
DepartmentBo department = new DepartmentBo();
RoleBo role = new RoleBo();
CompanyModel companyM = user.getCompanys() != null ? user.getCompanys().get(0) : null ;
Bean.copyExistPropertis(companyM, company);
Map<Long, List<DepartmentModel>> mapDepartments = user.getCompanyDepartments();
DepartmentModel departmentM = companyM != null ? mapDepartments.get(companyM.getSequenceNbr()).get(0) : null ;
Bean.copyExistPropertis(departmentM, department);
Map<Long, List<RoleModel>> roles = user.getOrgRoles();
Long sequenceNbr;
if (departmentM == null) {
sequenceNbr = null;
} else {
sequenceNbr = departmentM.getSequenceNbr();
}
RoleModel roleM = null;
if (sequenceNbr == null) {
roleM = companyM != null ?roles.get(companyM.getSequenceNbr()).get(0) : null;
} else {
roleM = roles.get(sequenceNbr).get(0);
}
Bean.copyExistPropertis(roleM, role);
ReginParams reginParams = new ReginParams();
reginParams.setCompany(company);
reginParams.setRole(role);
reginParams.setDepartment(department);
reginParams.setUserModel(user);
redisUtils.set(authToken, JSONObject.toJSONString(reginParams), redisRegionTimeSecond);
}
}
\ No newline at end of file
......@@ -73,22 +73,13 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
@Autowired
private VoiceRecordFileServiceImpl voiceRecordFileServiceImpl;
@Autowired
private TzsAuthServiceImpl tzsAuthServiceImpl;
@Scheduled(fixedDelay=ONE_Minute)
public void fixedDelayJob(){
// 需要登录后台账号
RequestContext.setAppKey("AMOS_STUDIO");
RequestContext.setProduct("AMOS_STUDIO_WEB");
if(redisUtils.hasKey(RedisKey.CTI_USER_TOKEN)) {
// 验证token
boolean validToken = TokenOperation.refresh(redisUtils.get(RedisKey.CTI_USER_TOKEN).toString());
if(!validToken) { // 登陆
loginCtiUser();
}
} else { // 登陆
loginCtiUser();
}
String ctiToken = redisUtils.get(RedisKey.CTI_USER_TOKEN).toString();
RequestContext.setToken(ctiToken);
// 设置token
tzsAuthServiceImpl.setRequestContext();
// 首先查找未完成 且失败次数少于5 的 记录
List<VoiceRecordLog> logList = this.list(new LambdaQueryWrapper<VoiceRecordLog>().eq(VoiceRecordLog::getIsDeal,false).lt(VoiceRecordLog::getDealTimes,5));
if(logList != null && logList.size() >0) {
......@@ -176,17 +167,6 @@ public class VoiceRecordLogServiceImpl extends BaseService<VoiceRecordLogDto,Voi
}
private void loginCtiUser() {
String passwd = DesUtil.encode(ctiUserPwd, "qaz");
IdPasswordAuthModel loninData = new IdPasswordAuthModel();
loninData.setLoginId(ctiUserName);
loninData.setPassword(passwd);
FeignClientResult loginResult = Privilege.authClient.idpassword(loninData);
if(loginResult.getStatus() == 200) {
HashMap resultMap = (HashMap) loginResult.getResult();
redisUtils.set(RedisKey.CTI_USER_TOKEN, resultMap.get("token").toString(), 25920000l);
}
}
......
......@@ -6,6 +6,8 @@ import com.yeejoin.amos.boot.module.tzs.api.dto.ElevatorDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.MaintenanceUnitDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.entity.MaintenanceUnit;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.UnitInfo;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -237,4 +239,36 @@ public class BeanDtoVoUtils {
}
});
}
/**
* 将企业注册实体类转换为Vo
*
* @param page 原分页对象
* @return 转换后的分页对象
*/
public static IPage<UnitInfoDto> unitInfoIPageDto(IPage<UnitInfo> page) {
return page.convert(item -> {
try {
UnitInfoDto target = new UnitInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(item, target);
if(item.getIsChange()) {
target.setTypeStr("变更");
} else {
target.setTypeStr("注册");
}
if(0 == item.getUnitStatus()) {
target.setStatusStr("审批中");
} else if(1 == item.getUnitStatus()) {
target.setStatusStr("审批结束");
} else if(2 == item.getUnitStatus()) {
target.setStatusStr("已驳回");
}
return target;
} catch (Exception e) {
return null;
}
});
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
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.controller.BaseController;
import com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.tzs.biz.utils.AlertBeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.UnitInfoApproveServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -66,19 +73,6 @@ public class UnitInfoApproveController extends BaseController {
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除企业信息审批意见表", notes = "根据sequenceNbr删除企业信息审批意见表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(unitInfoApproveServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
......@@ -109,15 +103,6 @@ public class UnitInfoApproveController extends BaseController {
return ResponseHelper.buildResponse(unitInfoApproveServiceImpl.queryForFlcUnitInfoApprovePage(page));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "企业信息审批意见表列表全部数据查询", notes = "企业信息审批意见表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<UnitInfoApproveDto>> selectForList() {
return ResponseHelper.buildResponse(unitInfoApproveServiceImpl.queryForFlcUnitInfoApproveList());
}
}
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
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.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsAuthServiceImpl;
import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.UnitInfoServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
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.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.UnitInfoServiceImpl;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
/**
* 企业信息表
......@@ -28,49 +57,186 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
@RequestMapping(value = "/flc-unit-info")
public class UnitInfoController extends BaseController {
@Autowired
RedisUtils redisUtils;
/**
* token 过期时间,wechat 系统为7200 ,tzs 系统小于7200 防止获取到无效token
*/
private long time = 600l;
@Autowired
UnitInfoServiceImpl unitInfoServiceImpl;
@Value("${flc.sms.tempCode}")
private String smsTempCode;
@Autowired
private TzsAuthServiceImpl tzsAuthServiceImpl;
/**
* 获取组织机构树
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/region/tree")
@ApiOperation(httpMethod = "GET", value = "获取组织机构树", notes = "获取组织机构树")
public ResponseModel<Collection<RegionModel>> getRegionTree(@RequestParam(value = "parentId",required = false) Long parentId) {
tzsAuthServiceImpl.setRequestContext();
Collection<RegionModel> result = null;
if(parentId == null) {
result = Systemctl.regionClient.queryForTree(null).getResult();
} else {
result = Systemctl.regionClient.querySubAgencyTree(parentId).getResult();
}
return ResponseHelper.buildResponse(result);
}
/**
* 获取管辖单位树
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/managerment/tree")
@ApiOperation(httpMethod = "GET", value = "获取管辖单位树", notes = "获取管辖单位树")
public ResponseModel<Collection<CompanyModel>> getManagermentTree() {
Collection<CompanyModel> result = null;
result = Privilege.companyClient.companyTreeWithoutAuth().getResult();
return ResponseHelper.buildResponse(result);
}
/**
* 企业信息图片上传 无token
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@PostMapping(value = "/uploadFile")
@ApiOperation(httpMethod = "POST", value = "企业信息图片上传 无token", notes = "企业信息图片上传 无token")
public ResponseModel<String> uploadFile(@ApiParam(value = "文件", required = true)@RequestParam MultipartFile file) {
if (ValidationUtil.isEmpty(file)){
throw new BadRequest("参数校验失败.");
}
tzsAuthServiceImpl.setRequestContext();
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFile(file);
String urlString="";
if (date != null) {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
urlString=it.next();
}
}
return ResponseHelper.buildResponse(urlString);
}
/**
* 判断组织机构是否存在
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/hasExistUnit/{organizationCode}")
@ApiOperation(httpMethod = "GET", value = "判断组织机构是否存在", notes = "判断组织机构是否存在")
public ResponseModel<Boolean> hasExistUnit( @PathVariable(value = "organizationCode") String organizationCode) {
Boolean flag = false;
UnitInfo temp = unitInfoServiceImpl.getOne(new LambdaQueryWrapper<UnitInfo>().eq(UnitInfo::getIsDelete,false).eq(UnitInfo::getOrganizationCode,organizationCode));
if(temp != null) {
flag = true;
}
return ResponseHelper.buildResponse(flag);
}
/**
* 判断用户是否存在
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/hasExistUser/{userName}")
@ApiOperation(httpMethod = "GET", value = "判断用户是否存在", notes = "判断用户是否存在")
public ResponseModel<Boolean> hasExistUser( @PathVariable(value = "userName") String userName) {
Boolean flag = false;
AgencyUserModel user = Privilege.agencyUserClient.queryByUserName(userName).getResult();
if(user != null ) {
flag = true;
}
return ResponseHelper.buildResponse(flag);
}
/**
* 发送手机号验证码
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/sendTelCode/{tel}")
@ApiOperation(httpMethod = "GET", value = "发送手机号验证码", notes = "发送手机号验证码")
public ResponseModel<Boolean> sendTelCode( @PathVariable(value = "tel") String tel) {
if (ValidationUtil.isEmpty(tel)) {
throw new BadRequest("参数校验失败.");
}
Boolean flag = false;
HashMap<String, String> params = new HashMap<>();
String code = this.getRandomCode();
params.put("code",code);
params.put("mobile",tel);
params.put("smsCode", smsTempCode);
try {
Systemctl.smsClient.sendCommonSms(params).getResult();
flag = true;
} catch (Exception e) {
throw new BadRequest("发送短信失败:" + e.getMessage());
}
// code 保存到缓存中
redisUtils.set(RedisKey.FLC_USER_TEL + tel, code,time);
return ResponseHelper.buildResponse(flag);
}
/**
* 验证手机号验证码是否成功
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping(value = "/verifyTelCode/{tel}/{code}")
@ApiOperation(httpMethod = "GET", value = "验证手机号验证码是否成功", notes = "验证手机号验证码是否成功")
public ResponseModel<Boolean> verifyTelCode(@PathVariable(value = "tel") String tel, @PathVariable(value = "code") String code) {
Boolean flag = false;
if (ValidationUtil.isEmpty(tel) || ValidationUtil.isEmpty(code)) {
throw new BadRequest("参数校验失败.");
}
if(redisUtils.hasKey(RedisKey.FLC_USER_TEL + tel)) {
String redisCode = redisUtils.get(RedisKey.FLC_USER_TEL + tel).toString();
if(code.equals(redisCode)) {
flag = true;
}
}
return ResponseHelper.buildResponse(flag);
}
/**
* 新增企业信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增企业信息表", notes = "新增企业信息表")
public ResponseModel<UnitInfoDto> save(@RequestBody UnitInfoDto model) {
model = unitInfoServiceImpl.createWithModel(model);
model = unitInfoServiceImpl.saveUnitInfo(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新企业信息表", notes = "根据sequenceNbr更新企业信息表")
public ResponseModel<UnitInfoDto> updateBySequenceNbrFlcUnitInfo(@RequestBody UnitInfoDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(unitInfoServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除企业信息表", notes = "根据sequenceNbr删除企业信息表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(unitInfoServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
......@@ -81,36 +247,125 @@ public class UnitInfoController extends BaseController {
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个企业信息表", notes = "根据sequenceNbr查询单个企业信息表")
public ResponseModel<UnitInfoDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(unitInfoServiceImpl.queryBySeq(sequenceNbr));
if (ValidationUtil.isEmpty(sequenceNbr) ) {
throw new BadRequest("参数校验失败.");
}
return ResponseHelper.buildResponse(unitInfoServiceImpl.getDtoById(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
* 列表分页查询
*
* @param pageNum 当前页
* @param pageSize 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "企业信息表分页查询", notes = "企业信息表分页查询")
public ResponseModel<Page<UnitInfoDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam
(value = "size") int size) {
Page<UnitInfoDto> page = new Page<UnitInfoDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(unitInfoServiceImpl.queryForFlcUnitInfoPage(page));
@GetMapping(value = "/list")
@ApiOperation(httpMethod = "GET", value = "企业审核列表查询", notes = "企业审核列表查询")
public ResponseModel<IPage<UnitInfoDto>> queryForPage(String pageNum, String pageSize, String sort, UnitInfoDto unitInfoDto) {
// UnitInfo unitInfo = BeanDtoVoUtils.convert(unitInfoDto, UnitInfo.class);
Page<UnitInfo> pageBean;
IPage<UnitInfo> page;
QueryWrapper<UnitInfo> unitInfoQueryWrapper = new QueryWrapper<UnitInfo>();
setQueryWrapper(unitInfoQueryWrapper, unitInfoDto, sort);
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = unitInfoServiceImpl.page(pageBean, unitInfoQueryWrapper);
int num= unitInfoServiceImpl.count(unitInfoQueryWrapper);
pageBean.setTotal(num);
IPage<UnitInfoDto> unitInfoVoIPage = BeanDtoVoUtils.unitInfoIPageDto(page);
return ResponseHelper.buildResponse(unitInfoVoIPage);
}
private QueryWrapper<UnitInfo> setQueryWrapper(QueryWrapper<UnitInfo> queryWrapper, UnitInfoDto unitInfoDto,String sort) {
queryWrapper.eq("is_delete", false);
if(sort!=null) { // 排序失效
String[] date= sort.split(",");
if(date[1].equals("ascend")) {
queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
}else {
queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
}
}else {
queryWrapper.orderByDesc("rec_date");
}
if (!ValidationUtil.isEmpty(unitInfoDto.getIsChange())) { // 分类 注册 / 信息变更 0 注册 1 变更
queryWrapper.eq("is_change",unitInfoDto.getIsChange());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getSubmitTimeStart())) { // 提交时间
queryWrapper.ge("rec_date",unitInfoDto.getSubmitTimeStart());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getSubmitTimeEnd())) { // 提交时间
queryWrapper.le("rec_date",unitInfoDto.getSubmitTimeEnd());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getUnitTypeCode())) { // 单位类型
queryWrapper.like("unit_type_code",unitInfoDto.getUnitTypeCode());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getOrgName())) { // 单位名称
queryWrapper.like("org_name",unitInfoDto.getOrgName());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getOrganizationCode())) { // 组织机构代码/统一信用代码
queryWrapper.like("organization_code",unitInfoDto.getOrganizationCode());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getAdminName())) { // 管理员
queryWrapper.like("admin_name",unitInfoDto.getAdminName());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getAdminTel())) { // 管理员电话
queryWrapper.like("admin_tel",unitInfoDto.getAdminTel());
}
if(!ValidationUtil.isEmpty(unitInfoDto.getUnitStatus())) { // 审核状态
queryWrapper.like("unit_status",unitInfoDto.getUnitStatus());
}
return queryWrapper;
}
private String getRandomCode(){
String code = "";
Random random = new Random();
for (int i = 0; i < 6; i++) {
int r = random.nextInt(10); //每次随机出一个数字(0-9)
code = code + r; //把每次随机出的数字拼在一起
}
return code;
}
/**
* 列表全部数据查询
*
* 审批企业注册
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "企业信息表列表全部数据查询", notes = "企业信息表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<UnitInfoDto>> selectForList() {
return ResponseHelper.buildResponse(unitInfoServiceImpl.queryForFlcUnitInfoList());
@PostMapping(value = "/approve")
@ApiOperation(httpMethod = "POST", value = "审批企业注册", notes = "审批企业注册")
public ResponseModel<UnitInfoDto> approve(@RequestBody UnitInfoApproveDto approveDto) {
if (ValidationUtil.isEmpty(approveDto.getUnitId()) || ValidationUtil.isEmpty(approveDto.getApproveStatus())) {
throw new BadRequest("参数校验失败.");
}
UnitInfoDto model = unitInfoServiceImpl.approve(approveDto);
return ResponseHelper.buildResponse(model);
}
}
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.QRCodeUtil;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.service.ISourceFileService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
import com.yeejoin.amos.boot.module.tzs.api.enums.TzsCommonParam;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsAuthServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.UnitInfoChange;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.UnitInfoMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.IUnitInfoService;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
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.RoleModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 企业信息表服务实现类
......@@ -18,17 +54,326 @@ import java.util.List;
*/
@Service
public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, UnitInfoMapper> implements IUnitInfoService {
/**
* 分页查询
*/
public Page<UnitInfoDto> queryForFlcUnitInfoPage(Page<UnitInfoDto> page) {
return this.queryForPage(page, null, false);
private final Logger logger = LogManager.getLogger(UnitInfoServiceImpl.class);
@Autowired
private TzsAuthServiceImpl tzsAuthServiceImpl;
@Autowired
ISourceFileService ISourceFileService;
@Autowired
DataDictionaryServiceImpl iDataDictionaryService;
@Autowired
UnitInfoChangeServiceImpl iUnitInfoChangeServiceImpl;
@Autowired
UnitInfoApproveServiceImpl iUnitInfoApproveServiceImpl;
@Autowired
OrgUsrServiceImpl iOrgUsrService;
@Autowired
UnitInfoChangeServiceImpl unitInfoChangeServiceImpl;
@Autowired
SourceFileServiceImpl sourceFileService;
@Transactional
public UnitInfoDto saveUnitInfo(UnitInfoDto model) {
tzsAuthServiceImpl.setRequestContext();
model.setUnitStatus(0);// 设置为待审核状态
model.setIsChange(false);// 新增状态不是变更状态
// 处理单位类型
String unitTypeCode = model.getUnitTypeCode();
String[] unitTypeCodes = unitTypeCode.split(",");
String unitType = "";
for(String t : unitTypeCodes) {
LambdaQueryWrapper<DataDictionary> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DataDictionary::getType, TzsCommonParam.UNIT_TYPE).eq(DataDictionary::getCode, t);
DataDictionary temp = iDataDictionaryService.getOne(queryWrapper);
unitType += "," + temp.getName();
}
if(unitType.length() > 0) {
unitType = unitType.substring(1);
model.setUnitType(unitType);
}
// 处理密码信息
String oldPwd = model.getAdminLoginPwd();
String newPwd = DesUtil.encode(oldPwd, "qaz");
model.setAdminLoginPwd(newPwd);
UnitInfo entity = this.prepareEntity(model);
if(this.save(entity)) {
// 处理图片信息
Map<String, List<AttachmentDto>> resultPicMap = new HashMap<>();
resultPicMap.put(TzsCommonParam.LICENCE_PIC,model.getLicencePic());
resultPicMap.put(TzsCommonParam.ADMIN_LICENSE_PIC,model.getAdminLicensePic());
ISourceFileService.saveAttachments(entity.getSequenceNbr(),resultPicMap);
}
return Bean.toModel(entity, model);
}
@Transactional
@Override
public UnitInfoDto approve(UnitInfoApproveDto approveDto) {
UnitInfoDto result = null;
// 如果不存在审批意见 则 默认 通过 / 驳回
// 通过unitid 查找企业信息表 如果不存在则查找 变更表 都不存在返回未找到企业审核表单
String content = approveDto.getContent(); // 审批意见
UnitInfo sourceUnit = this.getById(approveDto.getUnitId());
UnitInfoChange changeUnit = null;
if(sourceUnit == null) {
changeUnit = iUnitInfoChangeServiceImpl.getById(approveDto.getUnitId());
if(changeUnit == null) {
throw new BadRequest("未找到企业审核表单.");
}
sourceUnit = this.getById(changeUnit.getSourceId());
}
if(sourceUnit.getUnitStatus() != 0) { // 无论变更单还是新建单 原始单状态都应该为审核中
throw new BadRequest("表单未处于审核状态中.请确认后操作");
}
Integer approveStatus = approveDto.getApproveStatus(); // 0通过 1驳回
Boolean changeFlag = false;
if(changeUnit != null) {
changeFlag = true;
approveDto.setUnitId(changeUnit.getSequenceNbr());
approveDto.setApproveType(1); // 0 注册审批 1 变更审批
} else {
approveDto.setApproveType(0); // 0 注册审批 1 变更审批
}
approveDto.setSourceId(sourceUnit.getSequenceNbr());
if(0 == approveStatus) {
// 审核通过生成二维码
this.saveUnitInfoQrCode(sourceUnit);
if(StringUtils.isEmpty(content)) {
content = "通过";
}
sourceUnit.setUnitStatus(1);
if(changeFlag) { // 如果是变更单 需要把 变更数据覆盖到原单子 预留(确定字段)
} else { // 如果是审批单 创建用户 创建组织机构 赋权等
// 创建用户 创建组织机构 平台组织机构及 org_user表中 赋权
String adminUserName = sourceUnit.getAdminName();
String loginName = sourceUnit.getAdminLoginName();
String pwd = sourceUnit.getAdminLoginPwd();
String adminTel = sourceUnit.getAdminTel();
CompanyModel companyInfo = new CompanyModel();
companyInfo.setAddress(sourceUnit.getProvince() + sourceUnit.getCity() + sourceUnit.getDistrict() + sourceUnit.getStree() + sourceUnit.getCommunity() + sourceUnit.getAddress());
companyInfo.setAgencyCode("tzs");
companyInfo.setParentId(sourceUnit.getManagementUnitId());
companyInfo.setLevel("headquarter");
companyInfo.setCompanyName(sourceUnit.getOrgName());
companyInfo.setContact(sourceUnit.getUnitTel());
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
if(companyResult == null || companyResult.getResult() == null) {
throw new BadRequest("单位注册失败");
}
companyInfo = companyResult.getResult();
AgencyUserModel agencyUserModel = new AgencyUserModel();
agencyUserModel.setUserName(loginName);
agencyUserModel.setRealName(adminUserName);
agencyUserModel.setLockStatus("UNLOCK");
agencyUserModel.setPassword(pwd);
agencyUserModel.setRePassword(pwd);
agencyUserModel.setAgencyCode("tzs");
agencyUserModel.setMobile(adminTel);
// 根据unitTypeCode 获取应用和 角色
String unitTypeCode = sourceUnit.getUnitTypeCode();
String[] unitTypeCodes = unitTypeCode.split(",");
Set<String> roleNameSet = new HashSet<>();
Set<String> appCodesSet = new HashSet<>();
Map<Long, List<Long>> roleSeqsMap = new HashMap<>();
for(String code : unitTypeCodes) {
DataDictionary unitType = iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getCode,code));
String appCode = unitType.getTypeDesc();
String[] appCodes = appCode.split(",");
for(String tempCode : appCodes) {
appCodesSet.add(tempCode);
}
roleNameSet.add(unitType.getName());
}
List<RoleModel> userRoleList = new ArrayList<>();
// 全部角色筛选
// 获取角色
FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null,null);
List<RoleModel> allRoleList = roleListResult.getResult();
allRoleList.stream().forEach(t -> {
if(roleNameSet.contains(t.getRoleName())) {
userRoleList.add(t);
}
});
List<Long> roleIds = new ArrayList<>();
userRoleList.stream().forEach(r -> {
roleIds.add(r.getSequenceNbr());
});
roleSeqsMap.put(companyInfo.getSequenceNbr(),roleIds);
List<String> appCodes = new ArrayList<>(appCodesSet);
agencyUserModel.setAppCodes(appCodes);
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
orgRoles.put(companyInfo.getSequenceNbr(),userRoleList);
agencyUserModel.setOrgRoles(orgRoles);
agencyUserModel.setOrgRoleSeqs(roleSeqsMap);
FeignClientResult<AgencyUserModel> userResult = Privilege.agencyUserClient.create(agencyUserModel);
if(userResult == null || userResult.getResult() == null) {
throw new BadRequest("注册失败");
}
// org_user 创建组织机构
OrgUsr org = new OrgUsr();
TreeParser.genTreeCode();
org.setBizOrgCode(TreeParser.genTreeCode());
org.setBizOrgType(CommonConstant.BIZ_ORG_TYPE_COMPANY);
org.setBizOrgName(sourceUnit.getOrgName());
if(!iOrgUsrService.save(org)) {
throw new BadRequest("org单位注册失败");
}
sourceUnit.setOrgUserId(org.getSequenceNbr());
}
} else if(1 == approveStatus) {
if(StringUtils.isEmpty(content)) {
content = "驳回";
}
sourceUnit.setUnitStatus(2);
}
approveDto.setContent(content);
iUnitInfoApproveServiceImpl.createWithModel(approveDto);
if(this.updateById(sourceUnit)) {
if(changeFlag && 1 == approveStatus) { // 变更不通过返回变更表数据 其他情况返回原数据
result = unitChangeInfoToDto(changeUnit);
} else {
result = unitInfoToDto(sourceUnit);
}
}
return result;
}
/**
* 列表查询 示例
*/
public List<UnitInfoDto> queryForFlcUnitInfoList() {
return this.queryForList("", false);
@Override
public UnitInfoDto getDtoById(Long sequenceNbr) {
UnitInfo unitInfo = this.getById(sequenceNbr);
UnitInfoDto result = null;
// 如果是变更单 同时为 审批中,默认展示变更表中最新数据
if(unitInfo.getIsChange() && unitInfo.getUnitStatus() == 0) {
List<UnitInfoChange> changeList = unitInfoChangeServiceImpl.list(new LambdaQueryWrapper<UnitInfoChange>().eq(UnitInfoChange::getIsDelete,false).eq(UnitInfoChange::getSourceId,sequenceNbr).orderByDesc(UnitInfoChange::getRecDate));
UnitInfoChange temp = changeList.get(0);
result = unitChangeInfoToDto(temp);
} else {
result = unitInfoToDto(unitInfo);
}
return result;
}
private UnitInfoDto unitInfoToDto(UnitInfo source) {
UnitInfoDto target = new UnitInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(source, target);
if(source.getIsChange()) {
target.setTypeStr("变更");
} else {
target.setTypeStr("注册");
}
if(0 == source.getUnitStatus()) {
target.setStatusStr("审批中");
} else if(1 == source.getUnitStatus()) {
target.setStatusStr("审批结束");
} else if(2 == source.getUnitStatus()) {
target.setStatusStr("已驳回");
}
Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(source.getSequenceNbr());
// 获取企业二维码
if(attachmentMap != null) {
if(attachmentMap.get(TzsCommonParam.QR_CODE) != null) {
target.setQrcode(attachmentMap.get(TzsCommonParam.QR_CODE));
}
if(attachmentMap.get(TzsCommonParam.LICENCE_PIC) != null) {
target.setLicencePic(attachmentMap.get(TzsCommonParam.LICENCE_PIC));
}
if(attachmentMap.get(TzsCommonParam.ADMIN_LICENSE_PIC) != null) {
target.setAdminLicensePic(attachmentMap.get(TzsCommonParam.ADMIN_LICENSE_PIC));
}
}
return target;
}
private UnitInfoDto unitChangeInfoToDto(UnitInfoChange source) {
UnitInfoDto target = new UnitInfoDto();
// 把原对象数据拷贝到新对象
BeanUtils.copyProperties(source, target);
if(0 == source.getUnitStatus()) {
target.setStatusStr("审批中");
} else if(1 == source.getUnitStatus()) {
target.setStatusStr("审批结束");
} else if(2 == source.getUnitStatus()) {
target.setStatusStr("已驳回");
}
Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(source.getSourceId());
// 获取附件信息
if(attachmentMap != null) {
if(attachmentMap.get(TzsCommonParam.QR_CODE) != null) {
target.setQrcode(attachmentMap.get(TzsCommonParam.QR_CODE));
}
if(attachmentMap.get(TzsCommonParam.LICENCE_PIC) != null) {
target.setLicencePic(attachmentMap.get(TzsCommonParam.LICENCE_PIC));
}
if(attachmentMap.get(TzsCommonParam.ADMIN_LICENSE_PIC) != null) {
target.setAdminLicensePic(attachmentMap.get(TzsCommonParam.ADMIN_LICENSE_PIC));
}
}
return target;
}
private String saveUnitInfoQrCode( UnitInfo sourceUnit) {
// 二维码生成规则
String qrString = "企业统一信用代码: " +sourceUnit.getOrganizationCode() +"\n\r";
qrString += "管理人: " +sourceUnit.getAdminName() +"\n\r";
qrString += "管理人电话: " +sourceUnit.getAdminTel() +"\n\r";
byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(qrString, 480);
MultipartFile file = new MockMultipartFile("unitInfo_" + sourceUnit.getSequenceNbr() + ".png","unitInfo_" + sourceUnit.getSequenceNbr() + ".png","application/octet-stream" ,bytes);
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(file);
Map<String, String> map = result.getResult();
if(map.isEmpty()) {
logger.error("未生成二维码文件");
throw new BadRequest("未生成二维码文件");
}
String filePath = "";
for(Map.Entry<String,String> fileResult : map.entrySet()) {
filePath = fileResult.getKey();
}
// 保存qrCode
List<AttachmentDto> qrCode = new ArrayList<>();
AttachmentDto temp = new AttachmentDto();
temp.setName("unitInfo_" + sourceUnit.getSequenceNbr() + ".png");
temp.setType("image");
temp.setUrl(filePath);
qrCode.add(temp);
Map<String, List<AttachmentDto>> attachmentMap = new HashMap<>();
attachmentMap.put(TzsCommonParam.QR_CODE,qrCode);
sourceFileService.saveAttachments(sourceUnit.getSequenceNbr(),attachmentMap);
return filePath;
}
}
\ No newline at end of file
......@@ -75,4 +75,6 @@ mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
\ No newline at end of file
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
\ No newline at end of file
......@@ -81,3 +81,5 @@ mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
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