AdminDemandApiController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. package com.goafanti.demand.controller;
  2. import javax.annotation.Resource;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestMethod;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.goafanti.admin.service.AftFileService;
  9. import com.goafanti.common.bo.Result;
  10. import com.goafanti.common.constant.ErrorConstants;
  11. import com.goafanti.common.controller.CertifyApiController;
  12. import com.goafanti.common.enums.AttachmentType;
  13. import com.goafanti.common.enums.DeleteStatus;
  14. import com.goafanti.common.enums.DemandAuditStatus;
  15. import com.goafanti.common.model.AftFile;
  16. import com.goafanti.common.model.Demand;
  17. import com.goafanti.common.model.DemandFollow;
  18. import com.goafanti.common.model.DemandFollowDetail;
  19. import com.goafanti.common.model.DemandPublish;
  20. import com.goafanti.common.utils.StringUtils;
  21. import com.goafanti.demand.service.DemandFollowService;
  22. import com.goafanti.demand.service.DemandOrderService;
  23. import com.goafanti.demand.service.DemandPublishPageService;
  24. import com.goafanti.demand.service.DemandPublishService;
  25. import com.goafanti.demand.service.DemandService;
  26. import com.goafanti.user.service.UserService;
  27. @RestController
  28. @RequestMapping(value = "/api/admin/demand")
  29. public class AdminDemandApiController extends CertifyApiController {
  30. @Resource
  31. private DemandService demandService;
  32. @Resource
  33. private UserService userService;
  34. @Resource
  35. private AftFileService aftFileService;
  36. @Resource
  37. private DemandOrderService demandOrderService;
  38. @Resource
  39. DemandPublishService demandPublishService;
  40. @Resource
  41. DemandFollowService demandFollowService;
  42. /**
  43. * 科技需求匹配科技成果
  44. */
  45. @RequestMapping(value = "/matchAchievement", method = RequestMethod.POST)
  46. public Result matchAchievement(String id) {
  47. Result res = new Result();
  48. if (StringUtils.isBlank(id)) {
  49. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "成果ID"));
  50. return res;
  51. }
  52. Demand d = demandService.selectByPrimaryKey(id);
  53. if (null == d|| !DeleteStatus.UNDELETE.getCode().equals(d.getDeletedSign())
  54. || !DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())) {
  55. res.getError().add(buildError("", "当前状态无法匹配!"));
  56. return res;
  57. }
  58. res.setData(demandService.updateMatchAchievement(d));
  59. return res;
  60. }
  61. /**
  62. * 成果需求匹配列表
  63. */
  64. @RequestMapping(value = "/achievementDemand", method = RequestMethod.GET)
  65. public Result achievementDemand(String id) {
  66. Result res = new Result();
  67. res.setData(demandService.selectAchievementDemandListByDemandId(id));
  68. return res;
  69. }
  70. /**
  71. * 下载技术需求批量导入Excel模板
  72. *
  73. * @param response
  74. * @return
  75. */
  76. @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
  77. public Result downloadTemplateFile(HttpServletResponse response, String sign) {
  78. Result res = new Result();
  79. AttachmentType attachmentType = AttachmentType.getField(sign);
  80. if (attachmentType == AttachmentType.DEMAND_TEMPLATE) {
  81. String fileName = "";
  82. AftFile af = aftFileService.selectAftFileBySign(sign);
  83. if (null == af) {
  84. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  85. } else {
  86. String path = af.getFilePath();
  87. String suffix = path.substring(path.lastIndexOf("."));
  88. fileName = AttachmentType.DEMAND_TEMPLATE.getDesc() + suffix;
  89. downloadFile(response, fileName, path);
  90. }
  91. } else {
  92. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  93. }
  94. return res;
  95. }
  96. /**
  97. * 个人用户--需求列表
  98. */
  99. @RequestMapping(value = "/userList", method = RequestMethod.GET)
  100. public Result userList(String pageNo, String pageSize) {
  101. Result res = new Result();
  102. //res.setData(null); TODO
  103. return res;
  104. }
  105. /**
  106. * 组织用户--需求列表(个人组织合并)
  107. */
  108. @RequestMapping(value = "/orgList", method = RequestMethod.GET)
  109. public Result orgList(String pageNo, String pageSize) {
  110. Result res = new Result();
  111. //res.setData(null); TODO
  112. return res;
  113. }
  114. /**
  115. * 个人需求详情
  116. */
  117. @RequestMapping(value = "/userDemandDetail", method = RequestMethod.GET)
  118. public Result userDemandDetail(String id) {
  119. Result res = new Result();
  120. if (StringUtils.isBlank(id)) {
  121. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  122. return res;
  123. }
  124. res.setData(demandService.selectUserDemandDetail(id));
  125. return res;
  126. }
  127. /**
  128. * 组织用户详情(个人组织合并)
  129. */
  130. @RequestMapping(value = "/orgDemandDetail", method = RequestMethod.GET)
  131. public Result orgDemandDetail(String id,Integer dataCategory) {
  132. Result res = new Result();
  133. if (StringUtils.isBlank(id)) {
  134. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  135. return res;
  136. }
  137. if(dataCategory==0){
  138. res.setData(demandService.selectUserDemandDetail(id));
  139. return res;
  140. }else if(dataCategory==1){
  141. res.setData(demandService.selectOrgDemandDetail(id));
  142. return res;
  143. }
  144. return res;
  145. }
  146. /**
  147. * 需求管理--获取个人用户下拉
  148. */
  149. @RequestMapping(value = "/userNames", method = RequestMethod.GET)
  150. public Result getUserNames() {
  151. Result res = new Result();
  152. res.setData(userService.selectDemandUserNames());
  153. return res;
  154. }
  155. /**
  156. * 需求管理--获取组织用户下拉
  157. */
  158. @RequestMapping(value = "/unitNames", method = RequestMethod.GET)
  159. public Result getUnitNames() {
  160. Result res = new Result();
  161. res.setData(userService.selectDemandUnitNames());
  162. return res;
  163. }
  164. /**
  165. * 需求资料--图片上传
  166. */
  167. @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
  168. public Result uploadPicture(HttpServletRequest req, String sign, String uid) {
  169. Result res = new Result();
  170. if (StringUtils.isBlank(uid)) {
  171. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
  172. return res;
  173. }
  174. AttachmentType attachmentType = AttachmentType.getField(sign);
  175. if (attachmentType == AttachmentType.DEMAND_PICTURE|| attachmentType == AttachmentType.DEMAND_COVER_PICTURE) {
  176. res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
  177. } else {
  178. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  179. }
  180. return res;
  181. }
  182. /**
  183. * 需求资料--文本文件上传
  184. */
  185. @RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
  186. public Result uploadTextFile(HttpServletRequest req, String sign, String uid) {
  187. Result res = new Result();
  188. if (StringUtils.isBlank(uid)) {
  189. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
  190. return res;
  191. }
  192. AttachmentType attachmentType = AttachmentType.getField(sign);
  193. if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
  194. res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
  195. } else {
  196. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  197. }
  198. return res;
  199. }
  200. /**
  201. * 需求撤消发布(下架)
  202. */
  203. @RequestMapping(value = "/offShelf", method = RequestMethod.POST)
  204. public Result offShelf(String id,Integer releaseStatus) {
  205. Result res = new Result();
  206. if (StringUtils.isBlank(id)) {
  207. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  208. return res;
  209. }
  210. Demand d = demandService.selectByPrimaryKey(id);
  211. if (null == d) {
  212. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  213. return res;
  214. }
  215. d.setReleaseStatus(releaseStatus);
  216. res.setData(demandService.updateReleaseStatus(d));
  217. return res;
  218. }
  219. /**
  220. * 下载需求文件--文本文件
  221. */
  222. @RequestMapping(value = "/download", method = RequestMethod.GET)
  223. public Result download(HttpServletResponse response, String id) {
  224. Result res = new Result();
  225. if (StringUtils.isEmpty(id)) {
  226. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  227. return res;
  228. }
  229. Demand d = demandService.selectByPrimaryKey(id);
  230. if (null == d) {
  231. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  232. return res;
  233. }
  234. downloadUnPrivateFile(response, d.getTextFileDownloadFileName(), d.getTextFileUrl());
  235. return res;
  236. }
  237. /**
  238. * 我的需求列表
  239. */
  240. @RequestMapping(value = "/myList", method = RequestMethod.GET)
  241. public Result myList(String pageNo, String pageSize) {
  242. Result res = new Result();
  243. // res.setData(null) todo;
  244. return res;
  245. }
  246. /**
  247. * 需求发布
  248. */
  249. @RequestMapping(value = "/addDemandPublish", method = RequestMethod.POST)
  250. private Result addDemandPublish(DemandPublish d) {
  251. Result res = new Result();
  252. if (StringUtils.isBlank(d.getDemandId())) {
  253. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求", "需求"));
  254. return res;
  255. }
  256. res.setData(demandPublishService.insertDemandPublish(d));
  257. return res;
  258. }
  259. /**
  260. * 撤销发布
  261. */
  262. @RequestMapping(value = "/deletePublish", method = RequestMethod.GET)
  263. private Result deletePublish(String id) {
  264. Result res = new Result();
  265. res.setData(demandPublishService.deletePublish(id));
  266. return res;
  267. }
  268. /**
  269. * 修改发布
  270. */
  271. @RequestMapping(value = "/updatePublish", method = RequestMethod.GET)
  272. private Result updatePublish(DemandPublish d) {
  273. Result res = new Result();
  274. res.setData(demandPublishService.updatePublish(d));
  275. return res;
  276. }
  277. /**
  278. * 发布列表
  279. */
  280. @RequestMapping(value = "/listPublish", method = RequestMethod.GET)
  281. private Result listPublish(String name,String publishPlatform,Integer publishClient,String publishPage,
  282. Integer ifTop, Integer pageNo, Integer pageSize,String employerName) {
  283. Result res = new Result();
  284. if (null==pageNo) {
  285. pageNo=1;
  286. }
  287. if (null==pageSize) {
  288. pageSize=10;
  289. }
  290. res.setData(demandPublishService.listPublish( name, publishPlatform, publishClient, publishPage,
  291. ifTop, pageNo, pageSize,employerName));
  292. return res;
  293. }
  294. /**
  295. * 获取需求页面位置
  296. */
  297. @RequestMapping(value="/getPublishPage",method = RequestMethod.GET)
  298. private Result getPublishPage(){
  299. Result res=new Result();
  300. return res.data(DemandPublishPageService.getBranchInformation());
  301. }
  302. /**
  303. * 新增匹配跟进保存
  304. */
  305. @RequestMapping(value = "/addDemandFollow", method = RequestMethod.POST)
  306. private Result addDemandFollow(DemandFollow d) {
  307. Result res = new Result();
  308. if (StringUtils.isBlank(d.getDemandId())) {
  309. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求", "需求"));
  310. return res;
  311. }
  312. if (StringUtils.isBlank(d.getContactMobile())) {
  313. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到联系人电话", "联系人电话"));
  314. return res;
  315. }
  316. if (StringUtils.isBlank(d.getContacts())) {
  317. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到联系人", "联系人"));
  318. return res;
  319. }
  320. if (StringUtils.isBlank(d.getOrganization())) {
  321. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到机构", "机构"));
  322. return res;
  323. }
  324. res.data(demandFollowService.insertDemandFollow(d));
  325. return res;
  326. }
  327. /**
  328. * 修改匹配跟进
  329. */
  330. @RequestMapping(value = "/updateDemandFollow", method = RequestMethod.POST)
  331. private Result DemandFollow(DemandFollow d) {
  332. Result res = new Result();
  333. if (StringUtils.isBlank(d.getId())) {
  334. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配", "匹配跟进"));
  335. return res;
  336. }
  337. res.setData(demandFollowService.updateDemandFollow(d));
  338. return res;
  339. }
  340. /**
  341. * 新增跟进情况
  342. */
  343. @RequestMapping(value = "/addDemandFollowDetail", method = RequestMethod.POST)
  344. private Result addDemandFollowDetail(DemandFollowDetail d,String createTimeFormattedDate) {
  345. Result res = new Result();
  346. if (StringUtils.isBlank(d.getDemandFollowId())) {
  347. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配跟进", "需求匹配跟进"));
  348. return res;
  349. }
  350. if (StringUtils.isBlank(d.getRemarks())) {
  351. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到跟进情况", "跟进情况"));
  352. return res;
  353. }
  354. if (null==d.getResult()) {
  355. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到跟进结果", "跟进结果"));
  356. return res;
  357. }
  358. if (StringUtils.isBlank(createTimeFormattedDate)) {
  359. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到跟进时间", "跟进时间"));
  360. return res;
  361. }
  362. res.data(demandFollowService.insertDemandFollowDetail(d,createTimeFormattedDate));
  363. return res;
  364. }
  365. /**
  366. * 跟进列表
  367. */
  368. @RequestMapping(value = "/listDemandFollow", method = RequestMethod.GET)
  369. private Result listDemandFollow(String id,Integer pNo,Integer pSize) {
  370. Result res = new Result();
  371. if (StringUtils.isBlank(id)) {
  372. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配跟进", "需求匹配跟进"));
  373. return res;
  374. }
  375. res.data(demandFollowService.selectDemandFollow( id, pNo, pSize));
  376. return res;
  377. }
  378. /**
  379. * 删除跟进
  380. */
  381. @RequestMapping(value = "/deleteDemandFollow", method = RequestMethod.GET)
  382. private Result deleteDemandFollow(String id) {
  383. Result res = new Result();
  384. if (StringUtils.isBlank(id)) {
  385. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配跟进", "需求匹配跟进"));
  386. return res;
  387. }
  388. res.data(demandFollowService.deleteDemandFollow( id));
  389. return res;
  390. }
  391. /**
  392. * 跟进情况列表
  393. */
  394. @RequestMapping(value = "/listDemandFollowDetail", method = RequestMethod.GET)
  395. private Result listDemandFollowDetail(String id,Integer pNo, Integer pSize) {
  396. Result res = new Result();
  397. if (StringUtils.isBlank(id)) {
  398. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求跟进", "需求跟进"));
  399. return res;
  400. }
  401. res.data(demandFollowService.selectDemandFollowDetail( id,pNo, pSize));
  402. return res;
  403. }
  404. /**
  405. * 匹配跟进
  406. */
  407. @RequestMapping(value = "/DemandFollowDetails", method = RequestMethod.GET)
  408. private Result DemandFollowDetails(String id) {
  409. Result res = new Result();
  410. if (StringUtils.isBlank(id)) {
  411. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求跟进", "需求跟进"));
  412. return res;
  413. }
  414. res.data(demandService.DemandFollowDetails(id));
  415. return res;
  416. }
  417. }