| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- package cn.com.lzt.schedule.controller;
- import cn.com.lzt.common.util.StringUtil;
- import cn.com.lzt.schedule.service.impl.ScheduleSuperivseRecordServiceImpl;
- import cn.com.lzt.schedule.service.impl.ScheduleSuperivseServiceImpl;
- import cn.com.lzt.sysmsg.service.SysMsgServiceI;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.daju.common.util.DataPage;
- import com.daju.mix.dao.entity.TBScheduleSuperivse;
- import com.daju.mix.dao.entity.TBScheduleSuperivseRecord;
- import com.daju.mix.dao.service.impl.TSBaseUserServiceImpl;
- import com.xcgl.utils.OrderNumTools;
- import org.apache.commons.collections.CollectionUtils;
- import org.apache.commons.lang.StringUtils;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.ResourceUtil;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.web.system.pojo.base.TSUser;
- import org.jeecgframework.web.system.service.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- 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.text.SimpleDateFormat;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * @author :sahib.kio.m
- * @date :Created in 2021/8/10 下午3:11
- */
- @Controller
- @RequestMapping("/scheduleSuperivseController")
- public class ScheduleSuperivseController {
- @Resource
- private ScheduleSuperivseServiceImpl superivseService;
- @Resource
- private TSBaseUserServiceImpl baseUserService;
- @Resource
- private ScheduleSuperivseRecordServiceImpl superivseRecordService;
- @Autowired
- private SystemService systemService;
- @Autowired
- private SysMsgServiceI sysMsgService;
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/schedule/superivseList");
- }
- @RequestMapping(params = "datagrid")
- public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- Map<String, String> param = new HashMap<>();
- for (String key : request.getParameterMap().keySet()) {
- param.put(key, request.getParameter(key));
- }
- DataPage result = superivseService.superivseList(request,param);
- TagUtil.datagrid(response, dataGrid, result);
- }
- @RequestMapping(params = "goCheck")
- public ModelAndView goCheck(HttpServletRequest request) {
- String id = request.getParameter("id");
- TBScheduleSuperivse common = superivseService.getById(id);
- common = scheduleImageUrl(common);
- request.setAttribute("userName", baseUserService.getById(common.getUserId()).getRealname());
- request.setAttribute("common", common);
- request.setAttribute("responsibleUserName", common.getResponsibleUserId());
- request.setAttribute("leaderUserName", common.getLeaderUserId());
- List<TBScheduleSuperivseRecord> list = superivseRecordService.list(new QueryWrapper<TBScheduleSuperivseRecord>() {{
- eq("supervise_id", id);
- orderByDesc("deal_date");
- }});
- request.setAttribute("list", list);
- if (CollectionUtils.isEmpty(list)) {
- request.setAttribute("noRecord", "无整改记录");
- }
- return new ModelAndView("cn/com/lzt/schedule/superivseList-update");
- }
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/schedule/superivseList-add");
- }
- public TBScheduleSuperivse scheduleImageUrl(TBScheduleSuperivse common) {
- if (common != null) {
- // add-刘梦祥-2022年1月13日19:02:31(新增视频和图片路径解析)
- if (common.getImgUrl() != null && StringUtils.isNotEmpty(common.getImgUrl())) {
- if (common.getImgUrl().contains("http") && common.getImgUrl().length() > 10) {
- try {
- List<String> imgUrlList = JSONObject.parseArray(common.getImgUrl(), String.class);
- common.setImgUrlList(imgUrlList);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- List<String> imgUrlList = new ArrayList<>();
- if (!"[null]".equals(common.getImgUrl()) && !"[]".equals(common.getImgUrl())) {
- imgUrlList.add("http://47.100.210.233/" + common.getImgUrl());
- common.setImgUrlList(imgUrlList);
- }
- }
- }
- if (common.getVideos() != null && StringUtils.isNotEmpty(common.getVideos())) {
- if (common.getVideos().contains("http")) {
- try {
- List<String> videosList = JSONObject.parseArray(common.getVideos(), String.class);
- common.setVideosList(videosList);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- List<String> videosList = new ArrayList<>();
- if (!"[null]".equals(common.getVideos()) && !"[]".equals(common.getVideos())) {
- videosList.add("http://47.100.210.233/" + common.getVideos());
- common.setVideosList(videosList);
- }
- }
- }
- if (StringUtils.isNotEmpty(common.getResponsibleUserId())) {
- String getUserRealNameSql = "select realname from t_s_base_user where id = ?";
- Map<String, Object> userData = systemService.findOneForJdbc(getUserRealNameSql, common.getResponsibleUserId());
- if (userData != null && userData.containsKey("realname")) {
- common.setResponsibleUserId(String.valueOf(userData.get("realname")));
- }
- }
- if (StringUtils.isNotEmpty(common.getLeaderUserId())) {
- String getUserRealNameSql = "select realname from t_s_base_user where id = ?";
- Map<String, Object> userData = systemService.findOneForJdbc(getUserRealNameSql, common.getLeaderUserId());
- if (userData != null && userData.containsKey("realname")) {
- common.setLeaderUserId(String.valueOf(userData.get("realname")));
- }
- }
- }
- return common;
- }
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(HttpServletRequest request) {
- String id = request.getParameter("id");
- TBScheduleSuperivse common = superivseService.getById(id);
- common = scheduleImageUrl(common);
- request.setAttribute("userName", baseUserService.getById(common.getUserId()).getRealname());
- request.setAttribute("common", common);
- request.setAttribute("responsibleUserName", common.getResponsibleUserId());
- request.setAttribute("leaderUserName", common.getLeaderUserId());
- return new ModelAndView("cn/com/lzt/schedule/superivseList-update");
- }
- @RequestMapping(params = "statusUpdate")
- public ModelAndView statusUpdate(HttpServletRequest request) {
- String id = request.getParameter("id");
- TBScheduleSuperivse common = superivseService.getById(id);
- common = scheduleImageUrl(common);
- request.setAttribute("common", common);
- return new ModelAndView("cn/com/lzt/schedule/superivseList-statusUpdate");
- }
- @RequestMapping(params = "doNoDeal")
- @ResponseBody
- public AjaxJson doNoDeal(TBScheduleSuperivse common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "修改成功";
- j.setSuccess(true);
- try {
- common = superivseService.getById(common.getId());
- if("3".equals(common.getStatus())){
- common.setDealStatus("3");
- common.setStatus("4");
- }else{
- common.setDealStatus("3");
- }
- superivseService.updateById(common);
- } catch (Exception e) {
- e.printStackTrace();
- message = "修改失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- /**
- * 督查管理确认按钮
- * 如果状态状态为3:只有经办人能看到或操作确认、退回按钮。状态修改为5(整改完))。
- * @author 刘梦祥
- * @Date 2022年11月28日16:43:33
- * @param common 督查管理记录实体类
- * @param request HttpServletRequest
- * @return AjaxJson
- */
- @RequestMapping(params = "doConfirm")
- @ResponseBody
- public AjaxJson doConfirm(TBScheduleSuperivse common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "修改成功";
- j.setSuccess(true);
- try {
- common = superivseService.getById(common.getId());
- TSUser user = ResourceUtil.getSessionUser();
- if("3".equals(common.getStatus()) && common.getUserId() != null){
- common.setStatus("5");
- superivseService.updateById(common);
- sysMsgService.saveSysMsg(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_3,user.getId(),common.getResponsibleUserId());
- sysMsgService.saveSysMsgToDepart(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_3,user.getId(),common.getResponsibleUserId());
- }else{
- j.setSuccess(false);
- message = "修改失败,请刷新后重试!";
- }
- } catch (Exception e) {
- e.printStackTrace();
- message = "修改失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- /**
- * 督查管理退回按钮
- * 如果状态状态为3:只有经办人能看到或操作确认、退回按钮。状态修改为1(初始状态:整改中)
- * @author 刘梦祥
- * @Date 2022年11月28日16:43:33
- * @param common 督查管理记录实体类
- * @param request HttpServletRequest
- * @return AjaxJson
- */
- @RequestMapping(params = "doBack")
- @ResponseBody
- public AjaxJson doBack(TBScheduleSuperivse common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "修改成功";
- j.setSuccess(true);
- try {
- common = superivseService.getById(common.getId());
- TSUser user = ResourceUtil.getSessionUser();
- if("3".equals(common.getStatus()) && common.getUserId() != null){
- common.setStatus("1");
- superivseService.updateById(common);
- sysMsgService.saveSysMsg(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_4,user.getId(),common.getResponsibleUserId());
- sysMsgService.saveSysMsgToDepart(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_4,user.getId(),common.getResponsibleUserId());
- }else{
- j.setSuccess(false);
- message = "修改失败,请刷新后重试!";
- }
- } catch (Exception e) {
- e.printStackTrace();
- message = "修改失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(TBScheduleSuperivse common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "修改成功";
- j.setSuccess(true);
- try {
- common.setUpdateDate(getNowDateTime());
- //整改时间
- if (common.getResultUrl() != null) {
- common.setDealDate(getNowDateTime());
- TBScheduleSuperivseRecord record = new TBScheduleSuperivseRecord();
- record.setDealDate(getNowDateTime());
- record.setImgUrl(common.getResultUrl());
- record.setSuperviseId(common.getId());
- superivseRecordService.save(record);
- }
- //确认时间
- if (common.getStatus() == "2") {
- common.setConfirmDate(getNowDateTime());
- }
- Map<String, String> param = new HashMap<>();
- for (String key : request.getParameterMap().keySet()) {
- param.put(key, request.getParameter(key));
- }
- String pageTag = param.get("pageTag");
- if(StringUtils.isNotEmpty(pageTag) && "rectification".equals(pageTag)){
- common.setDealStatus("2");
- }
- superivseService.updateById(common);
- } catch (Exception e) {
- e.printStackTrace();
- message = "修改失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(TBScheduleSuperivse common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "添加成功";
- j.setSuccess(true);
- try {
- // update-刘梦祥-2022年11月28日16:30:21(经确认新增的督查表单默认状态为待确认即数据字典中的2)
- common.setStatus("2");
- common.setCreateDate(getNowDateTime());
- common.setUpdateDate(getNowDateTime());
- common.setCode(OrderNumTools.generateNextBillCode("DC" + getNowDate(), 10, "t_b_schedule_superivse", "code", 4));
- superivseService.save(common);
- // add-刘梦祥-2022年11月28日16:12:35(经确认当用户添加督查管理表单时,需要提示用户)
- sysMsgService.saveSysMsg(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_2,common.getUserId(),common.getResponsibleUserId());
- sysMsgService.saveSysMsgToDepart(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_2,common.getUserId(),common.getResponsibleUserId());
- } catch (Exception e) {
- e.printStackTrace();
- message = "添加失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd");
- private static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- public static String getNowDate() {
- Date now = new Date();
- String time = sdfDate.format(now);
- return time;
- }
- public static String getNowDateTime() {
- Date now = new Date();
- String time = sdfTime.format(now);
- return time;
- }
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(TBScheduleSuperivse common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "档案删除成功";
- try {
- superivseService.removeById(common);
- } catch (Exception e) {
- e.printStackTrace();
- message = "档案删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "getName")
- @ResponseBody
- public List getName(HttpServletRequest request) {
- String name = request.getParameter("name");
- String sql = "select ID,realname from t_s_base_user where 1=1";
- if (!StringUtil.isEmpty(name)) {
- sql += " and realname like '%" + name + "%'";
- }
- List<Object[]> list = systemService.findListbySql(sql);
- List<Map<String, String>> values = list.stream().map(e -> {
- Map<String, String> map = new HashMap();
- map.put("code", e[0].toString());
- map.put("name", e[1].toString());
- return map;
- }).collect(Collectors.toList());
- return values;
- }
- }
|