ClearingPointController.java 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package cn.com.lzt.clearingpoint.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.daju.mix.dao.entity.TBArchivesPlace;
  6. import com.daju.mix.dao.service.ITBArchivesPlaceService;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.apache.commons.lang3.StringUtils;
  9. import org.jeecgframework.core.common.model.json.AjaxJson;
  10. import org.jeecgframework.core.common.model.json.DataGrid;
  11. import org.jeecgframework.core.util.StringUtil;
  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. */
  26. @Slf4j
  27. @Controller
  28. @RequestMapping("/ClearingPointController")
  29. public class ClearingPointController {
  30. private static final String BASE_PATH = "cn/com/lzt/clearingpoint/";
  31. private static final int CLEAN_TYPE = 33;
  32. private static final String ARCHIVESPLACE = "archivesPlace";
  33. @Resource
  34. private ITBArchivesPlaceService archivesPlaceService;
  35. @RequestMapping(params = "view")
  36. public ModelAndView index() {
  37. System.out.println("--------------");
  38. return new ModelAndView(BASE_PATH.concat("clearingpoint"));
  39. }
  40. /**
  41. * 分页查询 清运点
  42. *
  43. * @param tbArchivesPlace
  44. * @param response
  45. * @param dataGrid
  46. */
  47. @RequestMapping(params = "datagrid")
  48. public void datagrid(TBArchivesPlace tbArchivesPlace, HttpServletResponse response, DataGrid dataGrid) throws Exception {
  49. //空对象判断
  50. Optional.ofNullable(tbArchivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null"));
  51. //条件
  52. LambdaQueryWrapper<TBArchivesPlace> queryWrapper = new LambdaQueryWrapper<>();
  53. queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE)
  54. .isNotNull(TBArchivesPlace::getTimeStatus)
  55. .eq(StringUtils.isNotBlank(tbArchivesPlace.getCode()), TBArchivesPlace::getCode, tbArchivesPlace.getCode())
  56. .like(StringUtils.isNotBlank(tbArchivesPlace.getName()), TBArchivesPlace::getName, StringUtils.isNotBlank(tbArchivesPlace.getName()) ? tbArchivesPlace.getName().trim():tbArchivesPlace.getName())
  57. .eq(StringUtils.isNotBlank(tbArchivesPlace.getPrepTime()), TBArchivesPlace::getPrepTime, tbArchivesPlace.getPrepTime())
  58. .eq(StringUtils.isNotBlank(tbArchivesPlace.getLateTime()), TBArchivesPlace::getLateTime, tbArchivesPlace.getLateTime())
  59. .eq(StringUtils.isNotBlank(tbArchivesPlace.getTimeStatus()), TBArchivesPlace::getTimeStatus, tbArchivesPlace.getTimeStatus());
  60. Page<TBArchivesPlace> list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper);
  61. TagUtil.datagrid(response, dataGrid, list);
  62. }
  63. /**
  64. * 新建页面
  65. *
  66. * @param archivesPlace
  67. * @param req
  68. * @return
  69. */
  70. @RequestMapping(params = "goAdd")
  71. public ModelAndView goAdd(TBArchivesPlace archivesPlace, HttpServletRequest req) throws Exception {
  72. //空对象判断
  73. Optional.ofNullable(archivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null"));
  74. if (StringUtil.isNotEmpty(archivesPlace.getId())) {
  75. TBArchivesPlace byId = archivesPlaceService.getById(archivesPlace.getId());
  76. req.setAttribute(ARCHIVESPLACE, byId);
  77. }
  78. return new ModelAndView(BASE_PATH.concat("clearingpoint-add"));
  79. }
  80. /**
  81. * 录入数据 or 更新
  82. *
  83. * @param archivesPlace
  84. * @param request
  85. * @return
  86. */
  87. @RequestMapping(params = "doAdd")
  88. @ResponseBody
  89. public AjaxJson doAdd(TBArchivesPlace archivesPlace, HttpServletRequest request) {
  90. AjaxJson j = new AjaxJson();
  91. String message;
  92. if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId()) || StringUtils.isBlank(archivesPlace.getPrepTime()) || StringUtils.isBlank(archivesPlace.getLateTime()) || StringUtils.isBlank(archivesPlace.getTimeStatus())) {
  93. message = "清运点`0档案信息有误";
  94. j.setMsg(message);
  95. j.setSuccess(false);
  96. return j;
  97. }
  98. boolean saveOrUpdate;
  99. LambdaUpdateWrapper<TBArchivesPlace> updateWrapper = new LambdaUpdateWrapper<>();
  100. updateWrapper.set(TBArchivesPlace::getPrepTime, archivesPlace.getPrepTime())
  101. .set(TBArchivesPlace::getLateTime, archivesPlace.getLateTime())
  102. .set(TBArchivesPlace::getTimeStatus, archivesPlace.getTimeStatus())
  103. .eq(TBArchivesPlace::getId, archivesPlace.getId());
  104. saveOrUpdate = archivesPlaceService.update(updateWrapper);
  105. if (saveOrUpdate) {
  106. message = "清运点档案保存成功";
  107. j.setSuccess(true);
  108. } else {
  109. message = "清运点档案保存失败";
  110. j.setSuccess(false);
  111. }
  112. j.setMsg(message);
  113. return j;
  114. }
  115. /**
  116. * 更新操作
  117. *
  118. * @param archivesPlace
  119. * @param req
  120. * @return
  121. */
  122. @RequestMapping(params = "goUpdate")
  123. public ModelAndView goUpdate(TBArchivesPlace archivesPlace, HttpServletRequest req) throws Exception {
  124. TBArchivesPlace one = archivesPlaceService.getById(archivesPlace.getId());
  125. // 空对象判断
  126. Optional.ofNullable(one).orElseThrow(() -> new Exception("不存在当前清运点档案"));
  127. req.setAttribute(ARCHIVESPLACE, one);
  128. return new ModelAndView(BASE_PATH.concat("clearingpoint-update"));
  129. }
  130. /**
  131. * 删除清运点的 信息
  132. *
  133. * @param archivesPlace
  134. * @return
  135. */
  136. @RequestMapping(params = "logicDel")
  137. @ResponseBody
  138. public AjaxJson logicDel(@RequestBody TBArchivesPlace archivesPlace) {
  139. AjaxJson j = new AjaxJson();
  140. String message;
  141. //空对象判断
  142. if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId())) {
  143. message = "清运点信息删除有误";
  144. j.setMsg(message);
  145. j.setSuccess(false);
  146. return j;
  147. }
  148. LambdaUpdateWrapper<TBArchivesPlace> updateWrapper = new LambdaUpdateWrapper<>();
  149. updateWrapper
  150. .set(TBArchivesPlace::getTimeStatus, null)
  151. .set(TBArchivesPlace::getType, CLEAN_TYPE)
  152. .eq(TBArchivesPlace::getId, archivesPlace.getId());
  153. boolean b = archivesPlaceService.update(updateWrapper);
  154. if (b) {
  155. message = "清运点删除成功";
  156. j.setSuccess(Boolean.TRUE);
  157. } else {
  158. message = "清运点删除失败";
  159. j.setSuccess(Boolean.FALSE);
  160. }
  161. j.setMsg(message);
  162. return j;
  163. }
  164. /**
  165. * 清运点选择
  166. *
  167. * @return
  168. */
  169. @RequestMapping(params = "CleanSelect")
  170. public ModelAndView userSelect() {
  171. return new ModelAndView(BASE_PATH.concat("clearingpoint-select"));
  172. }
  173. /**
  174. * 清运点选择 分页
  175. *
  176. * @param tbArchivesPlace
  177. * @param response
  178. * @param dataGrid
  179. */
  180. @RequestMapping(params = "datagrid2")
  181. public void datagrid2(TBArchivesPlace tbArchivesPlace, HttpServletResponse response, DataGrid dataGrid) throws Exception {
  182. //空对象判断
  183. Optional.ofNullable(tbArchivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null"));
  184. //条件
  185. LambdaQueryWrapper<TBArchivesPlace> queryWrapper = new LambdaQueryWrapper<>();
  186. queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE).isNull(TBArchivesPlace::getTimeStatus);
  187. if (StringUtils.isNotBlank(tbArchivesPlace.getCode())) {
  188. queryWrapper.eq(TBArchivesPlace::getCode, tbArchivesPlace.getCode());
  189. }
  190. if (StringUtils.isNotBlank(tbArchivesPlace.getName())) {
  191. queryWrapper.like(TBArchivesPlace::getName, tbArchivesPlace.getName().trim());
  192. }
  193. Page<TBArchivesPlace> list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper);
  194. TagUtil.datagrid(response, dataGrid, list);
  195. }
  196. }