ObsQuestionManage.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. package com.minpay.guomao.obsmanage.action;
  2. import java.io.IOException;
  3. import java.net.URLDecoder;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Date;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import java.util.Map;
  9. import org.springframework.context.ApplicationContext;
  10. import com.github.pagehelper.PageHelper;
  11. import com.github.pagehelper.PageInfo;
  12. import com.min.base64.Base64;
  13. import com.minpay.SpringContextUtil;
  14. import com.minpay.common.bean.User;
  15. import com.minpay.common.format.IFormatService;
  16. import com.minpay.db.table.mapper.ImBranchMapper;
  17. import com.minpay.db.table.mapper.ImUserMapper;
  18. import com.minpay.db.table.model.ImBranch;
  19. import com.minpay.db.table.model.ImUser;
  20. import com.minpay.db.table.model.ObsQuestion;
  21. import com.minpay.db.table.own.mapper.QuestionMapper;
  22. import com.minpay.db.table.service.IObsQuestionService;
  23. import com.startup.minpay.frame.business.IMINAction;
  24. import com.startup.minpay.frame.business.res.MINActionResult;
  25. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  26. import com.startup.minpay.frame.data.format.MINCopyFormat;
  27. import com.startup.minpay.frame.exception.MINBusinessException;
  28. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  29. import com.startup.minpay.frame.service.base.Service;
  30. import com.startup.minpay.frame.session.MINSession;
  31. import com.startup.minpay.frame.target.MINAction;
  32. import com.startup.minpay.frame.target.MINComponent;
  33. import com.startup.minpay.frame.target.MINParam;
  34. @MINComponent
  35. public class ObsQuestionManage implements IMINAction{
  36. public final static String QUESTION_ADD = "questionAdd";
  37. public final static String QUESTION_LIST = "questionList";
  38. public final static String QUESTION_QUERY = "questionQuery";
  39. public final static String QUESTION_EDIT = "questionEdit";
  40. public final static String QUESTION_DEAL = "questionDeal";
  41. public final static String MENU_LIST = "menuList";
  42. public final static String QUESTION_PRINT_QUERY = "questionPrintQuery";
  43. ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
  44. @MINAction(value = QUESTION_ADD)
  45. public MINActionResult questionAdd(
  46. MINSession session,
  47. @MINParam(key = "name") String name,
  48. @MINParam(key = "degree") String degree,
  49. @MINParam(key = "module") String module,
  50. @MINParam(key = "expectTime") String expectTime,
  51. @MINParam(key = "step") String step
  52. ) throws IOException{
  53. step = Base64.decode(step);
  54. step = URLDecoder.decode(step, "UTF-8");
  55. IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
  56. User u = session.getUser();
  57. Date date = new Date();
  58. SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmss");
  59. String dateString = sd.format(date);
  60. MINActionResult res = new MINActionResult();
  61. ObsQuestion obsQuestion = new ObsQuestion();
  62. obsQuestion.setOqId(String.valueOf(System.currentTimeMillis()));
  63. obsQuestion.setoqType("0");
  64. obsQuestion.setOqName(name);
  65. obsQuestion.setOqDegree(degree);
  66. obsQuestion.setOqStep(step);
  67. obsQuestion.setOqModule(module);
  68. obsQuestion.setOqExpectTime(expectTime.replaceAll("-", ""));
  69. obsQuestion.setOqState("00");
  70. obsQuestion.setOqCreateTime(dateString);
  71. obsQuestion.setOqCreateUser(u.getId());
  72. String record = u.getName() + "在" + dateString + "提出";
  73. obsQuestion.setOqRecord(record);
  74. iObsQuestionService.save(obsQuestion);
  75. return res;
  76. }
  77. @MINAction(value = QUESTION_LIST)
  78. public MINActionResult questionList(
  79. MINSession session,
  80. @MINParam(key = "keyword") String keyword,
  81. @MINParam(key = "state") String state,
  82. @MINParam(key = "page", defaultValue = "1") int page,
  83. @MINParam(key = "limit", defaultValue = "10") int limit
  84. ) throws MINBusinessException{
  85. PageHelper.startPage(page, limit);
  86. Map<String, Object> param = new HashMap<>();
  87. param.put("keyword", keyword);
  88. param.put("state", state);
  89. List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class).getMybatisMapper(QuestionMapper.class)
  90. .getList(param);
  91. list = Service.lookup(IFormatService.class).formatDateTime(list, "oqCreateTime", "oqUpdateTime");
  92. list = new MINCopyFormat("{oqState:'oqStateDesc'}").format(list);
  93. list = Service.lookup(IFormatService.class).formatEnum(list,"{oqStateDesc:'obs_question_state'}");
  94. PageInfo<Map<String, String>> pageList = new PageInfo<>(list);
  95. MINActionResult res = new MINActionResult();
  96. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  97. res.set(IMINBusinessConstant.F_PAGING_COUNT, pageList.getTotal());
  98. return res;
  99. }
  100. @MINAction(value = QUESTION_QUERY)
  101. public MINActionResult questionQuery(
  102. @MINParam(key = "oqId") String oqId
  103. ){
  104. IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
  105. ObsQuestion obsQuestion = iObsQuestionService.getById(oqId);
  106. MINActionResult res = new MINActionResult();
  107. res.set(IMINBusinessConstant.F_PAGING_LAY, obsQuestion);
  108. return res;
  109. }
  110. @MINAction(value = QUESTION_EDIT)
  111. public MINActionResult questionEdit(
  112. MINSession session,
  113. @MINParam(key = "id") String id,
  114. @MINParam(key = "name") String name,
  115. @MINParam(key = "degree") String degree,
  116. @MINParam(key = "step") String step
  117. ){
  118. Date date = new Date();
  119. SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddhhmmss");
  120. String dateString = sd.format(date);
  121. User u = session.getUser();
  122. IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
  123. ObsQuestion obsQuestion = new ObsQuestion();
  124. obsQuestion.setOqId(id);
  125. obsQuestion.setOqName(name);
  126. obsQuestion.setOqDegree(degree);
  127. obsQuestion.setOqStep(step);
  128. obsQuestion.setOqUpdateUser(u.getId());
  129. obsQuestion.setOqUpdateTime(dateString);
  130. iObsQuestionService.updateById(obsQuestion);
  131. MINActionResult res = new MINActionResult();
  132. return res;
  133. }
  134. @MINAction(value = QUESTION_DEAL)
  135. public MINActionResult questionDeal(
  136. MINSession session,
  137. @MINParam(key = "id") String id,
  138. @MINParam(key = "state") String state,
  139. @MINParam(key = "desc") String desc
  140. ){
  141. Date date = new Date();
  142. SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmss");
  143. SimpleDateFormat sd2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  144. String dateString = sd.format(date);
  145. String dateString2 = sd2.format(date);
  146. User u = session.getUser();
  147. IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
  148. // 原记录
  149. String record = iObsQuestionService.getById(id).getOqRecord();
  150. ObsQuestion obsQuestion = new ObsQuestion();
  151. obsQuestion.setOqId(id);
  152. obsQuestion.setOqState(state);
  153. obsQuestion.setOqUpdateUser(u.getId());
  154. obsQuestion.setOqUpdateTime(dateString);
  155. // 确认
  156. if("01".equals(state)) {
  157. obsQuestion.setOqConfirmTime(dateString);
  158. obsQuestion.setOqEngineer(u.getId());
  159. record = record + "\n" + u.getName() + "在" + dateString2 + "确认";
  160. } else if("02".equals(state)) {
  161. obsQuestion.setOqCompleteTime(dateString);
  162. record = record + "\n" + u.getName() + "在" + dateString2 + "解决了该问题";
  163. } else if("03".equals(state)) {
  164. obsQuestion.setOqFeedbackTime(dateString);
  165. record = record + "\n" + u.getName() + "在" + dateString2 + "确认该问题已解决";
  166. } else if("04".equals(state)) {
  167. obsQuestion.setOqFeedbackTime(dateString);
  168. obsQuestion.setOqCompleteDesc(desc);
  169. record = record + "\n" + u.getName() + "在" + dateString2 + "确认该问题未解决";
  170. }
  171. obsQuestion.setOqRecord(record);
  172. iObsQuestionService.updateById(obsQuestion);
  173. MINActionResult res = new MINActionResult();
  174. return res;
  175. }
  176. @MINAction(value = MENU_LIST)
  177. public MINActionResult menuList(
  178. MINSession session
  179. ) throws MINBusinessException{
  180. User u = session.getUser();
  181. Map<String, Object> param = new HashMap<>();
  182. param.put("roleId", u.getRoleId());
  183. List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class).getMybatisMapper(QuestionMapper.class)
  184. .getMenuListByRoleId(param);
  185. MINActionResult res = new MINActionResult();
  186. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  187. return res;
  188. }
  189. @MINAction(value = QUESTION_PRINT_QUERY)
  190. public MINActionResult questionPrintQuery(
  191. @MINParam(key = "oqId") String oqId
  192. ) throws MINBusinessException{
  193. IObsQuestionService iObsQuestionService = applicationContext.getBean(IObsQuestionService.class);
  194. ObsQuestion obsQuestion = iObsQuestionService.getById(oqId);
  195. ImUser imUser = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImUserMapper.class).selectByPrimaryKey(obsQuestion.getOqCreateUser());
  196. ImBranch imBranch = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImBranchMapper.class).selectByPrimaryKey(imUser.getBranchid());
  197. Map<String, String> data = new HashMap<>();
  198. data.put("shenqingriqi", obsQuestion.getOqCreateTime());
  199. data.put("shenqingrenxingming", imUser.getName());
  200. data.put("suozaibumen", imBranch.getName());
  201. data.put("lianxidianhua", imUser.getPhone());
  202. Map<String, Object> param = new HashMap<>();
  203. param.put("itemId", obsQuestion.getOqModule());
  204. List<Map<String, String>> list = Service.lookup(IMINDataBaseService.class).getMybatisMapper(QuestionMapper.class)
  205. .getMenuListByRoleId(param);
  206. data.put("mukuai", list.get(0).get("menuName"));
  207. data.put("shixiangmiaoshu", obsQuestion.getOqStep());
  208. data.put("yaoqiuwanchengqixian", obsQuestion.getOqExpectTime());
  209. if(obsQuestion.getOqEngineer() != null && !"".equals(obsQuestion.getOqEngineer())) {
  210. ImUser imUser2 = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImUserMapper.class).selectByPrimaryKey(obsQuestion.getOqEngineer());
  211. if("02".equals(obsQuestion.getOqState()) || "03".equals(obsQuestion.getOqState())) {
  212. data.put("wanchengqingkuang", "已解决");
  213. } else if ("00".equals(obsQuestion.getOqState()) || "04".equals(obsQuestion.getOqState())) {
  214. data.put("wanchengqingkuang", "待确认");
  215. } else if ("01".equals(obsQuestion.getOqState())) {
  216. data.put("wanchengqingkuang", "已确认");
  217. }
  218. data.put("yaoqiuwanchengqixian", obsQuestion.getOqExpectTime());
  219. data.put("fuwurenyuan", imUser2.getName());
  220. data.put("wanchengshijian", obsQuestion.getOqCompleteTime());
  221. }
  222. if("04".equals(obsQuestion.getOqState())){
  223. data.put("shifouwancheng", "fou");
  224. } else if("03".equals(obsQuestion.getOqState())){
  225. data.put("shifouwancheng", "shi");
  226. }
  227. data.put("miaoshu", obsQuestion.getOqCompleteDesc());
  228. data.put("shenqingrenyuan", imUser.getName());
  229. data.put("fanguiriqi", obsQuestion.getOqFeedbackTime());
  230. MINActionResult res = new MINActionResult();
  231. res.set(IMINBusinessConstant.F_PAGING_LAY, data);
  232. return res;
  233. }
  234. }