Browse Source

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

# Conflicts:
#	common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java
mengkang 5 years ago
parent
commit
e9786f6f26

+ 85 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/platform/IotShareInterfaceDO.java

@ -0,0 +1,85 @@
package com.yihu.jw.entity.iot.platform;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/28
 */
@Entity
@Table(name = "iot_share_interface")
public class IotShareInterfaceDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "method_name")
    private String methodName;//方法名
    @Column(name = "interface_name")
    private String interfaceName;//接口名称
    @Column(name = "type_name")
    private String typeName;//业务类型名称
    @Column(name = "explanation")
    private String explanation;//说明
    @Column(name = "del")
    private String del;//是否删除 1:删除  0:不删除
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
    public String getInterfaceName() {
        return interfaceName;
    }
    public void setInterfaceName(String interfaceName) {
        this.interfaceName = interfaceName;
    }
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    public String getExplanation() {
        return explanation;
    }
    public void setExplanation(String explanation) {
        this.explanation = explanation;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

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

@ -22,6 +22,7 @@ public class IotRequestMapping {
        public static final String patientDevice = api_iot_common + "/patientDevice";
        public static final String wlyy = api_iot_common + "/wlyy";
        public static final String figereLabel = api_iot_common + "/figereLabel";
        public static final String platform = api_iot_common + "/platform";
        public static final String message_success_update = "update success";
@ -64,6 +65,7 @@ public class IotRequestMapping {
     */
    public static class Company{
        public static final String findCompanyPage = "findCompanyPage";
        public static final String conditionQueryPage = "conditionQueryPage";
        public static final String addCompany = "addCompany";
        public static final String findCompanyById = "findCompanyById";
        public static final String findByBusinessLicense = "findByBusinessLicense";
@ -284,4 +286,20 @@ public class IotRequestMapping {
    }
    /**
     * 居民标签信息模块常量
     */
    public static class  Platform{
        public static final String addInterface ="addInterface";
        public static final String editInterface ="editInterface";
        public static final String findInterfaceById ="findInterfaceById";
        public static final String findAll ="findAll";
        public static final String conditionQueryPage ="conditionQueryPage";
        public static final String message_success_add = "add success";
        public static final String message_success_edit = "edit success";
        public static final String message_success_find = "find success";
    }
}

+ 34 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java

@ -69,6 +69,39 @@ public class IotCompanyController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = IotRequestMapping.Company.conditionQueryPage)
    @ApiOperation(value = "条件查找企业", notes = "条件查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> conditionQueryPage(@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 {
            if(page == null|| page < 0){
                page = 1;
            }
            if(size == null){
                size = 10;
            }
            if(StringUtils.isBlank(status)){
                return iotCompanyService.conditionQueryPage(page,size,null,name,type);
            }else {
                return iotCompanyService.conditionQueryPage(page,size,status,name,type);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.addCompany)
    @ApiOperation(value = "创建企业", notes = "创建企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> addCompany(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
@ -103,6 +136,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
                                                                    @ApiParam(name = "msg",value = "拒绝说明") @RequestParam(value = "msg",required = true,defaultValue = "")String msg){
        try {
            return  iotCompanyService.auditCompany(id, msg);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 126 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/platform/IotInterfaceController.java

@ -0,0 +1,126 @@
package com.yihu.iot.controller.platform;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.platform.IotShareInterfaceService;
import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/28
 */
@RestController
@RequestMapping(IotRequestMapping.Common.platform)
@Api(tags = "平台接口管理相关操作", description = "平台接口管理相关操作")
public class IotInterfaceController extends EnvelopRestEndpoint {
    @Autowired
    private IotShareInterfaceService iotShareInterfaceService;
    @PostMapping(value = IotRequestMapping.Platform.addInterface)
    @ApiOperation(value = "新增共享接口",notes = "新增共享接口")
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> addInterface(@ApiParam(name = "JSON",value = "接口JSON串") @RequestParam(value = "JSON",required = true)String json){
        try {
            iotShareInterfaceService.addInterface(json);
            return MixEnvelop.getSuccess(IotRequestMapping.Platform.message_success_add);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Platform.editInterface)
    @ApiOperation(value = "编辑共享接口",notes = "编辑共享接口")
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> editInterface(@ApiParam(name = "JSON",value = "接口JSON串") @RequestParam(value = "JSON",required = true)String json){
        try {
            iotShareInterfaceService.editInterface(json);
            return MixEnvelop.getSuccess(IotRequestMapping.Platform.message_success_edit);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Platform.findInterfaceById)
    @ApiOperation(value = "查找共享接口",notes = "查找共享接口")
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> findInterfaceById(@ApiParam(name = "id",value = "id") @RequestParam(value = "id",required = true)String id){
        try {
           IotShareInterfaceDO iotShareInterfaceDO = iotShareInterfaceService.findInterfaceById(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Platform.message_success_find,iotShareInterfaceDO);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Platform.findAll)
    @ApiOperation(value = "分页查询所有",notes = "分页查询所有")
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> findAll(@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 iotShareInterfaceService.findAll(page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Platform.conditionQueryPage)
    @ApiOperation(value = "条件查询分页",notes = "条件查询分页")
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> conditionQueryPage(@ApiParam(name = "type", value = "业务类型", defaultValue = "")
                                                                       @RequestParam(value = "type", required = false) String type,
                                                                            @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 iotShareInterfaceService.conditionQueryPage(page,size,type,name);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 14 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/IotShareInterfaceDao.java

@ -0,0 +1,14 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/28
 */
public interface IotShareInterfaceDao extends PagingAndSortingRepository<IotShareInterfaceDO,String>, JpaSpecificationExecutor<IotShareInterfaceDO> {
}

+ 32 - 12
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -217,7 +217,18 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
    }
/*    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String name, String type){
    /**
     * 条件分页查找
     * @param page
     * @param size
     * @param status
     * @param name
     * @param type
     * @return
     */
    public MixEnvelop<IotCompanyVO, IotCompanyVO> conditionQueryPage(Integer page, Integer size, String status, String name, String type){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_company c ,iot_company_type t WHERE c.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_company c ,iot_company_type t WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
@ -227,22 +238,28 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            args.add(status);
        }
        if(StringUtils.isNotBlank(name)){
            sql.append(" and (c.name like ? or c.contacts_name like ?)");
            sqlCount.append(" and (c.name like '").append(name).append("' or c.contacts_name like '").append(name).append("')");
            args.add(name);
            args.add(name);
            sql.append(" and (c.name like '%").append(name).append("%' or c.contacts_name like '%").append(name).append("%')");
            sqlCount.append(" and (c.name like '%").append(name).append("%' or c.contacts_name like '%").append(name).append("%')");
        }
        if(StringUtils.isNotBlank(type)){
            sql.append(" and c.id = t.company_id and t.type=? ");
            sqlCount.append(" and c.id = t.company_id and t.type='").append(type).append("' ");
            sql.append(" and c.id = t.company_id and t.type_name=? ");
            sqlCount.append(" and c.id = t.company_id and t.type_name='").append(type).append("' ");
            args.add(type);
        }
        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));
        list.forEach(one->{
            findType(one);
        });
        if(StringUtils.isBlank(type)){
            //得到list数据
            list.forEach(one->{
                findAppType(one);
            });
        }else {
            list.forEach(one->{
                findType(one);
            });
        }
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
@ -250,7 +267,9 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        List<IotCompanyVO> iotCompanyVOList = convertToModelVOs(list,new ArrayList<>(list.size()));
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
    }*/
    }
    /**
     * 新增
@ -297,6 +316,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            });
            iotCompanyTypeDao.save(companyTypes);
        }
        //应用的营业执照号 可以相同
        if("0".equalsIgnoreCase(iotCompany.getAccountType())){
            List<IotCompanyDO> iotCompanyDOS = iotCompanyDao.findByAccountType(iotCompany.getAccountType());
@ -573,7 +593,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    public MixEnvelop auditCompany(String id) {
        IotCompanyDO companyDO = findById(id);
        if (companyDO==null){
            return MixEnvelop.getError("无该企业");
        }
        String uname = userAgent.getUNAME();
        if (uname==null){

+ 128 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/platform/IotShareInterfaceService.java

@ -0,0 +1,128 @@
package com.yihu.iot.service.platform;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.platform.IotShareInterfaceDao;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/28
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class IotShareInterfaceService extends BaseJpaService<IotShareInterfaceDO, IotShareInterfaceDao> {
    @Autowired
    private IotShareInterfaceDao iotShareInterfaceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 增加接口
     * @param jsonData
     * @return
     */
    public void addInterface(String jsonData){
        IotShareInterfaceDO iotShareInterfaceDO = JSONObject.parseObject(jsonData, IotShareInterfaceDO.class);
        iotShareInterfaceDO.setDel("0");
        iotShareInterfaceDao.save(iotShareInterfaceDO);
    }
    /**
     * 编辑接口
     * @param json
     * @return
     */
    public void editInterface(String json) {
        IotShareInterfaceDO newInterface = JSONObject.parseObject(json, IotShareInterfaceDO.class);
        IotShareInterfaceDO oldInterface = iotShareInterfaceDao.findOne(newInterface.getId());
        oldInterface.setTypeName(newInterface.getTypeName());
        oldInterface.setExplanation(newInterface.getExplanation());
        oldInterface.setMethodName(newInterface.getMethodName());
        oldInterface.setInterfaceName(newInterface.getInterfaceName());
        oldInterface.setId(newInterface.getId());
        oldInterface.setDel("0");
        iotShareInterfaceDao.save(oldInterface);
    }
    /**
     * 根据ID查询接口
     * @param id
     * @return
     */
    public IotShareInterfaceDO findInterfaceById(String id) throws ParseException {
        IotShareInterfaceDO iotShareInterfaceDO = iotShareInterfaceDao.findOne(id);
        return iotShareInterfaceDO;
    }
    /**
     * 分页查询所有
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop<IotShareInterfaceDO,IotShareInterfaceDO> findAll(Integer page, Integer size) throws ParseException {
        String filters = "del=0;";
        String sorts = "-updateTime";//按更新时间降序
        List<IotShareInterfaceDO> list = search(null, filters, sorts, page, size);
        //获取总数
        long count = getCount(filters);
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Platform.message_success_find,list,page, size,count);
    }
    /**
     * 分页查询所有
     * @param page
     * @param size
     * @param type
     * @param name
     * @return
     */
    public MixEnvelop<IotShareInterfaceDO, IotShareInterfaceDO> conditionQueryPage(Integer page, Integer size, String type, String name){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_share_interface c  WHERE c.del=0 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_share_interface c  WHERE c.del=0 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(type)){
            sql.append(" and c.type_name=? ");
            sqlCount.append(" and c.type_name='").append(type).append("' ");
            args.add(type);
        }
        if(StringUtils.isNotBlank(name)){
            sql.append(" and c.method_name like '%").append(name).append("%'");
            sqlCount.append(" and c.method_name like '%").append(name).append("%'");
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotCompanyDO> list = jdbcTemplate.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotShareInterfaceDO.class));
        List<Map<String,Object>> countList = jdbcTemplate.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,list, page, size,count);
    }
}