|
@ -0,0 +1,93 @@
|
|
|
package com.yihu.wlyy.service.app.prescription;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionFollowupContent;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionFollowupContentDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 续方咨询问卷相关方法
|
|
|
* @author huangwenjie
|
|
|
* @date 2017/11/2 09:06
|
|
|
*/
|
|
|
@Service
|
|
|
@Component
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public class PrescriptionFollowupContentService extends BaseService {
|
|
|
|
|
|
@Autowired
|
|
|
private PrescriptionFollowupContentDao prescriptionFollowupContentDao;
|
|
|
|
|
|
/**
|
|
|
* 根据续方CODE,文件类型获取数据
|
|
|
* @param prescriptionCode
|
|
|
* @param followupProject
|
|
|
* @return
|
|
|
*/
|
|
|
public List<PrescriptionFollowupContent> getByPrescriptionCodeAndFollowupProject(String prescriptionCode, String followupProject) throws Exception{
|
|
|
|
|
|
//如果传多个类型,则返回多组数据
|
|
|
if(followupProject.contains(",")){
|
|
|
List<PrescriptionFollowupContent> datalist = new ArrayList<>();
|
|
|
String[] projectArray = followupProject.split(",");
|
|
|
|
|
|
for (String project: projectArray) {
|
|
|
List<PrescriptionFollowupContent> list = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptionCode,project);
|
|
|
datalist.addAll(list);
|
|
|
}
|
|
|
|
|
|
return datalist;
|
|
|
}else{
|
|
|
return prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptionCode,followupProject);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存随访调查分类数据
|
|
|
* @param prescriptioncode
|
|
|
* @param followupProjectData
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveInfo(String prescriptioncode, String followupProjectData) throws Exception{
|
|
|
JSONArray objects = JSON.parseArray(followupProjectData);
|
|
|
|
|
|
if(objects!= null & objects.size() >0){
|
|
|
for (int i = 0; i < objects.size(); i++) {
|
|
|
List<PrescriptionFollowupContent> savedatas = new ArrayList<>();
|
|
|
JSONObject jsonObject = objects.getJSONObject(i);
|
|
|
String followupProject = jsonObject.getString("followupProject");
|
|
|
String projectValueStr = jsonObject.getString("projectData");
|
|
|
if(StringUtils.isNotBlank(projectValueStr)){
|
|
|
HashMap<String,String> projectValueMap = (HashMap)JSON.parse(projectValueStr);
|
|
|
if(!projectValueMap.isEmpty()){
|
|
|
projectValueMap.forEach( (key,value)->{
|
|
|
PrescriptionFollowupContent prescriptionFollowupContent = new PrescriptionFollowupContent();
|
|
|
prescriptionFollowupContent.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionFollowupContent.setPrescriptionCode(prescriptioncode);
|
|
|
prescriptionFollowupContent.setFollowupProject(followupProject);
|
|
|
prescriptionFollowupContent.setFollowupKey(key);
|
|
|
prescriptionFollowupContent.setFollowupValue(value);
|
|
|
savedatas.add(prescriptionFollowupContent);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
if(!savedatas.isEmpty()){
|
|
|
prescriptionFollowupContentDao.deleteByPrescriptioncodeAndFollowupProject(prescriptioncode,followupProject);
|
|
|
prescriptionFollowupContentDao.save(savedatas);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
throw new Exception("保存的分类数据不能为空!");
|
|
|
}
|
|
|
}
|
|
|
}
|