|
@ -1,8 +1,10 @@
|
|
|
package com.yihu.iot.service.company;
|
|
|
|
|
|
import com.yihu.iot.dao.company.*;
|
|
|
import com.yihu.iot.dao.platform.IotCompanyAppInterfaceDao;
|
|
|
import com.yihu.iot.service.useragent.UserAgent;
|
|
|
import com.yihu.jw.entity.iot.company.*;
|
|
|
import com.yihu.jw.entity.iot.platform.IotCompanyAppInterfaceDO;
|
|
|
import com.yihu.jw.restmodel.iot.company.IotCompanyAppVO;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.iot.company.IotCompanyTypeVO;
|
|
@ -40,11 +42,12 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
private IotCompanyAppDao iotCompanyAppDao;
|
|
|
@Autowired
|
|
|
private UserAgent userAgent;
|
|
|
|
|
|
@Autowired
|
|
|
private IotCompanyAppInterfaceDao iotCompanyAppInterfaceDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 审核通过 分页查找
|
|
|
*分页查找
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @param accountType
|
|
@ -87,6 +90,58 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按类型分页查找
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @param status
|
|
|
* @param accountType
|
|
|
* @param enterType
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String accountType, String enterType){
|
|
|
StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_company c WHERE c.del=1 ");
|
|
|
StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_company c WHERE c.del=1 ");
|
|
|
List<Object> args = new ArrayList<>();
|
|
|
if(StringUtils.isNotBlank(status)){
|
|
|
sql.append(" and c.status=? ");
|
|
|
sqlCount.append(" and c.status='").append(status).append("' ");
|
|
|
args.add(status);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(accountType)){
|
|
|
sql.append(" and c.account_type=? ");
|
|
|
sqlCount.append(" and c.account_type='").append(accountType).append("' ");
|
|
|
args.add(accountType);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(enterType)){
|
|
|
sql.append(" and c.enter_type=? ");
|
|
|
sqlCount.append(" and c.enter_type='").append(enterType).append("' ");
|
|
|
args.add(enterType);
|
|
|
}
|
|
|
sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
|
|
|
|
|
|
List<IotCompanyDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotCompanyDO.class));
|
|
|
if(accountType.equalsIgnoreCase("1")){
|
|
|
//得到list数据
|
|
|
list.forEach(one->{
|
|
|
findType(one);
|
|
|
});
|
|
|
}
|
|
|
if(accountType.equalsIgnoreCase("0")){
|
|
|
list.forEach(one->{
|
|
|
findAppType(one);
|
|
|
});
|
|
|
}
|
|
|
List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
|
|
|
long count = Long.valueOf(countList.get(0).get("count").toString());
|
|
|
|
|
|
//DO转VO
|
|
|
List<IotCompanyVO> iotCompanyVOList = convertToModelVOs(list,new ArrayList<>(list.size()));
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转换
|
|
|
* @param sources
|
|
@ -162,56 +217,6 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
return target;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按类型分页查找
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @param status
|
|
|
* @param accountType
|
|
|
* @param enterType
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String accountType, String enterType){
|
|
|
StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_company c WHERE c.del=1 ");
|
|
|
StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_company c WHERE c.del=1 ");
|
|
|
List<Object> args = new ArrayList<>();
|
|
|
if(StringUtils.isNotBlank(status)){
|
|
|
sql.append(" and c.status=? ");
|
|
|
sqlCount.append(" and c.status='").append(status).append("' ");
|
|
|
args.add(status);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(accountType)){
|
|
|
sql.append(" and c.account_type=? ");
|
|
|
sqlCount.append(" and c.account_type='").append(accountType).append("' ");
|
|
|
args.add(accountType);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(enterType)){
|
|
|
sql.append(" and c.enter_type=? ");
|
|
|
sqlCount.append(" and c.enter_type='").append(enterType).append("' ");
|
|
|
args.add(enterType);
|
|
|
}
|
|
|
sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
|
|
|
|
|
|
List<IotCompanyDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotCompanyDO.class));
|
|
|
if(accountType.equalsIgnoreCase("1")){
|
|
|
//得到list数据
|
|
|
list.forEach(one->{
|
|
|
findType(one);
|
|
|
});
|
|
|
}
|
|
|
if(accountType.equalsIgnoreCase("0")){
|
|
|
list.forEach(one->{
|
|
|
findAppType(one);
|
|
|
});
|
|
|
}
|
|
|
List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
|
|
|
long count = Long.valueOf(countList.get(0).get("count").toString());
|
|
|
|
|
|
//DO转VO
|
|
|
List<IotCompanyVO> iotCompanyVOList = convertToModelVOs(list,new ArrayList<>(list.size()));
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 条件分页查找
|
|
@ -307,6 +312,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
companyType.setCompanyId(id);
|
|
|
companyType.setType(one.getType());
|
|
|
companyType.setTypeName(one.getTypeName());
|
|
|
companyType.setDel("0");
|
|
|
companyTypes.add(companyType);
|
|
|
});
|
|
|
iotCompanyTypeDao.save(companyTypes);
|
|
@ -326,7 +332,6 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
|
|
|
//查找所有应用名称
|
|
|
Iterable<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAll();
|
|
|
IotCompanyDO companyTemp = new IotCompanyDO();
|
|
|
for (IotCompanyAppDO app : appDOList) {
|
|
|
if(app.getName().equalsIgnoreCase(companyAppDO.getName())){
|
|
|
String companyId = app.getCompanyId();
|
|
@ -336,7 +341,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
//查找该企业下的app
|
|
|
List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(companyDO.getId());
|
|
|
//保存注册信息获取CompangId
|
|
|
companyTemp = iotCompanyDao.save(iotCompany);
|
|
|
iotCompany.setId(getCode());
|
|
|
//遍历apps找出与注册相同的app
|
|
|
for (IotCompanyAppDO appDO : apps) {
|
|
|
if (appDO.getName().equalsIgnoreCase(companyAppDO.getName())){
|
|
@ -344,17 +349,17 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
iotCompanyAppDao.save(appDO);
|
|
|
}
|
|
|
//更改公司ID
|
|
|
appDO.setCompanyId(companyTemp.getId());
|
|
|
appDO.setCompanyId(iotCompany.getId());
|
|
|
}
|
|
|
}
|
|
|
return MixEnvelop.getError("该应用已经注册,请使用注册账号登录");
|
|
|
}
|
|
|
}
|
|
|
//平台接入
|
|
|
companyTemp.setStatus("0");//待审核
|
|
|
companyTemp.setSaasId(getCode());
|
|
|
companyTemp.setDel(1);
|
|
|
iotCompany = iotCompanyDao.save(companyTemp);
|
|
|
iotCompany.setStatus("0");//待审核
|
|
|
iotCompany.setSaasId(getCode());
|
|
|
iotCompany.setDel(1);
|
|
|
iotCompany = iotCompanyDao.save(iotCompany);
|
|
|
//保存应用
|
|
|
String id = iotCompany.getId();
|
|
|
IotCompanyAppDO iotCompanyAppDO = new IotCompanyAppDO();
|
|
@ -370,7 +375,8 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
iotCompany.setAccount(userAgent.getUNAME());
|
|
|
iotCompany.setEhrUserId(userAgent.getUID());
|
|
|
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,iotCompany);
|
|
|
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,convertToModelVO(iotCompany));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -460,6 +466,42 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
return MixEnvelop.getError("该企业已删除,请勿重复操作");
|
|
|
}
|
|
|
company.setDel(0);
|
|
|
//删除企业下的信息 平台信息
|
|
|
if(company.getAccountType().equalsIgnoreCase("0")){
|
|
|
List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyId(company.getId());
|
|
|
if (appDOList!=null&&appDOList.size()>0){
|
|
|
//删除应用信息
|
|
|
appDOList.forEach(one->{
|
|
|
one.setDel("0");
|
|
|
//删除接口信息
|
|
|
List<IotCompanyAppInterfaceDO> interfaceDOList = iotCompanyAppInterfaceDao.findByAppId(one.getId());
|
|
|
if (interfaceDOList!=null&&interfaceDOList.size()>0){
|
|
|
interfaceDOList.forEach(tow->{
|
|
|
tow.setDel("1");
|
|
|
iotCompanyAppInterfaceDao.save(tow);
|
|
|
});
|
|
|
}
|
|
|
iotCompanyAppDao.save(one);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//删除产商信息
|
|
|
if (company.getAccountType().equalsIgnoreCase("1")){
|
|
|
List<IotCompanyTypeDO> typeDOList = iotCompanyTypeDao.findByCompanyId(company.getId());
|
|
|
//删除产商类型
|
|
|
if (typeDOList!=null&&typeDOList.size()>0){
|
|
|
typeDOList.forEach(one->{
|
|
|
one.setDel("1");
|
|
|
iotCompanyTypeDao.save(one);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
iotCompanyDao.save(company);
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_delete);
|
|
|
}
|
|
@ -473,7 +515,10 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
if(accountType.equalsIgnoreCase("1")){
|
|
|
//更新类型
|
|
|
List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
|
|
|
iotCompanyTypeDao.delete(typeList);
|
|
|
typeList.forEach(one->{
|
|
|
one.setDel("1");
|
|
|
iotCompanyTypeDao.save(one);
|
|
|
});
|
|
|
List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
|
|
|
|
|
|
iotCompany.getTypeList().forEach(one->{
|
|
@ -482,10 +527,12 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
companyType.setCompanyId(iotCompany.getId());
|
|
|
companyType.setType(one.getType());
|
|
|
companyType.setTypeName(one.getTypeName());
|
|
|
companyType.setDel("0");
|
|
|
companyTypes.add(companyType);
|
|
|
});
|
|
|
|
|
|
iotCompanyTypeDao.save(companyTypes);
|
|
|
|
|
|
}
|
|
|
//更新应用
|
|
|
if(accountType.equalsIgnoreCase("0")){
|
|
@ -676,7 +723,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
|
|
|
|
|
|
IotCompanyDO companyDO = iotCompanyDao.findByAccount(userAgent.getUNAME());
|
|
|
if (companyDO==null){
|
|
|
return MixEnvelop.getError("未入驻企业",-1);
|
|
|
return MixEnvelop.getSuccess("未入驻企业",-1);
|
|
|
}
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,companyDO.getStatus());
|
|
|
}
|