ProjectTaskController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. package com.ruoyi.web.controller.project;
  2. import com.ruoyi.common.annotation.Log;
  3. import com.ruoyi.common.config.RuoYiConfig;
  4. import com.ruoyi.common.core.controller.BaseController;
  5. import com.ruoyi.common.core.domain.AjaxResult;
  6. import com.ruoyi.common.core.page.TableDataInfo;
  7. import com.ruoyi.common.enums.BusinessType;
  8. import com.ruoyi.common.exception.ServiceException;
  9. import com.ruoyi.common.utils.SecurityUtils;
  10. import com.ruoyi.common.utils.StringUtils;
  11. import com.ruoyi.common.utils.file.FileUploadUtils;
  12. import com.ruoyi.common.utils.file.MimeTypeUtils;
  13. import com.ruoyi.common.utils.poi.ExcelUtil;
  14. import com.ruoyi.project.bo.*;
  15. import com.ruoyi.project.domain.ProjectStaff;
  16. import com.ruoyi.project.domain.ProjectStaffRecord;
  17. import com.ruoyi.project.domain.ProjectStaffRecordLog;
  18. import com.ruoyi.project.domain.ProjectTask;
  19. import com.ruoyi.project.service.ProjectStaffRecordService;
  20. import com.ruoyi.project.service.ProjectStaffService;
  21. import com.ruoyi.project.service.ProjectTaskService;
  22. import io.swagger.annotations.Api;
  23. import io.swagger.annotations.ApiOperation;
  24. import org.springframework.validation.annotation.Validated;
  25. import org.springframework.web.bind.annotation.*;
  26. import org.springframework.web.multipart.MultipartFile;
  27. import javax.annotation.Resource;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.io.IOException;
  30. import java.util.Date;
  31. import java.util.List;
  32. /**
  33. * 项目管理
  34. */
  35. @Api("项目管理")
  36. @RestController
  37. @RequestMapping("/api/project")
  38. public class ProjectTaskController extends BaseController {
  39. @Resource
  40. private ProjectTaskService projectTaskService;
  41. @Resource
  42. private ProjectStaffService projectStaffService;
  43. @Resource
  44. private ProjectStaffRecordService projectStaffRecordService;
  45. /**
  46. * 新增项目任务
  47. */
  48. @PostMapping("/add")
  49. @ApiOperation("新增项目")
  50. @Log(title = "项目管理", businessType = BusinessType.INSERT)
  51. public AjaxResult add( @RequestBody ProjectTask projectTask){
  52. if (projectTask.getAid()== null){
  53. return error("负责人不能为空");
  54. }
  55. if (projectTaskService.checkProjectNumber(projectTask)){
  56. return error("项目编号已存在");
  57. }
  58. return projectTaskService.addProjectTask(projectTask);
  59. }
  60. /**
  61. * 查询项目编号
  62. */
  63. @GetMapping("/checkProjectNumber")
  64. @ApiOperation("查询项目编号")
  65. public AjaxResult checkProjectNumber( @RequestBody ProjectTask projectTask){
  66. if (projectTaskService.checkProjectNumber(projectTask)){
  67. return error("项目编号已存在");
  68. }
  69. return success(1);
  70. }
  71. /**
  72. * 修改项目
  73. */
  74. @PutMapping("/update")
  75. @ApiOperation("修改项目")
  76. @Log(title = "项目管理", businessType = BusinessType.UPDATE)
  77. public AjaxResult update( @RequestBody ProjectTask projectTask){
  78. if (projectTask.getAid()== null){
  79. return error("负责人不能为空");
  80. }
  81. if (projectTaskService.checkProjectNumber(projectTask)){
  82. return error("项目编号已存在");
  83. }
  84. return projectTaskService.updateProjectTask(projectTask);
  85. }
  86. /**
  87. * 新增项目成员
  88. */
  89. @PostMapping("/addStaff")
  90. @ApiOperation("新增项目成员")
  91. public AjaxResult addStaff(@Validated @RequestBody ProjectStaff in){
  92. return projectStaffService.addStaff(in);
  93. }
  94. /**
  95. * 新增成员打卡
  96. */
  97. @PostMapping("/addRecord")
  98. @ApiOperation("新增项目打卡")
  99. @Log(title = "项目管理", businessType = BusinessType.INSERT)
  100. public AjaxResult addRecord( @RequestBody ProjectStaffRecord in){
  101. if (in.getRecordTime()==null){
  102. in.setRecordTime(new Date());
  103. }
  104. Long userId = SecurityUtils.getUserId();
  105. in.setAid(userId);
  106. AjaxResult ajaxResult = projectStaffRecordService.addCheckMaxDuration(in);
  107. ajaxResult=projectStaffRecordService.checkRecordTime(ajaxResult,in);
  108. if (ajaxResult.isError()){
  109. return ajaxResult;
  110. }
  111. return projectStaffRecordService.add(in);
  112. }
  113. /**
  114. * 修改成员打卡
  115. */
  116. @PostMapping("/updateRecord")
  117. @ApiOperation("修改成员打卡")
  118. @Log(title = "项目日志管理", businessType = BusinessType.UPDATE)
  119. public AjaxResult updateRecord( @RequestBody ProjectStaffRecord in){
  120. Long userId = SecurityUtils.getUserId();
  121. in.setAid(userId);
  122. AjaxResult ajaxResult = projectStaffRecordService.updateCheckMaxDuration(in);
  123. projectStaffRecordService.checkRecordTime(ajaxResult,in);
  124. if (ajaxResult.isError()){
  125. return ajaxResult;
  126. }
  127. return projectStaffRecordService.update(in);
  128. }
  129. /**
  130. * 研发打卡日志详情
  131. */
  132. @GetMapping("/recordDetails")
  133. @ApiOperation("打卡日志详情")
  134. public AjaxResult recordDetails( Long id){
  135. return projectStaffRecordService.recordDetails(id);
  136. }
  137. /**
  138. * 审核成员打卡
  139. */
  140. @PostMapping("/examineRecord")
  141. @ApiOperation("审核成员打卡")
  142. public AjaxResult examineRecord( @RequestBody ProjectStaffRecord in){
  143. if (in.getProcessStatus()!=2 && in.getProcessStatus()!=3){
  144. return AjaxResult.error("审核状态错误");
  145. }
  146. return projectStaffRecordService.examineRecord(in);
  147. }
  148. /**
  149. * 批量审核成员打卡
  150. */
  151. @PostMapping("/batchExamineRecord")
  152. @ApiOperation("批量审核成员打卡")
  153. public AjaxResult batchExamineRecord( @RequestBody batchExamineRecordInput in){
  154. if (in.getProcessStatus()!=2 && in.getProcessStatus()!=3){
  155. return AjaxResult.error("审核状态错误");
  156. }
  157. return projectStaffRecordService.batchExamineRecord(in);
  158. }
  159. /**
  160. * 成员打卡列表
  161. */
  162. @GetMapping("/listRecord")
  163. @ApiOperation("成员打卡列表")
  164. public TableDataInfo listRecord( ProjectStaffRecordInput in){
  165. startPage();
  166. List<ProjectStaffRecordOut> list = projectStaffRecordService.listRecord(in);
  167. return getDataTable(list);
  168. }
  169. /**
  170. * 成员打卡审核日志
  171. */
  172. @GetMapping("/listRecordLog")
  173. @ApiOperation("成员打卡审核日志")
  174. public AjaxResult listRecordLog(ProjectStaffRecordLog in){
  175. return projectStaffRecordService.listRecordLog(in);
  176. }
  177. /**
  178. * 导出项目打卡列表
  179. */
  180. @PostMapping("/listRecord/export")
  181. @ApiOperation("导出项目打卡列表")
  182. @Log(title = "项目日志管理", businessType = BusinessType.EXPORT)
  183. public void listRecordExport(HttpServletResponse response, ProjectStaffRecordInput in){
  184. in.setPageSize(999999);
  185. List<ProjectStaffRecordOut> list=projectStaffRecordService.listRecord(in);
  186. ExcelUtil<ProjectStaffRecordOut> util = new ExcelUtil<>(ProjectStaffRecordOut.class);
  187. util.exportExcel(response, list, "项目研发日志列表");
  188. }
  189. /**
  190. * 导入数据
  191. */
  192. @PostMapping("/listRecord/importData")
  193. @ApiOperation("导入项目打卡数据")
  194. @Log(title = "项目日志管理", businessType = BusinessType.IMPORT)
  195. public AjaxResult listRecordImportData(@RequestParam(value ="file")MultipartFile file, @RequestParam(value = "updateSupport") boolean updateSupport) throws Exception
  196. {
  197. ExcelUtil<ProjectStaffRecordOut> util = new ExcelUtil<>(ProjectStaffRecordOut.class);
  198. List<ProjectStaffRecordOut> list = util.importExcel(file.getInputStream());
  199. String message = projectStaffRecordService.importProject(list, updateSupport);
  200. return success(message);
  201. }
  202. /**
  203. * 项目打卡日志导出模版
  204. */
  205. @PostMapping("/listRecord/importTemplate")
  206. @ApiOperation("项目打卡日志导出模版")
  207. public void listRecordImportTemplate(HttpServletResponse response)
  208. {
  209. ExcelUtil<ProjectStaffRecordOut> util = new ExcelUtil<ProjectStaffRecordOut>(ProjectStaffRecordOut.class);
  210. util.importTemplateExcel(response, "项目打卡日志列表");
  211. }
  212. /**
  213. * 删除项目成员
  214. */
  215. @PostMapping("/deleteStaff")
  216. @ApiOperation("删除项目成员")
  217. @Log(title = "项目管理", businessType = BusinessType.DELETE)
  218. public AjaxResult deleteStaff( @RequestBody ProjectStaff in){
  219. if (in.getId()== null){
  220. return error("项目成员编号不能为空");
  221. }
  222. return projectStaffService.deleteStaff(in);
  223. }
  224. /**
  225. * 项目成员列表
  226. */
  227. @GetMapping("/listStaff")
  228. @ApiOperation("项目成员列表")
  229. public AjaxResult listStaff( ProjectStaff in){
  230. if (in.getPid()== null){
  231. return error("项目编号不能为空");
  232. }
  233. return projectStaffService.listStaff(in);
  234. }
  235. /**
  236. * 删除项目
  237. */
  238. @PostMapping("/deleteProject")
  239. @ApiOperation("删除项目")
  240. @Log(title = "项目管理", businessType = BusinessType.DELETE)
  241. public AjaxResult deleteProject( @RequestBody ProjectTask in){
  242. if (in.getId()== null){
  243. return error("项目编号不能为空");
  244. }
  245. return projectTaskService.deleteProject(in);
  246. }
  247. /**
  248. * 项目详情
  249. */
  250. @GetMapping ("/details")
  251. @ApiOperation("项目详情")
  252. public AjaxResult details( Long id){
  253. if (id== null){
  254. return error("项目编号不能为空");
  255. }
  256. return projectTaskService.details(id);
  257. }
  258. /**
  259. * 项目列表
  260. */
  261. @GetMapping ("/list")
  262. @ApiOperation("项目列表")
  263. public TableDataInfo list(ProjectListInput in){
  264. List<ProjectTaskListOut> list=projectTaskService.list(in);
  265. return getDataTable(list);
  266. }
  267. /**
  268. * 导出项目列表
  269. */
  270. @PostMapping("/export")
  271. @ApiOperation("导出项目列表")
  272. @Log(title = "项目管理", businessType = BusinessType.EXPORT)
  273. public void export(HttpServletResponse response,ProjectListInput in)
  274. {
  275. in.setPageSize(999999);
  276. List<ProjectTaskListOut> list=projectTaskService.list(in);
  277. ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<>(ProjectTaskListOut.class);
  278. util.exportExcel(response, list, "项目列表");
  279. }
  280. /**
  281. * 导入数据
  282. */
  283. @PostMapping("/importData")
  284. @Log(title = "项目管理", businessType = BusinessType.IMPORT)
  285. @ApiOperation("导入项目列表")
  286. public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
  287. {
  288. ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<>(ProjectTaskListOut.class);
  289. List<ProjectTaskListOut> list = util.importExcel(file.getInputStream());
  290. String operName = getUsername();
  291. String message = projectTaskService.importProject(list, updateSupport, operName);
  292. return success(message);
  293. }
  294. @PostMapping("/importTemplate")
  295. @ApiOperation("项目导出模版")
  296. public void importTemplate(HttpServletResponse response)
  297. {
  298. ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<ProjectTaskListOut>(ProjectTaskListOut.class);
  299. util.importTemplateExcel(response, "项目列表");
  300. }
  301. /**
  302. * 上传项目文件
  303. */
  304. @PostMapping("/upload")
  305. @ApiOperation("上传文件")
  306. public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception{
  307. if (!file.isEmpty()){
  308. String avatar = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
  309. AjaxResult ajax = AjaxResult.success();
  310. logger.debug(avatar);
  311. ajax.put("imgUrl", avatar);
  312. return ajax;
  313. }
  314. return error("上传图片异常,请联系管理员");
  315. }
  316. /**
  317. * 查询剩余时间
  318. */
  319. @GetMapping("/myDuration")
  320. @ApiOperation("查询剩余打卡时间")
  321. public AjaxResult myDuration(Long id,String recordTime){
  322. return projectStaffRecordService.myDuration(id,recordTime);
  323. }
  324. /**
  325. * 查询我的月份数据
  326. */
  327. @GetMapping("/myDurationMonth")
  328. @ApiOperation("查询我的月份数据")
  329. public AjaxResult myDurationMonth(Long id,Integer year,Integer month){
  330. return projectStaffRecordService.myDurationMonth(id,year,month);
  331. }
  332. /**
  333. * 项目附件目录
  334. */
  335. @GetMapping("/selectProjectImg")
  336. public AjaxResult selectProjectImg(Long pid){
  337. if (pid==null){
  338. return AjaxResult.error("项目编号不能为空!");
  339. }
  340. return projectTaskService.selectProjectImg(pid);
  341. }
  342. /**
  343. * 下载项目打卡数据包
  344. */
  345. @GetMapping("/download")
  346. public void downloadFiles(HttpServletResponse response,String ids) {
  347. if (StringUtils.isEmpty(ids)){
  348. throw new ServiceException("编号不能为空");
  349. }
  350. projectStaffRecordService.downloadFiles(ids, response);
  351. }
  352. /**
  353. * 打卡数据考勤匹配到打卡时间
  354. */
  355. @PostMapping("/mateUserRecord")
  356. public AjaxResult mateUserRecord(ProjectStaffRecordInput in) {
  357. if (in.getClockStatus()==null||in.getClockStatus()!=2){
  358. return error("请先查询需要合并的数据");
  359. }
  360. return projectStaffRecordService.mateUserRecord(in);
  361. }
  362. /**
  363. * 项目及日志上传天河链
  364. * @param id
  365. * @return
  366. */
  367. @GetMapping("/saveProjectTaskTianhe")
  368. public AjaxResult saveProjectTaskTianhe(@RequestParam("id") String id){
  369. if (StringUtils.isEmpty(id)){
  370. return AjaxResult.error("项目编号不能为空");
  371. }
  372. projectTaskService.saveProjectTaskTianhe(id);
  373. return AjaxResult.success();
  374. }
  375. /**
  376. * 项目日志上传天河链
  377. * @param id
  378. * @return
  379. */
  380. @GetMapping("/saveProjectStaffRecordTianhe")
  381. public AjaxResult saveProjectStaffRecordTianhe(@RequestParam("id") String id){
  382. if (StringUtils.isEmpty(id)){
  383. return AjaxResult.error("项目日志编号不能为空");
  384. }
  385. projectTaskService.saveProjectStaffRecordTianhe(id);
  386. return AjaxResult.success();
  387. }
  388. /**
  389. * 文字上传天河链
  390. * @param content
  391. * @return
  392. */
  393. @GetMapping("/saveText")
  394. public AjaxResult saveText(@RequestParam("content") String content){
  395. if (StringUtils.isEmpty(content)){
  396. return AjaxResult.error("内容不能为空");
  397. }
  398. projectTaskService.saveText(content);
  399. return AjaxResult.success();
  400. }
  401. /**
  402. * 获取项目月份打卡数据
  403. * @param id 项目编号
  404. * @param yearMonth 年月份
  405. * @return 数据
  406. */
  407. @GetMapping("/getMonthClock")
  408. public AjaxResult getMonthClock(@RequestParam("id") Integer id,@RequestParam("yearMonth") String yearMonth){
  409. if (id==null){
  410. return AjaxResult.error("项目编号不能为空");
  411. }
  412. if (yearMonth==null){
  413. return AjaxResult.error("年月日期不能为空");
  414. }
  415. return AjaxResult.success(projectStaffRecordService.getMonthClock(id,yearMonth));
  416. }
  417. /**
  418. * 获取项目月份打卡数据
  419. * @param id 项目编号
  420. * @param yearMonth 年月份
  421. * @return 数据
  422. */
  423. @PostMapping("/getMonthClockExport")
  424. public void getMonthClockExport(@RequestParam("id") Integer id,@RequestParam("yearMonth") String yearMonth,HttpServletResponse response){
  425. projectStaffRecordService.getMonthClockExport(id,yearMonth,response);
  426. }
  427. /**
  428. * 获取项目对应打卡月份
  429. */
  430. @GetMapping("/allProjectMonthData")
  431. public AjaxResult getAllProjectMonth(){
  432. return AjaxResult.success(projectStaffRecordService.getAllProjectMonth());
  433. }
  434. }