|
@@ -1,5 +1,11 @@
|
|
package com.ruoyi.care.service.impl;
|
|
package com.ruoyi.care.service.impl;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
+import java.nio.file.Paths;
|
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -9,7 +15,9 @@ import com.ruoyi.care.domain.CareRecords;
|
|
import com.ruoyi.care.mapper.CareApplicationsMapper;
|
|
import com.ruoyi.care.mapper.CareApplicationsMapper;
|
|
import com.ruoyi.care.mapper.CareNurseRecordsMapper;
|
|
import com.ruoyi.care.mapper.CareNurseRecordsMapper;
|
|
import com.ruoyi.care.mapper.CareRecordsMapper;
|
|
import com.ruoyi.care.mapper.CareRecordsMapper;
|
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
import com.ruoyi.common.enums.CareApplyStatus;
|
|
import com.ruoyi.common.enums.CareApplyStatus;
|
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
import org.apache.commons.lang3.time.FastDateFormat;
|
|
import org.apache.commons.lang3.time.FastDateFormat;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -70,6 +78,8 @@ public class CareNurseClocksServiceImpl implements ICareNurseClocksService
|
|
@Transactional
|
|
@Transactional
|
|
public int insertCareNurseClocks(CareNurseClocks careNurseClocks,Long userId)
|
|
public int insertCareNurseClocks(CareNurseClocks careNurseClocks,Long userId)
|
|
{
|
|
{
|
|
|
|
+ String psths[]=careNurseClocks.getImgPaths().split(",");
|
|
|
|
+ int result=0;
|
|
//获取当前节点记录
|
|
//获取当前节点记录
|
|
CareRecords curr=new CareRecords();
|
|
CareRecords curr=new CareRecords();
|
|
curr.setApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
curr.setApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
@@ -82,6 +92,7 @@ public class CareNurseClocksServiceImpl implements ICareNurseClocksService
|
|
}
|
|
}
|
|
|
|
|
|
careNurseClocks.setCreateTime(DateUtils.getNowDate());
|
|
careNurseClocks.setCreateTime(DateUtils.getNowDate());
|
|
|
|
+ careNurseClocks.setImgPaths(careNurseClocks.getImgPaths().replaceAll("/temp/","/upload/"));
|
|
// 判断当天任务是否一开始
|
|
// 判断当天任务是否一开始
|
|
String date=careNurseClocks.getNursingTime().substring(0,10);
|
|
String date=careNurseClocks.getNursingTime().substring(0,10);
|
|
CareNurseRecords careNurseRecords= new CareNurseRecords();
|
|
CareNurseRecords careNurseRecords= new CareNurseRecords();
|
|
@@ -91,9 +102,9 @@ public class CareNurseClocksServiceImpl implements ICareNurseClocksService
|
|
if(lst.size()>0){
|
|
if(lst.size()>0){
|
|
careRecordsMapper.updateCareRecords(curr);
|
|
careRecordsMapper.updateCareRecords(curr);
|
|
//已经开始了直接新增打卡记录
|
|
//已经开始了直接新增打卡记录
|
|
- return careNurseClocksMapper.insertCareNurseClocks(careNurseClocks);
|
|
|
|
|
|
+ result= careNurseClocksMapper.insertCareNurseClocks(careNurseClocks);
|
|
}else{
|
|
}else{
|
|
- //修改申请状态为正在进行,并添加护理记录级打卡记录
|
|
|
|
|
|
+ //修改申请状态为正在进行,并添加护理记录及打卡记录
|
|
CareApplications careApplications=careApplicationsMapper.selectCareApplicationsByApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
CareApplications careApplications=careApplicationsMapper.selectCareApplicationsByApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
careApplications.setDealStatus("in_progress");
|
|
careApplications.setDealStatus("in_progress");
|
|
careApplicationsMapper.updateCareApplications(careApplications);
|
|
careApplicationsMapper.updateCareApplications(careApplications);
|
|
@@ -103,11 +114,27 @@ public class CareNurseClocksServiceImpl implements ICareNurseClocksService
|
|
careNurseRecords.setApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
careNurseRecords.setApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
careNurseRecordsMapper.insertCareNurseRecords(careNurseRecords);
|
|
careNurseRecordsMapper.insertCareNurseRecords(careNurseRecords);
|
|
|
|
|
|
- curr.setRemark("已打卡"+(lst.size()+1)+"次");
|
|
|
|
- careRecordsMapper.updateCareRecords(curr);
|
|
|
|
|
|
+ //获取打卡次数
|
|
|
|
+ CareNurseRecords recordCount=new CareNurseRecords();
|
|
|
|
+ recordCount.setApplyId(Long.parseLong(careNurseClocks.getApplyId()));
|
|
|
|
+ curr.setRemark("已打卡"+careNurseRecordsMapper.selectCareNurseRecordsList(recordCount).size()+"次");
|
|
|
|
+ careRecordsMapper.updateCareRecords(curr);
|
|
|
|
+
|
|
|
|
+ result=careNurseClocksMapper.insertCareNurseClocks(careNurseClocks);
|
|
|
|
+ }
|
|
|
|
|
|
- return careNurseClocksMapper.insertCareNurseClocks(careNurseClocks);
|
|
|
|
|
|
+ //保存成功后 将文件转移到正式路径
|
|
|
|
+
|
|
|
|
+ for(int i=0;i<psths.length;i++){
|
|
|
|
+ String path= RuoYiConfig.getProfile()+psths[i].replace("profile","");
|
|
|
|
+ String finalFilePath=RuoYiConfig.getUploadPath()+psths[i].replace("/profile/temp","");
|
|
|
|
+ try {
|
|
|
|
+ moveFileToFinalPath(path,finalFilePath);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ return result;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -147,4 +174,29 @@ public class CareNurseClocksServiceImpl implements ICareNurseClocksService
|
|
{
|
|
{
|
|
return careNurseClocksMapper.deleteCareNurseClocksByClockId(clockId);
|
|
return careNurseClocksMapper.deleteCareNurseClocksByClockId(clockId);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void moveFileToFinalPath(String tempFilePath, String finalFilePath) throws IOException {
|
|
|
|
+ // 规范化路径
|
|
|
|
+ Path tempPath = Paths.get(tempFilePath).normalize();
|
|
|
|
+ Path finalPath = Paths.get(finalFilePath).normalize();
|
|
|
|
+
|
|
|
|
+ // 检查临时文件是否存在
|
|
|
|
+ if (!Files.exists(tempPath)) {
|
|
|
|
+ throw new IOException("临时文件不存在, 请重新上传: " + tempPath.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 创建目标目录(如果不存在)
|
|
|
|
+ Path finalDir = finalPath.getParent();
|
|
|
|
+ if (finalDir != null && !Files.exists(finalDir)) {
|
|
|
|
+ Files.createDirectories(finalDir);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 移动文件到最终路径
|
|
|
|
+ try {
|
|
|
|
+ Files.move(tempPath, finalPath, StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
+ System.out.println("文件已成功移动到: " + finalPath.toString());
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new IOException("文件移动失败: " + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|