Commit b1dbc050 authored by wujiang's avatar wujiang

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents 91ffeea4 7c12c0d3
......@@ -269,6 +269,48 @@ public class UnitInfoController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "单位注册", notes = "单位注册")
public ResponseModel<UnitRegisterDto> save(@RequestBody UnitRegisterDto model) {
try {
//判断公司名称重复,
LambdaQueryWrapper<UnitInfo> qudg=new LambdaQueryWrapper<>();
qudg.eq(UnitInfo::getName,model.getUnitInfoDto().getName());
qudg.eq(UnitInfo::getIsDelete,0);
List<UnitInfo> unitInfo= unitInfoMapper.selectList(qudg);
if(unitInfo!=null&&!unitInfo.isEmpty()){
throw new BadRequest("公司名称重复");
}
//判断公司统一信息用代码重复
LambdaQueryWrapper<CommerceInfo> queryWrapper1 = new LambdaQueryWrapper<CommerceInfo>();
queryWrapper1.eq(CommerceInfo::getCreditCode, model.getCommerceInfoDto().getCreditCode());
queryWrapper1.eq(CommerceInfo::getIsDelete,0);
List<CommerceInfo> commerceInfo= commerceInfoMapper.selectList(queryWrapper1);
if(commerceInfo!=null&&!commerceInfo.isEmpty()){
throw new BadRequest("统一信用代码重复");
}
//用户名重复
LambdaQueryWrapper<UnitInfo> qudg1=new LambdaQueryWrapper<>();
qudg1.eq(UnitInfo::getAdminLoginName,model.getUnitInfoDto().getAdminLoginName());
qudg1.eq(UnitInfo::getIsDelete,0);
List<UnitInfo> unitInfo1= unitInfoMapper.selectList(qudg);
if(unitInfo1!=null&&!unitInfo1.isEmpty()){
throw new BadRequest("管理员账户名重复,请更换");
}
LambdaQueryWrapper<PublicAgencyUser> qud2=new LambdaQueryWrapper<>();
qud2.eq(PublicAgencyUser::getAmosUserName,model.getUnitInfoDto().getAdminLoginName());
List<PublicAgencyUser> publicAgencyUse= publicAgencyUserMapper.selectList(qud2);
if(publicAgencyUse!=null&&!publicAgencyUse.isEmpty()){
throw new BadRequest("管理员账户名重复,请更换");
}
RequestContext.setAppKey("AMOS_STUDIO");
RequestContext.setProduct("AMOS_STUDIO_WEB");
RequestContext.setToken(requestContext.getToken());
......
......@@ -171,7 +171,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
regUnitInfo.setManagementUnit("经销商");
try {
// 1. 调用平台进行创建单位、用户信息
this.createCompanyAndUser(regUnitInfo);
// this.createCompanyAndUser(regUnitInfo);
// 2.插入单位表
// regUnitInfo = this.createWithModel(regUnitInfo);
regUnitInfo = this.createWithModelnew(regUnitInfo);
......@@ -187,44 +187,44 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
//新增人员基础信息表
PersonnelBusiness re=new PersonnelBusiness();
PublicAgencyUser publicAgencyUser=new PublicAgencyUser();
publicAgencyUser.setAmosUserId(regUnitInfo.getAdminUserId());
publicAgencyUser.setAmosUserName(regUnitInfo.getAdminLoginName());
publicAgencyUser.setRealName(regUnitInfo.getAdminLoginName());
publicAgencyUser.setRole("["+regUnitInfo.getRoleId()+"]");
publicAgencyUser.setEmergencyTelephone(regUnitInfo.getAdminPhone());
publicAgencyUser.setLockStatus("LOCK");
publicAgencyUserMapper.insert(publicAgencyUser);
re.setAmosDealerId(regUnitInfo.getAmosCompanySeq());
re.setAmosUnitId(regUnitInfo.getAmosCompanySeq());
re.setAmosUnitName(regUnitInfo.getName());
re.setAmosUnitOrgCode(regUnitInfo.getAmosCompanyCode());
re.setFoundationId(publicAgencyUser.getSequenceNbr());
re.setUserType("2");
personnelBusinessMapper.insert(re);
// PublicAgencyUser publicAgencyUser=new PublicAgencyUser();
// publicAgencyUser.setAmosUserId(regUnitInfo.getAdminUserId());
// publicAgencyUser.setAmosUserName(regUnitInfo.getAdminLoginName());
// publicAgencyUser.setRealName(regUnitInfo.getAdminLoginName());
// publicAgencyUser.setRole("["+regUnitInfo.getRoleId()+"]");
// publicAgencyUser.setEmergencyTelephone(regUnitInfo.getAdminPhone());
// publicAgencyUser.setLockStatus("LOCK");
// publicAgencyUserMapper.insert(publicAgencyUser);
//
// PersonnelBusiness re=new PersonnelBusiness();
// re.setAmosDealerId(regUnitInfo.getAmosCompanySeq());
// re.setAmosUnitId(regUnitInfo.getAmosCompanySeq());
// re.setAmosUnitName(regUnitInfo.getName());
// re.setAmosUnitOrgCode(regUnitInfo.getAmosCompanyCode());
// re.setFoundationId(publicAgencyUser.getSequenceNbr());
// re.setUserType("2");
// personnelBusinessMapper.insert(re);
model.setCommerceInfoDto(commerceInfo);
model.setUnitInfoDto(regUnitInfo);
} catch (Exception e) {
log.error(e.getMessage(), e);
// 失败后回滚:删除已经创建的企业信息
if (!ObjectUtils.isEmpty(regUnitInfo.getAmosCompanySeq())) {
FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient
.seleteOne(regUnitInfo.getAmosCompanySeq());
if (feignClientResult != null) {
Privilege.companyClient.deleteCompany(regUnitInfo.getAmosCompanySeq().toString());
}
}
// 失败后回滚:删除已经创建的管理员账号
if (StringUtils.isNotEmpty(regUnitInfo.getAdminUserId())) {
FeignClientResult<AgencyUserModel> feignClientResult = Privilege.agencyUserClient
.queryByUserId(regUnitInfo.getAdminUserId());
if (feignClientResult != null) {
Privilege.agencyUserClient.multDeleteUser(regUnitInfo.getAdminUserId());
}
}
// if (!ObjectUtils.isEmpty(regUnitInfo.getAmosCompanySeq())) {
// FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient
// .seleteOne(regUnitInfo.getAmosCompanySeq());
// if (feignClientResult != null) {
// Privilege.companyClient.deleteCompany(regUnitInfo.getAmosCompanySeq().toString());
// }
// }
// // 失败后回滚:删除已经创建的管理员账号
// if (StringUtils.isNotEmpty(regUnitInfo.getAdminUserId())) {
// FeignClientResult<AgencyUserModel> feignClientResult = Privilege.agencyUserClient
// .queryByUserId(regUnitInfo.getAdminUserId());
// if (feignClientResult != null) {
// Privilege.agencyUserClient.multDeleteUser(regUnitInfo.getAdminUserId());
// }
// }
throw new RuntimeException(e.getMessage());
}
return model;
......@@ -298,6 +298,89 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
return result;
}
private void createCompanyAndUsernew(UnitInfo regUnitInfo) {
CompanyModel companyInfo = new CompanyModel();
FeignClientResult<AgencyUserModel> userResult = null;
try {
//FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null, null);
// List<RoleModel> allRoleList = roleListResult.getResult();
List<RoleModel> userRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
// 1创建公司
companyInfo.setAddress(regUnitInfo.getRegisterPcd());
companyInfo.setAgencyCode("JXIOP");
companyInfo.setParentId(Long.parseLong(regUnitInfo.getManagementUnitId()));
companyInfo.setLevel("station");
companyInfo.setCompanyName(regUnitInfo.getName());
// companyInfo.setCompanyCode(regUnitInfo.getUnitType());
companyInfo.setContact(regUnitInfo.getHeadName());
companyInfo.setCompanyType(regUnitInfo.getUnitType());
companyInfo.setLandlinePhone(regUnitInfo.getHeadPhone());
FeignClientResult<CompanyModel> companyResult = Privilege.companyClient.create(companyInfo);
if (companyResult == null || companyResult.getStatus()!=200) {
throw new BadRequest("单位注册失败!"+companyResult.getDevMessage());
}
String adminUserName = regUnitInfo.getAdminUserName();
String loginName = regUnitInfo.getAdminLoginName();
String pwd = regUnitInfo.getAdminLoginPwd();
String adminTel = regUnitInfo.getAdminPhone();
// 2 创建平台用户
companyInfo = companyResult.getResult();
AgencyUserModel agencyUserModel = new AgencyUserModel();
agencyUserModel.setUserName(loginName);
agencyUserModel.setRealName(adminUserName);
agencyUserModel.setLockStatus("UNLOCK");
agencyUserModel.setPassword(pwd);
agencyUserModel.setRePassword(pwd);
agencyUserModel.setAgencyCode("JXIOP");
agencyUserModel.setMobile(adminTel);
List<String> split = Arrays.asList(StringUtils.split(appCodes, ','));
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
// userRoleList = allRoleList.stream().filter(r -> r.getSequenceNbr().toString().equals(regUnitInfo.getRoleId()))
// .collect(Collectors.toList());
// userRoleList.forEach(r -> {
// if (!roleIds.contains(r.getSequenceNbr())) {
// roleIds.add(r.getSequenceNbr());
// }
// });
// roleIds.add(Long.valueOf(regUnitInfo.getRoleId()));
roleIds.add(userGroupId);
roleSeqMap.put(companyInfo.getSequenceNbr(), roleIds);
orgRoles.put(companyInfo.getSequenceNbr(), userRoleList);
agencyUserModel.setOrgRoles(orgRoles);
agencyUserModel.setOrgRoleSeqs(roleSeqMap);
userResult = Privilege.agencyUserClient.create(agencyUserModel);
if (userResult == null || userResult.getStatus()!=200) {
throw new BadRequest("单位注册失败!"+userResult.getDevMessage());
}
regUnitInfo.setAdminUserId(userResult.getResult().getUserId());
regUnitInfo.setAmosCompanySeq(companyInfo.getSequenceNbr());
regUnitInfo.setAmosCompanyCode(companyInfo.getOrgCode());
List<String> userId = new ArrayList<>();
userId.add(userResult.getResult().getUserId());
// 将创建用户加入用户组
Privilege.groupUserClient.create(userGroupId, userId);
} catch (Exception e) {
// 删除已经创建的 企业信息
if (companyInfo != null && companyInfo.getSequenceNbr() != null) {
Privilege.companyClient.deleteCompany(companyInfo.getSequenceNbr() + "");
}
if (userResult != null && userResult.getResult() != null
&& StringUtils.isNotEmpty(userResult.getResult().getUserId())) {
Privilege.agencyUserClient.multDeleteUser(userResult.getResult().getUserId());
}
log.error(e.getMessage(), e);
throw new RuntimeException(e.getMessage());
}
}
private void createCompanyAndUser(UnitInfoDto regUnitInfo) {
CompanyModel companyInfo = new CompanyModel();
FeignClientResult<AgencyUserModel> userResult = null;
......@@ -435,9 +518,10 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
public String powerStationExamine(long pageId, String nodeCode, String stationId, String taskId, String planInstanceId, Map<String, Object> kv) {
// 2.更新审核记录表
UnitInfo unitInfo=null;
try{
DealerReview dealerReview= dealerReviewMapper.selectOne(new QueryWrapper<DealerReview>().eq("unit_info_id", stationId));
UnitInfo unitInfo= this.getById(stationId);
unitInfo= this.getById(stationId);
DealerReviewEnum nodeByCode = DealerReviewEnum.getNodeByCode(nodeCode);
String approvalStatue="";
if (DealerReviewEnum.经销商管理员审核.getCode().equals(nodeCode)) {
......@@ -458,8 +542,29 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
// 1. 更新经销商状态
unitInfo.setAuditStatus(2);
unitInfo.setBlacklist(0);
Privilege.agencyUserClient.unlockUsers(unitInfo.getAdminUserId());
approvalStatue="任务明细:"+DealerReviewEnum.经销商管理员审核.getName()+"审核通过";
this.createCompanyAndUsernew(unitInfo);
PublicAgencyUser publicAgencyUser=new PublicAgencyUser();
publicAgencyUser.setAmosUserId(unitInfo.getAdminUserId());
publicAgencyUser.setAmosUserName(unitInfo.getAdminLoginName());
publicAgencyUser.setRealName(unitInfo.getAdminLoginName());
publicAgencyUser.setRole("["+unitInfo.getRoleId()+"]");
publicAgencyUser.setEmergencyTelephone(unitInfo.getAdminPhone());
publicAgencyUser.setLockStatus("UNLOCK");
publicAgencyUserMapper.insert(publicAgencyUser);
PersonnelBusiness re=new PersonnelBusiness();
re.setAmosDealerId(unitInfo.getAmosCompanySeq());
re.setAmosUnitId(unitInfo.getAmosCompanySeq());
re.setAmosUnitName(unitInfo.getName());
re.setAmosUnitOrgCode(unitInfo.getAmosCompanyCode());
re.setFoundationId(publicAgencyUser.getSequenceNbr());
re.setUserType("2");
personnelBusinessMapper.insert(re);
// Privilege.agencyUserClient.unlockUsers(unitInfo.getAdminUserId());
approvalStatue="任务明细:"+DealerReviewEnum.经销商管理员审核.getName()+"审核通过";
}
}
// 2. 更新流程状态
......@@ -479,6 +584,26 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
}
this.saveOrUpdate(unitInfo);
}catch (Exception e){
if (!ObjectUtils.isEmpty(unitInfo.getAmosCompanySeq())) {
FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient
.seleteOne(unitInfo.getAmosCompanySeq());
if (feignClientResult != null) {
Privilege.companyClient.deleteCompany(unitInfo.getAmosCompanySeq().toString());
}
}
// 失败后回滚:删除已经创建的管理员账号
if (StringUtils.isNotEmpty(unitInfo.getAdminUserId())) {
FeignClientResult<AgencyUserModel> feignClientResult = Privilege.agencyUserClient
.queryByUserId(unitInfo.getAdminUserId());
if (feignClientResult != null) {
Privilege.agencyUserClient.multDeleteUser(unitInfo.getAdminUserId());
}
}
throw new BaseException("获取工作流节点失败!","400","获取工作流节点失败!");
}
......
......@@ -35,12 +35,12 @@
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-influxdb</artifactId>
<version>1.9.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.yeejoin</groupId>-->
<!-- <artifactId>amos-component-influxdb</artifactId>-->
<!-- <version>1.9.0-SNAPSHOT</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
......
......@@ -177,9 +177,7 @@ public class PowerGenerationImpl {
}
public List<ESMoonPowerGeneration> getESMoonPowerGeneration(StationCacheInfoDto stationCacheInfoDto,List<IndicatorData> indexDto,String daty,String day,String year,Double flags){
List<ESMoonPowerGeneration> list=new ArrayList<>();
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String datynew= myFmt2.format(now);
if(indexDto!=null&&!indexDto.isEmpty()){
for (IndicatorData dto : indexDto) {
double value=dto.getValueF()!=null?(double)dto.getValueF():0.0;
......@@ -187,7 +185,7 @@ public class PowerGenerationImpl {
value=value*flags;
}
ESMoonPowerGeneration moonPowerGeneration=new ESMoonPowerGeneration(
datynew+"_"+dto.getAddress(),
daty+"_"+dto.getAddress(),
stationCacheInfoDto.getStationId(),
stationCacheInfoDto.getStationName(),
stationCacheInfoDto.getStationType(),
......@@ -209,9 +207,7 @@ public class PowerGenerationImpl {
}
public List<ESYearPowerGeneration> getESYearPowerGeneration(StationCacheInfoDto stationCacheInfoDto,List<IndicatorData> indexDto,String daty,String day,Double flags){
List<ESYearPowerGeneration> list=new ArrayList<>();
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyy-MM-dd");
Date now=new Date();
String datynew= myFmt2.format(now);
if(indexDto!=null&&!indexDto.isEmpty()){
for (IndicatorData dto : indexDto) {
double value=dto.getValueF()!=null?(double)dto.getValueF():0.0;
......@@ -219,7 +215,7 @@ public class PowerGenerationImpl {
value=value*flags;
}
ESYearPowerGeneration yearPowerGeneration=new ESYearPowerGeneration(
datynew+"_"+dto.getAddress(),
daty+"_"+dto.getAddress(),
stationCacheInfoDto.getStationId(),
stationCacheInfoDto.getStationName(),
stationCacheInfoDto.getStationType(),
......
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