OrderProjectApiController.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.order.bo.TOrderTaskDetailBo;
  20. import com.goafanti.order.service.OrderProjectService;
  21. @RestController
  22. @RequestMapping(value = "/api/admin/orderProject")
  23. public class OrderProjectApiController extends CertifyApiController {
  24. @Autowired
  25. private OrderProjectService orderProjectService;
  26. /**
  27. * 项目分配
  28. */
  29. @RequestMapping(value = "/projectDistribution", method = RequestMethod.POST)
  30. public Result projectDistribution(Integer taskId,String taskReceiverId,Integer specially ){
  31. Result res = new Result();
  32. if(null==taskId || StringUtils.isBlank(taskReceiverId)){
  33. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务编号和受理人"));
  34. return res;
  35. }
  36. res.setData(orderProjectService.updateProjectDistribution( taskId, taskReceiverId,specially));
  37. return res;
  38. }
  39. /**
  40. * 任务派单列表
  41. */
  42. @RequestMapping(value="/orderTaskList" ,method = RequestMethod.GET)
  43. public Result orderTaskList(String name,String orderNo,String taskId,Integer taskStatus,String adminName,Integer specially ,Integer pageNo,Integer pageSize){
  44. Result res=new Result();
  45. res.setData(orderProjectService.orderTaskList( name, orderNo, taskId, taskStatus, adminName,specially , pageNo, pageSize));
  46. return res;
  47. }
  48. /**
  49. * 任务详情
  50. */
  51. @RequestMapping(value="/orderTaskDetail" ,method = RequestMethod.GET)
  52. public Result orderTaskDetail(String id){
  53. Result res=new Result();
  54. res.setData(orderProjectService.orderTaskDetail(id));
  55. return res;
  56. }
  57. /**
  58. * 任务修改
  59. */
  60. @RequestMapping(value="/updateOrderTask" ,method = RequestMethod.POST)
  61. public Result updateOrderTask(TOrderTaskDetailBo t){
  62. Result res=new Result();
  63. res.setData(orderProjectService.updateOrderTask(t));
  64. return res;
  65. }
  66. /**
  67. * 添加工时
  68. */
  69. @RequestMapping(value="/addTaskHours" ,method = RequestMethod.POST)
  70. public Result addTaskHours(TTaskHours t,String taskDate){
  71. Result res=new Result();
  72. if (t.getHours()==null) {
  73. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务时间"));
  74. return res;
  75. }
  76. if (StringUtils.isBlank(taskDate)) {
  77. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作日期"));
  78. return res;
  79. }
  80. if (StringUtils.isBlank(t.getRemarks())) {
  81. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作内容"));
  82. return res;
  83. }
  84. if (StringUtils.isNotBlank(taskDate)) {
  85. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  86. try {
  87. t.setTaskDay(sdf.parse(taskDate));
  88. } catch (ParseException e) {
  89. e.printStackTrace();
  90. }
  91. }
  92. res.setData(orderProjectService.addTaskHours(t));
  93. return res;
  94. }
  95. /**
  96. * 任务工时列表
  97. */
  98. @RequestMapping(value="/taskHoursList" ,method = RequestMethod.GET)
  99. public Result taskHoursList(String name, String taskId ,String starTime,String endTime ,
  100. Integer pageNo, Integer pageSize){
  101. Result res=new Result();
  102. res.setData(orderProjectService.taskHoursList(name,taskId, starTime, endTime ,pageNo, pageSize));
  103. return res;
  104. }
  105. /** 任务文件上传 **/
  106. @RequestMapping(value = "/uploadOrderTaskFile", method = RequestMethod.POST)
  107. public Result uploadOrderTaskFile(HttpServletRequest req,String sign){
  108. Result res = new Result();
  109. //order_refund_file
  110. res.setData(handleFile(res, "/order_task_file/", false, req, sign));
  111. return res;
  112. }
  113. /**
  114. * 任务工时表
  115. * @throws IOException
  116. */
  117. @RequestMapping(value = "/exportTaskHoursListData", method = RequestMethod.GET)
  118. public Result exportTaskHoursListData(String name, String taskId ,String starTime,String endTime ,HttpServletResponse response) throws IOException{
  119. Result res = new Result();
  120. XSSFWorkbook wb = orderProjectService.exportTaskHoursListData( name, taskId, starTime, endTime);
  121. if(null == wb){
  122. res.getError().add(buildError("", "没有找到数据"));
  123. return res;
  124. }
  125. String fileName = "任务工时表 " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + ".xls";
  126. OutputStream out = response.getOutputStream();
  127. response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
  128. response.setContentType("application/octet-stream;charset=utf-8");
  129. try {
  130. // 返回数据流
  131. wb.write(out);
  132. out.flush();
  133. out.close();
  134. } finally {
  135. out.flush();
  136. out.close();
  137. }
  138. return res;
  139. }
  140. }