Browse Source

物联网相关

yeshijie 7 years ago
parent
commit
02d856e292

+ 87 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/constant/ServiceApi.java

@ -0,0 +1,87 @@
package com.yihu.ehr.iot.constant;
/**
 * @author yeshijie on 2018/1/22.
 */
public class ServiceApi {
    public ServiceApi() {
    }
    public static class Company {
        public static final String Base = "wg/company/";
        public static final String FindCompanyPage = Base +"findCompanyPage";
        public static final String AddCompany = Base +"addCompany";
        public static final String FindCompanyById = Base +"findCompanyById";
        public static final String FindByBusinessLicense = Base +"findByBusinessLicense";
        public static final String UpdCompany = Base +"updCompany";
        public static final String DelCompany = Base +"delCompany";
        public static final String FindCompanyCertPage = Base +"findCompanyCertPage";
        public static final String FindCompanyCertById = Base +"findCompanyCertById";
        public static final String FindCompanyCertByCompanyId = Base +"findCompanyCertByCompanyId";
        public static final String AddCompanyCert = Base +"addCompanyCert";
        public Company() {
        }
    }
    public static class System{
        public static final String Base = "wg/systemDict/";
        public static final String FindDictByCode = Base +"findDictByCode";
    }
    public static class FileUpload{
        public static final String Base = "wg/fileUpload/";
        public static final String UploadStream = Base +"uploadStream";//文件流上传
        public static final String UploadImg = Base +"uploadImg";//文件流上传图片
        public static final String UploadattAchment = Base +"uploadattAchment";//文件流上传附件
        public static final String UploadString = Base +"uploadString";//base64字符串上传
    }
    public static class Product {
        public static final String Base = "wg/product/";
        public static final String FindProductPage = Base +"findProductPage";
        public static final String FindProductPageByCompanyId = Base +"findProductPageByCompanyId";
        public static final String AddProduct = Base +"addProduct";
        public static final String FindProductById = Base +"findProductById";
        public static final String UpdProduct= Base +"updProduct";
        public static final String DelProduct= Base + "delProduct";
        public Product() {
        }
    }
    public static class Device{
        public static final String Base = "wg/product/";
        public static final String CreateDevice = Base +"createDevice";
        public static final String GetDeviceById = Base +"getDeviceById";
        public static final String QueryDevicePage = Base +"queryDevicePage";
        public static final String GetDeviceList = Base +"getDeviceList";
        public static final String IsSnExist = Base +"isSnExist";
        public static final String IsSimExist = Base +"isSimExist";
        public static final String ImportDevice = Base +"importDevice";
        public static final String QueryImportRecordPage = Base +"queryImportRecordPage";
        public Device() {
        }
    }
    public static class DeviceOrder{
        public static final String Base = "wg/order/";
        public static final String FindPage = Base +"findPage";
        public static final String FindById = Base +"findById";
        public static final String DelOrder = Base +"delOrder";
        public static final String UpdOrder = Base +"updOrder";
        public static final String CreateOrder = Base +"createOrder";
        public static final String FindPurcharsePage = Base +"findPurcharsePage";
        public DeviceOrder() {
        }
    }
}

+ 180 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/controller/company/IotCompanyController.java

@ -0,0 +1,180 @@
package com.yihu.ehr.iot.controller.company;
import com.yihu.ehr.iot.controller.common.BaseController;
import com.yihu.ehr.iot.service.company.CompanyService;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author yeshijie on 2018/1/16.
 */
@RestController
@RequestMapping(IotRequestMapping.Common.company)
@Api(tags = "企业管理相关操作", description = "企业管理相关操作")
public class IotCompanyController extends BaseController {
    @Autowired
    private CompanyService companyService;
    @GetMapping(value = IotRequestMapping.Company.findCompanyPage)
    @ApiOperation(value = "分页查找企业", notes = "分页查找企业")
    public Envelop<IotCompanyVO> findCompanyPage(@ApiParam(name = "name", value = "供应商名称或联系人姓名", defaultValue = "")
                                                 @RequestParam(value = "name", required = false) String name,
                                                 @ApiParam(name = "status", value = "审核状态", defaultValue = "")
                                                 @RequestParam(value = "status", required = false) String status,
                                                 @ApiParam(name = "type", value = "企业类型", defaultValue = "")
                                                 @RequestParam(value = "type", required = false) String type,
                                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                                 @RequestParam(value = "page", required = false) Integer page,
                                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                                 @RequestParam(value = "size", required = false) Integer size){
        try {
            return companyService.findCompanyPage(name,status,type,page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
//    @PostMapping(value = IotRequestMapping.Company.addCompany)
//    @ApiOperation(value = "创建企业", notes = "创建企业")
//    public Envelop<IotCompanyVO> addCompany(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
//                                            @RequestParam(value = "jsonData", required = false)String jsonData) {
//        try {
//            IotCompanyDO iotCompany = toEntity(jsonData, IotCompanyDO.class);
//            return Envelop.getSuccess(IotRequestMapping.Company.message_success_create, iotCompanyService.create(iotCompany));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @GetMapping(value = IotRequestMapping.Company.findCompanyById)
//    @ApiOperation(value = "根据id查找企业", notes = "根据id查找企业")
//    public Envelop<IotCompanyVO> findByCode(@ApiParam(name = "id", value = "id")
//                                            @RequestParam(value = "id", required = true) String id) {
//        try {
//            IotCompanyDO iotCompanyDO = iotCompanyService.findById(id);
//            IotCompanyVO vo = iotCompanyService.convertToModelVO(iotCompanyDO);
//            return Envelop.getSuccess(IotRequestMapping.Company.message_success_find, vo);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @GetMapping(value = IotRequestMapping.Company.findByBusinessLicense)
//    @ApiOperation(value = "根据营业执照号查找企业", notes = "根据营业执照号查找企业")
//    public Envelop<IotCompanyVO> findByBusinessLicense(@ApiParam(name = "businessLicense", value = "businessLicense")
//                                                       @RequestParam(value = "businessLicense", required = true) String businessLicense) {
//        try {
//            IotCompanyDO iotCompanyDO = iotCompanyService.findByBusinessLicense(businessLicense);
//            IotCompanyVO vo = iotCompanyService.convertToModelVO(iotCompanyDO);
//            return Envelop.getSuccess(IotRequestMapping.Company.message_success_find, vo);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @PostMapping(value = IotRequestMapping.Company.delCompany)
//    @ApiOperation(value = "删除企业", notes = "删除企业")
//    public Envelop<IotCompanyVO> delCompany(@ApiParam(name = "id", value = "id")
//                                            @RequestParam(value = "id", required = true) String id) {
//        try {
//            iotCompanyService.delCompany(id);
//            return Envelop.getSuccess(IotRequestMapping.Company.message_success_find);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @PostMapping(value = IotRequestMapping.Company.updCompany)
//    @ApiOperation(value = "修改企业信息", notes = "修改企业信息")
//    public Envelop<IotCompanyVO> updCompany(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
//                                            @RequestParam(value = "jsonData", required = false)String jsonData) {
//        try {
//            IotCompanyDO iotCompany = toEntity(jsonData, IotCompanyDO.class);
//            iotCompanyService.updCompany(iotCompany);
//            return Envelop.getSuccess(IotRequestMapping.Company.message_success_find);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @PostMapping(value = IotRequestMapping.Company.findCompanyCertPage)
//    @ApiOperation(value = "分页获取企业证书", notes = "分页获取企业证书")
//    public Envelop<IotCompanyCertificateVO> findCompanyCertPage
//            (@ApiParam(name = "name", value = "证书名称", defaultValue = "")
//             @RequestParam(value = "name", required = false) String name,
//             @ApiParam(name = "page", value = "第几页", defaultValue = "")
//             @RequestParam(value = "page", required = false) Integer page,
//             @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
//             @RequestParam(value = "size", required = false) Integer size){
//        try {
//            if(page == null|| page < 0){
//                page = 1;
//            }
//            if(size == null){
//                size = 10;
//            }
//            return iotCompanyCertificateService.queryPage(page,size,name);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @GetMapping(value = IotRequestMapping.Company.findCompanyCertById)
//    @ApiOperation(value = "根据id查找企业证书", notes = "根据id查找企业证书")
//    public Envelop<IotCompanyCertificateVO> findCompanyCertById(@ApiParam(name = "id", value = "id")
//                                                                @RequestParam(value = "id", required = true) String id) {
//        try {
//            IotCompanyCertificateDO iotCompanyCertificateDO = iotCompanyCertificateService.findById(id);
//            IotCompanyCertificateVO vo = convertToModel(iotCompanyCertificateDO,IotCompanyCertificateVO.class);
//            return Envelop.getSuccess(IotRequestMapping.Common.message_success_find, vo);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @GetMapping(value = IotRequestMapping.Company.findCompanyCertByCompanyId)
//    @ApiOperation(value = "根据企业id查找企业证书", notes = "根据企业id查找企业证书")
//    public Envelop<IotCompanyCertificateVO> findCompanyCertByCompanyId(@ApiParam(name = "companyId", value = "companyId")
//                                                                       @RequestParam(value = "companyId", required = true) String companyId) {
//        try {
//            List<IotCompanyCertificateDO> iotCompanyCertificateDOList = iotCompanyCertificateService.findByCompanyId(companyId);
//            List<IotCompanyCertificateVO> voList = convertToModels(iotCompanyCertificateDOList,new ArrayList<>(iotCompanyCertificateDOList.size()),IotCompanyCertificateVO.class);
//            return Envelop.getSuccessList(IotRequestMapping.Common.message_success_find, voList);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
//    @PostMapping(value = IotRequestMapping.Company.addCompanyCert)
//    @ApiOperation(value = "创建企业证书", notes = "创建企业证书")
//    public Envelop<IotCompanyCertificateVO> addCompanyCert(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
//                                                           @RequestParam(value = "jsonData", required = false)String jsonData) {
//        try {
//            IotCompanyCertificateDO iotCompanyCertificate = toEntity(jsonData, IotCompanyCertificateDO.class);
//            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, iotCompanyCertificateService.create(iotCompanyCertificate));
//        } catch (Exception e) {
//            e.printStackTrace();
//            return Envelop.getError(e.getMessage());
//        }
//    }
}

+ 2 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/common/BaseService.java

@ -43,6 +43,8 @@ public class BaseService {
    protected String portalInnerUrl;
    @Value("${service-gateway.portalOuterUrl}")
    protected String portalOuterUrl;
    @Value("${service-gateway.iotUrl}")
    protected String iotUrl;
    @Value("${app.oauth2InnerUrl}")
    protected String oauth2InnerUrl;
    @Value("${app.oauth2OuterUrl}")

+ 42 - 0
app/app-iot-server/src/main/java/com/yihu/ehr/iot/service/company/CompanyService.java

@ -0,0 +1,42 @@
package com.yihu.ehr.iot.service.company;
import com.yihu.ehr.iot.service.common.BaseService;
import com.yihu.ehr.iot.util.http.HttpHelper;
import com.yihu.ehr.iot.util.http.HttpResponse;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
 * @author yeshijie on 2018/1/22.
 */
@Service
public class CompanyService extends BaseService {
    /**
     * 分页查找企业
     * @param name
     * @param status
     * @param type
     * @param page
     * @param size
     * @return
     * @throws IOException
     */
    public Envelop<IotCompanyVO> findCompanyPage(String name,String status,String type,Integer page,Integer size) throws IOException{
        Map<String, Object> params = new HashMap<>();
        params.put("name", name);
        params.put("status", status);
        params.put("type", type);
        params.put("page", page);
        params.put("size", size);
        HttpResponse response = HttpHelper.get(iotUrl + "/oauth/validToken", params);
        Envelop<IotCompanyVO> envelop = objectMapper.readValue(response.getBody(),Envelop.class);
        return envelop;
    }
}

+ 1 - 0
app/app-iot-server/src/main/resources/application.yml

@ -40,6 +40,7 @@ app:
  oauth2InnerUrl: http://172.19.103.44:10260/
  oauth2OuterUrl: http://27.154.233.186:10260/  #上饶-授权外网映射
service-gateway:
  iotUrl: http://192.168.131.24:8088/
  profileInnerUrl: http://172.19.103.48:10000/api/v1.0/admin
  profileOuterUrl: http://27.154.233.186:10000/api/v1.0/admin
  portalInnerUrl: http://172.19.103.48:10280/api/v1.0/portal