|
@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@ -68,10 +69,8 @@ public class DoctorTeamGuidanceService extends BaseService {
|
|
|
// 只限本地路径上传到FastDFS
|
|
|
image = CommonUtil.copyTempImage(images);
|
|
|
System.out.println("images =====>" + image);
|
|
|
} else {
|
|
|
// 只有新增的时候才必须传地址
|
|
|
throw new Exception("新增图片为空!");
|
|
|
}
|
|
|
|
|
|
for (Object team : teams) {
|
|
|
JSONObject teamJson = new JSONObject(team.toString());
|
|
|
int teamId = teamJson.getInt("teamId");
|
|
@ -140,16 +139,19 @@ public class DoctorTeamGuidanceService extends BaseService {
|
|
|
doctorGuidanceTemp.setSendTimes(0);
|
|
|
doctorGuidanceTempDao.save(doctorGuidanceTemp);
|
|
|
case 0:
|
|
|
// 直接修改团队模板后修改模板团队对应表
|
|
|
doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
|
|
|
for (Object team : teams) {
|
|
|
JSONObject teamJson = new JSONObject(team.toString());
|
|
|
int teamId = teamJson.getInt("teamId");
|
|
|
String teamName = teamJson.getString("teamName");
|
|
|
// 团队内模板标题要去重复(去掉自身)
|
|
|
List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
|
|
|
if (list.size() == 0) {
|
|
|
doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, title);
|
|
|
if (list.size() <= 1) {
|
|
|
doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId,guidanceCode, title);
|
|
|
} else {
|
|
|
throw new Exception(teamName + ":团队标题重复!");
|
|
|
}
|
|
|
// 直接修改团队模板后修改模板团队对应表
|
|
|
doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@ -191,9 +193,44 @@ public class DoctorTeamGuidanceService extends BaseService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public DoctorTeamGuidanceDetail getTeamGuidanceDetail(String guidanceCode) throws Exception {
|
|
|
public JSONObject getTeamGuidanceDetail(int teamId, String guidanceCode) throws Exception {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String createTime = "";
|
|
|
String czrq = "";
|
|
|
|
|
|
DoctorTeamGuidanceDetail guidanceDetail = doctorTeamGuidanceDetailDao.findGuidanceDetail(guidanceCode);
|
|
|
return guidanceDetail;
|
|
|
List<DoctorTeamGuidanceTemplate> doctorTeamGuidanceTemplate = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
|
|
|
List teamList = new ArrayList();
|
|
|
for (DoctorTeamGuidanceTemplate teamGuidanceTemplate : doctorTeamGuidanceTemplate) {
|
|
|
Map map = new HashMap();
|
|
|
map.put("teamId", teamGuidanceTemplate.getTeamId());
|
|
|
map.put("teamName", teamGuidanceTemplate.getTeamName());
|
|
|
if (teamGuidanceTemplate.getTeamId() == teamId) {
|
|
|
jsonObject.put("useTimes", teamGuidanceTemplate.getUseTimes());
|
|
|
}
|
|
|
teamList.add(map);
|
|
|
}
|
|
|
|
|
|
Date create = guidanceDetail.getCreateTime();
|
|
|
Date cztime = guidanceDetail.getCzrq();
|
|
|
if (create != null) {
|
|
|
createTime = sdf.format(create);
|
|
|
}
|
|
|
if (cztime != null) {
|
|
|
czrq = sdf.format(cztime);
|
|
|
}
|
|
|
|
|
|
jsonObject.put("id", guidanceDetail.getId() != null ? guidanceDetail.getId() : "");
|
|
|
jsonObject.put("code", guidanceDetail.getCode() != null ? guidanceDetail.getCode() : "");
|
|
|
jsonObject.put("creater", guidanceDetail.getCreater() != null ? guidanceDetail.getCreater() : "");
|
|
|
jsonObject.put("title", guidanceDetail.getTitle() != null ? guidanceDetail.getTitle() : "");
|
|
|
jsonObject.put("content", guidanceDetail.getContent() != null ? guidanceDetail.getContent() : "");
|
|
|
jsonObject.put("imagesUrl", guidanceDetail.getImagesUrl() != null ? guidanceDetail.getImagesUrl() : "");
|
|
|
jsonObject.put("createTime", createTime);
|
|
|
jsonObject.put("czrq", czrq);
|
|
|
jsonObject.put("teamList", teamList);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -203,14 +240,14 @@ public class DoctorTeamGuidanceService extends BaseService {
|
|
|
* @param guidanceCode
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void deleteTeamGuidance(String doctor,int deteleAll, Integer teamId, String guidanceCode) throws Exception {
|
|
|
public void deleteTeamGuidance(String doctor, int deteleAll, Integer teamId, String guidanceCode) throws Exception {
|
|
|
String str = "";
|
|
|
if (deteleAll == 0) {
|
|
|
doctorTeamGuidanceTemplateDao.deleteTeamGuidance(teamId, guidanceCode);
|
|
|
} else {
|
|
|
// 删除该医生所有团队内该模板
|
|
|
List<AdminTeam> teams = memberDao.findDoctorTeams(doctor);
|
|
|
for (AdminTeam team:teams) {
|
|
|
List<AdminTeam> teams = memberDao.findDoctorTeams(doctor);
|
|
|
for (AdminTeam team : teams) {
|
|
|
int teamCode = team.getId().intValue();
|
|
|
doctorTeamGuidanceTemplateDao.deleteTeamGuidance(teamCode, guidanceCode);
|
|
|
}
|
|
@ -264,6 +301,7 @@ public class DoctorTeamGuidanceService extends BaseService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public static String validateImages(String images) throws Exception {
|
|
|
String imagePath = "";
|
|
|
String imageUrls = "";
|
|
|
String imageRow = "";
|
|
|
String[] imgs = images.split(",");
|
|
@ -277,10 +315,11 @@ public class DoctorTeamGuidanceService extends BaseService {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
images += imageUrls + imageRow;
|
|
|
|
|
|
}
|
|
|
images = images.substring(0, images.length() - 1);
|
|
|
return images;
|
|
|
imagePath += imageUrls + imageRow;
|
|
|
imagePath = imagePath.substring(0, imagePath.length() - 1);
|
|
|
return imagePath;
|
|
|
}
|
|
|
|
|
|
}
|