Commit 61f9db5f47a348c392648e03adc1960d68696745

Authored by yiming
1 parent 40b60b30

大客流临加记录

src/main/java/com/bsth/data/zndd/OutEntrance.java
@@ -17,7 +17,13 @@ import org.slf4j.Logger; @@ -17,7 +17,13 @@ import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 17 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.beans.factory.annotation.Value; 19 import org.springframework.beans.factory.annotation.Value;
  20 +import org.springframework.scheduling.annotation.Scheduled;
20 import org.springframework.web.bind.annotation.*; 21 import org.springframework.web.bind.annotation.*;
  22 +import java.io.*;
  23 +import java.nio.file.Files;
  24 +import java.nio.file.Path;
  25 +import java.nio.file.Paths;
  26 +import java.nio.file.StandardCopyOption;
21 27
22 import java.io.ByteArrayInputStream; 28 import java.io.ByteArrayInputStream;
23 import java.io.File; 29 import java.io.File;
@@ -262,7 +268,7 @@ public class OutEntrance { @@ -262,7 +268,7 @@ public class OutEntrance {
262 rtn.put("status",ResponseCode.SUCCESS); 268 rtn.put("status",ResponseCode.SUCCESS);
263 } catch (Exception e) { 269 } catch (Exception e) {
264 rtn.put("status", ResponseCode.ERROR); 270 rtn.put("status", ResponseCode.ERROR);
265 - Logger logger = LoggerFactory.getLogger(this.getClass()); 271 + logger.error("大客流推送异常----",e);
266 } 272 }
267 return rtn; 273 return rtn;
268 } 274 }
@@ -308,7 +314,7 @@ public class OutEntrance { @@ -308,7 +314,7 @@ public class OutEntrance {
308 destfile.mkdirs(); 314 destfile.mkdirs();
309 } 315 }
310 //文件新名称 316 //文件新名称
311 - String fileNameNew = "666"+ ".png"; 317 + String fileNameNew = AutomaticSch.UUID()+ ".png";
312 File f = new File(destfile.getAbsoluteFile() + File.separator + fileNameNew); 318 File f = new File(destfile.getAbsoluteFile() + File.separator + fileNameNew);
313 // 将字符串转换成二进制,用于显示图片 319 // 将字符串转换成二进制,用于显示图片
314 // 将上面生成的图片格式字符串 imgStr,还原成图片显示 320 // 将上面生成的图片格式字符串 imgStr,还原成图片显示
@@ -334,6 +340,30 @@ public class OutEntrance { @@ -334,6 +340,30 @@ public class OutEntrance {
334 return null; 340 return null;
335 } 341 }
336 342
  343 + /**
  344 + * 转移文件图片
  345 + * @param url 文件路径
  346 + * @param (示例:D:\\1.png)
  347 + * @return
  348 + */
  349 + public String moveImg(String url) throws Exception {
  350 + try {
  351 + String file = url.replace("/"+profile+"/avat",imgurl+"/img");
  352 + String destDir = file.substring(0,file.lastIndexOf("/"));
  353 + File destPath = new File(destDir);
  354 + if (!destPath.exists()) {
  355 + destPath.mkdirs();
  356 + }
  357 + Path sourceFile= Paths.get(url.replace("/"+profile,imgurl));
  358 + Path destFile= Paths.get(url.replace("/"+profile+"/avat",imgurl+"/img"));
  359 + Files.copy(sourceFile, destFile,StandardCopyOption.REPLACE_EXISTING);
  360 + return file;
  361 + } catch (IOException e) {
  362 + e.printStackTrace();
  363 + return null;
  364 + }
  365 + }
  366 +
337 private static ConcurrentMap<String, Map<String,Object>> trafficMap = new ConcurrentHashMap<>(); 367 private static ConcurrentMap<String, Map<String,Object>> trafficMap = new ConcurrentHashMap<>();
338 public String getTraffic(String nbbm,String lon,String lat){ 368 public String getTraffic(String nbbm,String lon,String lat){
339 Map<String,Object> traffic=trafficMap.get(nbbm); 369 Map<String,Object> traffic=trafficMap.get(nbbm);
@@ -359,5 +389,26 @@ public class OutEntrance { @@ -359,5 +389,26 @@ public class OutEntrance {
359 return traffic.get("trafficStatus").toString(); 389 return traffic.get("trafficStatus").toString();
360 } 390 }
361 391
  392 + @Scheduled(cron = "0 0 0 * * ?")
  393 + public void clearImg(){
  394 + try {
  395 + File folder=new File(imgurl+"/avat");
  396 + delete(folder);
  397 + } catch (Exception e) {
  398 + e.printStackTrace();
  399 + }
  400 + }
  401 +
  402 + public static void delete(File folder) throws Exception{
  403 + if(folder.isDirectory()) {
  404 + File[] files = folder.listFiles();
  405 + if(files != null) { // 如果文件夹为空,files可能为null
  406 + for(File file : files) {
  407 + delete(file); // 递归删除子文件夹和文件
  408 + }
  409 + }
  410 + }
  411 + folder.delete(); // 删除空文件夹或者文件
  412 + }
362 413
363 } 414 }
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
@@ -245,6 +245,18 @@ public class ScheduleRealInfo { @@ -245,6 +245,18 @@ public class ScheduleRealInfo {
245 @Transient 245 @Transient
246 private String kxcl; 246 private String kxcl;
247 247
  248 + /**
  249 + * 大客流图片
  250 + */
  251 + @Transient
  252 + private String img;
  253 +
  254 + /**
  255 + * 操作类型 大客流-1
  256 + */
  257 + @Transient
  258 + private String operationType;
  259 +
248 public Integer getLpChange() { 260 public Integer getLpChange() {
249 return lpChange; 261 return lpChange;
250 } 262 }
@@ -1026,4 +1038,20 @@ public class ScheduleRealInfo { @@ -1026,4 +1038,20 @@ public class ScheduleRealInfo {
1026 public void setKxcl(String kxcl) { 1038 public void setKxcl(String kxcl) {
1027 this.kxcl = kxcl; 1039 this.kxcl = kxcl;
1028 } 1040 }
  1041 +
  1042 + public String getImg() {
  1043 + return img;
  1044 + }
  1045 +
  1046 + public void setImg(String img) {
  1047 + this.img = img;
  1048 + }
  1049 +
  1050 + public String getOperationType() {
  1051 + return operationType;
  1052 + }
  1053 +
  1054 + public void setOperationType(String operationType) {
  1055 + this.operationType = operationType;
  1056 + }
1029 } 1057 }
src/main/java/com/bsth/entity/zndd/LoggerZndd.java
@@ -32,6 +32,8 @@ public class LoggerZndd implements Serializable { @@ -32,6 +32,8 @@ public class LoggerZndd implements Serializable {
32 32
33 private String dir; 33 private String dir;
34 34
  35 + private String img;
  36 +
35 // 创建日期 37 // 创建日期
36 @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") 38 @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
37 private Date createDate; 39 private Date createDate;
@@ -107,4 +109,12 @@ public class LoggerZndd implements Serializable { @@ -107,4 +109,12 @@ public class LoggerZndd implements Serializable {
107 public void setDir(String dir) { 109 public void setDir(String dir) {
108 this.dir = dir; 110 this.dir = dir;
109 } 111 }
  112 +
  113 + public String getImg() {
  114 + return img;
  115 + }
  116 +
  117 + public void setImg(String img) {
  118 + this.img = img;
  119 + }
110 } 120 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -11,6 +11,7 @@ import java.sql.SQLException; @@ -11,6 +11,7 @@ import java.sql.SQLException;
11 import java.text.DecimalFormat; 11 import java.text.DecimalFormat;
12 import java.text.ParseException; 12 import java.text.ParseException;
13 import java.text.SimpleDateFormat; 13 import java.text.SimpleDateFormat;
  14 +import java.time.LocalDate;
14 import java.util.ArrayList; 15 import java.util.ArrayList;
15 import java.util.Calendar; 16 import java.util.Calendar;
16 import java.util.Collection; 17 import java.util.Collection;
@@ -29,6 +30,7 @@ import java.util.concurrent.*; @@ -29,6 +30,7 @@ import java.util.concurrent.*;
29 import java.util.regex.Pattern; 30 import java.util.regex.Pattern;
30 31
31 import com.bsth.data.SystemParamCache; 32 import com.bsth.data.SystemParamCache;
  33 +import com.bsth.data.zndd.OutEntrance;
32 import com.bsth.entity.zndd.LoggerZndd; 34 import com.bsth.entity.zndd.LoggerZndd;
33 import com.bsth.repository.zndd.LoggerZnddRepository; 35 import com.bsth.repository.zndd.LoggerZnddRepository;
34 import org.apache.commons.io.IOUtils; 36 import org.apache.commons.io.IOUtils;
@@ -228,6 +230,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -228,6 +230,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
228 @Autowired 230 @Autowired
229 LoggerZnddRepository loggerZnddRepository; 231 LoggerZnddRepository loggerZnddRepository;
230 232
  233 + @Autowired
  234 + OutEntrance outEntrance;
  235 +
231 Logger logger = LoggerFactory.getLogger(this.getClass()); 236 Logger logger = LoggerFactory.getLogger(this.getClass());
232 237
233 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), 238 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
@@ -728,6 +733,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -728,6 +733,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
728 public Map<String, Object> save(ScheduleRealInfo sch) { 733 public Map<String, Object> save(ScheduleRealInfo sch) {
729 Map<String, Object> rs = new HashMap<>(); 734 Map<String, Object> rs = new HashMap<>();
730 try { 735 try {
  736 + if("1".equals(sch.getOperationType())){//大客流临加班次
  737 + String img = outEntrance.moveImg(sch.getImg());
  738 + if(img==null){
  739 + rs.put("status", ResponseCode.ERROR);
  740 + rs.put("msg", "照片缺失");
  741 + return rs;
  742 + }
  743 + LoggerZndd lz = addZndd(sch);
  744 + String text = "大客流预警:"+sch.getXlName()+"_"+sch.getFcsj()+"新增临加班次";
  745 + lz.setText(text);
  746 + lz.setCreateBy(SecurityUtils.getCurrentUser().getId());
  747 + lz.setCreateDate(new Date());
  748 + lz.setLineCode(sch.getXlBm());
  749 + lz.setLineName(sch.getXlName());
  750 + lz.setDir(sch.getXlDir());
  751 + lz.setImg(img);
  752 + String rq=java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDate.now());
  753 + lz.setRq(rq);
  754 + loggerZnddRepository.save(lz);
  755 + }
731 String clZbh = sch.getClZbh(), lpName = sch.getLpName(); 756 String clZbh = sch.getClZbh(), lpName = sch.getLpName();
732 if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) { 757 if (StringUtils.isEmpty(lpName) || StringUtils.isEmpty(lpName.trim())) {
733 rs.put("status", ResponseCode.ERROR); 758 rs.put("status", ResponseCode.ERROR);
src/main/resources/static/real_control_v2/zndd/type/dkl.html
@@ -427,6 +427,8 @@ @@ -427,6 +427,8 @@
427 data.fgsBm = line.brancheCompany; 427 data.fgsBm = line.brancheCompany;
428 } 428 }
429 429
  430 + data.img=sch.image;
  431 + data.operationType=1;
430 gb_common.$post('/realSchedule', data, function (rs) { 432 gb_common.$post('/realSchedule', data, function (rs) {
431 notify_succ('新增临加班次成功'); 433 notify_succ('新增临加班次成功');
432 cb && cb(rs); 434 cb && cb(rs);