|
@@ -3,14 +3,18 @@ package cn.com.ty.lift.business.maintenance.controller;
|
|
import cn.com.ty.lift.business.common.CountPage;
|
|
import cn.com.ty.lift.business.common.CountPage;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceOption;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceOption;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceRecord;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceRecord;
|
|
|
|
+import cn.com.ty.lift.business.maintenance.dao.entity.MtRecordImg;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtPlanRequest;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtPlanRequest;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequest;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequest;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtOptionTree;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtOptionTree;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtPlanResponse;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtPlanResponse;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtRecordResponse;
|
|
import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtRecordResponse;
|
|
import cn.com.ty.lift.business.maintenance.service.*;
|
|
import cn.com.ty.lift.business.maintenance.service.*;
|
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
|
|
|
|
+import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
|
|
import cn.com.ty.lift.common.utils.Judge;
|
|
import cn.com.ty.lift.common.utils.Judge;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
|
+import cn.hutool.core.collection.IterUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.google.common.base.Splitter;
|
|
import com.google.common.base.Splitter;
|
|
@@ -22,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.LocalTime;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -43,7 +50,10 @@ public class MaintenanceRecordController {
|
|
private MtRecordCostService mtRecordCostService;
|
|
private MtRecordCostService mtRecordCostService;
|
|
private MaintenanceOptionService maintenanceOptionService;
|
|
private MaintenanceOptionService maintenanceOptionService;
|
|
private MtRecordImgService mtRecordImgService;
|
|
private MtRecordImgService mtRecordImgService;
|
|
|
|
+ private ProjectLiftRelevanceService projectLiftRelevanceService;
|
|
|
|
|
|
|
|
+ //法规维保间隔15天
|
|
|
|
+ private final int maintenance_interval = 15;
|
|
/**
|
|
/**
|
|
* 根据条件分页查询维保-日常保养
|
|
* 根据条件分页查询维保-日常保养
|
|
* @param request
|
|
* @param request
|
|
@@ -72,6 +82,26 @@ public class MaintenanceRecordController {
|
|
IPage<MtPlanResponse> pages = maintenancePlanService.pagePlanByCondition(request);
|
|
IPage<MtPlanResponse> pages = maintenancePlanService.pagePlanByCondition(request);
|
|
Judge.notNull(pages);
|
|
Judge.notNull(pages);
|
|
long count = maintenancePlanService.countPlanByCondition(request);
|
|
long count = maintenancePlanService.countPlanByCondition(request);
|
|
|
|
+ List<MtPlanResponse> records = pages.getRecords();
|
|
|
|
+ if(IterUtil.isNotEmpty(records)){
|
|
|
|
+ List<ProjectLiftRelevance> relevances = projectLiftRelevanceService.listByMtCompany(mtCompanyId);
|
|
|
|
+ records.forEach(record -> {
|
|
|
|
+ Optional<ProjectLiftRelevance> liftRelevance = relevances.stream().filter(r -> (
|
|
|
|
+ r.getLiftId().equals(record.getLiftId()) &&
|
|
|
|
+ r.getProjectId().equals(record.getProjectId()))).findFirst();
|
|
|
|
+ if(liftRelevance.isPresent()){
|
|
|
|
+ ProjectLiftRelevance relevance = liftRelevance.get();
|
|
|
|
+ log.info("PlanDate: {}",record.getPlanDate());
|
|
|
|
+ LocalDate deadline = record.getPlanDate().plusDays(maintenance_interval - relevance.getPlanInterval());
|
|
|
|
+ log.info("deadline: {}",deadline);
|
|
|
|
+ //如果超过法规15天,法规超期LocalDate.now() < deadline
|
|
|
|
+ LocalDateTime max = LocalDateTime.of(deadline,LocalTime.MAX);
|
|
|
|
+ log.info("maxtime: {}",max);
|
|
|
|
+ record.setOverdue(LocalDateTime.now().isBefore(max) ? 1 : 2);
|
|
|
|
+ log.info("overdue: {}",record.getOverdue());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
CountPage<MtPlanResponse> countPage = new CountPage<>(count,pages);
|
|
CountPage<MtPlanResponse> countPage = new CountPage<>(count,pages);
|
|
return RestResponse.success(countPage);
|
|
return RestResponse.success(countPage);
|
|
}
|
|
}
|
|
@@ -121,7 +151,8 @@ public class MaintenanceRecordController {
|
|
Integer type = request.getType();
|
|
Integer type = request.getType();
|
|
Integer liftType = request.getLiftType();
|
|
Integer liftType = request.getLiftType();
|
|
Long mtCompanyId = request.getMtCompanyId();
|
|
Long mtCompanyId = request.getMtCompanyId();
|
|
- Judge.gt0(type,liftType,mtCompanyId);
|
|
|
|
|
|
+ Judge.id(mtCompanyId);
|
|
|
|
+ Judge.gt0(type,liftType);
|
|
List<MaintenanceOption> optionList = maintenanceOptionService.listByTypeAndLiftType(type,liftType,mtCompanyId);
|
|
List<MaintenanceOption> optionList = maintenanceOptionService.listByTypeAndLiftType(type,liftType,mtCompanyId);
|
|
Judge.notNull(optionList);
|
|
Judge.notNull(optionList);
|
|
//按照sort groupby
|
|
//按照sort groupby
|
|
@@ -144,7 +175,8 @@ public class MaintenanceRecordController {
|
|
Integer type = request.getType();
|
|
Integer type = request.getType();
|
|
Integer liftType = request.getLiftType();
|
|
Integer liftType = request.getLiftType();
|
|
Long mtCompanyId = request.getMtCompanyId();
|
|
Long mtCompanyId = request.getMtCompanyId();
|
|
- Judge.gt0(type,liftType,mtCompanyId);
|
|
|
|
|
|
+ Judge.id(mtCompanyId);
|
|
|
|
+ Judge.gt0(type,liftType);
|
|
List<MaintenanceOption> optionList = maintenanceOptionService.listByTypeAndLiftType(type,liftType,mtCompanyId);
|
|
List<MaintenanceOption> optionList = maintenanceOptionService.listByTypeAndLiftType(type,liftType,mtCompanyId);
|
|
return RestResponse.success(optionList);
|
|
return RestResponse.success(optionList);
|
|
}
|
|
}
|
|
@@ -154,29 +186,41 @@ public class MaintenanceRecordController {
|
|
* @return RestResponse
|
|
* @return RestResponse
|
|
*/
|
|
*/
|
|
@PostMapping("tofill")
|
|
@PostMapping("tofill")
|
|
- public RestResponse tofill(@RequestBody MaintenanceRecord entity){
|
|
|
|
|
|
+ public RestResponse tofill(@Valid @RequestBody MaintenanceRecord entity){
|
|
//补录
|
|
//补录
|
|
entity.setIsRepair(1);
|
|
entity.setIsRepair(1);
|
|
- boolean result = maintenanceRecordService.tofill(entity);
|
|
|
|
- return RestResponse.success(result);
|
|
|
|
|
|
+ maintenanceRecordService.tofill(entity);
|
|
|
|
+ return RestResponse.success(entity.getId());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 填写保养单-确认,带维保项和现场图片 ,修改record
|
|
* 填写保养单-确认,带维保项和现场图片 ,修改record
|
|
- * @param entity
|
|
|
|
|
|
+ * @param request
|
|
* @return RestResponse
|
|
* @return RestResponse
|
|
*/
|
|
*/
|
|
@PostMapping("fill")
|
|
@PostMapping("fill")
|
|
- public RestResponse fill(@RequestBody MaintenanceRecord entity){
|
|
|
|
- Long id = entity.getId();
|
|
|
|
|
|
+ public RestResponse fill(@RequestBody MtRecordRequest request){
|
|
|
|
+ Long id = request.getId();
|
|
Judge.id(id);
|
|
Judge.id(id);
|
|
//维保项不能为空
|
|
//维保项不能为空
|
|
- String maintenanceOption = entity.getMaintenanceOption();
|
|
|
|
|
|
+ String maintenanceOption = request.getMaintenanceOption();
|
|
Judge.notNull(maintenanceOption,"维保项不能为空");
|
|
Judge.notNull(maintenanceOption,"维保项不能为空");
|
|
- List<String> imgs = entity.getImgs();
|
|
|
|
|
|
+
|
|
|
|
+ List<String> imgs = request.getImgs();
|
|
Judge.notNull(imgs,"维保图片不能为空");
|
|
Judge.notNull(imgs,"维保图片不能为空");
|
|
|
|
|
|
- boolean result = maintenanceRecordService.fill(entity);
|
|
|
|
|
|
+ List<MtRecordImg> mtRecordImgs = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < imgs.size(); i++) {
|
|
|
|
+ MtRecordImg mri = new MtRecordImg();
|
|
|
|
+ mri.setMtRecordId(id);
|
|
|
|
+ mri.setImgUrl(imgs.get(i));
|
|
|
|
+ mri.setSort(i);
|
|
|
|
+ mtRecordImgs.add(mri);
|
|
|
|
+ }
|
|
|
|
+ MaintenanceRecord entity = maintenanceRecordService.getById(id);
|
|
|
|
+ Judge.notNull(entity);
|
|
|
|
+ entity.setMaintenanceOption(maintenanceOption);
|
|
|
|
+ boolean result = maintenanceRecordService.fill(entity,mtRecordImgs);
|
|
return RestResponse.success(result);
|
|
return RestResponse.success(result);
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
@@ -186,7 +230,6 @@ public class MaintenanceRecordController {
|
|
*/
|
|
*/
|
|
@PostMapping("workOrder")
|
|
@PostMapping("workOrder")
|
|
public RestResponse workOrder(@Valid @RequestBody MaintenanceRecord entity){
|
|
public RestResponse workOrder(@Valid @RequestBody MaintenanceRecord entity){
|
|
-
|
|
|
|
boolean result = maintenanceRecordService.tofill(entity);
|
|
boolean result = maintenanceRecordService.tofill(entity);
|
|
return RestResponse.success(result);
|
|
return RestResponse.success(result);
|
|
}
|
|
}
|