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

新增修改服务计划

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