| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.alibaba.excel.annotation.format.DateTimeFormat; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.config.PlatformConfig; |
| | | import com.ycl.config.ServerConfig; |
| | | import com.ycl.exception.ServiceException; |
| | | import com.ycl.platform.domain.entity.*; |
| | | import com.ycl.platform.domain.excel.PointExport; |
| | |
| | | import com.ycl.platform.service.WorkOrderAuditingRecordService; |
| | | import com.ycl.platform.service.WorkOrderService; |
| | | import com.ycl.platform.service.YwPointService; |
| | | import com.ycl.platform.wvp.StreamContent; |
| | | import com.ycl.platform.wvp.WVPResult; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.domain.SysConfig; |
| | | import com.ycl.system.entity.SysDictData; |
| | | import com.ycl.system.mapper.SysConfigMapper; |
| | | import com.ycl.system.mapper.SysDictDataMapper; |
| | | import com.ycl.system.model.LoginUser; |
| | | import com.ycl.system.page.PageUtil; |
| | | import com.ycl.utils.DateUtils; |
| | |
| | | import com.ycl.utils.http.HttpUtils; |
| | | import com.ycl.utils.redis.RedisCache; |
| | | import com.ycl.utils.uuid.IdUtils; |
| | | import constant.ApiConstants; |
| | | import constant.CheckConstants; |
| | | import constant.Constants; |
| | | import constant.RedisConstant; |
| | | import enumeration.ErrorType; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.bytedeco.javacv.*; |
| | | import org.bytedeco.javacv.FFmpegFrameGrabber; |
| | | import org.bytedeco.javacv.Frame; |
| | | import org.bytedeco.javacv.FrameGrabber; |
| | | import org.bytedeco.javacv.OpenCVFrameConverter; |
| | | import org.bytedeco.opencv.global.opencv_imgcodecs; |
| | | import org.bytedeco.opencv.opencv_core.Mat; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | import pojo.CascadeOption; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.swing.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.net.URLDecoder; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | |
| | | public Result selectWorkOrderWhiteList(WorkOrderWhiteQuery query) { |
| | | IPage<WorkOrderWhite> page = PageUtil.getPage(query, WorkOrderWhite.class); |
| | | workOrderWhiteMapper.page(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | List<WorkOrderWhite> records = page.getRecords(); |
| | | records.forEach(white-> { |
| | | List<String> errorTextList = new ArrayList<>(); |
| | | List<String> errorTypeList = JSONArray.parseArray(white.getErrorType(), String.class); |
| | | errorTypeList.forEach(error->{ |
| | | String errorText = ErrorType.getDescriptionByValue(error); |
| | | errorTextList.add(errorText); |
| | | }); |
| | | white.setErrorType(String.join(",", errorTextList)); |
| | | }); |
| | | return Result.ok().data(records).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Result addWorkOrderWhite(WorkOrderWhite workOrderWhite) { |
| | | // 通过设备编码查询设备信息 |
| | | YwPoint ywPoint = ywPointService.selectBySerialNumber(workOrderWhite.getSerialNumber()); |
| | | // 新增白名单设备记录 |
| | | if (ywPoint == null){ |
| | | return Result.error("设备不存在"); |
| | | } |
| | | // 检查是否已经存在该白名单 |
| | | WorkOrderWhite flag = workOrderWhiteMapper.selectBySerialNumber(workOrderWhite.getSerialNumber()); |
| | | if (flag != null) { |
| | | return Result.error("该设备已存在白名单"); |
| | | } else { |
| | | workOrderWhite.setPointName(ywPoint.getPointName()); |
| | | List<String> errorTypeList = workOrderWhite.getErrorTypeList(); |
| | | workOrderWhite.setErrorType(JSONArray.toJSONString(errorTypeList)); |
| | | workOrderWhite.setCreateBy(SecurityUtils.getUsername()); |
| | | workOrderWhiteMapper.insert(workOrderWhite); |
| | | return Result.ok(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改工单白名单 |
| | | * |
| | | * @param workOrderWhite 白色工单 |
| | | * @return {@link Result } |
| | | * @author |
| | | */ |
| | | @Override |
| | | public Result updateWorkOrderWhite(WorkOrderWhite workOrderWhite) { |
| | | WorkOrderWhite white = workOrderWhiteMapper.selectBySerialNumber(workOrderWhite.getSerialNumber()); |
| | | workOrderWhite.setId(white.getId()); |
| | | List<String> errorTypeList = workOrderWhite.getErrorTypeList(); |
| | | workOrderWhite.setErrorType(JSONArray.toJSONString(errorTypeList)); |
| | | workOrderWhiteMapper.updateById(workOrderWhite); |
| | | return Result.ok(); |
| | | } |
| | | /** |
| | | * 批量删除工单白名单 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public void batchImportWhite(List<PointExport> dataList) { |
| | | // 获得所有需要新增的白名单对象 |
| | | List<WorkOrderWhite> whitelist = dataList.stream().map(pointExport -> |
| | | new WorkOrderWhite(pointExport.getSerialNumber(), pointExport.getPointName(), SecurityUtils.getUsername())) |
| | | .collect(Collectors.toList()); |
| | | // 获得所有已存在的白名单设备编码 |
| | | List<String> serialNumbers = workOrderWhiteMapper.selectList().stream().map(WorkOrderWhite::getSerialNumber).collect(Collectors.toList()); |
| | | // 筛选出新增、修改的白名单对象 |
| | | List<WorkOrderWhite> updateWhiteList = whitelist.stream().filter(white -> serialNumbers.contains(white.getSerialNumber())).collect(Collectors.toList()); |
| | | List<WorkOrderWhite> insertWhiteList = whitelist.stream().filter(white ->!serialNumbers.contains(white.getSerialNumber())).collect(Collectors.toList()); |
| | | // 新增/修改白名单设备记录 |
| | | updateWhiteList.stream().forEach(white -> workOrderWhiteMapper.updateBySerialNumber(white)); |
| | | insertWhiteList.stream().forEach(white -> workOrderWhiteMapper.insert(white)); |
| | | // // 获得所有需要新增的白名单对象 |
| | | // List<WorkOrderWhite> whitelist = dataList.stream().map(pointExport -> |
| | | // new WorkOrderWhite(pointExport.getSerialNumber(), pointExport.getPointName(), SecurityUtils.getUsername())) |
| | | // .collect(Collectors.toList()); |
| | | // // 获得所有已存在的白名单设备编码 |
| | | // List<String> serialNumbers = workOrderWhiteMapper.selectList().stream().map(WorkOrderWhite::getSerialNumber).collect(Collectors.toList()); |
| | | // // 筛选出新增、修改的白名单对象 |
| | | // List<WorkOrderWhite> updateWhiteList = whitelist.stream().filter(white -> serialNumbers.contains(white.getSerialNumber())).collect(Collectors.toList()); |
| | | // List<WorkOrderWhite> insertWhiteList = whitelist.stream().filter(white ->!serialNumbers.contains(white.getSerialNumber())).collect(Collectors.toList()); |
| | | // // 新增/修改白名单设备记录 |
| | | // updateWhiteList.stream().forEach(white -> workOrderWhiteMapper.updateBySerialNumber(white)); |
| | | // insertWhiteList.stream().forEach(white -> workOrderWhiteMapper.insert(white)); |
| | | } |
| | | |
| | | /** |
| | |
| | | results.add(face); |
| | | return Result.ok().data(results); |
| | | } |
| | | |
| | | @Override |
| | | public Result selectWorkOrderWhiteDetail(Integer id) { |
| | | WorkOrderWhite workOrderWhite = workOrderWhiteMapper.getById(id); |
| | | List<String> errorList = JSONArray.parseArray(workOrderWhite.getErrorType(), String.class); |
| | | workOrderWhite.setErrorTypeList(errorList); |
| | | return Result.ok().data(workOrderWhite); |
| | | } |
| | | |
| | | |
| | | } |