Commit 0808b760f6d9266c30c2e52a7c38f82707698e9f
1 parent
04d31709
m
Showing
13 changed files
with
938 additions
and
854 deletions
trash-admin/src/main/resources/application.yml
| ... | ... | @@ -11,6 +11,7 @@ spring: |
| 11 | 11 | bootstrap-servers: 183.66.242.6:9101 |
| 12 | 12 | listener: |
| 13 | 13 | ack-mode: manual_immediate |
| 14 | + missing-topics-fatal: false | |
| 14 | 15 | producer: |
| 15 | 16 | x-serializer: org.apache.kafka.common.serialization.StringSerializer |
| 16 | 17 | value-serializer: org.apache.kafka.common.serialization.StringSerializer | ... | ... |
trash-common/src/main/java/com/trash/common/core/domain/entity/SysUser.java
| ... | ... | @@ -102,11 +102,22 @@ public class SysUser extends BaseEntity |
| 102 | 102 | List<String> conList = new ArrayList<String>(); |
| 103 | 103 | List<String> earthList = new ArrayList<String>(); |
| 104 | 104 | List<String> conAreas = new ArrayList<String>(); |
| 105 | + List<String> companyAreas = new ArrayList<String>(); | |
| 105 | 106 | List<String> earthAreas = new ArrayList<String>(); |
| 106 | 107 | List<String> truckList = new ArrayList<String>(); |
| 107 | 108 | |
| 108 | 109 | |
| 109 | - public List<String> getTruckList() { | |
| 110 | + | |
| 111 | + | |
| 112 | + public List<String> getCompanyAreas() { | |
| 113 | + return companyAreas; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void setCompanyAreas(List<String> companyAreas) { | |
| 117 | + this.companyAreas = companyAreas; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public List<String> getTruckList() { | |
| 110 | 121 | return truckList; |
| 111 | 122 | } |
| 112 | 123 | ... | ... |
trash-framework/src/main/java/com/trash/framework/web/service/SysLoginService.java
| ... | ... | @@ -258,6 +258,11 @@ public class SysLoginService |
| 258 | 258 | List<String> companyIds = json.getJSONArray("companyIds").toJavaList(String.class); |
| 259 | 259 | user.setCompanyIds(companyIds); |
| 260 | 260 | } |
| 261 | + | |
| 262 | + if(json.getJSONArray("adCodes") != null){ | |
| 263 | + List<String> areas = json.getJSONArray("adCodes").toJavaList(String.class); | |
| 264 | + user.setCompanyAreas(areas); | |
| 265 | + } | |
| 261 | 266 | }else if(json.getInteger("sourceType") == 3){ |
| 262 | 267 | if(json.getJSONArray("sourceIds") != null){ |
| 263 | 268 | List<String> companyIds = json.getJSONArray("sourceIds").toJavaList(String.class); | ... | ... |
trash-quartz/src/main/java/com/trash/quartz/task/DriverTask.java
| ... | ... | @@ -273,12 +273,12 @@ public class DriverTask |
| 273 | 273 | * @throws InterruptedException |
| 274 | 274 | */ |
| 275 | 275 | public void kafkaCompensation() throws InterruptedException, IOException { |
| 276 | -// KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 277 | -// kafkaCompensation.setStatus(0); | |
| 278 | -// List<KafkaCompensation> kafkaCompensationList = SpringUtils.getBean(KafkaCompensationMapper.class).selectKafkaCompensationList(kafkaCompensation); | |
| 279 | -// for(KafkaCompensation k:kafkaCompensationList){ | |
| 280 | -// SpringUtils.getBean(Consumer.class).autoViolationWarning(k.getData(),k.getId().toString()); | |
| 281 | -// } | |
| 276 | + KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 277 | + kafkaCompensation.setStatus(0); | |
| 278 | + List<KafkaCompensation> kafkaCompensationList = SpringUtils.getBean(KafkaCompensationMapper.class).selectKafkaCompensationList(kafkaCompensation); | |
| 279 | + for(KafkaCompensation k:kafkaCompensationList){ | |
| 280 | + SpringUtils.getBean(Consumer.class).autoViolationWarning(k.getData(),k.getId().toString()); | |
| 281 | + } | |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
| ... | ... | @@ -339,6 +339,21 @@ public class DriverTask |
| 339 | 339 | /** |
| 340 | 340 | * 每分钟更新一次区域列表 |
| 341 | 341 | */ |
| 342 | + public void getTruckList(){ | |
| 343 | + if(RemoteServerUtils.remote == null){ | |
| 344 | + RemoteServerUtils.remote = trashConfig.getRemotePath(); | |
| 345 | + } | |
| 346 | + Map<String, Object> map = new HashMap<>(); | |
| 347 | + map.put("size",99999); | |
| 348 | + map.put("valid",0); | |
| 349 | + map.put("page",1); | |
| 350 | + | |
| 351 | + JSONArray jsonArray = RemoteServerUtils.getTruckList(map,trashConfig.getToken()); | |
| 352 | + redisCache.setCacheObject("truckList",jsonArray); | |
| 353 | + } | |
| 354 | + /** | |
| 355 | + * 每分钟更新一次区域列表 | |
| 356 | + */ | |
| 342 | 357 | public void getAreaList(){ |
| 343 | 358 | if(RemoteServerUtils.remote == null){ |
| 344 | 359 | RemoteServerUtils.remote = trashConfig.getRemotePath(); | ... | ... |
trash-ui/src/layout/index.vue
| 1 | 1 | <template> |
| 2 | - <app-main /> | |
| 2 | + <div :class="classObj" class="app-wrapper"> | |
| 3 | + <sidebar class="sidebar-container"/> | |
| 4 | + <div :class="{hasTagsView:needTagsView}" class="main-container"> | |
| 5 | + <tags-view v-if="needTagsView"/> | |
| 6 | + <app-main/> | |
| 7 | + | |
| 8 | + </div> | |
| 9 | + </div> | |
| 3 | 10 | </template> |
| 4 | 11 | |
| 5 | 12 | <script> |
| 6 | 13 | import RightPanel from '@/components/RightPanel' |
| 7 | -import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components' | |
| 14 | +import {AppMain, Navbar, Settings, Sidebar, TagsView} from './components' | |
| 8 | 15 | import ResizeMixin from './mixin/ResizeHandler' |
| 9 | -import { mapState } from 'vuex' | |
| 16 | +import {mapState} from 'vuex' | |
| 10 | 17 | |
| 11 | 18 | export default { |
| 12 | 19 | name: 'Layout', |
| ... | ... | @@ -38,52 +45,63 @@ export default { |
| 38 | 45 | }, |
| 39 | 46 | methods: { |
| 40 | 47 | handleClickOutside() { |
| 41 | - this.$store.dispatch('app/closeSideBar', { withoutAnimation: false }) | |
| 48 | + this.$store.dispatch('app/closeSideBar', {withoutAnimation: false}) | |
| 42 | 49 | } |
| 43 | 50 | } |
| 44 | 51 | } |
| 45 | 52 | </script> |
| 46 | 53 | |
| 47 | 54 | <style lang="scss" scoped> |
| 48 | - @import "~@/assets/styles/mixin.scss"; | |
| 49 | - @import "~@/assets/styles/variables.scss"; | |
| 50 | - | |
| 51 | - .app-wrapper { | |
| 52 | - @include clearfix; | |
| 53 | - position: relative; | |
| 54 | - height: 100%; | |
| 55 | - width: 100%; | |
| 56 | - | |
| 57 | - &.mobile.openSidebar { | |
| 58 | - position: fixed; | |
| 59 | - top: 0; | |
| 60 | - } | |
| 61 | - } | |
| 55 | +@import "~@/assets/styles/mixin.scss"; | |
| 56 | +@import "~@/assets/styles/variables.scss"; | |
| 62 | 57 | |
| 63 | - .drawer-bg { | |
| 64 | - background: #000; | |
| 65 | - opacity: 0.3; | |
| 66 | - width: 100%; | |
| 67 | - top: 0; | |
| 68 | - height: 100%; | |
| 69 | - position: absolute; | |
| 70 | - z-index: 999; | |
| 71 | - } | |
| 58 | +.app-wrapper { | |
| 59 | + @include clearfix; | |
| 60 | + position: relative; | |
| 61 | + height: 100%; | |
| 62 | + width: 100%; | |
| 72 | 63 | |
| 73 | - .fixed-header { | |
| 64 | + &.mobile.openSidebar { | |
| 74 | 65 | position: fixed; |
| 75 | 66 | top: 0; |
| 76 | - right: 0; | |
| 77 | - z-index: 9; | |
| 78 | - width: calc(100% - #{$sideBarWidth}); | |
| 79 | - transition: width 0.28s; | |
| 80 | 67 | } |
| 68 | +} | |
| 81 | 69 | |
| 82 | - .hideSidebar .fixed-header { | |
| 83 | - width: calc(100% - 54px) | |
| 84 | - } | |
| 70 | +.drawer-bg { | |
| 71 | + background: #000; | |
| 72 | + opacity: 0.3; | |
| 73 | + width: 100%; | |
| 74 | + top: 0; | |
| 75 | + height: 100%; | |
| 76 | + position: absolute; | |
| 77 | + z-index: 999; | |
| 78 | +} | |
| 85 | 79 | |
| 86 | - .mobile .fixed-header { | |
| 87 | - width: 100%; | |
| 88 | - } | |
| 80 | +.fixed-header { | |
| 81 | + position: fixed; | |
| 82 | + top: 0; | |
| 83 | + right: 0; | |
| 84 | + z-index: 9; | |
| 85 | + width: calc(100% - #{$sideBarWidth}); | |
| 86 | + transition: width 0.28s; | |
| 87 | +} | |
| 88 | + | |
| 89 | +.hideSidebar .fixed-header { | |
| 90 | + width: calc(100% - 54px) | |
| 91 | +} | |
| 92 | + | |
| 93 | +.mobile .fixed-header { | |
| 94 | + width: 100%; | |
| 95 | +} | |
| 96 | + | |
| 97 | +.preview figure { | |
| 98 | + float: left; | |
| 99 | + width: 30%; | |
| 100 | + height:calc(30vw - 0px); | |
| 101 | + margin: 1.5%; | |
| 102 | +} | |
| 103 | + | |
| 104 | +.preview figure img { | |
| 105 | + width: 400px; | |
| 106 | +} | |
| 89 | 107 | </style> | ... | ... |
trash-ui/src/layout/index55.vue renamed to trash-ui/src/layout/index4.vue
| 1 | 1 | <template> |
| 2 | - <div :class="classObj" class="app-wrapper"> | |
| 3 | - <sidebar class="sidebar-container"/> | |
| 4 | - <div :class="{hasTagsView:needTagsView}" class="main-container"> | |
| 5 | - <tags-view v-if="needTagsView"/> | |
| 6 | - <app-main/> | |
| 7 | - | |
| 8 | - </div> | |
| 9 | - </div> | |
| 2 | + <app-main /> | |
| 10 | 3 | </template> |
| 11 | 4 | |
| 12 | 5 | <script> |
| 13 | 6 | import RightPanel from '@/components/RightPanel' |
| 14 | -import {AppMain, Navbar, Settings, Sidebar, TagsView} from './components' | |
| 7 | +import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components' | |
| 15 | 8 | import ResizeMixin from './mixin/ResizeHandler' |
| 16 | -import {mapState} from 'vuex' | |
| 9 | +import { mapState } from 'vuex' | |
| 17 | 10 | |
| 18 | 11 | export default { |
| 19 | 12 | name: 'Layout', |
| ... | ... | @@ -45,63 +38,52 @@ export default { |
| 45 | 38 | }, |
| 46 | 39 | methods: { |
| 47 | 40 | handleClickOutside() { |
| 48 | - this.$store.dispatch('app/closeSideBar', {withoutAnimation: false}) | |
| 41 | + this.$store.dispatch('app/closeSideBar', { withoutAnimation: false }) | |
| 49 | 42 | } |
| 50 | 43 | } |
| 51 | 44 | } |
| 52 | 45 | </script> |
| 53 | 46 | |
| 54 | 47 | <style lang="scss" scoped> |
| 55 | -@import "~@/assets/styles/mixin.scss"; | |
| 56 | -@import "~@/assets/styles/variables.scss"; | |
| 48 | + @import "~@/assets/styles/mixin.scss"; | |
| 49 | + @import "~@/assets/styles/variables.scss"; | |
| 57 | 50 | |
| 58 | -.app-wrapper { | |
| 59 | - @include clearfix; | |
| 60 | - position: relative; | |
| 61 | - height: 100%; | |
| 62 | - width: 100%; | |
| 51 | + .app-wrapper { | |
| 52 | + @include clearfix; | |
| 53 | + position: relative; | |
| 54 | + height: 100%; | |
| 55 | + width: 100%; | |
| 63 | 56 | |
| 64 | - &.mobile.openSidebar { | |
| 65 | - position: fixed; | |
| 66 | - top: 0; | |
| 57 | + &.mobile.openSidebar { | |
| 58 | + position: fixed; | |
| 59 | + top: 0; | |
| 60 | + } | |
| 67 | 61 | } |
| 68 | -} | |
| 69 | 62 | |
| 70 | -.drawer-bg { | |
| 71 | - background: #000; | |
| 72 | - opacity: 0.3; | |
| 73 | - width: 100%; | |
| 74 | - top: 0; | |
| 75 | - height: 100%; | |
| 76 | - position: absolute; | |
| 77 | - z-index: 999; | |
| 78 | -} | |
| 79 | - | |
| 80 | -.fixed-header { | |
| 81 | - position: fixed; | |
| 82 | - top: 0; | |
| 83 | - right: 0; | |
| 84 | - z-index: 9; | |
| 85 | - width: calc(100% - #{$sideBarWidth}); | |
| 86 | - transition: width 0.28s; | |
| 87 | -} | |
| 88 | - | |
| 89 | -.hideSidebar .fixed-header { | |
| 90 | - width: calc(100% - 54px) | |
| 91 | -} | |
| 63 | + .drawer-bg { | |
| 64 | + background: #000; | |
| 65 | + opacity: 0.3; | |
| 66 | + width: 100%; | |
| 67 | + top: 0; | |
| 68 | + height: 100%; | |
| 69 | + position: absolute; | |
| 70 | + z-index: 999; | |
| 71 | + } | |
| 92 | 72 | |
| 93 | -.mobile .fixed-header { | |
| 94 | - width: 100%; | |
| 95 | -} | |
| 73 | + .fixed-header { | |
| 74 | + position: fixed; | |
| 75 | + top: 0; | |
| 76 | + right: 0; | |
| 77 | + z-index: 9; | |
| 78 | + width: calc(100% - #{$sideBarWidth}); | |
| 79 | + transition: width 0.28s; | |
| 80 | + } | |
| 96 | 81 | |
| 97 | -.preview figure { | |
| 98 | - float: left; | |
| 99 | - width: 30%; | |
| 100 | - height:calc(30vw - 0px); | |
| 101 | - margin: 1.5%; | |
| 102 | -} | |
| 82 | + .hideSidebar .fixed-header { | |
| 83 | + width: calc(100% - 54px) | |
| 84 | + } | |
| 103 | 85 | |
| 104 | -.preview figure img { | |
| 105 | - width: 400px; | |
| 106 | -} | |
| 86 | + .mobile .fixed-header { | |
| 87 | + width: 100%; | |
| 88 | + } | |
| 107 | 89 | </style> | ... | ... |
trash-ui/src/views/activiti/taskhistory/index.vue
| ... | ... | @@ -58,7 +58,7 @@ |
| 58 | 58 | </el-table> |
| 59 | 59 | </el-dialog> |
| 60 | 60 | |
| 61 | - <el-dialog :title="title" :visible.sync="construct" width="1200px" append-to-body> | |
| 61 | + <el-dialog :title="title" :visible.sync="construct" width="1500px" append-to-body> | |
| 62 | 62 | <companyInfo :businessKey="businessKey" :businessType="2" :signData="signData" v-if="construct"/> |
| 63 | 63 | <el-table :data="hisfromData" v-if="hisfromData != null"> |
| 64 | 64 | <el-table-column label="审批意见" align="center" prop="controlValue"/> |
| ... | ... | @@ -77,7 +77,7 @@ |
| 77 | 77 | </el-dialog> |
| 78 | 78 | |
| 79 | 79 | |
| 80 | - <el-dialog :title="title" :visible.sync="earthsites" width="1200px" append-to-body> | |
| 80 | + <el-dialog :title="title" :visible.sync="earthsites" width="1500px" append-to-body> | |
| 81 | 81 | <companyInfo :businessKey="businessKey" :businessType="3" v-if="earthsites"/> |
| 82 | 82 | <el-table :data="hisfromData" v-if="hisfromData != null"> |
| 83 | 83 | <el-table-column label="审批意见" align="center" prop="controlValue"/> |
| ... | ... | @@ -86,7 +86,7 @@ |
| 86 | 86 | </el-table> |
| 87 | 87 | </el-dialog> |
| 88 | 88 | |
| 89 | - <el-dialog :title="title" :visible.sync="contract" width="1200px" append-to-body> | |
| 89 | + <el-dialog :title="title" :visible.sync="contract" width="1500px" append-to-body> | |
| 90 | 90 | <companyInfo :businessKey="businessKey" :businessType="4" v-if="contract"/> |
| 91 | 91 | <el-table :data="hisfromData" v-if="hisfromData != null"> |
| 92 | 92 | |
| ... | ... | @@ -138,7 +138,7 @@ |
| 138 | 138 | </el-table> |
| 139 | 139 | </el-dialog> |
| 140 | 140 | |
| 141 | - <el-dialog :title="title" :visible.sync="company" width="1200px" append-to-body :close-on-click-modal="false"> | |
| 141 | + <el-dialog :title="title" :visible.sync="company" width="1500px" append-to-body :close-on-click-modal="false"> | |
| 142 | 142 | <companyInfo :businessKey="businessKey" :businessType="0" v-if="company"/> |
| 143 | 143 | <el-table :data="hisfromData" v-if="hisfromData != null"> |
| 144 | 144 | ... | ... |
trash-workFlow/src/main/java/com/trash/business/domain/SupervisionThreestep.java
| ... | ... | @@ -135,8 +135,11 @@ public class SupervisionThreestep extends BaseEntity |
| 135 | 135 | private String attchItem1; |
| 136 | 136 | private String attchItem2; |
| 137 | 137 | private String attchItem3; |
| 138 | - | |
| 138 | + | |
| 139 | + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") | |
| 139 | 140 | private Date workStartTime; |
| 141 | + | |
| 142 | + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss") | |
| 140 | 143 | private Date workEndTime; |
| 141 | 144 | |
| 142 | 145 | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/CompanyCreditServiceImpl.java
| ... | ... | @@ -17,8 +17,10 @@ import com.trash.business.domain.TruckCredit; |
| 17 | 17 | import com.trash.business.mapper.CompanyCreditMapper; |
| 18 | 18 | import com.trash.business.service.ICompanyCreditService; |
| 19 | 19 | import com.trash.business.service.ITruckCreditService; |
| 20 | +import com.trash.common.core.redis.RedisCache; | |
| 20 | 21 | import com.trash.common.utils.RemoteServerUtils; |
| 21 | 22 | import com.trash.common.utils.SecurityUtils; |
| 23 | + | |
| 22 | 24 | /** |
| 23 | 25 | * 企业失信Service业务层处理 |
| 24 | 26 | * |
| ... | ... | @@ -26,274 +28,283 @@ import com.trash.common.utils.SecurityUtils; |
| 26 | 28 | * @date 2023-04-25 |
| 27 | 29 | */ |
| 28 | 30 | @Service |
| 29 | -public class CompanyCreditServiceImpl implements ICompanyCreditService | |
| 30 | -{ | |
| 31 | - @Autowired | |
| 32 | - private CompanyCreditMapper companyCreditMapper; | |
| 33 | - | |
| 34 | - | |
| 35 | - @Autowired | |
| 36 | - private ITruckCreditService truckService;; | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * 查询企业失信 | |
| 40 | - * | |
| 41 | - * @param id 企业失信ID | |
| 42 | - * @return 企业失信 | |
| 43 | - */ | |
| 44 | - @Override | |
| 45 | - public CompanyCredit selectCompanyCreditById(Long id) | |
| 46 | - { | |
| 47 | - return companyCreditMapper.selectCompanyCreditById(id); | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * 查询企业失信列表 | |
| 52 | - * | |
| 53 | - * @param companyCredit 企业失信 | |
| 54 | - * @return 企业失信 | |
| 55 | - */ | |
| 56 | - @Override | |
| 57 | - public List<CompanyCredit> selectCompanyCreditList(CompanyCredit companyCredit) | |
| 58 | - { | |
| 59 | - List<CompanyCredit> list = new ArrayList<>(); | |
| 60 | - | |
| 61 | - if (SecurityUtils.getLoginUser().getUser().getCompanyIds().size() > 0) { | |
| 62 | - companyCredit.setIds(SecurityUtils.getLoginUser().getUser().getCompanyIds()); | |
| 63 | - list = companyCreditMapper.selectCompanyCreditList(companyCredit); | |
| 64 | - } | |
| 31 | +public class CompanyCreditServiceImpl implements ICompanyCreditService { | |
| 32 | + @Autowired | |
| 33 | + private CompanyCreditMapper companyCreditMapper; | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + private ITruckCreditService truckService;; | |
| 37 | + | |
| 38 | + @Autowired | |
| 39 | + RedisCache redisCache; | |
| 40 | + /** | |
| 41 | + * 查询企业失信 | |
| 42 | + * | |
| 43 | + * @param id 企业失信ID | |
| 44 | + * @return 企业失信 | |
| 45 | + */ | |
| 46 | + @Override | |
| 47 | + public CompanyCredit selectCompanyCreditById(Long id) { | |
| 48 | + return companyCreditMapper.selectCompanyCreditById(id); | |
| 49 | + } | |
| 65 | 50 | |
| 51 | + /** | |
| 52 | + * 查询企业失信列表 | |
| 53 | + * | |
| 54 | + * @param companyCredit 企业失信 | |
| 55 | + * @return 企业失信 | |
| 56 | + */ | |
| 57 | + @Override | |
| 58 | + public List<CompanyCredit> selectCompanyCreditList(CompanyCredit companyCredit) { | |
| 59 | + List<CompanyCredit> list = new ArrayList<>(); | |
| 60 | + | |
| 61 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 62 | + List<String> ids = SecurityUtils.getLoginUser().getUser().getCompanyIds(); | |
| 66 | 63 | |
| 67 | - return list; | |
| 68 | - } | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * 新增企业失信 | |
| 72 | - * | |
| 73 | - * @param companyCredit 企业失信 | |
| 74 | - * @return 结果 | |
| 75 | - */ | |
| 76 | - @SuppressWarnings("unchecked") | |
| 64 | + if(areas.size() > 0) { | |
| 65 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 66 | + if(array != null) { | |
| 67 | + for(Object obj:array) { | |
| 68 | + JSONObject json = (JSONObject)obj; | |
| 69 | + if(areas.indexOf(json.getString("areaCode")) > -1) { | |
| 70 | + ids.add(json.getString("id")); | |
| 71 | + } | |
| 72 | + } | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + if ( ids.size()> 0) { | |
| 77 | + companyCredit.setIds(SecurityUtils.getLoginUser().getUser().getCompanyIds()); | |
| 78 | + list = companyCreditMapper.selectCompanyCreditList(companyCredit); | |
| 79 | + } | |
| 80 | + | |
| 81 | + return list; | |
| 82 | + } | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * 新增企业失信 | |
| 86 | + * | |
| 87 | + * @param companyCredit 企业失信 | |
| 88 | + * @return 结果 | |
| 89 | + */ | |
| 90 | + @SuppressWarnings("unchecked") | |
| 77 | 91 | @Override |
| 78 | - public int insertCompanyCredit(CompanyCredit companyCredit) | |
| 79 | - { | |
| 80 | - int i = 0; | |
| 81 | - companyCredit.setCreateBy(SecurityUtils.getUsername()); | |
| 82 | - companyCredit.setTime(new Date()); | |
| 83 | - | |
| 84 | - | |
| 85 | - CompanyCredit cc = new CompanyCredit(); | |
| 86 | - | |
| 87 | - cc.setStatus(0L); | |
| 88 | - cc.setLostCredit(companyCredit.getLostCredit()); | |
| 89 | - cc.setObjectId(companyCredit.getObjectId()); | |
| 90 | - | |
| 91 | - | |
| 92 | - List old = selectCompanyCreditList(cc); | |
| 93 | - | |
| 94 | - if(old.size() > 0){ | |
| 95 | - i = 1; | |
| 96 | - }else{ | |
| 97 | - i = companyCreditMapper.insertCompanyCredit(companyCredit); | |
| 98 | - } | |
| 99 | - | |
| 100 | - updateRemoteCompanyAndTruck(companyCredit,null); | |
| 101 | - | |
| 102 | - return i; | |
| 103 | - } | |
| 104 | - | |
| 105 | - | |
| 106 | - | |
| 107 | - public void insertCompanyCredit(CompanyCredit companyCredit, String token){ | |
| 108 | - companyCredit.setTime(new Date()); | |
| 109 | - | |
| 110 | - int i = companyCreditMapper.insertCompanyCredit(companyCredit); | |
| 111 | - | |
| 112 | - updateRemoteCompanyAndTruck(companyCredit,token); | |
| 113 | - | |
| 114 | - return; | |
| 92 | + public int insertCompanyCredit(CompanyCredit companyCredit) { | |
| 93 | + int i = 0; | |
| 94 | + companyCredit.setCreateBy(SecurityUtils.getUsername()); | |
| 95 | + companyCredit.setTime(new Date()); | |
| 96 | + | |
| 97 | + CompanyCredit cc = new CompanyCredit(); | |
| 98 | + | |
| 99 | + cc.setStatus(0L); | |
| 100 | + cc.setLostCredit(companyCredit.getLostCredit()); | |
| 101 | + cc.setObjectId(companyCredit.getObjectId()); | |
| 102 | + | |
| 103 | + List old = selectCompanyCreditList(cc); | |
| 104 | + | |
| 105 | + if (old.size() > 0) { | |
| 106 | + i = 1; | |
| 107 | + } else { | |
| 108 | + i = companyCreditMapper.insertCompanyCredit(companyCredit); | |
| 109 | + } | |
| 110 | + | |
| 111 | + updateRemoteCompanyAndTruck(companyCredit, null); | |
| 112 | + | |
| 113 | + return i; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public void insertCompanyCredit(CompanyCredit companyCredit, String token) { | |
| 117 | + companyCredit.setTime(new Date()); | |
| 118 | + | |
| 119 | + int i = companyCreditMapper.insertCompanyCredit(companyCredit); | |
| 120 | + | |
| 121 | + updateRemoteCompanyAndTruck(companyCredit, token); | |
| 122 | + | |
| 123 | + return; | |
| 115 | 124 | } |
| 116 | - | |
| 117 | - | |
| 118 | - @Override | |
| 119 | - public void updateRemoteCompanyAndTruck(CompanyCredit companyCredit,String token){ | |
| 120 | - long credit = companyCredit.getLostCredit(); | |
| 121 | - String companyId = companyCredit.getObjectId(); | |
| 122 | - | |
| 123 | - | |
| 124 | - List<Map> cpcList = new ArrayList<>(); | |
| 125 | - Map cpc = new HashedMap<>(); | |
| 126 | - cpc.put("dishonestState", credit); | |
| 127 | - cpc.put("id", companyId); | |
| 128 | - | |
| 129 | - cpcList.add(cpc); | |
| 130 | - | |
| 131 | - | |
| 132 | - | |
| 133 | - Map map = new HashedMap<>(); | |
| 134 | - | |
| 135 | - map.put("companyID",companyId); | |
| 136 | - map.put("valid",0); | |
| 137 | - JSONArray turckList = null; | |
| 138 | - if(token == null){ | |
| 139 | - RemoteServerUtils.updateCompanyList(cpcList); | |
| 140 | - turckList = RemoteServerUtils.getTruckList(map); | |
| 141 | - }else{ | |
| 142 | - RemoteServerUtils.updateCompanyList(cpcList, token); | |
| 143 | - turckList = RemoteServerUtils.getTruckList(map,token); | |
| 144 | - } | |
| 145 | - | |
| 146 | - | |
| 147 | - if(turckList != null){ | |
| 148 | - for(Object objec:turckList){ | |
| 149 | - | |
| 150 | - List<Map> updateList = new ArrayList(); | |
| 151 | - JSONObject truck = (JSONObject)objec; | |
| 152 | - | |
| 153 | - String truckId = truck.getString("id"); | |
| 154 | - | |
| 155 | - TruckCredit tredit = new TruckCredit(); | |
| 156 | - | |
| 157 | - tredit.setStatus(0L); | |
| 158 | - tredit.setObjectId(truckId); | |
| 159 | - | |
| 160 | - List<TruckCredit> oldData = truckService.selectTruckCreditList(tredit); | |
| 161 | - TruckCredit data; | |
| 162 | - if(oldData.size() > 0){ | |
| 163 | - data = oldData.get(0); | |
| 164 | - if(data.getLostCredit() != credit){ | |
| 165 | - if(credit == 0 && (data.getCreateType() != null && data.getCreateType() == 1)){ | |
| 166 | - data.setLostCredit(credit); | |
| 167 | - data.setReason("公司失信恢复"); | |
| 168 | - truckService.updateTruckCredit(data); | |
| 169 | - Map upParam = new HashedMap<>(); | |
| 170 | - upParam.put("creditStatus", credit); | |
| 171 | - upParam.put("id", truckId); | |
| 172 | - updateList.add(upParam); | |
| 173 | - | |
| 174 | - if(token != null) | |
| 175 | - RemoteServerUtils.updateTruckList(updateList,token); | |
| 176 | - else | |
| 177 | - RemoteServerUtils.updateTruckList(updateList); | |
| 178 | - | |
| 179 | - continue; | |
| 180 | - } | |
| 181 | - } | |
| 182 | - }else{ | |
| 183 | - if(credit==0) | |
| 184 | - continue; | |
| 185 | - | |
| 186 | - data = new TruckCredit(); | |
| 187 | - | |
| 188 | - data.setLostCredit(credit); | |
| 189 | - | |
| 190 | - data.setCompanyId(companyCredit.getName()); | |
| 191 | - | |
| 192 | - data.setLicensePlate(truck.getString("licenseplateNo")); | |
| 193 | - | |
| 194 | - data.setTime(new Date()); | |
| 195 | - | |
| 125 | + | |
| 126 | + @Override | |
| 127 | + public void updateRemoteCompanyAndTruck(CompanyCredit companyCredit, String token) { | |
| 128 | + long credit = companyCredit.getLostCredit(); | |
| 129 | + String companyId = companyCredit.getObjectId(); | |
| 130 | + | |
| 131 | + List<Map> cpcList = new ArrayList<>(); | |
| 132 | + Map cpc = new HashedMap<>(); | |
| 133 | + cpc.put("dishonestState", credit); | |
| 134 | + cpc.put("id", companyId); | |
| 135 | + | |
| 136 | + cpcList.add(cpc); | |
| 137 | + | |
| 138 | + Map map = new HashedMap<>(); | |
| 139 | + | |
| 140 | + map.put("companyID", companyId); | |
| 141 | + map.put("valid", 0); | |
| 142 | + JSONArray turckList = null; | |
| 143 | + if (token == null) { | |
| 144 | + RemoteServerUtils.updateCompanyList(cpcList); | |
| 145 | + turckList = RemoteServerUtils.getTruckList(map); | |
| 146 | + } else { | |
| 147 | + RemoteServerUtils.updateCompanyList(cpcList, token); | |
| 148 | + turckList = RemoteServerUtils.getTruckList(map, token); | |
| 149 | + } | |
| 150 | + | |
| 151 | + if (turckList != null) { | |
| 152 | + for (Object objec : turckList) { | |
| 153 | + | |
| 154 | + List<Map> updateList = new ArrayList(); | |
| 155 | + JSONObject truck = (JSONObject) objec; | |
| 156 | + | |
| 157 | + String truckId = truck.getString("id"); | |
| 158 | + | |
| 159 | + TruckCredit tredit = new TruckCredit(); | |
| 160 | + | |
| 161 | + tredit.setStatus(0L); | |
| 162 | + tredit.setObjectId(truckId); | |
| 163 | + | |
| 164 | + List<TruckCredit> oldData = truckService.selectTruckCreditList(tredit); | |
| 165 | + TruckCredit data; | |
| 166 | + if (oldData.size() > 0) { | |
| 167 | + data = oldData.get(0); | |
| 168 | + if (data.getLostCredit() != credit) { | |
| 169 | + if (credit == 0 && (data.getCreateType() != null && data.getCreateType() == 1)) { | |
| 170 | + data.setLostCredit(credit); | |
| 171 | + data.setReason("公司失信恢复"); | |
| 172 | + truckService.updateTruckCredit(data); | |
| 173 | + Map upParam = new HashedMap<>(); | |
| 174 | + upParam.put("creditStatus", credit); | |
| 175 | + upParam.put("id", truckId); | |
| 176 | + updateList.add(upParam); | |
| 177 | + | |
| 178 | + if (token != null) | |
| 179 | + RemoteServerUtils.updateTruckList(updateList, token); | |
| 180 | + else | |
| 181 | + RemoteServerUtils.updateTruckList(updateList); | |
| 182 | + | |
| 183 | + continue; | |
| 184 | + } | |
| 185 | + } | |
| 186 | + } else { | |
| 187 | + if (credit == 0) | |
| 188 | + continue; | |
| 189 | + | |
| 190 | + data = new TruckCredit(); | |
| 191 | + | |
| 192 | + data.setLostCredit(credit); | |
| 193 | + | |
| 194 | + data.setCompanyId(companyCredit.getName()); | |
| 195 | + | |
| 196 | + data.setLicensePlate(truck.getString("licenseplateNo")); | |
| 197 | + | |
| 198 | + data.setTime(new Date()); | |
| 199 | + | |
| 196 | 200 | // data.setCreateBy(SecurityUtils.getUsername()); |
| 197 | - data.setCreateBy(""); | |
| 198 | - | |
| 199 | - data.setReason("公司失信"); | |
| 200 | - | |
| 201 | - data.setCreateType(1L); | |
| 202 | - | |
| 203 | - data.setObjectId(truckId); | |
| 204 | - | |
| 205 | - truckService.insertTruckCredit(data); | |
| 206 | - | |
| 207 | - Map upParam = new HashedMap<>(); | |
| 208 | - upParam.put("creditStatus", credit); | |
| 209 | - upParam.put("id", truckId); | |
| 210 | - updateList.add(upParam); | |
| 211 | - if(token != null) | |
| 212 | - RemoteServerUtils.updateTruckList(updateList,token); | |
| 213 | - else | |
| 214 | - RemoteServerUtils.updateTruckList(updateList); | |
| 215 | - | |
| 216 | - } | |
| 217 | - } | |
| 218 | - } | |
| 219 | - | |
| 220 | - } | |
| 221 | - | |
| 222 | - /** | |
| 223 | - * 修改企业失信 | |
| 224 | - * | |
| 225 | - * @param companyCredit 企业失信 | |
| 226 | - * @return 结果 | |
| 227 | - */ | |
| 228 | - @Override | |
| 229 | - @Transactional | |
| 230 | - public int updateCompanyCredit(CompanyCredit companyCredit) | |
| 231 | - { | |
| 232 | - | |
| 233 | - CompanyCredit cc = companyCreditMapper.selectCompanyCreditById(companyCredit.getId()); | |
| 234 | - | |
| 235 | - cc.setStatus(1L); | |
| 236 | - | |
| 237 | - try { | |
| 238 | - companyCreditMapper.updateCompanyCredit(cc); | |
| 239 | - | |
| 240 | - cc.setReason(companyCredit.getReason()); | |
| 241 | - cc.setLostCredit(0L); | |
| 242 | - | |
| 243 | - return insertCompanyCredit(cc); | |
| 244 | - | |
| 245 | - } catch (Exception e) { | |
| 246 | - e.printStackTrace(); | |
| 247 | - | |
| 248 | - } | |
| 249 | - | |
| 250 | - return 0; | |
| 251 | - } | |
| 252 | - | |
| 253 | - /** | |
| 254 | - * 批量删除企业失信 | |
| 255 | - * | |
| 256 | - * @param ids 需要删除的企业失信ID | |
| 257 | - * @return 结果 | |
| 258 | - */ | |
| 259 | - @Override | |
| 260 | - public int deleteCompanyCreditByIds(Long[] ids) | |
| 261 | - { | |
| 262 | - return companyCreditMapper.deleteCompanyCreditByIds(ids); | |
| 263 | - } | |
| 264 | - | |
| 265 | - public List<String> getNames(CompanyCredit companyCredit){ | |
| 266 | - return companyCreditMapper.getNames(companyCredit); | |
| 267 | - } | |
| 268 | - | |
| 269 | - public List<String> getPlaces(CompanyCredit companyCredit){ | |
| 270 | - return companyCreditMapper.getPlaces(companyCredit); | |
| 271 | - } | |
| 272 | - | |
| 273 | - | |
| 274 | - @Override | |
| 275 | - public List<CompanyCredit> selectCompanyCreditHistory(CompanyCredit companyCredit) | |
| 276 | - { | |
| 277 | - List<CompanyCredit> list = new ArrayList<>(); | |
| 278 | - | |
| 279 | - if (SecurityUtils.getLoginUser().getUser().getCompanyIds().size() > 0) { | |
| 280 | - companyCredit.setIds(SecurityUtils.getLoginUser().getUser().getCompanyIds()); | |
| 281 | - list = companyCreditMapper.selectCompanyCreditHistory(companyCredit); | |
| 201 | + data.setCreateBy(""); | |
| 202 | + | |
| 203 | + data.setReason("公司失信"); | |
| 204 | + | |
| 205 | + data.setCreateType(1L); | |
| 206 | + | |
| 207 | + data.setObjectId(truckId); | |
| 208 | + | |
| 209 | + truckService.insertTruckCredit(data); | |
| 210 | + | |
| 211 | + Map upParam = new HashedMap<>(); | |
| 212 | + upParam.put("creditStatus", credit); | |
| 213 | + upParam.put("id", truckId); | |
| 214 | + updateList.add(upParam); | |
| 215 | + if (token != null) | |
| 216 | + RemoteServerUtils.updateTruckList(updateList, token); | |
| 217 | + else | |
| 218 | + RemoteServerUtils.updateTruckList(updateList); | |
| 219 | + | |
| 220 | + } | |
| 282 | 221 | } |
| 222 | + } | |
| 223 | + | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * 修改企业失信 | |
| 228 | + * | |
| 229 | + * @param companyCredit 企业失信 | |
| 230 | + * @return 结果 | |
| 231 | + */ | |
| 232 | + @Override | |
| 233 | + @Transactional | |
| 234 | + public int updateCompanyCredit(CompanyCredit companyCredit) { | |
| 235 | + | |
| 236 | + CompanyCredit cc = companyCreditMapper.selectCompanyCreditById(companyCredit.getId()); | |
| 237 | + | |
| 238 | + cc.setStatus(1L); | |
| 239 | + | |
| 240 | + try { | |
| 241 | + companyCreditMapper.updateCompanyCredit(cc); | |
| 242 | + | |
| 243 | + cc.setReason(companyCredit.getReason()); | |
| 244 | + cc.setLostCredit(0L); | |
| 283 | 245 | |
| 246 | + return insertCompanyCredit(cc); | |
| 247 | + | |
| 248 | + } catch (Exception e) { | |
| 249 | + e.printStackTrace(); | |
| 250 | + | |
| 251 | + } | |
| 252 | + | |
| 253 | + return 0; | |
| 254 | + } | |
| 255 | + | |
| 256 | + /** | |
| 257 | + * 批量删除企业失信 | |
| 258 | + * | |
| 259 | + * @param ids 需要删除的企业失信ID | |
| 260 | + * @return 结果 | |
| 261 | + */ | |
| 262 | + @Override | |
| 263 | + public int deleteCompanyCreditByIds(Long[] ids) { | |
| 264 | + return companyCreditMapper.deleteCompanyCreditByIds(ids); | |
| 265 | + } | |
| 266 | + | |
| 267 | + public List<String> getNames(CompanyCredit companyCredit) { | |
| 268 | + return companyCreditMapper.getNames(companyCredit); | |
| 269 | + } | |
| 270 | + | |
| 271 | + public List<String> getPlaces(CompanyCredit companyCredit) { | |
| 272 | + return companyCreditMapper.getPlaces(companyCredit); | |
| 273 | + } | |
| 274 | + | |
| 275 | + @Override | |
| 276 | + public List<CompanyCredit> selectCompanyCreditHistory(CompanyCredit companyCredit) { | |
| 277 | + List<CompanyCredit> list = new ArrayList<>(); | |
| 278 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 279 | + List<String> ids = SecurityUtils.getLoginUser().getUser().getCompanyIds(); | |
| 284 | 280 | |
| 285 | - return list; | |
| 286 | - } | |
| 287 | - | |
| 288 | - /** | |
| 289 | - * 删除企业失信信息 | |
| 290 | - * | |
| 291 | - * @param id 企业失信ID | |
| 292 | - * @return 结果 | |
| 293 | - */ | |
| 294 | - @Override | |
| 295 | - public int deleteCompanyCreditById(Long id) | |
| 296 | - { | |
| 297 | - return companyCreditMapper.deleteCompanyCreditById(id); | |
| 298 | - } | |
| 281 | + if(areas.size() > 0) { | |
| 282 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 283 | + if(array != null) { | |
| 284 | + for(Object obj:array) { | |
| 285 | + JSONObject json = (JSONObject)obj; | |
| 286 | + if(areas.indexOf(json.getString("areaCode")) > -1) { | |
| 287 | + ids.add(json.getString("id")); | |
| 288 | + } | |
| 289 | + } | |
| 290 | + } | |
| 291 | + } | |
| 292 | + if (SecurityUtils.getLoginUser().getUser().getCompanyIds().size() > 0) { | |
| 293 | + companyCredit.setIds(SecurityUtils.getLoginUser().getUser().getCompanyIds()); | |
| 294 | + list = companyCreditMapper.selectCompanyCreditHistory(companyCredit); | |
| 295 | + } | |
| 296 | + | |
| 297 | + return list; | |
| 298 | + } | |
| 299 | + | |
| 300 | + /** | |
| 301 | + * 删除企业失信信息 | |
| 302 | + * | |
| 303 | + * @param id 企业失信ID | |
| 304 | + * @return 结果 | |
| 305 | + */ | |
| 306 | + @Override | |
| 307 | + public int deleteCompanyCreditById(Long id) { | |
| 308 | + return companyCreditMapper.deleteCompanyCreditById(id); | |
| 309 | + } | |
| 299 | 310 | } |
| 300 | 311 | \ No newline at end of file | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/SupervisionThreestepServiceImpl.java
| ... | ... | @@ -83,6 +83,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 83 | 83 | String start, end; |
| 84 | 84 | |
| 85 | 85 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 86 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 86 | 87 | Date date = new Date(); |
| 87 | 88 | |
| 88 | 89 | if (new Date().getHours() < 8) { |
| ... | ... | @@ -182,6 +183,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 182 | 183 | String start, end; |
| 183 | 184 | |
| 184 | 185 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 186 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 185 | 187 | Date date = new Date(); |
| 186 | 188 | |
| 187 | 189 | if (new Date().getHours() < 8) { |
| ... | ... | @@ -224,7 +226,6 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 224 | 226 | return supervisionThreestepMapper.getNames(supervisionThreestep); |
| 225 | 227 | } |
| 226 | 228 | |
| 227 | - SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 228 | 229 | |
| 229 | 230 | String[] outside = { "长沙县", "望城区", "浏阳市", "宁乡市", "株洲市", "湘潭市", "汩罗市", "湘阴县" }; |
| 230 | 231 | |
| ... | ... | @@ -233,6 +234,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 233 | 234 | public List<Map<String, String>> selectDayWorkList(SupervisionThreestep supervisionThreestep) { |
| 234 | 235 | |
| 235 | 236 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 237 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 236 | 238 | if (supervisionThreestep.getWorkStartTime() == null) { |
| 237 | 239 | String start, end; |
| 238 | 240 | |
| ... | ... | @@ -520,33 +522,36 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 520 | 522 | |
| 521 | 523 | @Override |
| 522 | 524 | public List<Map> selectDayWorkListByType(SupervisionThreestep supervisionThreestep) { |
| 523 | - | |
| 524 | - SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); | |
| 525 | - String start, end; | |
| 525 | + | |
| 526 | 526 | |
| 527 | 527 | Date date = new Date(); |
| 528 | - | |
| 529 | - if (new Date().getHours() < 8) { | |
| 530 | - end = yearFomat.format(date); | |
| 531 | - date.setDate(date.getDate() - 1); | |
| 532 | - start = yearFomat.format(date); | |
| 533 | - } else { | |
| 534 | - start = yearFomat.format(date); | |
| 535 | - date.setDate(date.getDate() + 1); | |
| 536 | - end = yearFomat.format(date); | |
| 537 | - } | |
| 538 | - | |
| 539 | - end += " 4:00:00"; | |
| 540 | - start += " 8:00:00"; | |
| 541 | - | |
| 542 | - try { | |
| 543 | - supervisionThreestep.setWorkStartTime(dateTime.parse(start)); | |
| 544 | - supervisionThreestep.setWorkEndTime(dateTime.parse(end)); | |
| 545 | - } catch (Exception e) { | |
| 546 | - // TODO Auto-generated catch block | |
| 547 | - e.printStackTrace(); | |
| 528 | + SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); | |
| 529 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 530 | + if(supervisionThreestep.getWorkStartTime() == null){ | |
| 531 | + String start, end; | |
| 532 | + | |
| 533 | + | |
| 534 | + if (new Date().getHours() < 8) { | |
| 535 | + end = yearFomat.format(date); | |
| 536 | + date.setDate(date.getDate() - 1); | |
| 537 | + start = yearFomat.format(date); | |
| 538 | + } else { | |
| 539 | + start = yearFomat.format(date); | |
| 540 | + date.setDate(date.getDate() + 1); | |
| 541 | + end = yearFomat.format(date); | |
| 542 | + } | |
| 543 | + | |
| 544 | + end += " 4:00:00"; | |
| 545 | + start += " 8:00:00"; | |
| 546 | + | |
| 547 | + try { | |
| 548 | + supervisionThreestep.setWorkStartTime(dateTime.parse(start)); | |
| 549 | + supervisionThreestep.setWorkEndTime(dateTime.parse(end)); | |
| 550 | + } catch (Exception e) { | |
| 551 | + // TODO Auto-generated catch block | |
| 552 | + e.printStackTrace(); | |
| 553 | + } | |
| 548 | 554 | } |
| 549 | - | |
| 550 | 555 | List<Map> map = supervisionThreestepMapper.selectDayWorkListByType(supervisionThreestep); |
| 551 | 556 | |
| 552 | 557 | List<Map> list = new ArrayList<>(); |
| ... | ... | @@ -583,6 +588,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 583 | 588 | public List<SupervisionThreestep> selectTodayDataList(SupervisionThreestep supervisionThreestep) { |
| 584 | 589 | |
| 585 | 590 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 591 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 586 | 592 | if (supervisionThreestep.getWorkStartTime() == null) { |
| 587 | 593 | String start, end; |
| 588 | 594 | |
| ... | ... | @@ -656,6 +662,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 656 | 662 | } |
| 657 | 663 | |
| 658 | 664 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 665 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 659 | 666 | if (supervisionThreestep.getId() != null) { |
| 660 | 667 | supervisionThreestepMapper.deleteSupervisionThreestepById(supervisionThreestep.getId()); |
| 661 | 668 | } |
| ... | ... | @@ -728,6 +735,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 728 | 735 | int j = supervisionThreestepMapper.updateSupervisionThreestep(supervisionThreestep); |
| 729 | 736 | |
| 730 | 737 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 738 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 731 | 739 | |
| 732 | 740 | supervisionThreestep = supervisionThreestepMapper.selectSupervisionThreestepById(supervisionThreestep.getId()); |
| 733 | 741 | |
| ... | ... | @@ -934,6 +942,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 934 | 942 | public void updateTodayData(String token) { |
| 935 | 943 | |
| 936 | 944 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 945 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 937 | 946 | |
| 938 | 947 | SupervisionThreestep supervisionThreestep = new SupervisionThreestep(); |
| 939 | 948 | |
| ... | ... | @@ -1023,6 +1032,7 @@ public class SupervisionThreestepServiceImpl implements ISupervisionThreestepSer |
| 1023 | 1032 | if (supervisionThreestep.getWorkStartTime() == null) { |
| 1024 | 1033 | |
| 1025 | 1034 | SimpleDateFormat yearFomat = new SimpleDateFormat("yyyy-MM-dd"); |
| 1035 | + SimpleDateFormat dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 1026 | 1036 | |
| 1027 | 1037 | String start, end; |
| 1028 | 1038 | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/TruckActivateServiceImpl.java
| ... | ... | @@ -90,7 +90,20 @@ public class TruckActivateServiceImpl implements ITruckActivateService { |
| 90 | 90 | |
| 91 | 91 | List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); |
| 92 | 92 | List<String> tList = SecurityUtils.getLoginUser().getUser().getTruckList(); |
| 93 | - | |
| 93 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 94 | + | |
| 95 | + | |
| 96 | + if(areas.size() > 0) { | |
| 97 | + JSONArray array = redis.getCacheObject("companyList"); | |
| 98 | + if(array != null) { | |
| 99 | + for(Object obj:array) { | |
| 100 | + JSONObject json = (JSONObject)obj; | |
| 101 | + if(areas.indexOf(json.getString("areaCode")) > -1) { | |
| 102 | + companys.add(json.getString("id")); | |
| 103 | + } | |
| 104 | + } | |
| 105 | + } | |
| 106 | + } | |
| 94 | 107 | if (tList.size() > 0 || companys.size() > 0 || cList.size() > 0) { |
| 95 | 108 | List<String> ids = new ArrayList<>(); |
| 96 | 109 | for (String str : tList) { |
| ... | ... | @@ -99,12 +112,7 @@ public class TruckActivateServiceImpl implements ITruckActivateService { |
| 99 | 112 | |
| 100 | 113 | if (companys.size() > 0) { |
| 101 | 114 | |
| 102 | - Map map = new HashMap<>(); | |
| 103 | - map.put("size", 99999); | |
| 104 | - map.put("valid", 0); | |
| 105 | - map.put("page", 1); | |
| 106 | - | |
| 107 | - JSONArray jsonArray = RemoteServerUtils.getTruckList(map); | |
| 115 | + JSONArray jsonArray = redis.getCacheObject("truckList"); | |
| 108 | 116 | |
| 109 | 117 | for (Object obj : jsonArray) { |
| 110 | 118 | JSONObject json = (JSONObject) obj; | ... | ... |
trash-workFlow/src/main/java/com/trash/business/service/impl/TruckCreditServiceImpl.java
| ... | ... | @@ -17,6 +17,7 @@ import com.trash.business.domain.EarthsitesCredit; |
| 17 | 17 | import com.trash.business.domain.TruckCredit; |
| 18 | 18 | import com.trash.business.mapper.TruckCreditMapper; |
| 19 | 19 | import com.trash.business.service.ITruckCreditService; |
| 20 | +import com.trash.common.core.redis.RedisCache; | |
| 20 | 21 | import com.trash.common.utils.RemoteServerUtils; |
| 21 | 22 | import com.trash.common.utils.SecurityUtils; |
| 22 | 23 | |
| ... | ... | @@ -32,6 +33,8 @@ public class TruckCreditServiceImpl implements ITruckCreditService |
| 32 | 33 | @Autowired |
| 33 | 34 | private TruckCreditMapper truckCreditMapper; |
| 34 | 35 | |
| 36 | + @Autowired | |
| 37 | + RedisCache redisCache; | |
| 35 | 38 | /** |
| 36 | 39 | * 查询车辆失信 |
| 37 | 40 | * |
| ... | ... | @@ -58,6 +61,21 @@ public class TruckCreditServiceImpl implements ITruckCreditService |
| 58 | 61 | |
| 59 | 62 | List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); |
| 60 | 63 | List<String> tList = SecurityUtils.getLoginUser().getUser().getTruckList(); |
| 64 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 65 | + | |
| 66 | + | |
| 67 | + if(areas.size() > 0) { | |
| 68 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 69 | + if(array != null) { | |
| 70 | + for(Object obj:array) { | |
| 71 | + JSONObject json = (JSONObject)obj; | |
| 72 | + if(areas.indexOf(json.getString("areaCode")) > -1) { | |
| 73 | + companys.add(json.getString("id")); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 61 | 79 | |
| 62 | 80 | if (tList.size() > 0 || companys.size() > 0) { |
| 63 | 81 | List<String> ids = new ArrayList<>(); |
| ... | ... | @@ -68,13 +86,7 @@ public class TruckCreditServiceImpl implements ITruckCreditService |
| 68 | 86 | |
| 69 | 87 | if(companys.size() > 0){ |
| 70 | 88 | |
| 71 | - Map map = new HashMap<>(); | |
| 72 | - map.put("size",99999); | |
| 73 | - map.put("valid",0); | |
| 74 | - map.put("page",1); | |
| 75 | - | |
| 76 | - JSONArray jsonArray = RemoteServerUtils.getTruckList(map); | |
| 77 | - | |
| 89 | + JSONArray jsonArray = redisCache.getCacheObject("truckList"); | |
| 78 | 90 | |
| 79 | 91 | for(Object obj:jsonArray){ |
| 80 | 92 | JSONObject json = (JSONObject) obj; |
| ... | ... | @@ -175,7 +187,20 @@ public class TruckCreditServiceImpl implements ITruckCreditService |
| 175 | 187 | List<TruckCredit> list = new ArrayList<>(); |
| 176 | 188 | List<String> companys = SecurityUtils.getLoginUser().getUser().getCompanyIds(); |
| 177 | 189 | List<String> tList = SecurityUtils.getLoginUser().getUser().getTruckList(); |
| 190 | + List<String> areas = SecurityUtils.getLoginUser().getUser().getCompanyAreas(); | |
| 178 | 191 | |
| 192 | + | |
| 193 | + if(areas.size() > 0) { | |
| 194 | + JSONArray array = redisCache.getCacheObject("companyList"); | |
| 195 | + if(array != null) { | |
| 196 | + for(Object obj:array) { | |
| 197 | + JSONObject json = (JSONObject)obj; | |
| 198 | + if(areas.indexOf(json.getString("areaCode")) > -1) { | |
| 199 | + companys.add(json.getString("id")); | |
| 200 | + } | |
| 201 | + } | |
| 202 | + } | |
| 203 | + } | |
| 179 | 204 | if (tList.size() > 0 || companys.size() > 0) { |
| 180 | 205 | List<String> ids = new ArrayList<>(); |
| 181 | 206 | for(String str:tList){ |
| ... | ... | @@ -185,12 +210,7 @@ public class TruckCreditServiceImpl implements ITruckCreditService |
| 185 | 210 | |
| 186 | 211 | if(companys.size() > 0){ |
| 187 | 212 | |
| 188 | - Map map = new HashMap<>(); | |
| 189 | - map.put("size",99999); | |
| 190 | - map.put("valid",0); | |
| 191 | - map.put("page",1); | |
| 192 | - | |
| 193 | - JSONArray jsonArray = RemoteServerUtils.getTruckList(map); | |
| 213 | + JSONArray jsonArray = redisCache.getCacheObject("truckList"); | |
| 194 | 214 | |
| 195 | 215 | |
| 196 | 216 | for(Object obj:jsonArray){ | ... | ... |
trash-workFlow/src/main/java/com/trash/casefile/kafka/Consumer.java
| 1 | -//package com.trash.casefile.kafka; | |
| 2 | -// | |
| 3 | -//import com.alibaba.fastjson.JSONArray; | |
| 4 | -//import com.alibaba.fastjson.JSONObject; | |
| 5 | -//import com.trash.casefile.domain.KafkaCompensation; | |
| 6 | -//import com.trash.casefile.domain.ViolationWarningInformation; | |
| 7 | -//import com.trash.casefile.mapper.KafkaCompensationMapper; | |
| 8 | -//import com.trash.casefile.mapper.ViolationWarningInformationMapper; | |
| 9 | -//import com.trash.casefile.service.IViolationWarningInformationService; | |
| 10 | -//import com.trash.common.config.trashConfig; | |
| 11 | -//import com.trash.common.core.redis.RedisCache; | |
| 12 | -//import com.trash.common.utils.DateUtils; | |
| 13 | -//import com.trash.common.utils.RemoteServerUtils; | |
| 14 | -//import com.trash.common.utils.StringUtils; | |
| 15 | -//import com.trash.common.utils.spring.SpringUtils; | |
| 16 | -//import com.trash.framework.web.service.SysLoginService; | |
| 17 | -//import org.apache.commons.lang3.time.DateFormatUtils; | |
| 18 | -//import org.apache.kafka.clients.consumer.ConsumerRecord; | |
| 19 | -//import org.slf4j.Logger; | |
| 20 | -//import org.slf4j.LoggerFactory; | |
| 21 | -//import org.springframework.beans.factory.annotation.Autowired; | |
| 22 | -//import org.springframework.kafka.annotation.KafkaListener; | |
| 23 | -//import org.springframework.kafka.support.Acknowledgment; | |
| 24 | -//import org.springframework.kafka.support.KafkaHeaders; | |
| 25 | -//import org.springframework.messaging.handler.annotation.Header; | |
| 26 | -//import org.springframework.messaging.handler.annotation.Payload; | |
| 27 | -//import org.springframework.stereotype.Component; | |
| 28 | -//import org.springframework.transaction.annotation.Transactional; | |
| 29 | -// | |
| 30 | -//import java.io.IOException; | |
| 31 | -//import java.time.LocalTime; | |
| 32 | -//import java.time.format.DateTimeFormatter; | |
| 33 | -//import java.util.*; | |
| 34 | -//import java.util.concurrent.TimeUnit; | |
| 35 | -// | |
| 36 | -//@Component | |
| 37 | -//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 | -// log.info("kafka消费数据成功,offset:"+ record.offset() +",data:" + record.value()); | |
| 46 | -// String id = insertKafkaCompensation(record.value().toString()); | |
| 47 | -// autoViolationWarning(record.value().toString(),id); | |
| 48 | -// //手动提交offset | |
| 49 | -// ack.acknowledge(); | |
| 50 | -// } | |
| 51 | -// | |
| 52 | -// @Autowired | |
| 53 | -// trashConfig trashConfig; | |
| 54 | -// | |
| 55 | -// @Autowired | |
| 56 | -// SysLoginService loginService; | |
| 57 | -// | |
| 58 | -// @Autowired | |
| 59 | -// RedisCache redisCache; | |
| 60 | -// | |
| 61 | -// public void autoViolationWarning(String data,String id) throws InterruptedException, IOException { | |
| 62 | -// | |
| 63 | -// String[] code = {"44030020=工地预警-未报开工作业", "44030021=工地预警-视频设备离线超时报警", "44030022=工地预警-三无车辆进入工地", "44030023=工地预警-未按时间作业", | |
| 64 | -// "44030024=处理场所预警-未报开工作业", "44030025=处理场所预警-视频设备离线超时报警", "44030026=处理场所预警-三无车辆进入处理场所", "44030027=处理场所预警-未到指定的处理场所作业", | |
| 65 | -// "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶", | |
| 66 | -// "44030033=闯禁行驶", "44030034=失信车辆作业", "44030035=卫星定位异常"}; | |
| 67 | -// | |
| 68 | -// | |
| 69 | -// JSONObject jsonObject = JSONObject.parseObject(data); | |
| 70 | -// //报警时间 | |
| 71 | -// Date alarmTime = new Date(jsonObject.getLong("alarmTime")*1000L); | |
| 72 | -// | |
| 73 | -// //这一块是一天内同一工地,同一类型的报警,只报有一条数据,不重复报工,只累加 | |
| 74 | -// String nowHour = DateFormatUtils.format(alarmTime, "HH"); | |
| 75 | -// String nowDate = null; | |
| 76 | -// String tomorrowDate = null; | |
| 77 | -// if(Integer.valueOf(nowHour)<8){ | |
| 78 | -// nowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, -1), "yyyy-MM-dd"); | |
| 79 | -// tomorrowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 80 | -// }else{ | |
| 81 | -// nowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 82 | -// tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); | |
| 83 | -// } | |
| 84 | -// | |
| 85 | -// | |
| 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, violationType, 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(jsonObject.getString("alarmName")); | |
| 134 | -// //发送人 | |
| 135 | -// violationWarningInformation.setCreateBy("长沙市建筑垃圾智慧监管平台"); | |
| 136 | -// //推送对象 | |
| 137 | -// violationWarningInformation.setViolationGrade("一般类"); | |
| 138 | -// //项目名称(工地名称,处理场所名称) | |
| 139 | -// | |
| 140 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 141 | -// String describe = ""; | |
| 142 | -// String alarmTimeString = DateFormatUtils.format(alarmTime,"HH:mm"); | |
| 143 | -// //根据不同违规类型,走不同流程 | |
| 144 | -// switch (violationTypeCode) { | |
| 145 | -// case "44030020"://工地预警-未报开工作业 | |
| 146 | -// //获取报警次数 | |
| 147 | -// int count44030020 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020").toString())+1; | |
| 148 | -// //获取累计报警描述 | |
| 149 | -// String describe44030020 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe").toString(); | |
| 150 | -// if(!StringUtils.isEmpty(describe44030020)){ | |
| 151 | -// describe44030020 = describe44030020 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 152 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 153 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 154 | -// }else{ | |
| 155 | -// describe44030020 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 156 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 157 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 158 | -// } | |
| 159 | -// //报警次数等于5推送案卷 | |
| 160 | -// if(count44030020==5){ | |
| 161 | -// violationWarningInformation.setViolationObjectType("0"); | |
| 162 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 163 | -// violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 164 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 165 | -// violationWarningInformation.setDescribe(describe44030020); | |
| 166 | -// // 业务逻辑 | |
| 167 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 168 | -// } | |
| 169 | -// //次数+1 | |
| 170 | -// redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020",count44030020,24, TimeUnit.HOURS); | |
| 171 | -// //累计描述 | |
| 172 | -// redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe",describe44030020,24, TimeUnit.HOURS); | |
| 173 | -// break; | |
| 174 | -// case "44030023"://工地预警-未按时间作业 | |
| 175 | -// try{ | |
| 176 | -// //获取工地信息 | |
| 177 | -// JSONObject object = RemoteServerUtils.getConstructionLicenseById(jsonObject.getString("siteId"), trashConfig.getToken()); | |
| 178 | -// String transportEndTime = object.getString("transportEndTime"); | |
| 179 | -// String transportStartTime = object.getString("transportStartTime"); | |
| 180 | -// String endTime = manipulateTime(transportEndTime,30); | |
| 181 | -// String startTime = manipulateTime(transportStartTime,-30); | |
| 182 | -// //获取结束运输报警次数 | |
| 183 | -// String countKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportEndTime; | |
| 184 | -// int count44030023 = redisCache.getCacheObject(countKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countKey).toString())+1; | |
| 185 | -// //获取结束运输累计报警描述 | |
| 186 | -// String describeKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportEndTime; | |
| 187 | -// String describe44030023 = redisCache.getCacheObject(describeKey)==null?"":redisCache.getCacheObject(describeKey).toString(); | |
| 188 | -// //获取结束运输报警次数 | |
| 189 | -// String countEKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportStartTime; | |
| 190 | -// int countE = redisCache.getCacheObject(countEKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countEKey).toString())+1; | |
| 191 | -// //获取结束运输累计报警描述 | |
| 192 | -// String describeEKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportStartTime; | |
| 193 | -// String describeE = redisCache.getCacheObject(describeEKey)==null?"":redisCache.getCacheObject(describeEKey).toString(); | |
| 194 | -// | |
| 195 | -// if(!StringUtils.isEmpty(describe44030023)){ | |
| 196 | -// describe44030023 = describe44030023 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 197 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 198 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 199 | -// }else{ | |
| 200 | -// describe44030023 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 201 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 202 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 203 | -// } | |
| 204 | -// //报警次数等于5推送案卷 | |
| 205 | -// if(count44030023==5){ | |
| 206 | -// violationWarningInformation.setViolationObjectType("0"); | |
| 207 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 208 | -// violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 209 | -// | |
| 210 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 211 | -// violationWarningInformation.setDescribe(describe44030023); | |
| 212 | -// // 业务逻辑 | |
| 213 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 214 | -// } | |
| 215 | -// | |
| 216 | -// if(!StringUtils.isEmpty(describeE)){ | |
| 217 | -// describeE = describeE + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 218 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 219 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 220 | -// }else{ | |
| 221 | -// describeE = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 222 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 223 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 224 | -// } | |
| 225 | -// //报警次数等于5推送案卷 | |
| 226 | -// if(countE==5){ | |
| 227 | -// violationWarningInformation.setViolationObjectType("0"); | |
| 228 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 229 | -// violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 230 | -// | |
| 231 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 232 | -// violationWarningInformation.setDescribe(describeE); | |
| 233 | -// // 业务逻辑 | |
| 234 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 235 | -// } | |
| 236 | -// | |
| 237 | -// | |
| 238 | -// //判断结束运输 | |
| 239 | -// if(isTimeWithinRange(alarmTimeString,transportEndTime,endTime)){ | |
| 240 | -// //次数+1 | |
| 241 | -// redisCache.setCacheObject(countKey,count44030023,12, TimeUnit.HOURS); | |
| 242 | -// //累计描述 | |
| 243 | -// redisCache.setCacheObject(describeKey,describe44030023,12, TimeUnit.HOURS); | |
| 244 | -// }else if(isTimeWithinRange(alarmTimeString,startTime,transportStartTime)){ | |
| 245 | -// //次数+1 | |
| 246 | -// redisCache.setCacheObject(countEKey,countE,12, TimeUnit.HOURS); | |
| 247 | -// //累计描述 | |
| 248 | -// redisCache.setCacheObject(describeEKey,describeE,12, TimeUnit.HOURS); | |
| 249 | -// } | |
| 250 | -// }catch (NullPointerException e){ | |
| 251 | -// throw e; | |
| 252 | -// } | |
| 253 | -// break; | |
| 254 | -// | |
| 255 | -// case "44030030"://未激活车辆作业 | |
| 256 | -// case "44030031"://未核准作业车辆作业 | |
| 257 | -// case "44030022"://工地预警-三无车辆进入工地 | |
| 258 | -// case "44030021"://工地预警-视频设备离线超时报警 | |
| 259 | -// case "44030028"://离线运输报警(工) | |
| 260 | -// | |
| 261 | -// violationWarningInformation.setViolationObjectType("0"); | |
| 262 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 263 | -// violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 264 | -// describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 265 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 266 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 267 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 268 | -// violationWarningInformation.setDescribe(describe); | |
| 269 | -// // 业务逻辑 | |
| 270 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 271 | -// break; | |
| 272 | -// | |
| 273 | -// case "44030024"://处理场所预警-未报开工作业 | |
| 274 | -// //获取报警次数 | |
| 275 | -// int count44030024 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024").toString())+1; | |
| 276 | -// //获取累计报警描述 | |
| 277 | -// String describe44030024 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe").toString(); | |
| 278 | -// if(!StringUtils.isEmpty(describe44030024)){ | |
| 279 | -// describe44030024 = describe44030024 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 280 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 281 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 282 | -// }else{ | |
| 283 | -// describe44030024 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 284 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 285 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 286 | -// } | |
| 287 | -// //报警次数等于5推送案卷 | |
| 288 | -// if(count44030024==5){ | |
| 289 | -// violationWarningInformation.setViolationObjectType("1"); | |
| 290 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 291 | -// violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 292 | -// | |
| 293 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 294 | -// violationWarningInformation.setDescribe(describe44030024); | |
| 295 | -// // 业务逻辑 | |
| 296 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 297 | -// } | |
| 298 | -// | |
| 299 | -// | |
| 300 | -// //次数+1 | |
| 301 | -// redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024",count44030024,24, TimeUnit.HOURS); | |
| 302 | -// //累计描述 | |
| 303 | -// redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe",describe44030024,24, TimeUnit.HOURS); | |
| 304 | -// break; | |
| 305 | -// case "44030027"://处理场所预警-未到指定的处理场所作业 | |
| 306 | -// case "44030026"://处理场所预警-三无车辆进入处理场所 | |
| 307 | -// case "44030029"://离线运输报警(消) | |
| 308 | -// case "44030025"://处理场所预警-视频设备离线超时报警 | |
| 309 | -// violationWarningInformation.setViolationObjectType("1"); | |
| 310 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 311 | -// violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 312 | -// describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 313 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 314 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 315 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 316 | -// violationWarningInformation.setDescribe(describe); | |
| 317 | -// // 业务逻辑 | |
| 318 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 319 | -// break; | |
| 320 | -// case "44030032"://未按线路行驶 | |
| 321 | -// violationWarningInformation.setViolationObjectType("0"); | |
| 322 | -// violationWarningInformation.setViolationGrade("重点类"); | |
| 323 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 324 | -// describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 325 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 326 | -// jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 327 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 328 | -// violationWarningInformation.setDescribe(describe); | |
| 329 | -// // 业务逻辑 | |
| 330 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 331 | -// break; | |
| 332 | -// case "44030033"://闯禁行驶 | |
| 333 | -// violationWarningInformation.setViolationObjectType("0"); | |
| 334 | -// violationWarningInformation.setSendObject("区管理部门"); | |
| 335 | -// describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 336 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType(); | |
| 337 | -// //设置公司简称 | |
| 338 | -// for(Object o:company1){ | |
| 339 | -// JSONObject jo = (JSONObject) o; | |
| 340 | -// if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){ | |
| 341 | -// violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 342 | -// } | |
| 343 | -// } | |
| 344 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 345 | -// violationWarningInformation.setDescribe(describe); | |
| 346 | -// // 业务逻辑 | |
| 347 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 348 | -// break; | |
| 349 | -// | |
| 350 | -// case "44030034"://失信车辆作业 | |
| 351 | -// violationWarningInformation.setViolationObjectType("2"); | |
| 352 | -// violationWarningInformation.setSendObject("运输企业"); | |
| 353 | -// describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 354 | -// + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType(); | |
| 355 | -// //设置公司简称 | |
| 356 | -// for(Object o:company1){ | |
| 357 | -// JSONObject jo = (JSONObject) o; | |
| 358 | -// if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){ | |
| 359 | -// violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 360 | -// } | |
| 361 | -// } | |
| 362 | -// violationWarningInformation.setCreateTime(alarmTime); | |
| 363 | -// violationWarningInformation.setDescribe(describe); | |
| 364 | -// // 业务逻辑 | |
| 365 | -// violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 366 | -// break; | |
| 367 | -// } | |
| 368 | -// | |
| 369 | -// | |
| 370 | -// | |
| 371 | -// | |
| 372 | -// } else { | |
| 373 | -// String describe = ""; | |
| 374 | -// if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){ | |
| 375 | -// describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 376 | -// + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName"); | |
| 377 | -// }else{ | |
| 378 | -// describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 379 | -// + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 380 | -// jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName"); | |
| 381 | -// } | |
| 382 | -// | |
| 383 | -// violationWarningInformation1.setDescribe(describe); | |
| 384 | -// SpringUtils.getBean(ViolationWarningInformationMapper.class).updateViolationWarningInformation(violationWarningInformation1); | |
| 385 | -// } | |
| 386 | -// //kafka消费成功 | |
| 387 | -// KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 388 | -// kafkaCompensation.setId(Long.valueOf(id)); | |
| 389 | -// kafkaCompensation.setStatus(1); | |
| 390 | -// SpringUtils.getBean(KafkaCompensationMapper.class).updateKafkaCompensation(kafkaCompensation); | |
| 391 | -// | |
| 392 | -// } | |
| 393 | -// | |
| 394 | -// public String insertKafkaCompensation(String data){ | |
| 395 | -// KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 396 | -// kafkaCompensation.setData(data); | |
| 397 | -// kafkaCompensation.setCreateTime(DateUtils.getNowDate()); | |
| 398 | -// kafkaCompensation.setStatus(0); | |
| 399 | -// SpringUtils.getBean(KafkaCompensationMapper.class).insertKafkaCompensation(kafkaCompensation); | |
| 400 | -// return kafkaCompensation.getId().toString(); | |
| 401 | -// } | |
| 402 | -// | |
| 403 | -// /** | |
| 404 | -// * 对HH:mm格式时间进行分钟的加减 | |
| 405 | -// * @param timeStr | |
| 406 | -// * @param minutesToAddOrSubtract | |
| 407 | -// * @return | |
| 408 | -// */ | |
| 409 | -// public String manipulateTime(String timeStr, int minutesToAddOrSubtract) { | |
| 410 | -// // 定义输入时间格式的日期时间格式器 | |
| 411 | -// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 412 | -// | |
| 413 | -// // 解析输入的时间字符串为 LocalTime 对象 | |
| 414 | -// LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 415 | -// | |
| 416 | -// // 执行加减分钟的操作 | |
| 417 | -// LocalTime modifiedTime = time.plusMinutes(minutesToAddOrSubtract); | |
| 418 | -// | |
| 419 | -// // 将修改后的时间格式化为 HH:mm 格式 | |
| 420 | -// String formattedModifiedTime = modifiedTime.format(formatter); | |
| 421 | -// | |
| 422 | -// return formattedModifiedTime; | |
| 423 | -// } | |
| 424 | -// | |
| 425 | -// /** | |
| 426 | -// * 判断timeStr是否在startTimeStr-endTimeStr区间 | |
| 427 | -// * @param timeStr | |
| 428 | -// * @param startTimeStr | |
| 429 | -// * @param endTimeStr | |
| 430 | -// * @return | |
| 431 | -// */ | |
| 432 | -// public boolean isTimeWithinRange(String timeStr, String startTimeStr, String endTimeStr) { | |
| 433 | -// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 434 | -// LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 435 | -// LocalTime startTime = LocalTime.parse(startTimeStr, formatter); | |
| 436 | -// LocalTime endTime = LocalTime.parse(endTimeStr, formatter); | |
| 437 | -// | |
| 438 | -// return !time.isBefore(startTime) && !time.isAfter(endTime); | |
| 439 | -// | |
| 440 | -// } | |
| 441 | -//} | |
| 1 | +package com.trash.casefile.kafka; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSONArray; | |
| 4 | +import com.alibaba.fastjson.JSONObject; | |
| 5 | +import com.trash.casefile.domain.KafkaCompensation; | |
| 6 | +import com.trash.casefile.domain.ViolationWarningInformation; | |
| 7 | +import com.trash.casefile.mapper.KafkaCompensationMapper; | |
| 8 | +import com.trash.casefile.mapper.ViolationWarningInformationMapper; | |
| 9 | +import com.trash.casefile.service.IViolationWarningInformationService; | |
| 10 | +import com.trash.common.config.trashConfig; | |
| 11 | +import com.trash.common.core.redis.RedisCache; | |
| 12 | +import com.trash.common.utils.DateUtils; | |
| 13 | +import com.trash.common.utils.RemoteServerUtils; | |
| 14 | +import com.trash.common.utils.StringUtils; | |
| 15 | +import com.trash.common.utils.spring.SpringUtils; | |
| 16 | +import com.trash.framework.web.service.SysLoginService; | |
| 17 | +import org.apache.commons.lang3.time.DateFormatUtils; | |
| 18 | +import org.apache.kafka.clients.consumer.ConsumerRecord; | |
| 19 | +import org.slf4j.Logger; | |
| 20 | +import org.slf4j.LoggerFactory; | |
| 21 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 22 | +import org.springframework.kafka.annotation.KafkaListener; | |
| 23 | +import org.springframework.kafka.support.Acknowledgment; | |
| 24 | +import org.springframework.kafka.support.KafkaHeaders; | |
| 25 | +import org.springframework.messaging.handler.annotation.Header; | |
| 26 | +import org.springframework.messaging.handler.annotation.Payload; | |
| 27 | +import org.springframework.stereotype.Component; | |
| 28 | +import org.springframework.transaction.annotation.Transactional; | |
| 29 | + | |
| 30 | +import java.io.IOException; | |
| 31 | +import java.time.LocalTime; | |
| 32 | +import java.time.format.DateTimeFormatter; | |
| 33 | +import java.util.*; | |
| 34 | +import java.util.concurrent.TimeUnit; | |
| 35 | + | |
| 36 | +@Component | |
| 37 | +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 | + log.info("kafka消费数据成功,offset:"+ record.offset() +",data:" + record.value()); | |
| 46 | + String id = insertKafkaCompensation(record.value().toString()); | |
| 47 | + autoViolationWarning(record.value().toString(),id); | |
| 48 | + //手动提交offset | |
| 49 | + ack.acknowledge(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Autowired | |
| 53 | + trashConfig trashConfig; | |
| 54 | + | |
| 55 | + @Autowired | |
| 56 | + SysLoginService loginService; | |
| 57 | + | |
| 58 | + @Autowired | |
| 59 | + RedisCache redisCache; | |
| 60 | + | |
| 61 | + public void autoViolationWarning(String data,String id) throws InterruptedException, IOException { | |
| 62 | + | |
| 63 | + String[] code = {"44030020=工地预警-未报开工作业", "44030021=工地预警-视频设备离线超时报警", "44030022=工地预警-三无车辆进入工地", "44030023=工地预警-未按时间作业", | |
| 64 | + "44030024=处理场所预警-未报开工作业", "44030025=处理场所预警-视频设备离线超时报警", "44030026=处理场所预警-三无车辆进入处理场所", "44030027=处理场所预警-未到指定的处理场所作业", | |
| 65 | + "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶", | |
| 66 | + "44030033=闯禁行驶", "44030034=失信车辆作业", "44030035=卫星定位异常"}; | |
| 67 | + | |
| 68 | + | |
| 69 | + JSONObject jsonObject = JSONObject.parseObject(data); | |
| 70 | + //报警时间 | |
| 71 | + Date alarmTime = new Date(jsonObject.getLong("alarmTime")*1000L); | |
| 72 | + | |
| 73 | + //这一块是一天内同一工地,同一类型的报警,只报有一条数据,不重复报工,只累加 | |
| 74 | + String nowHour = DateFormatUtils.format(alarmTime, "HH"); | |
| 75 | + String nowDate = null; | |
| 76 | + String tomorrowDate = null; | |
| 77 | + if(Integer.valueOf(nowHour)<8){ | |
| 78 | + nowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, -1), "yyyy-MM-dd"); | |
| 79 | + tomorrowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 80 | + }else{ | |
| 81 | + nowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | |
| 82 | + tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); | |
| 83 | + } | |
| 84 | + | |
| 85 | + | |
| 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, violationType, 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(jsonObject.getString("alarmName")); | |
| 134 | + //发送人 | |
| 135 | + violationWarningInformation.setCreateBy("长沙市建筑垃圾智慧监管平台"); | |
| 136 | + //推送对象 | |
| 137 | + violationWarningInformation.setViolationGrade("一般类"); | |
| 138 | + //项目名称(工地名称,处理场所名称) | |
| 139 | + | |
| 140 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 141 | + String describe = ""; | |
| 142 | + String alarmTimeString = DateFormatUtils.format(alarmTime,"HH:mm"); | |
| 143 | + //根据不同违规类型,走不同流程 | |
| 144 | + switch (violationTypeCode) { | |
| 145 | + case "44030020"://工地预警-未报开工作业 | |
| 146 | + //获取报警次数 | |
| 147 | + int count44030020 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020").toString())+1; | |
| 148 | + //获取累计报警描述 | |
| 149 | + String describe44030020 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe").toString(); | |
| 150 | + if(!StringUtils.isEmpty(describe44030020)){ | |
| 151 | + describe44030020 = describe44030020 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 152 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 153 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 154 | + }else{ | |
| 155 | + describe44030020 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 156 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 157 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 158 | + } | |
| 159 | + //报警次数等于5推送案卷 | |
| 160 | + if(count44030020==5){ | |
| 161 | + violationWarningInformation.setViolationObjectType("0"); | |
| 162 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 163 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 164 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 165 | + violationWarningInformation.setDescribe(describe44030020); | |
| 166 | + // 业务逻辑 | |
| 167 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 168 | + } | |
| 169 | + //次数+1 | |
| 170 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020",count44030020,24, TimeUnit.HOURS); | |
| 171 | + //累计描述 | |
| 172 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe",describe44030020,24, TimeUnit.HOURS); | |
| 173 | + break; | |
| 174 | + case "44030023"://工地预警-未按时间作业 | |
| 175 | + try{ | |
| 176 | + //获取工地信息 | |
| 177 | + JSONObject object = RemoteServerUtils.getConstructionLicenseById(jsonObject.getString("siteId"), trashConfig.getToken()); | |
| 178 | + String transportEndTime = object.getString("transportEndTime"); | |
| 179 | + String transportStartTime = object.getString("transportStartTime"); | |
| 180 | + String endTime = manipulateTime(transportEndTime,30); | |
| 181 | + String startTime = manipulateTime(transportStartTime,-30); | |
| 182 | + //获取结束运输报警次数 | |
| 183 | + String countKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportEndTime; | |
| 184 | + int count44030023 = redisCache.getCacheObject(countKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countKey).toString())+1; | |
| 185 | + //获取结束运输累计报警描述 | |
| 186 | + String describeKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportEndTime; | |
| 187 | + String describe44030023 = redisCache.getCacheObject(describeKey)==null?"":redisCache.getCacheObject(describeKey).toString(); | |
| 188 | + //获取结束运输报警次数 | |
| 189 | + String countEKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportStartTime; | |
| 190 | + int countE = redisCache.getCacheObject(countEKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countEKey).toString())+1; | |
| 191 | + //获取结束运输累计报警描述 | |
| 192 | + String describeEKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportStartTime; | |
| 193 | + String describeE = redisCache.getCacheObject(describeEKey)==null?"":redisCache.getCacheObject(describeEKey).toString(); | |
| 194 | + | |
| 195 | + if(!StringUtils.isEmpty(describe44030023)){ | |
| 196 | + describe44030023 = describe44030023 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 197 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 198 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 199 | + }else{ | |
| 200 | + describe44030023 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 201 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 202 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 203 | + } | |
| 204 | + //报警次数等于5推送案卷 | |
| 205 | + if(count44030023==5){ | |
| 206 | + violationWarningInformation.setViolationObjectType("0"); | |
| 207 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 208 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 209 | + | |
| 210 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 211 | + violationWarningInformation.setDescribe(describe44030023); | |
| 212 | + // 业务逻辑 | |
| 213 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 214 | + } | |
| 215 | + | |
| 216 | + if(!StringUtils.isEmpty(describeE)){ | |
| 217 | + describeE = describeE + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 218 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 219 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 220 | + }else{ | |
| 221 | + describeE = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 222 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 223 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 224 | + } | |
| 225 | + //报警次数等于5推送案卷 | |
| 226 | + if(countE==5){ | |
| 227 | + violationWarningInformation.setViolationObjectType("0"); | |
| 228 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 229 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 230 | + | |
| 231 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 232 | + violationWarningInformation.setDescribe(describeE); | |
| 233 | + // 业务逻辑 | |
| 234 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 235 | + } | |
| 236 | + | |
| 237 | + | |
| 238 | + //判断结束运输 | |
| 239 | + if(isTimeWithinRange(alarmTimeString,transportEndTime,endTime)){ | |
| 240 | + //次数+1 | |
| 241 | + redisCache.setCacheObject(countKey,count44030023,12, TimeUnit.HOURS); | |
| 242 | + //累计描述 | |
| 243 | + redisCache.setCacheObject(describeKey,describe44030023,12, TimeUnit.HOURS); | |
| 244 | + }else if(isTimeWithinRange(alarmTimeString,startTime,transportStartTime)){ | |
| 245 | + //次数+1 | |
| 246 | + redisCache.setCacheObject(countEKey,countE,12, TimeUnit.HOURS); | |
| 247 | + //累计描述 | |
| 248 | + redisCache.setCacheObject(describeEKey,describeE,12, TimeUnit.HOURS); | |
| 249 | + } | |
| 250 | + }catch (NullPointerException e){ | |
| 251 | + throw e; | |
| 252 | + } | |
| 253 | + break; | |
| 254 | + | |
| 255 | + case "44030030"://未激活车辆作业 | |
| 256 | + case "44030031"://未核准作业车辆作业 | |
| 257 | + case "44030022"://工地预警-三无车辆进入工地 | |
| 258 | + case "44030021"://工地预警-视频设备离线超时报警 | |
| 259 | + case "44030028"://离线运输报警(工) | |
| 260 | + | |
| 261 | + violationWarningInformation.setViolationObjectType("0"); | |
| 262 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 263 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 264 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 265 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 266 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 267 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 268 | + violationWarningInformation.setDescribe(describe); | |
| 269 | + // 业务逻辑 | |
| 270 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 271 | + break; | |
| 272 | + | |
| 273 | + case "44030024"://处理场所预警-未报开工作业 | |
| 274 | + //获取报警次数 | |
| 275 | + int count44030024 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024").toString())+1; | |
| 276 | + //获取累计报警描述 | |
| 277 | + String describe44030024 = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe").toString(); | |
| 278 | + if(!StringUtils.isEmpty(describe44030024)){ | |
| 279 | + describe44030024 = describe44030024 + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 280 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 281 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 282 | + }else{ | |
| 283 | + describe44030024 = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 284 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 285 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 286 | + } | |
| 287 | + //报警次数等于5推送案卷 | |
| 288 | + if(count44030024==5){ | |
| 289 | + violationWarningInformation.setViolationObjectType("1"); | |
| 290 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 291 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 292 | + | |
| 293 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 294 | + violationWarningInformation.setDescribe(describe44030024); | |
| 295 | + // 业务逻辑 | |
| 296 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 297 | + } | |
| 298 | + | |
| 299 | + | |
| 300 | + //次数+1 | |
| 301 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024",count44030024,24, TimeUnit.HOURS); | |
| 302 | + //累计描述 | |
| 303 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe",describe44030024,24, TimeUnit.HOURS); | |
| 304 | + break; | |
| 305 | + case "44030027"://处理场所预警-未到指定的处理场所作业 | |
| 306 | + case "44030026"://处理场所预警-三无车辆进入处理场所 | |
| 307 | + case "44030029"://离线运输报警(消) | |
| 308 | + case "44030025"://处理场所预警-视频设备离线超时报警 | |
| 309 | + violationWarningInformation.setViolationObjectType("1"); | |
| 310 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 311 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | |
| 312 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 313 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 314 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 315 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 316 | + violationWarningInformation.setDescribe(describe); | |
| 317 | + // 业务逻辑 | |
| 318 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 319 | + break; | |
| 320 | + case "44030032"://未按线路行驶 | |
| 321 | + violationWarningInformation.setViolationObjectType("0"); | |
| 322 | + violationWarningInformation.setViolationGrade("重点类"); | |
| 323 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 324 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 325 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 326 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | |
| 327 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 328 | + violationWarningInformation.setDescribe(describe); | |
| 329 | + // 业务逻辑 | |
| 330 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 331 | + break; | |
| 332 | + case "44030033"://闯禁行驶 | |
| 333 | + violationWarningInformation.setViolationObjectType("0"); | |
| 334 | + violationWarningInformation.setSendObject("区管理部门"); | |
| 335 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 336 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType(); | |
| 337 | + //设置公司简称 | |
| 338 | + for(Object o:company1){ | |
| 339 | + JSONObject jo = (JSONObject) o; | |
| 340 | + if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){ | |
| 341 | + violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 342 | + } | |
| 343 | + } | |
| 344 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 345 | + violationWarningInformation.setDescribe(describe); | |
| 346 | + // 业务逻辑 | |
| 347 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 348 | + break; | |
| 349 | + | |
| 350 | + case "44030034"://失信车辆作业 | |
| 351 | + violationWarningInformation.setViolationObjectType("2"); | |
| 352 | + violationWarningInformation.setSendObject("运输企业"); | |
| 353 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 354 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType(); | |
| 355 | + //设置公司简称 | |
| 356 | + for(Object o:company1){ | |
| 357 | + JSONObject jo = (JSONObject) o; | |
| 358 | + if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){ | |
| 359 | + violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | |
| 360 | + } | |
| 361 | + } | |
| 362 | + violationWarningInformation.setCreateTime(alarmTime); | |
| 363 | + violationWarningInformation.setDescribe(describe); | |
| 364 | + // 业务逻辑 | |
| 365 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | |
| 366 | + break; | |
| 367 | + } | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + } else { | |
| 373 | + String describe = ""; | |
| 374 | + if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){ | |
| 375 | + describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 376 | + + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName"); | |
| 377 | + }else{ | |
| 378 | + describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | |
| 379 | + + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" + | |
| 380 | + jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName"); | |
| 381 | + } | |
| 382 | + | |
| 383 | + violationWarningInformation1.setDescribe(describe); | |
| 384 | + SpringUtils.getBean(ViolationWarningInformationMapper.class).updateViolationWarningInformation(violationWarningInformation1); | |
| 385 | + } | |
| 386 | + //kafka消费成功 | |
| 387 | + KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 388 | + kafkaCompensation.setId(Long.valueOf(id)); | |
| 389 | + kafkaCompensation.setStatus(1); | |
| 390 | + SpringUtils.getBean(KafkaCompensationMapper.class).updateKafkaCompensation(kafkaCompensation); | |
| 391 | + | |
| 392 | + } | |
| 393 | + | |
| 394 | + public String insertKafkaCompensation(String data){ | |
| 395 | + KafkaCompensation kafkaCompensation = new KafkaCompensation(); | |
| 396 | + kafkaCompensation.setData(data); | |
| 397 | + kafkaCompensation.setCreateTime(DateUtils.getNowDate()); | |
| 398 | + kafkaCompensation.setStatus(0); | |
| 399 | + SpringUtils.getBean(KafkaCompensationMapper.class).insertKafkaCompensation(kafkaCompensation); | |
| 400 | + return kafkaCompensation.getId().toString(); | |
| 401 | + } | |
| 402 | + | |
| 403 | + /** | |
| 404 | + * 对HH:mm格式时间进行分钟的加减 | |
| 405 | + * @param timeStr | |
| 406 | + * @param minutesToAddOrSubtract | |
| 407 | + * @return | |
| 408 | + */ | |
| 409 | + public String manipulateTime(String timeStr, int minutesToAddOrSubtract) { | |
| 410 | + // 定义输入时间格式的日期时间格式器 | |
| 411 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 412 | + | |
| 413 | + // 解析输入的时间字符串为 LocalTime 对象 | |
| 414 | + LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 415 | + | |
| 416 | + // 执行加减分钟的操作 | |
| 417 | + LocalTime modifiedTime = time.plusMinutes(minutesToAddOrSubtract); | |
| 418 | + | |
| 419 | + // 将修改后的时间格式化为 HH:mm 格式 | |
| 420 | + String formattedModifiedTime = modifiedTime.format(formatter); | |
| 421 | + | |
| 422 | + return formattedModifiedTime; | |
| 423 | + } | |
| 424 | + | |
| 425 | + /** | |
| 426 | + * 判断timeStr是否在startTimeStr-endTimeStr区间 | |
| 427 | + * @param timeStr | |
| 428 | + * @param startTimeStr | |
| 429 | + * @param endTimeStr | |
| 430 | + * @return | |
| 431 | + */ | |
| 432 | + public boolean isTimeWithinRange(String timeStr, String startTimeStr, String endTimeStr) { | |
| 433 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | |
| 434 | + LocalTime time = LocalTime.parse(timeStr, formatter); | |
| 435 | + LocalTime startTime = LocalTime.parse(startTimeStr, formatter); | |
| 436 | + LocalTime endTime = LocalTime.parse(endTimeStr, formatter); | |
| 437 | + | |
| 438 | + return !time.isBefore(startTime) && !time.isAfter(endTime); | |
| 439 | + | |
| 440 | + } | |
| 441 | +} | ... | ... |