Browse Source

物联网 BUG修复

mengkang 5 years ago
parent
commit
e95ca1817d

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyAppDO.java

@ -25,6 +25,8 @@ public class IotCompanyAppDO extends UuidIdentityEntityWithOperator implements S
    private String companyName;//公司名称
    @Column(name = "address_ip")
    private String addressIp;//访问IP地址
    @Column(name = "status")
    private String status;//转态: 1:生效  0:为生效
    @Column(name = "del")
    private String del;//是否删除 0:删除  1:不删除
@ -66,4 +68,12 @@ public class IotCompanyAppDO extends UuidIdentityEntityWithOperator implements S
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
}

+ 7 - 3
svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyAppDao.java

@ -22,10 +22,14 @@ public interface IotCompanyAppDao extends PagingAndSortingRepository<IotCompanyA
        @Query("from IotCompanyAppDO w where w.id =?1 and w.del=1")
        IotCompanyAppDO findById(String appId);
        @Query("from IotCompanyAppDO w where w.companyId =?1 and w.del=0")
        List<IotCompanyAppDO> findByCompanyIdAndDel(String companyId);
        @Query("from IotCompanyAppDO w where w.companyId =?1 and w.status=0 and w.del=1")
        List<IotCompanyAppDO> findByCompanyIdAndStatus(String companyId);
        @Query("from IotCompanyAppDO w where w.del=0")
        @Query("from IotCompanyAppDO w where w.del=1")
        List<IotCompanyAppDO> findAllByDel();
        @Query("from IotCompanyAppDO w where w.name=?1 and w.del=1")
        IotCompanyAppDO findByName(String name);
        }

+ 6 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyDao.java

@ -36,4 +36,10 @@ public interface IotCompanyDao extends PagingAndSortingRepository<IotCompanyDO,
    @Query("from IotCompanyDO w where w.ehrUserId =?1 and w.del=1")
    IotCompanyDO findByEhrUserId(String uid);
    @Query("from IotCompanyDO w where w.businessLicense =?1 and w.accountType=?2 and w.del=1 and (w.status=1 or w.status=0 )")
    IotCompanyDO findByBusinessLicenseAndAccountType(String businessLicense,String accountType);
    @Query("from IotCompanyDO w where w.name =?1 and w.accountType=?2 and w.id<>?3 and w.del=1")
    IotCompanyDO findByNameAndAccountTypeAndId(String name,String accountType,String id);
}

+ 69 - 58
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -462,16 +462,27 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
                //1、判断企业名称是否已经注册
                List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
                for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                    //判断营业执照号是否被注册
                    if (iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) &&
                            (iotCompanyDO.getStatus().equalsIgnoreCase("1") || iotCompanyDO.getStatus().equalsIgnoreCase("0"))) {
                        return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                    }
                    if(iotCompany.getName().equalsIgnoreCase(iotCompanyDO.getName())&&(!iotCompany.getId().equalsIgnoreCase(iotCompanyDO.getId()))){
                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                    }
//                List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
//                for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
//                    //判断营业执照号是否被注册
//                    if (iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) &&
//                            (iotCompanyDO.getStatus().equalsIgnoreCase("1") || iotCompanyDO.getStatus().equalsIgnoreCase("0"))) {
//                        return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
//                    }
//                    if(iotCompany.getName().equalsIgnoreCase(iotCompanyDO.getName())&&(!iotCompany.getId().equalsIgnoreCase(iotCompanyDO.getId()))){
//                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
//                    }
//                }
                IotCompanyDO businessLicense = iotCompanyDao.findByBusinessLicenseAndAccountType(iotCompany.getBusinessLicense(), iotCompany.getAccountType());
                if (businessLicense!=null){
                    return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                }
                IotCompanyDO name = iotCompanyDao.findByNameAndAccountTypeAndId(iotCompany.getName(), iotCompany.getAccountType(), iotCompany.getId());
                if (name!=null){
                    return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                }
@ -500,20 +511,16 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            //平台
            if (iotCompany.getAccountType().equalsIgnoreCase("0")) {
                List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
                IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
                for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                    //判断营业执照号是否被注册
                    if (iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) &&
                            (iotCompanyDO.getStatus().equalsIgnoreCase("1")||iotCompanyDO.getStatus().equalsIgnoreCase("0"))) {
                        return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                    }
                    if(iotCompany.getName().equalsIgnoreCase(iotCompanyDO.getName())&&(!iotCompany.getId().equalsIgnoreCase(iotCompanyDO.getId()))){
                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                    }
                IotCompanyDO businessLicense = iotCompanyDao.findByBusinessLicenseAndAccountType(iotCompany.getBusinessLicense(), iotCompany.getAccountType());
                if (businessLicense!=null){
                    return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                }
                IotCompanyDO name = iotCompanyDao.findByNameAndAccountTypeAndId(iotCompany.getName(), iotCompany.getAccountType(), iotCompany.getId());
                if (name!=null){
                    return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                }
                List<IotCompanyAppDO> apps = iotCompanyAppDao.findAllByDel();
@ -521,11 +528,12 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
                for (IotCompanyAppDO appDO : apps) {
                    if(companyAppDO.getName().equalsIgnoreCase(appDO.getName())&&(!appDO.getId().equalsIgnoreCase(companyAppDO.getId()))){
                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                        return MixEnvelop.getError("该应用名称已被注册,请使用其他企业");
                    }
                    if (appDO.getId().equalsIgnoreCase(companyAppDO.getId())) {
                        appDO.setDel("0");
                        appDO.setStatus("0");
                        appDO.setCompanyName(iotCompany.getName());
                        appDO.setCompanyId(iotCompany.getId());
                        appDO.setName(companyAppDO.getName());
@ -542,27 +550,23 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        IotCompanyDO companyDO = null;
        //id为空,新增企业
        if (StringUtils.isEmpty(iotCompany.getId())) {
            companyDO= iotCompanyDao.save(iotCompany);
            //厂商
            if (companyDO.getAccountType().equalsIgnoreCase("1")) {
            if (iotCompany.getAccountType().equalsIgnoreCase("1")) {
                IotCompanyDO businessLicense = iotCompanyDao.findByBusinessLicenseAndAccountType(iotCompany.getBusinessLicense(), iotCompany.getAccountType());
                if (businessLicense!=null){
                    return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                }
                //1、判断企业名称是否已经注册
                List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(companyDO.getAccountType());
                for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                    //判断营业执照号是否被注册
                    if (companyDO.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) &&
                            (iotCompanyDO.getStatus().equalsIgnoreCase("1") || iotCompanyDO.getStatus().equalsIgnoreCase("0"))) {
                        return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                    }
                    if(companyDO.getName().equalsIgnoreCase(iotCompanyDO.getName())){
                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                    }
                IotCompanyDO name = iotCompanyDao.findByNameAndAccountType(iotCompany.getName(), iotCompany.getAccountType());
                if (name!=null){
                    return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                }
                List<IotCompanyTypeDO> list = companyDO.getTypeList();
                String id = companyDO.getId();
                List<IotCompanyTypeDO> list = iotCompany.getTypeList();
                iotCompany= iotCompanyDao.save(iotCompany);
                String id = iotCompany.getId();
                //新增类型
                List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
                list.forEach(one->{
@ -578,37 +582,43 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            }
            //平台
            if (companyDO.getAccountType().equalsIgnoreCase("0")) {
                List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(companyDO.getAccountType());
            if (iotCompany.getAccountType().equalsIgnoreCase("0")) {
                IotCompanyAppDO companyAppDO = companyDO.getAppList().get(0);
                IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
                for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                    //判断营业执照号是否被注册
                    if (companyDO.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) &&
                            (iotCompanyDO.getStatus().equalsIgnoreCase("1")||iotCompanyDO.getStatus().equalsIgnoreCase("0"))) {
                        return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                    }
                    if(companyDO.getName().equalsIgnoreCase(iotCompanyDO.getName())){
                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                    }
                IotCompanyDO businessLicense = iotCompanyDao.findByBusinessLicenseAndAccountType(iotCompany.getBusinessLicense(), iotCompany.getAccountType());
                if (businessLicense!=null){
                    return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                }
                IotCompanyDO name = iotCompanyDao.findByNameAndAccountType(iotCompany.getName(), iotCompany.getAccountType());
                if (name!=null){
                    return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                }
                List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAllByDel();
                for (IotCompanyAppDO one : appDOList) {
                    if (one.getName().equalsIgnoreCase(companyAppDO.getName())){
                        return MixEnvelop.getError("该应用已注册,请使用其他应用");
                    }
//                List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAllByDel();
//                for (IotCompanyAppDO one : appDOList) {
//                    if (one.getName().equalsIgnoreCase(companyAppDO.getName())){
//                        return MixEnvelop.getError("该应用已注册,请使用其他应用");
//                    }
//                }
                IotCompanyAppDO appDaoByName = iotCompanyAppDao.findByName(companyAppDO.getName());
                if (appDaoByName!=null){
                    return MixEnvelop.getError("该应用已注册,请使用其他应用");
                }
                //保存应用
                companyDO= iotCompanyDao.save(iotCompany);
                IotCompanyAppDO iotCompanyAppDO = new IotCompanyAppDO();
                iotCompanyAppDO.setSaasId(getCode());
                iotCompanyAppDO.setCompanyId(companyDO.getId());
                iotCompanyAppDO.setCompanyName(companyDO.getName());
                iotCompanyAppDO.setName(companyAppDO.getName());
                iotCompanyAppDO.setAddressIp(companyAppDO.getAddressIp());
                iotCompanyAppDO.setDel("0");
                iotCompanyAppDO.setDel("1");
                //新增应用 先设置应用无效  审核通过后更改为有效
                iotCompanyAppDO.setStatus("0");
                iotCompanyAppDao.save(iotCompanyAppDO);
            }
        }
@ -658,6 +668,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        appDO.setCompanyName(iotCompany.getName());
        appDO.setDel("1");
        appDO.setSaasId(getCode());
        appDO.setStatus("1");
        iotCompanyAppDao.save(appDO);
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
    }
@ -954,9 +965,9 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        //审核通过 设置平台应用为有效
        if (companyDO.getAccountType().equalsIgnoreCase("0")){
            List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyIdAndDel(id);
            List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyIdAndStatus(id);
            appDOList.forEach(one->{
                one.setDel("1");
                one.setStatus("1");
                iotCompanyAppDao.save(one);
            });
        }

+ 2 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceSimService.java

@ -131,7 +131,7 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(status)){
            sql.append(" and c.status=").append(status);
            sqlCount.append("and c.status='").append(status).append("' ");
            sqlCount.append(" and c.status='").append(status).append("' ");
            args.add(status);
        }
        if(StringUtils.isNotBlank(sim)){
@ -142,7 +142,7 @@ public class IotDeviceSimService  extends BaseJpaService<IotDeviceSimDO, IotDevi
            sql.append(" and (c.device_sn like '%").append(sn).append("%')");
            sqlCount.append(" and (c.device_sn like '%").append(sn).append("%')");
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        sql.append(" order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
//        List<IotDeviceSimDO> list = jdbcTemplate.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceSimDO.class));
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql.toString());