OrderProjectApiController.java 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. package com.goafanti.order.controller;
  2. import java.io.IOException;
  3. import java.io.OutputStream;
  4. import java.text.ParseException;
  5. import java.text.SimpleDateFormat;
  6. import java.util.Date;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestMethod;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import com.goafanti.common.bo.Result;
  15. import com.goafanti.common.constant.ErrorConstants;
  16. import com.goafanti.common.controller.CertifyApiController;
  17. import com.goafanti.common.model.TTaskHours;
  18. import com.goafanti.common.utils.StringUtils;
  19. import com.goafanti.core.shiro.token.TokenManager;
  20. import com.goafanti.order.bo.TOrderTaskDetailBo;
  21. import com.goafanti.order.bo.TaskProgressBo;
  22. import com.goafanti.order.service.OrderProjectService;
  23. @RestController
  24. @RequestMapping(value = "/api/admin/orderProject")
  25. public class OrderProjectApiController extends CertifyApiController {
  26. @Autowired
  27. private OrderProjectService orderProjectService;
  28. /**
  29. * 项目分配
  30. * taskId 项目ID
  31. * taskReceiverId 受理人ID
  32. * specially 0 任务派单(咨询师经理派单) 1项目派单(咨询师管理员派单)2咨询师退回给经理
  33. */
  34. @RequestMapping(value = "/projectDistribution", method = RequestMethod.POST)
  35. public Result projectDistribution(Integer taskId,String taskReceiverId,Integer specially ){
  36. Result res = new Result();
  37. if(null==taskId || StringUtils.isBlank(taskReceiverId)){
  38. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务编号和受理人"));
  39. return res;
  40. }
  41. res.setData(orderProjectService.updateProjectDistribution( taskId, taskReceiverId,specially));
  42. return res;
  43. }
  44. /**
  45. * 任务派单列表
  46. */
  47. @RequestMapping(value="/orderTaskList" ,method = RequestMethod.GET)
  48. public Result orderTaskList(String name,String orderNo,String taskId,Integer taskStatus,String adminName,Integer specially,String depId ,Integer pageNo,Integer pageSize,Integer outsource){
  49. Result res=new Result();
  50. res.setData(orderProjectService.orderTaskList( name, orderNo, taskId, taskStatus, adminName,specially , depId,pageNo, pageSize, outsource));
  51. return res;
  52. }
  53. /**
  54. * 任务派单查询
  55. */
  56. @RequestMapping(value="/selectTaskList" ,method = RequestMethod.GET)
  57. public Result selectTaskList(String name,String orderNo,String taskId,Integer taskStatus,String adminName,Integer specially ,String depId ,Integer pageNo,Integer pageSize){
  58. Result res=new Result();
  59. res.setData(orderProjectService.selectTaskList( name, orderNo, taskId, taskStatus, adminName,specially , depId ,pageNo, pageSize));
  60. return res;
  61. }
  62. /**
  63. * 任务详情
  64. */
  65. @RequestMapping(value="/orderTaskDetail" ,method = RequestMethod.GET)
  66. public Result orderTaskDetail(String id){
  67. Result res=new Result();
  68. res.setData(orderProjectService.orderTaskDetail(id));
  69. return res;
  70. }
  71. /**
  72. * 任务修改
  73. */
  74. @RequestMapping(value="/updateOrderTask" ,method = RequestMethod.POST)
  75. public Result updateOrderTask(TOrderTaskDetailBo t){
  76. Result res=new Result();
  77. res.setData(orderProjectService.updateOrderTask(t));
  78. return res;
  79. }
  80. /**
  81. * 添加工时
  82. */
  83. @RequestMapping(value="/addTaskHours" ,method = RequestMethod.POST)
  84. public Result addTaskHours(TTaskHours t,String taskDate){
  85. Result res=new Result();
  86. if (t.getHours()==null) {
  87. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务时间"));
  88. return res;
  89. }
  90. if (StringUtils.isBlank(taskDate)) {
  91. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作日期"));
  92. return res;
  93. }
  94. if (StringUtils.isBlank(t.getRemarks())) {
  95. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作内容"));
  96. return res;
  97. }
  98. if (StringUtils.isNotBlank(taskDate)) {
  99. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  100. try {
  101. t.setTaskDay(sdf.parse(taskDate));
  102. } catch (ParseException e) {
  103. e.printStackTrace();
  104. }
  105. }
  106. res.setData(orderProjectService.addTaskHours(t));
  107. return res;
  108. }
  109. /**
  110. * 任务工时列表
  111. */
  112. @RequestMapping(value="/taskHoursList" ,method = RequestMethod.GET)
  113. public Result taskHoursList(String name, String taskId ,String starTime,String endTime ,
  114. Integer pageNo, Integer pageSize){
  115. Result res=new Result();
  116. res.setData(orderProjectService.taskHoursList(name,taskId, starTime, endTime ,pageNo, pageSize));
  117. return res;
  118. }
  119. /**
  120. * 任务操作日志
  121. */
  122. @RequestMapping(value="/TaskLogList" ,method = RequestMethod.GET)
  123. public Result TaskLogList(Integer id){
  124. Result res=new Result();
  125. res.setData(orderProjectService.TaskLogList(id));
  126. return res;
  127. }
  128. /** 任务文件上传 **/
  129. @RequestMapping(value = "/uploadOrderTaskFile", method = RequestMethod.POST)
  130. public Result uploadOrderTaskFile(HttpServletRequest req,String sign){
  131. Result res = new Result();
  132. res.setData(handleFile(res, "/order_task_file/", false, req, sign));
  133. return res;
  134. }
  135. /**
  136. * 新增项目申报进度
  137. */
  138. @RequestMapping(value="/createTaskProgress" ,method = RequestMethod.POST)
  139. public Result createTaskProgress(TaskProgressBo t){
  140. Result res=new Result();
  141. if (StringUtils.isBlank(t.getLicenceTimes())|| null==t.getTaskId()|| null==t.getAlreadyNumber()) {
  142. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  143. }
  144. res.setData(orderProjectService.createTaskProgress(t));
  145. return res;
  146. }
  147. /**
  148. * 删除项目申报进度
  149. */
  150. @RequestMapping(value="/delectTaskProgress" ,method = RequestMethod.POST)
  151. public Result delectTaskProgress(Integer id){
  152. Result res=new Result();
  153. if (null==id) {
  154. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  155. }
  156. res.setData(orderProjectService.delectTaskProgress(id));
  157. return res;
  158. }
  159. /**
  160. * 查看项目申报进度
  161. */
  162. @RequestMapping(value="/selectTaskProgress" ,method = RequestMethod.GET)
  163. public Result selectTaskProgress(Integer tid){
  164. Result res=new Result();
  165. if (null==tid) {
  166. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  167. }
  168. res.setData(orderProjectService.selectTaskProgress(tid));
  169. return res;
  170. }
  171. /**
  172. * 任务工时表
  173. * @throws IOException
  174. */
  175. @RequestMapping(value = "/exportTaskHoursListData", method = RequestMethod.GET)
  176. public Result exportTaskHoursListData(String name, String taskId ,String starTime,String endTime ,HttpServletResponse response) throws IOException{
  177. Result res = new Result();
  178. XSSFWorkbook wb = orderProjectService.exportTaskHoursListData( name, taskId, starTime, endTime);
  179. if(null == wb){
  180. res.getError().add(buildError("", "没有找到数据"));
  181. return res;
  182. }
  183. String fileName = "任务工时表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  184. OutputStream out = response.getOutputStream();
  185. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
  186. response.setContentType("application/octet-stream;charset=utf-8");
  187. try {
  188. // 返回数据流
  189. wb.write(out);
  190. out.flush();
  191. out.close();
  192. } finally {
  193. out.flush();
  194. out.close();
  195. }
  196. return res;
  197. }
  198. /**
  199. * 我的任务列表导出xls
  200. * @throws IOException
  201. */
  202. @RequestMapping(value = "/exportMyTaskList", method = RequestMethod.GET)
  203. public Result exportMyTaskList(HttpServletResponse response) throws IOException{
  204. Result res = new Result();
  205. if(StringUtils.isBlank(TokenManager.getAdminId())){
  206. res.getError().add(buildError("", "没有找到数据"));
  207. return res;
  208. }
  209. XSSFWorkbook wb = orderProjectService.exportMyTaskList();//个人列表
  210. if(null == wb){
  211. res.getError().add(buildError("", "没有找到数据"));
  212. return res;
  213. }
  214. String fileName = "我的任务列表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  215. OutputStream out = response.getOutputStream();
  216. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
  217. response.setContentType("application/octet-stream;charset=utf-8");
  218. try {
  219. // 返回数据流
  220. wb.write(out);
  221. out.flush();
  222. out.close();
  223. } finally {
  224. out.flush();
  225. out.close();
  226. }
  227. return res;
  228. }
  229. }