| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | } |
| | | return R.data(lists); |
| | | |
| | | } |
| | | else { |
| | | } else { |
| | | //当前时间 |
| | | String times = time; |
| | | |
| | |
| | | */ |
| | | @ApiLog("查询洪水预警") |
| | | @GetMapping("/sss") |
| | | public R selectcInfoss(int type,String time,String dateEnds1,String dateEnds2,String dateEnds3,int k) { |
| | | public R selectcInfoss(int type, String time, String dateEnds1, String dateEnds2, String dateEnds3) { |
| | | //第二种方式预警 |
| | | if (type == 0 && k==13) { |
| | | if (type == 0) { |
| | | //当前时间 |
| | | String times = time; |
| | | |
| | |
| | | map.put("List", mountainrainsCVOS.get(i)); |
| | | map.put("Max", Max); |
| | | lists.add(map); |
| | | } |
| | | else { |
| | | } else { |
| | | int Max =mountainrainService .Max(mountainrainsCVOS.get(i).getDrp1(), mountainrainsCVOS.get(i).getDrp3(), |
| | | mountainrainsCVOS.get(i).getGohour(), mountainrainsCVOS.get(i).getGthour()); |
| | | map.put("List", mountainrainsCVOS.get(i)); |
| | |
| | | } |
| | | String code = strArrays.substring(0, strArrays.length() - 1); |
| | | List<Map<String, Integer>> list = mountainrainService.selecMone(times, dateEnd1, dateEnd2, dateEnd3, code); |
| | | List list1= new ArrayList(); |
| | | List list2= new ArrayList(); |
| | | List list3= new ArrayList(); |
| | | List<Map<String, Object>> lists = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | for (int i=0;i<list.size();i++){ |
| | | if (list.get(i).get("drp1")>=30){ |
| | | list1.add(list.get(i)); |
| | | map.put("List", list.get(i)); |
| | | map.put("Max", 1); |
| | | } |
| | | if (list.get(i).get("drp2")>=50) { |
| | | list2.add(list.get(i)); |
| | | map.put("List", list.get(i)); |
| | | map.put("Max", 2); |
| | | } |
| | | if (list.get(i).get("drp3")>=80) { |
| | | list3.add(list.get(i)); |
| | | map.put("List", list.get(i)); |
| | | map.put("Max", 3); |
| | | } |
| | | |
| | | } |
| | | Map map = new HashMap(); |
| | | map.put("list1",list1); |
| | | map.put("list2",list2); |
| | | map.put("list2",list3); |
| | | return R.data(map); |
| | | lists.add(map); |
| | | return R.data(lists); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 土壤湿度计算 |
| | | * |
| | | * @return |
| | | */ |
| | | @Scheduled(cron = "0 0 8 * * ?") |
| | | //@Scheduled(cron = "0 0 8 * * ?") |
| | | @GetMapping("/soleval") |
| | | public R soleval() { |
| | | SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd 08:00:00" ); |
| | | Date today = new Date(); |
| | | String endDate = sdf .format( today ); //当前日期 |
| | | //获取三十天前日期 |
| | | Calendar theCa = Calendar. getInstance (); |
| | | theCa .setTime( today ); |
| | | theCa .add( theCa . DATE , -30); //最后一个数字30可改,30天的意思 |
| | | Date start = theCa .getTime(); |
| | | String startDate = sdf .format( start ); //三十天之前日期 |
| | | mountainrainService.soildel(); |
| | | int intervals = 31; |
| | | ArrayList passDaysList = new ArrayList<>(); |
| | | for (int i = 0; i < intervals; i++) { |
| | | passDaysList.add(getDays(i, false)); |
| | | } |
| | | Collections.sort(passDaysList); |
| | | String s = mountainrainService.selectCode(); |
| | | //String s = "62310356,62310305"; |
| | | String[] split = s.split(","); |
| | | String strArrays = ""; |
| | | Integer num=60; |
| | | for (int i = 0; i < split.length; i++) { |
| | | strArrays += "'" + split[i] + "',"; |
| | | } |
| | | String code = strArrays.substring(0, strArrays.length() - 1); |
| | | mountainrainService.soildel(); |
| | | List<Map<String, Object>> list = mountainrainService.selectMtwo(startDate, endDate, code); |
| | | for (int i=0;i<list.size();i++){ ; |
| | | BigDecimal w = (BigDecimal) list.get(i).get("drp"); |
| | | double drp = w.doubleValue(); |
| | | String stcd = list.get(i).get("STCD").toString(); |
| | | //计算湿度 |
| | | double v = (num + drp) * 0.85; |
| | | if (v>60){ |
| | | mountainrainService.soleInster(stcd,"60"); |
| | | for (int i = 0; i < split.length; i++) { |
| | | Integer num = 30; |
| | | double v1 = 0; |
| | | String stcd = null; |
| | | for (int j = 0; j < passDaysList.size() - 1; j++) { |
| | | List<Map<String, Object>> map = mountainrainService.selectMtwo(passDaysList.get(j).toString(), passDaysList.get(j + 1).toString(), code); |
| | | if (map.size()==0){ |
| | | continue; |
| | | } |
| | | else { |
| | | String a= String.valueOf(v); |
| | | BigDecimal w = (BigDecimal) map.get(i).get("drp"); |
| | | double drp = w.doubleValue(); |
| | | stcd = map.get(i).get("STCD").toString(); |
| | | //计算湿度 |
| | | if (i == 0) { |
| | | v1 = formatDouble1((num + drp) * 0.85); |
| | | } else { |
| | | v1 += drp; |
| | | v1 = formatDouble1(v1 * 0.85); |
| | | } |
| | | } |
| | | if (v1 > 60) { |
| | | mountainrainService.soleInster(stcd, "60"); |
| | | } else { |
| | | String a = String.valueOf(v1); |
| | | mountainrainService.soleInster(stcd,a); |
| | | } |
| | | } |
| | | |
| | | return R.success("成功"); |
| | | } |
| | | |
| | | public static double formatDouble1(double d) { |
| | | return (double) Math.round(d * 10) / 10; |
| | | } |
| | | |
| | | private static String getDays(int i, boolean b) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | if (b) { |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + i); |
| | | } else { |
| | | calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - i); |
| | | } |
| | | Date today = calendar.getTime(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd 08:00:00"); |
| | | String result = format.format(today); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |