Przeglądaj źródła

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

wangzhinan 1 miesiąc temu
rodzic
commit
2dd87e0014
26 zmienionych plików z 866 dodań i 579 usunięć
  1. 32 32
      business/base-service/src/main/java/com/yihu/jw/device/dao/DeviceDetailDao.java
  2. 10 10
      business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java
  3. 75 75
      business/base-service/src/main/java/com/yihu/jw/device/dao/PatientDeviceDao.java
  4. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java
  5. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatMenuController.java
  6. 2 2
      svr/svr-cloud-device/pom.xml
  7. 1 2
      svr/svr-cloud-device/src/main/java/com/yihu/SvrCloudDeviceApplication.java
  8. 0 17
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  9. 0 35
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  10. 1 0
      svr/svr-cloud-device/src/main/resources/application.yml
  11. 1 1
      svr/svr-cloud-job/pom.xml
  12. 10 0
      svr/svr-cloud-transfor/pom.xml
  13. 4 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/SvrCloudTransforApplication.java
  14. 106 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/TransforController.java
  15. 119 0
      svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/WeixinMchApi.java
  16. 1 9
      svr/svr-visit-behind/pom.xml
  17. 32 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/device/DeviceDetailDao.java
  18. 10 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/device/DevicePatientHealthIndexDao.java
  19. 75 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/device/PatientDeviceDao.java
  20. 376 376
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceUploadService.java
  21. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationPlanService.java
  22. 3 1
      svr/svr-visit-behind/src/main/resources/application.yml
  23. 2 1
      svr/svr-visit-behind/src/main/resources/system.properties
  24. 0 4
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java
  25. 1 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java
  26. 2 10
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

+ 32 - 32
business/base-service/src/main/java/com/yihu/jw/device/dao/DeviceDetailDao.java

@ -1,32 +1,32 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.DeviceDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * @author yeshijie on 2018/1/10.
 */
public interface DeviceDetailDao extends JpaRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {
    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
    List<DeviceDetail> findByDeviceCode(String deviceCode);
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
    @Query("select a from DeviceDetail a where a.sim = ?1")
    List<DeviceDetail> findBySim(String sim);
    @Query("select a from DeviceDetail a where a.iccid = ?1")
    List<DeviceDetail> findByIccid(String iccid);
    @Query("select a from DeviceDetail a where a.imsi = ?1")
    List<DeviceDetail> findByImsi(String sim);
}
//package com.yihu.jw.device.dao;
//
//import com.yihu.jw.entity.care.device.DeviceDetail;
//import org.springframework.data.jpa.repository.JpaRepository;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//
//import java.util.List;
//
///**
// * @author yeshijie on 2018/1/10.
// */
//public interface DeviceDetailDao extends JpaRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {
//
//    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
//    DeviceDetail findBySn(String sn);
//
//    List<DeviceDetail> findByDeviceCode(String deviceCode);
//
//    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
//    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
//
//    @Query("select a from DeviceDetail a where a.sim = ?1")
//    List<DeviceDetail> findBySim(String sim);
//
//    @Query("select a from DeviceDetail a where a.iccid = ?1")
//    List<DeviceDetail> findByIccid(String iccid);
//
//    @Query("select a from DeviceDetail a where a.imsi = ?1")
//    List<DeviceDetail> findByImsi(String sim);
//
//}

+ 10 - 10
business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java

@ -1,10 +1,10 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface DevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
}
//package com.yihu.jw.device.dao;
//
//import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//public interface DevicePatientHealthIndexDao
//		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
//
//}

+ 75 - 75
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientDeviceDao.java

@ -1,75 +1,75 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface PatientDeviceDao extends JpaRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    List<DevicePatientDevice> findByAll();
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<DevicePatientDevice> findByPatientAndDel(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<DevicePatientDevice> findByDeviceSn(String deviceSn);
    //更换患者绑定的血糖仪
    @Modifying
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    //管理员解绑居民设备
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 and t.del =0  ")
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Query("select a from DevicePatientDevice a group by a.user")
    List<DevicePatientDevice> findAllGroupUser();
    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1 and a.del=0 group by a.user")
    List<DevicePatientDevice> findAllByCategoryCode(String categoryCode);
    @Modifying
    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
    int deleteByDeviceSn(String deviceSN);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findAllByUserAndCategoryCode(String user,String categoryCode);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}
//package com.yihu.jw.device.dao;
//
//import com.yihu.jw.entity.care.device.DevicePatientDevice;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.jpa.repository.JpaRepository;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Modifying;
//import org.springframework.data.jpa.repository.Query;
//
//import java.util.List;
//
//public interface PatientDeviceDao extends JpaRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
//
//    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
//    Iterable<DevicePatientDevice> findByUser(String user);
//
//    @Query("select a from DevicePatientDevice a where a.del = 0 ")
//    List<DevicePatientDevice> findByAll();
//
//    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
//    List<DevicePatientDevice> findByPatient(String user);
//
//    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
//    List<DevicePatientDevice> findByPatientAndDel(String user);
//
//    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
//    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
//
//    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
//
//    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
//
//    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
//
//    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
//
//    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
//
//    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
//
//    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
//    List<DevicePatientDevice> findByDeviceSn(String deviceSn);
//
//    //更换患者绑定的血糖仪
//    @Modifying
//    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
//    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
//
//    //管理员解绑居民设备
//    @Modifying
//    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 and t.del =0  ")
//    int updatePatientDevice(String deviceSN);
//
//    @Query("select a from DevicePatientDevice a")
//    List<DevicePatientDevice> findAll();
//
//    @Query("select a from DevicePatientDevice a group by a.user")
//    List<DevicePatientDevice> findAllGroupUser();
//
//    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1 and a.del=0 group by a.user")
//    List<DevicePatientDevice> findAllByCategoryCode(String categoryCode);
//
//    @Modifying
//    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
//    int deleteByDeviceSn(String deviceSN);
//
//    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
//    List<DevicePatientDevice> findAllByUser(String user);
//
//    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
//    List<DevicePatientDevice> findAllByUserAndCategoryCode(String user,String categoryCode);
//
//    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
//    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
//}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java

@ -66,7 +66,7 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntity implements S
    private String thirdOrgCode;//自动下转的医院code wlyy_rehabilitation_patient_info的 hospital_code
    @Column(name = "event_type")
    private String eventType;//1或者空为住院  ,2为门诊
    private String eventType;//1为门诊  2或者空为住院
    public String getEventType() {
        return eventType;

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatMenuController.java

@ -46,7 +46,7 @@ public class WechatMenuController extends EnvelopRestEndpoint {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            String sql = "SELECT content from wx_menu_json WHERE id = 'weixin_menu'";
            String params = jdbcTemplate.queryForObject(sql,String.class);
            String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + wxAccessTokenDO.getAccessToken();
            String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + wxAccessTokenDO.getAccessToken();
            // 请求微信接口创建菜单
            String jsonStr = HttpUtil.sendPost(url, params);

+ 2 - 2
svr/svr-cloud-device/pom.xml

@ -81,7 +81,7 @@
        </dependency>
        <!-- Jzkl Starter -->
        <dependency>
            <groupId>com.yihu</groupId>
            <groupId>com.yihu.jw</groupId>
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
@ -172,7 +172,7 @@
    </dependencies>
    <build>
        <finalName>svr-cloud-device-test</finalName>
        <finalName>svr-cloud-device</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>

+ 1 - 2
svr/svr-cloud-device/src/main/java/com/yihu/SvrCloudDeviceApplication.java

@ -5,7 +5,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;
@ -20,7 +19,7 @@ import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableJpaAuditing
@EnableAsync
@ComponentScan("com.yihu")
//@ComponentScan("com.yihu")
public class SvrCloudDeviceApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {

+ 0 - 17
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -3,16 +3,13 @@ package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.DPatientDeviceDao;
import com.yihu.jw.care.dao.device.YsConfigDao;
import com.yihu.jw.care.util.DeviceDataPushLogUtil;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.YsConfigDo;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
@ -21,11 +18,9 @@ import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -53,21 +48,9 @@ public class YsDeviceService {
    private static Logger logger = LoggerFactory.getLogger(YsDeviceService.class);
    private Map<String,String> msgType = new HashMap<>();
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private DPatientDeviceDao DPatientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private SecurityOrderUtil orderUtil;
    @Autowired
    private StringRedisTemplate redisTemplate;

+ 0 - 35
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -8,7 +8,6 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.care.common.GetuiClientDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
@ -16,8 +15,6 @@ import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.push.dao.GetuiClientDao;
import com.yihu.jw.push.service.GetuiService;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
@ -68,10 +65,6 @@ public class MessageUtil {
    private BaseOrgDao orgDao;
    @Autowired
    private TXYSmsService txySmsService;
    @Autowired
    private GetuiService getuiService;
    @Autowired
    private GetuiClientDao getuiClientDao;
    /**
     * 您好{1}有一条新的在线报名申请,请及时前往APP消息应用进行处理。
@ -85,34 +78,6 @@ public class MessageUtil {
        }
    }
    /**
     * 发送医生个推推送消息
     * type 1 安防紧急预警 2紧急呼叫 4im 5生日祝福
     */
    public void sendDoctorGetuiMessage(String doctorCode,String type,String url,String title,String body){
        try {
            List<GetuiClientDO> clientDOS = getuiClientDao.findByUser(doctorCode,2);
            JSONObject payload = new JSONObject();
            payload.put("title",title);
            payload.put("body",body);
            payload.put("url",url);
            JSONObject json = new JSONObject();
            json.put("title",title);
            json.put("body",body);
            json.put("url",url);
//        json.put("clickType","url");
            json.put("platform",getuiService.cloudCareDoctor);
            json.put("payload",payload.toString());
            for(GetuiClientDO clientDO:clientDOS){
                getuiService.push2(clientDO.getClientId(),Integer.valueOf(clientDO.getClientType()),json);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     *
     * @param wechatId

+ 1 - 0
svr/svr-cloud-device/src/main/resources/application.yml

@ -198,6 +198,7 @@ spring:
  redis:
    host: 172.26.0.253 # Redis server host.
    port: 6379 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
fast-dfs:

+ 1 - 1
svr/svr-cloud-job/pom.xml

@ -70,7 +70,7 @@
        </dependency>
        <!-- Jzkl Starter -->
        <dependency>
            <groupId>com.yihu</groupId>
            <groupId>com.yihu.jw</groupId>
            <artifactId>swagger-starter</artifactId>
            <version>2.0.0</version>
        </dependency>

+ 10 - 0
svr/svr-cloud-transfor/pom.xml

@ -79,6 +79,16 @@
            <artifactId>tencentcloud-sdk-java</artifactId>
            <version>3.1.272</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
            <version>1.68</version>
        </dependency>
        <dependency>
            <groupId>com.github.wechatpay-apiv3</groupId>
            <artifactId>wechatpay-java</artifactId>
            <version>0.2.15</version>
        </dependency>
    </dependencies>
    <build>

+ 4 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/SvrCloudTransforApplication.java

@ -1,5 +1,6 @@
package com.yihu;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -7,6 +8,8 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import java.security.Security;
/**
 * Created by yeshijie on 2021/10/14.
 */
@ -16,6 +19,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
public class SvrCloudTransforApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {
        Security.addProvider(new BouncyCastleProvider());
        SpringApplication.run(SvrCloudTransforApplication.class, args);
    }

+ 106 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/controller/TransforController.java

@ -2,9 +2,14 @@ package com.yihu.jw.care.controller;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
import com.wechat.pay.java.service.transferbatch.model.TransferBatchEntity;
import com.wechat.pay.java.service.transferbatch.model.TransferDetailEntity;
import com.yihu.jw.care.RequestParamUtil;
import com.yihu.jw.care.service.AqgService;
import com.yihu.jw.care.service.TXYSmsService;
import com.yihu.jw.care.service.WeixinMchApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -36,8 +41,87 @@ public class TransforController {
    private AqgService aqgService;
    @Autowired
    private TXYSmsService txySmsService;
    @Autowired
    private WeixinMchApi weixinMchApi;
    private static final RestTemplate restTemplate = new RestTemplate();
    @ApiOperation("批量转账")
    @RequestMapping(value = "initiateBatchTransfer", method = {RequestMethod.POST,RequestMethod.GET})
    public String initiateBatchTransfer(
            @ApiParam(name="outBatchNo",required = true,value="批次no")
            @RequestParam(value = "outBatchNo",required = true) String outBatchNo,
            @ApiParam(name="batchName",required = true,value="批次名")
            @RequestParam(value = "batchName",required = true) String batchName,
            @ApiParam(name="batchRemark",required = true,value="批次备注")
            @RequestParam(value = "batchRemark",required = true) String batchRemark,
            @ApiParam(name="totalAmount",required = true,value="总费用单位分")
            @RequestParam(value = "totalAmount",required = true) Long totalAmount,
            @ApiParam(name="totalNum",required = true)
            @RequestParam(value = "totalNum",required = true) Integer totalNum,
            @ApiParam(name="outDetailNo",required = true)
            @RequestParam(value = "outDetailNo",required = true) String outDetailNo,
            @ApiParam(name="transferAmount",required = true)
            @RequestParam(value = "transferAmount",required = true) Long transferAmount,
            @ApiParam(name="transferRemark",required = true)
            @RequestParam(value = "transferRemark",required = true) String transferRemark,
            @ApiParam(name="openid",required = true,value="openid")
            @RequestParam(value = "openid",required = true) String openid) {
        try {
            //String outBatchNo,String batchName,String batchRemark
            //            ,Long totalAmount,Integer totalNum,String outDetailNo,Long transferAmount,String transferRemark,String openid
            InitiateBatchTransferResponse res = weixinMchApi.initiateBatchTransfer(outBatchNo,batchName,batchRemark
                    ,totalAmount,totalNum,outDetailNo,transferAmount,transferRemark,openid);
            return write(200,"res","data", res);
        }catch (ServiceException se){
            return write(-1,se.getErrorMessage(),"data", se.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"转账失败");
        }
    }
    @ApiOperation("通过微信批次单号查询批次单")
    @RequestMapping(value = "getTransferBatchByNo", method = {RequestMethod.POST,RequestMethod.GET})
    public String getTransferBatchByNo(
            @ApiParam(name="batchId",required = true,value="批次id")
            @RequestParam(value = "batchId",required = true) String batchId,
            @ApiParam(name="offset",required = true,value="请求资源起始位置")
            @RequestParam(value = "offset",required = true) Integer offset,
            @ApiParam(name="limit",required = true,value="最大资源条数")
            @RequestParam(value = "limit",required = true) Integer limit,
            @ApiParam(name="detailStatus",required = true,value="状态")
            @RequestParam(value = "detailStatus",required = true) String detailStatus) {
        try {
            //String batchId,Integer offset,Integer limit,String detailStatus
            TransferBatchEntity res = weixinMchApi.getTransferBatchByNo(batchId,offset,limit,detailStatus);
            return write(200,"res","data", res);
        }catch (ServiceException se){
            return write(-1,se.getErrorMessage(),"data", se.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("通过微信明细单号查询明细单")
    @RequestMapping(value = "getTransferDetailByNo", method = {RequestMethod.POST,RequestMethod.GET})
    public String getTransferDetailByNo(
            @ApiParam(name="batchId",required = true,value="批次id")
            @RequestParam(value = "batchId",required = true) String batchId,
            @ApiParam(name="detailId",required = true,value="明细id")
            @RequestParam(value = "detailId",required = true) String detailId) {
        try {
            TransferDetailEntity res = weixinMchApi.getTransferDetailByNo(batchId,detailId);
            return write(200,"res","data", res);
        }catch (ServiceException se){
            return write(-1,se.getErrorMessage(),"data", se.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("腾讯云短信发送")
    @RequestMapping(value = "txSendMessage", method = {RequestMethod.POST,RequestMethod.GET})
    public String txSendMessage(
@ -544,4 +628,26 @@ public class TransforController {
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
}

+ 119 - 0
svr/svr-cloud-transfor/src/main/java/com/yihu/jw/care/service/WeixinMchApi.java

@ -0,0 +1,119 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSONObject;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.service.transferbatch.TransferBatchService;
import com.wechat.pay.java.service.transferbatch.model.*;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * 微信商户支付api
 * Created by yeshijie on 2024/12/23.
 */
@Service
public class WeixinMchApi {
    //apiv3:15FB41D6808D16668E7A4F4BE251FD1CD25D7D01
    //apiv3:23FB41D6808D16668E7A4F4BE251FD1C
    public static String merchantId = "1635527638"; //商户号
//    public static String privateKeyPath = "D:\\jkzl\\patient-co-management\\patient-co\\patient-co-wlyy-job\\src\\main\\resources\\apiclient_key.pem"; //商户API私钥路径
    public static String privateKeyPath = "/usr/local/svr-cloud-transfor/resources/apiclient_key.pem"; //商户API私钥路径
    public static String merchantSerialNumber = "4B4EB542718B4C91DCCCB294D6BCA10DEF204C90"; //商户证书序列号
    public static String apiV3Key = "23FB41D6808D16668E7A4F4BE251FD1C";//商户APIV3密钥
    public static String appid = "wxad04e9c4c5255acf";//公众号appid
    public static String notifyUrl = "https://www.xmtyw.cn/wlyytest/wx/Openid/notifyUrl";//回调url
    public static TransferBatchService service;
    //批量转账
    public InitiateBatchTransferResponse initiateBatchTransfer(String outBatchNo,String batchName,String batchRemark
            ,Long totalAmount,Integer totalNum,String outDetailNo,Long transferAmount,String transferRemark,String openid) {
        Config config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3Key)
                .build();
        service = new TransferBatchService.Builder().config(config).build();
        InitiateBatchTransferRequest initiateBatchTransferRequest =
                new InitiateBatchTransferRequest();
        initiateBatchTransferRequest.setAppid(appid);
        initiateBatchTransferRequest.setOutBatchNo(outBatchNo);
        initiateBatchTransferRequest.setBatchName(batchName);
        initiateBatchTransferRequest.setBatchRemark(batchRemark);
        initiateBatchTransferRequest.setTotalAmount(totalAmount);
        initiateBatchTransferRequest.setTotalNum(totalNum);
        {
            List<TransferDetailInput> transferDetailListList = new ArrayList<>();
            {
                TransferDetailInput transferDetailInput = new TransferDetailInput();
                transferDetailInput.setOutDetailNo(outDetailNo);
                transferDetailInput.setTransferAmount(transferAmount);
                transferDetailInput.setTransferRemark(transferRemark);
                transferDetailInput.setOpenid(openid);
//                transferDetailInput.setUserName(
//                        "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45");
                transferDetailListList.add(transferDetailInput);
            }
            initiateBatchTransferRequest.setTransferDetailList(
                    transferDetailListList);
        }
//        initiateBatchTransferRequest.setTransferSceneId("1000");
//        initiateBatchTransferRequest.setNotifyUrl(notifyUrl);
        InitiateBatchTransferResponse response =
                service.initiateBatchTransfer(initiateBatchTransferRequest);
        System.out.println("response="+JSONObject.toJSONString(response));
        return response;
    }
    //通过微信批次单号查询批次单
    //response={"batchId":"131000011058801571449282024122378196572602","batchStatus":"FINISHED","createTime":"2024-12-23T16:52:14+08:00","outBatchNo":"plfk2020042013124"}
    public TransferBatchEntity getTransferBatchByNo(String batchId,Integer offset,Integer limit,String detailStatus) {
        Config config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3Key)
                .build();
        service = new TransferBatchService.Builder().config(config).build();
        GetTransferBatchByNoRequest request = new GetTransferBatchByNoRequest();
        request.setBatchId(batchId);
        request.setNeedQueryDetail(true);
        request.setOffset(offset);
        request.setLimit(limit);
//        request.setDetailStatus("ALL");
        request.setDetailStatus(detailStatus);
        TransferBatchEntity response = service.getTransferBatchByNo(request);
        System.out.println("response="+JSONObject.toJSONString(response));
        return response;
    }
    //通过微信明细单号查询明细单
    //response={"transferBatch":{"appid":"wxad04e9c4c5255acf","batchId":"131000011058801571449282024122378196572602","batchName":"2024年test","batchRemark":"2024年test","batchStatus":"PROCESSING","batchType":"API","createTime":"2024-12-23T16:52:14+08:00","mchid":"1635527638","outBatchNo":"plfk2020042013124","successAmount":0,"successNum":0,"totalAmount":10,"totalNum":1,"transferSceneId":"1000","updateTime":"2024-12-23T16:52:18+08:00"},
    // "transferDetailList":[{"detailId":"132000011058801571449282024122333730580117","detailStatus":"WAIT_PAY","outDetailNo":"x23zy545Bd5436124"}]}
    public static TransferDetailEntity getTransferDetailByNo(String batchId,String detailId) {
        Config config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3Key)
                .build();
        service = new TransferBatchService.Builder().config(config).build();
        GetTransferDetailByNoRequest request = new GetTransferDetailByNoRequest();
        request.setBatchId(batchId);
        request.setDetailId(detailId);
        TransferDetailEntity response = service.getTransferDetailByNo(request);
        System.out.println("response="+JSONObject.toJSONString(response));
        //response={"appid":"wxad04e9c4c5255acf","batchId":"131000011058801571449282024122378196572602","detailId":"132000011058801571449282024122333730580117"
        // ,"detailStatus":"FAIL","failReason":"MERCHANT_REJECT","mchid":"1635527638","openid":"oULM4xNKlVPF9uarzycGbiI23L6I","outBatchNo":"plfk2020042013124"
        // ,"outDetailNo":"x23zy545Bd5436124","transferAmount":10,"transferRemark":"测试费用","updateTime":"2024-12-23T16:56:35+08:00"}
        return response;
    }
}

+ 1 - 9
svr/svr-visit-behind/pom.xml

@ -46,15 +46,7 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <!--注释掉就不会读取git的配置,只会读取yml中的配置-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>

+ 32 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/device/DeviceDetailDao.java

@ -0,0 +1,32 @@
package com.yihu.jw.hospital.module.device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * @author yeshijie on 2018/1/10.
 */
public interface DeviceDetailDao extends JpaRepository<DeviceDetail, Long>, JpaSpecificationExecutor<DeviceDetail> {
    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
    List<DeviceDetail> findByDeviceCode(String deviceCode);
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
    @Query("select a from DeviceDetail a where a.sim = ?1")
    List<DeviceDetail> findBySim(String sim);
    @Query("select a from DeviceDetail a where a.iccid = ?1")
    List<DeviceDetail> findByIccid(String iccid);
    @Query("select a from DeviceDetail a where a.imsi = ?1")
    List<DeviceDetail> findByImsi(String sim);
}

+ 10 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/device/DevicePatientHealthIndexDao.java

@ -0,0 +1,10 @@
package com.yihu.jw.hospital.module.device;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface DevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
}

+ 75 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/device/PatientDeviceDao.java

@ -0,0 +1,75 @@
package com.yihu.jw.hospital.module.device;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface PatientDeviceDao extends JpaRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    List<DevicePatientDevice> findByAll();
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<DevicePatientDevice> findByPatientAndDel(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<DevicePatientDevice> findByDeviceSn(String deviceSn);
    //更换患者绑定的血糖仪
    @Modifying
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    //管理员解绑居民设备
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 and t.del =0  ")
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Query("select a from DevicePatientDevice a group by a.user")
    List<DevicePatientDevice> findAllGroupUser();
    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1 and a.del=0 group by a.user")
    List<DevicePatientDevice> findAllByCategoryCode(String categoryCode);
    @Modifying
    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
    int deleteByDeviceSn(String deviceSN);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findAllByUserAndCategoryCode(String user,String categoryCode);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}

+ 376 - 376
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/DeviceUploadService.java

@ -1,376 +1,376 @@
package com.yihu.jw.hospital.module.health.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.device.dao.DeviceDetailDao;
import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
import com.yihu.jw.device.dao.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.hospital.module.health.controller.Result;
import com.yihu.jw.hospital.module.iot.service.IotDeviceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/7/7.
 */
@Service
public class DeviceUploadService {
    private static Logger logger = LoggerFactory.getLogger(DeviceUploadService.class);
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private IotDeviceService iotDeviceService;
    public void deviceRegistration(String deviceSn, String deviceModel, String deviceName, String categoryCode, String categoryName) {
        try {
            iotDeviceService.deviceRegistration(deviceSn,deviceModel,deviceName,categoryCode,categoryName);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public Result uploadDevicesData(String dataJson, HttpServletRequest request)throws Exception {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String, Object> map = objectMapper.readValue(dataJson, Map.class);
            String deviceSn = map.get("deviceSn").toString();//设备唯一码
            Integer deviceType = Integer.parseInt(map.get("deviceType").toString());//设备类型1:血压 2:血糖
            String data = map.get("data").toString();//体征值(血糖:data=血糖值   血压:data=收缩压,舒张压,脉搏)
            String uploadTime = map.get("uploadTime").toString();//体征上传时间yyyy-MM-dd HH:mm:ss
            String manufacturerCode = map.get("manufacturerCode").toString();//厂商代码
            String manufacturerName = map.get("manufacturerName").toString();//厂商名称
            String unit = map.get("unit").toString();//单位mmol/L,mmHg
            String sendTime = map.get("sendTime").toString();//发送时间yyyy-MM-dd HH:mm:ss
            String userType = map.get("button").toString();//按键号 即 userType
            String measurementType=null==map.get("measurementType")?"":map.get("measurementType").toString(); //单个设备的测量类型,deviceType=4智能手表:1心率,2血压
            String paraString = JSON.toJSONString(request.getParameterMap());
            JSONObject json = new JSONObject();
            json.put("deviceSn", deviceSn);
            json.put("deviceType", deviceType);
            json.put("data", data);
            json.put("uploadTime", uploadTime);//三诺的上传时间
            json.put("manufacturerCode", manufacturerCode);
            json.put("manufacturerName", manufacturerName);
            json.put("unit", unit);
            json.put("sendTime", sendTime);//三诺的测量时间
            json.put("userType", userType);
            json.put("measurementType", measurementType);
            String type = deviceType + "";
            if (1 == deviceType) {
                type = "2";
            } else if (2 == deviceType) {
                type = "1";
                userType = "-1";
            }
//            DeviceInfo deviceInfo = new DeviceInfo();
//            deviceInfo.setDeviceData(dataJson);
//            deviceInfo.setDeviceType(type);
//            deviceInfo.setPushDate(DateUtil.getNowTimestamp());
//            deviceInfo.setStatus("1");
//            deviceInfoDao.save(deviceInfo);
            DevicePatientHealthIndex result = null;
            if(type.equalsIgnoreCase("1")){
                if (Double.parseDouble(data)>=1){
                    result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json,measurementType);
                }else {
                    logger.info("This blood device data below 1.0:====="+dataJson);
                    throw new Exception("This blood device data below 1.0 ");
                }
            }else {
                result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json,measurementType);
            }
            if (result == null) {
                logger.info("This device is not relate patient!:====="+dataJson);
                throw new Exception("This device is not relate patient!");
            }
//            dataPushLogUtil.savePushLog(deviceSn,paraString,"体征数据接收");
//            dataPushLogUtil.updContactStatus(deviceSn,1,false);
            iotDeviceService.uploadDeviceData(result.getId());
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return Result.success("Device data incoming success");
    }
    /**
     * 保存设备数据
     * @param type 设备类型 4 智能手表
     * @param userType 用户身份:-1 单用户
     * @param measurementType 单设备多功能类型 type=4时,measurementType=1心率,measurementType=2血压
     */
    public DevicePatientHealthIndex savePatientDeviceData(String deviceSn, String type, String data, String uploadTime, String userType, JSONObject json, String measurementType) throws Exception {
        Date currentTime = DateUtil.getNowTimestamp();
        Date time = currentTime;
        if (!StringUtil.isEmpty(uploadTime)) {
            //设备重新开机启动会有默认时间,相隔很远.
            time = DateUtil.toTimestamp(uploadTime, DateUtil.YYYY_MM_DD_HH_MM_SS);
            Date monthTime = DateUtil.getNextMonthReturnDate( currentTime,-12);
            if (DateUtil.compareDate(time, monthTime) < 0) {
                time = currentTime;
            }
        }
        if (StringUtil.isStrEmpty(userType)) {
            userType = "-1";
        }
        DevicePatientDevice device = null;
        DeviceDetail deviceDetail = null;
        List<DeviceDetail> deviceDetails = deviceDetailDao.findByDeviceCode(deviceSn);
        if (deviceDetails != null || deviceDetails.size()!=0){
            deviceDetail = deviceDetails.get(0);
            if (deviceDetail.getGrantOrgCode() != null&& deviceDetail.getGrantOrgCode().equals("3502050300")){//
                List<DevicePatientDevice> patientDeviceList =  patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (patientDeviceList != null&&patientDeviceList.size()==1) {
                    device = patientDeviceList.get(0);
                }else if(patientDeviceList != null&&patientDeviceList.size()==2){
                    for (int i=0;i<patientDeviceList.size();i++){
                        if(userType.equals(patientDeviceList.get(i).getUserType())){
                            device = patientDeviceList.get(i);
                            break;
                        }
                    }
                }
            }else {
//                device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
                List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (devices.size()>0){
                    device = devices.get(0);
                }else {
                    device=null;
                }
            }
        }
        if (device != null) {
        /*//根据设备获取患者(设备只绑定一个人的时候,不判断按键)
        if (device!=null) {*/
            /************设备数据重复推送处理 start**********************/
            String value1 = data;
            String value2="";
            String value3="";
            if("2".equals(type)){
                String[] value = data.split(",");
                if (value.length > 0) {
                    value1 = value[0];     //收缩压
                    value2 = value[1];
                    value3 = value[2];
                }
            }else if("4".equals(type)){
                if(StringUtils.isNotBlank(measurementType)&&"2".equals(measurementType)){
                    type="2";
                    String[] value = data.split(",");
                    if (value.length > 0) {
                        value1 = value[0];     //收缩压
                        value2 = value[1];
                        /* value3 = value[2];*/
                    }
                }else {
                    //心率
                    type="5";
                }
            }
            if (value1.equals(value2) && value2.equals(value3)){
                return null;
            }
//            List<PatientHealthIndex> list = patientHealthIndexDao.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
            /*long maxtime = time.getTime()+30*1000;
            long mintime = time.getTime()-30*1000;*/
            Date minDate = DateUtil.getPreDays(time,-3);
            Date maxDate = DateUtil.getPreDays(time,3);
            List<DevicePatientHealthIndex> list = ioTfindByType(device.getUser(),deviceSn,value1,value2,value3,Integer.parseInt(type),time,minDate,maxDate);
            if(list!=null&&list.size()>0){
                return null;
            }
            /************设备数据重复推送处理 end**********************/
            DevicePatientHealthIndex obj = new DevicePatientHealthIndex();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            obj.setCzrq(sdf.parse(json.getString("sendTime")));//创建时间取三诺的测量时间记录
            obj.setDeviceSn(deviceSn);
            obj.setDel("1");
            obj.setRecordDate(sdf.parse(json.getString("uploadTime")));    //记录时间取上传时间
            obj.setSortDate(time);      //排序时间
//            obj.setManageResult(0);//默认数据是医生未干预状态
            String user = device.getUser();
            obj.setUser(user);
//            obj.setButton(userType);
            obj.setIdcard(device.getUserIdcard());
            obj.setStatus(0);
            //  1血糖 2血压 3体重 4腰围,5心率
            switch (type) {
                case "1":
                    obj.setType(1);
                    obj.setValue1(data);     //血糖值
                    obj.setValue2(formatBloodSuger(user,deviceSn,DateUtil.dateToStr(time, DateUtil.YYYY_MM_DD_HH_MM_SS)));
                    break;
                case "2":
                    obj.setType(2);
                    String[] value = data.split(",");
                    if (value.length > 0) {
                        obj.setValue1(value[0]);     //收缩压
                    }
                    if (value.length > 1) {
                        obj.setValue2(value[1]);     //舒张压
                    }
                    if (value.length > 2) {
                        obj.setValue3(value[2]);     //脉搏
                    }
                    if (value.length > 3) {
                        obj.setValue4(value[3]);     //有无心率不齐
                    }
                    break;
                case "3":
                    obj.setType(3);
                    obj.setValue1(data); //体重
                    break;
                case "4":
                    obj.setType(4);
                    obj.setValue1(data);  //腰围
                    break;
                case "5":
                    obj.setType(5);
                    obj.setValue1(data);  //心率
                    break;
                default:
                    throw new Exception("Can not support the metric!");
            }
            //新增字段处理
            BasePatientDO patient = patientDao.findById(user);
            if(patient!=null){
                obj.setName(patient.getName());
            }
            if(deviceDetail!=null){
                obj.setHospital(deviceDetail.getGrantOrgCode());
                obj.setHospitalName(deviceDetail.getOrgName());
            }
            obj = patientHealthIndexDao.save(obj);
            return obj;
        }
        return null;
    }
    /**
     * 查找重复数据
     * @param user
     * @param deviceSn
     * @param value1
     * @param type
     * @param time
     * @return
     */
    public List<DevicePatientHealthIndex> ioTfindByType(String user,String deviceSn,String value1,String value2,String value3,Integer type,Date time,Date timeMin,Date timeMax){
        List<DevicePatientHealthIndex> list = new ArrayList<>();
        String sql = "";
        String startTime = DateUtil.dateToStrLong(timeMin);
        String endTime = DateUtil.dateToStrLong(timeMax);
        if (type==1){
            sql = "select a.* from wlyy_patient_health_index a where a.user = '"+user+"' and a.device_sn = '"+deviceSn+"' " +
                   "and a.value1 = '"+value1+"' and a.type = "+type+" and a.record_date >= '"+startTime+"' and a.record_date<='"+endTime+"' and a.del = '1' ";
        }else if (type==2){
           sql = "select a.* from wlyy_patient_health_index a where a.user = '"+user+"' and a.device_sn = '"+deviceSn+"' " +
                   "and a.value1 = '"+value1+"' and a.value2='"+value2+"'  and a.value3='"+value3+"' and a.type = "+type+" " +
                   "and a.record_date >= '"+startTime+"' and a.record_date<='"+endTime+"' and a.del = '1' ";
        }
        list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
        return list;
    }
    /**
     * 血糖测量时间段
     * @param user
     * @param deviceSN
     * @param dateTime
     * @return
     */
    private String formatBloodSuger(String user,String deviceSN,String dateTime) {
        String fastingStart = "00:00:00";
        String fastingEnd = "07:59:59";
        String afterBreakFastStart = "08:00:00";
        String afterBreakFastEnd = "09:59:59";
        String beforeLunchStart = "10:00:00";
        String beforeLunchEnd = "11:59:59";
        String afterLunchStart = "12:00:00";
        String afterLunchEnd = "13:59:59";
        String beforeDinnerStart = "14:00:00";
        String beforeDinnerEnd = "17:59:59";
        String afterDinnerStart = "18:00:00";
        String afterDinnerEnd = "19:59:59";
        String beforeSleepStart = "20:00:00";
        String beforeSleepEnd = "23:59:59";
        if (isInArea(dateTime, fastingStart,fastingEnd)) {
            return "1";//"空腹血糖"
        }
        if (isInArea(dateTime, afterBreakFastStart,afterBreakFastEnd)) {
            return "2";//"早餐后血糖"
        }
        if (isInArea(dateTime, beforeLunchStart,beforeLunchEnd)) {
            return "3";//"午餐前血糖"
        }
        if (isInArea(dateTime, afterLunchStart,afterLunchEnd)) {
            return "4";//"午餐后血糖"
        }
        if (isInArea(dateTime, beforeDinnerStart,beforeDinnerEnd)) {
            return "5";//"晚餐前血糖"
        }
        if (isInArea(dateTime, afterDinnerStart,afterDinnerEnd)) {
            return "6";//"晚餐后血糖"
        }
        if (isInArea(dateTime, beforeSleepStart,beforeSleepEnd)) {
            return "7";//"睡前血糖"
        }
        return "1";//"空腹血糖"
    }
    // 判断时间是否在对应时间段
    private Boolean isInArea(String time,String begin,String end) {
        String date = DateUtil.getDateFromDateTime(time);
        Long beginTime = DateUtil.compareDateTime(DateUtil.toTimestamp(time), DateUtil.toTimestamp(date + " " + begin ));
        Long endTime = DateUtil.compareDateTime(DateUtil.toTimestamp(time), DateUtil.toTimestamp(date + " " + end ));
        if (beginTime > 0 && endTime < 0) {
            return true;
        } else {
            return false;
        }
    }
}
//package com.yihu.jw.hospital.module.health.service;
//
//import com.alibaba.fastjson.JSON;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.yihu.jw.device.dao.DeviceDetailDao;
//import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
//import com.yihu.jw.device.dao.PatientDeviceDao;
//import com.yihu.jw.entity.base.patient.BasePatientDO;
//import com.yihu.jw.entity.care.device.DeviceDetail;
//import com.yihu.jw.entity.care.device.DevicePatientDevice;
//import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
//import com.yihu.jw.hospital.module.health.controller.Result;
//import com.yihu.jw.hospital.module.iot.service.IotDeviceService;
//import com.yihu.jw.patient.dao.BasePatientDao;
//import com.yihu.jw.util.date.DateUtil;
//import com.yihu.jw.utils.StringUtil;
//import net.sf.json.JSONObject;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//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 javax.servlet.http.HttpServletRequest;
//import java.text.SimpleDateFormat;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by Bing on 2021/7/7.
// */
//@Service
//public class DeviceUploadService {
//    private static Logger logger = LoggerFactory.getLogger(DeviceUploadService.class);
//
//    @Autowired
//    private BasePatientDao patientDao;
//    @Autowired
//    private DeviceDetailDao deviceDetailDao;
//    @Autowired
//    private PatientDeviceDao patientDeviceDao;
//    @Autowired
//    private DevicePatientHealthIndexDao patientHealthIndexDao;
//    @Autowired
//    private JdbcTemplate jdbcTemplate;
//    @Autowired
//    private IotDeviceService iotDeviceService;
//
//    public void deviceRegistration(String deviceSn, String deviceModel, String deviceName, String categoryCode, String categoryName) {
//        try {
//            iotDeviceService.deviceRegistration(deviceSn,deviceModel,deviceName,categoryCode,categoryName);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//
//    public Result uploadDevicesData(String dataJson, HttpServletRequest request)throws Exception {
//        try {
//            ObjectMapper objectMapper = new ObjectMapper();
//            Map<String, Object> map = objectMapper.readValue(dataJson, Map.class);
//
//            String deviceSn = map.get("deviceSn").toString();//设备唯一码
//            Integer deviceType = Integer.parseInt(map.get("deviceType").toString());//设备类型1:血压 2:血糖
//            String data = map.get("data").toString();//体征值(血糖:data=血糖值   血压:data=收缩压,舒张压,脉搏)
//            String uploadTime = map.get("uploadTime").toString();//体征上传时间yyyy-MM-dd HH:mm:ss
//            String manufacturerCode = map.get("manufacturerCode").toString();//厂商代码
//            String manufacturerName = map.get("manufacturerName").toString();//厂商名称
//            String unit = map.get("unit").toString();//单位mmol/L,mmHg
//            String sendTime = map.get("sendTime").toString();//发送时间yyyy-MM-dd HH:mm:ss
//            String userType = map.get("button").toString();//按键号 即 userType
//            String measurementType=null==map.get("measurementType")?"":map.get("measurementType").toString(); //单个设备的测量类型,deviceType=4智能手表:1心率,2血压
//            String paraString = JSON.toJSONString(request.getParameterMap());
//
//            JSONObject json = new JSONObject();
//            json.put("deviceSn", deviceSn);
//            json.put("deviceType", deviceType);
//            json.put("data", data);
//            json.put("uploadTime", uploadTime);//三诺的上传时间
//            json.put("manufacturerCode", manufacturerCode);
//            json.put("manufacturerName", manufacturerName);
//            json.put("unit", unit);
//            json.put("sendTime", sendTime);//三诺的测量时间
//            json.put("userType", userType);
//            json.put("measurementType", measurementType);
//
//            String type = deviceType + "";
//            if (1 == deviceType) {
//                type = "2";
//            } else if (2 == deviceType) {
//                type = "1";
//                userType = "-1";
//            }
////            DeviceInfo deviceInfo = new DeviceInfo();
////            deviceInfo.setDeviceData(dataJson);
////            deviceInfo.setDeviceType(type);
////            deviceInfo.setPushDate(DateUtil.getNowTimestamp());
////            deviceInfo.setStatus("1");
////            deviceInfoDao.save(deviceInfo);
//
//            DevicePatientHealthIndex result = null;
//            if(type.equalsIgnoreCase("1")){
//                if (Double.parseDouble(data)>=1){
//                    result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json,measurementType);
//                }else {
//                    logger.info("This blood device data below 1.0:====="+dataJson);
//                    throw new Exception("This blood device data below 1.0 ");
//                }
//            }else {
//                result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json,measurementType);
//            }
//            if (result == null) {
//                logger.info("This device is not relate patient!:====="+dataJson);
//                throw new Exception("This device is not relate patient!");
//            }
////            dataPushLogUtil.savePushLog(deviceSn,paraString,"体征数据接收");
////            dataPushLogUtil.updContactStatus(deviceSn,1,false);
//            iotDeviceService.uploadDeviceData(result.getId());
//        } catch (Exception e) {
//            e.printStackTrace();
//            logger.error(e.getMessage());
//        }
//
//        return Result.success("Device data incoming success");
//    }
//
//    /**
//     * 保存设备数据
//     * @param type 设备类型 4 智能手表
//     * @param userType 用户身份:-1 单用户
//     * @param measurementType 单设备多功能类型 type=4时,measurementType=1心率,measurementType=2血压
//     */
//    public DevicePatientHealthIndex savePatientDeviceData(String deviceSn, String type, String data, String uploadTime, String userType, JSONObject json, String measurementType) throws Exception {
//        Date currentTime = DateUtil.getNowTimestamp();
//        Date time = currentTime;
//        if (!StringUtil.isEmpty(uploadTime)) {
//            //设备重新开机启动会有默认时间,相隔很远.
//            time = DateUtil.toTimestamp(uploadTime, DateUtil.YYYY_MM_DD_HH_MM_SS);
//            Date monthTime = DateUtil.getNextMonthReturnDate( currentTime,-12);
//            if (DateUtil.compareDate(time, monthTime) < 0) {
//                time = currentTime;
//            }
//        }
//        if (StringUtil.isStrEmpty(userType)) {
//            userType = "-1";
//        }
//        DevicePatientDevice device = null;
//        DeviceDetail deviceDetail = null;
//        List<DeviceDetail> deviceDetails = deviceDetailDao.findByDeviceCode(deviceSn);
//        if (deviceDetails != null || deviceDetails.size()!=0){
//            deviceDetail = deviceDetails.get(0);
//            if (deviceDetail.getGrantOrgCode() != null&& deviceDetail.getGrantOrgCode().equals("3502050300")){//
//                List<DevicePatientDevice> patientDeviceList =  patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
//                if (patientDeviceList != null&&patientDeviceList.size()==1) {
//                    device = patientDeviceList.get(0);
//                }else if(patientDeviceList != null&&patientDeviceList.size()==2){
//                    for (int i=0;i<patientDeviceList.size();i++){
//                        if(userType.equals(patientDeviceList.get(i).getUserType())){
//                            device = patientDeviceList.get(i);
//                            break;
//                        }
//                    }
//                }
//            }else {
////                device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
//                List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
//                if (devices.size()>0){
//                    device = devices.get(0);
//                }else {
//                    device=null;
//                }
//            }
//        }
//        if (device != null) {
//
//        /*//根据设备获取患者(设备只绑定一个人的时候,不判断按键)
//
//        if (device!=null) {*/
//            /************设备数据重复推送处理 start**********************/
//            String value1 = data;
//            String value2="";
//            String value3="";
//            if("2".equals(type)){
//                String[] value = data.split(",");
//                if (value.length > 0) {
//                    value1 = value[0];     //收缩压
//                    value2 = value[1];
//                    value3 = value[2];
//                }
//            }else if("4".equals(type)){
//                if(StringUtils.isNotBlank(measurementType)&&"2".equals(measurementType)){
//                    type="2";
//                    String[] value = data.split(",");
//                    if (value.length > 0) {
//                        value1 = value[0];     //收缩压
//                        value2 = value[1];
//                        /* value3 = value[2];*/
//                    }
//                }else {
//                    //心率
//                    type="5";
//                }
//            }
//
//            if (value1.equals(value2) && value2.equals(value3)){
//                return null;
//            }
////            List<PatientHealthIndex> list = patientHealthIndexDao.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
//            /*long maxtime = time.getTime()+30*1000;
//            long mintime = time.getTime()-30*1000;*/
//            Date minDate = DateUtil.getPreDays(time,-3);
//            Date maxDate = DateUtil.getPreDays(time,3);
//            List<DevicePatientHealthIndex> list = ioTfindByType(device.getUser(),deviceSn,value1,value2,value3,Integer.parseInt(type),time,minDate,maxDate);
//            if(list!=null&&list.size()>0){
//                return null;
//            }
//            /************设备数据重复推送处理 end**********************/
//
//            DevicePatientHealthIndex obj = new DevicePatientHealthIndex();
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            obj.setCzrq(sdf.parse(json.getString("sendTime")));//创建时间取三诺的测量时间记录
//            obj.setDeviceSn(deviceSn);
//            obj.setDel("1");
//            obj.setRecordDate(sdf.parse(json.getString("uploadTime")));    //记录时间取上传时间
//            obj.setSortDate(time);      //排序时间
////            obj.setManageResult(0);//默认数据是医生未干预状态
//            String user = device.getUser();
//
//            obj.setUser(user);
////            obj.setButton(userType);
//            obj.setIdcard(device.getUserIdcard());
//            obj.setStatus(0);
//            //  1血糖 2血压 3体重 4腰围,5心率
//            switch (type) {
//                case "1":
//                    obj.setType(1);
//                    obj.setValue1(data);     //血糖值
//                    obj.setValue2(formatBloodSuger(user,deviceSn,DateUtil.dateToStr(time, DateUtil.YYYY_MM_DD_HH_MM_SS)));
//                    break;
//                case "2":
//                    obj.setType(2);
//                    String[] value = data.split(",");
//                    if (value.length > 0) {
//                        obj.setValue1(value[0]);     //收缩压
//                    }
//                    if (value.length > 1) {
//                        obj.setValue2(value[1]);     //舒张压
//                    }
//                    if (value.length > 2) {
//                        obj.setValue3(value[2]);     //脉搏
//                    }
//                    if (value.length > 3) {
//                        obj.setValue4(value[3]);     //有无心率不齐
//                    }
//                    break;
//                case "3":
//                    obj.setType(3);
//                    obj.setValue1(data); //体重
//                    break;
//                case "4":
//                    obj.setType(4);
//                    obj.setValue1(data);  //腰围
//                    break;
//                case "5":
//                    obj.setType(5);
//                    obj.setValue1(data);  //心率
//                    break;
//                default:
//                    throw new Exception("Can not support the metric!");
//            }
//            //新增字段处理
//            BasePatientDO patient = patientDao.findById(user);
//            if(patient!=null){
//                obj.setName(patient.getName());
//            }
//            if(deviceDetail!=null){
//                obj.setHospital(deviceDetail.getGrantOrgCode());
//                obj.setHospitalName(deviceDetail.getOrgName());
//            }
//
//            obj = patientHealthIndexDao.save(obj);
//            return obj;
//        }
//        return null;
//    }
//
//    /**
//     * 查找重复数据
//     * @param user
//     * @param deviceSn
//     * @param value1
//     * @param type
//     * @param time
//     * @return
//     */
//    public List<DevicePatientHealthIndex> ioTfindByType(String user,String deviceSn,String value1,String value2,String value3,Integer type,Date time,Date timeMin,Date timeMax){
//
//        List<DevicePatientHealthIndex> list = new ArrayList<>();
//        String sql = "";
//        String startTime = DateUtil.dateToStrLong(timeMin);
//        String endTime = DateUtil.dateToStrLong(timeMax);
//        if (type==1){
//            sql = "select a.* from wlyy_patient_health_index a where a.user = '"+user+"' and a.device_sn = '"+deviceSn+"' " +
//                   "and a.value1 = '"+value1+"' and a.type = "+type+" and a.record_date >= '"+startTime+"' and a.record_date<='"+endTime+"' and a.del = '1' ";
//        }else if (type==2){
//           sql = "select a.* from wlyy_patient_health_index a where a.user = '"+user+"' and a.device_sn = '"+deviceSn+"' " +
//                   "and a.value1 = '"+value1+"' and a.value2='"+value2+"'  and a.value3='"+value3+"' and a.type = "+type+" " +
//                   "and a.record_date >= '"+startTime+"' and a.record_date<='"+endTime+"' and a.del = '1' ";
//        }
//        list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
//        return list;
//
//    }
//
//    /**
//     * 血糖测量时间段
//     * @param user
//     * @param deviceSN
//     * @param dateTime
//     * @return
//     */
//    private String formatBloodSuger(String user,String deviceSN,String dateTime) {
//        String fastingStart = "00:00:00";
//        String fastingEnd = "07:59:59";
//        String afterBreakFastStart = "08:00:00";
//        String afterBreakFastEnd = "09:59:59";
//        String beforeLunchStart = "10:00:00";
//        String beforeLunchEnd = "11:59:59";
//        String afterLunchStart = "12:00:00";
//        String afterLunchEnd = "13:59:59";
//        String beforeDinnerStart = "14:00:00";
//        String beforeDinnerEnd = "17:59:59";
//        String afterDinnerStart = "18:00:00";
//        String afterDinnerEnd = "19:59:59";
//        String beforeSleepStart = "20:00:00";
//        String beforeSleepEnd = "23:59:59";
//        if (isInArea(dateTime, fastingStart,fastingEnd)) {
//            return "1";//"空腹血糖"
//        }
//        if (isInArea(dateTime, afterBreakFastStart,afterBreakFastEnd)) {
//            return "2";//"早餐后血糖"
//        }
//        if (isInArea(dateTime, beforeLunchStart,beforeLunchEnd)) {
//            return "3";//"午餐前血糖"
//        }
//        if (isInArea(dateTime, afterLunchStart,afterLunchEnd)) {
//            return "4";//"午餐后血糖"
//        }
//        if (isInArea(dateTime, beforeDinnerStart,beforeDinnerEnd)) {
//            return "5";//"晚餐前血糖"
//        }
//        if (isInArea(dateTime, afterDinnerStart,afterDinnerEnd)) {
//            return "6";//"晚餐后血糖"
//        }
//        if (isInArea(dateTime, beforeSleepStart,beforeSleepEnd)) {
//            return "7";//"睡前血糖"
//        }
//
//        return "1";//"空腹血糖"
//    }
//
//    // 判断时间是否在对应时间段
//    private Boolean isInArea(String time,String begin,String end) {
//        String date = DateUtil.getDateFromDateTime(time);
//        Long beginTime = DateUtil.compareDateTime(DateUtil.toTimestamp(time), DateUtil.toTimestamp(date + " " + begin ));
//        Long endTime = DateUtil.compareDateTime(DateUtil.toTimestamp(time), DateUtil.toTimestamp(date + " " + end ));
//        if (beginTime > 0 && endTime < 0) {
//            return true;
//        } else {
//            return false;
//        }
//    }
//}

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationPlanService.java

@ -580,7 +580,7 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
    public RehabilitationPlanTemplateDO changeState(ParamQvo qvo) {
        RehabilitationPlanTemplateDO entity = templateDao.findOne(qvo.getId());
        if (entity != null) {
            entity.setStatus(qvo.getStatus());
//            entity.setStatus(qvo.getStatus());
            templateDao.save(entity);
            return entity;
        }

+ 3 - 1
svr/svr-visit-behind/src/main/resources/application.yml

@ -2,7 +2,9 @@
server:
  port: 10302
spring:
#spring:
#  application:
#    name: svr-visit-behind
  aop:
    proxy-target-class: true
  datasource:

+ 2 - 1
svr/svr-visit-behind/src/main/resources/system.properties

@ -12,7 +12,8 @@ key.read.type=0
#authorization.code=1ERSRATH80010100007F0000E43BC68D
###prod
gateway_url = http://192.168.120.103:6021/
#gateway_url = http://192.168.120.103:6021/
gateway_url = http://10.95.21.21:18280/
gateway_licence = 1E72F34S509433155F0A0000C0FAAB96
gateway_public_key = PublicGov.key
jw_hospital = 350211A1049

+ 0 - 4
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java

@ -1,6 +1,5 @@
package com.yihu.jw.controller.rehabilitation;
import com.yihu.jw.dao.rehabilitation.RehabilitationOperateRecordsDao;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -16,7 +15,6 @@ import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -31,8 +29,6 @@ public class RehabilitationManageController {
    private RehabilitationManageService rehabilitationManageService;
    @Autowired
    private Tracer tracer;
    @Autowired
    private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao;
    @GetMapping(value = SpecialistMapping.rehabilitation.findRehabilitationPlanList)
    @ApiOperation(value = "康复管理-康复计划列表")

Plik diff jest za duży
+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java


+ 2 - 10
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -129,15 +129,12 @@ public class RehabilitationManageService {
        sql += " ORDER BY p.create_time DESC LIMIT " + (page - 1) * pageSize + "," + pageSize;
        List<Map<String, Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> resultList = new ArrayList<>();
        Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "00:00:00");
        Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "23:59:59");
        if (patientRehabilitationPlanDOList.size() > 0 && patientRehabilitationPlanDOList.get(0).get("id") != null) {
            for (Map<String, Object> one : patientRehabilitationPlanDOList) {
                Map<String, Object> resultMap = new HashMap<>();
//                Integer age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
//                String sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
//                resultMap.put("age",age);
                resultMap.put("hospitalName", one.get("hospital_name"));
//                resultMap.put("sex","1".equals(sex)?"男":("2".equals(sex)?"女":"未知"));
                resultMap.put("patientName", one.get("name"));
                resultMap.put("patientCode", one.get("patient"));
                resultMap.put("id", one.get("id"));
@ -166,8 +163,6 @@ public class RehabilitationManageService {
                resultMap.put("planTypeName", planTypeName);
                resultMap.put("planCreateUser", one.get("create_user"));
                //今日待办(即今日全部的项目)
                Date beginTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "00:00:00");
                Date endTime = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " " + "23:59:59");
                Integer todayBacklogCount = rehabilitationDetailDao.todayBacklogCount(one.get("id").toString(), beginTime, endTime);
                resultMap.put("todayBacklogCount", todayBacklogCount);//今日待办总数
                //已完成
@ -1026,9 +1021,6 @@ public class RehabilitationManageService {
            String id = one.get("id").toString();
            Map<String, Object> map = new HashMap<>();
            map.put("id", id);//id
//            List<RehabilitationOperateRecordsDO> rehabilitationOperateRecords = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(id);
//            Date completeTime = rehabilitationOperateRecords!=null&&rehabilitationOperateRecords.size()>0?rehabilitationOperateRecords.get(0).getCompleteTime():null;
//            String completeTimeStr =  completeTime!=null?DateUtil.dateToStr(completeTime,"yyyy/MM/dd HH:mm"):"";
            map.put("executeTime", executeTime);//执行时间
            map.put("title", title);//项目标题
            map.put("content", content);//项目内容