From 4bf8db5a3d574e5175f8e08a76d08effd3b31a9e Mon Sep 17 00:00:00 2001 From: aijinhui <aijinhui> Date: 星期五, 06 十月 2023 14:02:25 +0800 Subject: [PATCH] 厂区介绍 --- ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java | 255 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 212 insertions(+), 43 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java index 9aae3b1..b04585d 100644 --- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java @@ -2,6 +2,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -71,7 +73,8 @@ .eq("user_id",ardAppPatrolpointRecord.getUserId()); List<ArdAppPatrolpointRecord> recordList = ardAppPatrolpointRecordMapper.selectList(recordQueryWrapper); ardAppPatrolpointRecord.setPointsNum(recordList.size()+1); - int num = ardAppPatrolpointRecordMapper.insert(ardAppPatrolpointRecord); +// int num = ardAppPatrolpointRecordMapper.insert(ardAppPatrolpointRecord); + int num = ardAppPatrolpointRecordMapper.insertArdAppPatrolpointRecord(ardAppPatrolpointRecord); List<String> list = ardAppPatrolpointRecord.getImg(); for (int i = 0; i < list.size(); i++) { ArdAppPatrolpointRecordImg recordImg = new ArdAppPatrolpointRecordImg(); @@ -79,7 +82,7 @@ recordImg.setId(imgId); recordImg.setAppPatrolponitRecordId(id); recordImg.setImg(list.get(i)); - recordImgMapper.insert(recordImg); + recordImgMapper.insertArdAppPatrolpointRecordImg(recordImg); } if(num>0){ return Results.succeed("鎵撳崱鎴愬姛锛�"); @@ -112,7 +115,6 @@ monthZero = String.valueOf(month); } JSONArray jsonArray = new JSONArray(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); for (int i = 1; i <= day; i++) { String di; if(i<10){ @@ -124,24 +126,20 @@ Boolean planBoolean = false; //寰幆姣忎竴澶� String ymd = year+"-"+monthZero+"-"+di; -// Date ymdDate = dateFormat.parse(ymd); //鍖归厤璁″垝鏃堕棿 String cycle = ardAppPatrolplan.getCycle(); if(cycle.equals("day")){ String createTime = ardAppPatrolplan.getCreateTime(); -// Date beginCreateDate = dateFormat.parse(createTime); - int d = ymd.compareTo(createTime); + String st = createTime.substring(0,10); + int d = ymd.compareTo(st); if(d>=0){ planBoolean = true; } }else if(cycle.equals("once")){ String onceBegin = ardAppPatrolplan.getPatroBeginTime(); -// Date onceBeginDate = dateFormat.parse(onceBegin); - String onceEnd = ardAppPatrolplan.getPatroEndTime(); -// Date onceEndDate = dateFormat.parse(onceEnd); - int bd = ymd.compareTo(onceBegin); - int ed = ymd.compareTo(onceEnd); - if(bd>=0 && ed<=0){ + String onceT = onceBegin.substring(0,10); + int num = ymd.compareTo(onceT); + if(num==0){ planBoolean = true; } } @@ -149,31 +147,49 @@ Boolean or = false; if(planBoolean){ for (int j = 0; j < list.size(); j++) { - //鎵撳崱鏃堕棿鎷嗗垎 - String recordTime = list.get(j).getRecordTime(); - String[] part = recordTime.split("[-\\s:]"); - int recordYear = Integer.parseInt(part[0]); - int recordMonth = Integer.parseInt(part[1]); - String recordMonthZero; - if(recordMonth<10){ - recordMonthZero = String.format("%02d", recordMonth); - }else { - recordMonthZero = String.valueOf(recordMonth); - } - int recordDay = Integer.parseInt(part[2]); - String recordDayZero; - if(recordDay<10){ - recordDayZero = String.format("%02d", recordDay); - }else { - recordDayZero = String.valueOf(recordDay); - } - String recordDate = recordYear+"-"+recordMonthZero+"-"+recordDayZero; - //濡傛灉鐩哥瓑璇存槑杩欏ぉ鏈夋墦鍗¤褰曡褰� - if(ymd.equals(recordDate)){ - or = true; - break; + //鑾峰彇鎵撳崱鏃堕棿 + String toDayRecord = list.get(j).getRecordTime(); + String dr = toDayRecord.substring(0,10); + //濡傛灉鎵撳紑鏃ユ湡鍜岃繖澶╃浉鍚� + if(ymd.equals(dr)){ + //鏌ヨ璇ヨ鍒掔殑鎵�鏈夊叴瓒g偣 + List<ArdAlarmpointsWell> wellList = wellMapper.wellByPlanId(planId); + //鏌ヨ璇ヨ鍒掔殑鎵�鏈夋墽琛屼汉 + List<SysUser> userList = sysUserMapper.userByPlanId(planId); + //婊″嫟澶氬皯鏉℃墦鍗¤褰� + int maxNum = wellList.size()*userList.size(); + //瀵规瘮搴旀墦鍗¤褰曠浉绛夊垯true + if(list.size()==maxNum){ + or = true; + } } } +// for (int j = 0; j < list.size(); j++) { +// //鎵撳崱鏃堕棿鎷嗗垎 +// String recordTime = list.get(j).getRecordTime(); +// String[] part = recordTime.split("[-\\s:]"); +// int recordYear = Integer.parseInt(part[0]); +// int recordMonth = Integer.parseInt(part[1]); +// String recordMonthZero; +// if(recordMonth<10){ +// recordMonthZero = String.format("%02d", recordMonth); +// }else { +// recordMonthZero = String.valueOf(recordMonth); +// } +// int recordDay = Integer.parseInt(part[2]); +// String recordDayZero; +// if(recordDay<10){ +// recordDayZero = String.format("%02d", recordDay); +// }else { +// recordDayZero = String.valueOf(recordDay); +// } +// String recordDate = recordYear+"-"+recordMonthZero+"-"+recordDayZero; +// //濡傛灉鐩哥瓑璇存槑杩欏ぉ鏈夋墦鍗¤褰曡褰� +// if(ymd.equals(recordDate)){ +// or = true; +// break; +// } +// } } jsonObject.put("toDay",ymd ); jsonObject.put("plan",planBoolean); @@ -186,7 +202,7 @@ @Override public Results recordDetails(RecordDetailsParam recordDetailsParam) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //鑾峰彇鍙傛暟 String planId = recordDetailsParam.getPlanId(); String toDay = recordDetailsParam.getToDay(); @@ -237,8 +253,9 @@ //灏忎簬0鏄巻鍙� recordQueryWrapper.select("max(points_num) pointsNum","user_id","user_name").eq("plan_id", planId).like("record_time", toDay).groupBy("user_id","user_name"); }else{ + String u = dateFormatTime.format(new Date()); //绛変簬0閫変腑鐨勬棩鏈熷氨鏄粖澶╋紝闇�瑕佽繘涓�姝ュ垽鏂皬浜庡綋鍓嶆椂鍒嗙鐨勮褰� - recordQueryWrapper.select("max(points_num) pointsNum","user_id","user_name").eq("plan_id", planId).le("record_time", dateFormatTime.format(new Date())).groupBy("user_id","user_name");; + recordQueryWrapper.select("max(points_num) pointsNum","user_id","user_name").eq("plan_id", planId).le("record_time", u).groupBy("user_id","user_name"); } List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(recordQueryWrapper); //閫変腑杩欏ぉ璇ヨ鍒掍笅娌℃湁浠讳綍鎵撳崱璁板綍 @@ -299,10 +316,20 @@ String userId = recordSoloParam.getUserId(); String planName = recordSoloParam.getPlanName(); String userName = recordSoloParam.getUserName(); + //鏍规嵁璁″垝ID鑾峰彇鍒跺畾浜篒D + ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId); + //鏍规嵁濮撳悕ID鏌ヨ璁″垝鍒跺畾浜虹殑濮撳悕 + String planUserId = ardAppPatrolplan.getUserId(); + SysUser sysUser = sysUserMapper.selectById(planUserId); + String nikeName = sysUser.getNickName(); QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("plan_id", planId).eq("user_id",userId).like("record_time", toDay); //褰撳墠璁″垝閫変腑鏃堕棿閲屾鐢ㄦ埛鐨勬墦鍗¤褰� List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); + for (int i = 0; i < list.size(); i++) { + ArdAppPatrolpointRecord ardAppPatrolpointRecord = list.get(i); + ardAppPatrolpointRecord.setPlanUserName(nikeName); + } //鏌ヨ璇ヨ鍒掔殑鎵�鏈夊叴瓒g偣 List<ArdAlarmpointsWell> wellList = wellMapper.wellByPlanId(planId); if(list.size()==0){ @@ -316,6 +343,7 @@ ardAppPatrolpointRecord.setUserName(userName); ardAppPatrolpointRecord.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude())); ardAppPatrolpointRecord.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString())); + ardAppPatrolpointRecord.setPlanUserName(nikeName); list.add(ardAppPatrolpointRecord); } return Results.succeed(list); @@ -349,6 +377,7 @@ ardAppPatrolpointRecord.setUserName(userName); ardAppPatrolpointRecord.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude())); ardAppPatrolpointRecord.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString())); + ardAppPatrolpointRecord.setPlanUserName(nikeName); list.add(ardAppPatrolpointRecord); } } @@ -448,9 +477,9 @@ } @Override - public Results executeDetails(RecordDetailsParam recordDetailsParam) throws ParseException { + public Results executeDetailsOld(RecordDetailsParam recordDetailsParam) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String userId = SecurityUtils.getUserId(); //鑾峰彇鍙傛暟 String planId = recordDetailsParam.getPlanId(); @@ -632,14 +661,14 @@ int planNum = dayNum+onceNum; //杩欏ぉ鎬诲叴瓒g偣鏁� int wellNum = dayWell+onceWell; - QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("user_id",userId).like("record_time",ymd); - List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); //宸叉墦鍗℃�绘潯鏁� + QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id",userId).like("record_time",ymd).isNull("del"); + List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); int num = list.size(); //搴旀墦鍗℃�绘潯鏁� int record = planNum*wellNum; - if(num==record){ + if(num>=record){ recordBoolean = true; } } @@ -650,4 +679,144 @@ } return Results.succeed(jsonArray); } + + @Override + public Results executeDetails(RecordDetailsExParam recordDetailsExParam) throws ParseException { + String userId = SecurityUtils.getUserId(); + //鑾峰彇鍙傛暟 + Boolean plan = recordDetailsExParam.getPlan(); + String toDay = recordDetailsExParam.getToDay(); + JSONArray jsonArray = new JSONArray(); + if(plan){ + //鏌ヨ杩欎釜鐢ㄦ埛涓嬩负鎵ц浜虹殑鎵�鏈夊贰妫�璁″垝 + ArdAppPatrolplan ardAppPatrolplan = new ArdAppPatrolplan(); + ardAppPatrolplan.setUserId(SecurityUtils.getUserId()); + List<ArdAppPatrolplan> list = patrolplanMapper.executeList(ardAppPatrolplan); + //鎵惧嚭浠婂ぉ鐨勫崟娆″拰姣忔棩璁″垝 + List<ArdAppPatrolplan> patrolplanList = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + String cycle = list.get(i).getCycle(); + //濡傛灉鏄崟娆′换鍔� + if(cycle.equals("once")){ + String begin = list.get(i).getPatroBeginTime(); + String b = begin.substring(0,10); + if(b.equals(toDay)){ + //鏄粖澶╃殑璁″垝 + patrolplanList.add(list.get(i)); + } + } + //濡傛灉鏄瘡鏃ヤ换鍔� + else if(cycle.equals("day")){ + String create = list.get(i).getCreateTime(); + String c = create.substring(0,10); + if(c.compareTo(toDay)<=0){ + //鏈変粖澶╃殑璁″垝 + patrolplanList.add(list.get(i)); + } + } + } + if(patrolplanList.size()>0){ + //閬嶅巻浠婂ぉ鐨勮鍒� + for (int i = 0; i < patrolplanList.size(); i++) { + String planId = patrolplanList.get(i).getId(); + String planName = patrolplanList.get(i).getPlanName(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("planId",planId); + jsonObject.put("planName",planName); + //鏌ヨ杩欏ぉ鏈夊灏戠偣 + List<ArdAlarmpointsWell> dayWells = wellMapper.wellByPlanId(planId); + int dayWellNum = dayWells.size(); + //鏌ヨ杩欎釜鐢ㄦ埛鐨勮繖涓鍒掑湪浠婂ぉ鎵撳崱鐨勬潯鏁� + QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("user_id",userId).eq("plan_id",planId).like("record_time",toDay); + List<ArdAppPatrolpointRecord> recordList = ardAppPatrolpointRecordMapper.selectList(queryWrapper); + int recordNum = recordList.size(); + //濡傛灉鐩哥瓑閭h繖鏉′粖澶╃殑璁″垝灏辨槸鍏ㄩ儴瀹屾垚浜� + if(recordNum==dayWellNum){ + jsonObject.put("type",true); + }else { + jsonObject.put("type",false); + } + jsonArray.add(jsonObject); + } + } + }else { + //娌℃湁璁″垝 + return Results.succeed("[]"); + } + return Results.succeed(jsonArray); + } + + @Override + public Results recordBefore(RecordBeforeParam recordBeforeParam) { + String planId = recordBeforeParam.getPlanId(); + String wellId = recordBeforeParam.getWellId(); + String toDay = recordBeforeParam.getToDay(); + String userId = SecurityUtils.getUserId(); + JSONArray jsonArray = new JSONArray(); + ArdAppPatrolplan plan = patrolplanMapper.selectById(planId); + jsonArray.add(plan); + QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("plan_id",planId).eq("app_patrolpoints_id",wellId).eq("user_id",userId).like("record_time",toDay); + ArdAppPatrolpointRecord record = ardAppPatrolpointRecordMapper.selectOne(queryWrapper); + //鏍规嵁濮撳悕ID鏌ヨ璁″垝鍒跺畾浜虹殑濮撳悕 + String planUserId = plan.getUserId(); + SysUser sysUser = sysUserMapper.selectById(planUserId); + String nikeName = sysUser.getNickName(); + if(record==null){ + //鏍规嵁濮撳悕ID鏌ヨ鎵ц浜哄鍚� + SysUser user = sysUserMapper.selectById(userId); + String userName = user.getNickName(); + //鏌ヨ璇ヨ鍒掔殑鎵�鏈夊叴瓒g偣 + ArdAlarmpointsWell ardAlarmpointsWell = wellMapper.selectById(wellId); + //娌℃墦鍗$殑鏁版嵁 + ArdAppPatrolpointRecord record1 = new ArdAppPatrolpointRecord(); + record1.setAppPatrolpointsId(ardAlarmpointsWell.getId()); + record1.setAppPatrolpointsName(ardAlarmpointsWell.getWellId()); + record1.setPlanId(planId); + record1.setPlanName(plan.getPlanName()); + record1.setUserId(userId); + record1.setUserName(userName); + record1.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude())); + record1.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString())); + record1.setPlanUserName(nikeName); + jsonArray.add(record1); + }else { + jsonArray.add(record); + } + return Results.succeed(jsonArray); + } + + @Override + public Results son() { + DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + //鑾峰彇鐢ㄦ埛鎵ц浜� + String userId = SecurityUtils.getUserId(); + // 鍑忓皯 10 绉� + LocalDateTime now = LocalDateTime.now(); // 鑾峰彇褰撳墠鏃ユ湡鏃堕棿 + LocalDateTime earlier = now.minusSeconds(10); // 鍑忓皯30绉� + RecordSonParam recordSonParam = new RecordSonParam(); + recordSonParam.setUserId(userId); + String n = fmt.format(now); + recordSonParam.setTime(n); + String e = fmt.format(earlier); + recordSonParam.setBeforeTime(e); + //鏍规嵁濮撳悕ID涓烘墽琛屼汉鑾峰彇鎵�鏈夊搴旂殑璁″垝鍚嶇О + List<ArdAppPatrolplan> list = patrolplanMapper.planUser(recordSonParam); + JSONArray jsonArray = new JSONArray(); + JSONObject jsonObject = new JSONObject(); + if(list.size()>0){ + jsonObject.put("plan",true); + jsonObject.put("user",list.get(0).getNickName()); + jsonObject.put("name",list.get(0).getPlanName()); +// list.get(0).setSon("宸查�氱煡"); +// patrolplanMapper.updateById(list.get(0)); + }else { + jsonObject.put("plan",false); + jsonObject.put("user",null); + jsonObject.put("name",null); + } + jsonArray.add(jsonObject); + return Results.succeed(jsonArray); + } } -- Gitblit v1.9.3