ClearPointScheduleController.java 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package cn.com.lzt.clearingpoint.controller;
  2. import cn.com.lzt.common.util.StringUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  5. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  6. import com.daju.mix.dao.entity.TBArchivesPlace;
  7. import com.daju.mix.dao.entity.TBCarDefend;
  8. import com.daju.mix.dao.service.ITBArchivesPlaceService;
  9. import org.apache.commons.lang3.StringUtils;
  10. import org.jeecgframework.core.common.model.json.AjaxJson;
  11. import org.jeecgframework.core.common.model.json.DataGrid;
  12. import org.jeecgframework.tag.core.easyui.TagUtil;
  13. import org.springframework.stereotype.Controller;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.ResponseBody;
  17. import org.springframework.web.servlet.ModelAndView;
  18. import javax.annotation.Resource;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.util.Objects;
  22. import java.util.Optional;
  23. /**
  24. * 清运点作业时间管理
  25. * @author :sahib.kio.m
  26. * @date :Created in 2021/8/23 上午11:05
  27. */
  28. @Controller
  29. @RequestMapping("/clearPointScheduleController")
  30. public class ClearPointScheduleController {
  31. private static final String BASE_PATH = "cn/com/lzt/clearingpoint/";
  32. private static final int CLEAN_TYPE = 3;
  33. @Resource
  34. private ITBArchivesPlaceService archivesPlaceService;
  35. @RequestMapping(params = "list")
  36. public ModelAndView list() {
  37. return new ModelAndView(BASE_PATH.concat("clearPointScheduleList"));
  38. }
  39. @RequestMapping(params = "goAdd")
  40. public ModelAndView goAdd() {
  41. return new ModelAndView(BASE_PATH.concat("clearPointScheduleList-add"));
  42. }
  43. @RequestMapping(params = "goUpdate")
  44. public ModelAndView goUpdate(HttpServletRequest request) {
  45. String id = request.getParameter("id");
  46. TBArchivesPlace common = archivesPlaceService.getById(id);
  47. request.setAttribute("common", common);
  48. return new ModelAndView(BASE_PATH.concat("clearPointScheduleList-update"));
  49. }
  50. @RequestMapping(params = "select")
  51. public ModelAndView select() {
  52. return new ModelAndView(BASE_PATH.concat("clearPointScheduleList-select"));
  53. }
  54. /**
  55. * 分页查询 清运点
  56. *
  57. * @param tbArchivesPlace
  58. * @param response
  59. * @param dataGrid
  60. */
  61. @RequestMapping(params = "datagrid")
  62. public void datagrid(TBArchivesPlace tbArchivesPlace, HttpServletResponse response, DataGrid dataGrid) throws Exception {
  63. //空对象判断
  64. Optional.ofNullable(tbArchivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null"));
  65. //条件
  66. LambdaQueryWrapper<TBArchivesPlace> queryWrapper = new LambdaQueryWrapper<>();
  67. queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE)
  68. .isNotNull(TBArchivesPlace::getScheduleStatus);
  69. if(!StringUtil.isEmpty(tbArchivesPlace.getCode())){
  70. queryWrapper.like(TBArchivesPlace::getCode, tbArchivesPlace.getCode());
  71. }
  72. if(!StringUtil.isEmpty(tbArchivesPlace.getName())){
  73. queryWrapper.like(TBArchivesPlace::getName, tbArchivesPlace.getName());
  74. }
  75. if(!StringUtil.isEmpty(tbArchivesPlace.getScheduleArrangeType())){
  76. queryWrapper.eq(TBArchivesPlace::getScheduleArrangeType, tbArchivesPlace.getScheduleArrangeType());
  77. }
  78. if(!StringUtil.isEmpty(tbArchivesPlace.getScheduleStatus())){
  79. queryWrapper.eq(TBArchivesPlace::getScheduleStatus, tbArchivesPlace.getScheduleStatus());
  80. }
  81. Page<TBArchivesPlace> list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper);
  82. TagUtil.datagrid(response, dataGrid, list);
  83. }
  84. @RequestMapping(params = "doDel")
  85. @ResponseBody
  86. public AjaxJson doDel(@RequestBody TBArchivesPlace archivesPlace) {
  87. AjaxJson j = new AjaxJson();
  88. String message;
  89. //空对象判断
  90. if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId())) {
  91. message = "清运点信息有误";
  92. j.setMsg(message);
  93. j.setSuccess(false);
  94. return j;
  95. }
  96. LambdaUpdateWrapper<TBArchivesPlace> updateWrapper = new LambdaUpdateWrapper<>();
  97. updateWrapper
  98. .set(TBArchivesPlace::getScheduleStatus, null)
  99. .set(TBArchivesPlace::getScheduleArrangeType, null)
  100. .set(TBArchivesPlace::getScheduleDate, null)
  101. .eq(TBArchivesPlace::getId, archivesPlace.getId());
  102. boolean b = archivesPlaceService.update(updateWrapper);
  103. if (b) {
  104. message = "删除成功";
  105. j.setSuccess(Boolean.TRUE);
  106. } else {
  107. message = "删除失败";
  108. j.setSuccess(Boolean.FALSE);
  109. }
  110. j.setMsg(message);
  111. return j;
  112. }
  113. /**
  114. * 清运点选择 分页
  115. *
  116. * @param tbArchivesPlace
  117. * @param response
  118. * @param dataGrid
  119. */
  120. @RequestMapping(params = "datagrid2")
  121. public void datagrid2(TBArchivesPlace tbArchivesPlace, HttpServletResponse response, DataGrid dataGrid) throws Exception {
  122. //空对象判断
  123. Optional.ofNullable(tbArchivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null"));
  124. //条件
  125. LambdaQueryWrapper<TBArchivesPlace> queryWrapper = new LambdaQueryWrapper<>();
  126. queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE)
  127. .isNull(TBArchivesPlace::getScheduleStatus);
  128. if (StringUtils.isNotBlank(tbArchivesPlace.getCode())) {
  129. queryWrapper.eq(TBArchivesPlace::getCode, tbArchivesPlace.getCode());
  130. }
  131. if (StringUtils.isNotBlank(tbArchivesPlace.getName())) {
  132. queryWrapper.like(TBArchivesPlace::getName, tbArchivesPlace.getName().trim());
  133. }
  134. Page<TBArchivesPlace> list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper);
  135. TagUtil.datagrid(response, dataGrid, list);
  136. }
  137. /**
  138. * 录入数据 or 更新
  139. *
  140. * @param archivesPlace
  141. * @param request
  142. * @return
  143. */
  144. @RequestMapping(params = "doUpdate")
  145. @ResponseBody
  146. public AjaxJson doUpdate(TBArchivesPlace archivesPlace, HttpServletRequest request) {
  147. AjaxJson j = new AjaxJson();
  148. String message;
  149. if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId())) {
  150. message = "信息有误";
  151. j.setMsg(message);
  152. j.setSuccess(false);
  153. return j;
  154. }
  155. boolean saveOrUpdate;
  156. LambdaUpdateWrapper<TBArchivesPlace> updateWrapper = new LambdaUpdateWrapper<>();
  157. updateWrapper.set(TBArchivesPlace::getScheduleStatus, archivesPlace.getScheduleStatus())
  158. .set(TBArchivesPlace::getScheduleArrangeType, archivesPlace.getScheduleArrangeType())
  159. .set(TBArchivesPlace::getScheduleDate, archivesPlace.getScheduleDate())
  160. .eq(TBArchivesPlace::getId, archivesPlace.getId());
  161. saveOrUpdate = archivesPlaceService.update(updateWrapper);
  162. if (saveOrUpdate) {
  163. message = "保存成功";
  164. j.setSuccess(true);
  165. } else {
  166. message = "保存失败";
  167. j.setSuccess(false);
  168. }
  169. j.setMsg(message);
  170. return j;
  171. }
  172. }