| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- package cn.com.lzt.complain.controller;
- import cn.com.lzt.complain.service.ComplainRecordService;
- import cn.com.lzt.complain.service.impl.ComplainServiceImpl;
- import cn.com.lzt.sysmsg.service.SysMsgServiceI;
- 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.TBComplaint;
- import com.daju.mix.dao.entity.TBComplaintRecord;
- import com.daju.mix.dao.entity.TBScheduleSuperivse;
- import com.daju.mix.dao.mapper.TBComplaintMapper;
- import com.daju.mix.dao.mapper.TBComplaintRecordMapper;
- 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 javax.transaction.Transactional;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * @author :sahib.kio.m
- * @date :Created in 2021/8/13 下午3:20
- */
- @RequestMapping("/complainController")
- @Controller
- public class ComplainController {
- @Resource
- private ComplainServiceImpl complainService;
- @Resource
- private ComplainRecordService complainRecordService;
- @Resource
- private TBComplaintRecordMapper tbComplaintRecordMapper;
- @Resource
- private TBComplaintMapper tbComplaintMapper;
- // add-刘梦祥-2022年8月25日11:13:37(投诉业务添加系统消息提示)
- @Autowired
- private SysMsgServiceI sysMsgService;
- @Autowired
- private SystemService systemService;
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- for (String key : request.getParameterMap().keySet()){
- request.setAttribute(key, request.getParameter(key));
- }
- return new ModelAndView("cn/com/lzt/complain/complainList");
- }
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/complain/complainList-add");
- }
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(HttpServletRequest request) {
- String id = request.getParameter("id");
- TBComplaint common = complainService.getById(id);
- common = scheduleImageUrl(common);
- request.setAttribute("common", common);
- return new ModelAndView("cn/com/lzt/complain/complainList-update");
- }
- public TBComplaint scheduleImageUrl(TBComplaint 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);
- }
- }
- }
- }
- return common;
- }
- @RequestMapping(params = "goCheck")
- public ModelAndView goCheck(HttpServletRequest request) {
- String id = request.getParameter("id");
- List<TBComplaintRecord> list = complainRecordService.list(new QueryWrapper<TBComplaintRecord>(){{
- eq("complaint_id", id);
- orderByDesc("complaint_date");
- }});
- request.setAttribute("list", list);
- if (CollectionUtils.isEmpty(list)) {
- request.setAttribute("noRecord", "无整改记录");
- }
- return new ModelAndView("cn/com/lzt/complain/complainList-check");
- }
- @RequestMapping(params = "goDeal")
- public ModelAndView goDeal(HttpServletRequest request) {
- for (String key : request.getParameterMap().keySet()){
- request.setAttribute(key, request.getParameter(key));
- }
- return new ModelAndView("cn/com/lzt/complain/complainList-deal");
- }
- @RequestMapping(params = "goConfirm")
- public ModelAndView goConfirm(HttpServletRequest request) {
- for (String key : request.getParameterMap().keySet()){
- request.setAttribute(key, request.getParameter(key));
- }
- return new ModelAndView("cn/com/lzt/complain/complainList-confirm");
- }
- @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 = complainService.list(param);
- TagUtil.datagrid(response, dataGrid, result);
- }
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(TBComplaint common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "档案添加成功";
- j.setSuccess(true);
- try{ // p_device_defend
- common.setCode(OrderNumTools.generateNextBillCode("" + getNowDate(),8, "t_b_complaint", "code", 4));
- if(StringUtils.isNotEmpty(common.getType())){
- // 判断投诉类型是不是垃圾清运,是的话就是清运科,否则是保洁科,默认是保洁科
- if(common.getType().equals("2")){
- common.setDepartId("清运科");
- }else{
- common.setDepartId("保洁科");
- }
- }
- TSUser user = ResourceUtil.getSessionUser();
- if (user != null){
- String userId = user.getId();
- common.setCreateDate(new Date());
- common.setCreateBy(userId);
- }
- common.setStatus("1");
- tbComplaintMapper.insert(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "档案添加失败";
- j.setMsg(message);
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(TBComplaint common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "更新成功";
- j.setSuccess(true);
- try{
- complainService.updateById(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "更新失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(TBComplaint common, HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "档案删除成功";
- try{
- complainService.removeById(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "档案删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- /**
- * add-刘梦祥-2022年6月21日13:26:24
- * 投诉管理完善下发逻辑
- * @param common
- * @param request
- * @return
- */
- @RequestMapping(params = "turnTo")
- @ResponseBody
- @Transactional
- public AjaxJson turnTo(TBComplaint common, HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "下发成功";
- try{
- common = complainService.getById(common.getId());
- if(common.getLeaderUserId() != null){
- common.setStatus("2");
- complainService.updateById(common);
- TSUser tSUser = ResourceUtil.getSessionUser();
- // 经确认下发后需要发送系统消息给责任人的科长和科室管理人员,可以写一个SQL获取到责任人的科室对应的科长和科室管理人员。
- String getPostUserId = "SELECT\n" +
- "\ttsu.id userId, tsd.departname, tbp.post_name\n" +
- "FROM\n" +
- "\tt_s_user tsu\n" +
- "LEFT JOIN t_s_user_org tsuo ON tsuo.user_id = tsu.id\n" +
- "LEFT JOIN t_bus_user_personnel tbup ON tbup.userid = tsu.id\n" +
- "LEFT JOIN t_s_depart tsd ON tsd.id = tsuo.org_id\n" +
- "LEFT JOIN t_bus_post tbp ON tbp.id = tbup.in_postid\n" +
- "WHERE\n" +
- "\ttsd.id in (select tsd.id from t_s_depart tsd LEFT JOIN t_s_user_org tsuo on tsuo.org_id = tsd.id where tsuo.user_id = '"+common.getResponsibleUserId()+"')\n" +
- "\tand tbp.post_name in ('科室科长','科室管理人员')\n;";
- List<Object[]> list = this.systemService.findListbySql(getPostUserId);
- if(list != null && list.size() > 0){
- for (Object[] item : list){
- if(item[0] != null){
- sysMsgService.saveSysMsg(Globals.MSG_TITLE_1,Globals.MSG_CONTENT_1,tSUser.getId(),item[0].toString());
- }
- }
- }
- }else{
- j.setSuccess(false);
- message = "下发失败!请指定责任人!";
- }
- }catch(Exception e){
- e.printStackTrace();
- message = "更新失败";
- j.setSuccess(false);
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doBack")
- @ResponseBody
- public AjaxJson doBack(TBComplaint common, HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "更新成功";
- try{
- common = complainService.getById(common.getId());
- common.setStatus("2");
- common.setBackStatus("1");
- complainService.updateById(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "更新失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doDeal")
- @ResponseBody
- public AjaxJson doDeal(TBComplaintRecord common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "更新成功";
- j.setSuccess(true);
- try{
- common.setComplaintDate(getNowDateTime());
- tbComplaintRecordMapper.insert(common);
- TBComplaint tbComplain = complainService.getById(common.getComplaintId());
- tbComplain.setStatus("3");
- tbComplain.setBackStatus("");
- tbComplain.setDealDate(getNowDateTime());
- complainService.updateById(tbComplain);
- }catch(Exception e){
- e.printStackTrace();
- message = "更新失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "confirm")
- @ResponseBody
- public AjaxJson confirm(TBComplaint common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "更新成功";
- j.setSuccess(true);
- try{
- common.setStatus("4");
- common.setBackStatus("2");
- complainService.updateById(common);
- }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;
- }
- }
|