package cn.com.lzt.clearingpoint.controller; import cn.com.lzt.common.util.StringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.daju.mix.dao.entity.TBArchivesPlace; import com.daju.mix.dao.entity.TBCarDefend; import com.daju.mix.dao.service.ITBArchivesPlaceService; import org.apache.commons.lang3.StringUtils; import org.jeecgframework.core.common.model.json.AjaxJson; import org.jeecgframework.core.common.model.json.DataGrid; import org.jeecgframework.tag.core.easyui.TagUtil; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Objects; import java.util.Optional; /** * 清运点作业时间管理 * @author :sahib.kio.m * @date :Created in 2021/8/23 上午11:05 */ @Controller @RequestMapping("/clearPointScheduleController") public class ClearPointScheduleController { private static final String BASE_PATH = "cn/com/lzt/clearingpoint/"; private static final int CLEAN_TYPE = 3; @Resource private ITBArchivesPlaceService archivesPlaceService; @RequestMapping(params = "list") public ModelAndView list() { return new ModelAndView(BASE_PATH.concat("clearPointScheduleList")); } @RequestMapping(params = "goAdd") public ModelAndView goAdd() { return new ModelAndView(BASE_PATH.concat("clearPointScheduleList-add")); } @RequestMapping(params = "goUpdate") public ModelAndView goUpdate(HttpServletRequest request) { String id = request.getParameter("id"); TBArchivesPlace common = archivesPlaceService.getById(id); request.setAttribute("common", common); return new ModelAndView(BASE_PATH.concat("clearPointScheduleList-update")); } @RequestMapping(params = "select") public ModelAndView select() { return new ModelAndView(BASE_PATH.concat("clearPointScheduleList-select")); } /** * 分页查询 清运点 * * @param tbArchivesPlace * @param response * @param dataGrid */ @RequestMapping(params = "datagrid") public void datagrid(TBArchivesPlace tbArchivesPlace, HttpServletResponse response, DataGrid dataGrid) throws Exception { //空对象判断 Optional.ofNullable(tbArchivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null")); //条件 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE) .isNotNull(TBArchivesPlace::getScheduleStatus); if(!StringUtil.isEmpty(tbArchivesPlace.getCode())){ queryWrapper.like(TBArchivesPlace::getCode, tbArchivesPlace.getCode()); } if(!StringUtil.isEmpty(tbArchivesPlace.getName())){ queryWrapper.like(TBArchivesPlace::getName, tbArchivesPlace.getName()); } if(!StringUtil.isEmpty(tbArchivesPlace.getScheduleArrangeType())){ queryWrapper.eq(TBArchivesPlace::getScheduleArrangeType, tbArchivesPlace.getScheduleArrangeType()); } if(!StringUtil.isEmpty(tbArchivesPlace.getScheduleStatus())){ queryWrapper.eq(TBArchivesPlace::getScheduleStatus, tbArchivesPlace.getScheduleStatus()); } Page list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper); TagUtil.datagrid(response, dataGrid, list); } @RequestMapping(params = "doDel") @ResponseBody public AjaxJson doDel(@RequestBody TBArchivesPlace archivesPlace) { AjaxJson j = new AjaxJson(); String message; //空对象判断 if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId())) { message = "清运点信息有误"; j.setMsg(message); j.setSuccess(false); return j; } LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper .set(TBArchivesPlace::getScheduleStatus, null) .set(TBArchivesPlace::getScheduleArrangeType, null) .set(TBArchivesPlace::getScheduleDate, null) .eq(TBArchivesPlace::getId, archivesPlace.getId()); boolean b = archivesPlaceService.update(updateWrapper); if (b) { message = "删除成功"; j.setSuccess(Boolean.TRUE); } else { message = "删除失败"; j.setSuccess(Boolean.FALSE); } j.setMsg(message); return j; } /** * 清运点选择 分页 * * @param tbArchivesPlace * @param response * @param dataGrid */ @RequestMapping(params = "datagrid2") public void datagrid2(TBArchivesPlace tbArchivesPlace, HttpServletResponse response, DataGrid dataGrid) throws Exception { //空对象判断 Optional.ofNullable(tbArchivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null")); //条件 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE) .isNull(TBArchivesPlace::getScheduleStatus); if (StringUtils.isNotBlank(tbArchivesPlace.getCode())) { queryWrapper.eq(TBArchivesPlace::getCode, tbArchivesPlace.getCode()); } if (StringUtils.isNotBlank(tbArchivesPlace.getName())) { queryWrapper.like(TBArchivesPlace::getName, tbArchivesPlace.getName().trim()); } Page list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper); TagUtil.datagrid(response, dataGrid, list); } /** * 录入数据 or 更新 * * @param archivesPlace * @param request * @return */ @RequestMapping(params = "doUpdate") @ResponseBody public AjaxJson doUpdate(TBArchivesPlace archivesPlace, HttpServletRequest request) { AjaxJson j = new AjaxJson(); String message; if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId())) { message = "信息有误"; j.setMsg(message); j.setSuccess(false); return j; } boolean saveOrUpdate; LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.set(TBArchivesPlace::getScheduleStatus, archivesPlace.getScheduleStatus()) .set(TBArchivesPlace::getScheduleArrangeType, archivesPlace.getScheduleArrangeType()) .set(TBArchivesPlace::getScheduleDate, archivesPlace.getScheduleDate()) .eq(TBArchivesPlace::getId, archivesPlace.getId()); saveOrUpdate = archivesPlaceService.update(updateWrapper); if (saveOrUpdate) { message = "保存成功"; j.setSuccess(true); } else { message = "保存失败"; j.setSuccess(false); } j.setMsg(message); return j; } }