cjl
2023-12-18 68e750bf109efb0469704e54e48a29649512358c
screen-api/src/main/java/com/moral/api/controller/HeatMapController.java
@@ -8,21 +8,15 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO;
import com.moral.api.service.DataDisplayService;
import com.moral.api.vo.HeatMapVo;
import com.moral.api.vo.TimeHourVo;
@@ -53,7 +47,7 @@
                                      @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime,
                                      @RequestParam @ApiParam(value = "type",name= "因子类型") String type,
                                      @RequestParam @ApiParam(value = "form",name= "时间类型") String form){
         ArrayList<Map<String, Object>> heatMapData = dataDisplayService.getHeatMapData(code, startTime, type, form);
         List<HeatMapDTO> heatMapData = dataDisplayService.getHeatMapData(code, startTime, type, form);
         return ResultMessage.ok(ObjectUtils.isEmpty(heatMapData)?"0":heatMapData);
     }
    @GetMapping("queryTime")
@@ -81,8 +75,11 @@
            ArrayList<TimeHourVo> timeHourVos = new ArrayList<>();
            String[] splitStart = startTime.split("-");
            String[] splitEnd = endTime.split("-");
            //结束时间月份的天数
            int monthDay = DateUtils.getMonthDay(DateUtils.getDate(endTime,DateUtils.yyyy_MM_EN));
            LocalDate startDate = LocalDate.of(Integer.parseInt(splitStart[0]), Integer.parseInt(splitStart[1]),1);
            LocalDate endDate = LocalDate.of(Integer.parseInt(splitEnd[0]), Integer.parseInt(splitEnd[1]),30);
            LocalDate endDate = LocalDate.of(Integer.parseInt(splitEnd[0]), Integer.parseInt(splitEnd[1]),monthDay);
            long daysBetween = ChronoUnit.DAYS.between(startDate, endDate);
            for (int i = 0; i <= daysBetween; i++) {
                HeatMapVo heatMapVo = new HeatMapVo();
@@ -117,6 +114,8 @@
                    if(ksTime.equals(endTime)){
                        heatMapVo.setHourListTime(hourListTime);
                        heatMapVos.add(heatMapVo);
                        idHour++;
                        break;
                    }
                }else {
                    id++;
@@ -133,6 +132,7 @@
                        heatMapVo.setName(nameEndTime);
                        heatMapVo.setHourListTime(hourListTime);
                        heatMapVos.add(heatMapVo);
                        break;
                    }else {
                        name = nameEndTime;
                        heatMapVo.setHourListTime(hourListTime);
@@ -148,11 +148,8 @@
            if(CollectionUtils.isNotEmpty(heatMapVos)){
                heatMapVos.get(0).setIdLength(idHour);
            }
/*
            String[] splitStart = startTime.split("-");
/*            String[] splitStart = startTime.split("-");
            String[] s1 = splitStart[2].split(" ");
            String[] splitEnd = endTime.split("-");
            String[] s2 = splitEnd[2].split(" ");
@@ -169,24 +166,28 @@
                hourList.add(currentDateTime.toString());
                currentDateTime = currentDateTime.plusHours(1);
            }
            int length=0;
            for (int i = 0; i <= daysBetween; i++) {
                ArrayList<Map<String,Object>> list = new ArrayList<>();
                ArrayList<TimeHourVo> timeHourVos = new ArrayList<>();
                HeatMapVo heatMapVo = new HeatMapVo();
                LocalDate date = startDate.plusDays(i);
                heatMapVo.setId(i);
                heatMapVo.setName(date.toString());
                for (int i1 = 0; i1 < hourList.size(); i1++) {
                    HashMap<String, Object> map = new HashMap<>();
                    if (hourList.get(i).contains(date.toString())){
                        map.put("name",hourList.get(i).substring(11,16));
                        list.add(map);
                    if (hourList.get(i1).contains(date.toString())){
                        TimeHourVo hourVo = new TimeHourVo();
                        hourVo.setName(hourList.get(i1).substring(11,13));
                        hourVo.setId(length);
                        timeHourVos.add(hourVo);
                        hourList.remove(i1);
                        i1--;
                        length++;
                    }
                }
                heatMapVo.setHourList(list);
                heatMapVo.setHourListTime(timeHourVos);
                heatMapVos.add(heatMapVo);
            }*/
            }
            heatMapVos.get(0).setIdLength(length);*/
        }
        return ResultMessage.ok(ObjectUtils.isEmpty(heatMapVos)?"0":heatMapVos);