| | |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.*; |
| | | import io.swagger.annotations.*; |
| | | import lombok.SneakyThrows; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.beans.factory.parsing.Problem; |
| | | import org.springframework.core.io.InputStreamResource; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static java.util.stream.Collectors.groupingBy; |
| | | |
| | |
| | | @Autowired |
| | | private ScreenAccountService screenAccountService; |
| | | |
| | | @Autowired |
| | | private ProjectProgressService projectProgressService; |
| | | |
| | | |
| | | @ApiOperation(value = "获取项目/委托方列表",response = LoginNameVo.class) |
| | | @GetMapping("/getLoginNameVoList") |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取项目最新进度",response = ProjectProgress.class) |
| | | @GetMapping("/getProjectProgress/{projectId}") |
| | | public R<ProjectProgress> getProjectProgress(@PathVariable Integer projectId) { |
| | | ProjectProgress projectProgress = projectProgressService.getOne(new LambdaQueryWrapper<ProjectProgress>().eq(ProjectProgress::getProjectId, projectId).eq(ProjectProgress::getDeleted,0).orderByDesc(ProjectProgress::getTime).last("limit 1")); |
| | | return R.ok(projectProgress); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取项目进度历史列表",response = ProjectProgress.class) |
| | | @PostMapping("/getProjectProgressList") |
| | | public R<Page<ProjectProgress>> getProjectProgressList(@Valid @RequestBody ProjectProgressQuery query) { |
| | | LambdaQueryWrapper<ProjectProgress> wrapper = new LambdaQueryWrapper<ProjectProgress>().eq(ProjectProgress::getProjectId, query.getProjectId()).eq(ProjectProgress::getDeleted, 0); |
| | | if(query.getContent()!=null && !query.getContent().isEmpty()){ |
| | | wrapper.like(ProjectProgress::getDetail, query.getContent()); |
| | | } |
| | | if(query.getStartTime()!=null && !query.getStartTime().isEmpty()){ |
| | | wrapper.ge(ProjectProgress::getTime, query.getStartTime()); |
| | | } |
| | | if(query.getEndTime()!=null && !query.getEndTime().isEmpty()){ |
| | | wrapper.le(ProjectProgress::getTime, query.getEndTime()); |
| | | } |
| | | |
| | | wrapper.orderByDesc(ProjectProgress::getTime); |
| | | Page<ProjectProgress> page = projectProgressService.page(new Page<>(query.getPageNum(), query.getPageSize()),wrapper); |
| | | return R.ok(page); |
| | | } |
| | | @ApiOperation(value = "获取项目进度详情",response = ProjectProgress.class) |
| | | @GetMapping("/getProjectProgressDetail/{id}") |
| | | public R<ProjectProgress> getProjectProgressDetail(@PathVariable Integer id) { |
| | | return R.ok(projectProgressService.getById(id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取项目详情",response = Project.class) |
| | | @GetMapping("/getProjectDetail/{id}") |
| | |
| | | BeanUtils.copyProperties(project,projectVo); |
| | | |
| | | List<String> properties = deviceUsageService.getDeviceUsageList(id); |
| | | properties = properties.stream().filter(e -> JSONObject.parseObject(e).containsKey("工程起重机械租赁单位") && JSONObject.parseObject(e).getString("工程起重机械租赁单位") != null && !JSONObject.parseObject(e).getString("工程起重机械租赁单位").isEmpty()).collect(Collectors.toList()); |
| | | projectVo.setProperties( properties); |
| | | |
| | | ProjectInfo projectInfo = projectInfoService.getOne(new LambdaUpdateWrapper<ProjectInfo>().eq(ProjectInfo::getProjectId, id).eq(ProjectInfo::getDeleted,false).orderByDesc(ProjectInfo::getCreateTime).last("limit 1")); |
| | |
| | | |
| | | @ApiOperation(value = "获取检查资料列表") |
| | | @GetMapping("/getDeviceDetailCheckPlanList") |
| | | public R<List<Check>> getDeviceDetailCheckPlanList(@RequestParam Integer planId) { |
| | | List<Check> list = checkService.list(new LambdaQueryWrapper<Check>().eq(Check::getPlanId,planId).orderByDesc(Check::getTime)); |
| | | public R<List<Check>> getDeviceDetailCheckPlanList(@RequestParam Integer planId,@RequestParam Integer projectId) { |
| | | List<Check> list = checkService.list(new LambdaQueryWrapper<Check>().eq(Check::getPlanId,planId).eq(projectId!=null,Check::getProjectId,projectId).orderByDesc(Check::getTime)); |
| | | if(!list.isEmpty()){ |
| | | List<Integer> planIds = list.stream().map(Check::getPlanId).toList(); |
| | | List<Plan> plans = planService.listByIds(planIds); |
| | |
| | | |
| | | @ApiOperation(value = "获取计划下拉框信息",response = Plan.class) |
| | | @GetMapping("/getPlanList") |
| | | public R<List<Plan>> getPlanList() { |
| | | List<Plan> list = planService.list(new LambdaQueryWrapper<Plan>().eq(Plan::getDeleted, false)); |
| | | public R<List<Plan>> getPlanList(Integer projectId) { |
| | | List<Plan> list = planService.list(new LambdaQueryWrapper<Plan>().eq(projectId!=null,Plan::getProjectId,projectId).eq(Plan::getDeleted, false)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取计划下拉框信息",response = Plan.class) |
| | | @GetMapping("/getPlanListFromOnDuty") |
| | | public R<List<Plan>> getPlanListFromOnDuty(Integer projectId) { |
| | | List<OnDuty> list = onDutyService.list(new LambdaQueryWrapper<OnDuty>().eq(OnDuty::getProjectId, projectId)); |
| | | if(list.isEmpty()){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | List<Integer> ids = list.stream().map(OnDuty::getPlanId).toList(); |
| | | List<Plan> resultList = planService.list(new LambdaQueryWrapper<Plan>().in(Plan::getId,ids).eq(Plan::getDeleted, false)); |
| | | return R.ok(resultList); |
| | | } |
| | | |
| | | |
| | |
| | | return R.ok(list); |
| | | |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | UserFileService userFileService; |
| | | |
| | | @SneakyThrows |
| | | @ApiOperation(value = "下载文件(名称)") |
| | | @GetMapping("/download/{name}") |
| | | public ResponseEntity<org.springframework.core.io.Resource> downloadFileByName(@PathVariable String name) { |
| | | var userFile = userFileService.getOne(new LambdaQueryWrapper<UserFile>().eq(UserFile::getName, name)); |
| | | return downloadFile(userFile); |
| | | } |
| | | |
| | | private ResponseEntity<org.springframework.core.io.Resource> downloadFile(UserFile userFile) throws IOException { |
| | | InputStreamResource resource =userFileService.resolveResource(userFile); |
| | | var fileSize = userFile.getSize(); |
| | | // if(resource == null) { |
| | | // resource = new InputStreamResource(getClass().getClassLoader().getResourceAsStream("images/wukong.png")); |
| | | // fileSize = 6215360L;// resource.contentLength(); |
| | | // } |
| | | |
| | | String encodedFileName = URLEncoder.encode(userFile.getOriginFileName(), "UTF-8"); |
| | | String headerValue = String.format("attachment; filename=\"%s\"", encodedFileName); |
| | | return ResponseEntity.ok() |
| | | .contentType(MediaType.parseMediaType(userFile.getContentType())) |
| | | .contentLength(fileSize) |
| | | .header(HttpHeaders.CONTENT_DISPOSITION, headerValue) |
| | | .body(resource); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Value("${file.upload.dir}/files") |
| | | private String UPLOAD_DIR; |
| | | |
| | | |
| | | // @PostConstruct |
| | | // void init(){ |
| | | // fileLocation = Path.of(UPLOAD_DIR).toAbsolutePath().normalize(); |
| | | // try { |
| | | // Files.createDirectories(this.fileLocation); |
| | | // } catch (Exception ex) { |
| | | // throw new RuntimeException("Could not create the directory where the uploaded files will be stored.", ex); |
| | | // } |
| | | // } |
| | | |
| | | } |