Commit 68a67f360760778338ba090944003b5b18ae6591

Authored by Liu Haoyu
1 parent fddd4673

接口问题处理;

Showing 35 changed files with 91 additions and 277 deletions
.gitignore
1 1 /vehicle-simple.iml
2 2 /.idea/
3 3 /target/
  4 +/picture/
... ...
... ... @@ -117,7 +117,11 @@
117 117 <dependency>
118 118 <groupId>com.alibaba</groupId>
119 119 <artifactId>fastjson</artifactId>
120   - <version>1.2.54</version>
  120 + <version>1.2.57</version>
  121 + </dependency>
  122 + <dependency>
  123 + <groupId>commons-codec</groupId>
  124 + <artifactId>commons-codec</artifactId>
121 125 </dependency>
122 126 <dependency>
123 127 <groupId>org.apache.httpcomponents</groupId>
... ...
src/main/java/com/objecteye/VehicleApplication.java
... ... @@ -10,10 +10,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
10 10 import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
11 11 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
12 12 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
13   -import org.springframework.transaction.annotation.EnableTransactionManagement;
14 13  
15 14 @SpringBootApplication
16   -@EnableTransactionManagement
17 15 @EnableScheduling
18 16 @EnableWebSecurity
19 17 @EnableGlobalMethodSecurity(prePostEnabled = true)
... ...
src/main/java/com/objecteye/config/AuthenticationHeadFilter.java
... ... @@ -40,6 +40,7 @@ public class AuthenticationHeadFilter extends OncePerRequestFilter {
40 40 String claims = jwt.getClaims();
41 41 user = JSON.parseObject(claims, TokenUser.class);
42 42 } catch (Exception e) {
  43 + e.printStackTrace();
43 44 httpServletResponse.setContentType("application/json;charset=UTF-8");
44 45 httpServletResponse.getWriter().write("Useless token...");
45 46 return;
... ...
src/main/java/com/objecteye/controller/DeployController.java
... ... @@ -155,7 +155,7 @@ public class DeployController {
155 155 @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
156 156 public CommonResult delete(@RequestBody Map<String, Object> map) {
157 157 try {
158   - String[] ids = (String[]) map.get("ids");
  158 + List<String> ids = (List<String>) map.get("ids");
159 159 deployService.delete(ids);
160 160 return CommonResult.success("操作成功");
161 161 } catch (Exception e) {
... ...
src/main/java/com/objecteye/controller/FeatureController.java
... ... @@ -99,7 +99,7 @@ public class FeatureController {
99 99 @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
100 100 public CommonResult delete(@RequestBody Map<String, Object> map) {
101 101 try {
102   - String[] ids = (String[]) map.get("ids");
  102 + List<String> ids = (List<String>) map.get("ids");
103 103 featureService.delete(ids);
104 104 return CommonResult.success("操作成功");
105 105 } catch (RuntimeException e) {
... ...
src/main/java/com/objecteye/controller/PersonnelController.java
... ... @@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
11 11 import org.springframework.web.bind.annotation.*;
12 12 import org.springframework.web.multipart.MultipartFile;
13 13  
  14 +import java.util.List;
14 15 import java.util.Map;
15 16  
16 17  
... ... @@ -98,7 +99,7 @@ public class PersonnelController {
98 99 @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
99 100 public CommonResult delete(@RequestBody Map<String, Object> map) {
100 101 try {
101   - String[] ids = (String[]) map.get("ids");
  102 + List<String> ids = (List<String>) map.get("ids");
102 103 personnelService.delete(ids);
103 104 return CommonResult.success("操作成功");
104 105 } catch (Exception e) {
... ...
src/main/java/com/objecteye/controller/UploadFileController.java
1 1 package com.objecteye.controller;
2 2  
3 3 import com.objecteye.common.CommonResult;
  4 +import com.objecteye.service.IUploadFileService;
4 5 import com.objecteye.utils.GlobalUtil;
5 6 import io.swagger.annotations.Api;
6 7 import io.swagger.annotations.ApiOperation;
  8 +import org.springframework.beans.factory.annotation.Autowired;
7 9 import org.springframework.web.bind.annotation.*;
8 10 import org.springframework.web.multipart.MultipartFile;
9 11  
  12 +import java.io.IOException;
  13 +
10 14 @RestController
11 15 @RequestMapping("uploadDbMongo")
12 16 @Api(value = "UploadFileController", description = "上传文件解析保存到mongo库,代替ftp")
13 17 @CrossOrigin
14   -public class UploadFileController {
  18 +public class UploadFileController extends BasicController {
  19 +
  20 + @Autowired
  21 + private IUploadFileService iUploadFileService;
15 22  
16 23 @ApiOperation("上传文件到mongo")
17 24 @RequestMapping(value = "uploadToMongo", method = RequestMethod.POST, produces = GlobalUtil.COMMON_HEADER_CONTENT_TYPE)
18   - public CommonResult uploadToMongo(@RequestParam MultipartFile multipartFile) {
19   - return CommonResult.success("");
  25 + public CommonResult uploadToMongo(@RequestParam MultipartFile multipartFile) throws IOException {
  26 + return jsonObjectResultHandle(iUploadFileService.uploadFile2Mongo(multipartFile));
20 27 }
21 28 }
... ...
src/main/java/com/objecteye/controller/VehicleController.java
... ... @@ -57,10 +57,9 @@ public class VehicleController {
57 57 */
58 58 @ApiOperation("批量删除")
59 59 @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
60   - public CommonResult delete(@RequestBody Map<String, String[]> map) {
  60 + public CommonResult delete(@RequestBody Map<String, Object> map) {
61 61 try {
62   - String[] ids = map.get("ids");
63   - //int vehicleId= (int) map.get("vehicleId");
  62 + List<String> ids = (List<String>) map.get("ids");
64 63 vehicleService.delete(ids);
65 64 return CommonResult.success("操作成功");
66 65 } catch (Exception e) {
... ...
src/main/java/com/objecteye/controller/VehicleDbController.java
... ... @@ -99,7 +99,7 @@ public class VehicleDbController {
99 99 @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
100 100 public CommonResult delete(@RequestBody Map<String, Object> map) {
101 101 try {
102   - String[] ids = (String[]) map.get("ids");
  102 + List<String> ids = (List<String>) map.get("ids");
103 103 vehicleDbService.delete(ids);
104 104 return CommonResult.success("");
105 105 } catch (Exception e) {
... ...
src/main/java/com/objecteye/controller/VehicleViolationsController.java
... ... @@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
10 10 import org.springframework.beans.factory.annotation.Autowired;
11 11 import org.springframework.web.bind.annotation.*;
12 12  
  13 +import java.util.List;
13 14 import java.util.Map;
14 15  
15 16 @CrossOrigin
... ... @@ -85,8 +86,8 @@ public class VehicleViolationsController {
85 86 */
86 87 @ApiOperation("禁行任务维护- 删除接口")
87 88 @RequestMapping(value = "forbiddenTaskDelete", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
88   - public CommonResult forbiddenTaskDelete(@RequestBody Map<String, String[]> queryParams) {
89   - String[] ids = queryParams.get("ids");
  89 + public CommonResult forbiddenTaskDelete(@RequestBody Map<String, Object> queryParams) {
  90 + List<String> ids = (List<String>) queryParams.get("ids");
90 91 int resultStatus = vehicleViolationsService.forbiddenTaskDelete(ids);
91 92 return resultStatus > 0 ? CommonResult.success("success") : CommonResult.success(201, "操作失败", 0);
92 93 }
... ...
src/main/java/com/objecteye/dao/MongoTemplates.java.old deleted
1   -package com.objecteye.dao;
2   -
3   -import org.springframework.beans.factory.annotation.Autowired;
4   -import org.springframework.data.mongodb.core.MongoTemplate;
5   -import org.springframework.data.mongodb.core.geo.GeoJson;
6   -import org.springframework.data.mongodb.core.query.Criteria;
7   -import org.springframework.stereotype.Component;
8   -
9   -import java.util.List;
10   -
11   -@Component
12   -public class MongoTemplates {
13   - @Autowired
14   - private MongoTemplate mongoTemplate;
15   -
16   - public void save(Polygon polygon){
17   - mongoTemplate.save(polygon);
18   - }
19   -
20   - public void saveRegions(List<GisRegion> gisRegionList){
21   - mongoTemplate.insert(gisRegionList,GisRegion.class);
22   - }
23   -
24   - public <T> T findById(Class<T> entityClass, String id) {
25   - return mongoTemplate.findById(id, entityClass);
26   - }
27   -
28   - public <T> List<T> findAll(Class<T> entityClass) {
29   - return mongoTemplate.findAll(entityClass);
30   - }
31   -
32   - public <T> void remove(T entity) {
33   - mongoTemplate.remove(entity);
34   - }
35   -
36   - public <T> void add(T entity) {
37   - mongoTemplate.insert(entity);
38   - }
39   -
40   - public <T> void addAll(List<T> entity) {
41   - mongoTemplate.insertAll(entity);
42   - }
43   -
44   - public <T> void saveOrUpdate(T entity) {
45   - mongoTemplate.save(entity);
46   - }
47   -
48   - public <T> T findOne(Class<T> entityClass) {
49   - return mongoTemplate.findOne(new Query(), entityClass);
50   - }
51   -
52   - public List<Polygon> findIntersective(GeoJson geoJson){
53   - Query query=new Query(Criteria.where("geometry").intersects(geoJson));
54   - List<Polygon> list=mongoTemplate.find(query,Polygon.class);
55   - return list;
56   - }
57   -
58   - public boolean isExistIntersective(GeoJson geoJson){
59   - Query query=new Query(Criteria.where("geometry").intersects(geoJson).and("_id").is(100000));
60   - boolean res=mongoTemplate.exists(query,GisRegion.class);
61   - return res;
62   - }
63   -
64   - /*public <T> T findBy(Class<T> entityClass, String id) {
65   -
66   - Criteria cri = new Criteria();
67   - // 设置条件(注意:设置查询的值类型必须和mongodb中类型一致)
68   - cri.and("status").is("0"); // 类型为String,类似sql中 status = '0'
69   - cri.and("boolRelation").is(0D); // 类型为Double,类似sql中 boolRelation = 0
70   - cri.and("enforType").regex("01.*"); // 正则表达匹配,类似右模糊查询,sql中 like '01%'
71   -
72   - // lt gt lte gte
73   -
74   - return null;
75   - }*/
76   -
77   - //mongodb查询根据指定条件对象
78   - /* public <T> T findQuery(Class<T> entityClass, BasicDBObject basicDBObject) {
79   - // 分、 排序、按时间查询
80   -
81   - Query query = new Query();
82   - //必须条件
83   - // Criteria c = Criteria.where("VINID").is(Map.get(vin));
84   - Criteria c = new Criteria();
85   - //范围条件
86   - if (!StringUtils.isEmpty(start) && StringUtils.isEmpty(end)) {
87   - c.and("TIME1").gte(GetTime1(start));
88   - } else if (StringUtils.isEmpty(start) && !StringUtils.isEmpty(end)) {
89   - c.and("TIME1").lte(GetTime1(end));
90   - } else if (!StringUtils.isEmpty(start) && !StringUtils.isEmpty(end)) {
91   - //对同一个属性加两次限制需这样操作
92   - c.andOperator(
93   - c.where("TIME1").gte(GetTime1(start)),
94   - c.where("TIME1").lte(GetTime1(end))
95   - );
96   - }
97   - query.addCriteria(c);
98   - //总数
99   - int num = (int) mongoTemplate.count(query, CarDataEx.class, "jmevTest");
100   - System.out.println("总数:" + num);
101   - //分页
102   - query.skip((page - 1) * rows).limit(rows);
103   - //排序
104   - query.with(new Sort(Sort.Direction.DESC, "TIME1","TIME2"));
105   - //query.with(new Sort(properties));
106   - List<T> jmevTest = (List<T>) mongoTemplate.find(query, CarDataEx.class, "jmevTest");
107   - }*/
108   -
109   -}
src/main/java/com/objecteye/entity/SyDeploy.java
... ... @@ -32,9 +32,6 @@ public class SyDeploy implements Serializable {
32 32  
33 33 private String description;
34 34  
35   - @ApiModelProperty(value = "布控设备id以逗号分隔")
36   - private String deployEquip;
37   -
38 35 @ApiModelProperty(value = "布控库")
39 36 private String deployLib;
40 37  
... ... @@ -54,10 +51,6 @@ public class SyDeploy implements Serializable {
54 51  
55 52 @ApiModelProperty(value = "人像/车辆id")
56 53 private String singleId;
57   - /**
58   - * 设备名称
59   - */
60   - private String areaName;
61 54  
62 55 private static final long serialVersionUID = 1L;
63 56 }
64 57 \ No newline at end of file
... ...
src/main/java/com/objecteye/entity/SyVehicleForbidenTask.java
... ... @@ -19,7 +19,7 @@ public class SyVehicleForbidenTask implements Serializable {
19 19 private static final long serialVersionUID = -8007441463935902798L;
20 20  
21 21 @ApiModelProperty(value = "任务id, 自增主键")
22   - private Integer id;
  22 + private String id;
23 23  
24 24 @ApiModelProperty(value = "任务名称")
25 25 private String name;
... ...
src/main/java/com/objecteye/pojo/RabbitMqVehicleViolation.java
... ... @@ -48,9 +48,5 @@ public class RabbitMqVehicleViolation implements Serializable {
48 48 /**
49 49 * 是否违规
50 50 */
51   - private Integer taskId;
52   - /**
53   - * 设备名称
54   - */
55   - private String equipmentName;
  51 + private String taskId;
56 52 }
... ...
src/main/java/com/objecteye/service/DeployService.java
... ... @@ -96,7 +96,7 @@ public interface DeployService {
96 96 *
97 97 * @param ids
98 98 */
99   - void delete(String[] ids);
  99 + void delete(List<String> ids);
100 100  
101 101 /**
102 102 * 布控任务查询列表- 分页
... ...
src/main/java/com/objecteye/service/FeatureService.java
... ... @@ -59,7 +59,7 @@ public interface FeatureService {
59 59 *
60 60 * @param ids
61 61 */
62   - void delete(String[] ids);
  62 + void delete(List<String> ids);
63 63  
64 64 /**
65 65 * 分页
... ...
src/main/java/com/objecteye/service/IVehicleViolationsService.java
... ... @@ -5,6 +5,8 @@ import com.objecteye.entity.SyVehicleForbidenTask;
5 5 import com.objecteye.entity.VehicleViolationsForbidenTaskQueryParams;
6 6 import com.objecteye.pojo.RabbitMQVehicle;
7 7  
  8 +import java.util.List;
  9 +
8 10 /**
9 11 * 车辆违规模块
10 12 *
... ... @@ -52,7 +54,7 @@ public interface IVehicleViolationsService {
52 54 * @param ids 请求参数
53 55 * @return 结果集
54 56 */
55   - int forbiddenTaskDelete(String[] ids);
  57 + int forbiddenTaskDelete(List<String> ids);
56 58  
57 59 /**
58 60 * 布控任务监控
... ...
src/main/java/com/objecteye/service/PersonnelService.java
... ... @@ -66,7 +66,7 @@ public interface PersonnelService {
66 66 * @param ids
67 67 */
68 68  
69   - void delete(String[] ids);
  69 + void delete(List<String> ids);
70 70  
71 71  
72 72 /**
... ...
src/main/java/com/objecteye/service/VehicleDbService.java
... ... @@ -57,7 +57,7 @@ public interface VehicleDbService {
57 57 *
58 58 * @param ids
59 59 */
60   - void delete(String[] ids);
  60 + void delete(List<String> ids);
61 61  
62 62 /**
63 63 * 分页
... ...
src/main/java/com/objecteye/service/VehicleService.java
... ... @@ -20,7 +20,7 @@ public interface VehicleService {
20 20 */
21 21 PageResult findPage(int vehicleId, String picName, int pageNum, int pageSize);
22 22  
23   - void delete(String[] ids);
  23 + void delete(List<String> ids);
24 24  
25 25 void update(UploadVehicleDbResult uploadVehicleDbResult);
26 26  
... ...
src/main/java/com/objecteye/service/impl/DeployServiceImpl.java
... ... @@ -19,10 +19,10 @@ import org.springframework.data.mongodb.core.aggregation.Aggregation;
19 19 import org.springframework.data.mongodb.core.aggregation.AggregationResults;
20 20 import org.springframework.data.mongodb.core.query.Criteria;
21 21 import org.springframework.data.mongodb.core.query.Query;
  22 +import org.springframework.data.mongodb.core.query.Update;
22 23 import org.springframework.data.redis.core.RedisTemplate;
23 24 import org.springframework.scheduling.annotation.Scheduled;
24   -import org.springframework.stereotype.Service;
25   -import org.springframework.transaction.annotation.Transactional;
  25 +import org.springframework.stereotype.Component;
26 26  
27 27 import java.math.BigDecimal;
28 28 import java.math.RoundingMode;
... ... @@ -35,7 +35,7 @@ import java.util.stream.Collectors;
35 35 *
36 36 * @author Administrator
37 37 */
38   -@Service
  38 +@Component
39 39 @Slf4j
40 40 public class DeployServiceImpl implements DeployService {
41 41 @Autowired
... ... @@ -60,6 +60,9 @@ public class DeployServiceImpl implements DeployService {
60 60 @Override
61 61 public Integer cancelOrReNewDeployTask(int deployId) {
62 62 SyDeploy syDeploy = mongoTemplate.findOne(Query.query(Criteria.where("id").is(deployId)), SyDeploy.class);
  63 + if (syDeploy == null) {
  64 + throw new RuntimeException("未找到对应布控任务");
  65 + }
63 66 Integer status = syDeploy.getStatus();
64 67 if (status == 0) {
65 68 syDeploy.setStatus(1);
... ... @@ -196,7 +199,6 @@ public class DeployServiceImpl implements DeployService {
196 199 *
197 200 * @param syDeploy
198 201 */
199   - @Transactional(rollbackFor = Exception.class)
200 202 @Override
201 203 public void add(SyDeploy syDeploy) {
202 204 // 处理前端传递的时间戳
... ... @@ -220,7 +222,6 @@ public class DeployServiceImpl implements DeployService {
220 222  
221 223 syDeploy.setDeployLib(featureIds);
222 224  
223   - syDeploy.setSingleId(syDeploy.getDeployEquip());
224 225 mongoTemplate.insert(syDeploy);
225 226 String deployId = syDeploy.getId();
226 227 // 布控库中每一条数据都放到redis中
... ... @@ -275,7 +276,6 @@ public class DeployServiceImpl implements DeployService {
275 276 }
276 277  
277 278 @Override
278   - @Transactional(rollbackFor = Exception.class)
279 279 public void update(SyDeploy deploy) {
280 280 // 处理前端传递的时间戳
281 281 makeTimeLongToTimeStr(deploy);
... ... @@ -304,7 +304,7 @@ public class DeployServiceImpl implements DeployService {
304 304 redisTemplate.opsForHash().put(GlobalUtil.DEPLOY_TYPE, deployId, deployType);
305 305 redisTemplate.opsForHash().put(GlobalUtil.DEPLOYIDANDENDTIME, deployId, endTime);
306 306  
307   - mongoTemplate.save(deploy, "syDeploy");
  307 + mongoTemplate.save(deploy);
308 308 }
309 309  
310 310 /**
... ... @@ -350,12 +350,10 @@ public class DeployServiceImpl implements DeployService {
350 350 * @param ids
351 351 */
352 352 @Override
353   - public void delete(String[] ids) {
  353 + public void delete(List<String> ids) {
354 354 for (String id : ids) {
355   - SyDeploy syDeploy = mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), SyDeploy.class);
356   - syDeploy.setIsDelete(1);
357 355 deleteRedisWhenUpdateDeploy(id);
358   - mongoTemplate.save(syDeploy);
  356 + mongoTemplate.updateMulti(Query.query(Criteria.where("id").is(id)), Update.update("isDelete", 1), SyDeploy.class);
359 357 redisTemplate.opsForHash().delete(GlobalUtil.DEPLOY_LIB, id);
360 358 redisTemplate.opsForHash().delete(GlobalUtil.DEPLOY_TYPE, id);
361 359 redisTemplate.opsForHash().delete(GlobalUtil.DEPLOYIDANDENDTIME, id);
... ... @@ -534,12 +532,7 @@ public class DeployServiceImpl implements DeployService {
534 532 mongoTemplate.save(syDeploy);
535 533 }
536 534 } else if (currentTimeStamp > deployEndTimeStamp) {
537   - SyDeploy syDeploy = mongoTemplate.findOne(Query.query(Criteria.where("id").is(integer)), SyDeploy.class);
538   - if (syDeploy == null) {
539   - return;
540   - }
541   - syDeploy.setStatus(1);
542   - mongoTemplate.save(syDeploy);
  535 + mongoTemplate.updateMulti(Query.query(Criteria.where("id").is(integer)), Update.update("status", 1), SyDeploy.class);
543 536 redisTemplate.opsForHash().delete(GlobalUtil.DEPLOYID_STATRTIME, integer);
544 537 }
545 538 }
... ... @@ -738,7 +731,7 @@ public class DeployServiceImpl implements DeployService {
738 731 */
739 732 private void plateAlarmMsgProducer(PlateAlarmMsg plateAlarmMsg) {
740 733 if (plateAlarmMsg != null) {
741   - PlateAlarmMsg save = mongoTemplate.save(plateAlarmMsg);
  734 + PlateAlarmMsg save = mongoTemplate.insert(plateAlarmMsg);
742 735 String s = JSON.toJSONString(save);
743 736 redisTemplate.opsForList().leftPush("ALARM", s);
744 737 }
... ...
src/main/java/com/objecteye/service/impl/FeatureServiceImpl.java
... ... @@ -11,13 +11,11 @@ import org.springframework.beans.factory.annotation.Autowired;
11 11 import org.springframework.data.mongodb.core.MongoTemplate;
12 12 import org.springframework.data.mongodb.core.query.Criteria;
13 13 import org.springframework.data.mongodb.core.query.Query;
  14 +import org.springframework.data.mongodb.core.query.Update;
14 15 import org.springframework.data.redis.core.RedisTemplate;
15 16 import org.springframework.stereotype.Service;
16 17  
17   -import java.util.ArrayList;
18   -import java.util.HashMap;
19   -import java.util.List;
20   -import java.util.Map;
  18 +import java.util.*;
21 19  
22 20 /**
23 21 * 服务实现层
... ... @@ -108,16 +106,13 @@ public class FeatureServiceImpl implements FeatureService {
108 106 * @param ids
109 107 */
110 108 @Override
111   - public void delete(String[] ids) {
  109 + public void delete(List<String> ids) {
112 110 for (String id : ids) {
113 111 List<String> deployList = deployService.getDeployListByLibAndDeployType(id, 2);
114   - SyFeature syFeature = mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), SyFeature.class);
115   - syFeature.setIsDelete(1);
116 112 List<SyPersonnel> syPersonnels = mongoTemplate.find(Query.query(Criteria.where("fid").is(id)), SyPersonnel.class);
  113 + mongoTemplate.updateMulti(Query.query(Criteria.where("fid").is(id)), Update.update("status", 1), SyPersonnel.class);
117 114 if (syPersonnels.size() > 0) {
118 115 for (SyPersonnel syPersonnel : syPersonnels) {
119   - syPersonnel.setStatus(1);
120   - mongoTemplate.save(syPersonnel);
121 116 redisTemplate.opsForHash().delete("personUrl", syPersonnel.getId());
122 117 }
123 118 }
... ... @@ -126,11 +121,11 @@ public class FeatureServiceImpl implements FeatureService {
126 121 String key = deployId + "|" + id;
127 122 redisTemplate.opsForHash().delete(key);
128 123 String[] deploy = {deployId};
129   - deployService.delete(deploy);
  124 + deployService.delete(Arrays.asList(deploy));
130 125 }
131 126 }
132   - mongoTemplate.save(syFeature);
133 127 }
  128 + mongoTemplate.updateMulti(Query.query(Criteria.where("id").in(ids)), Update.update("isDelete", 1), SyFeature.class);
134 129 }
135 130  
136 131  
... ...
src/main/java/com/objecteye/service/impl/LocusOrbitServiceImpl.java
... ... @@ -71,7 +71,8 @@ public class LocusOrbitServiceImpl implements ILocusOrbitService {
71 71 @Override
72 72 public List<LocusOrbitResultParams> locusOrbitByPlateNumber(int gcxh, LocusOrbitQueryParams locusOrbitQueryParams, MultipartFile multipartFile) {
73 73 String fileName = multipartFile.getOriginalFilename();
74   - String picPath = GlobalUtil.dbPath1() + File.separator + "picture" + File.separator + fileName;
  74 + String picPath = GlobalUtil.dbPath1() + File.separator + "export" + File.separator + "vehicleProject"
  75 + + File.separator + "picture" + File.separator + fileName;
75 76 File newFile = new File(picPath);
76 77 try {
77 78 multipartFile.transferTo(newFile);
... ...
src/main/java/com/objecteye/service/impl/PersonnelServiceImpl.java
... ... @@ -17,9 +17,9 @@ import org.springframework.beans.factory.annotation.Value;
17 17 import org.springframework.data.mongodb.core.MongoTemplate;
18 18 import org.springframework.data.mongodb.core.query.Criteria;
19 19 import org.springframework.data.mongodb.core.query.Query;
  20 +import org.springframework.data.mongodb.core.query.Update;
20 21 import org.springframework.data.redis.core.RedisTemplate;
21 22 import org.springframework.stereotype.Service;
22   -import org.springframework.transaction.annotation.Transactional;
23 23 import org.springframework.web.multipart.MultipartFile;
24 24  
25 25 import java.io.File;
... ... @@ -129,17 +129,16 @@ public class PersonnelServiceImpl implements PersonnelService {
129 129 */
130 130  
131 131 @Override
132   - @Transactional(rollbackFor = Exception.class)
133   - public void delete(String[] ids) {
  132 + public void delete(List<String> ids) {
134 133 for (String id : ids) {
135 134 SyPersonnel syPersonnel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), SyPersonnel.class);
136   - syPersonnel.setStatus(1);
137   - mongoTemplate.save(syPersonnel);
  135 + if (syPersonnel == null) {
  136 + continue;
  137 + }
  138 + mongoTemplate.updateMulti(Query.query(Criteria.where("id").is(id)), Update.update("status", 1), SyPersonnel.class);
138 139 String fid = syPersonnel.getFid();
139   - long personCountByFid = findPersonCountByFid(fid);
140   - SyFeature syFeature = mongoTemplate.findOne(Query.query(Criteria.where("id").is(fid)), SyFeature.class);
141   - syFeature.setCount((int) personCountByFid);
142   - mongoTemplate.save(syFeature);
  140 + int personCountByFid = (int) findPersonCountByFid(fid);
  141 + mongoTemplate.updateMulti(Query.query(Criteria.where("id").is(fid)), Update.update("count", personCountByFid), SyFeature.class);
143 142 List<String> deployListByLibAndDeployType = deployService.getDeployListByLibAndDeployType(fid, 2);
144 143 if (deployListByLibAndDeployType != null && deployListByLibAndDeployType.size() > 0) {
145 144 for (String s : deployListByLibAndDeployType) {
... ... @@ -207,7 +206,6 @@ public class PersonnelServiceImpl implements PersonnelService {
207 206 * @return
208 207 */
209 208 @Override
210   - @Transactional(rollbackFor = Exception.class)
211 209 public String uploadFiles(MultipartFile[] uploadFiles, String featureId) {
212 210 int count = 0;
213 211 SyFeature one = featureService.findOne(featureId);
... ...
src/main/java/com/objecteye/service/impl/UploadFileServiceImpl.java
... ... @@ -42,7 +42,8 @@ public class UploadFileServiceImpl implements IUploadFileService {
42 42 public JSONObject uploadFile2Mongo(MultipartFile multipartFile) throws IOException {
43 43 // 格式化文件名由format开头, e.g. format-15321354564-12.12654_15.156567.jpg
44 44 String fileName = multipartFile.getOriginalFilename();
45   - String picPath = GlobalUtil.dbPath1() + File.separator + "picture" + File.separator + fileName;
  45 + String picPath = GlobalUtil.dbPath1() + File.separator + "export" + File.separator + "vehicleProject"
  46 + + File.separator + "picture" + File.separator + fileName;
46 47 File newFile = new File(picPath);
47 48 multipartFile.transferTo(newFile);
48 49  
... ... @@ -75,8 +76,6 @@ public class UploadFileServiceImpl implements IUploadFileService {
75 76 String s = JSON.toJSONString(uploadVehicleResult);
76 77 rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM, "inform.store", s);
77 78 }
78   -
79   -
80   - return null;
  79 + return new JSONObject();
81 80 }
82 81 }
... ...
src/main/java/com/objecteye/service/impl/VehicleDbServiceImpl.java
... ... @@ -10,13 +10,11 @@ import org.springframework.beans.factory.annotation.Autowired;
10 10 import org.springframework.data.mongodb.core.MongoTemplate;
11 11 import org.springframework.data.mongodb.core.query.Criteria;
12 12 import org.springframework.data.mongodb.core.query.Query;
  13 +import org.springframework.data.mongodb.core.query.Update;
13 14 import org.springframework.data.redis.core.RedisTemplate;
14 15 import org.springframework.stereotype.Service;
15 16  
16   -import java.util.ArrayList;
17   -import java.util.HashMap;
18   -import java.util.List;
19   -import java.util.Map;
  17 +import java.util.*;
20 18  
21 19 /**
22 20 * 服务实现层
... ... @@ -95,7 +93,7 @@ public class VehicleDbServiceImpl implements VehicleDbService {
95 93 * @param ids
96 94 */
97 95 @Override
98   - public void delete(String[] ids) {
  96 + public void delete(List<String> ids) {
99 97 for (String id : ids) {
100 98 List<String> deployList = deployService.getDeployListByLibAndDeployType(id, 2);
101 99 UploadVehicleDbResult uploadVehicleDbResult = mongoTemplate.findOne(Query.query(new Criteria("id").is(id)), UploadVehicleDbResult.class);
... ... @@ -114,13 +112,11 @@ public class VehicleDbServiceImpl implements VehicleDbService {
114 112 for (int i = 0; i < size; i++) {
115 113 String deployId = deployList.get(i);
116 114 String[] deploy = {deployId};
117   - deployService.delete(deploy);
  115 + deployService.delete(Arrays.asList(deploy));
118 116 }
119 117 }
120 118 }
121   - SyVehicleDb syVehicleDb = mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), SyVehicleDb.class);
122   - syVehicleDb.setIsDelete(1);
123   - mongoTemplate.save(syVehicleDb);
  119 + mongoTemplate.updateMulti(Query.query(Criteria.where("id").is(id)), Update.update("isDelete", 1), SyVehicleDb.class);
124 120 }
125 121 }
126 122  
... ...
src/main/java/com/objecteye/service/impl/VehicleFileServiceImpl.java
... ... @@ -324,7 +324,8 @@ public class VehicleFileServiceImpl implements IVehicleFileService {
324 324 @Override
325 325 public VvehicleFilePicQueryResult picQuery(int gcxh, MultipartFile multipartFile) {
326 326 String fileName = multipartFile.getOriginalFilename();
327   - String picPath = GlobalUtil.dbPath1() + File.separator + "picture" + File.separator + fileName;
  327 + String picPath = GlobalUtil.dbPath1() + File.separator + "export" + File.separator + "vehicleProject"
  328 + + File.separator + "picture" + File.separator + fileName;
328 329 File newFile = new File(picPath);
329 330 try {
330 331 multipartFile.transferTo(newFile);
... ...
src/main/java/com/objecteye/service/impl/VehicleServiceImpl.java
... ... @@ -79,11 +79,10 @@ public class VehicleServiceImpl implements VehicleService {
79 79 }
80 80  
81 81 @Override
82   - public void delete(String[] ids) {
83   - int length = ids.length;
  82 + public void delete(List<String> ids) {
  83 + int length = ids.size();
84 84 String vehicleId = null;
85   - for (int i = 0; i < length; i++) {
86   - String id = ids[i];
  85 + for (String id : ids) {
87 86 UploadVehicleDbResult uploadVehicleDbResult = mongoTemplate.findOne(Query.query(new Criteria("id").is(id)), UploadVehicleDbResult.class);
88 87 vehicleId = uploadVehicleDbResult.getVehicleId();
89 88 String plateNum = uploadVehicleDbResult.getPlateNum();
... ...
src/main/java/com/objecteye/service/impl/VehicleViolationsServiceImpl.java
... ... @@ -95,7 +95,7 @@ public class VehicleViolationsServiceImpl implements IVehicleViolationsService {
95 95 continue;
96 96 }
97 97 SyVehicleForbiddenTaskOutput output = new SyVehicleForbiddenTaskOutput();
98   - output.setId(String.valueOf(forbiddenTask.getId()));
  98 + output.setId(forbiddenTask.getId());
99 99 output.setName(forbiddenTask.getName());
100 100 output.setDescription(forbiddenTask.getDescription());
101 101 output.setStatus(null != forbiddenTask.getStatus() && 1 == forbiddenTask.getStatus() ? "工作中" : "已撤销");
... ... @@ -164,7 +164,7 @@ public class VehicleViolationsServiceImpl implements IVehicleViolationsService {
164 164 * @return 结果集
165 165 */
166 166 @Override
167   - public int forbiddenTaskDelete(String[] ids) {
  167 + public int forbiddenTaskDelete(List<String> ids) {
168 168 int effectNum = 0;
169 169 for (String id : ids) {
170 170 if (null == id || "".equals(id)) {
... ...
src/main/java/com/objecteye/utils/FtpUtil.java deleted
1   -package com.objecteye.utils;
2   -
3   -import org.apache.commons.net.ftp.FTP;
4   -import org.apache.commons.net.ftp.FTPClient;
5   -import org.slf4j.Logger;
6   -import org.slf4j.LoggerFactory;
7   -import org.springframework.beans.factory.annotation.Value;
8   -import org.springframework.stereotype.Component;
9   -
10   -import java.io.IOException;
11   -import java.net.SocketException;
12   -import java.nio.charset.Charset;
13   -
14   -@Component
15   -public class FtpUtil {
16   -
17   - private static final Logger log = LoggerFactory.getLogger(FtpUtil.class);
18   -
19   - @Value("${ftp.username}")
20   - private String userName;
21   -
22   - @Value("${ftp.password}")
23   - private String passWord;
24   -
25   - @Value("${ftp.host}")
26   - private String ip;
27   -
28   - @Value("${ftp.port}")
29   - private int port;
30   -
31   - private FTPClient ftpClient = new FTPClient();
32   -
33   -
34   - public FTPClient connect() {
35   - try {
36   - if (!ftpClient.isConnected()) {
37   -
38   - ftpClient.connect(ip, port);
39   - ftpClient.login(userName, passWord);
40   - ftpClient.setCharset(Charset.forName("UTF-8"));
41   - ftpClient.setControlEncoding("UTF-8");
42   - ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
43   - }
44   - return ftpClient;
45   - } catch (SocketException e) {
46   - e.printStackTrace();
47   - } catch (IOException e) {
48   - e.printStackTrace();
49   - }
50   - return null;
51   - }
52   -}
src/main/java/com/objecteye/utils/GlobalUtil.java
... ... @@ -438,9 +438,8 @@ public class GlobalUtil {
438 438 if (imgStr == null) {
439 439 return false;
440 440 }
441   - BASE64Decoder decoder = new BASE64Decoder();
442 441 try {
443   - byte[] bytes = decoder.decodeBuffer(imgStr);
  442 + byte[] bytes = org.apache.commons.codec.binary.Base64.decodeBase64(imgStr);
444 443 for (int i = 0; i < bytes.length; ++i) {
445 444 if (bytes[i] < 0) {
446 445 bytes[i] += 256;
... ...
src/main/java/com/objecteye/utils/HttpClientUtils.java
1 1 package com.objecteye.utils;
2 2  
  3 +import org.apache.commons.codec.binary.Base64;
3 4 import org.springframework.beans.factory.annotation.Autowired;
4 5 import org.springframework.beans.factory.annotation.Value;
5 6 import org.springframework.http.ResponseEntity;
... ... @@ -7,7 +8,6 @@ import org.springframework.stereotype.Component;
7 8 import org.springframework.web.client.RestTemplate;
8 9 import org.springframework.web.multipart.MultipartFile;
9 10 import sun.misc.BASE64Decoder;
10   -import sun.misc.BASE64Encoder;
11 11  
12 12 import javax.imageio.ImageIO;
13 13 import java.awt.image.BufferedImage;
... ... @@ -85,12 +85,10 @@ public class HttpClientUtils {
85 85 }
86 86  
87 87 public String MultipartFileToBase64(MultipartFile file) throws Exception {
88   - BASE64Encoder base64Encoder = new BASE64Encoder();
89   - String base64EncoderImg = file.getOriginalFilename() + "," + base64Encoder.encode(file.getBytes());
  88 + String base64EncoderImg = file.getOriginalFilename() + "," + Base64.encodeBase64String(file.getBytes());
90 89 String[] split = base64EncoderImg.split(",");
91 90 String split1 = split[1];
92   - String base64Value = split1.replaceAll("\r\n|\r|\n", "");
93   - return base64Value;
  91 + return split1.replaceAll("\r\n|\r|\n", "");
94 92 }
95 93  
96 94 //将multipart文件转成车型对象
... ...
src/main/java/com/objecteye/utils/RabbitMQVehicleTools.java
... ... @@ -112,7 +112,7 @@ public class RabbitMQVehicleTools {
112 112 GlobalUtil.generateImage(mattingData, path);
113 113  
114 114 PersonMsg personMsg = new PersonMsg(null, snapshoturl, captureTime, null, null, null, url, retrieveKey, fea);
115   - PersonMsg save = mongoTemplate.save(personMsg);
  115 + PersonMsg save = mongoTemplate.insert(personMsg);
116 116 String s = JSON.toJSONString(save);
117 117 rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM, "inform.person", s);
118 118 }
... ...
src/main/resources/application.yml
... ... @@ -32,23 +32,16 @@ logging:
32 32 # file: demo_log.log #配置日志生成路径
33 33 # path: /var/logs #配置日志文件名称
34 34 picture:
35   - url: http://192.168.10.153:8880/
36   - storePath: /ftpTest
37   - http: http://192.168.10.153:8880/
38   - snapshotPath: /home/hexy/picture/snapshot/
  35 + url: http://192.168.10.117:32112/
  36 + storePath: /home/liuhaoyu/export/vehicleProject/picture/
  37 + http: http://192.168.10.117:32112/
  38 + snapshotPath: /home/liuhaoyu/export/vehicleProject/picture/snapshot/
39 39  
40   -snapshotPrefix: http://192.168.10.153:8880/snapshot/
  40 +snapshotPrefix: http://192.168.10.117:32112/snapshot/
41 41  
42 42 server:
43   - port: 8080
44   - address: 127.0.0.1
45   -
46   -ftp:
47   - username: officer
48   - password: 334554321123211
49   - host: 192.168.10.39
50   - port: 21
51   -
  43 + port: 8845
  44 + address: 192.168.10.117
52 45  
53 46 #调用引擎url
54 47 requestFile: http://192.168.10.4:10002/vps/analysisFile
... ...