From d254c34b538e190fd5a9355d757f64bd495bdda9 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 26 四月 2023 11:01:33 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/dao/SuYuanMapper.java | 3 + src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java | 72 +++++++++++++++++------- src/main/java/com/yssh/service/ISuYuanService.java | 18 +++-- src/main/resources/mapping/SuYuanMapper.xml | 4 + src/main/java/com/yssh/service/impl/DictRecordServiceImpl.java | 6 + src/main/java/com/yssh/service/IDictRecordService.java | 2 src/main/java/com/yssh/controller/SuYuanController.java | 72 +++++++++++++---------- 7 files changed, 115 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/yssh/controller/SuYuanController.java b/src/main/java/com/yssh/controller/SuYuanController.java index b0d4e91..7adc24c 100644 --- a/src/main/java/com/yssh/controller/SuYuanController.java +++ b/src/main/java/com/yssh/controller/SuYuanController.java @@ -33,7 +33,7 @@ @RequestMapping("/suYuan") @SuppressWarnings("rawtypes") public class SuYuanController { - + @Autowired private ISuYuanService suYuanService; @@ -41,66 +41,76 @@ @ApiOperationSupport(order = 1) @GetMapping("/get2d") public Result get2d( - @RequestParam(value = "date", required = true)@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date){ - List<SuYuan2d> list = suYuanService.selectSuYuan2d(date); - return Result.OK(list); + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + List<SuYuan2d> list = suYuanService.selectSuYuan2d(date); + return Result.OK(list); } - + @ApiOperation(value = "鏌ヨ3d鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ3d鐑姏鍥炬暟鎹�") @ApiOperationSupport(order = 2) @GetMapping("/get3d") public Result get3d( - @RequestParam(value = "name", required = true) String name, - @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date){ - List<SuYuan3d> list = suYuanService.selectSuYuan3d(name, date); - return Result.OK(list); + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) { + List<SuYuan3d> list = suYuanService.selectSuYuan3d(name, date); + return Result.OK(list); } - + @ApiOperation(value = "鏌ヨ婧簮100鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮100鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") @ApiOperationSupport(order = 3) @GetMapping("/get100") public Result get100( - @RequestParam(value = "name", required = true) String name, - @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date - ){ - return Result.OK(suYuanService.selectSuYuan100(name, date)); + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan100(name, date)); } @ApiOperation(value = "鏌ヨ婧簮200鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮200鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") @ApiOperationSupport(order = 4) @GetMapping("/get200") public Result get200( - @RequestParam(value = "name", required = true) String name, - @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date - ){ - return Result.OK(suYuanService.selectSuYuan200(name, date)); + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan200(name, date)); } - + @ApiOperation(value = "鏌ヨ婧簮300鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮300鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") @ApiOperationSupport(order = 5) @GetMapping("/get300") public Result get300( - @RequestParam(value = "name", required = true) String name, - @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date - ){ - return Result.OK(suYuanService.selectSuYuan300(name, date)); + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan300(name, date)); } @ApiOperation(value = "鏌ヨ婧簮500鐑姏鍥炬暟鎹�", notes = "鏍规嵁鏃堕棿鏌ヨ婧簮500鐑姏鍥炬暟鎹紝result杩斿洖鍊间腑data瀵瑰簲鍊间负鐑姏鍥炬暟鎹紝feedbackId涓哄弽棣堜富閿紪鍙凤紝鍦ㄨ繘琛屽弽棣堜腑闇�瑕佷紶閫�") @ApiOperationSupport(order = 6) @GetMapping("/get500") public Result get500( - @RequestParam(value = "name", required = true) String name, - @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date - ){ - return Result.OK(suYuanService.selectSuYuan500(name, date)); + @RequestParam(value = "name", required = true) String name, + @RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date + ) { + return Result.OK(suYuanService.selectSuYuan500(name, date)); } - + @ApiOperation(value = "鑾峰彇鎵�鏈夌洃娴嬫暟鎹�", notes = "鑾峰彇鎵�鏈夌洃娴嬫暟鎹�") @ApiOperationSupport(order = 7) @GetMapping("/query/{name}") - public Result getMonitorData(@PathVariable("name") String name){ - List<SuYuanMonitorData> list = suYuanService.getMonitorData(name); - return Result.OK(list); + public Result getMonitorData(@PathVariable("name") String name) { + List<SuYuanMonitorData> list = suYuanService.getMonitorData(name); + return Result.OK(list); + } + + @ApiOperation(value = "鏇存柊Vocs鍚嶇О", notes = "鏇存柊Vocs鍚嶇О") + @ApiOperationSupport(order = 7) + @GetMapping("/updateVocsName") + public Result updateVocsName(@RequestParam(value = "date", required = true) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date, + @RequestParam(value = "id", required = true) String id, + @RequestParam(value = "vocsName", required = true) String vocsName + ) { + return Result.OK(suYuanService.updateVocsName(date, id, vocsName)); } } diff --git a/src/main/java/com/yssh/dao/SuYuanMapper.java b/src/main/java/com/yssh/dao/SuYuanMapper.java index 61038f1..0228a63 100644 --- a/src/main/java/com/yssh/dao/SuYuanMapper.java +++ b/src/main/java/com/yssh/dao/SuYuanMapper.java @@ -1,5 +1,6 @@ package com.yssh.dao; +import java.util.Date; import java.util.List; import java.util.Map; @@ -36,4 +37,6 @@ //鑾峰彇鏈湀鎸囧畾鐩戞祴绔欑偣鐩戞祴鍊煎澶х殑鏁版嵁 Map<String, Object> getMonthValueDataMax(@Param("tableNames") List<String> tableNames, @Param("id") String id); + + int updateVocsName(String table, String id, String vocsName); } diff --git a/src/main/java/com/yssh/service/IDictRecordService.java b/src/main/java/com/yssh/service/IDictRecordService.java index a7f43f1..211732b 100644 --- a/src/main/java/com/yssh/service/IDictRecordService.java +++ b/src/main/java/com/yssh/service/IDictRecordService.java @@ -2,6 +2,7 @@ import com.yssh.entity.DictRecord; +import java.util.Date; import java.util.List; /** @@ -45,5 +46,4 @@ * 鍒涘缓瀛楀吀璁板綍淇℃伅琛� */ int createDictRecoTable(); - } diff --git a/src/main/java/com/yssh/service/ISuYuanService.java b/src/main/java/com/yssh/service/ISuYuanService.java index 01c28a5..c027fac 100644 --- a/src/main/java/com/yssh/service/ISuYuanService.java +++ b/src/main/java/com/yssh/service/ISuYuanService.java @@ -14,22 +14,24 @@ public Integer isTableExists(String tableName); public void insertSuYuanDatas(List<SuYuan> lists, String time) throws Exception; - + int createNewTable(String tableName); - + public List<SuYuan2d> selectSuYuan2d(Date date); - + public List<SuYuan3d> selectSuYuan3d(String name, Date date); - + public Map<String, Object> selectSuYuan100(String name, Date date); - + public Map<String, Object> selectSuYuan200(String name, Date date); - + public Map<String, Object> selectSuYuan300(String name, Date date); - + public Map<String, Object> selectSuYuan500(String name, Date date); - + public List<SuYuanMonitorData> getMonitorData(String name); //public List<Temporary> temporary(String name, Date date); + + public int updateVocsName(Date date, String id, String vocsName); } diff --git a/src/main/java/com/yssh/service/impl/DictRecordServiceImpl.java b/src/main/java/com/yssh/service/impl/DictRecordServiceImpl.java index 1fda56f..c99aa7d 100644 --- a/src/main/java/com/yssh/service/impl/DictRecordServiceImpl.java +++ b/src/main/java/com/yssh/service/impl/DictRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.yssh.service.impl; +import java.util.Date; import java.util.List; import lombok.Synchronized; @@ -25,6 +26,7 @@ /** * 鏌ヨ瀛楀吀璁板綍鍒楄〃 + * * @param dictRecord 瀛楀吀璁板綍 * @return 瀛楀吀璁板綍 */ @@ -35,6 +37,7 @@ /** * 鏂板瀛楀吀璁板綍 + * * @param dictRecord 瀛楀吀璁板綍 * @return 缁撴灉 */ @@ -45,6 +48,7 @@ /** * 鍒犻櫎瀛楀吀璁板綍瀵硅薄 + * * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID * @return 缁撴灉 */ @@ -56,6 +60,7 @@ /** * 鍒犻櫎瀛楀吀璁板綍淇℃伅 + * * @param id 瀛楀吀璁板綍ID * @return 缁撴灉 */ @@ -73,5 +78,4 @@ public int createDictRecoTable() { return dictRecordMapper.createDictRecoTable(); } - } diff --git a/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java b/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java index 5d2a37b..e3c8904 100644 --- a/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java +++ b/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java @@ -1,5 +1,6 @@ package com.yssh.service.impl; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -39,38 +40,40 @@ public class SuYuanServiceImpl implements ISuYuanService { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); - + @Autowired private SuYuanMapper suYuanMapper; - + @Autowired - private IAsyncService asyncService; - + private IAsyncService asyncService; + @Autowired private DictRecordMapper dictRecordMapper; - + @Autowired private ICommonService commonService; - + @Autowired private FeedbackMapper feedbackMapper; - + + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH"); + //@Transactional @Override @Async("threadPoolTaskExecutor") - public void insertSuYuanDatas(List<SuYuan> lists, String time) throws Exception{ + public void insertSuYuanDatas(List<SuYuan> lists, String time) throws Exception { //鎻掑叆鏁版嵁 List<List<SuYuan>> list = Lists.partition(lists, IAsyncService.BATCH_INSERT_NUMBER); CountDownLatch countDownLatch = new CountDownLatch(list.size()); for (List<SuYuan> corpReserveList : list) { asyncService.executeAsync(TableStrategy.getTableStrategy(time), corpReserveList, suYuanMapper, countDownLatch); } - countDownLatch.await(); + countDownLatch.await(); logger.info(lists.size() + "鏉℃暟鎹叆搴撳畬鎴�-----"); } @Override - public Integer isTableExists(String tableName){ + public Integer isTableExists(String tableName) { return suYuanMapper.isTableExists(tableName); } @@ -122,11 +125,15 @@ } List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); AtomicInteger i = new AtomicInteger(0); - list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());}); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); if (StringUtils.isNotEmpty(list)) { Collections.sort(list); DistanceSuYuan max = list.get(0); - FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); feedbackMapper.insert(feedbackDetail); result.put("feedbackId", feedbackDetail.getId()); @@ -151,11 +158,15 @@ } List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); AtomicInteger i = new AtomicInteger(0); - list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());}); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); if (StringUtils.isNotEmpty(list)) { Collections.sort(list); DistanceSuYuan max = list.get(0); - FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); feedbackMapper.insert(feedbackDetail); result.put("feedbackId", feedbackDetail.getId()); @@ -163,7 +174,7 @@ result.put("data", list); return result; } - + @Override public Map<String, Object> selectSuYuan300(String name, Date date) { Map<String, Object> result = new HashMap<String, Object>(); @@ -180,11 +191,15 @@ } List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); AtomicInteger i = new AtomicInteger(0); - list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());}); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); if (StringUtils.isNotEmpty(list)) { Collections.sort(list); DistanceSuYuan max = list.get(0); - FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); feedbackMapper.insert(feedbackDetail); result.put("feedbackId", feedbackDetail.getId()); @@ -192,7 +207,7 @@ result.put("data", list); return result; } - + @Override public Map<String, Object> selectSuYuan500(String name, Date date) { Map<String, Object> result = new HashMap<String, Object>(); @@ -209,11 +224,15 @@ } List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d); AtomicInteger i = new AtomicInteger(0); - list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());}); + list.stream().forEach(s -> { + s.setName(checkPoint.getName()); + i.getAndIncrement(); + s.setVocsName(checkPoint.getName() + "-" + i.longValue()); + }); if (StringUtils.isNotEmpty(list)) { Collections.sort(list); DistanceSuYuan max = list.get(0); - FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), + FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(), max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate()); feedbackMapper.insert(feedbackDetail); result.put("feedbackId", feedbackDetail.getId()); @@ -230,8 +249,19 @@ } List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord()); List<String> tableNames = new ArrayList<String>(); - recordList.stream().forEach(s -> {tableNames.add(s.getTableName());}); + recordList.stream().forEach(s -> { + tableNames.add(s.getTableName()); + }); return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ()); } + @Override + public int updateVocsName(Date date, String id, String vocsName) { + String table = "su_yuan_" + dateFormat.format(new Date()); + if (isTableExists(table) == 0) { + return 0; + } + + return suYuanMapper.updateVocsName(table, id, vocsName); + } } diff --git a/src/main/resources/mapping/SuYuanMapper.xml b/src/main/resources/mapping/SuYuanMapper.xml index a6d162a..d2a5408 100644 --- a/src/main/resources/mapping/SuYuanMapper.xml +++ b/src/main/resources/mapping/SuYuanMapper.xml @@ -191,4 +191,8 @@ <update id="update" > UPDATE ${tableName} SET c = #{value} WHERE id = #{id} </update> + + <update id="updateVocsName"> + update ${table} set vocsName = #{vocsName} where id = #{id}; + </update> </mapper> \ No newline at end of file -- Gitblit v1.9.3