| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491 |
- package com.ruoyi.web.controller.project;
- import com.ruoyi.common.annotation.Log;
- import com.ruoyi.common.config.RuoYiConfig;
- import com.ruoyi.common.core.controller.BaseController;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.core.page.TableDataInfo;
- import com.ruoyi.common.enums.BusinessType;
- import com.ruoyi.common.exception.ServiceException;
- import com.ruoyi.common.utils.SecurityUtils;
- import com.ruoyi.common.utils.StringUtils;
- import com.ruoyi.common.utils.file.FileUploadUtils;
- import com.ruoyi.common.utils.file.MimeTypeUtils;
- import com.ruoyi.common.utils.poi.ExcelUtil;
- import com.ruoyi.project.bo.*;
- import com.ruoyi.project.domain.ProjectStaff;
- import com.ruoyi.project.domain.ProjectStaffRecord;
- import com.ruoyi.project.domain.ProjectStaffRecordLog;
- import com.ruoyi.project.domain.ProjectTask;
- import com.ruoyi.project.service.ProjectStaffRecordService;
- import com.ruoyi.project.service.ProjectStaffService;
- import com.ruoyi.project.service.ProjectTaskService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import java.io.IOException;
- import java.util.Date;
- import java.util.List;
- /**
- * 项目管理
- */
- @Api("项目管理")
- @RestController
- @RequestMapping("/api/project")
- public class ProjectTaskController extends BaseController {
- @Resource
- private ProjectTaskService projectTaskService;
- @Resource
- private ProjectStaffService projectStaffService;
- @Resource
- private ProjectStaffRecordService projectStaffRecordService;
- /**
- * 新增项目任务
- */
- @PostMapping("/add")
- @ApiOperation("新增项目")
- @Log(title = "项目管理", businessType = BusinessType.INSERT)
- public AjaxResult add( @RequestBody ProjectTask projectTask){
- if (projectTask.getAid()== null){
- return error("负责人不能为空");
- }
- if (projectTaskService.checkProjectNumber(projectTask)){
- return error("项目编号已存在");
- }
- return projectTaskService.addProjectTask(projectTask);
- }
- /**
- * 查询项目编号
- */
- @GetMapping("/checkProjectNumber")
- @ApiOperation("查询项目编号")
- public AjaxResult checkProjectNumber( @RequestBody ProjectTask projectTask){
- if (projectTaskService.checkProjectNumber(projectTask)){
- return error("项目编号已存在");
- }
- return success(1);
- }
- /**
- * 修改项目
- */
- @PutMapping("/update")
- @ApiOperation("修改项目")
- @Log(title = "项目管理", businessType = BusinessType.UPDATE)
- public AjaxResult update( @RequestBody ProjectTask projectTask){
- if (projectTask.getAid()== null){
- return error("负责人不能为空");
- }
- if (projectTaskService.checkProjectNumber(projectTask)){
- return error("项目编号已存在");
- }
- return projectTaskService.updateProjectTask(projectTask);
- }
- /**
- * 新增项目成员
- */
- @PostMapping("/addStaff")
- @ApiOperation("新增项目成员")
- public AjaxResult addStaff(@Validated @RequestBody ProjectStaff in){
- return projectStaffService.addStaff(in);
- }
- /**
- * 新增成员打卡
- */
- @PostMapping("/addRecord")
- @ApiOperation("新增项目打卡")
- @Log(title = "项目管理", businessType = BusinessType.INSERT)
- public AjaxResult addRecord( @RequestBody ProjectStaffRecord in){
- if (in.getRecordTime()==null){
- in.setRecordTime(new Date());
- }
- Long userId = SecurityUtils.getUserId();
- in.setAid(userId);
- AjaxResult ajaxResult = projectStaffRecordService.addCheckMaxDuration(in);
- ajaxResult=projectStaffRecordService.checkRecordTime(ajaxResult,in);
- if (ajaxResult.isError()){
- return ajaxResult;
- }
- return projectStaffRecordService.add(in);
- }
- /**
- * 修改成员打卡
- */
- @PostMapping("/updateRecord")
- @ApiOperation("修改成员打卡")
- @Log(title = "项目日志管理", businessType = BusinessType.UPDATE)
- public AjaxResult updateRecord( @RequestBody ProjectStaffRecord in){
- Long userId = SecurityUtils.getUserId();
- in.setAid(userId);
- AjaxResult ajaxResult = projectStaffRecordService.updateCheckMaxDuration(in);
- projectStaffRecordService.checkRecordTime(ajaxResult,in);
- if (ajaxResult.isError()){
- return ajaxResult;
- }
- return projectStaffRecordService.update(in);
- }
- /**
- * 研发打卡日志详情
- */
- @GetMapping("/recordDetails")
- @ApiOperation("打卡日志详情")
- public AjaxResult recordDetails( Long id){
- return projectStaffRecordService.recordDetails(id);
- }
- /**
- * 审核成员打卡
- */
- @PostMapping("/examineRecord")
- @ApiOperation("审核成员打卡")
- public AjaxResult examineRecord( @RequestBody ProjectStaffRecord in){
- if (in.getProcessStatus()!=2 && in.getProcessStatus()!=3){
- return AjaxResult.error("审核状态错误");
- }
- return projectStaffRecordService.examineRecord(in);
- }
- /**
- * 批量审核成员打卡
- */
- @PostMapping("/batchExamineRecord")
- @ApiOperation("批量审核成员打卡")
- public AjaxResult batchExamineRecord( @RequestBody batchExamineRecordInput in){
- if (in.getProcessStatus()!=2 && in.getProcessStatus()!=3){
- return AjaxResult.error("审核状态错误");
- }
- return projectStaffRecordService.batchExamineRecord(in);
- }
- /**
- * 成员打卡列表
- */
- @GetMapping("/listRecord")
- @ApiOperation("成员打卡列表")
- public TableDataInfo listRecord( ProjectStaffRecordInput in){
- startPage();
- List<ProjectStaffRecordOut> list = projectStaffRecordService.listRecord(in);
- return getDataTable(list);
- }
- /**
- * 成员打卡审核日志
- */
- @GetMapping("/listRecordLog")
- @ApiOperation("成员打卡审核日志")
- public AjaxResult listRecordLog(ProjectStaffRecordLog in){
- return projectStaffRecordService.listRecordLog(in);
- }
- /**
- * 导出项目打卡列表
- */
- @PostMapping("/listRecord/export")
- @ApiOperation("导出项目打卡列表")
- @Log(title = "项目日志管理", businessType = BusinessType.EXPORT)
- public void listRecordExport(HttpServletResponse response, ProjectStaffRecordInput in){
- in.setPageSize(999999);
- List<ProjectStaffRecordOut> list=projectStaffRecordService.listRecord(in);
- ExcelUtil<ProjectStaffRecordOut> util = new ExcelUtil<>(ProjectStaffRecordOut.class);
- util.exportExcel(response, list, "项目研发日志列表");
- }
- /**
- * 导入数据
- */
- @PostMapping("/listRecord/importData")
- @ApiOperation("导入项目打卡数据")
- @Log(title = "项目日志管理", businessType = BusinessType.IMPORT)
- public AjaxResult listRecordImportData(@RequestParam(value ="file")MultipartFile file, @RequestParam(value = "updateSupport") boolean updateSupport) throws Exception
- {
- ExcelUtil<ProjectStaffRecordOut> util = new ExcelUtil<>(ProjectStaffRecordOut.class);
- List<ProjectStaffRecordOut> list = util.importExcel(file.getInputStream());
- String message = projectStaffRecordService.importProject(list, updateSupport);
- return success(message);
- }
- /**
- * 项目打卡日志导出模版
- */
- @PostMapping("/listRecord/importTemplate")
- @ApiOperation("项目打卡日志导出模版")
- public void listRecordImportTemplate(HttpServletResponse response)
- {
- ExcelUtil<ProjectStaffRecordOut> util = new ExcelUtil<ProjectStaffRecordOut>(ProjectStaffRecordOut.class);
- util.importTemplateExcel(response, "项目打卡日志列表");
- }
- /**
- * 删除项目成员
- */
- @PostMapping("/deleteStaff")
- @ApiOperation("删除项目成员")
- @Log(title = "项目管理", businessType = BusinessType.DELETE)
- public AjaxResult deleteStaff( @RequestBody ProjectStaff in){
- if (in.getId()== null){
- return error("项目成员编号不能为空");
- }
- return projectStaffService.deleteStaff(in);
- }
- /**
- * 项目成员列表
- */
- @GetMapping("/listStaff")
- @ApiOperation("项目成员列表")
- public AjaxResult listStaff( ProjectStaff in){
- if (in.getPid()== null){
- return error("项目编号不能为空");
- }
- return projectStaffService.listStaff(in);
- }
- /**
- * 删除项目
- */
- @PostMapping("/deleteProject")
- @ApiOperation("删除项目")
- @Log(title = "项目管理", businessType = BusinessType.DELETE)
- public AjaxResult deleteProject( @RequestBody ProjectTask in){
- if (in.getId()== null){
- return error("项目编号不能为空");
- }
- return projectTaskService.deleteProject(in);
- }
- /**
- * 项目详情
- */
- @GetMapping ("/details")
- @ApiOperation("项目详情")
- public AjaxResult details( Long id){
- if (id== null){
- return error("项目编号不能为空");
- }
- return projectTaskService.details(id);
- }
- /**
- * 项目列表
- */
- @GetMapping ("/list")
- @ApiOperation("项目列表")
- public TableDataInfo list(ProjectListInput in){
- List<ProjectTaskListOut> list=projectTaskService.list(in);
- return getDataTable(list);
- }
- /**
- * 导出项目列表
- */
- @PostMapping("/export")
- @ApiOperation("导出项目列表")
- @Log(title = "项目管理", businessType = BusinessType.EXPORT)
- public void export(HttpServletResponse response,ProjectListInput in)
- {
- in.setPageSize(999999);
- List<ProjectTaskListOut> list=projectTaskService.list(in);
- ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<>(ProjectTaskListOut.class);
- util.exportExcel(response, list, "项目列表");
- }
- /**
- * 导入数据
- */
- @PostMapping("/importData")
- @Log(title = "项目管理", businessType = BusinessType.IMPORT)
- @ApiOperation("导入项目列表")
- public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
- {
- ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<>(ProjectTaskListOut.class);
- List<ProjectTaskListOut> list = util.importExcel(file.getInputStream());
- String operName = getUsername();
- String message = projectTaskService.importProject(list, updateSupport, operName);
- return success(message);
- }
- @PostMapping("/importTemplate")
- @ApiOperation("项目导出模版")
- public void importTemplate(HttpServletResponse response)
- {
- ExcelUtil<ProjectTaskListOut> util = new ExcelUtil<ProjectTaskListOut>(ProjectTaskListOut.class);
- util.importTemplateExcel(response, "项目列表");
- }
- /**
- * 上传项目文件
- */
- @PostMapping("/upload")
- @ApiOperation("上传文件")
- public AjaxResult upload(@RequestParam("file") MultipartFile file) throws Exception{
- if (!file.isEmpty()){
- String avatar = FileUploadUtils.upload(RuoYiConfig.getUploadPath(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
- AjaxResult ajax = AjaxResult.success();
- logger.debug(avatar);
- ajax.put("imgUrl", avatar);
- return ajax;
- }
- return error("上传图片异常,请联系管理员");
- }
- /**
- * 查询剩余时间
- */
- @GetMapping("/myDuration")
- @ApiOperation("查询剩余打卡时间")
- public AjaxResult myDuration(Long id,String recordTime){
- return projectStaffRecordService.myDuration(id,recordTime);
- }
- /**
- * 查询我的月份数据
- */
- @GetMapping("/myDurationMonth")
- @ApiOperation("查询我的月份数据")
- public AjaxResult myDurationMonth(Long id,Integer year,Integer month){
- return projectStaffRecordService.myDurationMonth(id,year,month);
- }
- /**
- * 项目附件目录
- */
- @GetMapping("/selectProjectImg")
- public AjaxResult selectProjectImg(Long pid){
- if (pid==null){
- return AjaxResult.error("项目编号不能为空!");
- }
- return projectTaskService.selectProjectImg(pid);
- }
- /**
- * 下载项目打卡数据包
- */
- @GetMapping("/download")
- public void downloadFiles(HttpServletResponse response,String ids) {
- if (StringUtils.isEmpty(ids)){
- throw new ServiceException("编号不能为空");
- }
- projectStaffRecordService.downloadFiles(ids, response);
- }
- /**
- * 打卡数据考勤匹配到打卡时间
- */
- @PostMapping("/mateUserRecord")
- public AjaxResult mateUserRecord(ProjectStaffRecordInput in) {
- if (in.getClockStatus()==null||in.getClockStatus()!=2){
- return error("请先查询需要合并的数据");
- }
- return projectStaffRecordService.mateUserRecord(in);
- }
- /**
- * 项目及日志上传天河链
- * @param id
- * @return
- */
- @GetMapping("/saveProjectTaskTianhe")
- public AjaxResult saveProjectTaskTianhe(@RequestParam("id") String id){
- if (StringUtils.isEmpty(id)){
- return AjaxResult.error("项目编号不能为空");
- }
- projectTaskService.saveProjectTaskTianhe(id);
- return AjaxResult.success();
- }
- /**
- * 项目日志上传天河链
- * @param id
- * @return
- */
- @GetMapping("/saveProjectStaffRecordTianhe")
- public AjaxResult saveProjectStaffRecordTianhe(@RequestParam("id") String id){
- if (StringUtils.isEmpty(id)){
- return AjaxResult.error("项目日志编号不能为空");
- }
- projectTaskService.saveProjectStaffRecordTianhe(id);
- return AjaxResult.success();
- }
- /**
- * 文字上传天河链
- * @param content
- * @return
- */
- @GetMapping("/saveText")
- public AjaxResult saveText(@RequestParam("content") String content){
- if (StringUtils.isEmpty(content)){
- return AjaxResult.error("内容不能为空");
- }
- projectTaskService.saveText(content);
- return AjaxResult.success();
- }
- /**
- * 获取项目月份打卡数据
- * @param id 项目编号
- * @param yearMonth 年月份
- * @return 数据
- */
- @GetMapping("/getMonthClock")
- public AjaxResult getMonthClock(@RequestParam("id") Integer id,@RequestParam("yearMonth") String yearMonth){
- if (id==null){
- return AjaxResult.error("项目编号不能为空");
- }
- if (yearMonth==null){
- return AjaxResult.error("年月日期不能为空");
- }
- return AjaxResult.success(projectStaffRecordService.getMonthClock(id,yearMonth));
- }
- /**
- * 获取项目月份打卡数据
- * @param id 项目编号
- * @param yearMonth 年月份
- * @return 数据
- */
- @PostMapping("/getMonthClockExport")
- public void getMonthClockExport(@RequestParam("id") Integer id,@RequestParam("yearMonth") String yearMonth,HttpServletResponse response){
- projectStaffRecordService.getMonthClockExport(id,yearMonth,response);
- }
- /**
- * 获取项目对应打卡月份
- */
- @GetMapping("/allProjectMonthData")
- public AjaxResult getAllProjectMonth(){
- return AjaxResult.success(projectStaffRecordService.getAllProjectMonth());
- }
- }
|