package com.wgcloud.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.wgcloud.entity.FailureLogging; import com.wgcloud.entity.InspectionTask; import com.wgcloud.entity.TaskInfo; import com.wgcloud.mapper.InspectionTaskMapper; import com.wgcloud.util.DateUtil; import com.wgcloud.util.HostUtil; import com.wgcloud.util.UUIDUtil; import com.wgcloud.util.staticvar.StaticKeys; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.List; import java.util.Map; /** * @author kdq * @version 1.0.0 * @ClassName InspectionTaskService.java * @Description TODO * @createTime 2022年12月16日 16:52:00 */ @Service public class InspectionTaskService { @Autowired private InspectionTaskMapper inspectionTaskMapper; @Autowired private LogInfoService logInfoService; public void save(InspectionTask inspectionTask) throws Exception { inspectionTask.setId(UUIDUtil.getUUID()); inspectionTask.setCreateTime(DateUtil.getCurrentDateTime()); inspectionTaskMapper.save(inspectionTask); } public PageInfo selectByParams(Map params, Integer currPage, Integer pageSize)throws Exception { PageHelper.startPage(currPage, pageSize); List list = inspectionTaskMapper.selectByParams(params); PageInfo pageInfo = new PageInfo(list); return pageInfo; } public List selectAllByParams(Map params)throws Exception { return inspectionTaskMapper.selectAllByParams(params); } /** * 保存操作日志 * * @param request 获取当前登录用户 * @param action 操作标识 */ public void saveLog(HttpServletRequest request, String action, InspectionTask inspectionTask) { if (null == inspectionTask) { return; } logInfoService.save(HostUtil.getAccountByRequest(request).getAccount() + action + "巡检任务:" + inspectionTask.getTitle(), "创建时间:" + inspectionTask.getCreateTime()+",周期:"+inspectionTask.getStartDate()+"-"+inspectionTask.getEndDate(), StaticKeys.LOG_XTCZ); } public InspectionTask selectById(String id)throws Exception { return inspectionTaskMapper.selectById(id); } public void deleteById(String[] ids)throws Exception { inspectionTaskMapper.deleteById(ids); } public void updateById(InspectionTask inspectionTask) throws Exception { inspectionTaskMapper.updateById(inspectionTask); } public List selectByDate(Map params) { return inspectionTaskMapper.selectByDate(params); } }