| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.LocalDateTimeUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.utils.bean.BeanUtils; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.map.constant.I18nKeyConstant; |
| | | import com.xiaopeng.map.service.*; |
| | | import com.xiaopeng.map.service.serviceimpl.BootCommonService; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.xiaopeng.map.service.serviceimpl.XpElectronicFenceServiceImpl.getPinyinInitials; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "新增电子围栏") |
| | | public R add(@Valid @RequestBody ElectronicFenceAddDto dto) { |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ELECTRONIC_FENCE_MANAGEMENT, |
| | | operationType = AdminOperationType.ADD, |
| | | content = "新增电子围栏", |
| | | appendRequestData = true |
| | | ) |
| | | public R add(@Validated @RequestBody ElectronicFenceAddDto dto) { |
| | | validateFenceTime(dto.getStatus(), dto.getEffectType(), dto.getEffectTime(), dto.getFailureType(), dto.getFailureTime()); |
| | | return xpElectronicFenceService.addElectronic(dto); |
| | | } |
| | |
| | | @PostMapping("/updateStatus") |
| | | @ResponseBody |
| | | @ApiOperation(value = "修改状态") |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ELECTRONIC_FENCE_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | content = "修改电子围栏状态", |
| | | appendRequestData = true |
| | | ) |
| | | public R updateStatus(@RequestBody ElectronicFenceAreaUpdateStatusDto dto) { |
| | | XpElectronicFenceArea electronicFenceArea = xpElectronicFenceAreaService.getById(dto.getId()); |
| | | if (electronicFenceArea == null) { |
| | |
| | | |
| | | ElectronicFenceDetailVo.Numbers pointsNumbers = new ElectronicFenceDetailVo.Numbers(); |
| | | if(CollUtil.isNotEmpty(pointList)){ |
| | | for (XpPoint xpPoint : pointList) { |
| | | if (xpPoint.getOperationStatus() == 1) { |
| | | pointsNumbers.setPendingLaunch(pointsNumbers.getPendingLaunch() + 1); |
| | | } else if (xpPoint.getOperationStatus() == 2) { |
| | | pointsNumbers.setStartingUp(pointsNumbers.getStartingUp() + 1); |
| | | } |
| | | else if (xpPoint.getOperationStatus() == 3) { |
| | | pointsNumbers.setExpired(pointsNumbers.getExpired() + 1); |
| | | } |
| | | else if (xpPoint.getOperationStatus() == 4) { |
| | | pointsNumbers.setDisabled(pointsNumbers.getDisabled() + 1); |
| | | } |
| | | } |
| | | LocalTime localTime = LocalTime.now(); |
| | | //总数 |
| | | pointsNumbers.setTotalNum(pointList.size()); |
| | | //待测试 |
| | | long count = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 1 && xpPoint.getVerificationStatus() == 1).count(); |
| | | pointsNumbers.setToBeTested(Integer.parseInt(count+"")); |
| | | //测试中 |
| | | long count2 = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 1 && xpPoint.getVerificationStatus() == 2).count(); |
| | | pointsNumbers.setTesting(Integer.parseInt(count2+"")); |
| | | //测试不通过 |
| | | long count3 = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 1 && xpPoint.getVerificationStatus() == 4).count(); |
| | | pointsNumbers.setTestNotPass(Integer.parseInt(count3+"")); |
| | | //待启用 |
| | | long count4 = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 1 && (xpPoint.getVerificationStatus() == 3 || xpPoint.getVerificationStatus() == 5)).count(); |
| | | pointsNumbers.setPendingLaunch(Integer.parseInt(count4+"")); |
| | | //启用中 |
| | | long count5 = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 2 && xpPoint.getVerificationStatus() == 5).count(); |
| | | pointsNumbers.setStartingUp(Integer.parseInt(count5+"")); |
| | | //已停用 |
| | | long count6 = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 3 && xpPoint.getVerificationStatus() == 5).count(); |
| | | pointsNumbers.setDisabled(Integer.parseInt(count6+"")); |
| | | //已失效 |
| | | long count7 = pointList.stream().filter(xpPoint -> xpPoint.getOperationStatus() == 4 && xpPoint.getVerificationStatus() == 5).count(); |
| | | pointsNumbers.setExpired(Integer.parseInt(count7+"")); |
| | | } |
| | | res.setPointsNumbers(pointsNumbers); |
| | | } |
| | |
| | | |
| | | ElectronicFenceDetailVo.Numbers stationNumbers = new ElectronicFenceDetailVo.Numbers(); |
| | | if(CollUtil.isNotEmpty(stationList)){ |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | LocalTime localTime = LocalTime.now(); |
| | | //status 场站状态 0=草稿 1=待启用 2=启用中 3=已停用 4=失效 |
| | | for (XpStation xpStation : stationList) { |
| | | switch (xpStation.getStatus()) { |
| | | case 0: |
| | | stationNumbers.setDraft(stationNumbers.getDraft() + 1); |
| | | break; |
| | | case 1: |
| | | stationNumbers.setPendingLaunch(stationNumbers.getPendingLaunch() + 1); |
| | | break; |
| | | case 2: //启动中 判断 待启动的状态 ,当前时间在 运营时间 内是启动中,否则是 待启动 |
| | | |
| | | boolean stationOperation = bootCommonService.getStationOperation(localTime, xpStation.getOperationType(), xpStation.getEffectivePeriod(), xpStation.getEffectiveTimePeriod(), xpStation.getFenceOperationStrategy()); |
| | | if (stationOperation) { |
| | | stationNumbers.setStartingUp(stationNumbers.getStartingUp() + 1); |
| | | }else{ |
| | | stationNumbers.setPendingLaunch(stationNumbers.getPendingLaunch() + 1); |
| | | } |
| | | break; |
| | | case 3: |
| | | stationNumbers.setDisabled(stationNumbers.getDisabled() + 1); |
| | | break; |
| | | case 4: |
| | | stationNumbers.setExpired(stationNumbers.getExpired() + 1); |
| | | break; |
| | | } |
| | | } |
| | | stationNumbers.setTotalNum(stationList.size()); |
| | | //待生效 |
| | | long count1 = stationList.stream().filter(xpStation -> xpStation.getStatus() == 1).count(); |
| | | stationNumbers.setPendingLaunch(Integer.parseInt(count1+"")); |
| | | //启用中 |
| | | long count2 = stationList.stream().filter(xpStation -> xpStation.getStatus() == 2).count(); |
| | | stationNumbers.setStartingUp(Integer.parseInt(count2+"")); |
| | | //已停用 |
| | | long count3 = stationList.stream().filter(xpStation -> xpStation.getStatus() == 3).count(); |
| | | stationNumbers.setDisabled(Integer.parseInt(count3+"")); |
| | | //已失效 |
| | | long count4 = stationList.stream().filter(xpStation -> xpStation.getStatus() == 4).count(); |
| | | stationNumbers.setExpired(Integer.parseInt(count4+"")); |
| | | } |
| | | res.setStationNumbers(stationNumbers); |
| | | return R.ok(res); |
| | |
| | | @ApiOperation(value = "编辑电子围栏") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ELECTRONIC_FENCE_MANAGEMENT, |
| | | operationType = AdminOperationType.EDIT, |
| | | content = "编辑电子围栏", |
| | | appendRequestData = true |
| | | ) |
| | | public R edit(@Validated @RequestBody ElectronicFenceUpdateDto dto) { |
| | | validateFenceTime(dto.getStatus(), dto.getEffectType(), dto.getEffectTime(), dto.getFailureType(), dto.getFailureTime()); |
| | | return xpElectronicFenceService.editElectronic(dto); |
| | |
| | | disableCount++; |
| | | } |
| | | } |
| | | |
| | | List<XpStation> listByElectronicId = xpStationService.findListByElectronicId(dto.getId()); |
| | | if(CollUtil.isNotEmpty(listByElectronicId)){ |
| | | |
| | | for (XpStation bean : listByElectronicId) { |
| | | if (StrUtil.isBlank(bean.getEffectiveTimePeriod())) { |
| | | continue; |
| | | } |
| | | List<OperationStrategyIndex.TimeInterval> pointIntervals = OperationStrategyIndex.parsePointEffectiveTimePeriod(bean.getEffectiveTimePeriod()); |
| | | if (pointIntervals.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | boolean shouldDisable = !newIndex.isPointScheduleWithin(pointIntervals); |
| | | if (shouldDisable) { |
| | | disableCount++; |
| | | } |
| | | } |
| | | } |
| | | return R.ok(disableCount); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "复制电子围栏") |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.ELECTRONIC_FENCE_MANAGEMENT, |
| | | operationType = AdminOperationType.ADD, |
| | | contentExpression = "'复制电子围栏,id=' + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | public R<Long> copy(@RequestParam("id") Integer id) { |
| | | XpElectronicFence electronicFence = xpElectronicFenceService.getById(id); |
| | | if (electronicFence.getStatus()==2){ |