Ver código fonte

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

LAPTOP-KB9HII50\70708 2 anos atrás
pai
commit
9eae9ec646
17 arquivos alterados com 828 adições e 361 exclusões
  1. 13 1
      common/common-entity/sql记录
  2. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/BaseDeviceRepairEntity.java
  3. 23 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  4. 1 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  5. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java
  6. 59 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java
  7. 10 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  8. 30 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  9. 45 16
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  10. 52 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/common/CommomService.java
  11. 6 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceManageService.java
  12. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  13. 123 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java
  14. 15 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  15. 59 54
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  16. 156 48
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  17. 213 213
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HlsDownloader.java

Diferenças do arquivo suprimidas por serem muito extensas
+ 13 - 1
common/common-entity/sql记录


+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/BaseDeviceRepairEntity.java

@ -31,6 +31,17 @@ public class BaseDeviceRepairEntity extends IdEntity {
    private Date dealTime; //处理时间
    private String feedback; //反馈
    private Integer type;//类型。空是保修,0是设备异常登记维护信息
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "order_id")
    public String getOrderId() {
        return orderId;

+ 23 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1539,4 +1539,27 @@ public class DateUtil {
        return calendar.getTime();
    }
    /**
     * 获取指定时间和当前时间的距离
     * 几秒前、几分钟前、几小时前、几天前
     * @param l1 秒级时间戳
     * @return
     */
    public static String getTimeAgeStr(Long l1){
        String timeAgoStr = "";
        BigDecimal b1 = new BigDecimal(l1);
        BigDecimal b2 = new BigDecimal(System.currentTimeMillis()/1000);
        BigDecimal subtract = b2.subtract(b1);//秒数
        if(subtract.compareTo(new BigDecimal(60))<0){//小于一分钟前
            timeAgoStr = subtract.toString()+"秒前";
        }else if(subtract.compareTo(new BigDecimal(3600))<0){//小于一小时
            timeAgoStr = subtract.divide(new BigDecimal(60),0,BigDecimal.ROUND_HALF_DOWN).toString()+"分钟前";
        }else if(subtract.compareTo(new BigDecimal(86400))<0){//小于一天
            timeAgoStr = subtract.divide(new BigDecimal(3600),0,BigDecimal.ROUND_HALF_DOWN).toString()+"小时前";
        }else {//超过一天
            timeAgoStr = subtract.divide(new BigDecimal(86400),0,BigDecimal.ROUND_HALF_DOWN).toString()+"天前";
        }
        return timeAgoStr;
    }
}

+ 1 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -874,6 +874,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        loginTypeList.add("5");//支付宝登录
        loginTypeList.add("6");//第三方登录-医联康护
        loginTypeList.add("7");//家人登录
        //loginTypeList.add("8");//4k 大屏登入
    }
    public boolean setRolePhth(String loginType, OAuth2AccessToken token, String id, StringRedisTemplate redisTemplate) {

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java

@ -228,4 +228,15 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "open/hualianmenjing")
    @ApiOperation(value = "华联社区门禁初始化--临时")
    public Envelop hualianmenjing() {
        try {
            commomService.hualianmenjing();
            return success("success");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
}

+ 59 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.message;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.common.PermissionService;
import com.yihu.jw.care.service.message.DoctorMessageService;
import com.yihu.jw.care.service.message.PatientMessageService;
import com.yihu.jw.restmodel.ResponseContant;
@ -26,6 +27,8 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
    private DoctorMessageService doctorMessageService;
    @Autowired
    private PatientMessageService patientMessageService;
    @Autowired
    private PermissionService permissionService;
    @GetMapping(value = "messages")
    @ApiOperation("应用消息")
@ -151,4 +154,60 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "/submitRepairMessage")
    @ApiOperation("登记维护信息")
    @ObserverRequired
    public Envelop submitRepairMessage(@ApiParam @RequestParam String id,
                                       @ApiParam @RequestParam String patientId,
                                       @ApiParam @RequestParam String deviceCode,
                                       @ApiParam @RequestParam String content,
                                       @ApiParam @RequestParam String doctorId,
                                       @ApiParam @RequestParam String doctorName,
                                       @ApiParam @RequestParam(required = false,value = "deviceName") String deviceName,
                                       @ApiParam @RequestParam(required = false,value = "img")String img){
        try{
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("doctorId",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return ObjEnvelop.getError("该操作没有权限",-1);
            }
            return doctorMessageService.submitRepairMessage(id, patientId, deviceCode, deviceName,doctorId,doctorName,content,img);
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = "/getRepairMessageList")
    @ApiOperation("维护信息列表")
    public PageEnvelop getRepairMessageList(@ApiParam @RequestParam String doctorId,
                                            @ApiParam @RequestParam(required = false,value = "page",defaultValue = "1")Integer page,
                                            @ApiParam @RequestParam(required = false,value = "pageSize",defaultValue = "20")Integer pageSize,
                                            @ApiParam @RequestParam(required = false,value = "name")String name){
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("doctorId",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return PageEnvelop.getError("该操作没有权限",-1);
            }
            return doctorMessageService.getRepairMassageList(doctorId, page, pageSize,name);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "/getRepairMessageListById")
    @ApiOperation("根据id获取一条维护信息")
    public ObjEnvelop getRepairMessageListById(@ApiParam @RequestParam Integer id){
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("doctorId",permissionService.getUID());
            if (permissionService.noPermission(1, jsonObject)) {
                return ObjEnvelop.getError("该操作没有权限",-1);
            }
            return doctorMessageService.getRepairMessageListById(id);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
}

+ 10 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -8,7 +8,6 @@ import com.yihu.jw.care.service.device.NetworkCardService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.statistics.DetectionPlatformService;
import com.yihu.jw.care.util.HlsDownloader;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -459,16 +458,16 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "testDownloadVideoUrl")
    @ApiOperation(value = "下载m3u8")
    public ObjEnvelop downM3u8Video(@RequestParam String url) {
        try {
            return platformService.downM3u8Video(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ObjEnvelop.getSuccess("1111","");
    }
//    @PostMapping(value = "testDownloadVideoUrl")
//    @ApiOperation(value = "下载m3u8")
//    public ObjEnvelop downM3u8Video(@RequestParam String url) {
//        try {
//            return platformService.downM3u8Video(url);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return ObjEnvelop.getSuccess("1111","");
//    }
//    public static void main(String[] args) {

+ 30 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -615,9 +615,11 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "deviceinfoStatisticsNum")
    @ApiOperation(value = "获取设备数量")
    public ObjEnvelop deviceinfoStatisticsNum(@ApiParam(name = "type",value = "设备类型0健康 1安防",required = true)
                                              @RequestParam(value = "type",required = true)String type){
                                              @RequestParam(value = "type",required = true)String type,
                                              @ApiParam(name = "deviceCategory",value = "设备code",required = false)
                                              @RequestParam(value = "deviceCategory",required = false)String deviceCategory){
        try {
            JSONObject jsonObject = statisticsService.deviceinfoStatisticsNum(type);
            JSONObject jsonObject = statisticsService.deviceinfoStatisticsNum(type,deviceCategory);
            return success(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
@ -651,6 +653,18 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getDoorServiceDictNum")
    @ApiOperation(value ="获取上门辅导服务次数")
    public ListEnvelop getDoorServiceDictNum(){
        try {
            return success(statisticsService.getDoorServiceDictNum());
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "findDictEmeStatus")
    @ApiOperation(value = "紧急预警状态字典")
    public ListEnvelop findDictEmeStatus(){
@ -662,6 +676,20 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientFamilyAndDoctor")
    @ApiOperation(value = "获取居民 社工,助老元,家人信息 ")
    public ObjEnvelop findPatientFamilyAndDoctor(@ApiParam(name = "patient",value = "居民code",required = true)
                                                 @RequestParam(value = "patient",required = true)String patient,
                                                 @ApiParam(name = "orderId",value = "工单Id",required = true)
                                                 @RequestParam(value = "orderId",required = true)String orderid){
        try {
            return success(statisticsService.findPatientFamilyAndDoctor(patient, orderid));
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
}

+ 45 - 16
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -611,7 +611,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            jsonObject.put("sessionId",null);
            jsonObject.put("UnRead",0);
        }
        result.put("phone",patientDO.getMobile());
        result.put("phone",patientDO.getPhoto());
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,jsonObject);
        return result;
@ -794,21 +795,11 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                patientCodes.add(obj.getPatient());
            }
        }
        String inSql = "";
        for (String code : patientCodes) {
            inSql += "'"+code+"',";
        }
        if(StringUtils.isNotBlank(inSql)){
            inSql = inSql.substring(0,inSql.lastIndexOf(","));
            //居民绑定的设备code
            String deviceSql = "SELECT user,GROUP_CONCAT( DISTINCT category_code SEPARATOR ',' ) code  " +
                    "from wlyy_patient_device where del = 0 and user in ("+inSql+") group by user";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(deviceSql);
            for (Map<String, Object> map : list) {
                for (EmergencyAssistanceDO em : resultList) {
                    if(map.get("user").toString().equals(em.getPatient())){
                        em.setPatientDevices(map.get("code").toString());
                    }
        List<Map<String, Object>> list = this.getUserCodeByPatientList(patientCodes);
        for (Map<String, Object> map : list) {
            for (EmergencyAssistanceDO em : resultList) {
                if(map.get("user").toString().equals(em.getPatient())){
                    em.setPatientDevices(map.get("code").toString());
                }
            }
        }
@ -1409,9 +1400,25 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            sql += " order by create_time desc limit "+page*pageSize+","+pageSize;
            result =   jdbcTemplate.queryForList(sql);
        }
        //获取居民的设备code
        List<String> patientCodes = new ArrayList<>();
        for (Map<String, Object> map : result) {
            if(!patientCodes.contains(map.get("patient").toString())){
                patientCodes.add(map.get("patient").toString());
            }
        }
        List<Map<String, Object>> list = this.getUserCodeByPatientList(patientCodes);
        for (Map<String, Object> map : list) {
            for (Map<String, Object> l : result) {
                if(map.get("user").toString().equals(l.get("patient").toString())){
                    l.put("patientDevices",map.get("code").toString());
                }
            }
        }
        return result;
    }
    public JSONObject getEmeAndSecuOrderTab(String doctor,String status){
        JSONObject result = new JSONObject();
        JSONObject eme = new JSONObject();
@ -1813,4 +1820,26 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        return result;
    }
    /**
     * 根据用户code集合获取设备码
     * @param patientCodes
     * @return
     */
    List<Map<String, Object>> getUserCodeByPatientList(List<String> patientCodes){
        List<Map<String, Object>> list = new ArrayList<>();
        String inSql = "";
        for (String code : patientCodes) {
            inSql += "'"+code+"',";
        }
        if(StringUtils.isNotBlank(inSql)) {
            inSql = inSql.substring(0, inSql.lastIndexOf(","));
            //居民绑定的设备code
            String deviceSql = "SELECT user,GROUP_CONCAT( DISTINCT category_code SEPARATOR ',' ) code  " +
                    "from wlyy_patient_device where del = 0 and user in (" + inSql + ") group by user";
            list = jdbcTemplate.queryForList(deviceSql);
        }
        return list;
    }
}

+ 52 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/common/CommomService.java

@ -91,4 +91,56 @@ public class CommomService {
            deviceDetailDao.save(deviceDetails);
        }
    }
    //华联社区门禁用户初始化
    public void hualianmenjing(){
        String sql = " select id,idcard from base_patient where saas_id='8a92aba97a9f6f49017ae4fdbdmqteam' " +
                "UNION  " +
                "select p.id,p.idcard from base_patient p, base_service_package_sign_record sr,base_service_package_record r " +
                "where p.id = sr.patient and  sr.status=1 and r.team_code='8a92aba97a9f6f49017ae4fdbdmqteam' and sr.id=r.sign_id  ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<DeviceDetail> deviceDetails = new ArrayList<>();
        List<DevicePatientDevice> patientDevices = new ArrayList<>();
        List<Device> dmDevices = deviceDao.findByCategoryCode("19");
        Device deviceDo = dmDevices.get(0);
        for (int i=0;i<list.size();i++){
            Map<String,Object> tmp = list.get(i);
            String patient = tmp.get("id").toString();
            String deviceSn = "MJ052700"+i;
            String idcard = tmp.get("idcard").toString();
            DeviceDetail deviceDetail = new DeviceDetail();
            deviceDetail.setDeviceName(deviceDo.getName());
            deviceDetail.setDeviceCode(deviceSn);
            deviceDetail.setDeviceModel(deviceDo.getModel());
            deviceDetail.setCategoryCode(deviceDo.getCategoryCode());
            deviceDetail.setBindingCount("{\"1\":\"1\"}");
            deviceDetail.setContactStatus(1);
            deviceDetail.setDeviceType(1);
            deviceDetail.setIsGrant(1);
            deviceDetail.setGrantAdminTeam("0");
            deviceDetail.setManufacturer("天图");
            deviceDetail.setApplyDate(DateUtil.getStringDate());
            deviceDetails.add(deviceDetail);
            DevicePatientDevice patientDevice = new DevicePatientDevice();
            patientDevice.setDel(0);
            patientDevice.setUser(patient);
            patientDevice.setCategoryCode(deviceDo.getCategoryCode());
            patientDevice.setDeviceId(deviceDo.getId());
            patientDevice.setDeviceName(deviceDo.getName());
            patientDevice.setDeviceSn(deviceSn);
            patientDevice.setUserIdcard(idcard);
            patientDevice.setUserType("-1");
            patientDevice.setCzrq(new Date());
            patientDevice.setDeviceType(1);
            patientDevices.add(patientDevice);
        }
        if (patientDevices.size()>0){
            patientDeviceDao.save(patientDevices);
        }
        if (deviceDetails.size()>0){
            deviceDetailDao.save(deviceDetails);
        }
    }
}

+ 6 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceManageService.java

@ -11,7 +11,6 @@ import com.yihu.jw.entity.patient.BaseDeviceRepairEntity;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -99,7 +98,8 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
                         " AND dr.device_sn = pd.device_sn" +
                         " AND pd. USER = ph.patient" +
                         " AND ph.doctor = '"+doctor+"'" +
                         " AND ph.del = '1'";
                         " AND ph.del = '1'  " +
                         " AND dr.type is null ";
            } else {
                 repairSql = "SELECT DISTINCT dr.order_id AS id,dr.bind_user_name AS patientName, pd.category_code as categoryCode," +
                        " dr.`status` AS `status`,dr.create_time AS createTime,dr.repair_peoper_name AS repairName,wd.device_name AS deviceName" +
@ -117,6 +117,7 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
                        " AND dd.model = wd.device_model" +
                        " AND p.del = 1" +
                        " AND pd.device_sn = dr.device_sn" +
                        " AND dr.type is null " +
                        " and EXISTS (SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
                        " WHERE sr.patient = p.id and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id AND dr.repair_peoper = m.doctor_code" +
                        " and m.doctor_code = '" + doctor + "' and m.del = '1')";
@ -142,7 +143,7 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
    /*报修详细信息*/
    public List<BaseDeviceRepairEntity> getRepairInfo(String orderId) {
        return jdbcTemplate.query("SELECT * from base_device_repair WHERE order_id = '" + orderId + "'", new BeanPropertyRowMapper<>(BaseDeviceRepairEntity.class));
        return jdbcTemplate.query("SELECT * from base_device_repair WHERE type is null and order_id = '" + orderId + "'", new BeanPropertyRowMapper<>(BaseDeviceRepairEntity.class));
    }
    /*报修*/
@ -185,7 +186,7 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
                " DATE_FORMAT( dr.create_time ,'%Y-%m-%d %H:%i:%S') createTime " ;
        String countSql = " select count(distinct dr.id) ";
        String filterSql =  " FROM wlyy_patient_device pd,base_device_repair dr,base_patient p " +
                "WHERE p.id = pd.user AND pd.del = 0 AND dr.device_sn = pd.device_sn and p.del=1  ";
                "WHERE p.id = pd.user AND pd.del = 0 AND dr.device_sn = pd.device_sn and p.del=1 and dr.type is null  ";
        if (StringUtils.isNotBlank(status)){
            filterSql += " and dr.status='"+status+"' ";
        }
@ -205,7 +206,7 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
                " DATE_FORMAT( dr.create_time ,'%Y-%m-%d %H:%i:%S') createTime,  DATE_FORMAT( pd.czrq ,'%Y-%m-%d %H:%i:%S') czrq, " +
                " dr.show_content,dr.img,dr.feedback " +
                "FROM wlyy_patient_device pd,base_device_repair dr,base_patient p " +
                "WHERE p.id = pd.user AND pd.del = 0 AND dr.device_sn = pd.device_sn and p.del=1 and dr.id='"+orderId+"' ";
                "WHERE p.id = pd.user AND pd.del = 0 AND dr.device_sn = pd.device_sn and dr.type is null and p.del=1 and dr.id='"+orderId+"' ";
        List <Map<String,Object>> list =  jdbcTemplate.queryForList(sql);
        if (list.size()>0){
            result = list.get(0);

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -945,7 +945,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            String sql = "select dd.photo,GROUP_CONCAT(DISTINCT p.name) as patientName,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime,wd.manufacturer,p.mobile,p.address,p.idcard,wd.device_type  " +
                    "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN base_patient p on p.id = pd.user " +
                    " INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code " +
                    "where 1=1 and  pd.del=0 and pd.device_sn ='" + deviceSn + "' group by pd.device_sn";
                    "where 1=1 and  pd.del=0 and pd.device_sn ='" + deviceSn + "' "+(StringUtils.isNotBlank(patient)?"and pd.user='"+patient+"'":"")+"  group by pd.device_sn";
            Map<String, Object> devInfo = jdbcTemplate.queryForMap(sql);
            devInfo.put("patient", patient);
            devInfo.put("sosContactsDOS", new ArrayList<>());

+ 123 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java

@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.device.BaseDeviceRepairDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.message.OrgNoticeDao;
import com.yihu.jw.care.dao.message.UserNoticeDao;
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
@ -14,9 +16,15 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.notice.UserNoticeDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import com.yihu.jw.entity.patient.BaseDeviceRepairEntity;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
@ -24,6 +32,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.*;
@ -54,6 +64,14 @@ public class DoctorMessageService {
    private DoctorServicePermissionsService doctorServicePermissionsService;
    @Autowired
    private RoleService roleService;
    @Autowired
    private BaseDeviceRepairDao baseDeviceRepairDao;
    @Autowired
    private PatientMessageService patientMessageService;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private BasePatientDao basePatientDao;
    /**
     *
@ -323,19 +341,24 @@ public class DoctorMessageService {
       // List<SystemMessageDO> systemMessageDOS = messageDao.getByReceiverAndType(doctor,"43");
        String sql =  "select DISTINCT sm.id as id,sm.type AS type,sm.title AS title,sm.sender AS sender,sm.sender_name AS senderName,\n" +
                "  sm.receiver AS receiver,sm.receiver_name AS receiver_name,sm.relation_code AS relationCode,\n" +
                "  sm.data AS data,sm.is_read AS isRead,DATE_FORMAT(sm.create_time,'%Y-%m-%d') AS createTime,sm.sender_photo AS sender_photo,pd.category_code,pd.device_name" +
                "  from base_system_message sm LEFT JOIN wlyy_patient_device pd ON sm.relation_code = pd.device_sn where sm.receiver = '"+doctor+"' AND sm.type=43 and sm.del=1 ";
                "  sm.data AS data,sm.is_read AS isRead,DATE_FORMAT(sm.create_time,'%Y-%m-%d') AS createTime,UNIX_TIMESTAMP(sm.create_time) AS createTimeNum,sm.sender_photo AS sender_photo,pd.category_code,pd.device_name,p.photo " +
                "  from base_system_message sm LEFT JOIN wlyy_patient_device pd ON sm.relation_code = pd.device_sn left join base_patient p on sm.sender = p.id where sm.receiver = '"+doctor+"' AND sm.type=43 and sm.del=1 ";
        if (StringUtils.isNotBlank(deviceCode)&&!"''".equals(deviceCode)){
            sql +=" AND pd.category_code = '"+deviceCode+"'";
        }
        //模糊搜居民名字和身份证号
        if (StringUtils.isNotBlank(deviceName)){
            sql += " and pd.device_name LIKE '%"+deviceName+"%'";
            sql += " and ( p.name LIKE '%"+deviceName+"%' or p.idcard like '%"+deviceName+"%' )";
        }
        sql+= "  order by sm.create_time desc";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : maps) {
            Long l = (Long) map.get("createTimeNum");
            map.put("timeAgoStr",DateUtil.getTimeAgeStr(l));
        }
        return maps;
    }
@ -476,4 +499,101 @@ public class DoctorMessageService {
        return result;
    }
    /**
     * 登记维护信息
     * @param id 消息id
     * @param patientId 居民code
     * @param deviceCode 设备sn
     * @param deviceName 设备名称
     * @param doctorId 医生id
     * @param doctorName 医生名字
     * @param content 处理内容
     * @param img 图片
     * @return
     */
    @Transactional
    public Envelop submitRepairMessage(String id,String patientId,String deviceCode,String deviceName,String doctorId,String doctorName,String content,String img){
        BaseDeviceRepairEntity baseDeviceRepairEntity = new BaseDeviceRepairEntity();
        baseDeviceRepairEntity.setOrderId(id);
        baseDeviceRepairEntity.setDeviceSn(deviceCode);
        if(StringUtils.isBlank(deviceName)){
            //查设备
            DeviceDetail bySn = deviceDetailDao.findBySn(deviceCode);
            if(bySn != null){
                deviceName = bySn.getDeviceName();
            }
        }
        baseDeviceRepairEntity.setDeviceName(deviceName);
        baseDeviceRepairEntity.setBindUser(patientId);
        //查居民名字
        BasePatientDO byId = basePatientDao.findById(patientId);
        String userName = "";
        if(byId != null){
            userName = byId.getName();
        }
        baseDeviceRepairEntity.setBindUserName(userName);
        baseDeviceRepairEntity.setStatus(1);
        baseDeviceRepairEntity.setRepairPeoper(patientId);
        baseDeviceRepairEntity.setRepairPeoperName(userName);
        Date nowDate = DateUtil.getNowDate();
        baseDeviceRepairEntity.setCreateTime(nowDate);
        baseDeviceRepairEntity.setImg(img);
        baseDeviceRepairEntity.setDealTime(nowDate);
        baseDeviceRepairEntity.setFeedback(content);
        baseDeviceRepairEntity.setType(0);
        baseDeviceRepairEntity.setDealPeoper(doctorId);
        baseDeviceRepairEntity.setDealPeoperName(doctorName);
        baseDeviceRepairDao.save(baseDeviceRepairEntity);
        patientMessageService.delMessageRead(id);
        return Envelop.getSuccess("操作成功");
    }
    /**
     * 维护信息列表
     * @param doctorId
     * @param page
     * @param pageSize
     * @param name
     * @return
     */
    public PageEnvelop getRepairMassageList(String doctorId,Integer page,Integer pageSize,String name){
        page = page>0?page-1:0;
        String selectSql = "SELECT re.id,re.order_id orderId,p.name patientName,re.device_sn deviceSn,re.device_name deviceName,CAST(DATE_FORMAT(re.deal_time,'%Y-%m-%d %H:%i:%S') as char) dealTime,re.deal_peoper dealPeoper,re.deal_peoper_name dealPeoperName,p.photo ";
        String sql = " from base_device_repair re left join base_patient p on re.bind_user = p.id " +
                " where re.type = 0 and re.status = 1 and re.deal_peoper = '"+doctorId+"' ";
        if(StringUtils.isNotBlank(name)){
            sql += " and ( p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
        }
        String pageSql = " limit "+page*pageSize+","+pageSize+" ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql + sql + pageSql);
        String countSql = "SELECT COUNT(re.id) ";
        Long total = jdbcTemplate.queryForObject(countSql + sql, Long.class);
        //计算时间差
        //for (Map<String, Object> map : list) {
        //    Long l1 = (Long) map.get("dealTimeNum");
        //    map.put("timeAgoStr",DateUtil.getTimeAgeStr(l1));
        //}
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,total);
    }
    /**
     * 根据id获取一条维护信息
     * @param id
     * @return
     */
    public ObjEnvelop getRepairMessageListById(Integer id){
        String sql = "SELECT re.id,re.order_id orderId,p.name patientName,re.device_sn deviceSn,re.device_name deviceName,CAST(DATE_FORMAT(re.deal_time,'%Y-%m-%d %H:%i:%S') as char) dealTime,re.deal_peoper dealPeoper,re.deal_peoper_name dealPeoperName,p.photo,re.feedback,re.img " +
                " from base_device_repair re left join base_patient p on re.bind_user = p.id where re.type = 0 and re.id = "+id;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Object> map = new HashMap<>();
        if(!ObjectUtils.isEmpty(list)){
            map = list.get(0);
            //Long l1 = (Long) map.get("dealTimeNum");
            //map.put("timeAgoStr",DateUtil.getTimeAgeStr(l1));
            return ObjEnvelop.getSuccess("获取成功",map);
        }
        return ObjEnvelop.getError("无数据");
    }
}

+ 15 - 7
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -389,6 +389,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        emergencyOrderVO.setPatientName(orderDO.getPatientName());
        emergencyOrderVO.setSex(patientDO.getSex());
        emergencyOrderVO.setTopicItem(orderDO.getTopicItem());
        emergencyOrderVO.setPhone(patientDO.getMobile());
        emergencyOrderVO.setOrderType(22);
        if (StringUtils.isNotBlank(orderDO.getSceneImg())) {
            emergencyOrderVO.setSceneImg(orderDO.getSceneImg());
@ -623,6 +624,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            jsonObject.put("UnRead", 0);
        }
        jsonObject.put("photo",patientDO.getPhoto());
        result.put("resultFlag", 1);
        result.put("resultMsg", jsonObject);
        return result;
@ -2136,7 +2138,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                dulat = Double.parseDouble(pointss[0]);
                            }
                            if (StringUtils.isNotBlank(pointss[1])) {
                                dulat = Double.parseDouble(pointss[1]);
                                dulon = Double.parseDouble(pointss[1]);
                            }
                        }
                    }
@ -2666,12 +2668,15 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
                String deviceSn = "";
                List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " +
                        " on pd.device_id = dd.id where  pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0  and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItemTmp + "',dd.service_topic)", String.class);
                String deviceCode = "";
                List<Map<String, Object>> deviceSns = jdbcTemplate.queryForList("select pd.device_sn,pd.category_code from wlyy_patient_device pd INNER JOIN dm_device dd " +
                        " on pd.device_id = dd.id where  pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0  and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItemTmp + "',dd.service_topic)");
                if (deviceSns.size() > 0) {
                    deviceSn = deviceSns.get(0);
                    deviceSn = deviceSns.get(0).get("device_sn").toString();
                    deviceCode = deviceSns.get(0).get("category_code").toString();
                }
                object.put("deviceSn", deviceSn);
                object.put("deviceCode", deviceCode);
                switch (topicItem) {
                    case "actionTrack":
@ -2712,14 +2717,17 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            for (int i = 0; i < list.size(); i++) {
                Map<String, Object> patientTmp = list.get(i);
                String deviceSn = "";
                List<String> deviceSns = jdbcTemplate.queryForList("select pd.device_sn from wlyy_patient_device pd INNER JOIN dm_device dd " +
                        " on pd.device_id = dd.id where  pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0  and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItem + "',dd.service_topic)", String.class);
                String deviceCode = "";
                List<Map<String, Object>> deviceSns = jdbcTemplate.queryForList("select pd.device_sn,pd.category_code from wlyy_patient_device pd INNER JOIN dm_device dd " +
                        " on pd.device_id = dd.id where  pd.user = '" + patientTmp.get("id").toString() + "' and pd.del=0  and pd.category_code in (" + categoryCode + ") and FIND_IN_SET('" + topicItem + "',dd.service_topic)");
                if (deviceSns.size() > 0) {
                    deviceSn = deviceSns.get(0);
                    deviceSn = deviceSns.get(0).get("device_sn").toString();
                    deviceCode = deviceSns.get(0).get("category_code").toString();
                }
                JSONObject object = patientMonitoringInfo(patientTmp.get("id").toString(), "null", null,false);
                object.put("deviceSn", deviceSn);
                object.put("patientInfo", patientTmp);
                object.put("deviceCode", deviceCode);
                monitorInfos.add(object);
            }
            result.put("topicInfo", monitorInfos);

Diferenças do arquivo suprimidas por serem muito extensas
+ 59 - 54
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java


Diferenças do arquivo suprimidas por serem muito extensas
+ 156 - 48
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java


+ 213 - 213
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HlsDownloader.java

@ -1,217 +1,217 @@
package com.yihu.jw.care.util;

import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

// https://my.oschina.net/haitaohu/blog/1941179
public class HlsDownloader {

    private String uuid;
    private String originUrlpath;
    private String preUrlPath;
    private String rootPath;
    private String fileName;
    private String folderPath;
    private int threadQuantity = 10;

    public int getThreadQuantity() {
        return threadQuantity;
    }

    public void setThreadQuantity(int threadQuantity) {
        this.threadQuantity = threadQuantity;
    }


    public HlsDownloader(String originUrlpath, String preUrlPath, String rootPath){
        this.uuid = UUID.randomUUID().toString().replaceAll("-","");
        this.originUrlpath = originUrlpath;
        this.preUrlPath = preUrlPath;
        this.rootPath = rootPath;

        this.fileName = uuid+ ".mp4";

        this.folderPath = rootPath + File.separator + uuid;
        File file = new File(folderPath);
        if(!file.exists()) file.mkdirs();
    }

    public String download(boolean isAsync) throws Exception {

        String indexStr = getIndexFile();

        List urlList = analysisIndex(indexStr);

        HashMap<Integer,String> keyFileMap = new HashMap<>();

        if(isAsync){
            downLoadIndexFileAsync(urlList, keyFileMap);

            while (keyFileMap.size()<urlList.size()){
                //System.out.println("当前下载数量"+keyFileMap.size());
                Thread.sleep(3000);
            }
        }else{
            keyFileMap = downLoadIndexFile(urlList);
        }

        return composeFile(keyFileMap);
    }

    /* 下载索引文件 */
    public String getIndexFile() throws Exception{
        URL url = new URL(originUrlpath);

        /*File file = new File("E:\\JKZL\\1.m3u8");
        url = file.toURL();*/
        //下载资源
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));

        String content = "" ;
        String line;
        while ((line = in.readLine()) != null) {
            content += line + "\n";
        }
        in.close();

        return content;
    }

    /* 解析索引文件 */
    public List analysisIndex(String content) throws Exception{
        Pattern pattern = Pattern.compile(".*ts");
        Matcher ma = pattern.matcher(content);

        List<String> list = new ArrayList<String>();

        while(ma.find()){
            list.add(ma.group());
        }

        return list;
    }

    /* 下载视频片段 */
    public HashMap downLoadIndexFile(List<String> urlList){
        HashMap<Integer,String> keyFileMap = new HashMap<>();

        for(int i =0;i<urlList.size();i++){
            String subUrlPath = urlList.get(i);
            String fileOutPath = folderPath + File.separator + i + ".ts";
            keyFileMap.put(i, fileOutPath);
            try{
                downloadNet(preUrlPath + subUrlPath, fileOutPath);

                System.out.println("成功:"+ (i + 1) +"/" + urlList.size());
            }catch (Exception e){
                System.err.println("失败:"+ (i + 1) +"/" + urlList.size());
            }
        }

        return  keyFileMap;
    }

    public void downLoadIndexFileAsync(List<String> urlList, HashMap<Integer,String> keyFileMap) throws Exception{
        int downloadForEveryThread = (urlList.size() + threadQuantity - 1)/threadQuantity;
        if(downloadForEveryThread == 0) downloadForEveryThread = urlList.size();

        for(int i=0; i<urlList.size();i+=downloadForEveryThread){
            int startIndex = i;
            int endIndex = i + downloadForEveryThread - 1;
            if(endIndex >= urlList.size())
                endIndex = urlList.size() - 1;

            new DownloadThread(urlList, startIndex, endIndex, keyFileMap).start();
        }
    }
    /**
     * 视频片段合成
     */
    public String composeFile(HashMap<Integer,String> keyFileMap) throws Exception{

        if(keyFileMap.isEmpty()) return null;

        String fileOutPath = rootPath + File.separator + fileName;
        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
        byte[] bytes = new byte[1024];
        int length = 0;
        for(int i=0; i<keyFileMap.size(); i++){
            String nodePath = keyFileMap.get(i);
            File file = new File(nodePath);
            if(!file.exists())  continue;

            FileInputStream fis = new FileInputStream(file);
            while ((length = fis.read(bytes)) != -1) {
                fileOutputStream.write(bytes, 0, length);
            }
        }

        return fileName;
    }


    class DownloadThread extends Thread{
        private List<String> urlList;
        private int startIndex;
        private int endIndex;
        private HashMap<Integer,String> keyFileMap;

        public DownloadThread(List<String> urlList, int startIndex, int endIndex, HashMap<Integer,String> keyFileMap){
            this.urlList = urlList;
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            this.keyFileMap = keyFileMap;
        }
        @Override
        public void run(){
            for(int i=startIndex;i<=endIndex;i++){
                String subUrlPath = urlList.get(i);
                String fileOutPath = folderPath + File.separator + i + ".ts";
                keyFileMap.put(i, fileOutPath);
                String message = "%s: 线程 " + (startIndex/(endIndex - startIndex) + 1)
                        + ", "+ (i + 1) +"/" + urlList.size() +", 合计: %d";
                try{
                    downloadNet(preUrlPath + subUrlPath, fileOutPath);

                    System.out.println(String.format(message, "成功", keyFileMap.size()));
                }catch (Exception e){
                    System.err.println(String.format(message, "失败", keyFileMap.size()));
                }
            }
        }
    }

    private void downloadNet(String fullUrlPath, String fileOutPath) throws Exception {
        // 下载网络文件
//        DataInputStream dataInputStream = new DataInputStream(url.openStream());
//package com.yihu.jw.care.util;
//
//import java.io.*;
//import java.net.URL;
//import java.net.URLConnection;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.UUID;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
//// https://my.oschina.net/haitaohu/blog/1941179
//public class HlsDownloader {
//
//    private String uuid;
//    private String originUrlpath;
//    private String preUrlPath;
//    private String rootPath;
//    private String fileName;
//    private String folderPath;
//    private int threadQuantity = 10;
//
//    public int getThreadQuantity() {
//        return threadQuantity;
//    }
//
//    public void setThreadQuantity(int threadQuantity) {
//        this.threadQuantity = threadQuantity;
//    }
//
//
//    public HlsDownloader(String originUrlpath, String preUrlPath, String rootPath){
//        this.uuid = UUID.randomUUID().toString().replaceAll("-","");
//        this.originUrlpath = originUrlpath;
//        this.preUrlPath = preUrlPath;
//        this.rootPath = rootPath;
//
//        this.fileName = uuid+ ".mp4";
//
//        this.folderPath = rootPath + File.separator + uuid;
//        File file = new File(folderPath);
//        if(!file.exists()) file.mkdirs();
//    }
//
//    public String download(boolean isAsync) throws Exception {
//
//        String indexStr = getIndexFile();
//
//        List urlList = analysisIndex(indexStr);
//
//        HashMap<Integer,String> keyFileMap = new HashMap<>();
//
//        if(isAsync){
//            downLoadIndexFileAsync(urlList, keyFileMap);
//
//            while (keyFileMap.size()<urlList.size()){
//                //System.out.println("当前下载数量"+keyFileMap.size());
//                Thread.sleep(3000);
//            }
//        }else{
//            keyFileMap = downLoadIndexFile(urlList);
//        }
//
//        return composeFile(keyFileMap);
//    }
//
//    /* 下载索引文件 */
//    public String getIndexFile() throws Exception{
//        URL url = new URL(originUrlpath);
//
//        /*File file = new File("E:\\JKZL\\1.m3u8");
//        url = file.toURL();*/
//        //下载资源
//        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));
//
//        String content = "" ;
//        String line;
//        while ((line = in.readLine()) != null) {
//            content += line + "\n";
//        }
//        in.close();
//
//        return content;
//    }
//
//    /* 解析索引文件 */
//    public List analysisIndex(String content) throws Exception{
//        Pattern pattern = Pattern.compile(".*ts");
//        Matcher ma = pattern.matcher(content);
//
//        List<String> list = new ArrayList<String>();
//
//        while(ma.find()){
//            list.add(ma.group());
//        }
//
//        return list;
//    }
//
//    /* 下载视频片段 */
//    public HashMap downLoadIndexFile(List<String> urlList){
//        HashMap<Integer,String> keyFileMap = new HashMap<>();
//
//        for(int i =0;i<urlList.size();i++){
//            String subUrlPath = urlList.get(i);
//            String fileOutPath = folderPath + File.separator + i + ".ts";
//            keyFileMap.put(i, fileOutPath);
//            try{
//                downloadNet(preUrlPath + subUrlPath, fileOutPath);
//
//                System.out.println("成功:"+ (i + 1) +"/" + urlList.size());
//            }catch (Exception e){
//                System.err.println("失败:"+ (i + 1) +"/" + urlList.size());
//            }
//        }
//
//        return  keyFileMap;
//    }
//
//    public void downLoadIndexFileAsync(List<String> urlList, HashMap<Integer,String> keyFileMap) throws Exception{
//        int downloadForEveryThread = (urlList.size() + threadQuantity - 1)/threadQuantity;
//        if(downloadForEveryThread == 0) downloadForEveryThread = urlList.size();
//
//        for(int i=0; i<urlList.size();i+=downloadForEveryThread){
//            int startIndex = i;
//            int endIndex = i + downloadForEveryThread - 1;
//            if(endIndex >= urlList.size())
//                endIndex = urlList.size() - 1;
//
//            new DownloadThread(urlList, startIndex, endIndex, keyFileMap).start();
//        }
//    }
//    /**
//     * 视频片段合成
//     */
//    public String composeFile(HashMap<Integer,String> keyFileMap) throws Exception{
//
//        if(keyFileMap.isEmpty()) return null;
//
//        String fileOutPath = rootPath + File.separator + fileName;
//        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
//        byte[] bytes = new byte[1024];
//        int length = 0;
//        while ((length = dataInputStream.read(bytes)) != -1) {
//            fileOutputStream.write(bytes, 0, length);
//        for(int i=0; i<keyFileMap.size(); i++){
//            String nodePath = keyFileMap.get(i);
//            File file = new File(nodePath);
//            if(!file.exists())  continue;
//
//            FileInputStream fis = new FileInputStream(file);
//            while ((length = fis.read(bytes)) != -1) {
//                fileOutputStream.write(bytes, 0, length);
//            }
//        }
//
//        return fileName;
//    }
//
//
////    class DownloadThread extends Thread{
////        private List<String> urlList;
////        private int startIndex;
////        private int endIndex;
////        private HashMap<Integer,String> keyFileMap;
////
////        public DownloadThread(List<String> urlList, int startIndex, int endIndex, HashMap<Integer,String> keyFileMap){
////            this.urlList = urlList;
////            this.startIndex = startIndex;
////            this.endIndex = endIndex;
////            this.keyFileMap = keyFileMap;
////        }
////        @Override
////        public void run(){
////            for(int i=startIndex;i<=endIndex;i++){
////                String subUrlPath = urlList.get(i);
////                String fileOutPath = folderPath + File.separator + i + ".ts";
////                keyFileMap.put(i, fileOutPath);
////                String message = "%s: 线程 " + (startIndex/(endIndex - startIndex) + 1)
////                        + ", "+ (i + 1) +"/" + urlList.size() +", 合计: %d";
////                try{
////                    downloadNet(preUrlPath + subUrlPath, fileOutPath);
////
////                    System.out.println(String.format(message, "成功", keyFileMap.size()));
////                }catch (Exception e){
////                    System.err.println(String.format(message, "失败", keyFileMap.size()));
////                }
////            }
////        }
////    }
//
//    private void downloadNet(String fullUrlPath, String fileOutPath) throws Exception {
//        // 下载网络文件
////        DataInputStream dataInputStream = new DataInputStream(url.openStream());
////        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
////        byte[] bytes = new byte[1024];
////        int length = 0;
////        while ((length = dataInputStream.read(bytes)) != -1) {
////            fileOutputStream.write(bytes, 0, length);
////        }
////        dataInputStream.close();
//
//        //int bytesum = 0;
//        int byteread = 0;
//
//        URL url = new URL(fullUrlPath);
//        URLConnection conn = url.openConnection();
//        InputStream inStream = conn.getInputStream();
//        FileOutputStream fs = new FileOutputStream(fileOutPath);
//
//        byte[] buffer = new byte[1204];
//        while ((byteread = inStream.read(buffer)) != -1) {
//            //bytesum += byteread;
//            fs.write(buffer, 0, byteread);
//        }
//        dataInputStream.close();

        //int bytesum = 0;
        int byteread = 0;

        URL url = new URL(fullUrlPath);
        URLConnection conn = url.openConnection();
        InputStream inStream = conn.getInputStream();
        FileOutputStream fs = new FileOutputStream(fileOutPath);

        byte[] buffer = new byte[1204];
        while ((byteread = inStream.read(buffer)) != -1) {
            //bytesum += byteread;
            fs.write(buffer, 0, byteread);
        }
    }

}
//    }
//
//}