123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- package com.minpay.guomao.obsmanage.action;
- import java.io.IOException;
- import java.net.URLDecoder;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.springframework.context.ApplicationContext;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.min.base64.Base64;
- import com.minpay.SpringContextUtil;
- import com.minpay.common.bean.User;
- import com.minpay.common.format.IFormatService;
- import com.minpay.db.table.mapper.ImBranchMapper;
- import com.minpay.db.table.mapper.ImUserMapper;
- import com.minpay.db.table.model.ImBranch;
- import com.minpay.db.table.model.ImUser;
- import com.minpay.db.table.model.ObsQuestion;
- import com.minpay.db.table.own.mapper.QuestionMapper;
- import com.minpay.db.table.service.IObsQuestionService;
- import com.startup.minpay.frame.business.IMINAction;
- import com.startup.minpay.frame.business.res.MINActionResult;
- import com.startup.minpay.frame.constant.IMINBusinessConstant;
- import com.startup.minpay.frame.data.format.MINCopyFormat;
- import com.startup.minpay.frame.exception.MINBusinessException;
- import com.startup.minpay.frame.service.base.IMINDataBaseService;
- import com.startup.minpay.frame.service.base.Service;
- import com.startup.minpay.frame.session.MINSession;
- import com.startup.minpay.frame.target.MINAction;
- import com.startup.minpay.frame.target.MINComponent;
- import com.startup.minpay.frame.target.MINParam;
- @MINComponent
- public class ObsQuestionManage implements IMINAction{
- public final static String QUESTION_ADD = "questionAdd";
- public final static String QUESTION_LIST = "questionList";
- public final static String QUESTION_QUERY = "questionQuery";
- public final static String QUESTION_EDIT = "questionEdit";
- public final static String QUESTION_DEAL = "questionDeal";
- public final static String MENU_LIST = "menuList";
- public final static String QUESTION_PRINT_QUERY = "questionPrintQuery";
- ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
-
- @MINAction(value = QUESTION_ADD)
- public MINActionResult questionAdd(
- MINSession session,
- @MINParam(key = "name") String name,
- @MINParam(key = "degree") String degree,
- @MINParam(key = "module") String module,
- @MINParam(key = "expectTime") String expectTime,
- @MINParam(key = "step") String step
- ) throws IOException{
- step = Base64.decode(step);
- step = URLDecoder.decode(step, "UTF-8");
-
- IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
- User u = session.getUser();
-
- Date date = new Date();
- SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmss");
- String dateString = sd.format(date);
-
- MINActionResult res = new MINActionResult();
- ObsQuestion obsQuestion = new ObsQuestion();
- obsQuestion.setOqId(String.valueOf(System.currentTimeMillis()));
- obsQuestion.setoqType("0");
- obsQuestion.setOqName(name);
- obsQuestion.setOqDegree(degree);
- obsQuestion.setOqStep(step);
- obsQuestion.setOqModule(module);
- obsQuestion.setOqExpectTime(expectTime.replaceAll("-", ""));
- obsQuestion.setOqState("00");
- obsQuestion.setOqCreateTime(dateString);
- obsQuestion.setOqCreateUser(u.getId());
- String record = u.getName() + "在" + dateString + "提出";
- obsQuestion.setOqRecord(record);
- iObsQuestionService.save(obsQuestion);
- return res;
- }
- @MINAction(value = QUESTION_LIST)
- public MINActionResult questionList(
- MINSession session,
- @MINParam(key = "keyword") String keyword,
- @MINParam(key = "state") String state,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "10") int limit
- ) throws MINBusinessException{
-
- PageHelper.startPage(page, limit);
- Map<String, Object> param = new HashMap<>();
- param.put("keyword", keyword);
- param.put("state", state);
- List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class).getMybatisMapper(QuestionMapper.class)
- .getList(param);
- list = Service.lookup(IFormatService.class).formatDateTime(list, "oqCreateTime", "oqUpdateTime");
- list = new MINCopyFormat("{oqState:'oqStateDesc'}").format(list);
- list = Service.lookup(IFormatService.class).formatEnum(list,"{oqStateDesc:'obs_question_state'}");
-
- PageInfo<Map<String, String>> pageList = new PageInfo<>(list);
- MINActionResult res = new MINActionResult();
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, pageList.getTotal());
- return res;
- }
-
- @MINAction(value = QUESTION_QUERY)
- public MINActionResult questionQuery(
- @MINParam(key = "oqId") String oqId
- ){
- IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
- ObsQuestion obsQuestion = iObsQuestionService.getById(oqId);
- MINActionResult res = new MINActionResult();
- res.set(IMINBusinessConstant.F_PAGING_LAY, obsQuestion);
- return res;
- }
-
- @MINAction(value = QUESTION_EDIT)
- public MINActionResult questionEdit(
- MINSession session,
- @MINParam(key = "id") String id,
- @MINParam(key = "name") String name,
- @MINParam(key = "degree") String degree,
- @MINParam(key = "step") String step
- ){
- Date date = new Date();
- SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddhhmmss");
- String dateString = sd.format(date);
- User u = session.getUser();
-
- IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
- ObsQuestion obsQuestion = new ObsQuestion();
- obsQuestion.setOqId(id);
- obsQuestion.setOqName(name);
- obsQuestion.setOqDegree(degree);
- obsQuestion.setOqStep(step);
- obsQuestion.setOqUpdateUser(u.getId());
- obsQuestion.setOqUpdateTime(dateString);
- iObsQuestionService.updateById(obsQuestion);
-
- MINActionResult res = new MINActionResult();
- return res;
- }
-
- @MINAction(value = QUESTION_DEAL)
- public MINActionResult questionDeal(
- MINSession session,
- @MINParam(key = "id") String id,
- @MINParam(key = "state") String state,
- @MINParam(key = "desc") String desc
- ){
- Date date = new Date();
- SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmss");
- SimpleDateFormat sd2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String dateString = sd.format(date);
- String dateString2 = sd2.format(date);
- User u = session.getUser();
-
- IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
- // 原记录
- String record = iObsQuestionService.getById(id).getOqRecord();
-
- ObsQuestion obsQuestion = new ObsQuestion();
- obsQuestion.setOqId(id);
- obsQuestion.setOqState(state);
- obsQuestion.setOqUpdateUser(u.getId());
- obsQuestion.setOqUpdateTime(dateString);
-
- // 确认
- if("01".equals(state)) {
- obsQuestion.setOqConfirmTime(dateString);
- obsQuestion.setOqEngineer(u.getId());
- record = record + "\n" + u.getName() + "在" + dateString2 + "确认";
- } else if("02".equals(state)) {
- obsQuestion.setOqCompleteTime(dateString);
- record = record + "\n" + u.getName() + "在" + dateString2 + "解决了该问题";
- } else if("03".equals(state)) {
- obsQuestion.setOqFeedbackTime(dateString);
- record = record + "\n" + u.getName() + "在" + dateString2 + "确认该问题已解决";
- } else if("04".equals(state)) {
- obsQuestion.setOqFeedbackTime(dateString);
- obsQuestion.setOqCompleteDesc(desc);
- record = record + "\n" + u.getName() + "在" + dateString2 + "确认该问题未解决";
- }
- obsQuestion.setOqRecord(record);
- iObsQuestionService.updateById(obsQuestion);
- MINActionResult res = new MINActionResult();
- return res;
- }
-
- @MINAction(value = MENU_LIST)
- public MINActionResult menuList(
- MINSession session
- ) throws MINBusinessException{
- User u = session.getUser();
- Map<String, Object> param = new HashMap<>();
- param.put("roleId", u.getRoleId());
- List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class).getMybatisMapper(QuestionMapper.class)
- .getMenuListByRoleId(param);
- MINActionResult res = new MINActionResult();
- res.set(IMINBusinessConstant.F_PAGING_LAY, list);
- return res;
- }
-
- @MINAction(value = QUESTION_PRINT_QUERY)
- public MINActionResult questionPrintQuery(
- @MINParam(key = "oqId") String oqId
- ) throws MINBusinessException{
- IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
- ObsQuestion obsQuestion = iObsQuestionService.getById(oqId);
-
- ImUser imUser = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImUserMapper.class).selectByPrimaryKey(obsQuestion.getOqCreateUser());
- ImBranch imBranch = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImBranchMapper.class).selectByPrimaryKey(imUser.getBranchid());
-
- Map<String, String> data = new HashMap<>();
- data.put("shenqingriqi", obsQuestion.getOqCreateTime());
- data.put("shenqingrenxingming", imUser.getName());
- data.put("suozaibumen", imBranch.getName());
- data.put("lianxidianhua", imUser.getPhone());
-
- Map<String, Object> param = new HashMap<>();
- param.put("itemId", obsQuestion.getOqModule());
- List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class).getMybatisMapper(QuestionMapper.class)
- .getMenuListByRoleId(param);
- data.put("mukuai", list.get(0).get("menuName"));
-
- data.put("shixiangmiaoshu", obsQuestion.getOqStep());
- data.put("yaoqiuwanchengqixian", obsQuestion.getOqExpectTime());
-
- if(obsQuestion.getOqEngineer() != null && !"".equals(obsQuestion.getOqEngineer())) {
- ImUser imUser2 = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImUserMapper.class).selectByPrimaryKey(obsQuestion.getOqEngineer());
- if("02".equals(obsQuestion.getOqState()) || "03".equals(obsQuestion.getOqState())) {
- data.put("wanchengqingkuang", "已解决");
- } else if ("00".equals(obsQuestion.getOqState()) || "04".equals(obsQuestion.getOqState())) {
- data.put("wanchengqingkuang", "待确认");
- } else if ("01".equals(obsQuestion.getOqState())) {
- data.put("wanchengqingkuang", "已确认");
- }
- data.put("yaoqiuwanchengqixian", obsQuestion.getOqExpectTime());
- data.put("fuwurenyuan", imUser2.getName());
- data.put("wanchengshijian", obsQuestion.getOqCompleteTime());
- }
-
- if("04".equals(obsQuestion.getOqState())){
- data.put("shifouwancheng", "fou");
- } else if("03".equals(obsQuestion.getOqState())){
- data.put("shifouwancheng", "shi");
- }
- data.put("miaoshu", obsQuestion.getOqCompleteDesc());
- data.put("shenqingrenyuan", imUser.getName());
- data.put("fanguiriqi", obsQuestion.getOqFeedbackTime());
-
- MINActionResult res = new MINActionResult();
- res.set(IMINBusinessConstant.F_PAGING_LAY, data);
- return res;
- }
- }
|