| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- package cn.com.lzt.clearingpoint.controller;
- 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.service.ITBArchivesPlaceService;
- import lombok.extern.slf4j.Slf4j;
- 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.core.util.StringUtil;
- 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;
- /**
- * 清运点 管理
- */
- @Slf4j
- @Controller
- @RequestMapping("/ClearingPointController")
- public class ClearingPointController {
- private static final String BASE_PATH = "cn/com/lzt/clearingpoint/";
- private static final int CLEAN_TYPE = 33;
- private static final String ARCHIVESPLACE = "archivesPlace";
- @Resource
- private ITBArchivesPlaceService archivesPlaceService;
- @RequestMapping(params = "view")
- public ModelAndView index() {
- System.out.println("--------------");
- return new ModelAndView(BASE_PATH.concat("clearingpoint"));
- }
- /**
- * 分页查询 清运点
- *
- * @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<TBArchivesPlace> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE)
- .isNotNull(TBArchivesPlace::getTimeStatus)
- .eq(StringUtils.isNotBlank(tbArchivesPlace.getCode()), TBArchivesPlace::getCode, tbArchivesPlace.getCode())
- .like(StringUtils.isNotBlank(tbArchivesPlace.getName()), TBArchivesPlace::getName, StringUtils.isNotBlank(tbArchivesPlace.getName()) ? tbArchivesPlace.getName().trim():tbArchivesPlace.getName())
- .eq(StringUtils.isNotBlank(tbArchivesPlace.getPrepTime()), TBArchivesPlace::getPrepTime, tbArchivesPlace.getPrepTime())
- .eq(StringUtils.isNotBlank(tbArchivesPlace.getLateTime()), TBArchivesPlace::getLateTime, tbArchivesPlace.getLateTime())
- .eq(StringUtils.isNotBlank(tbArchivesPlace.getTimeStatus()), TBArchivesPlace::getTimeStatus, tbArchivesPlace.getTimeStatus());
- Page<TBArchivesPlace> list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper);
- TagUtil.datagrid(response, dataGrid, list);
- }
- /**
- * 新建页面
- *
- * @param archivesPlace
- * @param req
- * @return
- */
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(TBArchivesPlace archivesPlace, HttpServletRequest req) throws Exception {
- //空对象判断
- Optional.ofNullable(archivesPlace).orElseThrow(() -> new Exception("场所档案对象不能为null"));
- if (StringUtil.isNotEmpty(archivesPlace.getId())) {
- TBArchivesPlace byId = archivesPlaceService.getById(archivesPlace.getId());
- req.setAttribute(ARCHIVESPLACE, byId);
- }
- return new ModelAndView(BASE_PATH.concat("clearingpoint-add"));
- }
- /**
- * 录入数据 or 更新
- *
- * @param archivesPlace
- * @param request
- * @return
- */
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(TBArchivesPlace archivesPlace, HttpServletRequest request) {
- AjaxJson j = new AjaxJson();
- String message;
- if (Objects.isNull(archivesPlace) || Objects.isNull(archivesPlace.getId()) || StringUtils.isBlank(archivesPlace.getPrepTime()) || StringUtils.isBlank(archivesPlace.getLateTime()) || StringUtils.isBlank(archivesPlace.getTimeStatus())) {
- message = "清运点`0档案信息有误";
- j.setMsg(message);
- j.setSuccess(false);
- return j;
- }
- boolean saveOrUpdate;
- LambdaUpdateWrapper<TBArchivesPlace> updateWrapper = new LambdaUpdateWrapper<>();
- updateWrapper.set(TBArchivesPlace::getPrepTime, archivesPlace.getPrepTime())
- .set(TBArchivesPlace::getLateTime, archivesPlace.getLateTime())
- .set(TBArchivesPlace::getTimeStatus, archivesPlace.getTimeStatus())
- .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;
- }
- /**
- * 更新操作
- *
- * @param archivesPlace
- * @param req
- * @return
- */
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(TBArchivesPlace archivesPlace, HttpServletRequest req) throws Exception {
- TBArchivesPlace one = archivesPlaceService.getById(archivesPlace.getId());
- // 空对象判断
- Optional.ofNullable(one).orElseThrow(() -> new Exception("不存在当前清运点档案"));
- req.setAttribute(ARCHIVESPLACE, one);
- return new ModelAndView(BASE_PATH.concat("clearingpoint-update"));
- }
- /**
- * 删除清运点的 信息
- *
- * @param archivesPlace
- * @return
- */
- @RequestMapping(params = "logicDel")
- @ResponseBody
- public AjaxJson logicDel(@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<TBArchivesPlace> updateWrapper = new LambdaUpdateWrapper<>();
- updateWrapper
- .set(TBArchivesPlace::getTimeStatus, null)
- .set(TBArchivesPlace::getType, CLEAN_TYPE)
- .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;
- }
- /**
- * 清运点选择
- *
- * @return
- */
- @RequestMapping(params = "CleanSelect")
- public ModelAndView userSelect() {
- return new ModelAndView(BASE_PATH.concat("clearingpoint-select"));
- }
- /**
- * 清运点选择 分页
- *
- * @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<TBArchivesPlace> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(TBArchivesPlace::getType, CLEAN_TYPE).isNull(TBArchivesPlace::getTimeStatus);
- if (StringUtils.isNotBlank(tbArchivesPlace.getCode())) {
- queryWrapper.eq(TBArchivesPlace::getCode, tbArchivesPlace.getCode());
- }
- if (StringUtils.isNotBlank(tbArchivesPlace.getName())) {
- queryWrapper.like(TBArchivesPlace::getName, tbArchivesPlace.getName().trim());
- }
- Page<TBArchivesPlace> list = archivesPlaceService.page(new Page<>(dataGrid.getPage(), dataGrid.getRows()), queryWrapper);
- TagUtil.datagrid(response, dataGrid, list);
- }
- }
|