Quellcode durchsuchen

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan vor 5 Jahren
Ursprung
Commit
82954b9677

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -75,6 +75,7 @@ public class IotRequestMapping {
    public static class Company{
        public static final String findCompanyPage = "findCompanyPage";
        public static final String addCompany = "addCompany";
        public static final String rootAddCompany = "rootAddCompany";
        public static final String findCompanyById = "findCompanyById";
        public static final String findByBusinessLicense = "findByBusinessLicense";
        public static final String updCompany = "updCompany";

+ 1 - 1
svr/svr-base/src/main/resources/application.yml

@ -330,5 +330,5 @@ wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  sign: 1
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream

+ 26 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java

@ -19,6 +19,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -231,7 +232,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    public MixEnvelop<IotCompanyVO, IotCompanyVO> updCompany(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                  @RequestParam(value = "jsonData", required = true)String jsonData,
                                                             @ApiParam(name = "accountType", value = "注册类型", defaultValue = "")
                                                             @RequestParam(value = "accountType", required = true)String accountType) {
                                                             @RequestParam(value = "accountType", required = false)String accountType) {
        try {
            IotCompanyVO iotCompanyVO = toEntity(jsonData, IotCompanyVO.class);
            IotCompanyDO iotCompany = iotCompanyService.convertToModelDO(iotCompanyVO);
@ -357,4 +358,28 @@ public class IotCompanyController extends EnvelopRestEndpoint {
           return iotCompanyService.findCompanyApp();
    }
    @PostMapping(value = IotRequestMapping.Company.rootAddCompany)
    @ApiOperation(value = "管理员新增厂商", notes = "管理员新增厂商")
    public MixEnvelop rootAddCompany( @ApiParam(name = "jsonData", value = "jsonData", defaultValue = "")
                                  @RequestParam(value = "jsonData") String jsonData){
        try {
            IotCompanyVO iotCompanyVO = toEntity(jsonData, IotCompanyVO.class);
            IotCompanyDO iotCompany = iotCompanyService.convertToModelDO(iotCompanyVO);
            return iotCompanyService.addCompany(iotCompany);
        } catch (IOException e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 19 - 19
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceQualityController.java

@ -140,7 +140,7 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
                                                                   @ApiParam(name = "summary", value = "质检总结")
                                            @RequestParam(value = "summary", required = true) String summary,
                                                                   @ApiParam(name = "imgs", value = "质检图像")
                                            @RequestParam(value = "imgs",required = false,defaultValue = "") List<String> imgs ) {
                                            @RequestParam(value = "imgs",required = false,defaultValue = "") String imgs ) {
        try {
            iotDeviceQualityInspectionPlanService.completePlan(id,actualTime,summary,imgs);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
@ -150,24 +150,24 @@ public class IotDeviceQualityController extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = IotRequestMapping.DeviceQuality.completePlanByPurchaseId)
    @ApiOperation(value = "完成质检计划(按采购id)", notes = "完成质检计划(按采购id)")
    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> completePlanByPurchaseId(@ApiParam(name = "actualTime", value = "完成时间", defaultValue = "")
                                                                @RequestParam(value = "actualTime", required = true) String actualTime,
                                                                                 @ApiParam(name = "purchaseId", value = "purchaseId")
                                                                @RequestParam(value = "purchaseId", required = true) String purchaseId,
                                                                                 @ApiParam(name = "summary", value = "质检总结")
                                                                @RequestParam(value = "summary", required = true) String summary,
                                                                                 @ApiParam(name = "imgs", value = "质检图像")
                                                                @RequestBody List<String> imgs ) {
        try{
            iotDeviceQualityInspectionPlanService.completePlanByPurchaseId(purchaseId,actualTime,summary,imgs);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
//    @PostMapping(value = IotRequestMapping.DeviceQuality.completePlanByPurchaseId)
//    @ApiOperation(value = "完成质检计划(按采购id)", notes = "完成质检计划(按采购id)")
//    public MixEnvelop<IotDeviceQualityInspectionPlanVO, IotDeviceQualityInspectionPlanVO> completePlanByPurchaseId(@ApiParam(name = "actualTime", value = "完成时间", defaultValue = "")
//                                                                @RequestParam(value = "actualTime", required = true) String actualTime,
//                                                                                 @ApiParam(name = "purchaseId", value = "purchaseId")
//                                                                @RequestParam(value = "purchaseId", required = true) String purchaseId,
//                                                                                 @ApiParam(name = "summary", value = "质检总结")
//                                                                @RequestParam(value = "summary", required = true) String summary,
//                                                                                 @ApiParam(name = "imgs", value = "质检图像")
//                                                                @RequestBody List<String> imgs ) {
//        try{
//            iotDeviceQualityInspectionPlanService.completePlanByPurchaseId(purchaseId,actualTime,summary,imgs);
//            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return MixEnvelop.getError(e.getMessage());
//        }
//    }

+ 4 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/dict/IotDeviceDictController.java

@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * @author yeshijie on 2017/12/8.
@ -39,7 +41,8 @@ public class IotDeviceDictController extends EnvelopRestEndpoint {
        List<IotDeviceDictDO> list = iotDeviceDictService.search(fields,filters,sorts);
        //封装返回格式
        List<IotDeviceDictDO> iotDeviceDicts = convertToModels(list, new ArrayList<>(list.size()), IotDeviceDictDO.class, fields);
        return MixEnvelop.getSuccessList(IotRequestMapping.DeviceDict.message_success_find_functions,iotDeviceDicts);
        Map<String,List<IotDeviceDictDO>> map = iotDeviceDicts.stream().collect(Collectors.groupingBy(IotDeviceDictDO :: getDeviceType));
        return MixEnvelop.getSuccess(IotRequestMapping.DeviceDict.message_success_find_functions,map);
    }
    @PostMapping(value = IotRequestMapping.DeviceDict.api_create)

+ 10 - 17
svr/svr-iot/src/main/java/com/yihu/iot/controller/platform/IotInterfaceController.java

@ -162,9 +162,11 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Platform.findAllLog)
    @ApiOperation(value = "分页查询所有接口日志信息",notes = "分页查询所有接口日志信息")
    public MixEnvelop<IotInterfaceLogVO,IotInterfaceLogVO> findAllLog(@ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                                       @RequestParam(value = "page", required = false) Integer page,
                                                                        @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                       @RequestParam(value = "size", required = false) Integer size){
                                                                            @RequestParam(value = "page", required = false) Integer page,
                                                                      @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                            @RequestParam(value = "size", required = false) Integer size,
                                                                      @ApiParam(name = "interfaceName", value = "接口名或方法名称", defaultValue = "")
                                                                          @RequestParam(value = "interfaceName", required = false) String interfaceName){
        try {
            if(page == null|| page < 0){
@ -173,7 +175,7 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
            if(size == null){
                size = 10;
            }
            return iotInterfaceLogService.findAll(page,size);
            return iotInterfaceLogService.findAll(page,size,interfaceName);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -309,7 +311,9 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
                                                                             @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                                                 @RequestParam(value = "size", required = false) Integer size,
                                                                             @ApiParam(name = "interfaceName", value = "接口名称", defaultValue = "")
                                                                                 @RequestParam(value = "interfaceName") String interfaceName) {
                                                                                 @RequestParam(value = "interfaceName") String interfaceName,
                                                                             @ApiParam(name = "addressIp", value = "IP地址", defaultValue = "")
                                                                                 @RequestParam(value = "addressIp",required = false) String addressIp) {
        try {
            if(page == null|| page < 0){
@ -319,7 +323,7 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
                size = 10;
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Platform.message_success_find, iotInterfaceLogService.findInterfaceLog(page,size,interfaceName));
            return MixEnvelop.getSuccess(IotRequestMapping.Platform.message_success_find, iotInterfaceLogService.findInterfaceLog(page,size,interfaceName,addressIp));
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -354,16 +358,6 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
//    @GetMapping(value = IotRequestMapping.Platform.interfaceDoc)
//    @ApiOperation(value = "接口文档说明", notes = "接口文档说明")
//    public MixEnvelop interfaceDoc( @ApiParam(name = "dictName", value = "字典名称", defaultValue = "")
//                                        @RequestParam(value = "dictName") String dictName){
//
//       String url =  iotShareInterfaceService.interfaceDoc(dictName);
//       return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,url);
//
//    }
    @PostMapping(value = IotRequestMapping.Platform.addApp)
    @ApiOperation(value = "新增平台应用", notes = "新增平台应用")
@ -382,5 +376,4 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
    }
}

+ 3 - 4
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -135,8 +135,8 @@ public class IotProductController extends EnvelopRestEndpoint {
                                            @RequestParam(value = "jsonData", required = false)String jsonData) {
        try {
            IotProductVO iotProductVO = toEntity(jsonData, IotProductVO.class);
            iotProductBaseInfoService.addProduct(iotProductVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
           return iotProductBaseInfoService.addProduct(iotProductVO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -194,8 +194,7 @@ public class IotProductController extends EnvelopRestEndpoint {
                                            @RequestParam(value = "jsonData", required = false)String jsonData) {
        try {
            IotProductVO iotProductVO = toEntity(jsonData, IotProductVO.class);
            iotProductBaseInfoService.updProduct(iotProductVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update);
            return iotProductBaseInfoService.updProduct(iotProductVO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 5 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyAppDao.java

@ -22,5 +22,10 @@ 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.del=0")
        List<IotCompanyAppDO> findAllByDel();
        }

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/product/IotProductBaseInfoDao.java

@ -19,4 +19,7 @@ public interface IotProductBaseInfoDao extends PagingAndSortingRepository<IotPro
    @Query("from IotProductBaseInfoDO w where w.del = 1")
    List<IotProductBaseInfoDO> findAllByDel();
    @Query("from IotProductBaseInfoDO w where w.name =?1 and w.del = 1")
    IotProductBaseInfoDO findByName(String name);
}

+ 379 - 91
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -279,6 +279,165 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    /**
     * 新增
     * @param iotCompany
     * @return
     */
//    public MixEnvelop<IotCompanyVO, IotCompanyVO> creat(IotCompanyDO iotCompany) {
//
//        //判断账户是否重复
//        IotCompanyDO account = iotCompanyDao.findByEhrUserId(userAgent.getUID());
//        if (account!=null&&(account.getStatus().equalsIgnoreCase("2")==false)){
//            return MixEnvelop.getSuccess("账户已注册",-1);
//        }
//
//
//        List<IotCompanyTypeDO> list = iotCompany.getTypeList();
//        if("1".equalsIgnoreCase(iotCompany.getAccountType())){
//            //产商注册
//            //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())){
//                    //该公司重新申请注册,则删除原先注册信息
//                    if(iotCompanyDO.getStatus().equalsIgnoreCase("2")){
////                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(iotCompanyDO.getId());
////                        iotCompanyAppDao.delete(apps);
////                        iotCompanyDao.delete(iotCompanyDO);
//                        //更新类型
//                        List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
//
//                        iotCompanyTypeDao.delete(typeList);
//
//                        List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
//
//                        String id = iotCompany.getId();
//
//                        iotCompany.getTypeList().forEach(one->{
//                            IotCompanyTypeDO companyType = new IotCompanyTypeDO();
//                            companyType.setSaasId(getCode());
//                            companyType.setCompanyId(id);
//                            companyType.setType(one.getType());
//                            companyType.setTypeName(one.getTypeName());
//                            companyType.setDel("0");
//                            companyTypes.add(companyType);
//                        });
//                        iotCompanyTypeDao.save(companyTypes);
//
//                        iotCompany.setStatus("0");//待审核
//                        iotCompany.setSaasId(getCode());
//                        iotCompany.setDel(1);
//                        iotCompany = iotCompanyDao.save(iotCompany);
//
//                    }else {
//                        return MixEnvelop.getError("该企业已经注册,请使用注册账号登录");
//                    }
//                }
//            }
//            //保存产商信息
//            iotCompany.setStatus("0");//待审核
//            iotCompany.setSaasId(getCode());
//            iotCompany.setDel(1);
//            iotCompany = iotCompanyDao.save(iotCompany);
//            String id = iotCompany.getId();
//            //新增类型
//            List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
//            list.forEach(one->{
//                IotCompanyTypeDO companyType = new IotCompanyTypeDO();
//                companyType.setSaasId(getCode());
//                companyType.setCompanyId(id);
//                companyType.setType(one.getType());
//                companyType.setTypeName(one.getTypeName());
//                companyType.setDel("0");
//                companyTypes.add(companyType);
//            });
//            iotCompanyTypeDao.save(companyTypes);
//        }
//
//
//        //应用的营业执照号 可以相同
//        if("0".equalsIgnoreCase(iotCompany.getAccountType())){
//
//            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("该营业执照号已经注册,请使用其他执照");
//                }
//            }
//
//            //判断应用是否已经注册
//            IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
//            //查找所有应用名称
//            Iterable<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAll();
//            for (IotCompanyAppDO app : appDOList) {
//                if(app.getName().equalsIgnoreCase(companyAppDO.getName())&&
//                        app.getCompanyId().equalsIgnoreCase(iotCompany.getId())){
//                    String companyId = app.getCompanyId();
//                    IotCompanyDO companyDO = iotCompanyDao.findOne(companyId);
//                    //该平台重新申请注册
//                    if(iotCompany.getId().equalsIgnoreCase(companyDO.getId())&&companyDO.getStatus().equalsIgnoreCase("2")){
//                        //查找该企业下的app
//                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(companyDO.getId());
//                        //遍历apps找出与注册相同的app
//                        for (IotCompanyAppDO appDO : apps) {
//                            if (appDO.getId().equalsIgnoreCase(companyAppDO.getId())){
//                                appDO.setDel("0");
//                                appDO.setCompanyName(iotCompany.getName());
//                                appDO.setName(companyAppDO.getName());
//                                appDO.setAddressIp(companyAppDO.getAddressIp());
//                                iotCompanyAppDao.save(appDO);
//                            }
//                            iotCompany.setStatus("0");//待审核
//                            iotCompany.setSaasId(getCode());
//                            iotCompany.setDel(1);
//
//                            iotCompany.setAccount(userAgent.getUNAME());
//                            iotCompany.setEhrUserId(userAgent.getUID());
//                            iotCompany = iotCompanyDao.save(iotCompany);
//
//                            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,convertToModelVO(iotCompany));
//                        }
//                    }else {
//                        return MixEnvelop.getError("该应用已经注册,请使用注册账号登录");
//                    }
////                    return MixEnvelop.getError("该应用已经注册,请使用注册账号登录");
//                }
//            }
//            //平台接入
//            iotCompany.setStatus("0");//待审核
//            iotCompany.setSaasId(getCode());
//            iotCompany.setDel(1);
//
//            iotCompany = iotCompanyDao.save(iotCompany);
//            //保存应用
//            String id = iotCompany.getId();
//            IotCompanyAppDO iotCompanyAppDO = new IotCompanyAppDO();
//            iotCompanyAppDO.setSaasId(getCode());
//            iotCompanyAppDO.setCompanyId(id);
//            iotCompanyAppDO.setCompanyName(iotCompany.getName());
//            iotCompanyAppDO.setName(companyAppDO.getName());
//            iotCompanyAppDO.setAddressIp(companyAppDO.getAddressIp());
//            iotCompanyAppDO.setDel("0");
//            iotCompanyAppDao.save(iotCompanyAppDO);
//        }
//
//        iotCompany.setAccount(userAgent.getUNAME());
//        iotCompany.setEhrUserId(userAgent.getUID());
//
//
//        return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,convertToModelVO(iotCompany));
//    }
    /**
     * 新增
     * @param iotCompany
@ -286,117 +445,193 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     */
    public MixEnvelop<IotCompanyVO, IotCompanyVO> create(IotCompanyDO iotCompany) {
        //判断账户是否重复
        IotCompanyDO account = iotCompanyDao.findByEhrUserId(userAgent.getUID());
        if (account!=null){
            return MixEnvelop.getSuccess("账户已注册",-1);
        if (account != null && (!account.getStatus().equalsIgnoreCase("2"))) {
            return MixEnvelop.getSuccess("账户已注册", -1);
        }
        //id不为空,则重新注册
        if (StringUtils.isNotBlank(iotCompany.getId())) {
            //判断是产商还是平台入驻
            //厂商
            if (iotCompany.getAccountType().equalsIgnoreCase("1")) {
                //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<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
                iotCompanyTypeDao.delete(typeList);
                List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
                String id = iotCompany.getId();
                iotCompany.getTypeList().forEach(one -> {
                    IotCompanyTypeDO companyType = new IotCompanyTypeDO();
                    companyType.setSaasId(getCode());
                    companyType.setCompanyId(id);
                    companyType.setType(one.getType());
                    companyType.setTypeName(one.getTypeName());
                    companyType.setDel("0");
                    companyTypes.add(companyType);
                });
                iotCompanyTypeDao.save(companyTypes);
            }
            //平台
            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("该企业名称已被注册,请使用其他企业");
                    }
        List<IotCompanyTypeDO> list = iotCompany.getTypeList();
        if("1".equalsIgnoreCase(iotCompany.getAccountType())){
            //产商注册
            //1、判断企业名称是否已经注册
            List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
            for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                //判断营业执照号是否被注册
                if(iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense())&&iotCompanyDO.getStatus().equalsIgnoreCase("1")){
                    return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
                }
                if(iotCompany.getName().equalsIgnoreCase(iotCompanyDO.getName())){
                    //该公司重新申请注册,则删除原先注册信息
                    if(iotCompanyDO.getStatus().equalsIgnoreCase("2")){
                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(iotCompanyDO.getId());
                        iotCompanyAppDao.delete(apps);
                        iotCompanyDao.delete(iotCompanyDO);
                    }else {
                        return MixEnvelop.getError("该企业已经注册,请使用注册账号登录");
                List<IotCompanyAppDO> apps = iotCompanyAppDao.findAllByDel();
                //遍历apps找出与注册相同的app
                for (IotCompanyAppDO appDO : apps) {
                    if(companyAppDO.getName().equalsIgnoreCase(appDO.getName())&&(!appDO.getId().equalsIgnoreCase(companyAppDO.getId()))){
                        return MixEnvelop.getError("该企业名称已被注册,请使用其他企业");
                    }
                    if (appDO.getId().equalsIgnoreCase(companyAppDO.getId())) {
                        appDO.setDel("0");
                        appDO.setCompanyName(iotCompany.getName());
                        appDO.setCompanyId(iotCompany.getId());
                        appDO.setName(companyAppDO.getName());
                        appDO.setAddressIp(companyAppDO.getAddressIp());
                        iotCompanyAppDao.save(appDO);
                    }
                }
            }
            //保存产商信息
            iotCompany.setStatus("0");//待审核
            iotCompany.setSaasId(getCode());
            iotCompany.setDel(1);
            iotCompany = iotCompanyDao.save(iotCompany);
            String id = iotCompany.getId();
            //新增类型
            List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
            list.forEach(one->{
                IotCompanyTypeDO companyType = new IotCompanyTypeDO();
                companyType.setSaasId(getCode());
                companyType.setCompanyId(id);
                companyType.setType(one.getType());
                companyType.setTypeName(one.getTypeName());
                companyType.setDel("0");
                companyTypes.add(companyType);
            });
            iotCompanyTypeDao.save(companyTypes);
        }
        //应用的营业执照号 可以相同
        if("0".equalsIgnoreCase(iotCompany.getAccountType())){
            List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
            for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                //判断营业执照号是否被注册
                if (iotCompany.getBusinessLicense().equalsIgnoreCase(iotCompanyDO.getBusinessLicense()) && iotCompanyDO.getStatus().equalsIgnoreCase("1")) {
                    return MixEnvelop.getError("该营业执照号已经注册,请使用其他执照");
        IotCompanyDO companyDO = null;
        //id为空,新增企业
        if (StringUtils.isEmpty(iotCompany.getId())) {
            companyDO= iotCompanyDao.save(iotCompany);
            //厂商
            if (companyDO.getAccountType().equalsIgnoreCase("1")) {
                //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("该企业名称已被注册,请使用其他企业");
                    }
                }
                List<IotCompanyTypeDO> list = companyDO.getTypeList();
                String id = companyDO.getId();
                //新增类型
                List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
                list.forEach(one->{
                    IotCompanyTypeDO companyType = new IotCompanyTypeDO();
                    companyType.setSaasId(getCode());
                    companyType.setCompanyId(id);
                    companyType.setType(one.getType());
                    companyType.setTypeName(one.getTypeName());
                    companyType.setDel("0");
                    companyTypes.add(companyType);
                });
                iotCompanyTypeDao.save(companyTypes);
            }
            //判断应用是否已经注册
            IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
            //查找所有应用名称
            Iterable<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAll();
            for (IotCompanyAppDO app : appDOList) {
                if(app.getName().equalsIgnoreCase(companyAppDO.getName())){
                    String companyId = app.getCompanyId();
                    IotCompanyDO companyDO = iotCompanyDao.findOne(companyId);
                    //该平台重新申请注册
                    if(iotCompany.getName().equalsIgnoreCase(companyDO.getName())&&companyDO.getStatus().equalsIgnoreCase("2")){
                        //查找该企业下的app
                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(companyDO.getId());
                        //保存注册信息获取CompangId
                       iotCompany.setId(getCode());
                        //遍历apps找出与注册相同的app
                        for (IotCompanyAppDO appDO : apps) {
                            if (appDO.getName().equalsIgnoreCase(companyAppDO.getName())){
                                appDO.setDel("0");
                                iotCompanyAppDao.save(appDO);
                            }
                            //更改公司ID
                            appDO.setCompanyId(iotCompany.getId());
                        }
            //平台
            if (companyDO.getAccountType().equalsIgnoreCase("0")) {
                List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(companyDO.getAccountType());
                IotCompanyAppDO companyAppDO = companyDO.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("该企业名称已被注册,请使用其他企业");
                    }
                }
                List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAllByDel();
                for (IotCompanyAppDO one : appDOList) {
                    if (one.getName().equalsIgnoreCase(companyAppDO.getName())){
                        return MixEnvelop.getError("该应用已注册,请使用其他应用");
                    }
                    return MixEnvelop.getError("该应用已经注册,请使用注册账号登录");
                }
                //保存应用
                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");
                iotCompanyAppDao.save(iotCompanyAppDO);
            }
            //平台接入
            iotCompany.setStatus("0");//待审核
            iotCompany.setSaasId(getCode());
            iotCompany.setDel(1);
            iotCompany = iotCompanyDao.save(iotCompany);
            //保存应用
            String id = iotCompany.getId();
            IotCompanyAppDO iotCompanyAppDO = new IotCompanyAppDO();
            iotCompanyAppDO.setSaasId(getCode());
            iotCompanyAppDO.setCompanyId(id);
            iotCompanyAppDO.setCompanyName(iotCompany.getName());
            iotCompanyAppDO.setName(companyAppDO.getName());
            iotCompanyAppDO.setAddressIp(companyAppDO.getAddressIp());
            iotCompanyAppDO.setDel("1");
            iotCompanyAppDao.save(iotCompanyAppDO);
        }
        iotCompany.setAccount(userAgent.getUNAME());
        iotCompany.setEhrUserId(userAgent.getUID());
        return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create,convertToModelVO(iotCompany));
        }
        companyDO= iotCompanyDao.save(iotCompany);
        companyDO.setStatus("0");//待审核
        companyDO.setSaasId(getCode());
        companyDO.setDel(1);
        //保存账户与UID
        companyDO.setAccount(userAgent.getUNAME());
        companyDO.setEhrUserId(userAgent.getUID());
        iotCompanyDao.save(companyDO);
        return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create, convertToModelVO(iotCompany));
    }
    /**
     * 新增平台应用
     * @param iotCompany
@ -561,7 +796,11 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @param iotCompany
     */
    public void updCompany(IotCompanyDO iotCompany,String accountType){
        
        if (accountType==null){
            accountType=iotCompany.getAccountType();
        }
        if(accountType.equalsIgnoreCase("1")){
            //更新类型
            List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
@ -713,6 +952,16 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        companyDO.setAuditName(uname);
        iotCompanyDao.save(companyDO);
        //审核通过 设置平台应用为有效
        if (companyDO.getAccountType().equalsIgnoreCase("0")){
            List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyIdAndDel(id);
            appDOList.forEach(one->{
                one.setDel("1");
                iotCompanyAppDao.save(one);
            });
        }
        //根据注册类型配置相应角色菜单,注册类型(1:厂商注册  0:平台注册)
        String roleId = "";
        if(companyDO.getAccountType().equals("0")){
@ -821,4 +1070,43 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,appDOS);
    }
    /**
     * 新增厂商
     * @param iotCompany
     * @return
     */
    public MixEnvelop addCompany(IotCompanyDO iotCompany) {
        IotCompanyDO platform = iotCompanyDao.findByNameAndAccountType(iotCompany.getName(), "1");
        if (platform!=null){
            return MixEnvelop.getError("企业已经注册");
        }
        iotCompany.setStatus("1");//默认审核通过
        iotCompany.setSaasId(getCode());
        iotCompany.setDel(1);
        iotCompany.setAccount(iotCompany.getContactsMobile());
        iotCompany.setEhrUserId(getCode());
        iotCompany.setAccountType("1");
        iotCompanyDao.save(iotCompany);
        //保存企业类型
        List<IotCompanyTypeDO> companyTypes = new ArrayList<>(10);
        iotCompany.getTypeList().forEach(one->{
            IotCompanyTypeDO companyType = new IotCompanyTypeDO();
            companyType.setSaasId(getCode());
            companyType.setCompanyId(iotCompany.getId());
            companyType.setType(one.getType());
            companyType.setTypeName(one.getTypeName());
            companyType.setDel("0");
            companyTypes.add(companyType);
        });
        iotCompanyTypeDao.save(companyTypes);
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
    }
}

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

@ -110,7 +110,7 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
                String deviceSn = deviceDO.getDeviceSn();
                Integer type = deviceInventoryLogDO.getType();//调拨类型(1入库 2设备调拨出库 3核销出库)
                if (type.equals("1")) {
                if (type == 1) {
                    deviceDO.setSaasId(getCode());
                    deviceDO.setProductId(jsonObject.getString("productId"));
                    deviceDO.setName(jsonObject.getString("name"));
@ -120,7 +120,7 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
                    deviceDO.setManufacturerName(jsonObject.getString("manufacturerName"));
                } else {//设备出库,更换相关信息
                    deviceDO = iotDeviceDao.findByDeviceSn(deviceSn);
                    if (type.equals("3")) {
                    if (type == 3) {
                        deviceDO.setDel(0);
                        deviceDO.setStatus("2");
                        deviceDO.setInventoryLogId(deviceInventoryLogDO.getId());

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

@ -122,7 +122,7 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
     * 完成质检计划
     * @param id 质检id
     */
    public void completePlan(String id,String time,String summary,List<String> imgs){
    public void completePlan(String id,String time,String summary,String imgs){
        IotDeviceQualityInspectionPlanDO planDO = iotDeviceQualityInspectionPlanDao.findById(id);
        if(planDO!=null){
            planDO.setStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
@ -130,7 +130,7 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
            planDO.setSummary(summary);
            //设置质检小结与质检图像
            planDO.setImg(imgs.toString());
            planDO.setImg(imgs);
            iotDeviceQualityInspectionPlanDao.save(planDO);

+ 13 - 9
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotInterfaceLogService.java

@ -65,11 +65,13 @@ public class IotInterfaceLogService extends BaseJpaService<IotInterfaceLogDO, Io
     * @return
     * @throws ParseException
     */
    public MixEnvelop<IotInterfaceLogVO,IotInterfaceLogVO> findAll(Integer page, Integer size) throws ParseException {
    public MixEnvelop<IotInterfaceLogVO,IotInterfaceLogVO> findAll(Integer page, Integer size,String name) throws ParseException {
        StringBuffer sql = new StringBuffer("SELECT * FROM (select * from iot_interface_log c where 1=1  ORDER BY c.time desc) b GROUP BY b.interface_name ");
        sql.append(" limit ").append((page-1)*size).append(",").append(size);
        StringBuffer sql = new StringBuffer("SELECT * FROM (select * from iot_interface_log c where 1=1  ORDER BY c.time desc) b   ");
        if (StringUtils.isNotBlank(name)){
            sql.append(" where b.method LIKE '%").append(name).append("%'OR b.interface_name LIKE '%").append(name).append("%'");
        }
        sql.append(" GROUP BY b.interface_name limit ").append((page-1)*size).append(",").append(size);
        List<IotInterfaceLogDO> list = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(IotInterfaceLogDO.class));
@ -94,16 +96,18 @@ public class IotInterfaceLogService extends BaseJpaService<IotInterfaceLogDO, Io
     * @param interfaceName
     * @return
     */
    public MixEnvelop<IotInterfaceLogVO, IotInterfaceLogVO> findInterfaceLog(Integer page, Integer size, String interfaceName) {
    public MixEnvelop<IotInterfaceLogVO, IotInterfaceLogVO> findInterfaceLog(Integer page, Integer size, String interfaceName,String addressIP) {
        StringBuffer sql =new StringBuffer("SELECT c.* FROM iot_interface_log c WHERE ");
        StringBuffer sql =new StringBuffer("SELECT c.* FROM iot_interface_log c WHERE 1=1 ");
        if (StringUtils.isNotBlank(interfaceName)){
            sql.append(" c.interface_name like'%").append(interfaceName).append("%'");
            sql.append(" and c.interface_name like'%").append(interfaceName).append("%'");
        }
        if (StringUtils.isNotBlank(addressIP)){
            sql.append(" and c.address_ip='").append(addressIP).append("'");
        }
        sql.append("order by c.time desc limit ").append((page-1)*size).append(",").append(size);
//        List<IotInterfaceLogDO> list = iotInterfaceLogDao.findAllByInterfaceName(interfaceName);
        sql.append(" order by c.time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotInterfaceLogDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(IotInterfaceLogDO.class));

+ 16 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/product/IotProductBaseInfoService.java

@ -130,7 +130,7 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
     * 修改产品
     * @param iotProductVO
     */
    public void updProduct(IotProductVO iotProductVO){
    public MixEnvelop<IotProductVO, IotProductVO> updProduct(IotProductVO iotProductVO){
        IotProductBaseInfoVO baseInfoVO = iotProductVO.getIotProductBaseInfo();
        IotProductExtendInfoVO extendInfoVO = iotProductVO.getIotProductExtendInfo();
        List<IotProductAttachmentVO> attachmentVOList = extendInfoVO.getAttachmentVOList();
@ -139,6 +139,12 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
        //数据转换
        IotProductBaseInfoDO baseInfoDO = convertToModel(baseInfoVO,IotProductBaseInfoDO.class);
        IotProductBaseInfoDO productBaseInfoDO = iotProductBaseInfoDao.findByName(baseInfoDO.getName());
        if (productBaseInfoDO!=null&&(baseInfoDO.getId().equalsIgnoreCase(productBaseInfoDO.getId())==false)){
            return MixEnvelop.getError("产品已存在");
        }
        //日期单独处理
        baseInfoDO.setStartTime(DateUtil.strToDate(baseInfoVO.getStartTime()));
        baseInfoDO.setEndTime(DateUtil.strToDate(baseInfoVO.getEndTime()));
@ -228,14 +234,20 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
            one.setProductId(productId);
        });
        iotProductDataTransmissionDao.save(dataTransmissionDOList);
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update);
    }
    /**
     * 新增产品
     * @param iotProductVO
     */
    public void addProduct(IotProductVO iotProductVO){
    public MixEnvelop<IotProductVO, IotProductVO> addProduct(IotProductVO iotProductVO){
        IotProductBaseInfoVO baseInfoVO = iotProductVO.getIotProductBaseInfo();
        IotProductBaseInfoDO productBaseInfoDO = iotProductBaseInfoDao.findByName(baseInfoVO.getName());
        if (productBaseInfoDO!=null){
            return MixEnvelop.getError("产品已存在");
        }
        IotProductExtendInfoVO extendInfoVO = iotProductVO.getIotProductExtendInfo();
        List<IotProductAttachmentVO> attachmentVOList = extendInfoVO.getAttachmentVOList();
        List<IotProductMeasuredDataVO> measuredDataVOList = iotProductVO.getMeasuredDataVOList();
@ -282,6 +294,8 @@ public class IotProductBaseInfoService extends BaseJpaService<IotProductBaseInfo
            one.setProductId(productId);
        });
        iotProductDataTransmissionDao.save(dataTransmissionDOList);
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
    }
    /**