liubing пре 3 година
родитељ
комит
9177a1bf2c

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.doctor.CareDoctorService;
@ -16,14 +17,11 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created with IntelliJ IDEA.
@ -268,4 +266,15 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
            return failedListEnvelopException2(e);
        }
    }
    @RequestMapping(value="esDataModify",method = RequestMethod.GET)
    public ObjEnvelop esDataModify(@RequestParam(required = true) String sql,@RequestParam(required = true) String jsonStr){
        try {
            return ObjEnvelop.getSuccess("success",statisticsService.esDataModify(sql,jsonStr));
        }catch (Exception e){
           return failedObjEnvelopException2(e);
        }
    }
}

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

@ -440,6 +440,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patientDO.getId());
                if(null==monitorInfo){
                    monitorInfo = new JSONObject();
                }
                if (sleepPlans.size()>0){
                    BaseSleepPlan sleepPlan = sleepPlans.get(0);
                    String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);

+ 50 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -15,6 +15,7 @@ import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.es.es.ElasticSearchHelperUtil;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
@ -27,9 +28,11 @@ import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.nlpcn.es4sql.jdbc.ObjectResult;
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.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -79,6 +82,12 @@ public class StatisticsService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private ElasticSearchHelperUtil elasticSearchHelper;
    @Value("${es.index.Statistics}")
    private String esIndex;
    @Value("${es.type.Statistics}")
    private String esType;
    private static final String defalutArea = "330100";
@ -1404,4 +1413,45 @@ public class StatisticsService {
        }
        return null;
    }
    /**
     *
     * @param esSql
     * @param jsonStr 修改数据
     * @return
     */
    public boolean esDataModify(String esSql,String jsonStr) {
        try {
            if (StringUtils.containsIgnoreCase(esSql,"limit")){
                return false;
            }
            Boolean flag=false;
            List<SaveModel> objs = elasticsearchUtil.excute(esSql,SaveModel.class,"","");
            List<Map<String,Object>> sourceMap = new ArrayList<>();
            int i=0;
            for (SaveModel tmp:objs){
                String jsonStr1 = JSON.toJSONString(tmp);
                Map<String,Object> tmpInfo = com.alibaba.fastjson.JSONObject.parseObject(jsonStr1,Map.class);
                if (StringUtils.isNotBlank(jsonStr)){
                    Map<String,Object> modifyInfo = com.alibaba.fastjson.JSONObject.parseObject(jsonStr,Map.class);
                    for (String key:modifyInfo.keySet()){
                        tmpInfo.put(key, modifyInfo.get(key));
                    }
                    sourceMap.add(tmpInfo);
                }
                i++;
            }
            if (i>0){
                flag = elasticSearchHelper.updateByMap(esIndex,esIndex,sourceMap);//修改
            }
            return flag;
        }
        catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}