From 28f6c716269ce5435b103137dd7ec1f1f9ab19ba Mon Sep 17 00:00:00 2001
From: 16639036659 <577530412@qq.com>
Date: 星期一, 26 六月 2023 09:16:56 +0800
Subject: [PATCH] 临时提交-已经与app端对接完成

---
 src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventOverhaulLogServiceImpl.java |  236 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 236 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventOverhaulLogServiceImpl.java b/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventOverhaulLogServiceImpl.java
new file mode 100644
index 0000000..497b9f5
--- /dev/null
+++ b/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventOverhaulLogServiceImpl.java
@@ -0,0 +1,236 @@
+package com.ruoyi.doublePrevention.service.baseService.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.ruoyi.common.exception.BusinessException;
+import com.ruoyi.common.utils.BeanCopyUtils;
+import com.ruoyi.common.utils.text.Convert;
+import com.ruoyi.doublePrevention.entity.PreventOverhaulLog;
+import com.ruoyi.doublePrevention.entity.PreventReportConfig;
+import com.ruoyi.doublePrevention.entity.dto.req.PreventOverhaulLogInsertReqBO;
+import com.ruoyi.doublePrevention.entity.dto.req.PreventOverhaulLogReqBO;
+import com.ruoyi.doublePrevention.entity.dto.req.PreventOverhaulLogUpdateReqBO;
+import com.ruoyi.doublePrevention.entity.dto.resp.PreventOverhaulLogRespDTO;
+import com.ruoyi.doublePrevention.enums.ErrorCodes;
+import com.ruoyi.doublePrevention.enums.SyncEnum;
+import com.ruoyi.doublePrevention.repository.PreventOverhaulLogRepository;
+import com.ruoyi.doublePrevention.repository.param.HandlerReportParam;
+import com.ruoyi.doublePrevention.service.baseService.PreventOverhaulLogService;
+import com.ruoyi.doublePrevention.service.baseService.PreventReportConfigService;
+import com.ruoyi.doublePrevention.vo.ResultVO;
+import com.ruoyi.project.system.user.domain.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import static com.ruoyi.common.utils.security.ShiroUtils.getSysUser;
+
+@Service
+public class PreventOverhaulLogServiceImpl implements PreventOverhaulLogService {
+
+    @Autowired
+    private PreventOverhaulLogRepository overhaulLogRepository;
+    @Autowired
+    private PreventReportConfigService preventReportConfigService;
+
+
+    @Override
+    public ResultVO<PreventOverhaulLogRespDTO> selectOverhaulLogPage(PreventOverhaulLogReqBO overhaulLogReqBO) {
+
+        ResultVO resultVO = new ResultVO<>();
+
+        if (ObjectUtils.isEmpty(overhaulLogReqBO.getPageSize())){
+            throw new BusinessException("分页信息不能为空");
+        }
+        if (ObjectUtils.isEmpty(overhaulLogReqBO.getPageNum())){
+            throw new BusinessException("分页信息不能为空");
+        }
+        Integer pageIndex = overhaulLogReqBO.getPageNum();
+        Integer pageSize = overhaulLogReqBO.getPageSize();
+
+        Page<PreventOverhaulLog> page = PageHelper.startPage(pageIndex, pageSize);
+        List<PreventOverhaulLog> preventOverhaulLogs = overhaulLogRepository.selectOverhaulLogPage(overhaulLogReqBO);
+        List<PreventOverhaulLog> result = page.getResult();
+
+        resultVO.setData(result);
+        resultVO.setCount((int) page.getTotal());
+        resultVO.setPageNum(page.getPageNum());
+        resultVO.setPageSize(page.getPageSize());
+
+        return resultVO;
+    }
+
+    @Override
+    public ResultVO<PreventOverhaulLog> savePreventOverhaulLog(PreventOverhaulLogInsertReqBO insertReqBO) {
+
+        User sysUser = getSysUser();
+        ResultVO resultVO = new ResultVO<>();
+        resultVO.setCode(ErrorCodes.REQUEST_PARAM_ERROR.getCode());
+
+        if (insertReqBO.getHazardCode().isEmpty()){
+            resultVO.setMsg("风险分析对象编码");
+            return resultVO;
+        }
+        if (ObjectUtils.isEmpty(insertReqBO.getRiskUnitId())){
+            resultVO.setMsg("所属安全风险分析单元");
+            return resultVO;
+        }
+        if (ObjectUtils.isEmpty(insertReqBO.getStopStartTime())){
+            resultVO.setMsg("装置停用或者检维修开始时间");
+            return resultVO;
+        }
+        if (ObjectUtils.isEmpty(insertReqBO.getStopEndTime())){
+            resultVO.setMsg("装置停用或者检维修结束时间");
+            return resultVO;
+        }
+        if (insertReqBO.getStopReason().isEmpty()){
+            resultVO.setMsg("描述停用原因");
+            return resultVO;
+        }
+
+        Date date = new Date();
+        String uuid = UUID.randomUUID().toString();
+
+        PreventOverhaulLog preventOverhaulLog = BeanCopyUtils.copyBean(insertReqBO, PreventOverhaulLog.class);
+
+        preventOverhaulLog.setUuid(uuid);
+        preventOverhaulLog.setDeleteStatus((byte) 0);
+        preventOverhaulLog.setCreateByUserName(sysUser.getUserName());
+        preventOverhaulLog.setGmtCreate(date);
+        preventOverhaulLog.setLastEditUserName(sysUser.getUserName());
+        preventOverhaulLog.setGmtModitify(date);
+        preventOverhaulLog.setRiskUnitId(null);// todo 暂时未设置
+
+        //todo 对所属企业id和uuid没有进行设置
+        PreventReportConfig reportConfigById = preventReportConfigService.getReportConfigById(SyncEnum.REPORT_CONFIG_RISK_ANA_UNIT.getCode());
+        //设置上报时间为空
+        preventOverhaulLog.setReportTime(null);
+        //设置本条数据上报更新时间
+        preventOverhaulLog.setUpdateReportDataTime(date);
+        //读取上报主配置,进行任务记录上报配置,如果开启上报功能,且设置为自动上报,开启上报相关配置
+        if (reportConfigById.getReportState() == SyncEnum.REPORT_ON.getCode()
+                && reportConfigById.getReportType() == SyncEnum.REPORT_HAND_EXEC_CONFIG.getCode()){
+            //设置上报状态为-等待上报
+            preventOverhaulLog.setReportStatus(SyncEnum.SYNC_WAIT_EXEC.getCode());
+            //设置本条数据上报开关为-开启
+            preventOverhaulLog.setReportSwitch(SyncEnum.REPORT_ON.getCode());
+            //其他情况默认不开启上报数据,如果是手动上报,可对单条数据进行操作
+        }else {
+            //设置上报状态为-不上报
+            preventOverhaulLog.setReportStatus(SyncEnum.SYNC_NOT_EXEC.getCode());
+            //设置本条数据上报开关为-关闭
+            preventOverhaulLog.setReportSwitch(SyncEnum.REPORT_OFF.getCode());
+        }
+
+        int result = overhaulLogRepository.savePreventOverhaulLog(preventOverhaulLog);
+
+        resultVO.setCount(result);
+        resultVO.setCode("200");
+        resultVO.setMsg("保存成功");
+
+        return resultVO;
+    }
+
+    /**
+     * 查询 by id
+     * */
+    @Override
+    public PreventOverhaulLog getOverhaulLogById(Long id) {
+        return overhaulLogRepository.getOverhaulLogById(id);
+    }
+
+    /**
+     * 修改保存
+     * */
+    @Override
+    public ResultVO<PreventOverhaulLog> updateOverhaulLog(PreventOverhaulLogUpdateReqBO updateReqBO) {
+
+
+        User sysUser = getSysUser();
+        ResultVO resultVO = new ResultVO<>();
+        resultVO.setCode(ErrorCodes.REQUEST_PARAM_ERROR.getCode());
+
+        if (updateReqBO.getHazardCode().isEmpty()){
+            resultVO.setMsg("风险分析对象编码");
+            return resultVO;
+        }
+        if (ObjectUtils.isEmpty(updateReqBO.getRiskUnitId())){
+            resultVO.setMsg("所属安全风险分析单元");
+            return resultVO;
+        }
+        if (ObjectUtils.isEmpty(updateReqBO.getStopStartTime())){
+            resultVO.setMsg("装置停用或者检维修开始时间");
+            return resultVO;
+        }
+        if (ObjectUtils.isEmpty(updateReqBO.getStopEndTime())){
+            resultVO.setMsg("装置停用或者检维修结束时间");
+            return resultVO;
+        }
+        if (updateReqBO.getStopReason().isEmpty()){
+            resultVO.setMsg("描述停用原因");
+            return resultVO;
+        }
+
+        Date date = new Date();
+        String uuid = UUID.randomUUID().toString();
+
+        PreventOverhaulLog preventOverhaulLog = BeanCopyUtils.copyBean(updateReqBO, PreventOverhaulLog.class);
+
+        preventOverhaulLog.setUuid(uuid);
+        preventOverhaulLog.setDeleteStatus((byte) 0);
+        preventOverhaulLog.setLastEditUserName(sysUser.getUserName());
+        preventOverhaulLog.setGmtModitify(date);
+        preventOverhaulLog.setRiskUnitId(null);// todo 暂时未设置
+
+
+        //todo 对所属企业id和uuid没有进行设置
+        PreventReportConfig reportConfigById = preventReportConfigService.getReportConfigById(SyncEnum.REPORT_CONFIG_RISK_ANA_UNIT.getCode());
+        //设置上报时间为空
+        preventOverhaulLog.setReportTime(null);
+        //设置本条数据上报更新时间
+        preventOverhaulLog.setUpdateReportDataTime(date);
+        //读取上报主配置,进行任务记录上报配置,如果开启上报功能,且设置为自动上报,开启上报相关配置
+        if (reportConfigById.getReportState() == SyncEnum.REPORT_ON.getCode()
+                && reportConfigById.getReportType() == SyncEnum.REPORT_HAND_EXEC_CONFIG.getCode()){
+            //设置上报状态为-等待上报
+            preventOverhaulLog.setReportStatus(SyncEnum.SYNC_WAIT_EXEC.getCode());
+            //设置本条数据上报开关为-开启
+            preventOverhaulLog.setReportSwitch(SyncEnum.REPORT_ON.getCode());
+            //其他情况默认不开启上报数据,如果是手动上报,可对单条数据进行操作
+        }else {
+            //设置上报状态为-不上报
+            preventOverhaulLog.setReportStatus(SyncEnum.SYNC_NOT_EXEC.getCode());
+            //设置本条数据上报开关为-关闭
+            preventOverhaulLog.setReportSwitch(SyncEnum.REPORT_OFF.getCode());
+        }
+
+        int result = overhaulLogRepository.updateOverhaulLog(updateReqBO);
+
+        resultVO.setCount(result);
+        resultVO.setCode("200");
+        resultVO.setMsg("保存成功");
+
+        return resultVO;
+    }
+
+    @Override
+    public int deleteOverhaulLogByIds(String ids) {
+        return overhaulLogRepository.deleteOverhaulLogByIds(Convert.toStrArray(ids));
+    }
+
+    @Override
+    public List<PreventOverhaulLog> listReportOverhaulLog() {
+        return overhaulLogRepository.listReportOverhaulLog();
+    }
+
+    @Override
+    public int updateOverhaulReportStatus(HandlerReportParam handlerReportParam) {
+        return overhaulLogRepository.updateOverhaulReportStatus(handlerReportParam);
+    }
+
+
+}

--
Gitblit v1.9.2