OrderProjectApiController.java 8.4 KB

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