OrderProjectApiController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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. */
  63. @RequestMapping(value="/orderTaskList" ,method = RequestMethod.GET)
  64. public Result orderTaskList(inuptTaskListBo ib){
  65. Result res=new Result();
  66. res.setData(orderProjectService.orderTaskList(ib));
  67. return res;
  68. }
  69. /**
  70. * 任务派单查询
  71. */
  72. @RequestMapping(value="/selectTaskList" ,method = RequestMethod.GET)
  73. public Result selectTaskList(String name,String orderNo,String taskId,Integer taskStatus,String adminName,Integer specially ,String depId ,Integer pageNo,Integer pageSize){
  74. Result res=new Result();
  75. res.setData(orderProjectService.selectTaskList( name, orderNo, taskId, taskStatus, adminName,specially , depId ,pageNo, pageSize));
  76. return res;
  77. }
  78. /**
  79. * 经理查询订单
  80. */
  81. @RequestMapping(value="/managerSelect" ,method = RequestMethod.GET)
  82. public Result managerSelect(String name,String orderNo,String contractNo,String cid,String projectType,
  83. String depId,String techDepId ,Integer declarationBatch ,String commodityPrice,String startTime,
  84. String endTime,Integer pageNo,Integer pageSize){
  85. Result res=new Result();
  86. res.setData(orderProjectService.managerSelect( name, orderNo, contractNo, cid, projectType,
  87. depId, techDepId , declarationBatch ,commodityPrice,startTime, endTime , pageNo, pageSize));
  88. return res;
  89. }
  90. /**
  91. * 经理查询订单
  92. */
  93. @RequestMapping(value="/exportManagerSelect" ,method = RequestMethod.GET)
  94. public Result exportManagerSelect(String name,String orderNo,String contractNo,String cid,String projectType,
  95. String depId,String techDepId ,Integer declarationBatch ,String commodityPrice,String startTime,
  96. String endTime,Integer pageNo,Integer pageSize){
  97. @SuppressWarnings("unchecked")
  98. List<managerListBo> list=(List<managerListBo>) orderProjectService.managerSelect( name, orderNo, contractNo,
  99. cid, projectType,depId, techDepId , declarationBatch ,commodityPrice,startTime, endTime , pageNo, pageSize).getList();
  100. NewExcelUtil<managerListBo> excel=new NewExcelUtil<>(managerListBo.class);
  101. return excel.exportExcel(list, "企业项目查询列表", uploadPath);
  102. }
  103. /**
  104. * 任务详情
  105. */
  106. @RequestMapping(value="/orderTaskDetail" ,method = RequestMethod.GET)
  107. public Result orderTaskDetail(String id){
  108. Result res=new Result();
  109. res.setData(orderProjectService.orderTaskDetail(id));
  110. return res;
  111. }
  112. /**
  113. * 任务修改(咨询师)
  114. */
  115. @RequestMapping(value="/updateOrderTask" ,method = RequestMethod.POST)
  116. public Result updateOrderTask(TOrderTaskDetailBo t){
  117. Result res=new Result();
  118. res.setData(orderProjectService.updateOrderTask(t));
  119. return res;
  120. }
  121. /**
  122. * 修改项目状态(咨询师)
  123. */
  124. @RequestMapping(value="/updateProjectStatus" ,method = RequestMethod.POST)
  125. public Result updateProjectStatus(@Valid UpdateProjectStatusBo a,BindingResult bindingResult){
  126. Result res=new Result();
  127. if (bindingResult.hasErrors()) {
  128. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage()));
  129. return res;
  130. }
  131. res.setData(orderProjectService.updateProjectStatus( a));
  132. return res;
  133. }
  134. /**
  135. * 添加工时
  136. */
  137. @RequestMapping(value="/addTaskHours" ,method = RequestMethod.POST)
  138. public Result addTaskHours(TTaskHours t,String taskDate){
  139. Result res=new Result();
  140. if (t.getHours()==null) {
  141. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "任务时间"));
  142. return res;
  143. }
  144. if (StringUtils.isBlank(taskDate)) {
  145. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作日期"));
  146. return res;
  147. }
  148. if (StringUtils.isBlank(t.getRemarks())) {
  149. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "工作内容"));
  150. return res;
  151. }
  152. if (StringUtils.isNotBlank(taskDate)) {
  153. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  154. try {
  155. t.setTaskDay(sdf.parse(taskDate));
  156. } catch (ParseException e) {
  157. e.printStackTrace();
  158. }
  159. }
  160. res.setData(orderProjectService.addTaskHours(t));
  161. return res;
  162. }
  163. /**
  164. * 任务工时列表
  165. */
  166. @RequestMapping(value="/taskHoursList" ,method = RequestMethod.GET)
  167. public Result taskHoursList(inuptTaskHoursListBo ib,
  168. Integer pageNo, Integer pageSize){
  169. Result res=new Result();
  170. res.setData(orderProjectService.taskHoursList(ib,pageNo, pageSize));
  171. return res;
  172. }
  173. /**
  174. * 任务工时详情列表
  175. */
  176. @RequestMapping(value="/taskHoursDetailsList" ,method = RequestMethod.GET)
  177. public Result taskHoursDetailsList( String taskId ){
  178. Result res=new Result();
  179. if (StringUtils.isBlank(taskId)) {
  180. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目编号"));
  181. return res;
  182. }
  183. res.setData(orderProjectService.taskHoursDetailsList(taskId));
  184. return res;
  185. }
  186. /**
  187. * 任务操作日志
  188. */
  189. @RequestMapping(value="/TaskLogList" ,method = RequestMethod.GET)
  190. public Result TaskLogList(Integer id){
  191. Result res=new Result();
  192. res.setData(orderProjectService.TaskLogList(id));
  193. return res;
  194. }
  195. /** 任务文件上传 **/
  196. @RequestMapping(value = "/uploadOrderTaskFile", method = RequestMethod.POST)
  197. public Result uploadOrderTaskFile(HttpServletRequest req,String sign){
  198. Result res = new Result();
  199. res.setData(handleFile(res, "/order_task_file/", false, req, sign));
  200. return res;
  201. }
  202. /**
  203. * 新增项目申报进度
  204. */
  205. @RequestMapping(value="/createTaskProgress" ,method = RequestMethod.POST)
  206. public Result createTaskProgress(TaskProgressBo t){
  207. Result res=new Result();
  208. if ( null==t.getTaskId()|| null==t.getAlreadyNumber()) {
  209. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  210. }
  211. res.setData(orderProjectService.createTaskProgress(t));
  212. return res;
  213. }
  214. /**
  215. * 修改项目申报进度
  216. */
  217. @RequestMapping(value="/updateTaskProgress" ,method = RequestMethod.POST)
  218. public Result updateTaskProgress(TaskProgressBo t){
  219. Result res=new Result();
  220. if (null==t.getTaskId()|| null==t.getAlreadyNumber()) {
  221. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  222. }
  223. res.setData(orderProjectService.updateTaskProgress(t));
  224. return res;
  225. }
  226. /**
  227. * 删除项目申报进度
  228. */
  229. @RequestMapping(value="/delectTaskProgress" ,method = RequestMethod.POST)
  230. public Result delectTaskProgress(Integer id){
  231. Result res=new Result();
  232. if (null==id) {
  233. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  234. }
  235. res.setData(orderProjectService.delectTaskProgress(id));
  236. return res;
  237. }
  238. /**
  239. * 查看项目申报进度
  240. */
  241. @RequestMapping(value="/selectTaskProgress" ,method = RequestMethod.GET)
  242. public Result selectTaskProgress(Integer tid){
  243. Result res=new Result();
  244. if (null==tid) {
  245. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  246. }
  247. res.setData(orderProjectService.selectTaskProgress(tid));
  248. return res;
  249. }
  250. /**
  251. * 项目申报进度日志
  252. */
  253. @RequestMapping(value="/selectTaskProgressLog" ,method = RequestMethod.GET)
  254. public Result selectTaskProgressLog(Integer tid){
  255. Result res=new Result();
  256. if (null==tid) {
  257. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"参数","参数"));
  258. }
  259. res.setData(orderProjectService.selectTaskProgressLog(tid));
  260. return res;
  261. }
  262. /**
  263. * 拆分项目
  264. */
  265. @RequestMapping(value="/addSplitProject" ,method = RequestMethod.POST)
  266. public Result addSplitProject(Integer tid,String splitList){
  267. Result res=new Result();
  268. if (null==tid||StringUtils.isBlank(splitList)) {
  269. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"项目和拆分数","项目和拆分数"));
  270. return res;
  271. }
  272. int i=orderProjectService.pushSplitProject(tid,splitList);
  273. if (i==-1) {
  274. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"拆分数","拆分数"));
  275. return res;
  276. }
  277. res.setData(i);
  278. return res;
  279. }
  280. /**
  281. * 拆分项目列表
  282. */
  283. @RequestMapping(value="/splitProjectList" ,method = RequestMethod.GET)
  284. public Result splitProjectList(Integer tid){
  285. Result res=new Result();
  286. if (null==tid) {
  287. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"项目和拆分数","项目和拆分数"));
  288. return res;
  289. }
  290. res.setData(orderProjectService.splitProjectList(tid));
  291. return res;
  292. }
  293. /**
  294. * 我的工时列表导出xls
  295. * @throws IOException
  296. */
  297. @RequestMapping(value = "/exportMyTaskList", method = RequestMethod.GET)
  298. public Result exportMyTaskList(HttpServletResponse response,inuptTaskHoursListBo ib, Integer pageNo, Integer pageSize) {
  299. if(pageSize==null)pageSize=999999;
  300. @SuppressWarnings("unchecked")
  301. List<TOrderTaskListBo> list=(List<TOrderTaskListBo>) orderProjectService.taskHoursList(ib, pageNo, pageSize).getList();
  302. NewExcelUtil<TOrderTaskListBo> excel=new NewExcelUtil<>(TOrderTaskListBo.class);
  303. return excel.exportExcel(list, "工时信息记录表", response);
  304. }
  305. /**
  306. * 我的任务列表导出xls
  307. * @throws IOException
  308. */
  309. @RequestMapping(value = "/exporProjectList", method = RequestMethod.GET)
  310. public Result exporProjectList(HttpServletResponse response,inuptTaskListBo ib) {
  311. if(ib.getPageSize()==null)ib.setPageSize(99999);
  312. String str="项目任务列表";
  313. @SuppressWarnings("unchecked")
  314. List<TOrderTaskListBo> list=(List<TOrderTaskListBo>) orderProjectService.orderTaskList(ib).getList();
  315. NewExcelUtil<TOrderTaskListBo>excel=new NewExcelUtil<>(TOrderTaskListBo.class);
  316. return excel.exportExcel(list, str, response);
  317. }
  318. /**
  319. * 项目日志 (转交日志)
  320. * @param tid
  321. * @return
  322. */
  323. @RequestMapping(value = "/taskAttributionLog",method = RequestMethod.GET)
  324. public Result taskAttributionLog(Integer tid) {
  325. Result res =new Result();
  326. if (tid==null) {
  327. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"项目编号","项目编号"));
  328. return res;
  329. }
  330. res.data(orderProjectService.taskAttributionLog(tid));
  331. return res;
  332. }
  333. /**
  334. * 客户项目列表
  335. * @return
  336. */
  337. @RequestMapping(value = "/selectUidByproject",method = RequestMethod.GET)
  338. public Result selectUidByproject(String uid) {
  339. Result res =new Result();
  340. if (uid==null) {
  341. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"客户编号","客户编号"));
  342. return res;
  343. }
  344. res.data( orderProjectService.selectUidByproject(uid) );
  345. return res;
  346. }
  347. /**
  348. * 发起项目核对
  349. * @param tid
  350. * @return
  351. */
  352. @RequestMapping(value = "/addProjectCheck",method = RequestMethod.POST)
  353. public Result addProjectCheck(Integer tid) {
  354. Result res =new Result();
  355. if (tid==null) {
  356. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"项目编号","项目编号"));
  357. return res;
  358. }
  359. res.data( orderProjectService.addProjectCheck(tid) );
  360. return res;
  361. }
  362. /**
  363. * 核对日志
  364. * @param tid
  365. * @return
  366. */
  367. @RequestMapping(value = "/projectCheckLog",method = RequestMethod.GET)
  368. public Result projectCheckLog(Integer tid) {
  369. Result res =new Result();
  370. if (tid==null) {
  371. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"项目编号","项目编号"));
  372. return res;
  373. }
  374. res.data( orderProjectService.projectCheckLog(tid) );
  375. return res;
  376. }
  377. /**
  378. * 获取专利分类
  379. * @return
  380. */
  381. @RequestMapping(value = "/getPatentType",method = RequestMethod.GET)
  382. public Result getPatentType() {
  383. Result res =new Result();
  384. res.data(OfficialPatentType.getStatus());
  385. return res;
  386. }
  387. /**
  388. * 核对列表
  389. * @return
  390. */
  391. @RequestMapping(value = "/selectProjectCheck",method = RequestMethod.GET)
  392. public Result selectProjectCheck(InputProjectCheck in) {
  393. Result res =new Result();
  394. res.data(orderProjectService.selectProjectCheck(in));
  395. return res;
  396. }
  397. /**
  398. * 高新复审统计
  399. */
  400. @RequestMapping(value = "/highNewRetrialStatistics",method = RequestMethod.GET)
  401. public Result highNewRetrialStatistics(String depId,String startDate,String endDate) {
  402. Result res =new Result();
  403. res.data(orderProjectService.highNewRetrialStatistics(depId,startDate,endDate));
  404. return res;
  405. }
  406. /**
  407. * 高新复审统计
  408. */
  409. @RequestMapping(value = "/highNewRetrialStatistics/export",method = RequestMethod.GET)
  410. public Result highNewRetrialStatisticsExport(String depId,String startDate,String endDate,String depName) {
  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. /**
  419. * 高新复审详情列表
  420. */
  421. @RequestMapping(value = "/highNewRetrialList",method = RequestMethod.GET)
  422. public Result highNewRetrialList(String province,String depId,String startDate,String endDate,String aid,Integer sort) {
  423. Result res =new Result();
  424. res.data(orderProjectService.highNewRetrialList(province,depId,aid,sort,startDate,endDate));
  425. return res;
  426. }
  427. @RequestMapping(value = "/highNewRetrialList/export",method = RequestMethod.GET)
  428. public Result highNewRetrialListExport(String province,String provinceName,String depId,String depName,String startDate,String endDate,String aid,
  429. String aName,Integer sort) {
  430. List<OutHighNewRetrialList> list=orderProjectService.highNewRetrialList(province,depId,aid,sort,startDate,endDate);
  431. NewExcelUtil<OutHighNewRetrialList> newExcelUtil=new NewExcelUtil<>(OutHighNewRetrialList.class);
  432. StringBuffer str=new StringBuffer("搜索条件=》");
  433. if (provinceName!=null)str=str.append("省份:").append(provinceName).append(",");
  434. if (depName!=null)str=str.append("部门:").append(depName).append(",");
  435. if (aName!=null)str=str.append("跟进人:").append(aName).append(",");
  436. if (startDate!=null&&endDate!=null)str=str.append("时间:").append(startDate).append("~").append(endDate).append(",");
  437. if(sort!=null){
  438. str=str.append("排序:");
  439. if(sort==0)str=str.append("按签通过高新排序");
  440. else if(sort==1)str=str.append("按未通过高新排序");
  441. }
  442. return newExcelUtil.exportExcel(list,"高新复审详情",uploadPath,str.substring(0,str.toString().length()-1));
  443. }
  444. }