Commit b6685aaf authored by kongfm's avatar kongfm

提交企业变更 及 变更审核逻辑代码

parent 445c198b
package com.yeejoin.amos.boot.module.tzs.flc.api.service; package com.yeejoin.amos.boot.module.tzs.flc.api.service;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto;
/** /**
* 企业信息变更表接口类 * 企业信息变更表接口类
* *
...@@ -9,4 +11,5 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.service; ...@@ -9,4 +11,5 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.service;
*/ */
public interface IUnitInfoChangeService { public interface IUnitInfoChangeService {
UnitInfoDto findLastChangInfo(Long sourceId);
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.service; ...@@ -3,6 +3,8 @@ 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.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto; 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;
/** /**
* 企业信息表接口类 * 企业信息表接口类
...@@ -21,5 +23,13 @@ public interface IUnitInfoService { ...@@ -21,5 +23,13 @@ public interface IUnitInfoService {
UnitInfoDto getDtoById(Long sequenceNbr); UnitInfoDto getDtoById(Long sequenceNbr);
UnitInfoDto getUnItDtoById(Long sequenceNbr);
UnitInfoDto unitInfoToDto(UnitInfo source);
UnitInfoDto unitChangeInfoToDto(UnitInfoChange source);
UnitInfoDto getDtoByOrgId(Long sequenceNbr); UnitInfoDto getDtoByOrgId(Long sequenceNbr);
UnitInfoDto changeUnInfo(UnitInfoDto model);
} }
...@@ -18,6 +18,7 @@ import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator; ...@@ -18,6 +18,7 @@ import com.yeejoin.amos.boot.module.tzs.api.entity.Elevator;
import com.yeejoin.amos.boot.module.tzs.api.entity.ElevatorInsure; import com.yeejoin.amos.boot.module.tzs.api.entity.ElevatorInsure;
import com.yeejoin.amos.boot.module.tzs.api.entity.ElevatorInsureRelation; import com.yeejoin.amos.boot.module.tzs.api.entity.ElevatorInsureRelation;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.enums.TzsCommonParam;
import com.yeejoin.amos.boot.module.tzs.api.mapper.ElevatorMapper; import com.yeejoin.amos.boot.module.tzs.api.mapper.ElevatorMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IElevatorInsureRelationService; import com.yeejoin.amos.boot.module.tzs.api.service.IElevatorInsureRelationService;
import com.yeejoin.amos.boot.module.tzs.api.service.IElevatorService; import com.yeejoin.amos.boot.module.tzs.api.service.IElevatorService;
...@@ -209,8 +210,8 @@ public class ElevatorServiceImpl extends BaseService<ElevatorDto, Elevator, Elev ...@@ -209,8 +210,8 @@ public class ElevatorServiceImpl extends BaseService<ElevatorDto, Elevator, Elev
temp.setType("image"); temp.setType("image");
temp.setUrl(filePath); temp.setUrl(filePath);
qrCode.add(temp); qrCode.add(temp);
Map<String, List<AttachmentDto>> attachmentMap = new HashMap<>(); Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(elevatorId);
attachmentMap.put("qrCode",qrCode); attachmentMap.put(TzsCommonParam.QR_CODE,qrCode);
sourceFileService.saveAttachments(elevatorId,attachmentMap); sourceFileService.saveAttachments(elevatorId,attachmentMap);
return filePath; return filePath;
} }
......
...@@ -267,6 +267,7 @@ public class BeanDtoVoUtils { ...@@ -267,6 +267,7 @@ public class BeanDtoVoUtils {
} }
target.setFullAddress(item.getProvince() + item.getCity() + item.getDistrict() + item.getStree() + item.getCommunity() + item.getAddress()); target.setFullAddress(item.getProvince() + item.getCity() + item.getDistrict() + item.getStree() + item.getCommunity() + item.getAddress());
target.setAdminLoginPwd(null);
return target; return target;
} catch (Exception e) { } catch (Exception e) {
return null; return null;
......
...@@ -14,6 +14,7 @@ import com.yeejoin.amos.boot.module.tzs.biz.utils.BeanDtoVoUtils; ...@@ -14,6 +14,7 @@ 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.UnitInfoApproveDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto; 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.UnitInfo;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.UnitInfoChangeServiceImpl;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.UnitInfoServiceImpl; import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.UnitInfoServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
...@@ -81,6 +82,9 @@ public class UnitInfoController extends BaseController { ...@@ -81,6 +82,9 @@ public class UnitInfoController extends BaseController {
@Autowired @Autowired
OrgUsrServiceImpl iOrgUsrService; OrgUsrServiceImpl iOrgUsrService;
@Autowired
UnitInfoChangeServiceImpl unitInfoChangeServiceImpl;
/** /**
* 获取组织机构树 * 获取组织机构树
* *
...@@ -256,7 +260,7 @@ public class UnitInfoController extends BaseController { ...@@ -256,7 +260,7 @@ public class UnitInfoController extends BaseController {
if (ValidationUtil.isEmpty(sequenceNbr) ) { if (ValidationUtil.isEmpty(sequenceNbr) ) {
throw new BadRequest("参数校验失败."); throw new BadRequest("参数校验失败.");
} }
return ResponseHelper.buildResponse(unitInfoServiceImpl.getDtoById(sequenceNbr)); return ResponseHelper.buildResponse(unitInfoServiceImpl.getUnItDtoById(sequenceNbr));
} }
...@@ -395,7 +399,14 @@ public class UnitInfoController extends BaseController { ...@@ -395,7 +399,14 @@ public class UnitInfoController extends BaseController {
for(CompanyModel c : companys) { for(CompanyModel c : companys) {
OrgUsr temp = iOrgUsrService.getOne(new LambdaQueryWrapper<OrgUsr>().eq(OrgUsr::getIsDelete,false).eq(OrgUsr::getAmosOrgId,c.getSequenceNbr())); OrgUsr temp = iOrgUsrService.getOne(new LambdaQueryWrapper<OrgUsr>().eq(OrgUsr::getIsDelete,false).eq(OrgUsr::getAmosOrgId,c.getSequenceNbr()));
if(temp != null) { if(temp != null) {
return ResponseHelper.buildResponse(unitInfoServiceImpl.getDtoByOrgId(temp.getSequenceNbr())); // 企业信息查看判断是否变更 如果变更信息则返回变更中信息
result = unitInfoServiceImpl.getDtoByOrgId(temp.getSequenceNbr());
if(result.getIsChange() && result.getUnitStatus() == 0) {
result = unitInfoChangeServiceImpl.findLastChangInfo(temp.getSequenceNbr());
}
return ResponseHelper.buildResponse(result);
} }
} }
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
...@@ -403,4 +414,38 @@ public class UnitInfoController extends BaseController { ...@@ -403,4 +414,38 @@ public class UnitInfoController extends BaseController {
/**
* 变更企业表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/change")
@ApiOperation(httpMethod = "POST", value = "变更企业表", notes = "变更企业表")
public ResponseModel<UnitInfoDto> change(@RequestBody UnitInfoDto model) {
model = unitInfoServiceImpl.changeUnInfo(model);
return ResponseHelper.buildResponse(model);
}
/**
* 查询审批数据
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/approve/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "查询审批数据", notes = "查询审批数据")
public ResponseModel<UnitInfoDto> getApproveInfo(@PathVariable Long sequenceNbr) {
if (ValidationUtil.isEmpty(sequenceNbr) ) {
throw new BadRequest("参数校验失败.");
}
return ResponseHelper.buildResponse(unitInfoServiceImpl.getDtoById(sequenceNbr));
}
} }
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl; package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoChangeDto; import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoChangeDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.UnitInfoDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.UnitInfoChange; import com.yeejoin.amos.boot.module.tzs.flc.api.entity.UnitInfoChange;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.UnitInfoChangeMapper; import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.UnitInfoChangeMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.IUnitInfoChangeService; import com.yeejoin.amos.boot.module.tzs.flc.api.service.IUnitInfoChangeService;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.IUnitInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.List; import java.util.List;
...@@ -18,6 +23,10 @@ import java.util.List; ...@@ -18,6 +23,10 @@ import java.util.List;
*/ */
@Service @Service
public class UnitInfoChangeServiceImpl extends BaseService<UnitInfoChangeDto, UnitInfoChange, UnitInfoChangeMapper> implements IUnitInfoChangeService { public class UnitInfoChangeServiceImpl extends BaseService<UnitInfoChangeDto, UnitInfoChange, UnitInfoChangeMapper> implements IUnitInfoChangeService {
@Autowired
IUnitInfoService iUnitInfoService;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -31,4 +40,22 @@ public class UnitInfoChangeServiceImpl extends BaseService<UnitInfoChangeDto, Un ...@@ -31,4 +40,22 @@ public class UnitInfoChangeServiceImpl extends BaseService<UnitInfoChangeDto, Un
public List<UnitInfoChangeDto> queryForFlcUnitInfoChangeList() { public List<UnitInfoChangeDto> queryForFlcUnitInfoChangeList() {
return this.queryForList("", false); return this.queryForList("", false);
} }
/**
* 根据源码id 返回最新的变更记录
* @param sourceId
* @return
*/
@Override
public UnitInfoDto findLastChangInfo(Long sourceId) {
UnitInfoChange result;
List<UnitInfoChange> changInfoList = this.list(new LambdaQueryWrapper<UnitInfoChange>().eq(UnitInfoChange::getIsDelete,false).eq(UnitInfoChange::getSourceId,sourceId).orderByDesc(UnitInfoChange::getRecDate));
if(changInfoList != null && changInfoList.size() >0) {
result = changInfoList.get(0);
} else {
throw new BadRequest("未找到变更记录");
}
return iUnitInfoService.unitChangeInfoToDto(result);
}
} }
\ No newline at end of file
...@@ -83,6 +83,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -83,6 +83,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
SourceFileServiceImpl sourceFileService; SourceFileServiceImpl sourceFileService;
@Transactional @Transactional
public UnitInfoDto saveUnitInfo(UnitInfoDto model) { public UnitInfoDto saveUnitInfo(UnitInfoDto model) {
tzsAuthServiceImpl.setRequestContext(); tzsAuthServiceImpl.setRequestContext();
...@@ -150,19 +151,96 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -150,19 +151,96 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
approveDto.setSourceId(sourceUnit.getSequenceNbr()); approveDto.setSourceId(sourceUnit.getSequenceNbr());
if(0 == approveStatus) { if(0 == approveStatus) {
// 审核通过生成二维码 Set<String> roleNameSet = new HashSet<>();
this.saveUnitInfoQrCode(sourceUnit); FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null,null);
List<RoleModel> allRoleList = roleListResult.getResult();
List<RoleModel> userRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
if(StringUtils.isEmpty(content)) { if(StringUtils.isEmpty(content)) {
content = "通过"; content = "通过";
} }
sourceUnit.setUnitStatus(1); sourceUnit.setUnitStatus(1);
if(changeFlag) { // 如果是变更单 需要把 变更数据覆盖到原单子 预留(确定字段) if(changeFlag) { // 如果是变更单 需要把 变更数据覆盖到原单子 预留(确定字段)
changeUnit.setUnitStatus(1);
// 变更单全覆盖原单
Long sourceId = sourceUnit.getSequenceNbr();
BeanUtils.copyProperties(changeUnit,sourceUnit);
sourceUnit.setSequenceNbr(sourceId);
unitInfoChangeServiceImpl.updateById(changeUnit);
// 更新企业信息 org_user 信息 及管理员信息
} else { // 如果是审批单 创建用户 创建组织机构 赋权等 // 根据unitTypeCode 获取应用和 角色
String unitTypeCode = sourceUnit.getUnitTypeCode();
String[] unitTypeCodes = unitTypeCode.split(",");
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());
}
allRoleList.stream().forEach(t -> {
if(roleNameSet.contains(t.getRoleName())) {
userRoleList.add(t);
}
});
userRoleList.stream().forEach(r -> {
roleIds.add(r.getSequenceNbr());
});
// orguser
OrgUsr org = iOrgUsrService.getById(sourceUnit.getOrgUserId());
org.setBizOrgName(sourceUnit.getOrgName());
iOrgUsrService.updateById(org);
// company
CompanyModel companyInfo = Privilege.companyClient.seleteOne(Long.parseLong(org.getAmosOrgId())).getResult();
companyInfo.setCompanyName(sourceUnit.getOrgName());
companyInfo.setAddress(sourceUnit.getProvince() + sourceUnit.getCity() + sourceUnit.getDistrict() + sourceUnit.getStree() + sourceUnit.getCommunity() + sourceUnit.getAddress());
Privilege.companyClient.update(companyInfo,Long.parseLong(org.getAmosOrgId()));
// 人员信息
AgencyUserModel agencyUserModel = Privilege.agencyUserClient.queryByUserName(sourceUnit.getAdminLoginName()).getResult();
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);
Privilege.agencyUserClient.update(agencyUserModel,agencyUserModel.getUserId());
// 更新附件
Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(changeUnit.getSequenceNbr());
// 获取附件
if(attachmentMap != null) {
Map<String, List<AttachmentDto>> resultPicMap = new HashMap<>();
if(attachmentMap.get(TzsCommonParam.LICENCE_PIC) != null) {
resultPicMap.put(TzsCommonParam.LICENCE_PIC,attachmentMap.get(TzsCommonParam.LICENCE_PIC));
}
if(attachmentMap.get(TzsCommonParam.ADMIN_LICENSE_PIC) != null) {
resultPicMap.put(TzsCommonParam.ADMIN_LICENSE_PIC,attachmentMap.get(TzsCommonParam.ADMIN_LICENSE_PIC));
}
ISourceFileService.saveAttachments(sourceUnit.getSequenceNbr(),resultPicMap);
}
} else { // 如果是审批单 创建用户 创建组织机构 赋权等
sourceUnit.setApprovedTime(new Date()); sourceUnit.setApprovedTime(new Date());
// 创建用户 创建组织机构 平台组织机构及 org_user表中 赋权 // 创建用户 创建组织机构 平台组织机构及 org_user表中 赋权
String adminUserName = sourceUnit.getAdminName(); String adminUserName = sourceUnit.getAdminName();
...@@ -195,7 +273,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -195,7 +273,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
// 根据unitTypeCode 获取应用和 角色 // 根据unitTypeCode 获取应用和 角色
String unitTypeCode = sourceUnit.getUnitTypeCode(); String unitTypeCode = sourceUnit.getUnitTypeCode();
String[] unitTypeCodes = unitTypeCode.split(","); String[] unitTypeCodes = unitTypeCode.split(",");
Set<String> roleNameSet = new HashSet<>();
Set<String> appCodesSet = new HashSet<>(); Set<String> appCodesSet = new HashSet<>();
Map<Long, List<Long>> roleSeqsMap = new HashMap<>(); Map<Long, List<Long>> roleSeqsMap = new HashMap<>();
...@@ -208,23 +286,20 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -208,23 +286,20 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} }
roleNameSet.add(unitType.getName()); 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 -> { allRoleList.stream().forEach(t -> {
if(roleNameSet.contains(t.getRoleName())) { if(roleNameSet.contains(t.getRoleName())) {
userRoleList.add(t); userRoleList.add(t);
} }
}); });
List<Long> roleIds = new ArrayList<>();
userRoleList.stream().forEach(r -> { userRoleList.stream().forEach(r -> {
roleIds.add(r.getSequenceNbr()); roleIds.add(r.getSequenceNbr());
}); });
roleSeqsMap.put(companyInfo.getSequenceNbr(),roleIds);
roleSeqsMap.put(companyInfo.getSequenceNbr(),roleIds);
List<String> appCodes = new ArrayList<>(appCodesSet); List<String> appCodes = new ArrayList<>(appCodesSet);
agencyUserModel.setAppCodes(appCodes); agencyUserModel.setAppCodes(appCodes);
Map<Long, List<RoleModel>> orgRoles = new HashMap<>(); Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
...@@ -253,16 +328,25 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -253,16 +328,25 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
sourceUnit.setOrgUserId(org.getSequenceNbr()); sourceUnit.setOrgUserId(org.getSequenceNbr());
} }
// 审核通过生成二维码
this.saveUnitInfoQrCode(sourceUnit);
} else if(1 == approveStatus) { } else if(1 == approveStatus) {
if(StringUtils.isEmpty(content)) { if(StringUtils.isEmpty(content)) {
content = "驳回"; content = "驳回";
} }
if(changeFlag) { // 如果是变更单 需要把 变更数据覆盖到原单子 预留(确定字段)
changeUnit.setUnitStatus(2);
// 变更单全覆盖原单
unitInfoChangeServiceImpl.updateById(changeUnit);
}
sourceUnit.setUnitStatus(2); sourceUnit.setUnitStatus(2);
} }
approveDto.setContent(content); approveDto.setContent(content);
iUnitInfoApproveServiceImpl.createWithModel(approveDto); iUnitInfoApproveServiceImpl.createWithModel(approveDto);
if(this.updateById(sourceUnit)) { if(this.updateById(sourceUnit)) {
if(changeFlag && 1 == approveStatus) { // 变更不通过返回变更表数据 其他情况返回原数据 if(changeFlag && 1 == approveStatus) { // 变更不通过返回变更表数据 其他情况返回原数据
result = unitChangeInfoToDto(changeUnit); result = unitChangeInfoToDto(changeUnit);
...@@ -281,17 +365,22 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -281,17 +365,22 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
UnitInfoDto result = null; UnitInfoDto result = null;
// 如果是变更单 同时为 审批中,默认展示变更表中最新数据 // 如果是变更单 同时为 审批中,默认展示变更表中最新数据
if(unitInfo.getIsChange() && unitInfo.getUnitStatus() == 0) { 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)); result = unitInfoChangeServiceImpl.findLastChangInfo(sequenceNbr);
UnitInfoChange temp = changeList.get(0);
result = unitChangeInfoToDto(temp);
} else { } else {
result = unitInfoToDto(unitInfo); result = unitInfoToDto(unitInfo);
} }
return result; return result;
} }
@Override
public UnitInfoDto getUnItDtoById(Long sequenceNbr) {
UnitInfo unitInfo = this.getById(sequenceNbr);
return unitInfoToDto(unitInfo);
}
private UnitInfoDto unitInfoToDto(UnitInfo source) {
@Override
public UnitInfoDto unitInfoToDto(UnitInfo source) {
UnitInfoDto target = new UnitInfoDto(); UnitInfoDto target = new UnitInfoDto();
// 把原对象数据拷贝到新对象 // 把原对象数据拷贝到新对象
BeanUtils.copyProperties(source, target); BeanUtils.copyProperties(source, target);
...@@ -322,10 +411,12 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -322,10 +411,12 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} }
target.setFullAddress(source.getProvince() + source.getCity() + source.getDistrict() + source.getStree() + source.getCommunity() + source.getAddress()); target.setFullAddress(source.getProvince() + source.getCity() + source.getDistrict() + source.getStree() + source.getCommunity() + source.getAddress());
target.setAdminLoginPwd(null);
return target; return target;
} }
private UnitInfoDto unitChangeInfoToDto(UnitInfoChange source) { @Override
public UnitInfoDto unitChangeInfoToDto(UnitInfoChange source) {
UnitInfoDto target = new UnitInfoDto(); UnitInfoDto target = new UnitInfoDto();
// 把原对象数据拷贝到新对象 // 把原对象数据拷贝到新对象
BeanUtils.copyProperties(source, target); BeanUtils.copyProperties(source, target);
...@@ -336,7 +427,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -336,7 +427,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} else if(2 == source.getUnitStatus()) { } else if(2 == source.getUnitStatus()) {
target.setStatusStr("已驳回"); target.setStatusStr("已驳回");
} }
Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(source.getSourceId()); Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(source.getSequenceNbr());
// 获取附件信息 // 获取附件信息
if(attachmentMap != null) { if(attachmentMap != null) {
if(attachmentMap.get(TzsCommonParam.QR_CODE) != null) { if(attachmentMap.get(TzsCommonParam.QR_CODE) != null) {
...@@ -351,6 +442,10 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -351,6 +442,10 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} }
target.setFullAddress(source.getProvince() + source.getCity() + source.getDistrict() + source.getStree() + source.getCommunity() + source.getAddress()); target.setFullAddress(source.getProvince() + source.getCity() + source.getDistrict() + source.getStree() + source.getCommunity() + source.getAddress());
UnitInfo info = this.getById(source.getSourceId());
target.setAdminName(info.getAdminName());
target.setAdminLoginName(info.getAdminLoginName());
return target; return target;
} }
...@@ -379,7 +474,8 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -379,7 +474,8 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
temp.setType("image"); temp.setType("image");
temp.setUrl(filePath); temp.setUrl(filePath);
qrCode.add(temp); qrCode.add(temp);
Map<String, List<AttachmentDto>> attachmentMap = new HashMap<>(); // 查询之前的附件
Map<String, List<AttachmentDto>> attachmentMap = sourceFileService.getAttachments(sourceUnit.getSequenceNbr());
attachmentMap.put(TzsCommonParam.QR_CODE,qrCode); attachmentMap.put(TzsCommonParam.QR_CODE,qrCode);
sourceFileService.saveAttachments(sourceUnit.getSequenceNbr(),attachmentMap); sourceFileService.saveAttachments(sourceUnit.getSequenceNbr(),attachmentMap);
return filePath; return filePath;
...@@ -394,4 +490,60 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -394,4 +490,60 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} }
return unitInfoToDto(unitInfo); return unitInfoToDto(unitInfo);
} }
@Transactional
@Override
public UnitInfoDto changeUnInfo(UnitInfoDto model) {
// 变更之前判断是否可以变更
UnitInfo sourceInfo = this.getById(model.getSequenceNbr());
if(sourceInfo == null) {
throw new BadRequest("未找到原单");
}
if(sourceInfo.getUnitStatus() != 1) {
throw new BadRequest("该企业状态无法变更");
}
// 原表单变为 变更审核状态
sourceInfo.setIsChange(true);// 新增状态不是变更状态
sourceInfo.setUnitStatus(0);// 设置为待审核状态
this.updateById(sourceInfo);
UnitInfoChange targetInfo = new UnitInfoChange();
BeanUtils.copyProperties(model,targetInfo);
targetInfo.setSequenceNbr(null);
targetInfo.setSourceId(model.getSequenceNbr());
targetInfo.setRecDate(new Date());
// 社会信用代码和管辖单位不可变
targetInfo.setOrganizationCode(sourceInfo.getOrganizationCode());
targetInfo.setManagementUnit(sourceInfo.getManagementUnit());
targetInfo.setManagementUnitId(sourceInfo.getManagementUnitId());
targetInfo.setUnitStatus(0);
targetInfo.setSubmitTime(sourceInfo.getSubmitTime());
// targetInfo.setApprovedTime(sourceInfo.getApprovedTime());
// 处理单位类型
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);
targetInfo.setUnitType(unitType);
}
if(unitInfoChangeServiceImpl.save(targetInfo)) {
// 处理图片信息
Map<String, List<AttachmentDto>> resultPicMap = new HashMap<>();
resultPicMap.put(TzsCommonParam.LICENCE_PIC,model.getLicencePic());
resultPicMap.put(TzsCommonParam.ADMIN_LICENSE_PIC,model.getAdminLicensePic());
ISourceFileService.saveAttachments(targetInfo.getSequenceNbr(),resultPicMap);
}
return unitChangeInfoToDto(targetInfo);
}
} }
\ 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