|
|
|
package com.supervision.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
import com.supervision.model.Process;
|
|
|
|
import com.supervision.model.TreatmentPlanRecord;
|
|
|
|
import com.supervision.service.ProcessService;
|
|
|
|
import com.supervision.service.TreatmentPlanRecordService;
|
|
|
|
import com.supervision.service.TreatmentPlanService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Service
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
public class TreatmentPlanServiceImpl implements TreatmentPlanService {
|
|
|
|
|
|
|
|
|
|
|
|
private final TreatmentPlanRecordService treatmentPlanRecordService;
|
|
|
|
|
|
|
|
private final ProcessService processService;
|
|
|
|
@Override
|
|
|
|
public boolean saveTreatmentPlanRecord(TreatmentPlanRecord treatmentPlanRecord) {
|
|
|
|
|
|
|
|
assertSaveTreatmentPlanRecord(treatmentPlanRecord);
|
|
|
|
|
|
|
|
return treatmentPlanRecordService.save(treatmentPlanRecord);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<TreatmentPlanRecord> queryTreatmentPlanRecord(String processId, String disposalPlanType) {
|
|
|
|
|
|
|
|
Assert.notEmpty(processId,"流程id不允许为空");
|
|
|
|
|
|
|
|
return treatmentPlanRecordService.lambdaQuery().eq(TreatmentPlanRecord::getProcessId, processId)
|
|
|
|
.eq("0".equals(disposalPlanType), TreatmentPlanRecord::getDisposalPlan, "2")
|
|
|
|
.in("1".equals(disposalPlanType), TreatmentPlanRecord::getDisposalPlan,
|
|
|
|
CollUtil.newArrayList("1","3","4","5","6","7")).list();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean updateTreatmentPlanRecord(TreatmentPlanRecord treatmentPlanRecord) {
|
|
|
|
|
|
|
|
Assert.notEmpty(treatmentPlanRecord.getId(),"主键不能为空");
|
|
|
|
assertSaveTreatmentPlanRecord(treatmentPlanRecord);
|
|
|
|
|
|
|
|
return treatmentPlanRecordService.updateById(treatmentPlanRecord);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean deleteTreatmentPlanRecord(String id) {
|
|
|
|
|
|
|
|
Assert.notEmpty("主键id不能为空");
|
|
|
|
|
|
|
|
return treatmentPlanRecordService.removeById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean confirmTreatmentPlan(String processId) {
|
|
|
|
Process process = processService.getById(processId);
|
|
|
|
Assert.notNull(process,"流程数据不存在");
|
|
|
|
Assert.notNull(process.getStatus(),"状态值有误");
|
|
|
|
|
|
|
|
if (process.getStatus().equals(2)){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
process.setStatus(2);
|
|
|
|
return processService.updateById(process);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void assertSaveTreatmentPlanRecord(TreatmentPlanRecord treatmentPlanRecord){
|
|
|
|
Assert.notEmpty(treatmentPlanRecord.getProcessId(),"流程id不能为空");
|
|
|
|
Assert.notNull(treatmentPlanRecord.getDisposalMethod(),"处置方式不能为为空");
|
|
|
|
Assert.notNull(treatmentPlanRecord.getDisposalPlan(),"处置计划不能为空");
|
|
|
|
}
|
|
|
|
}
|