Commit 69f4afe1 authored by 蔡镇泽's avatar 蔡镇泽

新增修改服务计划

parent 2d922617
......@@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -92,25 +94,27 @@ public class SrvTaskController {
*
* @param programId 服务方案id
* @param srvEmpId 护理人员id
* @param startTime 服务计划开始时间 yyyy-MM-dd
* @param endTime 服务计划结束时间 yyyy-MM-dd
* @param taskDetails 具体护理日期 yyyy-MM-dd(逗号分隔)
*/
@RequestMapping("/addSrvTask")
public Result<Object> addSrvTask(Long programId, Long srvEmpId, String startTime, String endTime) {
public Result<Object> addSrvTask(Long programId, Long srvEmpId, String taskDetails) {
if (programId == null) {
return Result.failed("服务方案id不能为空!");
}
if (srvEmpId == null) {
return Result.failed("护理人员id不能为空!");
}
if (StringUtils.isBlank(startTime)) {
return Result.failed("服务计划开始时间不能为空!");
}
if (StringUtils.isBlank(endTime)) {
return Result.failed("服务计划结束时间不能为空!");
if (StringUtils.isBlank(taskDetails)) {
return Result.failed("具体护理日期不能为空!");
}
try {
srvTaskService.addSrvTask(programId, srvEmpId, DateUtils.strToDate(startTime), DateUtils.strToDate(endTime));
String[] details = taskDetails.split(",");
List<Date> dates = new ArrayList<>();
for (String detail : details) {
Date date = DateUtils.strToDate(detail);
dates.add(date);
}
srvTaskService.addSrvTask(programId, srvEmpId, dates);
} catch (RuntimeException e) {
//添加失败
return Result.failed(e.getMessage());
......@@ -124,25 +128,28 @@ public class SrvTaskController {
*
* @param taskId 服务计划id
* @param srvEmpId 护理人员id
* @param startTime 服务计划开始时间 yyyy-MM-dd
* @param endTime 服务计划结束时间 yyyy-MM-dd
* @param taskDetails 具体护理日期 yyyy-MM-dd(逗号分隔)
*/
@RequestMapping("/updateSrvTask")
public Result<Object> updateSrvTask(String taskId, Long srvEmpId, String startTime, String endTime) {
public Result<Object> updateSrvTask(String taskId, Long srvEmpId, String taskDetails) {
if (taskId == null) {
return Result.failed("taskId不能为空!");
}
if (srvEmpId == null) {
return Result.failed("护理人员id不能为空!");
}
if (StringUtils.isBlank(startTime)) {
return Result.failed("服务计划开始时间不能为空!");
}
if (StringUtils.isBlank(endTime)) {
return Result.failed("服务计划结束时间不能为空!");
if (StringUtils.isBlank(taskDetails)) {
return Result.failed("具体护理日期不能为空!");
}
try {
srvTaskService.updateSrvTask(taskId, srvEmpId, DateUtils.strToDate(startTime), DateUtils.strToDate(endTime));
String[] details = taskDetails.split(",");
List<Date> dates = new ArrayList<>();
for (String detail : details) {
Date date = DateUtils.strToDate(detail);
dates.add(date);
}
srvTaskService.updateSrvTask(taskId, srvEmpId, dates);
} catch (RuntimeException e) {
//修改失败
return Result.failed(e.getMessage());
......
......@@ -22,9 +22,9 @@ public interface SrvTaskService {
List<SrvTaskInfoVO> getSrvTaskInfoList(String programId);
void addSrvTask(Long programId, Long srvEmpId, Date startTime, Date endTime);
void addSrvTask(Long programId, Long srvEmpId, List<Date> dates);
void updateSrvTask(String taskId, Long srvEmpId, Date startTime, Date endTime);
void updateSrvTask(String taskId, Long srvEmpId, List<Date> dates);
Page<OrganEmpVO> getSrvOrganEmpList(Page<OrganEmpVO> page, String organId, String name, String certiType, String certifNum);
......
......@@ -72,7 +72,7 @@ public class SrvTaskServiceImpl implements SrvTaskService {
@Transactional(rollbackFor = Exception.class)
@Override
public void addSrvTask(Long programId, Long srvEmpId, Date startTime, Date endTime) {
public void addSrvTask(Long programId, Long srvEmpId, List<Date> dates) {
try {
//添加服务计划
ChSrvTask chSrvTask = new ChSrvTask();
......@@ -85,15 +85,16 @@ public class SrvTaskServiceImpl implements SrvTaskService {
throw new RuntimeException("添加服务计划失败!");
}
//添加服务计划详情
for (Date date : dates) {
ChSrvTaskDetail chSrvTaskDetail = new ChSrvTaskDetail();
chSrvTaskDetail.setSrvTaskId(chSrvTask.getSrvTaskId());
chSrvTaskDetail.setSrvStartTime(startTime);//服务开始时间
chSrvTaskDetail.setEndTime(endTime);//服务结束时间
chSrvTaskDetail.setSrvTaskId(chSrvTask.getSrvTaskId());//taskId
chSrvTaskDetail.setSrvDate(date);//服务开始时间
chSrvTaskDetail.setStatus((short) 0);//状态 未执行:0;执行中:1;已执行:2;已失效:3已完成4
int insert1 = chSrvTaskDetailMapper.insert(chSrvTaskDetail);
if (insert1 <= 0) {
throw new RuntimeException("添加服务计划详情失败!");
}
}
} catch (Exception e) {
throw new RuntimeException("系统繁忙,请稍后再试!");
}
......@@ -101,7 +102,7 @@ public class SrvTaskServiceImpl implements SrvTaskService {
@Transactional(rollbackFor = Exception.class)
@Override
public void updateSrvTask(String taskId, Long srvEmpId, Date startTime, Date endTime) {
public void updateSrvTask(String taskId, Long srvEmpId, List<Date> dates) {
//修改服务计划服务人员
ChSrvTask chSrvTask = srvTaskMapper.selectById(taskId);
if (chSrvTask == null) {
......@@ -112,13 +113,18 @@ public class SrvTaskServiceImpl implements SrvTaskService {
if (i <= 0) {
throw new RuntimeException("修改服务计划服务人员失败!");
}
//修改服务计划详情计划起止日期
ChSrvTaskDetail chSrvTaskDetail = chSrvTaskDetailMapper.selectOne(new QueryWrapper<ChSrvTaskDetail>().eq("srv_task_id", chSrvTask.getSrvTaskId()));
chSrvTaskDetail.setSrvStartTime(startTime);
chSrvTaskDetail.setEndTime(endTime);
int i1 = chSrvTaskDetailMapper.updateById(chSrvTaskDetail);
if (i1 <= 0) {
throw new RuntimeException("修改服务计划详情计划起止日期失败!");
//修改服务计划详情计划详情
chSrvTaskDetailMapper.delete(new QueryWrapper<ChSrvTaskDetail>().eq("srv_task_id", taskId));//删除原来的计划详情
for (Date date : dates) {
//新增计划详情
ChSrvTaskDetail chSrvTaskDetail = new ChSrvTaskDetail();
chSrvTaskDetail.setSrvTaskId(chSrvTask.getSrvTaskId());//taskId
chSrvTaskDetail.setSrvDate(date);//服务开始时间
chSrvTaskDetail.setStatus((short) 0);//状态 未执行:0;执行中:1;已执行:2;已失效:3已完成4
int insert1 = chSrvTaskDetailMapper.insert(chSrvTaskDetail);
if (insert1 <= 0) {
throw new RuntimeException("添加服务计划详情失败!");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment