OrderProjectApiController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. package com.goafanti.order.controller;
  2. import java.io.IOException;
  3. import java.text.ParseException;
  4. import java.text.SimpleDateFormat;
  5. import java.util.List;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. import javax.validation.Valid;
  9. import com.goafanti.order.bo.*;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.validation.BindingResult;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.goafanti.common.bo.Result;
  17. import com.goafanti.common.constant.AFTConstants;
  18. import com.goafanti.common.constant.ErrorConstants;
  19. import com.goafanti.common.controller.CertifyApiController;
  20. import com.goafanti.common.enums.OfficialPatentType;
  21. import com.goafanti.common.model.TTaskHours;
  22. import com.goafanti.common.utils.StringUtils;
  23. import com.goafanti.common.utils.excel.NewExcelUtil;
  24. import com.goafanti.core.shiro.token.TokenManager;
  25. import com.goafanti.order.service.OrderProjectService;
  26. @RestController
  27. @RequestMapping(value = "/api/admin/orderProject")
  28. public class OrderProjectApiController extends CertifyApiController {
  29. @Autowired
  30. private OrderProjectService orderProjectService;
  31. @Value(value = "${upload.path}")
  32. private String uploadPath = null;
  33. /**
  34. * 项目分配
  35. * taskId 项目ID
  36. * taskReceiverId 受理人ID
  37. * type 0管理员派单 1经理转交 2经理派单 3咨询师转交 4回退
  38. */
  39. @RequestMapping(value = "/projectDistribution", method = RequestMethod.POST)
  40. public Result projectDistribution(Integer taskId,String taskReceiverId ,String remarks,Integer type){
  41. Result res = new Result();
  42. if(null==taskId || StringUtils.isBlank(taskReceiverId)){
  43. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务编号和受理人"));
  44. return res;
  45. }
  46. if(type==null) type=0;
  47. boolean flag=true;
  48. if (type==0&&(TokenManager.hasRole(AFTConstants.TECH_ADMIN)||TokenManager.hasRole(AFTConstants.SUPERADMIN)))flag=false;
  49. else if ((type==1||type==2)&&TokenManager.hasRole(AFTConstants.TECH_MANAGER))flag=false;
  50. else if ((type==3||type==4)&&TokenManager.hasRole(AFTConstants.TECH))flag=false;
  51. if (flag) {
  52. res.getError().add(buildError("角色不正确,请勿在浏览器登录多个账号!"));
  53. return res;
  54. }
  55. res.setData(orderProjectService.updateProjectDistribution( taskId, taskReceiverId,remarks,type));
  56. return res;
  57. }
  58. /**
  59. * 任务派单列表 我的任务,我的外包任务
  60. * specially 0我的任务 1任务派单
  61. */
  62. @RequestMapping(value="/orderTaskList" ,method = RequestMethod.GET)
  63. public Result orderTaskList(inuptTaskListBo ib){
  64. Result res=new Result();
  65. res.setData(orderProjectService.orderTaskList(ib));
  66. return res;
  67. }
  68. /**
  69. * 任务派单查询
  70. */
  71. @RequestMapping(value="/selectTaskList" ,method = RequestMethod.GET)
  72. public Result selectTaskList(String name,String orderNo,String taskId,Integer taskStatus,String adminName,Integer specially ,String depId ,Integer pageNo,Integer pageSize){
  73. Result res=new Result();
  74. res.setData(orderProjectService.selectTaskList( name, orderNo, taskId, taskStatus, adminName,specially , depId ,pageNo, pageSize));
  75. return res;
  76. }
  77. /**
  78. * 经理查询订单
  79. */
  80. @RequestMapping(value="/managerSelect" ,method = RequestMethod.GET)
  81. public Result managerSelect(String name,String orderNo,String contractNo,String cid,String projectType,
  82. String depId,String techDepId ,Integer declarationBatch ,String commodityPrice,String startTime,
  83. String endTime,Integer pageNo,Integer pageSize){
  84. Result res=new Result();
  85. res.setData(orderProjectService.managerSelect( name, orderNo, contractNo, cid, projectType,
  86. depId, techDepId , declarationBatch ,commodityPrice,startTime, endTime , pageNo, pageSize));
  87. return res;
  88. }
  89. /**
  90. * 经理查询订单
  91. */
  92. @RequestMapping(value="/exportManagerSelect" ,method = RequestMethod.GET)
  93. public Result exportManagerSelect(String name,String orderNo,String contractNo,String cid,String projectType,
  94. String depId,String techDepId ,Integer declarationBatch ,String commodityPrice,String startTime,
  95. String endTime,Integer pageNo,Integer pageSize){
  96. @SuppressWarnings("unchecked")
  97. List<managerListBo> list=(List<managerListBo>) orderProjectService.managerSelect( name, orderNo, contractNo,
  98. cid, projectType,depId, techDepId , declarationBatch ,commodityPrice,startTime, endTime , pageNo, pageSize).getList();
  99. NewExcelUtil<managerListBo> excel=new NewExcelUtil<>(managerListBo.class);
  100. return excel.exportExcel(list, "企业项目查询列表", uploadPath);
  101. }
  102. /**
  103. * 任务详情
  104. */
  105. @RequestMapping(value="/orderTaskDetail" ,method = RequestMethod.GET)
  106. public Result orderTaskDetail(String id){
  107. Result res=new Result();
  108. res.setData(orderProjectService.orderTaskDetail(id));
  109. return res;
  110. }
  111. /**
  112. * 任务修改(咨询师)
  113. */
  114. @RequestMapping(value="/updateOrderTask" ,method = RequestMethod.POST)
  115. public Result updateOrderTask(TOrderTaskDetailBo t){
  116. Result res=new Result();
  117. res.setData(orderProjectService.updateOrderTask(t));
  118. return res;
  119. }
  120. /**
  121. * 修改状态(咨询师)
  122. */
  123. @RequestMapping(value="/updateProjectStatus" ,method = RequestMethod.POST)
  124. public Result updateProjectStatus(@Valid UpdateProjectStatusBo a,BindingResult bindingResult){
  125. Result res=new Result();
  126. if (bindingResult.hasErrors()) {
  127. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage()));
  128. return res;
  129. }
  130. res.setData(orderProjectService.updateProjectStatus( a));
  131. return res;
  132. }
  133. /**
  134. * 添加工时
  135. */
  136. @RequestMapping(value="/addTaskHours" ,method = RequestMethod.POST)
  137. public Result addTaskHours(TTaskHours t,String taskDate){
  138. Result res=new Result();
  139. if (t.getHours()==null) {
  140. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务时间"));
  141. return res;
  142. }
  143. if (StringUtils.isBlank(taskDate)) {
  144. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作日期"));
  145. return res;
  146. }
  147. if (StringUtils.isBlank(t.getRemarks())) {
  148. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作内容"));
  149. return res;
  150. }
  151. if (StringUtils.isNotBlank(taskDate)) {
  152. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  153. try {
  154. t.setTaskDay(sdf.parse(taskDate));
  155. } catch (ParseException e) {
  156. e.printStackTrace();
  157. }
  158. }
  159. res.setData(orderProjectService.addTaskHours(t));
  160. return res;
  161. }
  162. /**
  163. * 任务工时列表
  164. */
  165. @RequestMapping(value="/taskHoursList" ,method = RequestMethod.GET)
  166. public Result taskHoursList(inuptTaskHoursListBo ib,
  167. Integer pageNo, Integer pageSize){
  168. Result res=new Result();
  169. res.setData(orderProjectService.taskHoursList(ib,pageNo, pageSize));
  170. return res;
  171. }
  172. /**
  173. * 任务工时详情列表
  174. */
  175. @RequestMapping(value="/taskHoursDetailsList" ,method = RequestMethod.GET)
  176. public Result taskHoursDetailsList( String taskId ){
  177. Result res=new Result();
  178. if (StringUtils.isBlank(taskId)) {
  179. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目编号"));
  180. return res;
  181. }
  182. res.setData(orderProjectService.taskHoursDetailsList(taskId));
  183. return res;
  184. }
  185. /**
  186. * 任务操作日志
  187. */
  188. @RequestMapping(value="/TaskLogList" ,method = RequestMethod.GET)
  189. public Result TaskLogList(Integer id){
  190. Result res=new Result();
  191. res.setData(orderProjectService.TaskLogList(id));
  192. return res;
  193. }
  194. /** 任务文件上传 **/
  195. @RequestMapping(value = "/uploadOrderTaskFile", method = RequestMethod.POST)
  196. public Result uploadOrderTaskFile(HttpServletRequest req,String sign){
  197. Result res = new Result();
  198. res.setData(handleFile(res, "/order_task_file/", false, req, sign));
  199. return res;
  200. }
  201. /**
  202. * 新增项目申报进度
  203. */
  204. @RequestMapping(value="/createTaskProgress" ,method = RequestMethod.POST)
  205. public Result createTaskProgress(TaskProgressBo t){
  206. Result res=new Result();
  207. if ( null==t.getTaskId()|| null==t.getAlreadyNumber()) {
  208. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  209. }
  210. res.setData(orderProjectService.createTaskProgress(t));
  211. return res;
  212. }
  213. /**
  214. * 修改项目申报进度
  215. */
  216. @RequestMapping(value="/updateTaskProgress" ,method = RequestMethod.POST)
  217. public Result updateTaskProgress(TaskProgressBo t){
  218. Result res=new Result();
  219. if (null==t.getTaskId()|| null==t.getAlreadyNumber()) {
  220. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  221. }
  222. res.setData(orderProjectService.updateTaskProgress(t));
  223. return res;
  224. }
  225. /**
  226. * 删除项目申报进度
  227. */
  228. @RequestMapping(value="/delectTaskProgress" ,method = RequestMethod.POST)
  229. public Result delectTaskProgress(Integer id){
  230. Result res=new Result();
  231. if (null==id) {
  232. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  233. }
  234. res.setData(orderProjectService.delectTaskProgress(id));
  235. return res;
  236. }
  237. /**
  238. * 查看项目申报进度
  239. */
  240. @RequestMapping(value="/selectTaskProgress" ,method = RequestMethod.GET)
  241. public Result selectTaskProgress(Integer tid){
  242. Result res=new Result();
  243. if (null==tid) {
  244. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  245. }
  246. res.setData(orderProjectService.selectTaskProgress(tid));
  247. return res;
  248. }
  249. /**
  250. * 项目申报进度日志
  251. */
  252. @RequestMapping(value="/selectTaskProgressLog" ,method = RequestMethod.GET)
  253. public Result selectTaskProgressLog(Integer tid){
  254. Result res=new Result();
  255. if (null==tid) {
  256. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  257. }
  258. res.setData(orderProjectService.selectTaskProgressLog(tid));
  259. return res;
  260. }
  261. /**
  262. * 拆分项目
  263. */
  264. @RequestMapping(value="/addSplitProject" ,method = RequestMethod.POST)
  265. public Result addSplitProject(Integer tid,String splitList){
  266. Result res=new Result();
  267. if (null==tid||StringUtils.isBlank(splitList)) {
  268. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"项目和拆分数","项目和拆分数"));
  269. return res;
  270. }
  271. int i=orderProjectService.pushSplitProject(tid,splitList);
  272. if (i==-1) {
  273. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"拆分数","拆分数"));
  274. return res;
  275. }
  276. res.setData(i);
  277. return res;
  278. }
  279. /**
  280. * 拆分项目列表
  281. */
  282. @RequestMapping(value="/splitProjectList" ,method = RequestMethod.GET)
  283. public Result splitProjectList(Integer tid){
  284. Result res=new Result();
  285. if (null==tid) {
  286. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"项目和拆分数","项目和拆分数"));
  287. return res;
  288. }
  289. res.setData(orderProjectService.splitProjectList(tid));
  290. return res;
  291. }
  292. /**
  293. * 我的工时列表导出xls
  294. * @throws IOException
  295. */
  296. @RequestMapping(value = "/exportMyTaskList", method = RequestMethod.GET)
  297. public Result exportMyTaskList(HttpServletResponse response,inuptTaskHoursListBo ib, Integer pageNo, Integer pageSize) {
  298. if(pageSize==null)pageSize=999999;
  299. @SuppressWarnings("unchecked")
  300. List<TOrderTaskListBo> list=(List<TOrderTaskListBo>) orderProjectService.taskHoursList(ib, pageNo, pageSize).getList();
  301. NewExcelUtil<TOrderTaskListBo> excel=new NewExcelUtil<>(TOrderTaskListBo.class);
  302. return excel.exportExcel(list, "工时信息记录表", response);
  303. }
  304. /**
  305. * 我的任务列表导出xls
  306. * @throws IOException
  307. */
  308. @RequestMapping(value = "/exporProjectList", method = RequestMethod.GET)
  309. public Result exporProjectList(HttpServletResponse response,inuptTaskListBo ib) {
  310. if(ib.getPageSize()==null)ib.setPageSize(99999);
  311. String str="项目任务列表";
  312. @SuppressWarnings("unchecked")
  313. List<TOrderTaskListBo> list=(List<TOrderTaskListBo>) orderProjectService.orderTaskList(ib).getList();
  314. NewExcelUtil<TOrderTaskListBo>excel=new NewExcelUtil<>(TOrderTaskListBo.class);
  315. return excel.exportExcel(list, str, response);
  316. }
  317. /**
  318. * 项目日志 (转交日志)
  319. * @param tid
  320. * @return
  321. */
  322. @RequestMapping(value = "/taskAttributionLog",method = RequestMethod.GET)
  323. public Result taskAttributionLog(Integer tid) {
  324. Result res =new Result();
  325. if (tid==null) {
  326. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"项目编号","项目编号"));
  327. return res;
  328. }
  329. res.data(orderProjectService.taskAttributionLog(tid));
  330. return res;
  331. }
  332. /**
  333. * 客户项目列表
  334. * @return
  335. */
  336. @RequestMapping(value = "/selectUidByproject",method = RequestMethod.GET)
  337. public Result selectUidByproject(String uid) {
  338. Result res =new Result();
  339. if (uid==null) {
  340. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"客户编号","客户编号"));
  341. return res;
  342. }
  343. res.data( orderProjectService.selectUidByproject(uid) );
  344. return res;
  345. }
  346. /**
  347. * 发起项目核对
  348. * @param tid
  349. * @return
  350. */
  351. @RequestMapping(value = "/addProjectCheck",method = RequestMethod.POST)
  352. public Result addProjectCheck(Integer tid) {
  353. Result res =new Result();
  354. if (tid==null) {
  355. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"项目编号","项目编号"));
  356. return res;
  357. }
  358. res.data( orderProjectService.addProjectCheck(tid) );
  359. return res;
  360. }
  361. /**
  362. * 核对日志
  363. * @param tid
  364. * @return
  365. */
  366. @RequestMapping(value = "/projectCheckLog",method = RequestMethod.GET)
  367. public Result projectCheckLog(Integer tid) {
  368. Result res =new Result();
  369. if (tid==null) {
  370. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"项目编号","项目编号"));
  371. return res;
  372. }
  373. res.data( orderProjectService.projectCheckLog(tid) );
  374. return res;
  375. }
  376. /**
  377. * 获取专利分类
  378. * @return
  379. */
  380. @RequestMapping(value = "/getPatentType",method = RequestMethod.GET)
  381. public Result getPatentType() {
  382. Result res =new Result();
  383. res.data(OfficialPatentType.getStatus());
  384. return res;
  385. }
  386. /**
  387. * 核对列表
  388. * @return
  389. */
  390. @RequestMapping(value = "/selectProjectCheck",method = RequestMethod.GET)
  391. public Result selectProjectCheck(InputProjectCheck in) {
  392. Result res =new Result();
  393. res.data(orderProjectService.selectProjectCheck(in));
  394. return res;
  395. }
  396. /**
  397. * 高新复审统计
  398. */
  399. @RequestMapping(value = "/highNewRetrialStatistics",method = RequestMethod.GET)
  400. public Result highNewRetrialStatistics(String depId,String startDate,String endDate) {
  401. Result res =new Result();
  402. res.data(orderProjectService.highNewRetrialStatistics(depId,startDate,endDate));
  403. return res;
  404. }
  405. /**
  406. * 高新复审统计
  407. */
  408. @RequestMapping(value = "/highNewRetrialStatistics/export",method = RequestMethod.GET)
  409. public Result highNewRetrialStatisticsExport(String depId,String startDate,String endDate,String depName) {
  410. Result res =new Result();
  411. List<OutHighNewRetrialStatistics> list=orderProjectService.highNewRetrialStatistics(depId,startDate,endDate);
  412. NewExcelUtil<OutHighNewRetrialStatistics> newExcelUtil=new NewExcelUtil<>(OutHighNewRetrialStatistics.class);
  413. StringBuffer str=new StringBuffer("搜索条件=》");
  414. if (depName!=null)str=str.append("部门:").append(depName).append(",");
  415. if (startDate!=null&&endDate!=null)str=str.append("时间:").append(startDate).append("~").append(endDate).append(",");
  416. return newExcelUtil.exportExcel(list,"高新复审统计",uploadPath,str.substring(0,str.toString().length()-1));
  417. }
  418. }