Commit 0004e2b5c0221499fe189ad109d0718d57133429
1 parent
cf5c28af
m
Showing
22 changed files
with
1307 additions
and
1098 deletions
trash-common/src/main/java/com/trash/common/core/domain/entity/SysUser.java
| ... | ... | @@ -105,10 +105,28 @@ public class SysUser extends BaseEntity |
| 105 | 105 | List<String> companyAreas = new ArrayList<String>(); |
| 106 | 106 | List<String> earthAreas = new ArrayList<String>(); |
| 107 | 107 | List<String> truckList = new ArrayList<String>(); |
| 108 | - | |
| 108 | + | |
| 109 | + List<String> streetsAreas = new ArrayList<String>(); | |
| 110 | + List<String> streetsList = new ArrayList<String>(); | |
| 109 | 111 | |
| 110 | 112 | |
| 111 | 113 | |
| 114 | + public List<String> getStreetsAreas() { | |
| 115 | + return streetsAreas; | |
| 116 | + } | |
| 117 | + | |
| 118 | + public void setStreetsAreas(List<String> streetsAreas) { | |
| 119 | + this.streetsAreas = streetsAreas; | |
| 120 | + } | |
| 121 | + | |
| 122 | + public List<String> getStreetsList() { | |
| 123 | + return streetsList; | |
| 124 | + } | |
| 125 | + | |
| 126 | + public void setStreetsList(List<String> streetsList) { | |
| 127 | + this.streetsList = streetsList; | |
| 128 | + } | |
| 129 | + | |
| 112 | 130 | public List<String> getCompanyAreas() { |
| 113 | 131 | return companyAreas; |
| 114 | 132 | } | ... | ... |
trash-common/src/main/java/com/trash/common/utils/RemoteServerUtils.java
| ... | ... | @@ -488,6 +488,32 @@ public class RemoteServerUtils { |
| 488 | 488 | return object; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | + public static JSONArray getStreets(String token){ | |
| 492 | + JSONArray array = null; | |
| 493 | + | |
| 494 | + if (okHttpClient == null) { | |
| 495 | + okHttpClient = getOkClient(); | |
| 496 | + } | |
| 497 | + | |
| 498 | + Request request = new Request.Builder().url(remote + "/api/siteservice/v1/sites/tree/auth?type=4").addHeader("Authorization", token).get().build(); | |
| 499 | + | |
| 500 | + try { | |
| 501 | + okhttp3.Response response = okHttpClient.newCall(request).execute(); | |
| 502 | + String result = response.body().string(); | |
| 503 | + | |
| 504 | + if (result != null) { | |
| 505 | + JSONArray json = JSON.parseArray(result); | |
| 506 | + return json; | |
| 507 | + } else { | |
| 508 | + return null; | |
| 509 | + } | |
| 510 | + | |
| 511 | + } catch (Exception e) { | |
| 512 | + e.printStackTrace(); | |
| 513 | + return null; | |
| 514 | + } | |
| 515 | + } | |
| 516 | + | |
| 491 | 517 | public static JSONArray getAreas(String token) { |
| 492 | 518 | JSONArray array = null; |
| 493 | 519 | Object object = get("/api/gpsservice/cs/area", null, token); |
| ... | ... | @@ -634,7 +660,7 @@ public class RemoteServerUtils { |
| 634 | 660 | String token = SecurityUtils.getLoginUser().getToken(); |
| 635 | 661 | |
| 636 | 662 | if (token.contains("durable:")) { |
| 637 | - token = token.replace("durable:", "Bearer durable:auth:token:"); | |
| 663 | + token = "Bearer " + token; | |
| 638 | 664 | } else { |
| 639 | 665 | token = "Bearer auth:token:" + token; |
| 640 | 666 | } |
| ... | ... | @@ -674,8 +700,9 @@ public class RemoteServerUtils { |
| 674 | 700 | |
| 675 | 701 | String token = SecurityUtils.getLoginUser().getToken(); |
| 676 | 702 | |
| 703 | + | |
| 677 | 704 | if (token.contains("durable:")) { |
| 678 | - token = token.replace("durable:", "Bearer durable:auth:token:"); | |
| 705 | + token = "Bearer " + token; | |
| 679 | 706 | } else { |
| 680 | 707 | token = "Bearer auth:token:" + token; |
| 681 | 708 | } |
| ... | ... | @@ -724,13 +751,8 @@ public class RemoteServerUtils { |
| 724 | 751 | okHttpClient = getOkClient(); |
| 725 | 752 | } |
| 726 | 753 | |
| 727 | - | |
| 728 | - if (token.contains("durable:")) { | |
| 729 | - token = "Bearer " + token.replaceAll("durable:", ""); | |
| 730 | - } else { | |
| 731 | - token = "Bearer auth:token:" + token; | |
| 732 | - } | |
| 733 | - | |
| 754 | + token = "Bearer " + token; | |
| 755 | + | |
| 734 | 756 | |
| 735 | 757 | String param = JSON.toJSON(obj).toString(); |
| 736 | 758 | |
| ... | ... | @@ -784,15 +806,11 @@ public class RemoteServerUtils { |
| 784 | 806 | |
| 785 | 807 | public static Object get(String url, Map<String, String> obj, String token) { |
| 786 | 808 | if (okHttpClient == null) { |
| 787 | - | |
| 788 | - | |
| 789 | 809 | okHttpClient = getOkClient(); |
| 790 | 810 | } |
| 791 | - if (token.contains("durable:")) { | |
| 792 | - token = "Bearer " + token.replaceAll("durable:", ""); | |
| 793 | - } else { | |
| 794 | - token = "Bearer auth:token:" + token; | |
| 795 | - } | |
| 811 | + | |
| 812 | + token = "Bearer " + token; | |
| 813 | + | |
| 796 | 814 | String params = ""; |
| 797 | 815 | |
| 798 | 816 | if (obj != null) { |
| ... | ... | @@ -844,35 +862,27 @@ public class RemoteServerUtils { |
| 844 | 862 | } |
| 845 | 863 | |
| 846 | 864 | |
| 847 | - public static JSONArray getDriverList() { | |
| 865 | + public static JSONArray getDriverList(Map map) { | |
| 848 | 866 | |
| 849 | - try { | |
| 850 | - Map map = new HashMap<>(); | |
| 851 | - Object result = get(DriverListPath, null); | |
| 852 | 867 | |
| 853 | - if (result != null) { | |
| 854 | - JSONObject json = JSON.parseObject(result.toString()); | |
| 855 | - return json.getJSONArray("list"); | |
| 856 | - | |
| 857 | - } else { | |
| 858 | - return null; | |
| 859 | - } | |
| 868 | + String token = SecurityUtils.getLoginUser().getToken(); | |
| 860 | 869 | |
| 861 | - } catch (Exception e) { | |
| 862 | - e.printStackTrace(); | |
| 863 | - return null; | |
| 864 | - } | |
| 870 | + return getDriverList(token,map); | |
| 865 | 871 | } |
| 866 | 872 | |
| 867 | - public static JSONArray getDriverList(String token) { | |
| 873 | + public static JSONArray getDriverList(String token,Map map) { | |
| 868 | 874 | |
| 869 | 875 | if (okHttpClient == null) { |
| 870 | 876 | okHttpClient = getOkClient(); |
| 871 | 877 | } |
| 878 | + | |
| 879 | + if (token.contains("durable:")) { | |
| 880 | + token = "Bearer " + token; | |
| 881 | + } else { | |
| 882 | + token = "Bearer auth:token:" + token; | |
| 883 | + } | |
| 872 | 884 | |
| 873 | - token = "Bearer " + token; | |
| 874 | - | |
| 875 | - String param = JSON.toJSON(new HashMap<>()).toString(); | |
| 885 | + String param = JSON.toJSON(map).toString(); | |
| 876 | 886 | |
| 877 | 887 | RequestBody body = RequestBody.create(MediaType.parse("application/json"), param); |
| 878 | 888 | ... | ... |
trash-framework/src/main/java/com/trash/framework/web/service/SysLoginService.java
| ... | ... | @@ -31,8 +31,10 @@ import org.springframework.stereotype.Component; |
| 31 | 31 | |
| 32 | 32 | import javax.annotation.Resource; |
| 33 | 33 | import java.util.ArrayList; |
| 34 | +import java.util.HashMap; | |
| 34 | 35 | import java.util.HashSet; |
| 35 | 36 | import java.util.List; |
| 37 | +import java.util.Map; | |
| 36 | 38 | import java.util.Set; |
| 37 | 39 | |
| 38 | 40 | /** |
| ... | ... | @@ -41,264 +43,296 @@ import java.util.Set; |
| 41 | 43 | * @author trash |
| 42 | 44 | */ |
| 43 | 45 | @Component |
| 44 | -public class SysLoginService | |
| 45 | -{ | |
| 46 | - @Autowired | |
| 47 | - private TokenService tokenService; | |
| 46 | +public class SysLoginService { | |
| 47 | + @Autowired | |
| 48 | + private TokenService tokenService; | |
| 48 | 49 | |
| 49 | - @Resource | |
| 50 | - private AuthenticationManager authenticationManager; | |
| 50 | + @Resource | |
| 51 | + private AuthenticationManager authenticationManager; | |
| 51 | 52 | |
| 52 | - @Autowired | |
| 53 | - private RedisCache redisCache; | |
| 54 | - | |
| 55 | - @Autowired | |
| 56 | - UserDetailsService UserDetailsService; | |
| 53 | + @Autowired | |
| 54 | + private RedisCache redisCache; | |
| 57 | 55 | |
| 58 | - @Autowired | |
| 56 | + @Autowired | |
| 57 | + UserDetailsService UserDetailsService; | |
| 58 | + | |
| 59 | + @Autowired | |
| 59 | 60 | SysTempMapper tempMapper; |
| 60 | - | |
| 61 | - /** | |
| 62 | - * 登录验证 | |
| 63 | - * | |
| 64 | - * @param username 用户名 | |
| 65 | - * @param password 密码 | |
| 66 | - * @param code 验证码 | |
| 67 | - * @param uuid 唯一标识 | |
| 68 | - * @return 结果 | |
| 69 | - */ | |
| 70 | - public String login(String username, String password, String code, String uuid) | |
| 71 | - { | |
| 72 | - String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; | |
| 73 | - String captcha = redisCache.getCacheObject(verifyKey); | |
| 74 | - redisCache.deleteObject(verifyKey); | |
| 75 | - if (captcha == null) | |
| 76 | - { | |
| 77 | - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); | |
| 78 | - throw new CaptchaExpireException(); | |
| 79 | - } | |
| 80 | - if (!code.equalsIgnoreCase(captcha)) | |
| 81 | - { | |
| 82 | - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); | |
| 83 | - throw new CaptchaException(); | |
| 84 | - } | |
| 85 | - // 用户验证 | |
| 86 | - Authentication authentication = null; | |
| 87 | - try | |
| 88 | - { | |
| 89 | - // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername | |
| 90 | - authentication = authenticationManager | |
| 91 | - .authenticate(new UsernamePasswordAuthenticationToken(username, password)); | |
| 92 | - } | |
| 93 | - catch (Exception e) | |
| 94 | - { | |
| 95 | - if (e instanceof BadCredentialsException) | |
| 96 | - { | |
| 97 | - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); | |
| 98 | - throw new UserPasswordNotMatchException(); | |
| 99 | - } | |
| 100 | - else | |
| 101 | - { | |
| 102 | - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); | |
| 103 | - throw new CustomException(e.getMessage()); | |
| 104 | - } | |
| 105 | - } | |
| 106 | - | |
| 107 | - AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); | |
| 108 | - LoginUser loginUser = (LoginUser) authentication.getPrincipal(); | |
| 109 | - // 生成token | |
| 110 | - return tokenService.createToken(loginUser); | |
| 111 | - } | |
| 112 | - | |
| 113 | - | |
| 114 | - | |
| 115 | - public final String LOGIN_URL = "/api/authservice/cs/thirdpart/user"; //登录地址 待配置 | |
| 116 | - | |
| 117 | - public LoginUser loginByRemote(String token) | |
| 118 | - { | |
| 119 | - OkHttpClient okHttpClient = RemoteServerUtils.getOkClient(); | |
| 120 | - | |
| 121 | - JSONObject userJson = null; | |
| 122 | - | |
| 123 | - if(!token.contains("Bearer ")){ | |
| 124 | - token = "Bearer "+ token; | |
| 125 | - } | |
| 126 | - | |
| 127 | - Request request = new Request.Builder().url(RemoteServerUtils.remote + LOGIN_URL).addHeader("Authorization",token).get().build(); | |
| 128 | - | |
| 129 | - try { | |
| 130 | - okhttp3.Response response = okHttpClient.newCall(request).execute(); | |
| 131 | - String result = response.body().string(); | |
| 132 | - | |
| 133 | - if(result != null){ | |
| 134 | - JSONObject json = JSON.parseObject(result); | |
| 135 | - if("success".equals(json.getString("message"))){ | |
| 136 | - userJson = json.getJSONObject("result"); | |
| 137 | - } | |
| 138 | - }else{ | |
| 139 | - return null; | |
| 140 | - } | |
| 141 | - | |
| 142 | - }catch (Exception e) { | |
| 143 | - e.printStackTrace(); | |
| 144 | - return null; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 登录验证 | |
| 64 | + * | |
| 65 | + * @param username | |
| 66 | + * 用户名 | |
| 67 | + * @param password | |
| 68 | + * 密码 | |
| 69 | + * @param code | |
| 70 | + * 验证码 | |
| 71 | + * @param uuid | |
| 72 | + * 唯一标识 | |
| 73 | + * @return 结果 | |
| 74 | + */ | |
| 75 | + public String login(String username, String password, String code, String uuid) { | |
| 76 | + String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; | |
| 77 | + String captcha = redisCache.getCacheObject(verifyKey); | |
| 78 | + redisCache.deleteObject(verifyKey); | |
| 79 | + if (captcha == null) { | |
| 80 | + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, | |
| 81 | + MessageUtils.message("user.jcaptcha.expire"))); | |
| 82 | + throw new CaptchaExpireException(); | |
| 83 | + } | |
| 84 | + if (!code.equalsIgnoreCase(captcha)) { | |
| 85 | + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, | |
| 86 | + MessageUtils.message("user.jcaptcha.error"))); | |
| 87 | + throw new CaptchaException(); | |
| 88 | + } | |
| 89 | + // 用户验证 | |
| 90 | + Authentication authentication = null; | |
| 91 | + try { | |
| 92 | + // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername | |
| 93 | + authentication = authenticationManager | |
| 94 | + .authenticate(new UsernamePasswordAuthenticationToken(username, password)); | |
| 95 | + } catch (Exception e) { | |
| 96 | + if (e instanceof BadCredentialsException) { | |
| 97 | + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, | |
| 98 | + MessageUtils.message("user.password.not.match"))); | |
| 99 | + throw new UserPasswordNotMatchException(); | |
| 100 | + } else { | |
| 101 | + AsyncManager.me() | |
| 102 | + .execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); | |
| 103 | + throw new CustomException(e.getMessage()); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, | |
| 108 | + MessageUtils.message("user.login.success"))); | |
| 109 | + LoginUser loginUser = (LoginUser) authentication.getPrincipal(); | |
| 110 | + // 生成token | |
| 111 | + return tokenService.createToken(loginUser); | |
| 112 | + } | |
| 113 | + | |
| 114 | + public final String LOGIN_URL = "/api/authservice/cs/thirdpart/user"; // 登录地址 | |
| 115 | + // 待配置 | |
| 116 | + | |
| 117 | + public LoginUser loginByRemote(String token) { | |
| 118 | + OkHttpClient okHttpClient = RemoteServerUtils.getOkClient(); | |
| 119 | + | |
| 120 | + JSONObject userJson = null; | |
| 121 | + | |
| 122 | + if (!token.contains("Bearer ")) { | |
| 123 | + token = "Bearer " + token; | |
| 124 | + } | |
| 125 | + | |
| 126 | + Request request = new Request.Builder().url(RemoteServerUtils.remote + LOGIN_URL) | |
| 127 | + .addHeader("Authorization", token).get().build(); | |
| 128 | + | |
| 129 | + try { | |
| 130 | + okhttp3.Response response = okHttpClient.newCall(request).execute(); | |
| 131 | + String result = response.body().string(); | |
| 132 | + | |
| 133 | + if (result != null) { | |
| 134 | + JSONObject json = JSON.parseObject(result); | |
| 135 | + if ("success".equals(json.getString("message"))) { | |
| 136 | + userJson = json.getJSONObject("result"); | |
| 137 | + } | |
| 138 | + } else { | |
| 139 | + return null; | |
| 140 | + } | |
| 141 | + | |
| 142 | + } catch (Exception e) { | |
| 143 | + e.printStackTrace(); | |
| 144 | + return null; | |
| 145 | + } | |
| 146 | + | |
| 147 | + if (userJson == null) { | |
| 148 | + return null; | |
| 145 | 149 | } |
| 146 | - | |
| 147 | - if(userJson == null){ | |
| 148 | - return null; | |
| 149 | - } | |
| 150 | - | |
| 151 | - LoginUser loginUser = new LoginUser(); | |
| 152 | - | |
| 153 | - ArrayList<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>(); | |
| 154 | - SimpleGrantedAuthority activitiUser = new SimpleGrantedAuthority("ROLE_ACTIVITI_USER"); | |
| 155 | - SimpleGrantedAuthority admin = new SimpleGrantedAuthority("admin"); | |
| 156 | - authorities.add(activitiUser); | |
| 157 | - authorities.add(admin); | |
| 158 | - loginUser.setAuthorities(authorities); | |
| 159 | - | |
| 160 | - Set<String> set = new HashSet<String>(); | |
| 161 | - | |
| 162 | - SysUser user = new SysUser(); | |
| 163 | - user.setUserId(userJson.getString("id")); | |
| 164 | - user.setUserName(userJson.getString("name")); | |
| 165 | - user.setNickName(userJson.getString("name")); | |
| 166 | - user.setPassword(userJson.getString("id")); | |
| 167 | - SysDept dept = new SysDept(); | |
| 168 | - | |
| 169 | - if(userJson.getJSONArray("userIdentityList")!=null){ | |
| 170 | - | |
| 171 | - List<String> poStrings = new ArrayList<String>(); | |
| 172 | - | |
| 173 | - List<String> rolStrings = new ArrayList<String>(); | |
| 174 | - | |
| 175 | - try { | |
| 176 | - | |
| 177 | - for(Object obj:userJson.getJSONArray("userIdentityList")){ | |
| 178 | - | |
| 179 | - JSONObject uId = (JSONObject)obj; | |
| 180 | - | |
| 181 | - poStrings.add(uId.getString("postType")); | |
| 182 | - | |
| 183 | - rolStrings.add(uId.getString("departmentType")); | |
| 184 | - | |
| 185 | - | |
| 186 | - } | |
| 187 | - | |
| 188 | - user.setPostIds(poStrings); | |
| 189 | - | |
| 190 | - user.setRoleIds(rolStrings); | |
| 191 | - | |
| 192 | - | |
| 193 | - } catch (Exception e) { | |
| 194 | - // TODO: handle exception | |
| 195 | - } | |
| 196 | - | |
| 197 | - | |
| 198 | - | |
| 199 | - } | |
| 200 | - | |
| 201 | - JSONArray compnayList = redisCache.getCacheObject("companyList"); | |
| 202 | - | |
| 203 | - if(compnayList == null){ | |
| 204 | - | |
| 205 | - compnayList = JSONArray.parseArray(tempMapper.getLocalData("companyList")); | |
| 206 | - } | |
| 207 | - for(Object obj:compnayList){ | |
| 208 | - JSONObject con = (JSONObject)(obj); | |
| 209 | - | |
| 210 | - | |
| 211 | - if(con.getString("abbreviation").equals(user.getUserName().replace("公司", ""))){ | |
| 212 | - user.setCompanyName(con.getString("name")); | |
| 213 | - user.setUserName(con.getString("abbreviation")); | |
| 214 | - user.setNickName(con.getString("abbreviation")); | |
| 215 | - break; | |
| 216 | - } | |
| 217 | - | |
| 218 | - } | |
| 219 | - | |
| 220 | - | |
| 221 | - | |
| 222 | - | |
| 223 | - | |
| 224 | - JSONArray jsonArray = (JSONArray)RemoteServerUtils.getAuth(token); | |
| 225 | - if(jsonArray != null){ | |
| 226 | - for(Object obj:jsonArray){ | |
| 227 | - JSONObject json = (JSONObject)obj; | |
| 228 | - if(json.getInteger("sourceType") == 2){ | |
| 229 | - if(json.getJSONArray("sourceIds") != null){ | |
| 230 | - List<String> tIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 231 | - user.setTruckList(tIds); | |
| 232 | - } | |
| 233 | - if(json.getJSONArray("companyIds") != null){ | |
| 234 | - List<String> companyIds = json.getJSONArray("companyIds").toJavaList(String.class); | |
| 235 | - user.setCompanyIds(companyIds); | |
| 236 | - } | |
| 237 | - | |
| 238 | - if(json.getJSONArray("adCodes") != null){ | |
| 239 | - List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 240 | - user.setCompanyAreas(areas); | |
| 241 | - } | |
| 242 | - }else if(json.getInteger("sourceType") == 3){ | |
| 243 | - if(json.getJSONArray("sourceIds") != null){ | |
| 244 | - List<String> companyIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 245 | - user.setConList(companyIds); | |
| 246 | - } | |
| 247 | - if(json.getJSONArray("adCodes") != null){ | |
| 248 | - List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 249 | - user.setConAreas(areas); | |
| 250 | - } | |
| 251 | - }else if(json.getInteger("sourceType") == 4){ | |
| 252 | - if(json.getJSONArray("sourceIds") != null){ | |
| 253 | - List<String> companyIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 254 | - user.setEarthList(companyIds); | |
| 255 | - } | |
| 256 | - if(json.getJSONArray("adCodes") != null){ | |
| 257 | - List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 258 | - user.setEarthAreas(areas); | |
| 259 | - } | |
| 260 | - } | |
| 261 | - } | |
| 262 | - } | |
| 263 | - | |
| 264 | - | |
| 265 | - | |
| 266 | - dept.setDeptName(userJson.getString("orgName")); | |
| 267 | - | |
| 268 | - user.setDept(dept); | |
| 269 | - | |
| 270 | - user.setAvatar(RemoteServerUtils.remote + userJson.getString("elecSignaturePath")); | |
| 271 | - | |
| 272 | - loginUser.setUser(user); | |
| 273 | - | |
| 274 | - | |
| 275 | - set.add("*:*:*");//测试直接给admin | |
| 276 | - | |
| 277 | - for(Object object:userJson.getJSONArray("menus")){ | |
| 278 | - JSONObject menu = (JSONObject) object; | |
| 279 | - | |
| 280 | - set.add(menu.getString("code")); | |
| 281 | - } | |
| 282 | - | |
| 283 | - | |
| 284 | - SysRole role = new SysRole(); | |
| 285 | - | |
| 286 | - role.setRoleKey("admin"); | |
| 287 | - | |
| 288 | - ArrayList<SysRole> roles = new ArrayList<SysRole>(); | |
| 289 | - | |
| 290 | - roles.add(role); | |
| 291 | - | |
| 292 | - user.setRoles(roles); | |
| 293 | - | |
| 294 | - token = token.replace("Bearer ", "").replace("auth:token:", ""); | |
| 295 | - | |
| 296 | - loginUser.setPermissions(set); | |
| 297 | - | |
| 298 | - loginUser.setToken(token); | |
| 299 | - tokenService.refreshToken(loginUser); | |
| 300 | - | |
| 301 | - // 生成token | |
| 302 | - return loginUser; | |
| 303 | - } | |
| 150 | + | |
| 151 | + LoginUser loginUser = new LoginUser(); | |
| 152 | + | |
| 153 | + ArrayList<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>(); | |
| 154 | + SimpleGrantedAuthority activitiUser = new SimpleGrantedAuthority("ROLE_ACTIVITI_USER"); | |
| 155 | + SimpleGrantedAuthority admin = new SimpleGrantedAuthority("admin"); | |
| 156 | + authorities.add(activitiUser); | |
| 157 | + authorities.add(admin); | |
| 158 | + loginUser.setAuthorities(authorities); | |
| 159 | + | |
| 160 | + Set<String> set = new HashSet<String>(); | |
| 161 | + | |
| 162 | + SysUser user = new SysUser(); | |
| 163 | + user.setUserId(userJson.getString("id")); | |
| 164 | + user.setUserName(userJson.getString("name")); | |
| 165 | + user.setNickName(userJson.getString("name")); | |
| 166 | + user.setPassword(userJson.getString("id")); | |
| 167 | + SysDept dept = new SysDept(); | |
| 168 | + | |
| 169 | + if (userJson.getJSONArray("userIdentityList") != null) { | |
| 170 | + | |
| 171 | + List<String> poStrings = new ArrayList<String>(); | |
| 172 | + | |
| 173 | + List<String> rolStrings = new ArrayList<String>(); | |
| 174 | + | |
| 175 | + try { | |
| 176 | + | |
| 177 | + for (Object obj : userJson.getJSONArray("userIdentityList")) { | |
| 178 | + | |
| 179 | + JSONObject uId = (JSONObject) obj; | |
| 180 | + | |
| 181 | + poStrings.add(uId.getString("postType")); | |
| 182 | + | |
| 183 | + rolStrings.add(uId.getString("departmentType")); | |
| 184 | + | |
| 185 | + } | |
| 186 | + | |
| 187 | + user.setPostIds(poStrings); | |
| 188 | + | |
| 189 | + user.setRoleIds(rolStrings); | |
| 190 | + | |
| 191 | + } catch (Exception e) { | |
| 192 | + // TODO: handle exception | |
| 193 | + } | |
| 194 | + | |
| 195 | + } | |
| 196 | + | |
| 197 | + JSONArray compnayList = redisCache.getCacheObject("companyList"); | |
| 198 | + | |
| 199 | + if (compnayList == null) { | |
| 200 | + compnayList = JSONArray.parseArray(tempMapper.getLocalData("companyList")); | |
| 201 | + } | |
| 202 | + for (Object obj : compnayList) { | |
| 203 | + JSONObject con = (JSONObject) (obj); | |
| 204 | + | |
| 205 | + if (con.getString("abbreviation").equals(user.getUserName().replace("公司", ""))) { | |
| 206 | + user.setCompanyName(con.getString("name")); | |
| 207 | + user.setUserName(con.getString("abbreviation")); | |
| 208 | + user.setNickName(con.getString("abbreviation")); | |
| 209 | + break; | |
| 210 | + } | |
| 211 | + | |
| 212 | + } | |
| 213 | + | |
| 214 | + JSONArray jsonArray = (JSONArray) RemoteServerUtils.getAuth(token); | |
| 215 | + | |
| 216 | + JSONArray streets = (JSONArray) RemoteServerUtils.getStreets(token); | |
| 217 | + | |
| 218 | + Map<String, List<String>> streetsMap = new HashMap<String, List<String>>(); | |
| 219 | + | |
| 220 | + for(Object obj:streets){ | |
| 221 | + JSONObject jsonObject = (JSONObject) obj; | |
| 222 | + if(jsonObject.getString("level").equals("3")){ | |
| 223 | + streetsMap.put(jsonObject.getString("id"), new ArrayList<>()); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + for(Object obj:streets){ | |
| 228 | + JSONObject jsonObject = (JSONObject) obj; | |
| 229 | + if(jsonObject.getString("level").equals("4")){ | |
| 230 | + streetsMap.get(jsonObject.getString("pid")).add(jsonObject.getString("name")); | |
| 231 | + } | |
| 232 | + } | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + if (jsonArray != null) { | |
| 237 | + | |
| 238 | + | |
| 239 | + if(user.getStreetsList() == null){ | |
| 240 | + user.setStreetsList(new ArrayList<>()); | |
| 241 | + } | |
| 242 | + | |
| 243 | + for (Object obj : jsonArray) { | |
| 244 | + JSONObject json = (JSONObject) obj; | |
| 245 | + if (json.getInteger("sourceType") == 2) { | |
| 246 | + if (json.getJSONArray("sourceIds") != null) { | |
| 247 | + List<String> tIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 248 | + user.setTruckList(tIds); | |
| 249 | + } | |
| 250 | + if (json.getJSONArray("companyIds") != null) { | |
| 251 | + List<String> companyIds = json.getJSONArray("companyIds").toJavaList(String.class); | |
| 252 | + user.setCompanyIds(companyIds); | |
| 253 | + } | |
| 254 | + | |
| 255 | + if (json.getJSONArray("adCodes") != null) { | |
| 256 | + List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 257 | + user.setCompanyAreas(areas); | |
| 258 | + } | |
| 259 | + } else if (json.getInteger("sourceType") == 3) { | |
| 260 | + if (json.getJSONArray("sourceIds") != null) { | |
| 261 | + List<String> companyIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 262 | + user.setConList(companyIds); | |
| 263 | + } | |
| 264 | + if (json.getJSONArray("adCodes") != null) { | |
| 265 | + List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 266 | + user.setConAreas(areas); | |
| 267 | + } | |
| 268 | + } else if (json.getInteger("sourceType") == 4) { | |
| 269 | + if (json.getJSONArray("sourceIds") != null) { | |
| 270 | + List<String> companyIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 271 | + user.setEarthList(companyIds); | |
| 272 | + } | |
| 273 | + if (json.getJSONArray("adCodes") != null) { | |
| 274 | + List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 275 | + user.setEarthAreas(areas); | |
| 276 | + } | |
| 277 | + } else if (json.getInteger("sourceType") == 6) { | |
| 278 | + if (json.getJSONArray("sourceIds") != null) { | |
| 279 | + List<String> companyIds = json.getJSONArray("sourceIds").toJavaList(String.class); | |
| 280 | + | |
| 281 | + for(String id:companyIds){ | |
| 282 | + for(Object sObj:streets){ | |
| 283 | + JSONObject jsonObject = (JSONObject) sObj; | |
| 284 | + if(jsonObject.getString("id").equals(id)){ | |
| 285 | + user.getStreetsList().add(jsonObject.getString("name")); | |
| 286 | + } | |
| 287 | + } | |
| 288 | + } | |
| 289 | + } | |
| 290 | + if (json.getJSONArray("adCodes") != null) { | |
| 291 | + List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 292 | + for(String str:areas){ | |
| 293 | + if(streetsMap.get(str) == null) | |
| 294 | + continue; | |
| 295 | + user.getStreetsList().addAll(streetsMap.get(str)); | |
| 296 | + } | |
| 297 | + } | |
| 298 | + } | |
| 299 | + } | |
| 300 | + } | |
| 301 | + | |
| 302 | + dept.setDeptName(userJson.getString("orgName")); | |
| 303 | + | |
| 304 | + user.setDept(dept); | |
| 305 | + | |
| 306 | + user.setAvatar(RemoteServerUtils.remote + userJson.getString("elecSignaturePath")); | |
| 307 | + | |
| 308 | + loginUser.setUser(user); | |
| 309 | + | |
| 310 | + set.add("*:*:*");// 测试直接给admin | |
| 311 | + | |
| 312 | + for (Object object : userJson.getJSONArray("menus")) { | |
| 313 | + JSONObject menu = (JSONObject) object; | |
| 314 | + | |
| 315 | + set.add(menu.getString("code")); | |
| 316 | + } | |
| 317 | + | |
| 318 | + SysRole role = new SysRole(); | |
| 319 | + | |
| 320 | + role.setRoleKey("admin"); | |
| 321 | + | |
| 322 | + ArrayList<SysRole> roles = new ArrayList<SysRole>(); | |
| 323 | + | |
| 324 | + roles.add(role); | |
| 325 | + | |
| 326 | + user.setRoles(roles); | |
| 327 | + | |
| 328 | + token = token.replace("Bearer ", "").replace("auth:token:", ""); | |
| 329 | + | |
| 330 | + loginUser.setPermissions(set); | |
| 331 | + | |
| 332 | + loginUser.setToken(token); | |
| 333 | + tokenService.refreshToken(loginUser); | |
| 334 | + | |
| 335 | + // 生成token | |
| 336 | + return loginUser; | |
| 337 | + } | |
| 304 | 338 | } | ... | ... |
trash-quartz/src/main/java/com/trash/quartz/task/DriverTask.java
| ... | ... | @@ -603,8 +603,11 @@ public class DriverTask { |
| 603 | 603 | if (TOKEN == null) { |
| 604 | 604 | TOKEN = trashConfig.getToken(); |
| 605 | 605 | } |
| 606 | - | |
| 607 | - JSONArray drivers = RemoteServerUtils.getDriverList(TOKEN); | |
| 606 | + | |
| 607 | + Map map = new HashMap<>(); | |
| 608 | + map.put("size", "99999"); | |
| 609 | + map.put("page", "1"); | |
| 610 | + JSONArray drivers = RemoteServerUtils.getDriverList(TOKEN,map); | |
| 608 | 611 | |
| 609 | 612 | for (Object object : drivers) { |
| 610 | 613 | |
| ... | ... | @@ -640,7 +643,7 @@ public class DriverTask { |
| 640 | 643 | |
| 641 | 644 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| 642 | 645 | Map map = new HashMap<>(); |
| 643 | - map.put("size", 9999); | |
| 646 | + map.put("size", 99999); | |
| 644 | 647 | map.put("valid", 0); |
| 645 | 648 | map.put("page", 1); |
| 646 | 649 | |
| ... | ... | @@ -713,7 +716,7 @@ public class DriverTask { |
| 713 | 716 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| 714 | 717 | |
| 715 | 718 | Map map = new HashMap<>(); |
| 716 | - map.put("size", 9999); | |
| 719 | + map.put("size", 99999); | |
| 717 | 720 | map.put("page", 1); |
| 718 | 721 | |
| 719 | 722 | JSONArray companys = RemoteServerUtils.getCompanyList(map, TOKEN); | ... | ... |
trash-ui/dist.7z
No preview for this file type
trash-ui/src/api/dayWorkReport.js
| ... | ... | @@ -218,7 +218,7 @@ export default { |
| 218 | 218 | var size = this.queryParams.pageSize; |
| 219 | 219 | |
| 220 | 220 | this.queryParams.page = 1; |
| 221 | - this.queryParams.pageSize = 9999; | |
| 221 | + this.queryParams.pageSize = 999999; | |
| 222 | 222 | |
| 223 | 223 | if (this.queryParams.timeRange) { |
| 224 | 224 | this.queryParams.workStartTime = this.queryParams.timeRange[0]; | ... | ... |
trash-ui/src/api/truck_active.js
| ... | ... | @@ -298,16 +298,16 @@ export default { |
| 298 | 298 | let list = tres.result.list; |
| 299 | 299 | |
| 300 | 300 | let qr = { |
| 301 | - status:0, | |
| 302 | - constructionId:item.objectId | |
| 301 | + status:0 | |
| 303 | 302 | } |
| 304 | 303 | |
| 305 | 304 | listTruckActivate(qr).then(response => { |
| 306 | 305 | let taList = response.rows; |
| 307 | 306 | for(let i = 0;i< list.length;i++){ |
| 308 | - if(vids.indexOf(list[i].id) == -1){ | |
| 309 | - continue; | |
| 310 | - } | |
| 307 | + //过滤勾选车辆 | |
| 308 | + // if(vids.indexOf(list[i].id) == -1){ | |
| 309 | + // continue; | |
| 310 | + // } | |
| 311 | 311 | let count = 0; |
| 312 | 312 | for(let j in taList){ |
| 313 | 313 | if(taList[j].objectId == list[i].id){ | ... | ... |
trash-ui/src/api/vio_warning_info.js
| ... | ... | @@ -80,10 +80,10 @@ export default { |
| 80 | 80 | replyPeople:obj.createBy, |
| 81 | 81 | replyTime:obj.createTime |
| 82 | 82 | }; |
| 83 | - | |
| 83 | + | |
| 84 | 84 | newRep.push(data); |
| 85 | 85 | } |
| 86 | - | |
| 86 | + | |
| 87 | 87 | |
| 88 | 88 | for(let j in array){ |
| 89 | 89 | newRep.push(array[j]); |
| ... | ... | @@ -97,7 +97,7 @@ export default { |
| 97 | 97 | }; |
| 98 | 98 | newRep.push(data); |
| 99 | 99 | } |
| 100 | - | |
| 100 | + | |
| 101 | 101 | this.replyApprovalProcessList = newRep; |
| 102 | 102 | this.$forceUpdate(); |
| 103 | 103 | }); | ... | ... |
trash-ui/src/api/warningInfo.js
| ... | ... | @@ -207,7 +207,16 @@ export default { |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | |
| 210 | - this.getList(); | |
| 210 | + this.getList(); | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + setInterval(() => { | |
| 215 | + console.log("getList"); | |
| 216 | + this.getList(); | |
| 217 | + }, 60000); | |
| 218 | + | |
| 219 | + | |
| 211 | 220 | }, |
| 212 | 221 | methods: { |
| 213 | 222 | getCaseStatus(item){ |
| ... | ... | @@ -245,8 +254,7 @@ export default { |
| 245 | 254 | return type; |
| 246 | 255 | }, |
| 247 | 256 | /** 查询违规预警信息列表 */ |
| 248 | - getList() { | |
| 249 | - this.loading = true; | |
| 257 | + getList() { | |
| 250 | 258 | if(this.queryParams.createTime){ |
| 251 | 259 | this.queryParams.startTime = this.queryParams.createTime[0]; |
| 252 | 260 | this.queryParams.endTime = this.queryParams.createTime[1]; |
| ... | ... | @@ -431,7 +439,7 @@ export default { |
| 431 | 439 | } |
| 432 | 440 | if(query.owningRegion) |
| 433 | 441 | query.owningRegion = query.owningRegion + "" |
| 434 | - | |
| 442 | + | |
| 435 | 443 | query.createTime = null; |
| 436 | 444 | |
| 437 | 445 | this.$confirm('是否确认导出所有违规预警信息数据项?', "警告", { | ... | ... |
trash-ui/src/views/h5/task/violationCaseFileInfo.vue
trash-ui/src/views/h5/task/violationWarningInformationInfo.vue
trash-ui/src/views/h5/threestep/index.vue
| ... | ... | @@ -67,13 +67,23 @@ |
| 67 | 67 | <el-col :span="24"> |
| 68 | 68 | <div>巡查时间:{{item.checkTime}}</div> |
| 69 | 69 | </el-col> |
| 70 | - </el-row> | |
| 70 | + </el-row> | |
| 71 | + | |
| 72 | + <el-row class="card_row" style="margin-top: 20px;" v-if="queryParams.pageStatus==1"> | |
| 73 | + <el-col :span="24"> | |
| 74 | + <div>抽查时间:{{item.checkEndTime}}</div> | |
| 75 | + </el-col> | |
| 76 | + </el-row> | |
| 77 | + | |
| 78 | + | |
| 71 | 79 | |
| 72 | 80 | <span v-if="item.status==3">已停工"</span> |
| 73 | 81 | |
| 74 | 82 | |
| 75 | - <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(item,0)" v-hasPermi="['business:threestep:edit']" v-if="queryParams.pageStatus==1 && item.status==1 && item.checkEndTime == null">抽查</el-button> | |
| 76 | - <el-button size="mini" type="text" icon="el-icon-edit" @click="reSub(item)" v-hasPermi="['business:threestep:add']" v-if="item.status==2">被驳回</el-button> | |
| 83 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(item,0)" | |
| 84 | + v-if="queryParams.pageStatus==1 && item.status==1 && item.checkEndTime == null | |
| 85 | + && checkPer(['business.supervision.threestep.spot'])">抽查</el-button> | |
| 86 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="reSub(item)" v-hasPermi="['business:threestep:add']" v-if="item.status==2">被驳回</el-button> | |
| 77 | 87 | |
| 78 | 88 | |
| 79 | 89 | <el-button size="mini" type="text" @click="handleUpdate(item,1)" v-hasPermi="['business:threestep:edit']">查看详情</el-button> | ... | ... |
trash-ui/src/views/h5/truckActivate/index.vue
| ... | ... | @@ -49,8 +49,8 @@ |
| 49 | 49 | placeholder="结束日期"> |
| 50 | 50 | </el-date-picker> |
| 51 | 51 | </el-form-item> |
| 52 | - | |
| 53 | - | |
| 52 | + | |
| 53 | + | |
| 54 | 54 | <el-form-item> |
| 55 | 55 | <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
| 56 | 56 | <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
| ... | ... | @@ -120,7 +120,7 @@ |
| 120 | 120 | <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| 121 | 121 | <el-form-item label="所属工地" prop="construction"> |
| 122 | 122 | <el-select v-model="form.construction" placeholder="请选择所属工地" filterable reserve-keyword @change="getCompany"> |
| 123 | - <el-option v-for="item in constList" :label="item.name" :value="item.name" ></el-option> | |
| 123 | + <el-option class="custom-option" v-for="item in constList" :label="item.name" :value="item.name" ></el-option> | |
| 124 | 124 | </el-select> |
| 125 | 125 | </el-form-item> |
| 126 | 126 | <el-form-item label="所属企业" prop="company"> |
| ... | ... | @@ -157,4 +157,11 @@ |
| 157 | 157 | .el-select-dropdown__item{ |
| 158 | 158 | width:300px; |
| 159 | 159 | } |
| 160 | + .el-select-dropdown__item.hover, .el-select-dropdown__item:hover{ | |
| 161 | + height:auto; | |
| 162 | + } | |
| 163 | + .custom-option { | |
| 164 | + white-space: normal; /* 允许文本换行 */ | |
| 165 | + word-wrap: break-word; /* 在长单词或URL地址内部进行换行 */ | |
| 166 | + } | |
| 160 | 167 | </style> | ... | ... |
trash-unit/src/main/java/com/trash/dropPointInfo/domain/DropPointInfo.java
| ... | ... | @@ -2,6 +2,8 @@ package com.trash.dropPointInfo.domain; |
| 2 | 2 | |
| 3 | 3 | import java.math.BigDecimal; |
| 4 | 4 | import java.util.Date; |
| 5 | +import java.util.List; | |
| 6 | + | |
| 5 | 7 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 6 | 8 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 7 | 9 | import org.apache.commons.lang3.builder.ToStringStyle; |
| ... | ... | @@ -84,8 +86,18 @@ public class DropPointInfo extends BaseEntity |
| 84 | 86 | /** 坐标点 */ |
| 85 | 87 | @Excel(name = "坐标点") |
| 86 | 88 | private String coordinatePoint; |
| 87 | - | |
| 88 | - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 89 | + | |
| 90 | + private List<String> sList; | |
| 91 | + | |
| 92 | + public List<String> getSList() { | |
| 93 | + return sList; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setSList(List<String> sList) { | |
| 97 | + this.sList = sList; | |
| 98 | + } | |
| 99 | + | |
| 100 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
| 89 | 101 | @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| 90 | 102 | private Date createTime; |
| 91 | 103 | ... | ... |
trash-unit/src/main/java/com/trash/dropPointInfo/service/impl/DropPointInfoServiceImpl.java
| 1 | 1 | package com.trash.dropPointInfo.service.impl; |
| 2 | 2 | |
| 3 | +import java.util.ArrayList; | |
| 3 | 4 | import java.util.List; |
| 4 | 5 | import com.trash.common.utils.DateUtils; |
| 5 | 6 | import com.trash.common.utils.SecurityUtils; |
| ... | ... | @@ -41,8 +42,16 @@ public class DropPointInfoServiceImpl implements IDropPointInfoService |
| 41 | 42 | */ |
| 42 | 43 | @Override |
| 43 | 44 | public List<DropPointInfo> selectDropPointInfoList(DropPointInfo dropPointInfo) |
| 44 | - { | |
| 45 | - return dropPointInfoMapper.selectDropPointInfoList(dropPointInfo); | |
| 45 | + { | |
| 46 | + List<String> ids = SecurityUtils.getLoginUser().getUser().getStreetsList(); | |
| 47 | + | |
| 48 | + if(ids.size() > 0){ | |
| 49 | + dropPointInfo.setSList(ids); | |
| 50 | + return dropPointInfoMapper.selectDropPointInfoList(dropPointInfo); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return new ArrayList<DropPointInfo>(); | |
| 54 | + | |
| 46 | 55 | } |
| 47 | 56 | |
| 48 | 57 | /** | ... | ... |
trash-unit/src/main/resources/mapper/unit/DropPointInfoMapper.xml
| ... | ... | @@ -3,134 +3,150 @@ |
| 3 | 3 | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 4 | 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 5 | 5 | <mapper namespace="com.trash.dropPointInfo.mapper.DropPointInfoMapper"> |
| 6 | - | |
| 7 | - <resultMap type="DropPointInfo" id="DropPointInfoResult"> | |
| 8 | - <result property="id" column="id" /> | |
| 9 | - <result property="dropPointName" column="drop_point_name" /> | |
| 10 | - <result property="district" column="district" /> | |
| 11 | - <result property="street" column="street" /> | |
| 12 | - <result property="community" column="community" /> | |
| 13 | - <result property="address" column="address" /> | |
| 14 | - <result property="type" column="type" /> | |
| 15 | - <result property="area" column="area" /> | |
| 16 | - <result property="capacity" column="capacity" /> | |
| 17 | - <result property="managementUnit" column="management_unit" /> | |
| 18 | - <result property="custodian" column="custodian" /> | |
| 19 | - <result property="custodianPhone" column="custodian_phone" /> | |
| 20 | - <result property="dropTime" column="drop_time" /> | |
| 21 | - <result property="dropPointNo" column="drop_point_no" /> | |
| 22 | - <result property="operatingUnit" column="operating_unit" /> | |
| 23 | - <result property="transportUnit" column="transport_unit" /> | |
| 24 | - <result property="coordinatePoint" column="coordinate_point" /> | |
| 25 | - <result property="createTime" column="create_time" /> | |
| 26 | - <result property="createBy" column="create_by" /> | |
| 27 | - <result property="updateTime" column="update_time" /> | |
| 28 | - <result property="updateBy" column="update_by" /> | |
| 29 | - </resultMap> | |
| 30 | 6 | |
| 31 | - <sql id="selectDropPointInfoVo"> | |
| 32 | - select id, drop_point_name, district, street, community, address, type, area, capacity, management_unit, custodian, custodian_phone, drop_time, drop_point_no, operating_unit, transport_unit,coordinate_point, create_time, create_by, update_time, update_by from drop_point_info | |
| 33 | - </sql> | |
| 7 | + <resultMap type="DropPointInfo" id="DropPointInfoResult"> | |
| 8 | + <result property="id" column="id" /> | |
| 9 | + <result property="dropPointName" column="drop_point_name" /> | |
| 10 | + <result property="district" column="district" /> | |
| 11 | + <result property="street" column="street" /> | |
| 12 | + <result property="community" column="community" /> | |
| 13 | + <result property="address" column="address" /> | |
| 14 | + <result property="type" column="type" /> | |
| 15 | + <result property="area" column="area" /> | |
| 16 | + <result property="capacity" column="capacity" /> | |
| 17 | + <result property="managementUnit" column="management_unit" /> | |
| 18 | + <result property="custodian" column="custodian" /> | |
| 19 | + <result property="custodianPhone" column="custodian_phone" /> | |
| 20 | + <result property="dropTime" column="drop_time" /> | |
| 21 | + <result property="dropPointNo" column="drop_point_no" /> | |
| 22 | + <result property="operatingUnit" column="operating_unit" /> | |
| 23 | + <result property="transportUnit" column="transport_unit" /> | |
| 24 | + <result property="coordinatePoint" column="coordinate_point" /> | |
| 25 | + <result property="createTime" column="create_time" /> | |
| 26 | + <result property="createBy" column="create_by" /> | |
| 27 | + <result property="updateTime" column="update_time" /> | |
| 28 | + <result property="updateBy" column="update_by" /> | |
| 29 | + </resultMap> | |
| 34 | 30 | |
| 35 | - <select id="selectDropPointInfoList" parameterType="DropPointInfo" resultMap="DropPointInfoResult"> | |
| 36 | - <include refid="selectDropPointInfoVo"/> | |
| 37 | - <where> | |
| 38 | - <if test="dropPointName != null and dropPointName != ''"> and drop_point_name like concat('%', #{dropPointName}, '%')</if> | |
| 39 | - <if test="address != null and address != ''"> and address like concat('%', #{address}, '%')</if> | |
| 40 | - <if test="type != null and type != ''"> and type = #{type}</if> | |
| 41 | - <if test="dropPointNo != null and dropPointNo != ''"> and drop_point_no like concat(#{dropPointNo}, '%')</if> | |
| 42 | - </where> | |
| 43 | - </select> | |
| 44 | - | |
| 45 | - <select id="selectDropPointInfoById" parameterType="Long" resultMap="DropPointInfoResult"> | |
| 46 | - <include refid="selectDropPointInfoVo"/> | |
| 47 | - where id = #{id} | |
| 48 | - </select> | |
| 49 | - | |
| 50 | - <insert id="insertDropPointInfo" parameterType="DropPointInfo" useGeneratedKeys="true" keyProperty="id"> | |
| 51 | - insert into drop_point_info | |
| 52 | - <trim prefix="(" suffix=")" suffixOverrides=","> | |
| 53 | - <if test="dropPointName != null">drop_point_name,</if> | |
| 54 | - <if test="district != null">district,</if> | |
| 55 | - <if test="street != null">street,</if> | |
| 56 | - <if test="community != null">community,</if> | |
| 57 | - <if test="address != null">address,</if> | |
| 58 | - <if test="type != null">type,</if> | |
| 59 | - <if test="area != null">area,</if> | |
| 60 | - <if test="capacity != null">capacity,</if> | |
| 61 | - <if test="managementUnit != null">management_unit,</if> | |
| 62 | - <if test="custodian != null">custodian,</if> | |
| 63 | - <if test="custodianPhone != null">custodian_phone,</if> | |
| 64 | - <if test="dropTime != null">drop_time,</if> | |
| 65 | - <if test="dropPointNo != null">drop_point_no,</if> | |
| 66 | - <if test="operatingUnit != null">operating_unit,</if> | |
| 67 | - <if test="transportUnit != null">transport_unit,</if> | |
| 68 | - <if test="coordinatePoint != null">coordinate_point,</if> | |
| 69 | - <if test="createTime != null">create_time,</if> | |
| 70 | - <if test="createBy != null">create_by,</if> | |
| 71 | - <if test="updateTime != null">update_time,</if> | |
| 72 | - <if test="updateBy != null">update_by,</if> | |
| 73 | - </trim> | |
| 74 | - <trim prefix="values (" suffix=")" suffixOverrides=","> | |
| 75 | - <if test="dropPointName != null">#{dropPointName},</if> | |
| 76 | - <if test="district != null">#{district},</if> | |
| 77 | - <if test="street != null">#{street},</if> | |
| 78 | - <if test="community != null">#{community},</if> | |
| 79 | - <if test="address != null">#{address},</if> | |
| 80 | - <if test="type != null">#{type},</if> | |
| 81 | - <if test="area != null">#{area},</if> | |
| 82 | - <if test="capacity != null">#{capacity},</if> | |
| 83 | - <if test="managementUnit != null">#{managementUnit},</if> | |
| 84 | - <if test="custodian != null">#{custodian},</if> | |
| 85 | - <if test="custodianPhone != null">#{custodianPhone},</if> | |
| 86 | - <if test="dropTime != null">#{dropTime},</if> | |
| 87 | - <if test="dropPointNo != null">#{dropPointNo},</if> | |
| 88 | - <if test="operatingUnit != null">#{operatingUnit},</if> | |
| 89 | - <if test="transportUnit != null">#{transportUnit},</if> | |
| 90 | - <if test="coordinatePoint != null">#{coordinatePoint},</if> | |
| 91 | - <if test="createTime != null">#{createTime},</if> | |
| 92 | - <if test="createBy != null">#{createBy},</if> | |
| 93 | - <if test="updateTime != null">#{updateTime},</if> | |
| 94 | - <if test="updateBy != null">#{updateBy},</if> | |
| 95 | - </trim> | |
| 96 | - </insert> | |
| 31 | + <sql id="selectDropPointInfoVo"> | |
| 32 | + select id, drop_point_name, district, street, community, address, type, | |
| 33 | + area, capacity, management_unit, custodian, custodian_phone, | |
| 34 | + drop_time, drop_point_no, operating_unit, | |
| 35 | + transport_unit,coordinate_point, create_time, create_by, update_time, | |
| 36 | + update_by from drop_point_info | |
| 37 | + </sql> | |
| 97 | 38 | |
| 98 | - <update id="updateDropPointInfo" parameterType="DropPointInfo"> | |
| 99 | - update drop_point_info | |
| 100 | - <trim prefix="SET" suffixOverrides=","> | |
| 101 | - <if test="dropPointName != null">drop_point_name = #{dropPointName},</if> | |
| 102 | - <if test="district != null">district = #{district},</if> | |
| 103 | - <if test="street != null">street = #{street},</if> | |
| 104 | - <if test="community != null">community = #{community},</if> | |
| 105 | - <if test="address != null">address = #{address},</if> | |
| 106 | - <if test="type != null">type = #{type},</if> | |
| 107 | - <if test="area != null">area = #{area},</if> | |
| 108 | - <if test="capacity != null">capacity = #{capacity},</if> | |
| 109 | - <if test="managementUnit != null">management_unit = #{managementUnit},</if> | |
| 110 | - <if test="custodian != null">custodian = #{custodian},</if> | |
| 111 | - <if test="custodianPhone != null">custodian_phone = #{custodianPhone},</if> | |
| 112 | - <if test="dropTime != null">drop_time = #{dropTime},</if> | |
| 113 | - <if test="dropPointNo != null">drop_point_no = #{dropPointNo},</if> | |
| 114 | - <if test="operatingUnit != null">operating_unit = #{operatingUnit},</if> | |
| 115 | - <if test="transportUnit != null">transport_unit = #{transportUnit},</if> | |
| 116 | - <if test="coordinatePoint != null">coordinate_point = #{coordinatePoint},</if> | |
| 117 | - <if test="createTime != null">create_time = #{createTime},</if> | |
| 118 | - <if test="createBy != null">create_by = #{createBy},</if> | |
| 119 | - <if test="updateTime != null">update_time = #{updateTime},</if> | |
| 120 | - <if test="updateBy != null">update_by = #{updateBy},</if> | |
| 121 | - </trim> | |
| 122 | - where id = #{id} | |
| 123 | - </update> | |
| 39 | + <select id="selectDropPointInfoList" parameterType="DropPointInfo" | |
| 40 | + resultMap="DropPointInfoResult"> | |
| 41 | + <include refid="selectDropPointInfoVo" /> | |
| 42 | + <where> | |
| 43 | + <if test="dropPointName != null and dropPointName != ''"> and drop_point_name like concat('%', #{dropPointName}, | |
| 44 | + '%')</if> | |
| 45 | + <if test="address != null and address != ''"> and address like concat('%', #{address}, '%')</if> | |
| 46 | + <if test="type != null and type != ''"> and type = #{type}</if> | |
| 47 | + <if test="dropPointNo != null and dropPointNo != ''"> and drop_point_no like concat(#{dropPointNo}, '%')</if> | |
| 48 | + <if test="sList != null and sList.size() > 0 "> | |
| 49 | + and street in | |
| 50 | + <foreach item="id" collection="sList" open="(" separator="," | |
| 51 | + close=")"> | |
| 52 | + #{id} | |
| 53 | + </foreach> | |
| 54 | + </if> | |
| 55 | + </where> | |
| 56 | + </select> | |
| 124 | 57 | |
| 125 | - <delete id="deleteDropPointInfoById" parameterType="Long"> | |
| 126 | - delete from drop_point_info where id = #{id} | |
| 127 | - </delete> | |
| 58 | + <select id="selectDropPointInfoById" parameterType="Long" | |
| 59 | + resultMap="DropPointInfoResult"> | |
| 60 | + <include refid="selectDropPointInfoVo" /> | |
| 61 | + where id = #{id} | |
| 62 | + </select> | |
| 63 | + | |
| 64 | + <insert id="insertDropPointInfo" parameterType="DropPointInfo" | |
| 65 | + useGeneratedKeys="true" keyProperty="id"> | |
| 66 | + insert into drop_point_info | |
| 67 | + <trim prefix="(" suffix=")" suffixOverrides=","> | |
| 68 | + <if test="dropPointName != null">drop_point_name,</if> | |
| 69 | + <if test="district != null">district,</if> | |
| 70 | + <if test="street != null">street,</if> | |
| 71 | + <if test="community != null">community,</if> | |
| 72 | + <if test="address != null">address,</if> | |
| 73 | + <if test="type != null">type,</if> | |
| 74 | + <if test="area != null">area,</if> | |
| 75 | + <if test="capacity != null">capacity,</if> | |
| 76 | + <if test="managementUnit != null">management_unit,</if> | |
| 77 | + <if test="custodian != null">custodian,</if> | |
| 78 | + <if test="custodianPhone != null">custodian_phone,</if> | |
| 79 | + <if test="dropTime != null">drop_time,</if> | |
| 80 | + <if test="dropPointNo != null">drop_point_no,</if> | |
| 81 | + <if test="operatingUnit != null">operating_unit,</if> | |
| 82 | + <if test="transportUnit != null">transport_unit,</if> | |
| 83 | + <if test="coordinatePoint != null">coordinate_point,</if> | |
| 84 | + <if test="createTime != null">create_time,</if> | |
| 85 | + <if test="createBy != null">create_by,</if> | |
| 86 | + <if test="updateTime != null">update_time,</if> | |
| 87 | + <if test="updateBy != null">update_by,</if> | |
| 88 | + </trim> | |
| 89 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | |
| 90 | + <if test="dropPointName != null">#{dropPointName},</if> | |
| 91 | + <if test="district != null">#{district},</if> | |
| 92 | + <if test="street != null">#{street},</if> | |
| 93 | + <if test="community != null">#{community},</if> | |
| 94 | + <if test="address != null">#{address},</if> | |
| 95 | + <if test="type != null">#{type},</if> | |
| 96 | + <if test="area != null">#{area},</if> | |
| 97 | + <if test="capacity != null">#{capacity},</if> | |
| 98 | + <if test="managementUnit != null">#{managementUnit},</if> | |
| 99 | + <if test="custodian != null">#{custodian},</if> | |
| 100 | + <if test="custodianPhone != null">#{custodianPhone},</if> | |
| 101 | + <if test="dropTime != null">#{dropTime},</if> | |
| 102 | + <if test="dropPointNo != null">#{dropPointNo},</if> | |
| 103 | + <if test="operatingUnit != null">#{operatingUnit},</if> | |
| 104 | + <if test="transportUnit != null">#{transportUnit},</if> | |
| 105 | + <if test="coordinatePoint != null">#{coordinatePoint},</if> | |
| 106 | + <if test="createTime != null">#{createTime},</if> | |
| 107 | + <if test="createBy != null">#{createBy},</if> | |
| 108 | + <if test="updateTime != null">#{updateTime},</if> | |
| 109 | + <if test="updateBy != null">#{updateBy},</if> | |
| 110 | + </trim> | |
| 111 | + </insert> | |
| 112 | + | |
| 113 | + <update id="updateDropPointInfo" parameterType="DropPointInfo"> | |
| 114 | + update drop_point_info | |
| 115 | + <trim prefix="SET" suffixOverrides=","> | |
| 116 | + <if test="dropPointName != null">drop_point_name = #{dropPointName},</if> | |
| 117 | + <if test="district != null">district = #{district},</if> | |
| 118 | + <if test="street != null">street = #{street},</if> | |
| 119 | + <if test="community != null">community = #{community},</if> | |
| 120 | + <if test="address != null">address = #{address},</if> | |
| 121 | + <if test="type != null">type = #{type},</if> | |
| 122 | + <if test="area != null">area = #{area},</if> | |
| 123 | + <if test="capacity != null">capacity = #{capacity},</if> | |
| 124 | + <if test="managementUnit != null">management_unit = #{managementUnit},</if> | |
| 125 | + <if test="custodian != null">custodian = #{custodian},</if> | |
| 126 | + <if test="custodianPhone != null">custodian_phone = #{custodianPhone},</if> | |
| 127 | + <if test="dropTime != null">drop_time = #{dropTime},</if> | |
| 128 | + <if test="dropPointNo != null">drop_point_no = #{dropPointNo},</if> | |
| 129 | + <if test="operatingUnit != null">operating_unit = #{operatingUnit},</if> | |
| 130 | + <if test="transportUnit != null">transport_unit = #{transportUnit},</if> | |
| 131 | + <if test="coordinatePoint != null">coordinate_point = #{coordinatePoint},</if> | |
| 132 | + <if test="createTime != null">create_time = #{createTime},</if> | |
| 133 | + <if test="createBy != null">create_by = #{createBy},</if> | |
| 134 | + <if test="updateTime != null">update_time = #{updateTime},</if> | |
| 135 | + <if test="updateBy != null">update_by = #{updateBy},</if> | |
| 136 | + </trim> | |
| 137 | + where id = #{id} | |
| 138 | + </update> | |
| 139 | + | |
| 140 | + <delete id="deleteDropPointInfoById" parameterType="Long"> | |
| 141 | + delete from drop_point_info where id = #{id} | |
| 142 | + </delete> | |
| 143 | + | |
| 144 | + <delete id="deleteDropPointInfoByIds" parameterType="String"> | |
| 145 | + delete from drop_point_info where id in | |
| 146 | + <foreach item="id" collection="array" open="(" separator="," | |
| 147 | + close=")"> | |
| 148 | + #{id} | |
| 149 | + </foreach> | |
| 150 | + </delete> | |
| 128 | 151 | |
| 129 | - <delete id="deleteDropPointInfoByIds" parameterType="String"> | |
| 130 | - delete from drop_point_info where id in | |
| 131 | - <foreach item="id" collection="array" open="(" separator="," close=")"> | |
| 132 | - #{id} | |
| 133 | - </foreach> | |
| 134 | - </delete> | |
| 135 | - | |
| 136 | 152 | </mapper> |
| 137 | 153 | \ No newline at end of file | ... | ... |
trash-workFlow/src/main/java/com/trash/business/controller/TruckActivateController.java
| ... | ... | @@ -185,7 +185,7 @@ public class TruckActivateController extends BaseController |
| 185 | 185 | info.setAddress(turck.getAddress()); |
| 186 | 186 | info.setEarthName(turck.getEarthName()); |
| 187 | 187 | info.setRouteName(turck.getRouteName()); |
| 188 | - info.setTransportEndTime(turck.getTransportStartTime()); | |
| 188 | + info.setTransportEndTime(turck.getTransportEndTime()); | |
| 189 | 189 | info.setTransportStartTime(turck.getTransportStartTime()); |
| 190 | 190 | info.setEffectiveFrom(turck.getEffectiveFrom()); |
| 191 | 191 | info.setEffectiveEnd(turck.getEffectiveEnd()); | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/DriverCreditServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import java.util.Date; |
| 5 | 5 | import java.util.HashMap; |
| 6 | 6 | import java.util.List; |
| 7 | 7 | import java.util.Map; |
| 8 | +import java.util.concurrent.TimeUnit; | |
| 8 | 9 | |
| 9 | 10 | import com.trash.business.domain.TruckCredit; |
| 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -23,6 +24,8 @@ import com.trash.common.utils.util.PostSms; |
| 23 | 24 | import com.trash.common.utils.vo.mt.JsonSmsSend; |
| 24 | 25 | import com.trash.common.utils.vo.mt.Mobile; |
| 25 | 26 | |
| 27 | +import ch.qos.logback.core.util.TimeUtil; | |
| 28 | + | |
| 26 | 29 | import org.springframework.transaction.annotation.Transactional; |
| 27 | 30 | |
| 28 | 31 | /** |
| ... | ... | @@ -32,276 +35,300 @@ import org.springframework.transaction.annotation.Transactional; |
| 32 | 35 | * @date 2023-04-26 |
| 33 | 36 | */ |
| 34 | 37 | @Service |
| 35 | -public class DriverCreditServiceImpl implements IDriverCreditService | |
| 36 | -{ | |
| 37 | - @Autowired | |
| 38 | - private DriverCreditMapper driverCreditMapper; | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - RedisCache redisCache; | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * 查询驾驶员失信 | |
| 45 | - * | |
| 46 | - * @param id 驾驶员失信ID | |
| 47 | - * @return 驾驶员失信 | |
| 48 | - */ | |
| 49 | - @Override | |
| 50 | - public DriverCredit selectDriverCreditById(Long id) | |
| 51 | - { | |
| 52 | - return driverCreditMapper.selectDriverCreditById(id); | |
| 53 | - } | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 查询驾驶员失信列表 | |
| 57 | - * | |
| 58 | - * @param driverCredit 驾驶员失信 | |
| 59 | - * @return 驾驶员失信 | |
| 60 | - */ | |
| 61 | - @Autowired | |
| 62 | - private trashConfig trashConfig; | |
| 63 | - | |
| 64 | - @Autowired | |
| 65 | - RedisCache redis; | |
| 66 | - | |
| 67 | - @Override | |
| 68 | - public List<DriverCredit> selectDriverCreditList(DriverCredit driverCredit) | |
| 69 | - { | |
| 70 | - | |
| 71 | - List<DriverCredit> list = new ArrayList<>(); | |
| 72 | - | |
| 73 | - List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); | |
| 74 | - List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 75 | - | |
| 76 | - | |
| 77 | - if(areas.size() > 0) { | |
| 78 | - JSONArray array = redis.getCacheObject("companyList"); | |
| 79 | - if(array != null) { | |
| 80 | - for(Object obj:array) { | |
| 81 | - JSONObject json = (JSONObject)obj; | |
| 82 | - if(areas.indexOf(json.getString("areaCode")) > -1) { | |
| 83 | - companys.add(json.getString("id")); | |
| 84 | - } | |
| 38 | +public class DriverCreditServiceImpl implements IDriverCreditService { | |
| 39 | + @Autowired | |
| 40 | + private DriverCreditMapper driverCreditMapper; | |
| 41 | + | |
| 42 | + @Autowired | |
| 43 | + RedisCache redisCache; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 查询驾驶员失信 | |
| 47 | + * | |
| 48 | + * @param id | |
| 49 | + * 驾驶员失信ID | |
| 50 | + * @return 驾驶员失信 | |
| 51 | + */ | |
| 52 | + @Override | |
| 53 | + public DriverCredit selectDriverCreditById(Long id) { | |
| 54 | + return driverCreditMapper.selectDriverCreditById(id); | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 查询驾驶员失信列表 | |
| 59 | + * | |
| 60 | + * @param driverCredit | |
| 61 | + * 驾驶员失信 | |
| 62 | + * @return 驾驶员失信 | |
| 63 | + */ | |
| 64 | + @Autowired | |
| 65 | + private trashConfig trashConfig; | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public List<DriverCredit> selectDriverCreditList(DriverCredit driverCredit) { | |
| 69 | + | |
| 70 | + List<DriverCredit> list = new ArrayList<>(); | |
| 71 | + | |
| 72 | + List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); | |
| 73 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 74 | + | |
| 75 | + if (areas.size() > 0) { | |
| 76 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 77 | + if (array != null) { | |
| 78 | + for (Object obj : array) { | |
| 79 | + JSONObject json = (JSONObject) obj; | |
| 80 | + if (areas.indexOf(json.getString("areaCode")) > -1) { | |
| 81 | + companys.add(json.getString("id")); | |
| 85 | 82 | } |
| 86 | 83 | } |
| 87 | 84 | } |
| 88 | - | |
| 89 | - if (companys.size() > 0) { | |
| 85 | + } | |
| 90 | 86 | |
| 91 | - List<String> ids = new ArrayList<>(); | |
| 92 | - | |
| 93 | - JSONArray jsonArray = RemoteServerUtils.getDriverList(trashConfig.getToken()); | |
| 94 | - | |
| 95 | - for(Object obj:jsonArray){ | |
| 96 | - JSONObject json = (JSONObject) obj; | |
| 97 | - if(companys.indexOf(json.getString("companyId")) > -1){ | |
| 98 | - ids.add(json.getString("id")); | |
| 99 | - System.out.print(json.getString("id") + " "); | |
| 100 | - } | |
| 101 | - } | |
| 102 | - | |
| 103 | - driverCredit.setIds(ids); | |
| 104 | - | |
| 87 | + if (companys.size() > 0) { | |
| 88 | + | |
| 89 | + List<String> ids = new ArrayList<>(); | |
| 90 | + JSONArray jsonArray = redisCache.getCacheObject("driverList"); | |
| 91 | + if(jsonArray == null){ | |
| 92 | + Map map = new HashMap<>(); | |
| 93 | + map.put("size", "99999"); | |
| 94 | + map.put("page", "1"); | |
| 95 | + jsonArray = RemoteServerUtils.getDriverList(trashConfig.getToken(), map); | |
| 105 | 96 | |
| 97 | + if(jsonArray != null){ | |
| 98 | + redisCache.setCacheObject("driverList", jsonArray, 60, TimeUnit.DAYS); | |
| 99 | + } | |
| 106 | 100 | |
| 107 | - list = driverCreditMapper.selectDriverCreditList(driverCredit); | |
| 108 | 101 | } |
| 109 | - | |
| 110 | 102 | |
| 111 | - | |
| 112 | - return list; | |
| 113 | - | |
| 114 | - } | |
| 115 | - | |
| 116 | - /** | |
| 117 | - * 新增驾驶员失信 | |
| 118 | - * | |
| 119 | - * @param driverCredit 驾驶员失信 | |
| 120 | - * @return 结果 | |
| 121 | - */ | |
| 122 | - @Override | |
| 123 | - public int insertDriverCredit(DriverCredit driverCredit) | |
| 124 | - { | |
| 125 | - | |
| 126 | - int i; | |
| 127 | - | |
| 128 | - DriverCredit cc = new DriverCredit(); | |
| 129 | - | |
| 130 | - cc.setStatus(0L); | |
| 131 | - cc.setLostCredit(driverCredit.getLostCredit()); | |
| 132 | - cc.setObjectId(driverCredit.getObjectId()); | |
| 133 | - | |
| 134 | - List old = driverCreditMapper.selectDriverCreditList(cc); | |
| 135 | - | |
| 136 | - if(old.size() > 0){ | |
| 137 | - i = 1; | |
| 138 | - }else{ | |
| 139 | - i = driverCreditMapper.insertDriverCredit(driverCredit); | |
| 140 | - | |
| 141 | - | |
| 142 | - JSONArray array = redisCache.getCacheObject("companyList"); | |
| 143 | - | |
| 144 | - | |
| 145 | - JSONArray drivers = RemoteServerUtils.getDriverList(); | |
| 146 | - String companyId = null; | |
| 147 | - | |
| 148 | - for(Object obj:drivers){ | |
| 149 | - | |
| 150 | - JSONObject json = (JSONObject)obj; | |
| 151 | - if(json.getString("id").equals(driverCredit.getObjectId())){ | |
| 152 | - companyId = json.getString("companyId"); | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + for (Object obj : jsonArray) { | |
| 107 | + JSONObject json = (JSONObject) obj; | |
| 108 | + if (companys.indexOf(json.getString("companyId")) > -1) { | |
| 109 | + ids.add(json.getString("id")); | |
| 110 | + System.out.print(json.getString("id") + " "); | |
| 111 | + } | |
| 153 | 112 | } |
| 113 | + | |
| 114 | + driverCredit.setIds(ids); | |
| 115 | + | |
| 116 | + list = driverCreditMapper.selectDriverCreditList(driverCredit); | |
| 154 | 117 | } |
| 155 | - | |
| 156 | - if(companyId != null){ | |
| 157 | - String number = null; | |
| 158 | - for(Object obj:array){ | |
| 159 | - JSONObject json = (JSONObject)obj; | |
| 160 | - if(companyId.equals(json.getString("id"))){ | |
| 161 | - number = json.getString("principalPhoneNo"); //企业安全负责人 | |
| 162 | - break; | |
| 118 | + | |
| 119 | + return list; | |
| 120 | + | |
| 121 | + } | |
| 122 | + | |
| 123 | + /** | |
| 124 | + * 新增驾驶员失信 | |
| 125 | + * | |
| 126 | + * @param driverCredit | |
| 127 | + * 驾驶员失信 | |
| 128 | + * @return 结果 | |
| 129 | + */ | |
| 130 | + @Override | |
| 131 | + public int insertDriverCredit(DriverCredit driverCredit) { | |
| 132 | + | |
| 133 | + int i; | |
| 134 | + | |
| 135 | + DriverCredit cc = new DriverCredit(); | |
| 136 | + | |
| 137 | + cc.setStatus(0L); | |
| 138 | + cc.setLostCredit(driverCredit.getLostCredit()); | |
| 139 | + cc.setObjectId(driverCredit.getObjectId()); | |
| 140 | + | |
| 141 | + List old = driverCreditMapper.selectDriverCreditList(cc); | |
| 142 | + | |
| 143 | + if (old.size() > 0) { | |
| 144 | + i = 1; | |
| 145 | + } else { | |
| 146 | + i = driverCreditMapper.insertDriverCredit(driverCredit); | |
| 147 | + | |
| 148 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 149 | + | |
| 150 | + JSONArray jsonArray = redisCache.getCacheObject("driverList"); | |
| 151 | + if(jsonArray == null){ | |
| 152 | + Map map = new HashMap<>(); | |
| 153 | + map.put("size", "99999"); | |
| 154 | + map.put("page", "1"); | |
| 155 | + jsonArray = RemoteServerUtils.getDriverList(trashConfig.getToken(), map); | |
| 156 | + | |
| 157 | + if(jsonArray != null){ | |
| 158 | + redisCache.setCacheObject("driverList", jsonArray, 60, TimeUnit.DAYS); | |
| 163 | 159 | } |
| 164 | 160 | } |
| 165 | 161 | |
| 162 | + String companyId = null; | |
| 163 | + | |
| 164 | + for (Object obj : jsonArray) { | |
| 166 | 165 | |
| 167 | - | |
| 168 | - | |
| 169 | - if(number != null){ | |
| 170 | - List<Mobile> mobileList=new ArrayList<Mobile>(); | |
| 171 | - Mobile mobile=new Mobile(); | |
| 172 | - mobile.setMobile(number); | |
| 173 | - mobileList.add(mobile); | |
| 174 | - | |
| 175 | - String smsString = ""; | |
| 176 | - if(driverCredit.getLostCredit() == 1){ | |
| 177 | - smsString = "失信提醒:"+driverCredit.getName()+"因"+driverCredit.getReason()+"原因,被纳入失信名单,将影响渣土业务办理,请及时处理。"; | |
| 178 | - }else{ | |
| 179 | - smsString = "失信解除提醒:"+driverCredit.getName()+"现已解除失信,可以进行渣土业务办理,请知悉。"; | |
| 180 | - } | |
| 181 | - | |
| 182 | - | |
| 183 | - | |
| 184 | - JsonSmsSend jsonSmsSend= PostSms.sendSms(mobileList,smsString); | |
| 185 | - if(jsonSmsSend!=null){ | |
| 186 | - if(jsonSmsSend.getState()==0){ | |
| 187 | - System.out.println("发送成功"); | |
| 188 | - }else{ | |
| 189 | - System.out.println(jsonSmsSend.getMessage()); | |
| 190 | - } | |
| 191 | - }else{ | |
| 192 | - System.out.println("发送返回空"); | |
| 193 | - } | |
| 166 | + JSONObject json = (JSONObject) obj; | |
| 167 | + if (json.getString("id").equals(driverCredit.getObjectId())) { | |
| 168 | + companyId = json.getString("companyId"); | |
| 169 | + break; | |
| 170 | + } | |
| 194 | 171 | } |
| 195 | - } | |
| 196 | - | |
| 197 | - } | |
| 198 | - | |
| 199 | - | |
| 200 | - | |
| 201 | - | |
| 202 | -// sentDataToRemoteServer(driverCredit); | |
| 203 | 172 | |
| 204 | - return i; | |
| 205 | - } | |
| 173 | + if (companyId != null) { | |
| 174 | + String number = null; | |
| 175 | + for (Object obj : array) { | |
| 176 | + JSONObject json = (JSONObject) obj; | |
| 177 | + if (companyId.equals(json.getString("id"))) { | |
| 178 | + number = json.getString("principalPhoneNo"); // 企业安全负责人 | |
| 179 | + break; | |
| 180 | + } | |
| 181 | + } | |
| 206 | 182 | |
| 207 | - private void sentDataToRemoteServer(DriverCredit driverCredit) { | |
| 183 | + if (number != null) { | |
| 184 | + List<Mobile> mobileList = new ArrayList<Mobile>(); | |
| 185 | + Mobile mobile = new Mobile(); | |
| 186 | + mobile.setMobile(number); | |
| 187 | + mobileList.add(mobile); | |
| 188 | + | |
| 189 | + String smsString = ""; | |
| 190 | + if (driverCredit.getLostCredit() == 1) { | |
| 191 | + smsString = "失信提醒:" + driverCredit.getName() + "因" + driverCredit.getReason() | |
| 192 | + + "原因,被纳入失信名单,将影响渣土业务办理,请及时处理。"; | |
| 193 | + } else { | |
| 194 | + smsString = "失信解除提醒:" + driverCredit.getName() + "现已解除失信,可以进行渣土业务办理,请知悉。"; | |
| 195 | + } | |
| 208 | 196 | |
| 209 | - System.out.println("sendData!" + driverCredit.getObjectId() + "status" + driverCredit.getStatus() ); | |
| 197 | + JsonSmsSend jsonSmsSend = PostSms.sendSms(mobileList, smsString); | |
| 198 | + if (jsonSmsSend != null) { | |
| 199 | + if (jsonSmsSend.getState() == 0) { | |
| 200 | + System.out.println("发送成功"); | |
| 201 | + } else { | |
| 202 | + System.out.println(jsonSmsSend.getMessage()); | |
| 203 | + } | |
| 204 | + } else { | |
| 205 | + System.out.println("发送返回空"); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + } | |
| 210 | 209 | |
| 211 | - } | |
| 210 | + } | |
| 212 | 211 | |
| 213 | - /** | |
| 214 | - * 修改驾驶员失信 | |
| 215 | - * | |
| 216 | - * @param driverCredit 驾驶员失信 | |
| 217 | - * @return 结果 | |
| 218 | - */ | |
| 219 | - @Override | |
| 220 | - @Transactional | |
| 221 | - public int updateDriverCredit(DriverCredit driverCredit) | |
| 222 | - { | |
| 223 | - DriverCredit cc = driverCreditMapper.selectDriverCreditById(driverCredit.getId()); | |
| 212 | + // sentDataToRemoteServer(driverCredit); | |
| 224 | 213 | |
| 225 | - cc.setStatus(1L); | |
| 214 | + return i; | |
| 215 | + } | |
| 226 | 216 | |
| 227 | - try { | |
| 228 | - driverCreditMapper.updateDriverCredit(cc); | |
| 217 | + private void sentDataToRemoteServer(DriverCredit driverCredit) { | |
| 229 | 218 | |
| 230 | - cc.setReason(driverCredit.getReason()); | |
| 231 | - cc.setTime(new Date()); | |
| 232 | - cc.setLostCredit(0L); | |
| 219 | + System.out.println("sendData!" + driverCredit.getObjectId() + "status" + driverCredit.getStatus()); | |
| 233 | 220 | |
| 234 | - return insertDriverCredit(cc); | |
| 221 | + } | |
| 235 | 222 | |
| 236 | - } catch (Exception e) { | |
| 223 | + /** | |
| 224 | + * 修改驾驶员失信 | |
| 225 | + * | |
| 226 | + * @param driverCredit | |
| 227 | + * 驾驶员失信 | |
| 228 | + * @return 结果 | |
| 229 | + */ | |
| 230 | + @Override | |
| 231 | + @Transactional | |
| 232 | + public int updateDriverCredit(DriverCredit driverCredit) { | |
| 233 | + DriverCredit cc = driverCreditMapper.selectDriverCreditById(driverCredit.getId()); | |
| 237 | 234 | |
| 238 | - } | |
| 235 | + cc.setStatus(1L); | |
| 239 | 236 | |
| 240 | - return 0; | |
| 241 | - } | |
| 237 | + try { | |
| 238 | + driverCreditMapper.updateDriverCredit(cc); | |
| 242 | 239 | |
| 243 | - @Override | |
| 244 | - public List<DriverCredit> selectDriverCreditHistory(DriverCredit driverCredit) | |
| 245 | - { | |
| 246 | - | |
| 247 | - List<DriverCredit> list = new ArrayList<>(); | |
| 240 | + cc.setReason(driverCredit.getReason()); | |
| 241 | + cc.setTime(new Date()); | |
| 242 | + cc.setLostCredit(0L); | |
| 248 | 243 | |
| 249 | - List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); | |
| 244 | + return insertDriverCredit(cc); | |
| 250 | 245 | |
| 251 | - | |
| 252 | - if (companys.size() > 0) { | |
| 246 | + } catch (Exception e) { | |
| 247 | + e.printStackTrace(); | |
| 248 | + } | |
| 253 | 249 | |
| 254 | - List<String> ids = new ArrayList<>(); | |
| 255 | - | |
| 256 | - JSONArray jsonArray = RemoteServerUtils.getDriverList(trashConfig.getToken()); | |
| 257 | - | |
| 258 | - for(Object obj:jsonArray){ | |
| 259 | - JSONObject json = (JSONObject) obj; | |
| 260 | - if(companys.indexOf(json.getString("companyId")) > -1){ | |
| 261 | - ids.add(json.getString("id")); | |
| 262 | - } | |
| 250 | + return 0; | |
| 251 | + } | |
| 252 | + | |
| 253 | + @Override | |
| 254 | + public List<DriverCredit> selectDriverCreditHistory(DriverCredit driverCredit) { | |
| 255 | + | |
| 256 | + List<DriverCredit> list = new ArrayList<>(); | |
| 257 | + | |
| 258 | + List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); | |
| 259 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 260 | + | |
| 261 | + if (areas.size() > 0) { | |
| 262 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 263 | + if (array != null) { | |
| 264 | + for (Object obj : array) { | |
| 265 | + JSONObject json = (JSONObject) obj; | |
| 266 | + if (areas.indexOf(json.getString("areaCode")) > -1) { | |
| 267 | + companys.add(json.getString("id")); | |
| 263 | 268 | } |
| 269 | + } | |
| 270 | + } | |
| 271 | + } | |
| 272 | + | |
| 273 | + if (companys.size() > 0) { | |
| 274 | + | |
| 275 | + | |
| 276 | + List<String> ids = new ArrayList<>(); | |
| 277 | + | |
| 278 | + JSONArray jsonArray = redisCache.getCacheObject("driverList"); | |
| 279 | + if(jsonArray == null){ | |
| 280 | + Map map = new HashMap<>(); | |
| 281 | + map.put("size", "99999"); | |
| 282 | + map.put("page", "1"); | |
| 283 | + jsonArray = RemoteServerUtils.getDriverList(trashConfig.getToken(), map); | |
| 264 | 284 | |
| 285 | + if(jsonArray != null){ | |
| 286 | + redisCache.setCacheObject("driverList", jsonArray, 60, TimeUnit.DAYS); | |
| 287 | + } | |
| 265 | 288 | |
| 266 | - driverCredit.setIds(ids); | |
| 267 | - | |
| 268 | - | |
| 269 | - | |
| 270 | - list = driverCreditMapper.selectDriverCreditHistory(driverCredit); | |
| 271 | 289 | } |
| 272 | 290 | |
| 273 | - | |
| 274 | - return list; | |
| 275 | - } | |
| 276 | - | |
| 277 | - /** | |
| 278 | - * 批量删除驾驶员失信 | |
| 279 | - * | |
| 280 | - * @param ids 需要删除的驾驶员失信ID | |
| 281 | - * @return 结果 | |
| 282 | - */ | |
| 283 | - @Override | |
| 284 | - public int deleteDriverCreditByIds(Long[] ids) | |
| 285 | - { | |
| 286 | - return driverCreditMapper.deleteDriverCreditByIds(ids); | |
| 287 | - } | |
| 288 | - | |
| 289 | - | |
| 290 | - | |
| 291 | - public List<String> getNames(DriverCredit driverCredit) { | |
| 292 | - | |
| 293 | - return driverCreditMapper.getNames(driverCredit); | |
| 294 | - } | |
| 295 | - | |
| 296 | - /** | |
| 297 | - * 删除驾驶员失信信息 | |
| 298 | - * | |
| 299 | - * @param id 驾驶员失信ID | |
| 300 | - * @return 结果 | |
| 301 | - */ | |
| 302 | - @Override | |
| 303 | - public int deleteDriverCreditById(Long id) | |
| 304 | - { | |
| 305 | - return driverCreditMapper.deleteDriverCreditById(id); | |
| 306 | - } | |
| 291 | + for (Object obj : jsonArray) { | |
| 292 | + JSONObject json = (JSONObject) obj; | |
| 293 | + if (companys.indexOf(json.getString("companyId")) > -1) { | |
| 294 | + ids.add(json.getString("id")); | |
| 295 | + } | |
| 296 | + } | |
| 297 | + | |
| 298 | + driverCredit.setIds(ids); | |
| 299 | + | |
| 300 | + list = driverCreditMapper.selectDriverCreditHistory(driverCredit); | |
| 301 | + } | |
| 302 | + | |
| 303 | + return list; | |
| 304 | + } | |
| 305 | + | |
| 306 | + /** | |
| 307 | + * 批量删除驾驶员失信 | |
| 308 | + * | |
| 309 | + * @param ids | |
| 310 | + * 需要删除的驾驶员失信ID | |
| 311 | + * @return 结果 | |
| 312 | + */ | |
| 313 | + @Override | |
| 314 | + public int deleteDriverCreditByIds(Long[] ids) { | |
| 315 | + return driverCreditMapper.deleteDriverCreditByIds(ids); | |
| 316 | + } | |
| 317 | + | |
| 318 | + public List<String> getNames(DriverCredit driverCredit) { | |
| 319 | + | |
| 320 | + return driverCreditMapper.getNames(driverCredit); | |
| 321 | + } | |
| 322 | + | |
| 323 | + /** | |
| 324 | + * 删除驾驶员失信信息 | |
| 325 | + * | |
| 326 | + * @param id | |
| 327 | + * 驾驶员失信ID | |
| 328 | + * @return 结果 | |
| 329 | + */ | |
| 330 | + @Override | |
| 331 | + public int deleteDriverCreditById(Long id) { | |
| 332 | + return driverCreditMapper.deleteDriverCreditById(id); | |
| 333 | + } | |
| 307 | 334 | } |
| 308 | 335 | \ No newline at end of file | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/SupervisionThreestepServiceImpl.java
| ... | ... | @@ -989,7 +989,8 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 989 | 989 | JSONObject truckObject = (JSONObject) object; |
| 990 | 990 | |
| 991 | 991 | for (TruckActivate ta : taList) { |
| 992 | - | |
| 992 | + | |
| 993 | + | |
| 993 | 994 | if (truckObject.getString("vehicleId").equals(ta.getObjectId())) { |
| 994 | 995 | |
| 995 | 996 | if (truckObject.getInteger("vehicleStatus") == 1) { | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/TruckActivateServiceImpl.java
| ... | ... | @@ -77,9 +77,6 @@ public class TruckActivateServiceImpl implements ITruckActivateService { |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | List<TruckActivate> list = new ArrayList<>(); |
| 80 | - if(1==1){ | |
| 81 | - return truckActivateMapper.selectTruckActivateList(truckActivate); | |
| 82 | - } | |
| 83 | 80 | |
| 84 | 81 | List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); |
| 85 | 82 | List<String> tList = SecurityUtils.getLoginUser().getUser().getTruckList(); | ... | ... |
trash-workFlow/src/main/java/com/trash/casefile/kafka/Consumer.java
| 1 | 1 | package com.trash.casefile.kafka; |
| 2 | 2 | |
| 3 | +import com.alibaba.druid.sql.visitor.functions.If; | |
| 3 | 4 | import com.alibaba.fastjson.JSONArray; |
| 4 | 5 | import com.alibaba.fastjson.JSONObject; |
| 5 | 6 | import com.trash.casefile.domain.KafkaCompensation; |
| ... | ... | @@ -35,408 +36,464 @@ import java.util.concurrent.TimeUnit; |
| 35 | 36 | |
| 36 | 37 | @Component |
| 37 | 38 | public class Consumer { |
| 38 | - private static final Logger log = LoggerFactory.getLogger(Consumer.class); | |
| 39 | - | |
| 40 | - @Autowired | |
| 41 | - private IViolationWarningInformationService violationWarningInformationService; | |
| 42 | - | |
| 43 | - @KafkaListener(topics = "record_process_alarm") | |
| 44 | - public void consume(ConsumerRecord<?, ?> record, Acknowledgment ack) throws InterruptedException, IOException { | |
| 45 | - if(record==null){ | |
| 46 | - throw new RuntimeException("kafka record对象为空"); | |
| 47 | - } | |
| 48 | - if(record.value()==null){ | |
| 49 | - throw new RuntimeException("kafka消费数据为空"); | |
| 50 | - } | |
| 51 | - if(ack==null){ | |
| 52 | - throw new RuntimeException("kafka ack对象为空"); | |
| 53 | - } | |
| 54 | - log.info("kafka消费数据成功,offset:"+ record.offset() +",data:" + record.value()); | |
| 55 | - String id = insertKafkaCompensation(record.value().toString()); | |
| 56 | - autoViolationWarning(record.value().toString(),id); | |
| 57 | - //手动提交offset | |
| 58 | - ack.acknowledge(); | |
| 59 | - } | |
| 60 | - | |
| 61 | - @Autowired | |
| 62 | - trashConfig trashConfig; | |
| 63 | - | |
| 64 | - @Autowired | |
| 65 | - SysLoginService loginService; | |
| 66 | - | |
| 67 | - @Autowired | |
| 68 | - RedisCache redisCache; | |
| 69 | - | |
| 70 | - public void autoViolationWarning(String data,String id) throws InterruptedException, IOException { | |
| 71 | - | |
| 72 | - JSONObject jsonObject = JSONObject.parseObject(data); | |
| 73 | - //报警时间 | |
| 74 | - Date alarmTime = new Date(jsonObject.getLong("alarmTime")*1000L); | |
| 75 | - | |
| 76 | - //这一块是一天内同一工地,同一类型的报警,只报有一条数据,不重复报工,只累加 | |
| 77 | - String nowHour = DateFormatUtils.format(alarmTime, "HH"); | |
| 78 | - String nowDate = null; | |
| 79 | - String tomorrowDate = null; | |
| 80 | - if(Integer.valueOf(nowHour)<8){ | |
| 81 | - nowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, -1), "yyyy-MM-dd"); | |
| 82 | - tomorrowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 83 | - }else{ | |
| 84 | - nowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 85 | - tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); | |
| 86 | - } | |
| 87 | - | |
| 88 | - //违规类型code | |
| 89 | - String violationTypeCode = jsonObject.getString("alarmType"); | |
| 90 | - //违规类型 | |
| 91 | - String violationType = jsonObject.getString("alarmName"); | |
| 92 | - if(RemoteServerUtils.remote==null){ | |
| 93 | - //登录 | |
| 94 | - RemoteServerUtils.remote = trashConfig.getRemotePath(); | |
| 95 | - loginService.loginByRemote(trashConfig.getToken()); | |
| 96 | - } | |
| 97 | - ViolationWarningInformation violationWarningInformation1 = null; | |
| 98 | - JSONArray company1 = null; | |
| 99 | - JSONObject basevehicleInfo = null; | |
| 100 | - //这些类型无需累加 | |
| 101 | - if(violationTypeCode.equals("44030021") || violationTypeCode.equals("44030025")||violationTypeCode.equals("44030023")){ | |
| 102 | - violationWarningInformation1 = null; | |
| 103 | - }else if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){//这两种类型根据公司累加 | |
| 104 | - company1 = redisCache.getCacheObject("companyList"); | |
| 105 | - basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"),trashConfig.getToken()); | |
| 106 | - if(company1==null){ | |
| 107 | - throw new RuntimeException("获取公司列表失败!!!"); | |
| 108 | - } | |
| 109 | - | |
| 110 | - if(basevehicleInfo==null){ | |
| 111 | - throw new RuntimeException("获取公司详情失败!vehicleId:"+jsonObject.getString("vehicleId")); | |
| 112 | - } | |
| 113 | - }else{//其他都是根据工地/消纳站累加 | |
| 114 | - String project = jsonObject.getString("siteName"); | |
| 115 | - violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(null,project, violationTypeCode, nowDate, tomorrowDate); | |
| 116 | - } | |
| 117 | - String siteName = jsonObject.getString("siteName"); | |
| 118 | - //判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增 | |
| 119 | - if (violationWarningInformation1 == null) { | |
| 120 | - ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation(); | |
| 121 | - String siteType = jsonObject.getString("siteType"); | |
| 122 | - if ("2".equals(siteType)) {//消纳场 | |
| 123 | - violationWarningInformation.setViolationObjectType("1"); | |
| 124 | - } | |
| 125 | - //所属区域 | |
| 126 | - violationWarningInformation.setOwningRegion(jsonObject.getString("areaName")); | |
| 127 | - //案卷编码 | |
| 128 | - String number = DateFormatUtils.format(alarmTime, "yyyyMMddHHmmssSSS"); | |
| 129 | - violationWarningInformation.setNumber(number.substring(2)); | |
| 130 | - //公司名称 | |
| 131 | - violationWarningInformation.setCompanyName(jsonObject.getString("enterpriseName")); | |
| 132 | - //违规类型 | |
| 133 | - violationWarningInformation.setViolationType(violationTypeCode); | |
| 134 | - //发送人 | |
| 135 | - violationWarningInformation.setCreateBy("长沙市建筑垃圾智慧监管平台"); | |
| 136 | - //推送对象 | |
| 137 | - violationWarningInformation.setViolationGrade("一般类"); | |
| 138 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 139 | - String describe = ""; | |
| 140 | - String alarmTimeString = DateFormatUtils.format(alarmTime,"HH:mm"); | |
| 141 | - //根据不同违规类型,走不同流程 | |
| 142 | - switch (violationTypeCode) { | |
| 143 | - case "44030020"://工地预警-未报开工作业 | |
| 144 | - //获取报警次数 | |
| 145 | - int count44030020 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020").toString())+1; | |
| 146 | - //获取累计报警描述 | |
| 147 | - String describe44030020 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe").toString(); | |
| 148 | - if(!StringUtils.isEmpty(describe44030020)){ | |
| 149 | - describe44030020 = describe44030020 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 150 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 151 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 152 | - }else{ | |
| 153 | - describe44030020 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 154 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 155 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 156 | - } | |
| 157 | - //报警次数等于5推送案卷 | |
| 158 | - if(count44030020==5){ | |
| 159 | - violationWarningInformation.setViolationObjectType("0"); | |
| 160 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 161 | - violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 162 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 163 | - violationWarningInformation.setDescribe(describe44030020); | |
| 164 | - // 业务逻辑 | |
| 165 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 166 | - } | |
| 167 | - //次数+1 | |
| 168 | - redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020",count44030020,24, TimeUnit.HOURS); | |
| 169 | - //累计描述 | |
| 170 | - redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe",describe44030020,24, TimeUnit.HOURS); | |
| 171 | - break; | |
| 172 | - case "44030023"://工地预警-未按时间作业 | |
| 173 | - try{ | |
| 174 | - //获取工地信息 | |
| 175 | - JSONObject object = RemoteServerUtils.getConstructionLicenseById(jsonObject.getString("siteId"), trashConfig.getToken()); | |
| 176 | - String transportEndTime = object.getString("transportEndTime"); | |
| 177 | - String transportStartTime = object.getString("transportStartTime"); | |
| 178 | - String endTime = manipulateTime(transportEndTime,30); | |
| 179 | - String startTime = manipulateTime(transportStartTime,-30); | |
| 180 | - //获取结束运输报警次数 | |
| 181 | - String countKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportEndTime; | |
| 182 | - int count44030023 = redisCache.getCacheObject(countKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countKey).toString())+1; | |
| 183 | - //获取结束运输累计报警描述 | |
| 184 | - String describeKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportEndTime; | |
| 185 | - String describe44030023 = redisCache.getCacheObject(describeKey)==null?"":redisCache.getCacheObject(describeKey).toString(); | |
| 186 | - //获取结束运输报警次数 | |
| 187 | - String countEKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportStartTime; | |
| 188 | - int countE = redisCache.getCacheObject(countEKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countEKey).toString())+1; | |
| 189 | - //获取结束运输累计报警描述 | |
| 190 | - String describeEKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportStartTime; | |
| 191 | - String describeE = redisCache.getCacheObject(describeEKey)==null?"":redisCache.getCacheObject(describeEKey).toString(); | |
| 192 | - | |
| 193 | - if(!StringUtils.isEmpty(describe44030023)){ | |
| 194 | - describe44030023 = describe44030023 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 195 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 196 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 197 | - }else{ | |
| 198 | - describe44030023 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 199 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 200 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 201 | - } | |
| 202 | - //报警次数等于5推送案卷 | |
| 203 | - if(count44030023==5&&isTimeWithinRange(alarmTimeString,transportEndTime,endTime)){ | |
| 204 | - violationWarningInformation.setViolationObjectType("0"); | |
| 205 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 206 | - violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 207 | - | |
| 208 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 209 | - violationWarningInformation.setDescribe(describe44030023); | |
| 210 | - // 业务逻辑 | |
| 211 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 212 | - } | |
| 213 | - | |
| 214 | - if(!StringUtils.isEmpty(describeE)){ | |
| 215 | - describeE = describeE + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 216 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 217 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 218 | - }else{ | |
| 219 | - describeE = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 220 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 221 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 222 | - } | |
| 223 | - //报警次数等于5推送案卷 | |
| 224 | - if(countE==5&&isTimeWithinRange(alarmTimeString,startTime,transportStartTime)){ | |
| 225 | - violationWarningInformation.setViolationObjectType("0"); | |
| 226 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 227 | - violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 228 | - | |
| 229 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 230 | - violationWarningInformation.setDescribe(describeE); | |
| 231 | - // 业务逻辑 | |
| 232 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 233 | - } | |
| 234 | - | |
| 235 | - | |
| 236 | - //判断结束运输 | |
| 237 | - if(isTimeWithinRange(alarmTimeString,transportEndTime,endTime)){ | |
| 238 | - //次数+1 | |
| 239 | - redisCache.setCacheObject(countKey,count44030023,1, TimeUnit.HOURS); | |
| 240 | - //累计描述 | |
| 241 | - redisCache.setCacheObject(describeKey,describe44030023,1, TimeUnit.HOURS); | |
| 242 | - }else if(isTimeWithinRange(alarmTimeString,startTime,transportStartTime)){ | |
| 243 | - //次数+1 | |
| 244 | - redisCache.setCacheObject(countEKey,countE,1, TimeUnit.HOURS); | |
| 245 | - //累计描述 | |
| 246 | - redisCache.setCacheObject(describeEKey,describeE,1, TimeUnit.HOURS); | |
| 247 | - } | |
| 248 | - }catch (NullPointerException e){ | |
| 249 | - throw e; | |
| 250 | - } | |
| 251 | - break; | |
| 252 | - | |
| 253 | - case "44030030"://未激活车辆作业 | |
| 254 | - case "44030031"://未核准作业车辆作业 | |
| 255 | - case "44030022"://工地预警-三无车辆进入工地 | |
| 256 | - case "44030021"://工地预警-视频设备离线超时报警 | |
| 257 | - case "44030028"://离线运输报警(工) | |
| 258 | - | |
| 259 | - violationWarningInformation.setViolationObjectType("0"); | |
| 260 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 261 | - violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 262 | - describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 263 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 264 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 265 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 266 | - violationWarningInformation.setDescribe(describe); | |
| 267 | - // 业务逻辑 | |
| 268 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 269 | - break; | |
| 270 | - | |
| 271 | - case "44030024"://处理场所预警-未报开工作业 | |
| 272 | - //获取报警次数 | |
| 273 | - int count44030024 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024").toString())+1; | |
| 274 | - //获取累计报警描述 | |
| 275 | - String describe44030024 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe").toString(); | |
| 276 | - if(!StringUtils.isEmpty(describe44030024)){ | |
| 277 | - describe44030024 = describe44030024 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 278 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 279 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 280 | - }else{ | |
| 281 | - describe44030024 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 282 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 283 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 284 | - } | |
| 285 | - //报警次数等于5推送案卷 | |
| 286 | - if(count44030024==5){ | |
| 287 | - violationWarningInformation.setViolationObjectType("1"); | |
| 288 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 289 | - violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 290 | - | |
| 291 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 292 | - violationWarningInformation.setDescribe(describe44030024); | |
| 293 | - // 业务逻辑 | |
| 294 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 295 | - } | |
| 296 | - | |
| 297 | - | |
| 298 | - //次数+1 | |
| 299 | - redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024",count44030024,24, TimeUnit.HOURS); | |
| 300 | - //累计描述 | |
| 301 | - redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe",describe44030024,24, TimeUnit.HOURS); | |
| 302 | - break; | |
| 303 | - case "44030027"://处理场所预警-未到指定的处理场所作业 | |
| 304 | - case "44030026"://处理场所预警-三无车辆进入处理场所 | |
| 305 | - case "44030029"://离线运输报警(消) | |
| 306 | - case "44030025"://处理场所预警-视频设备离线超时报警 | |
| 307 | - violationWarningInformation.setViolationObjectType("1"); | |
| 308 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 309 | - violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 310 | - describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 311 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 312 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 313 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 314 | - violationWarningInformation.setDescribe(describe); | |
| 315 | - // 业务逻辑 | |
| 316 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 317 | - break; | |
| 318 | - case "44030032"://未按线路行驶 | |
| 319 | - violationWarningInformation.setViolationObjectType("0"); | |
| 320 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 321 | - violationWarningInformation.setProjectName(siteName); | |
| 322 | - describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 323 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 324 | - jsonObject.get("siteName") + "出现" + violationType; | |
| 325 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 326 | - violationWarningInformation.setDescribe(describe); | |
| 327 | - // 业务逻辑 | |
| 328 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 329 | - break; | |
| 330 | - case "44030033"://闯禁行驶 | |
| 331 | - violationWarningInformation.setViolationObjectType("0"); | |
| 332 | - violationWarningInformation.setSendObject("区管理部门"); | |
| 333 | - violationWarningInformation.setProjectName(siteName); | |
| 334 | - describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 335 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationType; | |
| 336 | - //设置公司简称 | |
| 337 | - for(Object o:company1){ | |
| 338 | - JSONObject jo = (JSONObject) o; | |
| 339 | - if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){ | |
| 340 | - violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 341 | - } | |
| 342 | - } | |
| 343 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 344 | - violationWarningInformation.setDescribe(describe); | |
| 345 | - // 业务逻辑 | |
| 346 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 347 | - break; | |
| 348 | - | |
| 349 | - case "44030034"://失信车辆作业 | |
| 350 | - case "44030035"://卫星 | |
| 351 | - violationWarningInformation.setProjectName(siteName); | |
| 352 | - violationWarningInformation.setViolationObjectType("2"); | |
| 353 | - violationWarningInformation.setSendObject("运输企业"); | |
| 354 | - describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 355 | - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationType; | |
| 356 | - //设置公司简称 | |
| 357 | - for(Object o:company1){ | |
| 358 | - JSONObject jo = (JSONObject) o; | |
| 359 | - if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){ | |
| 360 | - violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 361 | - } | |
| 362 | - } | |
| 363 | - violationWarningInformation.setCreateTime(alarmTime); | |
| 364 | - violationWarningInformation.setDescribe(describe); | |
| 365 | - // 业务逻辑 | |
| 366 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 367 | - break; | |
| 368 | - } | |
| 369 | - | |
| 370 | - | |
| 371 | - | |
| 372 | - | |
| 373 | - } else { | |
| 374 | - String describe = ""; | |
| 375 | - if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){ | |
| 376 | - describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 377 | - + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName"); | |
| 378 | - }else{ | |
| 379 | - describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 380 | - + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 381 | - jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName"); | |
| 382 | - } | |
| 383 | - | |
| 384 | - violationWarningInformation1.setDescribe(describe); | |
| 385 | - SpringUtils.getBean(ViolationWarningInformationMapper.class).updateViolationWarningInformation(violationWarningInformation1); | |
| 386 | - } | |
| 387 | - //kafka消费成功 | |
| 388 | - KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 389 | - kafkaCompensation.setId(Long.valueOf(id)); | |
| 390 | - kafkaCompensation.setStatus(1); | |
| 391 | - SpringUtils.getBean(KafkaCompensationMapper.class).updateKafkaCompensation(kafkaCompensation); | |
| 392 | - | |
| 393 | - } | |
| 394 | - | |
| 395 | - public String insertKafkaCompensation(String data){ | |
| 396 | - KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 397 | - kafkaCompensation.setData(data); | |
| 398 | - kafkaCompensation.setCreateTime(DateUtils.getNowDate()); | |
| 399 | - kafkaCompensation.setStatus(0); | |
| 400 | - SpringUtils.getBean(KafkaCompensationMapper.class).insertKafkaCompensation(kafkaCompensation); | |
| 401 | - return kafkaCompensation.getId().toString(); | |
| 402 | - } | |
| 403 | - | |
| 404 | - /** | |
| 405 | - * 对HH:mm格式时间进行分钟的加减 | |
| 406 | - * @param timeStr | |
| 407 | - * @param minutesToAddOrSubtract | |
| 408 | - * @return | |
| 409 | - */ | |
| 410 | - public String manipulateTime(String timeStr, int minutesToAddOrSubtract) { | |
| 411 | - // 定义输入时间格式的日期时间格式器 | |
| 412 | - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 413 | - | |
| 414 | - // 解析输入的时间字符串为 LocalTime 对象 | |
| 415 | - LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 416 | - | |
| 417 | - // 执行加减分钟的操作 | |
| 418 | - LocalTime modifiedTime = time.plusMinutes(minutesToAddOrSubtract); | |
| 419 | - | |
| 420 | - // 将修改后的时间格式化为 HH:mm 格式 | |
| 421 | - String formattedModifiedTime = modifiedTime.format(formatter); | |
| 422 | - | |
| 423 | - return formattedModifiedTime; | |
| 424 | - } | |
| 425 | - | |
| 426 | - /** | |
| 427 | - * 判断timeStr是否在startTimeStr-endTimeStr区间 | |
| 428 | - * @param timeStr | |
| 429 | - * @param startTimeStr | |
| 430 | - * @param endTimeStr | |
| 431 | - * @return | |
| 432 | - */ | |
| 433 | - public boolean isTimeWithinRange(String timeStr, String startTimeStr, String endTimeStr) { | |
| 434 | - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 435 | - LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 436 | - LocalTime startTime = LocalTime.parse(startTimeStr, formatter); | |
| 437 | - LocalTime endTime = LocalTime.parse(endTimeStr, formatter); | |
| 438 | - | |
| 439 | - return !time.isBefore(startTime) && !time.isAfter(endTime); | |
| 440 | - | |
| 441 | - } | |
| 39 | + private static final Logger log = LoggerFactory.getLogger(Consumer.class); | |
| 40 | + | |
| 41 | + @Autowired | |
| 42 | + private IViolationWarningInformationService violationWarningInformationService; | |
| 43 | + | |
| 44 | + @KafkaListener(topics = "record_process_alarm") | |
| 45 | + public void consume(ConsumerRecord<?, ?> record, Acknowledgment ack) throws InterruptedException, IOException { | |
| 46 | + if (record == null) { | |
| 47 | + throw new RuntimeException("kafka record对象为空"); | |
| 48 | + } | |
| 49 | + if (record.value() == null) { | |
| 50 | + throw new RuntimeException("kafka消费数据为空"); | |
| 51 | + } | |
| 52 | + if (ack == null) { | |
| 53 | + throw new RuntimeException("kafka ack对象为空"); | |
| 54 | + } | |
| 55 | + log.info("kafka消费数据成功,offset:" + record.offset() + ",data:" + record.value()); | |
| 56 | + String id = insertKafkaCompensation(record.value().toString()); | |
| 57 | + autoViolationWarning(record.value().toString(), id); | |
| 58 | + // 手动提交offset | |
| 59 | + ack.acknowledge(); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @Autowired | |
| 63 | + trashConfig trashConfig; | |
| 64 | + | |
| 65 | + @Autowired | |
| 66 | + SysLoginService loginService; | |
| 67 | + | |
| 68 | + @Autowired | |
| 69 | + RedisCache redisCache; | |
| 70 | + | |
| 71 | + Map<String, Long> cMap = new HashMap<String, Long>(); | |
| 72 | + | |
| 73 | + JSONArray company1 = null; | |
| 74 | + | |
| 75 | + public void autoViolationWarning(String data, String id) throws InterruptedException, IOException { | |
| 76 | + | |
| 77 | + JSONObject jsonObject = JSONObject.parseObject(data); | |
| 78 | + // 报警时间 | |
| 79 | + Date alarmTime = new Date(jsonObject.getLong("alarmTime") * 1000L); | |
| 80 | + | |
| 81 | + // 这一块是一天内同一工地,同一类型的报警,只报有一条数据,不重复报工,只累加 | |
| 82 | + String nowHour = DateFormatUtils.format(alarmTime, "HH"); | |
| 83 | + String nowDate = null; | |
| 84 | + String tomorrowDate = null; | |
| 85 | + if (Integer.valueOf(nowHour) < 8) { | |
| 86 | + nowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, -1), "yyyy-MM-dd"); | |
| 87 | + tomorrowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 88 | + } else { | |
| 89 | + nowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 90 | + tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); | |
| 91 | + } | |
| 92 | + | |
| 93 | + // 违规类型code | |
| 94 | + String violationTypeCode = jsonObject.getString("alarmType"); | |
| 95 | + // 违规类型 | |
| 96 | + String violationType = jsonObject.getString("alarmName"); | |
| 97 | + if (RemoteServerUtils.remote == null) { | |
| 98 | + // 登录 | |
| 99 | + RemoteServerUtils.remote = trashConfig.getRemotePath(); | |
| 100 | + loginService.loginByRemote(trashConfig.getToken()); | |
| 101 | + } | |
| 102 | + ViolationWarningInformation violationWarningInformation1 = null; | |
| 103 | + JSONObject basevehicleInfo = null; | |
| 104 | + // 这些类型无需累加 | |
| 105 | + if (violationTypeCode.equals("44030021") || violationTypeCode.equals("44030025") | |
| 106 | + || violationTypeCode.equals("44030023")) { | |
| 107 | + violationWarningInformation1 = null; | |
| 108 | + } else if (violationTypeCode.equals("44030033") || violationTypeCode.equals("44030034") | |
| 109 | + || violationTypeCode.equals("44030035")) {// 这两种类型根据公司累加 | |
| 110 | + | |
| 111 | + if (company1 == null || cMap.get("companyTime")==null || (new Date().getTime() - cMap.get("companyTime")) > 1000 * 60 * 60) { | |
| 112 | + company1 = redisCache.getCacheObject("companyList"); | |
| 113 | + cMap.put("companyTime", new Date().getTime()); | |
| 114 | + } | |
| 115 | + basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"), | |
| 116 | + trashConfig.getToken()); | |
| 117 | + if (company1 == null) { | |
| 118 | + throw new RuntimeException("获取公司列表失败!!!"); | |
| 119 | + } | |
| 120 | + | |
| 121 | + if (basevehicleInfo == null) { | |
| 122 | + throw new RuntimeException("获取公司详情失败!vehicleId:" + jsonObject.getString("vehicleId")); | |
| 123 | + } | |
| 124 | + } else {// 其他都是根据工地/消纳站累加 | |
| 125 | + String project = jsonObject.getString("siteName"); | |
| 126 | + violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class) | |
| 127 | + .selectViolationWarningInformation(null, project, violationTypeCode, nowDate, tomorrowDate); | |
| 128 | + } | |
| 129 | + String siteName = jsonObject.getString("siteName"); | |
| 130 | + // 判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增 | |
| 131 | + if (violationWarningInformation1 == null) { | |
| 132 | + ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation(); | |
| 133 | + String siteType = jsonObject.getString("siteType"); | |
| 134 | + if ("2".equals(siteType)) {// 消纳场 | |
| 135 | + violationWarningInformation.setViolationObjectType("1"); | |
| 136 | + } | |
| 137 | + // 所属区域 | |
| 138 | + violationWarningInformation.setOwningRegion(jsonObject.getString("areaName")); | |
| 139 | + // 案卷编码 | |
| 140 | + String number = DateFormatUtils.format(alarmTime, "yyyyMMddHHmmssSSS"); | |
| 141 | + violationWarningInformation.setNumber(number.substring(2)); | |
| 142 | + // 公司名称 | |
| 143 | + violationWarningInformation.setCompanyName(jsonObject.getString("enterpriseName")); | |
| 144 | + // 违规类型 | |
| 145 | + violationWarningInformation.setViolationType(violationTypeCode); | |
| 146 | + // 发送人 | |
| 147 | + violationWarningInformation.setCreateBy("长沙市建筑垃圾智慧监管平台"); | |
| 148 | + // 推送对象 | |
| 149 | + violationWarningInformation.setViolationGrade("一般类"); | |
| 150 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 151 | + String describe = ""; | |
| 152 | + String alarmTimeString = DateFormatUtils.format(alarmTime, "HH:mm"); | |
| 153 | + // 根据不同违规类型,走不同流程 | |
| 154 | + switch (violationTypeCode) { | |
| 155 | + case "44030020":// 工地预警-未报开工作业 | |
| 156 | + // 获取报警次数 | |
| 157 | + int count44030020 = redisCache | |
| 158 | + .getCacheObject(nowDate + jsonObject.getString("siteId") + "44030020") == null | |
| 159 | + ? 1 | |
| 160 | + : Integer.parseInt( | |
| 161 | + redisCache.getCacheObject(nowDate + jsonObject.getString("siteId") + "44030020") | |
| 162 | + .toString()) | |
| 163 | + + 1; | |
| 164 | + // 获取累计报警描述 | |
| 165 | + String describe44030020 = redisCache | |
| 166 | + .getCacheObject(nowDate + jsonObject.getString("siteId") + "44030020describe") == null | |
| 167 | + ? "" | |
| 168 | + : redisCache | |
| 169 | + .getCacheObject(nowDate + jsonObject.getString("siteId") + "44030020describe") | |
| 170 | + .toString(); | |
| 171 | + if (!StringUtils.isEmpty(describe44030020)) { | |
| 172 | + describe44030020 = describe44030020 + ";\n" | |
| 173 | + + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 174 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 175 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 176 | + } else { | |
| 177 | + describe44030020 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 178 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 179 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 180 | + } | |
| 181 | + // 报警次数等于5推送案卷 | |
| 182 | + if (count44030020 == 5) { | |
| 183 | + violationWarningInformation.setViolationObjectType("0"); | |
| 184 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 185 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 186 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 187 | + violationWarningInformation.setDescribe(describe44030020); | |
| 188 | + // 业务逻辑 | |
| 189 | + violationWarningInformationService.insertViolationWarningInformation(null, | |
| 190 | + violationWarningInformation); | |
| 191 | + } | |
| 192 | + // 次数+1 | |
| 193 | + redisCache.setCacheObject(nowDate + jsonObject.getString("siteId") + "44030020", count44030020, 24, | |
| 194 | + TimeUnit.HOURS); | |
| 195 | + // 累计描述 | |
| 196 | + redisCache.setCacheObject(nowDate + jsonObject.getString("siteId") + "44030020describe", | |
| 197 | + describe44030020, 24, TimeUnit.HOURS); | |
| 198 | + break; | |
| 199 | + case "44030023":// 工地预警-未按时间作业 | |
| 200 | + try { | |
| 201 | + // 获取工地信息 | |
| 202 | + JSONObject object = RemoteServerUtils.getConstructionLicenseById(jsonObject.getString("siteId"), | |
| 203 | + trashConfig.getToken()); | |
| 204 | + String transportEndTime = object.getString("transportEndTime"); | |
| 205 | + String transportStartTime = object.getString("transportStartTime"); | |
| 206 | + String endTime = manipulateTime(transportEndTime, 30); | |
| 207 | + String startTime = manipulateTime(transportStartTime, -30); | |
| 208 | + // 获取结束运输报警次数 | |
| 209 | + String countKey = nowDate + jsonObject.getString("siteId") + "44030023" + transportEndTime; | |
| 210 | + int count44030023 = redisCache.getCacheObject(countKey) == null ? 1 | |
| 211 | + : Integer.parseInt(redisCache.getCacheObject(countKey).toString()) + 1; | |
| 212 | + // 获取结束运输累计报警描述 | |
| 213 | + String describeKey = nowDate + jsonObject.getString("siteId") + "44030023describe" | |
| 214 | + + transportEndTime; | |
| 215 | + String describe44030023 = redisCache.getCacheObject(describeKey) == null ? "" | |
| 216 | + : redisCache.getCacheObject(describeKey).toString(); | |
| 217 | + // 获取结束运输报警次数 | |
| 218 | + String countEKey = nowDate + jsonObject.getString("siteId") + "44030023" + transportStartTime; | |
| 219 | + int countE = redisCache.getCacheObject(countEKey) == null ? 1 | |
| 220 | + : Integer.parseInt(redisCache.getCacheObject(countEKey).toString()) + 1; | |
| 221 | + // 获取结束运输累计报警描述 | |
| 222 | + String describeEKey = nowDate + jsonObject.getString("siteId") + "44030023describe" | |
| 223 | + + transportStartTime; | |
| 224 | + String describeE = redisCache.getCacheObject(describeEKey) == null ? "" | |
| 225 | + : redisCache.getCacheObject(describeEKey).toString(); | |
| 226 | + | |
| 227 | + if (!StringUtils.isEmpty(describe44030023)) { | |
| 228 | + describe44030023 = describe44030023 + ";\n" | |
| 229 | + + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 230 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 231 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 232 | + } else { | |
| 233 | + describe44030023 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 234 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 235 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 236 | + } | |
| 237 | + // 报警次数等于5推送案卷 | |
| 238 | + if (count44030023 == 5 && isTimeWithinRange(alarmTimeString, transportEndTime, endTime)) { | |
| 239 | + violationWarningInformation.setViolationObjectType("0"); | |
| 240 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 241 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 242 | + | |
| 243 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 244 | + violationWarningInformation.setDescribe(describe44030023); | |
| 245 | + // 业务逻辑 | |
| 246 | + violationWarningInformationService.insertViolationWarningInformation(null, | |
| 247 | + violationWarningInformation); | |
| 248 | + } | |
| 249 | + | |
| 250 | + if (!StringUtils.isEmpty(describeE)) { | |
| 251 | + describeE = describeE + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 252 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 253 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 254 | + } else { | |
| 255 | + describeE = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 256 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 257 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 258 | + } | |
| 259 | + // 报警次数等于5推送案卷 | |
| 260 | + if (countE == 5 && isTimeWithinRange(alarmTimeString, startTime, transportStartTime)) { | |
| 261 | + violationWarningInformation.setViolationObjectType("0"); | |
| 262 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 263 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 264 | + | |
| 265 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 266 | + violationWarningInformation.setDescribe(describeE); | |
| 267 | + // 业务逻辑 | |
| 268 | + violationWarningInformationService.insertViolationWarningInformation(null, | |
| 269 | + violationWarningInformation); | |
| 270 | + } | |
| 271 | + | |
| 272 | + // 判断结束运输 | |
| 273 | + if (isTimeWithinRange(alarmTimeString, transportEndTime, endTime)) { | |
| 274 | + // 次数+1 | |
| 275 | + redisCache.setCacheObject(countKey, count44030023, 1, TimeUnit.HOURS); | |
| 276 | + // 累计描述 | |
| 277 | + redisCache.setCacheObject(describeKey, describe44030023, 1, TimeUnit.HOURS); | |
| 278 | + } else if (isTimeWithinRange(alarmTimeString, startTime, transportStartTime)) { | |
| 279 | + // 次数+1 | |
| 280 | + redisCache.setCacheObject(countEKey, countE, 1, TimeUnit.HOURS); | |
| 281 | + // 累计描述 | |
| 282 | + redisCache.setCacheObject(describeEKey, describeE, 1, TimeUnit.HOURS); | |
| 283 | + } | |
| 284 | + } catch (NullPointerException e) { | |
| 285 | + throw e; | |
| 286 | + } | |
| 287 | + break; | |
| 288 | + | |
| 289 | + case "44030030":// 未激活车辆作业 | |
| 290 | + case "44030031":// 未核准作业车辆作业 | |
| 291 | + case "44030022":// 工地预警-三无车辆进入工地 | |
| 292 | + case "44030021":// 工地预警-视频设备离线超时报警 | |
| 293 | + case "44030028":// 离线运输报警(工) | |
| 294 | + | |
| 295 | + violationWarningInformation.setViolationObjectType("0"); | |
| 296 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 297 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 298 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 299 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" | |
| 300 | + + jsonObject.get("siteName") + "出现" + violationType; | |
| 301 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 302 | + violationWarningInformation.setDescribe(describe); | |
| 303 | + // 业务逻辑 | |
| 304 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 305 | + break; | |
| 306 | + | |
| 307 | + case "44030024":// 处理场所预警-未报开工作业 | |
| 308 | + // 获取报警次数 | |
| 309 | + int count44030024 = redisCache | |
| 310 | + .getCacheObject(nowDate + jsonObject.getString("siteId") + "44030024") == null | |
| 311 | + ? 1 | |
| 312 | + : Integer.parseInt( | |
| 313 | + redisCache.getCacheObject(nowDate + jsonObject.getString("siteId") + "44030024") | |
| 314 | + .toString()) | |
| 315 | + + 1; | |
| 316 | + // 获取累计报警描述 | |
| 317 | + String describe44030024 = redisCache | |
| 318 | + .getCacheObject(nowDate + jsonObject.getString("siteId") + "44030024describe") == null | |
| 319 | + ? "" | |
| 320 | + : redisCache | |
| 321 | + .getCacheObject(nowDate + jsonObject.getString("siteId") + "44030024describe") | |
| 322 | + .toString(); | |
| 323 | + if (!StringUtils.isEmpty(describe44030024)) { | |
| 324 | + describe44030024 = describe44030024 + ";\n" | |
| 325 | + + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 326 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 327 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 328 | + } else { | |
| 329 | + describe44030024 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 330 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") | |
| 331 | + + "在" + jsonObject.get("siteName") + "出现" + violationType; | |
| 332 | + } | |
| 333 | + // 报警次数等于5推送案卷 | |
| 334 | + if (count44030024 == 5) { | |
| 335 | + violationWarningInformation.setViolationObjectType("1"); | |
| 336 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 337 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 338 | + | |
| 339 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 340 | + violationWarningInformation.setDescribe(describe44030024); | |
| 341 | + // 业务逻辑 | |
| 342 | + violationWarningInformationService.insertViolationWarningInformation(null, | |
| 343 | + violationWarningInformation); | |
| 344 | + } | |
| 345 | + | |
| 346 | + // 次数+1 | |
| 347 | + redisCache.setCacheObject(nowDate + jsonObject.getString("siteId") + "44030024", count44030024, 24, | |
| 348 | + TimeUnit.HOURS); | |
| 349 | + // 累计描述 | |
| 350 | + redisCache.setCacheObject(nowDate + jsonObject.getString("siteId") + "44030024describe", | |
| 351 | + describe44030024, 24, TimeUnit.HOURS); | |
| 352 | + break; | |
| 353 | + case "44030027":// 处理场所预警-未到指定的处理场所作业 | |
| 354 | + case "44030026":// 处理场所预警-三无车辆进入处理场所 | |
| 355 | + case "44030029":// 离线运输报警(消) | |
| 356 | + case "44030025":// 处理场所预警-视频设备离线超时报警 | |
| 357 | + violationWarningInformation.setViolationObjectType("1"); | |
| 358 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 359 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 360 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 361 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" | |
| 362 | + + jsonObject.get("siteName") + "出现" + violationType; | |
| 363 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 364 | + violationWarningInformation.setDescribe(describe); | |
| 365 | + // 业务逻辑 | |
| 366 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 367 | + break; | |
| 368 | + case "44030032":// 未按线路行驶 | |
| 369 | + violationWarningInformation.setViolationObjectType("0"); | |
| 370 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 371 | + violationWarningInformation.setProjectName(siteName); | |
| 372 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 373 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" | |
| 374 | + + jsonObject.get("siteName") + "出现" + violationType; | |
| 375 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 376 | + violationWarningInformation.setDescribe(describe); | |
| 377 | + // 业务逻辑 | |
| 378 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 379 | + break; | |
| 380 | + case "44030033":// 闯禁行驶 | |
| 381 | + violationWarningInformation.setViolationObjectType("0"); | |
| 382 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 383 | + violationWarningInformation.setProjectName(siteName); | |
| 384 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 385 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" | |
| 386 | + + violationType; | |
| 387 | + // 设置公司简称 | |
| 388 | + for (Object o : company1) { | |
| 389 | + JSONObject jo = (JSONObject) o; | |
| 390 | + if (basevehicleInfo.getString("companyID").equals(jo.getString("id"))) { | |
| 391 | + violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 392 | + break; | |
| 393 | + } | |
| 394 | + } | |
| 395 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 396 | + violationWarningInformation.setDescribe(describe); | |
| 397 | + // 业务逻辑 | |
| 398 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 399 | + break; | |
| 400 | + | |
| 401 | + case "44030034":// 失信车辆作业 | |
| 402 | + case "44030035":// 卫星 | |
| 403 | + violationWarningInformation.setProjectName(siteName); | |
| 404 | + violationWarningInformation.setViolationObjectType("2"); | |
| 405 | + violationWarningInformation.setSendObject("运输企业"); | |
| 406 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 407 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" | |
| 408 | + + violationType; | |
| 409 | + // 设置公司简称 | |
| 410 | + for (Object o : company1) { | |
| 411 | + JSONObject jo = (JSONObject) o; | |
| 412 | + if (basevehicleInfo.getString("companyID").equals(jo.getString("id"))) { | |
| 413 | + violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 414 | + break; | |
| 415 | + } | |
| 416 | + } | |
| 417 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 418 | + violationWarningInformation.setDescribe(describe); | |
| 419 | + // 业务逻辑 | |
| 420 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 421 | + break; | |
| 422 | + } | |
| 423 | + | |
| 424 | + } else { | |
| 425 | + String describe = ""; | |
| 426 | + if (violationTypeCode.equals("44030033") || violationTypeCode.equals("44030034")) { | |
| 427 | + describe = violationWarningInformation1.getDescribe() + ";\n" | |
| 428 | + + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 429 | + + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" | |
| 430 | + + jsonObject.getString("alarmName"); | |
| 431 | + } else { | |
| 432 | + describe = violationWarningInformation1.getDescribe() + ";\n" | |
| 433 | + + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 434 | + + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" | |
| 435 | + + jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName"); | |
| 436 | + } | |
| 437 | + | |
| 438 | + violationWarningInformation1.setDescribe(describe); | |
| 439 | + SpringUtils.getBean(ViolationWarningInformationMapper.class) | |
| 440 | + .updateViolationWarningInformation(violationWarningInformation1); | |
| 441 | + } | |
| 442 | + // kafka消费成功 | |
| 443 | + KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 444 | + kafkaCompensation.setId(Long.valueOf(id)); | |
| 445 | + kafkaCompensation.setStatus(1); | |
| 446 | + SpringUtils.getBean(KafkaCompensationMapper.class).updateKafkaCompensation(kafkaCompensation); | |
| 447 | + | |
| 448 | + } | |
| 449 | + | |
| 450 | + public String insertKafkaCompensation(String data) { | |
| 451 | + KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 452 | + kafkaCompensation.setData(data); | |
| 453 | + kafkaCompensation.setCreateTime(DateUtils.getNowDate()); | |
| 454 | + kafkaCompensation.setStatus(0); | |
| 455 | + SpringUtils.getBean(KafkaCompensationMapper.class).insertKafkaCompensation(kafkaCompensation); | |
| 456 | + return kafkaCompensation.getId().toString(); | |
| 457 | + } | |
| 458 | + | |
| 459 | + /** | |
| 460 | + * 对HH:mm格式时间进行分钟的加减 | |
| 461 | + * | |
| 462 | + * @param timeStr | |
| 463 | + * @param minutesToAddOrSubtract | |
| 464 | + * @return | |
| 465 | + */ | |
| 466 | + public String manipulateTime(String timeStr, int minutesToAddOrSubtract) { | |
| 467 | + // 定义输入时间格式的日期时间格式器 | |
| 468 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 469 | + | |
| 470 | + // 解析输入的时间字符串为 LocalTime 对象 | |
| 471 | + LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 472 | + | |
| 473 | + // 执行加减分钟的操作 | |
| 474 | + LocalTime modifiedTime = time.plusMinutes(minutesToAddOrSubtract); | |
| 475 | + | |
| 476 | + // 将修改后的时间格式化为 HH:mm 格式 | |
| 477 | + String formattedModifiedTime = modifiedTime.format(formatter); | |
| 478 | + | |
| 479 | + return formattedModifiedTime; | |
| 480 | + } | |
| 481 | + | |
| 482 | + /** | |
| 483 | + * 判断timeStr是否在startTimeStr-endTimeStr区间 | |
| 484 | + * | |
| 485 | + * @param timeStr | |
| 486 | + * @param startTimeStr | |
| 487 | + * @param endTimeStr | |
| 488 | + * @return | |
| 489 | + */ | |
| 490 | + public boolean isTimeWithinRange(String timeStr, String startTimeStr, String endTimeStr) { | |
| 491 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 492 | + LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 493 | + LocalTime startTime = LocalTime.parse(startTimeStr, formatter); | |
| 494 | + LocalTime endTime = LocalTime.parse(endTimeStr, formatter); | |
| 495 | + | |
| 496 | + return !time.isBefore(startTime) && !time.isAfter(endTime); | |
| 497 | + | |
| 498 | + } | |
| 442 | 499 | } | ... | ... |
trash-workFlow/src/main/resources/mapper/TruckActivateMapper.xml
| ... | ... | @@ -26,9 +26,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 26 | 26 | <result property="transportEndTime" column="transport_end_time" /> |
| 27 | 27 | <result property="routeName" column="route_name" /> |
| 28 | 28 | <result property="earthName" column="earth_name" /> |
| 29 | - <result property="routeInfo" column="route_info" /> | |
| 29 | +<!-- <result property="routeInfo" column="route_info" /> | |
| 30 | 30 | <result property="earthList" column="earth_list" /> |
| 31 | - <result property="coord" column="coord" /> | |
| 31 | + <result property="coord" column="coord" /> --> | |
| 32 | 32 | </resultMap> |
| 33 | 33 | |
| 34 | 34 | <sql id="selectTruckActivateVo"> |
| ... | ... | @@ -161,9 +161,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 161 | 161 | <if test="transportEndTime != null">transport_end_time,</if> |
| 162 | 162 | <if test="routeName != null">route_name,</if> |
| 163 | 163 | <if test="earthName != null">earth_name,</if> |
| 164 | - <if test="routeInfo != null">route_info,</if> | |
| 164 | +<!-- <if test="routeInfo != null">route_info,</if> | |
| 165 | 165 | <if test="earthList != null">earth_list,</if> |
| 166 | - <if test="coord != null">coord,</if> | |
| 166 | + <if test="coord != null">coord,</if> --> | |
| 167 | 167 | </trim> |
| 168 | 168 | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| 169 | 169 | <if test="company != null">#{company},</if> |
| ... | ... | @@ -187,9 +187,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 187 | 187 | <if test="transportEndTime != null">#{transportEndTime},</if> |
| 188 | 188 | <if test="routeName != null">#{routeName},</if> |
| 189 | 189 | <if test="earthName != null">#{earthName},</if> |
| 190 | - <if test="routeInfo != null">#{routeInfo},</if> | |
| 190 | +<!-- <if test="routeInfo != null">#{routeInfo},</if> | |
| 191 | 191 | <if test="earthList != null">#{earthList},</if> |
| 192 | - <if test="coord != null">#{coord},</if> | |
| 192 | + <if test="coord != null">#{coord},</if> --> | |
| 193 | 193 | </trim> |
| 194 | 194 | </insert> |
| 195 | 195 | |
| ... | ... | @@ -216,9 +216,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 216 | 216 | <if test="transportEndTime != null">transport_end_time = #{transportEndTime},</if> |
| 217 | 217 | <if test="routeName != null">route_name = #{routeName},</if> |
| 218 | 218 | <if test="earthName != null">earth_name = #{earthName},</if> |
| 219 | - <if test="routeInfo != null">route_info = #{routeInfo},</if> | |
| 219 | +<!-- <if test="routeInfo != null">route_info = #{routeInfo},</if> | |
| 220 | 220 | <if test="earthList != null">earth_list = #{earthList},</if> |
| 221 | - <if test="coord != null">coord = #{coord},</if> | |
| 221 | + <if test="coord != null">coord = #{coord},</if> --> | |
| 222 | 222 | </trim> |
| 223 | 223 | where id = #{id} |
| 224 | 224 | </update> | ... | ... |