|
@ -12,6 +12,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@ -30,19 +31,21 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
|
|
|
/**
|
|
|
* 记录医生健康指导模板使用次数
|
|
|
*
|
|
|
* @param modelCode 健康指导模板编码
|
|
|
*/
|
|
|
public void countSend(String modelCode){
|
|
|
synchronized (this){
|
|
|
public void countSend(String modelCode) {
|
|
|
synchronized (this) {
|
|
|
String sql = "UPDATE wlyy_doctor_guidance_temp " +
|
|
|
"SET send_times=send_times+1 " +
|
|
|
"WHERE CODE=?";
|
|
|
jdbcTemplate.update(sql,modelCode);
|
|
|
jdbcTemplate.update(sql, modelCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询单个指导模板详情
|
|
|
*
|
|
|
* @param modelCode
|
|
|
* @return
|
|
|
* @throws Exception
|
|
@ -51,24 +54,25 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
String sql = "SELECT wdgt.`model_name`,wdgt.`content`,wdgt.`images_url`,wdgt.`create_time`,wdgt.`send_times` " +
|
|
|
"FROM wlyy_doctor_guidance_temp wdgt " +
|
|
|
"WHERE wdgt.`code`=?";
|
|
|
Map temp=(Map)jdbcTemplate.queryForMap(sql,modelCode);
|
|
|
String modelName= (String)temp.get("model_name");
|
|
|
String content= (String)temp.get("content");
|
|
|
String imagesUrl= (String)temp.get("images_url");
|
|
|
Map temp = (Map) jdbcTemplate.queryForMap(sql, modelCode);
|
|
|
String modelName = (String) temp.get("model_name");
|
|
|
String content = (String) temp.get("content");
|
|
|
String imagesUrl = (String) temp.get("images_url");
|
|
|
// 多图按逗号分割保存成数组
|
|
|
String [] imagesArray = null;
|
|
|
if(imagesUrl != null){
|
|
|
String[] imagesArray = null;
|
|
|
if (imagesUrl != null) {
|
|
|
imagesArray = imagesUrl.split(",");
|
|
|
}
|
|
|
|
|
|
String createTime = (String)temp.get("create_time").toString();
|
|
|
String sendTimes = (String)temp.get("send_times").toString();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Date createTime = (Date) temp.get("create_time");
|
|
|
String dateTime = sdf.format(createTime);
|
|
|
String sendTimes = (String) temp.get("send_times").toString();
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("modelName",modelName);
|
|
|
json.put("content",content);
|
|
|
json.put("imagesUrls",imagesArray);
|
|
|
json.put("createTime",createTime);
|
|
|
json.put("sendTimes",sendTimes);
|
|
|
json.put("modelName", modelName);
|
|
|
json.put("content", content);
|
|
|
json.put("imagesUrls", imagesArray);
|
|
|
json.put("createTime", dateTime);
|
|
|
json.put("sendTimes", sendTimes);
|
|
|
return json;
|
|
|
}
|
|
|
|
|
@ -79,7 +83,7 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
* @param content 指导内容
|
|
|
* @return
|
|
|
*/
|
|
|
public DoctorGuidanceTemp add(String doctor, String content,String modelName,String imagesUrl) {
|
|
|
public DoctorGuidanceTemp add(String doctor, String content, String modelName, String imagesUrl) {
|
|
|
DoctorGuidanceTemp guidanceTemp = new DoctorGuidanceTemp();
|
|
|
String imageUrls = "";
|
|
|
String imageRow = "";
|
|
@ -92,16 +96,16 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
|
|
|
guidanceTemp.setModelName(modelName);
|
|
|
|
|
|
if (imagesUrl==null||"".equals(imagesUrl)) {
|
|
|
imagesUrl=null;
|
|
|
}else {
|
|
|
if (imagesUrl == null || "".equals(imagesUrl)) {
|
|
|
imagesUrl = null;
|
|
|
} else {
|
|
|
String[] images = imagesUrl.split(",");
|
|
|
for (String image : images) {
|
|
|
if (image.contains("http://")) {
|
|
|
imageUrls += image + ",";
|
|
|
} else {
|
|
|
try {
|
|
|
imageRow += CommonUtil.copyTempImage(image)+",";
|
|
|
imageRow += CommonUtil.copyTempImage(image) + ",";
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@ -109,7 +113,7 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
}
|
|
|
|
|
|
imagesUrl = imageUrls + imageRow;
|
|
|
imagesUrl = imagesUrl.substring(0,imagesUrl.length()-1);
|
|
|
imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
|
|
|
}
|
|
|
|
|
|
guidanceTemp.setImagesUrl(imagesUrl);
|
|
@ -136,16 +140,16 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
guidanceTemp.setModelName(modelName);
|
|
|
guidanceTemp.setContent(content);
|
|
|
|
|
|
if (imagesUrl==null||"".equals(imagesUrl)) {
|
|
|
imagesUrl=null;
|
|
|
}else {
|
|
|
if (imagesUrl == null || "".equals(imagesUrl)) {
|
|
|
imagesUrl = null;
|
|
|
} else {
|
|
|
String[] images = imagesUrl.split(",");
|
|
|
for (String image : images) {
|
|
|
if (image.contains("http://")) {
|
|
|
imageUrls += image + ",";
|
|
|
} else {
|
|
|
try {
|
|
|
imageRow += CommonUtil.copyTempImage(image)+",";
|
|
|
imageRow += CommonUtil.copyTempImage(image) + ",";
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@ -153,7 +157,7 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
}
|
|
|
|
|
|
imagesUrl = imageUrls + imageRow;
|
|
|
imagesUrl = imagesUrl.substring(0,imagesUrl.length()-1);
|
|
|
imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
|
|
|
}
|
|
|
|
|
|
guidanceTemp.setImagesUrl(imagesUrl);
|
|
@ -173,8 +177,8 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
if (codes != null && codes.length > 0) {
|
|
|
for (String temp : codes) {
|
|
|
String sql = "SELECT t.owner FROM wlyy_doctor_guidance_temp t WHERE t.code=?";
|
|
|
String owner = jdbcTemplate.queryForObject(sql,String.class,temp);
|
|
|
if(!"system".equals(owner)){
|
|
|
String owner = jdbcTemplate.queryForObject(sql, String.class, temp);
|
|
|
if (!"system".equals(owner)) {
|
|
|
guidanceTempDao.deleteByCode(temp);
|
|
|
}
|
|
|
|
|
@ -191,49 +195,49 @@ public class DoctorGuidanceTempService extends BaseService {
|
|
|
* @param type 模板类型
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String,Object>> list(String doctor, String type,int pageSize,int pageNo) throws Exception {
|
|
|
public List<Map<String, Object>> list(String doctor, String type, int pageSize, int pageNo) throws Exception {
|
|
|
Page<DoctorGuidanceTemp> temps = null;
|
|
|
PageRequest pageRequest = new PageRequest(pageNo, pageSize);
|
|
|
List<Map<String,Object>> listMap = new ArrayList<>();
|
|
|
List<Map<String, Object>> listMap = new ArrayList<>();
|
|
|
|
|
|
if (type.equals("1")) {
|
|
|
temps = guidanceTempDao.findByOwner("system",pageRequest);
|
|
|
|
|
|
List<DoctorGuidanceTemp> list = temps.getContent();
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
DoctorGuidanceTemp dgt = list.get(i);
|
|
|
Map<String,Object> tem = new HashMap<>();
|
|
|
tem.put("code",dgt.getCode());
|
|
|
tem.put("owner",dgt.getOwner());
|
|
|
tem.put("sendTimes",dgt.getSendTimes());
|
|
|
tem.put("lastTime",dgt.getLastTime());
|
|
|
tem.put("modelName",dgt.getModelName());
|
|
|
listMap.add(tem);
|
|
|
}
|
|
|
temps = guidanceTempDao.findByOwner("system", pageRequest);
|
|
|
|
|
|
List<DoctorGuidanceTemp> list = temps.getContent();
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
DoctorGuidanceTemp dgt = list.get(i);
|
|
|
Map<String, Object> tem = new HashMap<>();
|
|
|
tem.put("code", dgt.getCode());
|
|
|
tem.put("owner", dgt.getOwner());
|
|
|
tem.put("sendTimes", dgt.getSendTimes());
|
|
|
tem.put("lastTime", dgt.getLastTime());
|
|
|
tem.put("modelName", dgt.getModelName());
|
|
|
listMap.add(tem);
|
|
|
}
|
|
|
} else if (type.equals("2")) {
|
|
|
temps = guidanceTempDao.findByOwner(doctor,pageRequest);
|
|
|
temps = guidanceTempDao.findByOwner(doctor, pageRequest);
|
|
|
List<DoctorGuidanceTemp> list = temps.getContent();
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
DoctorGuidanceTemp dgt = list.get(i);
|
|
|
Map<String,Object> tem = new HashMap<>();
|
|
|
tem.put("code",dgt.getCode());
|
|
|
tem.put("owner",dgt.getOwner());
|
|
|
tem.put("sendTimes",dgt.getSendTimes());
|
|
|
tem.put("lastTime",dgt.getLastTime());
|
|
|
tem.put("modelName",dgt.getModelName());
|
|
|
Map<String, Object> tem = new HashMap<>();
|
|
|
tem.put("code", dgt.getCode());
|
|
|
tem.put("owner", dgt.getOwner());
|
|
|
tem.put("sendTimes", dgt.getSendTimes());
|
|
|
tem.put("lastTime", dgt.getLastTime());
|
|
|
tem.put("modelName", dgt.getModelName());
|
|
|
listMap.add(tem);
|
|
|
}
|
|
|
} else {
|
|
|
temps = guidanceTempDao.findByOwnerAndSystem(doctor,pageRequest);
|
|
|
temps = guidanceTempDao.findByOwnerAndSystem(doctor, pageRequest);
|
|
|
List<DoctorGuidanceTemp> list = temps.getContent();
|
|
|
for (int i=0;i<list.size();i++){
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
DoctorGuidanceTemp dgt = list.get(i);
|
|
|
Map<String,Object> tem = new HashMap<>();
|
|
|
tem.put("code",dgt.getCode());
|
|
|
tem.put("owner",dgt.getOwner());
|
|
|
tem.put("sendTimes",dgt.getSendTimes());
|
|
|
tem.put("lastTime",dgt.getLastTime());
|
|
|
tem.put("modelName",dgt.getModelName());
|
|
|
Map<String, Object> tem = new HashMap<>();
|
|
|
tem.put("code", dgt.getCode());
|
|
|
tem.put("owner", dgt.getOwner());
|
|
|
tem.put("sendTimes", dgt.getSendTimes());
|
|
|
tem.put("lastTime", dgt.getLastTime());
|
|
|
tem.put("modelName", dgt.getModelName());
|
|
|
listMap.add(tem);
|
|
|
}
|
|
|
}
|