Quellcode durchsuchen

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

wangzhinan vor 5 Jahren
Ursprung
Commit
378fec929f
28 geänderte Dateien mit 1211 neuen und 89 gelöschten Zeilen
  1. 19 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  2. 2 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java
  3. 11 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxPushLogDao.java
  4. 117 4
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java
  5. 5 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxPushLogDO.java
  6. 68 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyAppDO.java
  7. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java
  8. 61 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java
  9. 33 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductExtendInfoDO.java
  10. 2 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  11. 6 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  12. 47 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyAppVO.java
  13. 31 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyVO.java
  14. 61 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductBaseInfoVO.java
  15. 32 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductExtendInfoVO.java
  16. 1 1
      common/common-util/src/main/java/com/yihu/jw/util/wechat/WeixinMessagePushUtils.java
  17. 42 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UnSettledHISPrescriptionJob.java
  18. 30 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  19. 2 2
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  20. 2 1
      svr/svr-internet-hospital-job/src/main/resources/system.properties
  21. 29 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java
  22. 92 17
      svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java
  23. 2 2
      svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java
  24. 18 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyAppDao.java
  25. 10 2
      svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyDao.java
  26. 3 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyCertificateService.java
  27. 333 55
      svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java
  28. 90 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/useragent/UserAgent.java

+ 19 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -167,6 +167,25 @@ public class YkyyEntranceService {
        return "success";
    }
    /**
     * 查找眼科his 已审核未付款的处方
     * @throws Exception
     */
    public JSONArray getUnsettledPrescription() throws Exception{
        String sql = "SELECT h.BRID,h.CFSB from HLW_CF01 h WHERE h.SPZT = 1 and h.FKZT = 0";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            return rs.getJSONArray("detailModelList");
        }
        return new JSONArray();
    }
    public String updateYkyyDoctor()throws Exception{
        String sql ="select y.code AS \"code\",y.name AS \"name\",y.expertise AS \"expertise\",y.introduce AS \"introduce\",y.mobile AS \"mobile\",y.idCard AS \"idcard\",y.jobtitlecode AS \"jobTitleCode\",y.jobTitleName AS \"jobTitleName\",y.dept AS \"dept\",y.deptName AS \"deptName\" from v_Hlw_Ysxx y where y.idcard is not null";
        Map<String,Object> params = new HashedMap();

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java

@ -36,6 +36,8 @@ public interface BasePatientDao extends PagingAndSortingRepository<BasePatientDO
    @Query("from BasePatientDO p where p.mobile = ?1 and p.del=?2")
    List<BasePatientDO> findByMobileAndDel(String mobile,String del);
    
    BasePatientDO findByIdcard(String idcard);
//    @Modifying
//    @Query(" update BasePatientDO a set a.openid=?2 where a.id=?1 ")

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxPushLogDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2020/4/27.
 */
public interface WxPushLogDao extends PagingAndSortingRepository<WxPushLogDO, String>, JpaSpecificationExecutor<WxPushLogDO> {
}

+ 117 - 4
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java

@ -4,18 +4,20 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.oauth.OauthSsoService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.RSAEncrypt;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
import org.slf4j.Logger;
@ -28,6 +30,7 @@ import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/5/19 0019.
@ -62,6 +65,14 @@ public class WxTemplateService {
    
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    
    
    /**
@ -115,6 +126,72 @@ public class WxTemplateService {
        return "success";
    }
    /**
     * 查询HIS的01表中的审方状态,如果已审方,且未结算,则推送一条模板消息给居民,让居民进行支付结算。
     */
    public void unSettledHISPrescription() throws Exception{
        if("xm_ykyy_wx".equals(wechatId)){
            //获取已审核未结算的处方
            JSONArray array = ykyyEntranceService.getUnsettledPrescription();
//            JSONArray array = new JSONArray();
//            JSONObject tmpjson = new JSONObject();
//            tmpjson.put("BRID","1234");
//            tmpjson.put("CFSB","1159744");
//            array.add(tmpjson);
            //发送模板
            if(array!=null&&array.size()>0) {
                for (int i = 0; i<array.size(); i++){
                    JSONObject json = array.getJSONObject(i);
                    String brid = json.getString("BRID");
                    String cfsb = json.getString("CFSB");
                    //查找居民信息
                    BasePatientDO patientDO = ykyyEntranceService.findPatientByMapingCode(brid);
                    if(patientDO!=null){
                        //查找对应的处方
                        String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' ORDER BY w.CREATE_TIME desc";
                        List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                        if(pre!=null && pre.size()>0){
                            String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
                            String prescriptionId = pre.get(0).get("ID").toString();
                            String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
                            //判断是否发送过
                            String countSql = "SELECT id from WX_PUSH_LOG w WHERE w.RECEIVER = '"+patientDO.getId()
                                    +"' and w.OPENID = '"+prescriptionId+"' and w.scene = 'djsxxtz' and w.WECHAT_ID='"+wechatId+"'";
                            List<Map<String, Object>> count = hibenateUtils.createSQLQuery(countSql);
                            if(count==null || count.size() == 0){
                                List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patientDO.getId());
                                if(ps.isEmpty()){
                                    logger.info("该用户"+patientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+patientDO.getId()+"wechatId:"+wechatId);
                                }else{
                                    ps.stream().forEach(one->{
                                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_unsettled_notice","djsxxtz",1);
                                        config.setFirst(config.getFirst().replace("key1",patientDO.getName()));
                                        config.setUrl(config.getUrl()+""+outpatientId+"&openid="+one.getOpenid());
                                        config.setKeyword3(doctorName);
                                        WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                                        weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),config);
                                    });
                                    //保存发送模板记录,
                                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                                    wxPushLogDO.setCreateTime(new Date());
                                    wxPushLogDO.setOpenid(prescriptionId);
                                    wxPushLogDO.setReceiver(patientDO.getId());
                                    wxPushLogDO.setWechatId(wechatId);
                                    wxPushLogDO.setReceiverName(patientDO.getName());
                                    wxPushLogDO.setScene("djsxxtz");
                                    wxPushLogDao.save(wxPushLogDO);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_survey","test",1);
@ -123,6 +200,7 @@ public class WxTemplateService {
        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),openid,config);
        return "success";
    }
    
    public Envelop getAllTemp(String wechatId){
@ -169,5 +247,40 @@ public class WxTemplateService {
        }
        return rs;
    }
    
    /**
     * 发送微信模版消息
     * @param userName
     * @param senderName
     * @param idCard
     * @param phone
     * @param title
     * @param content
     * @param contentString
     * @param url
     */
    public String sendWxTemple(String userName, String senderName,
                             String idCard, String phone, String title,
                             String content, String contentString,
                             String url) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findByIdcard(idCard);
        if(basePatientDO!=null){
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,basePatientDO.getId());
            if(ps.isEmpty()){
                logger.info("该用户"+basePatientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+basePatientDO.getId()+"wechatId:"+wechatId);
            }else{
                for (BasePatientWechatDo basePatientWechatDo:ps){
                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_im_notice","zxtx",1);
                        config.setFirst(config.getFirst().replace("key1",senderName));
                        config.setKeyword1(contentString);
                        config.setKeyword2(DateUtil.dateToStrLong(new Date()));
                        config.setUrl(url);
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                }
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
}

+ 5 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxPushLogDO.java

@ -3,12 +3,16 @@ package com.yihu.jw.entity.base.wx;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/8/21.
 */
public class WxPushLogDO extends UuidIdentityEntity {
@Entity
@Table(name = "wx_push_log")
public class WxPushLogDO extends UuidIdentityEntity implements java.io.Serializable{
    private String wechatId;//推送类型
    private String tempName;//模板名称

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

@ -0,0 +1,68 @@
package com.yihu.jw.entity.iot.company;
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/27
 */
@Entity
@Table(name = "iot_company_app")
public class IotCompanyAppDO extends UuidIdentityEntityWithOperator implements Serializable {
    @Column(name = "saas_id")
    private String saasId;//
    @Column(name = "name")
    private String name;//应用名称',
    @Column(name = "company_id")
    private String companyId;//公司ID
    @Column(name = "company_name")
    private String companyName;
    @Column(name = "address_ip")
    private String addressIp;//访问IP地址
    @Column(name = "del")
    private String del;//是否删除 0:删除  1:不删除
    public IotCompanyAppDO() {
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saas_id) {
        this.saasId = saas_id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getCompanyId() {
        return companyId;
    }
    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }
    public String getAddressIp() {
        return addressIp;
    }
    public void setAddressIp(String addressIp) {
        this.addressIp = addressIp;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
}

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java

@ -62,6 +62,20 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
    @Transient
    private List<IotCompanyTypeDO> typeList;//类型
    //    新增加的字段
    @Column(name = "enter_type")
    private String enterType;//厂商入驻类型 1:供应商  2:代理商 3:厂商
    @Column(name = "account_type")
    private String accountType;//注册类型(1:厂商注册  0:平台注册)
    @Column(name = "audit_message")
    private String auditMessage;//审核不通过信息说明
    @Column(name = "audit_time")
    private Date auditTime;//审核时间
    @Column(name = "audit_name")
    private String auditName;//审核人姓名
    @Transient
//    private List<IotCompanyAppDO> appList;//应用实体
    public String getSaasId() {
        return saasId;
    }
@ -230,4 +244,52 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
    public void setTypeList(List<IotCompanyTypeDO> typeList) {
        this.typeList = typeList;
    }
    public String getEnterType() {
        return enterType;
    }
    public void setEnterType(String enterType) {
        this.enterType = enterType;
    }
    public String getAccountType() {
        return accountType;
    }
    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }
    public String getAuditMessage() {
        return auditMessage;
    }
    public void setAuditMessage(String auditMessage) {
        this.auditMessage = auditMessage;
    }
    public Date getAuditTime() {
        return auditTime;
    }
    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }
    public String getAuditName() {
        return auditName;
    }
    public void setAuditName(String auditName) {
        this.auditName = auditName;
    }
//    public List<IotCompanyAppDO> getAppList() {
//        return appList;
//    }
//
//    public void setAppList(List<IotCompanyAppDO> appList) {
//        this.appList = appList;
//    }
}

+ 61 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java

@ -62,6 +62,19 @@ public class IotProductBaseInfoDO extends UuidIdentityEntityWithOperator impleme
    private String certificateName;//授权书名称
    @Column(name = "del")
    private Integer del;//删除标志
    //以下为新增的字段
    @Column(name = "register_name")
    private String registerName;//注册名称
    @Column(name = "spec")
    private String spec;//规格
    @Column(name = "unit")
    private String unit;//单位
    @Column(name = "purchase_price")
    private Double purchasePrice;//进货价
    @Column(name = "retail_price")
    private Double retailPrice;//零售价格
    @Column(name = "category_code")
    private String categoryCode;//设备类型标识
    public String getSaasId() {
        return saasId;
@ -246,4 +259,52 @@ public class IotProductBaseInfoDO extends UuidIdentityEntityWithOperator impleme
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getRegisterName() {
        return registerName;
    }
    public void setRegisterName(String registerName) {
        this.registerName = registerName;
    }
    public String getSpec() {
        return spec;
    }
    public void setSpec(String spec) {
        this.spec = spec;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public Double getPurchasePrice() {
        return purchasePrice;
    }
    public void setPurchasePrice(Double purchasePrice) {
        this.purchasePrice = purchasePrice;
    }
    public Double getRetailPrice() {
        return retailPrice;
    }
    public void setRetailPrice(Double retailPrice) {
        this.retailPrice = retailPrice;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
}

+ 33 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductExtendInfoDO.java

@ -6,6 +6,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 产品扩展信息表
@ -36,6 +37,14 @@ public class IotProductExtendInfoDO extends UuidIdentityEntityWithOperator imple
    @Column(name = "del")
    private Integer del;//删除标志
    //以下为增加的字段
    @Column(name = "company_name")
    private String companyName;//生产企业名称
    @Column(name = "ratify_date")
    private Date ratifyDate;//批准日期
    @Column(name = "agency_name")
    private String agencyName;//代理人
    public String getSaasId() {
        return saasId;
    }
@ -115,4 +124,28 @@ public class IotProductExtendInfoDO extends UuidIdentityEntityWithOperator imple
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public Date getRatifyDate() {
        return ratifyDate;
    }
    public void setRatifyDate(Date ratifyDate) {
        this.ratifyDate = ratifyDate;
    }
    public String getAgencyName() {
        return agencyName;
    }
    public void setAgencyName(String agencyName) {
        this.agencyName = agencyName;
    }
}

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1076,5 +1076,7 @@ public class BaseHospitalRequestMapping {
    public static class WxPay extends Basic{
        public static final String wechatPay =  "/wechatPay";
        public static final String Notify =  "/notify";
        //发送微信模版消息
        public static final String sendWxTemple = "/sendWxTemple";
    }
}

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

@ -69,6 +69,10 @@ public class IotRequestMapping {
        public static final String findByBusinessLicense = "findByBusinessLicense";
        public static final String updCompany = "updCompany";
        public static final String delCompany = "delCompany";
        public static final String auditCompanyPass = "auditCompanyPass";
        public static final String auditCompanyNoPass = "auditCompanyNoPass";
        public static final String findAll = "findAll";
        public static final String enterType = "enterType";
        public static final String findCompanyCertPage = "findCompanyCertPage";
        public static final String findCompanyCertById = "findCompanyCertById";
@ -89,6 +93,8 @@ public class IotRequestMapping {
        public static final String message_success_find = "find success";
        public static final String message_success_create = "create success";
        public static final String message_success_find_functions = "find success";
        public static final String message_success_audit = "audit success";
        public static final String message_success_enterType = "enter success";
    }

+ 47 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyAppVO.java

@ -0,0 +1,47 @@
package com.yihu.jw.restmodel.iot.company;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 企业应用表
 * @author suhaiwen on 2020/4/24.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "企业应用类", description = "企业应用表")
public class IotCompanyAppVO implements Serializable {
    @ApiModelProperty("应用ID")
    private String id;
    @ApiModelProperty("应用名称")
    private String name;
    @ApiModelProperty("访问IP地址")
    private String addressIp;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddressIp() {
        return addressIp;
    }
    public void setAddressIp(String addressIp) {
        this.addressIp = addressIp;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
}

+ 31 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/company/IotCompanyVO.java

@ -60,6 +60,13 @@ public class IotCompanyVO extends BaseVO implements Serializable {
    @ApiModelProperty("类型")
    private List<IotCompanyTypeVO> typeList;
    @ApiModelProperty("厂商入驻类型 1:供应商  2:代理商 3:厂商")
    private String enterType;//
    @ApiModelProperty("注册类型(1:厂商注册  0:平台注册)")
    private String accountType;
    @ApiModelProperty("应用")
    private List<IotCompanyAppVO> appList;
    public String getStatus() {
        return status;
    }
@ -219,4 +226,28 @@ public class IotCompanyVO extends BaseVO implements Serializable {
    public void setEhrUserId(String ehrUserId) {
        this.ehrUserId = ehrUserId;
    }
    public String getEnterType() {
        return enterType;
    }
    public void setEnterType(String enterType) {
        this.enterType = enterType;
    }
    public String getAccountType() {
        return accountType;
    }
    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }
    public List<IotCompanyAppVO> getAppList() {
        return appList;
    }
    public void setAppList(List<IotCompanyAppVO> appList) {
        this.appList = appList;
    }
}

+ 61 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductBaseInfoVO.java

@ -71,6 +71,19 @@ public class IotProductBaseInfoVO extends BaseVO implements Serializable {
    private String certificateName;
    @ApiModelProperty("数据传输方式")
    private List<IotProductDataTransmissionVO> dataTransmissionVOList;
    //以下为新增加的字段
    @ApiModelProperty("注册名称")
    private String registerName;
    @ApiModelProperty("规格")
    private String spec;
    @ApiModelProperty("单位")
    private String unit;
    @ApiModelProperty("进货价")
    private Double purchasePrice;
    @ApiModelProperty("零售价格")
    private Double retailPrice;
    @ApiModelProperty("设备类型标识")
    private String categoryCode;
    public String getParentId() {
        return parentId;
@ -279,4 +292,52 @@ public class IotProductBaseInfoVO extends BaseVO implements Serializable {
    public void setOriginTypeName(String originTypeName) {
        this.originTypeName = originTypeName;
    }
    public String getRegisterName() {
        return registerName;
    }
    public void setRegisterName(String registerName) {
        this.registerName = registerName;
    }
    public String getSpec() {
        return spec;
    }
    public void setSpec(String spec) {
        this.spec = spec;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public Double getPurchasePrice() {
        return purchasePrice;
    }
    public void setPurchasePrice(Double purchasePrice) {
        this.purchasePrice = purchasePrice;
    }
    public Double getRetailPrice() {
        return retailPrice;
    }
    public void setRetailPrice(Double retailPrice) {
        this.retailPrice = retailPrice;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
}

+ 32 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/product/IotProductExtendInfoVO.java

@ -33,6 +33,14 @@ public class IotProductExtendInfoVO extends BaseVO implements Serializable {
    @ApiModelProperty("附件列表")
    private List<IotProductAttachmentVO> attachmentVOList;
    //以下为新增加字段
    @ApiModelProperty("生产企业名称")
    private String companyName;
    @ApiModelProperty("批准日期")
    private String ratifyDate;
    @ApiModelProperty("代理人")
    private String agencyName;
    public String getProductImg() {
        return productImg;
    }
@ -96,4 +104,28 @@ public class IotProductExtendInfoVO extends BaseVO implements Serializable {
    public void setAttachmentVOList(List<IotProductAttachmentVO> attachmentVOList) {
        this.attachmentVOList = attachmentVOList;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public String getRatifyDate() {
        return ratifyDate;
    }
    public void setRatifyDate(String ratifyDate) {
        this.ratifyDate = ratifyDate;
    }
    public String getAgencyName() {
        return agencyName;
    }
    public void setAgencyName(String agencyName) {
        this.agencyName = agencyName;
    }
}

+ 1 - 1
common/common-util/src/main/java/com/yihu/jw/util/wechat/WeixinMessagePushUtils.java

@ -169,7 +169,7 @@ public class WeixinMessagePushUtils {
        //设置keyword1
        if(StringUtils.isNotBlank(wxtemp.getKeyword1())){
            WechatTemplateDataDO keyword1 = new WechatTemplateDataDO();
            keyword1.setValue(wxtemp.getRemark());
            keyword1.setValue(wxtemp.getKeyword1());
            keyword1.setColor("#000000");
            data.put("keyword1",keyword1);
        }

+ 42 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UnSettledHISPrescriptionJob.java

@ -0,0 +1,42 @@
package com.yihu.jw.job.ykyy;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.job.DataUploadJob;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import com.yihu.jw.wechat.service.WxTemplateService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 定时查询HIS的01表中的审方状态,如果已审方,且未结算,则推送一条模板消息给居民,让居民进行支付结算。
 * Created by yeshijie on 2020/4/26.
 *
 * @author yeshijie.
 */
public class UnSettledHISPrescriptionJob implements Job{
    private static final Logger logger = LoggerFactory.getLogger(UnSettledHISPrescriptionJob.class);
    @Autowired
    private WxTemplateService wxTemplateService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========UnSettledHISPrescriptionJob========");
        try {
            wxTemplateService.unSettledHISPrescription();
            logger.info("END========UnSettledHISPrescriptionJob 执行结束========");
        }catch (Exception e){
            e.printStackTrace();
            logger.error("END===ERROE===UnSettledHISPrescriptionJob,message:"+e.getMessage());
        }
    }
}

+ 30 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -7,11 +7,13 @@ import com.yihu.jw.internet.service.InternetCommonService;
import com.yihu.jw.internet.service.InternetService;
import com.yihu.jw.internet.service.ykyy.YkyyInternetService;
import com.yihu.jw.job.*;
import com.yihu.jw.job.ykyy.UnSettledHISPrescriptionJob;
import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.LoggerFactory;
@ -53,6 +55,8 @@ public class JobController extends BaseController {
    @Autowired
    private InternetCommonService internetCommonService;
    @Autowired
    private WxTemplateService wxTemplateService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
@ -60,6 +64,21 @@ public class JobController extends BaseController {
        this.quartzHelper = quartzHelper;
    }
    /**
     * 测试方法
     * @return
     */
    @RequestMapping(value = "unSettledHISPrescription", method = RequestMethod.GET)
    public String unSettledHISPrescription() {
        try {
            wxTemplateService.unSettledHISPrescription();
            return success("成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "失败:" + e.getMessage());
        }
    }
    @RequestMapping(value = "removeJob", method = RequestMethod.GET)
    public String removeJob(String taskId) {
@ -145,6 +164,17 @@ public class JobController extends BaseController {
                        logger.info("data_common_upload_job  job exist");
                    }
                    break;
                case "unsettled_prescription_notice_job" :
                    //互联网医院 待结算消息推送
                    if (!quartzHelper.isExistJob("unsettled_prescription_notice_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("unsettled_prescription_notice_job");
                        quartzHelper.addJob(UnSettledHISPrescriptionJob.class, trigger, "unsettled_prescription_notice_job", new HashMap<String, Object>());
                        logger.info("unsettled_prescription_notice_job  job success");
                    } else {
                        logger.info("unsettled_prescription_notice_job  job exist");
                    }
                    break;
                default :
            }

+ 2 - 2
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -155,7 +155,7 @@ fastDFS:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---
@ -192,7 +192,7 @@ fastDFS:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---

+ 2 - 1
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -11,7 +11,8 @@ data_upload_job=0 0 2 * * ?
#-------------------------中山医院end-----------------------------#
#-------------------------眼科医院-----------------------------#
data_ykupload_job=0 0 0 * * ?
#每间隔1分钟触发
unsettled_prescription_notice_job=0 */1 * * * ?
#-------------------------眼科医院end-----------------------------#
#-------------------------监管平台通用医院-----------------------------#
data_common_upload_job=0 0 0 * * ?

+ 29 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

@ -5,11 +5,13 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -40,6 +42,8 @@ public class YkyyController extends EnvelopRestEndpoint {
    private BusinessOrderService businessOrderService;
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private WxTemplateService wxTemplateService;
    @GetMapping(value = "/selectCardList")
@ -285,8 +289,29 @@ public class YkyyController extends EnvelopRestEndpoint {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    
    
    @ResponseBody
    @ApiOperation("发送微信模版消息")
    @RequestMapping(value = BaseHospitalRequestMapping.WxPay.sendWxTemple, method = {RequestMethod.GET, RequestMethod.POST})
    public Envelop sendWxTemple(@ApiParam(name = "userName", value = "居民名称")
                                              @RequestParam(value = "userName", required = false,defaultValue = "") String userName,
                                          @ApiParam(name = "senderName", value = "发送人名称")
                                              @RequestParam(value = "senderName", required = false,defaultValue = "") String senderName,
                                          @ApiParam(name = "idCard", value = "身份证")
                                              @RequestParam(value = "idCard", required = false,defaultValue = "") String idCard,
                                          @ApiParam(name = "phone", value = "居民手机")
                                              @RequestParam(value = "phone", required = false,defaultValue = "") String phone,
                                          @ApiParam(name = "title", value = "标题")
                                              @RequestParam(value = "title", required = false,defaultValue = "") String title,
                                          @ApiParam(name = "content", value = "简介")
                                              @RequestParam(value = "content", required = false,defaultValue = "") String content,
                                          @ApiParam(name = "contentString", value = "回复内容")
                                              @RequestParam(value = "contentString", required = false,defaultValue = "") String contentString,
                                          @ApiParam(name = "url", value = "跳转URL")
                                              @RequestParam(value = "url", required = false,defaultValue = "") String url
    )throws Exception  {
        wxTemplateService.sendWxTemple(userName,senderName,idCard,phone,title,content,contentString,url);
        return success("操作成功");
    }
}

+ 92 - 17
svr/svr-iot/src/main/java/com/yihu/iot/controller/company/IotCompanyController.java

@ -11,10 +11,15 @@ import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.ValidateActions;
import org.elasticsearch.common.recycler.Recycler;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
@ -35,12 +40,12 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Company.findCompanyPage)
    @ApiOperation(value = "分页查找企业", notes = "分页查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findCompanyPage(@ApiParam(name = "name", value = "供应商名称或联系人姓名", defaultValue = "")
                                       @RequestParam(value = "name", required = false) String name,
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findCompanyPage(@ApiParam(name = "accountType", value = "注册类型", defaultValue = "")
                                       @RequestParam(value = "accountType", required = false) String accountType,
                                                    @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 = "enterType", value = "入驻类型", defaultValue = "")
                                       @RequestParam(value = "enterType", required = false) String enterType,
                                                    @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                       @RequestParam(value = "page", required = false) Integer page,
                                                    @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
@ -52,10 +57,10 @@ public class IotCompanyController extends EnvelopRestEndpoint {
            if(size == null){
                size = 10;
            }
            if(StringUtils.isBlank(type)){
                return iotCompanyService.queryPage(page,size,status,name);
            if(StringUtils.isBlank(status)){
                return iotCompanyService.queryPage(page,size,accountType,enterType);
            }else {
                return iotCompanyService.queryPage(page,size,status,name,type);
                return iotCompanyService.queryPage(page,size,status,accountType,enterType);
            }
        } catch (Exception e) {
@ -71,13 +76,79 @@ public class IotCompanyController extends EnvelopRestEndpoint {
        try {
            IotCompanyVO iotCompanyVO = toEntity(jsonData, IotCompanyVO.class);
            IotCompanyDO iotCompany = iotCompanyService.convertToModelDO(iotCompanyVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create, iotCompanyService.create(iotCompany));
            iotCompanyService.create(iotCompany);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_create);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.auditCompanyPass)
    @ApiOperation(value = "通过审核",notes = "通过审核")
    public MixEnvelop<IotCompanyVO,IotCompanyVO> auditCompanyPass(@ApiParam(name = "id",value = "id") @RequestParam(value = "id",required = true)String id){
        try {
            return  iotCompanyService.auditCompany(id);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.auditCompanyNoPass)
    @ApiOperation(value = "审核失败",notes = "审核失败")
    public MixEnvelop<IotCompanyVO,IotCompanyVO> auditCompanyNoPass(@ApiParam(name = "id",value = "id") @RequestParam(value = "id",required = true)String id,
                                                                    @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());
        }
    }
    @PostMapping(value = IotRequestMapping.Company.enterType)
    @ApiOperation(value = "根据入驻类型查找企业",notes = "根据入驻类型查找企业")
    public MixEnvelop<IotCompanyVO,IotCompanyVO> findByEnterType(@ApiParam(name = "entryCode",value = "入驻类型") @RequestParam(value = "entryCode",required = true)String entryCode){
        try {
            List<IotCompanyDO>  iotCompanyDOList = iotCompanyService.findByEnterType(entryCode);
            List<IotCompanyVO> iotCompanyVOList = new ArrayList<>();
            for (IotCompanyDO iotCompanyDO : iotCompanyDOList) {
                IotCompanyVO iotCompanyVO = iotCompanyService.convertToModelVO(iotCompanyDO);
                iotCompanyVOList.add(iotCompanyVO);
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_enterType,iotCompanyVOList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Company.findAll)
    @ApiOperation(value = "查询所有企业", notes = "查询所有企业")
    public MixEnvelop<IotCompanyCertificateVO, IotCompanyCertificateVO> findAll(@ApiParam(name = "accountType", value = "注册类型" )
                                                                                       @RequestParam(value = "accountType", required = true)String accountType) {
        try {
           List<IotCompanyDO> iotCompanyDOList =  iotCompanyService.findAll(accountType);
            List<IotCompanyVO> iotCompanyVOList = new ArrayList<>();
            for (IotCompanyDO iotCompanyDO : iotCompanyDOList) {
                IotCompanyVO iotCompanyVO = iotCompanyService.convertToModelVO(iotCompanyDO);
                iotCompanyVOList.add(iotCompanyVO);
            }
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find, iotCompanyVOList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Company.findCompanyById)
    @ApiOperation(value = "根据id查找企业", notes = "根据id查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findByCode(@ApiParam(name = "id", value = "id")
@ -94,10 +165,12 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Company.findByBusinessLicense)
    @ApiOperation(value = "根据营业执照号查找企业", notes = "根据营业执照号查找企业")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findByBusinessLicense(@ApiParam(name = "businessLicense", value = "businessLicense")
                                            @RequestParam(value = "businessLicense", required = true) String businessLicense) {
    public MixEnvelop<IotCompanyVO, IotCompanyVO> findByBusinessLicense(@ApiParam(name = "businessLicense", value = "营业执照号")
                                            @RequestParam(value = "businessLicense", required = true) String businessLicense,
                                               @ApiParam(name = "accountType", value = "注册类型")
                                            @RequestParam(value = "accountType", required = true) String accountType) {
        try {
            IotCompanyDO iotCompanyDO = iotCompanyService.findByBusinessLicense(businessLicense);
            IotCompanyDO iotCompanyDO = iotCompanyService.findByBusinessLicense(businessLicense,accountType);
            IotCompanyVO vo = iotCompanyService.convertToModelVO(iotCompanyDO);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find, vo);
        } catch (Exception e) {
@ -112,7 +185,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
                              @RequestParam(value = "id", required = true) String id) {
        try {
            iotCompanyService.delCompany(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -122,12 +195,14 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @PostMapping(value = IotRequestMapping.Company.updCompany)
    @ApiOperation(value = "修改企业信息", notes = "修改企业信息")
    public MixEnvelop<IotCompanyVO, IotCompanyVO> updCompany(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                  @RequestParam(value = "jsonData", required = true)String jsonData) {
                                  @RequestParam(value = "jsonData", required = true)String jsonData,
                                                             @ApiParam(name = "accountType", value = "注册类型", defaultValue = "")
                                                             @RequestParam(value = "accountType", required = true)String accountType) {
        try {
            IotCompanyVO iotCompanyVO = toEntity(jsonData, IotCompanyVO.class);
            IotCompanyDO iotCompany = iotCompanyService.convertToModelDO(iotCompanyVO);
            iotCompanyService.updCompany(iotCompany);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_find);
            iotCompanyService.updCompany(iotCompany,accountType);
            return MixEnvelop.getSuccess(IotRequestMapping.Company.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
@ -161,7 +236,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Company.findCompanyCertById)
    @ApiOperation(value = "根据id查找企业证书", notes = "根据id查找企业证书")
    public MixEnvelop<IotCompanyCertificateVO, IotCompanyCertificateVO> findCompanyCertById(@ApiParam(name = "id", value = "id")
    public MixEnvelop<IotCompanyCertificateVO, IotCompanyCertificateVO> findCompanyCertById(@ApiParam(name = "id", value = "证书ID")
                                            @RequestParam(value = "id", required = true) String id) {
        try {
            IotCompanyCertificateDO iotCompanyCertificateDO = iotCompanyCertificateService.findById(id);
@ -220,7 +295,7 @@ public class IotCompanyController extends EnvelopRestEndpoint {
                                                           @RequestParam(value = "id", required = true)String id) {
        try {
            iotCompanyCertificateService.delCompanyCert(id);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

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

@ -179,7 +179,7 @@ public class IotProductController extends EnvelopRestEndpoint {
            if(re==-1){
                return MixEnvelop.getError("该产品已有关联订单,不允许删除",-1);
            }else {
                return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
                return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_delete);
            }
        } catch (Exception e) {
            e.printStackTrace();
@ -194,7 +194,7 @@ public class IotProductController extends EnvelopRestEndpoint {
        try {
            IotProductVO iotProductVO = toEntity(jsonData, IotProductVO.class);
            iotProductBaseInfoService.updProduct(iotProductVO);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

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

@ -0,0 +1,18 @@
package com.yihu.iot.dao.company;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/24
 */
public interface IotCompanyAppDao extends PagingAndSortingRepository<IotCompanyAppDO, String>,
        JpaSpecificationExecutor<IotCompanyAppDO> {
        List<IotCompanyAppDO> findByCompanyId(String companyId);
        }

+ 10 - 2
svr/svr-iot/src/main/java/com/yihu/iot/dao/company/IotCompanyDao.java

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 企业表
 * @author yeshijie on 2018/1/15.
@ -15,6 +17,12 @@ public interface IotCompanyDao extends PagingAndSortingRepository<IotCompanyDO,
    @Query("from IotCompanyDO w where w.id =?1 and w.del=1 ")
    IotCompanyDO findById(String id);
    @Query("from IotCompanyDO w where w.businessLicense =?1 and w.del=1")
    IotCompanyDO findByBusinessLicense(String businessLicense);
    @Query("from IotCompanyDO w where w.businessLicense =?1 and w.accountType=?2 and w.del=1")
    IotCompanyDO findByBusinessLicense(String businessLicense,String accountType);
    @Query("from IotCompanyDO w where w.accountType =?1 and w.del=1")
    List<IotCompanyDO> findByAccountType(String accountType);
    @Query("from IotCompanyDO w where w.enterType =?1 and w.status=1 and w.del=1")
    List<IotCompanyDO> findByEnterType(String entryType);
}

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyCertificateService.java

@ -112,6 +112,9 @@ public class IotCompanyCertificateService extends BaseJpaService<IotCompanyCerti
     */
    public void delCompanyCert(String id){
        IotCompanyCertificateDO companyCert = iotCompanyCertificateDao.findById(id);
        if(companyCert==null){
            throw new RuntimeException("证书已删除,请勿重复操作");
        }
        companyCert.setDel(0);
        iotCompanyCertificateDao.save(companyCert);
    }

+ 333 - 55
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -1,11 +1,15 @@
package com.yihu.iot.service.company;
import com.yihu.iot.dao.company.IotCompanyAppDao;
import com.yihu.iot.dao.company.IotCompanyCertificateChangeRecordDao;
import com.yihu.iot.dao.company.IotCompanyDao;
import com.yihu.iot.dao.company.IotCompanyTypeDao;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.company.IotCompanyAppDO;
import com.yihu.jw.entity.iot.company.IotCompanyCertificateChangeRecordDO;
import com.yihu.jw.entity.iot.company.IotCompanyDO;
import com.yihu.jw.entity.iot.company.IotCompanyTypeDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyAppVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.iot.company.IotCompanyTypeVO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
@ -38,33 +42,47 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
    private JdbcTemplate jdbcTempalte;
    @Autowired
    private IotCompanyCertificateChangeRecordDao iotCompanyCertificateChangeRecordDao;
    @Autowired
    private IotCompanyAppDao iotCompanyAppDao;
    @Autowired
    private UserAgent userAgent;
    /**
     * 分页查找
     * 审核通过 分页查找
     * @param page
     * @param size
     * @param status
     * @param name
     * @param accountType
     * @param enterType
     * @return
     * @throws ParseException
     */
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String name) throws ParseException {
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String accountType, String enterType) throws ParseException {
        String filters = "del=1;";
        String semicolon = "";
        if(StringUtils.isNotBlank(name)){
            filters += "name?"+name+" g1;contactsName?"+name+" g1";
        if(StringUtils.isNotBlank(accountType)){
            filters += "accountType?"+accountType;
            semicolon = ";";
        }
        if(StringUtils.isNotBlank(status)){
            filters += semicolon +"status="+status;
        if(StringUtils.isNotBlank(enterType)){
            filters += semicolon +"enterType="+enterType;
            semicolon = ";";
        }
        String sorts = "-updateTime";
        //得到list数据
        String sorts = "-updateTime";//按更新时间降序
        List<IotCompanyDO> list = search(null, filters, sorts, page, size);
        list.forEach(one->{
            findType(one);
        });
        if(accountType.equalsIgnoreCase("1")){
            //得到list数据
            list.forEach(one->{
                findType(one);
            });
        }
        if(accountType.equalsIgnoreCase("0")){
            list.forEach(one->{
                findAppType(one);
            });
        }
        //获取总数
        long count = getCount(filters);
@ -84,8 +102,18 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        sources.forEach(one -> {
            IotCompanyVO target = new IotCompanyVO();
            BeanUtils.copyProperties(one, target);
            List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
            target.setTypeList(voList);
            if(target.getTypeList()!=null){
                List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
                target.setTypeList(voList);
            }
            if (target.getAppList()!=null){
                List<IotCompanyAppVO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppVO.class);
                target.setAppList(appList);
            }
//            List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
//            List<IotCompanyAppVO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppVO.class);
//            target.setTypeList(voList);
//            target.setAppList(appList);
            targets.add(target);
        });
        return targets;
@ -107,6 +135,10 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            List<IotCompanyTypeVO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeVO.class);
            target.setTypeList(voList);
        }
        if (target.getAppList()!=null){
            List<IotCompanyAppVO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppVO.class);
            target.setAppList(appList);
        }
        return target;
    }
@ -123,8 +155,15 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        if(StringUtils.isNotBlank(iotCompanyVO.getBusinessStartTime())){
            target.setBusinessStartTime(DateUtil.strToDate(iotCompanyVO.getBusinessStartTime()));
        }
        List<IotCompanyTypeDO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeDO.class);
        target.setTypeList(voList);
        if (iotCompanyVO.getTypeList()!=null){
            List<IotCompanyTypeDO> voList = convertToModels(target.getTypeList(),new ArrayList<>(target.getTypeList().size()),IotCompanyTypeDO.class);
            target.setTypeList(voList);
        }
        if (iotCompanyVO.getAppList()!=null){
            List<IotCompanyAppDO> appList = convertToModels(target.getAppList(),new ArrayList<>(target.getAppList().size()),IotCompanyAppDO.class);
            target.setAppList(appList);
        }
        return target;
    }
@ -133,11 +172,44 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @param page
     * @param size
     * @param status
     * @param name
     * @param type
     * @param accountType
     * @param enterType
     * @return
     */
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String name, String type){
    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(Integer page, Integer size, String status, String accountType, String enterType){
        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_company c WHERE c.del=1 ");
        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_company c  WHERE c.del=1 ");
        List<Object> args = new ArrayList<>();
        if(StringUtils.isNotBlank(status)){
            sql.append(" and c.status=? ");
            sqlCount.append(" and c.status='").append(status).append("' ");
            args.add(status);
        }
        if(StringUtils.isNotBlank(accountType)){
            sql.append(" and c.account_type=? ");
            sqlCount.append(" and c.account_type='").append(accountType).append("' ");
            args.add(accountType);
        }
        if(StringUtils.isNotBlank(enterType)){
            sql.append(" and c.enter_type=? ");
            sqlCount.append(" and c.enter_type='").append(enterType).append("' ");
            args.add(enterType);
        }
        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size);
        List<IotCompanyDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotCompanyDO.class));
        list.forEach(one->{
            findType(one);
        });
        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString());
        long count = Long.valueOf(countList.get(0).get("count").toString());
        //DO转VO
        List<IotCompanyVO> iotCompanyVOList = convertToModelVOs(list,new ArrayList<>(list.size()));
        return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Company.message_success_find_functions,iotCompanyVOList, page, size,count);
    }
/*    public MixEnvelop<IotCompanyVO, IotCompanyVO> queryPage(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<>();
@ -170,7 +242,7 @@ 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);
    }
    }*/
    /**
     * 新增
@ -178,23 +250,100 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @return
     */
    public IotCompanyDO create(IotCompanyDO iotCompany) {
        iotCompany.setStatus("1");
        iotCompany.setSaasId(getCode());
        iotCompany.setDel(1);
        List<IotCompanyTypeDO> list = iotCompany.getTypeList();
        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());
            companyTypes.add(companyType);
        });
        iotCompanyTypeDao.save(companyTypes);
        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")){
                    throw new RuntimeException("该营业执照号已经注册,请使用其他执照");
                }
                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 {
                        throw new RuntimeException("该企业已经注册,请使用注册账号登录");
                    }
                }
            }
            //保存产商信息
            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());
                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")) {
                    throw new RuntimeException("该营业执照号已经注册,请使用其他执照");
                }
            }
            //判断应用是否已经注册
            IotCompanyAppDO companyAppDO = iotCompany.getAppList().get(0);
            //查找所有应用名称
            Iterable<IotCompanyAppDO> appDOList = iotCompanyAppDao.findAll();
            IotCompanyDO companyTemp = new IotCompanyDO();
            for (IotCompanyAppDO app : appDOList) {
                if(app.getName().equalsIgnoreCase(companyAppDO.getName())){
                    String companyId = app.getCompanyId();
                    IotCompanyDO companyDO = iotCompanyDao.findOne(companyId);
                    //该平台重新申请注册
                    if(iotCompany.getName().equalsIgnoreCase(companyDO.getName())&&companyDO.getStatus().equalsIgnoreCase("2")){
                        //查找该企业下的app
                        List<IotCompanyAppDO> apps = iotCompanyAppDao.findByCompanyId(companyDO.getId());
                        //保存注册信息获取CompangId
                         companyTemp = iotCompanyDao.save(iotCompany);
                        //遍历apps找出与注册相同的app
                        for (IotCompanyAppDO appDO : apps) {
                            if (appDO.getName().equalsIgnoreCase(companyAppDO.getName())){
                                appDO.setDel("0");
                                iotCompanyAppDao.save(appDO);
                            }
                            //更改公司ID
                            appDO.setCompanyId(companyTemp.getId());
                        }
                    }
                    throw new RuntimeException("该应用已经注册,请使用注册账号登录");
                }
            }
            //平台接入
            companyTemp.setStatus("0");//待审核
            companyTemp.setSaasId(getCode());
            companyTemp.setDel(1);
            iotCompany = iotCompanyDao.save(companyTemp);
            //保存应用
            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);
        }
        return iotCompany;
    }
@ -206,7 +355,14 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     */
    public IotCompanyDO findById(String id) {
        IotCompanyDO company = iotCompanyDao.findById(id);
        findType(company);
        String accountType = company.getAccountType();
        if ("1".equalsIgnoreCase(accountType)){
            findType(company);
        }
        if ("0".equalsIgnoreCase(accountType)){
            List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyId(company.getId());
            company.setAppList(appDOList);
        }
        return company;
    }
@ -215,8 +371,8 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * @param businessLincense
     * @return
     */
    public IotCompanyDO findByBusinessLicense(String businessLincense){
        return iotCompanyDao.findByBusinessLicense(businessLincense);
    public IotCompanyDO findByBusinessLicense(String businessLincense,String accountType){
        return iotCompanyDao.findByBusinessLicense(businessLincense,accountType);
    }
    /**
@ -241,6 +397,25 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        company.setTypeList(list);
    }
    public void findAppType(IotCompanyDO company){
        if(company==null){
            return;
        }
        //查找类型
        List<IotCompanyAppDO> appList = iotCompanyAppDao.findByCompanyId(company.getId());
        List<IotCompanyAppDO> list = new ArrayList<>(8);
        if(appList.size()>0){
            appList.forEach(one->{
                IotCompanyAppDO vo = new IotCompanyAppDO();
                vo.setName(one.getName());
                vo.setAddressIp(one.getAddressIp());
                vo.setId(one.getId());
                list.add(vo);
            });
        }
        company.setAppList(appList);
    }
    /**
     * 查找企业类型
     * @param companyId
@ -256,6 +431,9 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     */
    public void delCompany(String id){
        IotCompanyDO company = iotCompanyDao.findById(id);
        if (company==null){
           throw new RuntimeException("该企业已删除,请勿重复操作");
        }
        company.setDel(0);
        iotCompanyDao.save(company);
    }
@ -264,22 +442,38 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
     * 修改
     * @param iotCompany
     */
    public void updCompany(IotCompanyDO iotCompany){
        //更新类型
        List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
        iotCompanyTypeDao.delete(typeList);
        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());
            companyTypes.add(companyType);
        });
    public void updCompany(IotCompanyDO iotCompany,String accountType){
        
        if(accountType.equalsIgnoreCase("1")){
            //更新类型
            List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(iotCompany.getId());
            iotCompanyTypeDao.delete(typeList);
            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());
                companyTypes.add(companyType);
            });
        iotCompanyTypeDao.save(companyTypes);
            iotCompanyTypeDao.save(companyTypes);
        }
        //更新应用
        if(accountType.equalsIgnoreCase("0")){
            IotCompanyAppDO newApp = iotCompany.getAppList().get(0);
            IotCompanyAppDO oldApp = iotCompanyAppDao.findOne(newApp.getId());
            oldApp.setAddressIp(newApp.getAddressIp());
            oldApp.setName(newApp.getName());
            oldApp.setId(newApp.getId());
            oldApp.setCompanyId(iotCompany.getId());
            oldApp.setCompanyName(iotCompany.getName());
            oldApp.setSaasId(getCode());
            iotCompanyAppDao.save(oldApp);
        }
       
        //记录三证变更记录
        IotCompanyDO iotCompanyOld = iotCompanyDao.findById(iotCompany.getId());
@ -328,6 +522,7 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        }
        //修改企业记录
        iotCompanyOld.setEnterType(iotCompany.getEnterType());
        iotCompanyOld.setName(iotCompany.getName());
        iotCompanyOld.setIsThreeInOne(iotCompany.getIsThreeInOne());
        iotCompanyOld.setBusinessLicense(iotCompany.getBusinessLicense());
@ -361,4 +556,87 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
            return true;
        }
    }
    /**
     * 通过审核
     * @param id 企业ID
     * @return
     */
    public MixEnvelop auditCompany(String id) {
        IotCompanyDO companyDO = findById(id);
        if (companyDO==null){
        }
        String uname = userAgent.getUNAME();
        if (uname==null){
            companyDO.setAuditName("system");
        }
        companyDO.setStatus("1");
        companyDO.setAuditTime(DateUtil.getNowDate());
        companyDO.setAuditName(uname);
        iotCompanyDao.save(companyDO);
        return MixEnvelop.getSuccess("审核操作成功");
    }
    /**
     * 审核失败
     * @param id 企业ID
     * @param msg 拒绝说明
     * @return
     */
    public MixEnvelop auditCompany(String id,String msg) {
        IotCompanyDO companyDO = findById(id);
        if (companyDO==null){
            return MixEnvelop.getError("无该企业");
        }
        String uname = userAgent.getUNAME();
        if (uname==null){
            companyDO.setAuditName("system");
        }
        companyDO.setStatus("2");
        companyDO.setAuditTime(DateUtil.getNowDate());
        companyDO.setAuditMessage(msg);
        companyDO.setAuditName(uname);
        iotCompanyDao.save(companyDO);
        return MixEnvelop.getSuccess("审核操作成功");
    }
    /**
     * 根据入驻类型查找企业信息
     * @param entryCode 入驻类型
     * @return
     */
    public List<IotCompanyDO> findByEnterType(String entryCode) {
        List<IotCompanyDO> companyDOList = iotCompanyDao.findByEnterType(entryCode);
        for (IotCompanyDO companyDO : companyDOList) {
            List<IotCompanyTypeDO> typeList = iotCompanyTypeDao.findByCompanyId(companyDO.getId());
            companyDO.setTypeList(typeList);
        }
        return companyDOList;
    }
    /**
     * 查找所有企业
     * @param accountType 标识 1:厂商 0:平台
     * @return
     */
    public List<IotCompanyDO> findAll(String accountType) {
        List<IotCompanyDO> iotCompanyDOS = new ArrayList<>();
        if("1".equalsIgnoreCase(accountType)){
            iotCompanyDOS = iotCompanyDao.findByAccountType(accountType);
            for (IotCompanyDO iotCompanyDO : iotCompanyDOS) {
                List<IotCompanyTypeDO> companyTypeDOS = iotCompanyTypeDao.findByCompanyId(iotCompanyDO.getId());
                iotCompanyDO.setTypeList(companyTypeDOS);
            }
        }
        if ("0".equalsIgnoreCase(accountType)){
            Iterable<IotCompanyDO> companyDOS = iotCompanyDao.findByAccountType(accountType);
            for (IotCompanyDO companyDO : companyDOS) {
                List<IotCompanyAppDO> appDOList = iotCompanyAppDao.findByCompanyId(companyDO.getId());
                companyDO.setAppList(appDOList);
                iotCompanyDOS.add(companyDO);
            }
        }
        return iotCompanyDOS;
    }
}

+ 90 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/useragent/UserAgent.java

@ -0,0 +1,90 @@
package com.yihu.iot.service.useragent;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
 * 用户头部信息获取
 * Created by Trick on 2018/10/30.
 */
@Component
public class UserAgent {
    /**
     * 获取当前登录人ID
     * @return
     */
    public String getUID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            return json.getString("uid");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取登录人姓名
     * @return
     */
    public String getUNAME(){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            String info = json.getString("uname");
            String uname = java.net.URLDecoder.decode(info,"UTF-8");
            return uname;
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取角色ID
     * @return
     */
    public String getROLEID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSON.parseObject(userAgent);
            return json.getString("roleid");
        } catch (Exception e) {
            return null;
        }
    }
    public JSONObject getUserAgent(){
        try{
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            JSONObject user = JSON.parseObject(userAgent);
            return user;
        }catch (Exception e){
            return null;
        }
    }
}