503 lines
23 KiB
Plaintext
503 lines
23 KiB
Plaintext
|
|
package com.nationalelectric.greenH5;
|
|||
|
|
|
|||
|
|
import java.text.SimpleDateFormat;
|
|||
|
|
import java.util.ArrayList;
|
|||
|
|
import java.util.Date;
|
|||
|
|
import java.util.HashMap;
|
|||
|
|
import java.util.List;
|
|||
|
|
import java.util.Map;
|
|||
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|||
|
|
|
|||
|
|
import javax.annotation.Resource;
|
|||
|
|
|
|||
|
|
import org.apache.commons.lang.StringUtils;
|
|||
|
|
import org.springframework.stereotype.Controller;
|
|||
|
|
import org.springframework.transaction.annotation.Transactional;
|
|||
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
|
|
|||
|
|
import com.jysoft.unipush.AliasManage;
|
|||
|
|
import com.jysoft.weChat.service.WechatService;
|
|||
|
|
import com.jysoft.weChat.vo.ContentVo;
|
|||
|
|
import com.nationalelectirc.Constant.Constant;
|
|||
|
|
import com.nationalelectirc.utils.RestResult;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenSeekmedicalRecordBizc;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenSpanRegisterBizc;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenSeekmedicalRecord;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
|||
|
|
import com.sgcc.uap.persistence.IHibernateDao;
|
|||
|
|
|
|||
|
|
import com.sgcc.uap.service.validator.ServiceValidatorBaseException;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* <b>概述</b>:<br>
|
|||
|
|
* <p>
|
|||
|
|
* <b>功能</b>:<br>
|
|||
|
|
*
|
|||
|
|
* @author chenweikang
|
|||
|
|
*/
|
|||
|
|
@Controller
|
|||
|
|
@RequestMapping("/greenSeekMedicalRecord")
|
|||
|
|
public class GreenSeekmedicalRecordController extends GreenBaseController {
|
|||
|
|
|
|||
|
|
|
|||
|
|
@Resource
|
|||
|
|
private IHibernateDao hibernateDao;
|
|||
|
|
@Resource
|
|||
|
|
private WechatService wService;
|
|||
|
|
|
|||
|
|
@Resource
|
|||
|
|
private IGreenSeekmedicalRecordBizc greenSeekmedicalRecordBizc;
|
|||
|
|
@Resource
|
|||
|
|
private AliasManageController aliasManageController;
|
|||
|
|
|
|||
|
|
private ReentrantLock lock = new ReentrantLock();
|
|||
|
|
/**
|
|||
|
|
* greenfoodorderdetail GreenFoodOrderDetail逻辑构件
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 获取就诊项目
|
|||
|
|
*
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@RequestMapping("/getSeekmedicalProject")
|
|||
|
|
public RestResult getSeekmedicalProject(Map<String, Object> map) {
|
|||
|
|
try {
|
|||
|
|
String userId = (String) map.get("userId");
|
|||
|
|
GreenUserInfo userInfo = getUserInfo(userId);
|
|||
|
|
if (userInfo == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
// 所有时间段数据
|
|||
|
|
String projectParentSql = "select id as \"id\",project_name as \"project_name\",project_week as \"project_week\",is_deleted as \"is_deleted\",create_time as \"create_time\","
|
|||
|
|
+ "create_by as \"create_by\",parent_id as \"parent_id\",project_tips as \"project_tips\",project_day as \"project_day\",sort as \"sort\""
|
|||
|
|
+ " from green_seekmedical_project where parent_id=0 and is_deleted='N' order by sort ";
|
|||
|
|
List<Map<String, Object>> projectParentList = hibernateDao.queryForListWithSql(projectParentSql);
|
|||
|
|
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|||
|
|
for(Map<String, Object> parentMap :projectParentList){
|
|||
|
|
String projectSql = "select p.id as \"id\",p.project_name as \"project_name\",p.project_week as \"project_week\",p.is_deleted as \"is_deleted\",p.create_time as \"create_time\","
|
|||
|
|
+ "p.create_by as \"create_by\",p.parent_id as \"parent_id\",p.project_tips as \"project_tips\",p.project_day as \"project_day\",p.sort as \"sort\""
|
|||
|
|
+ ",r.count from green_seekmedical_project p left join "
|
|||
|
|
+ "(select count(project_id) as count,project_id from green_seekmedical_record where is_deleted='N' group by project_id) r on p.id= r.project_id where p.is_deleted='N' and p.parent_id=?";
|
|||
|
|
List<Map<String, Object>> projectList = hibernateDao.queryForListWithSql(projectSql,new Object[]{parentMap.get("id")});
|
|||
|
|
parentMap.put("childrenList", projectList);
|
|||
|
|
list.add(parentMap);
|
|||
|
|
}
|
|||
|
|
// String projectSql = "select p.*,r.count from green_seekmedical_project p left join "
|
|||
|
|
// + "(select count(project_id) as count,project_id from green_seekmedical_record where is_deleted='N' group by project_id) r on p.id= r.project_id where p.is_deleted='N'";
|
|||
|
|
// List<Map<String, Object>> projectList = hibernateDao.queryForListWithSql(projectSql);
|
|||
|
|
return new RestResult(Constant.SUCCESS, "初始化成功",list);
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "查询失败");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 获取就诊项目详细信息
|
|||
|
|
*
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@RequestMapping("/getSeekmedicalProjectInfo")
|
|||
|
|
public RestResult getSeekmedicalProjectInfo(@RequestBody Map<String, Object> map) {
|
|||
|
|
String userId = (String) map.get("userId");
|
|||
|
|
Integer projectId = (Integer) map.get("projectId");
|
|||
|
|
String applyDate = (String) map.get("applyDate");
|
|||
|
|
GreenUserInfo userInfo = getUserInfo(userId);
|
|||
|
|
if (userInfo == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
try {
|
|||
|
|
// 所有时间段数据
|
|||
|
|
String projectSql = "SELECT p.id as \"id\",p.project_id as \"project_id\",p.project_time as \"project_time\","
|
|||
|
|
+ "p.project_num as \"project_num\",p.create_time as \"create_time\",p.create_by as \"create_by\",p.is_deleted as \"is_deleted\","
|
|||
|
|
+ " r.applyNum as \"applyNum\" ,r.project_name as \"project_name\" FROM green_seekmedical_projectinfo p LEFT JOIN "
|
|||
|
|
+ "( SELECT count(project_info_id) AS applyNum, project_info_id,project_name FROM green_seekmedical_record "
|
|||
|
|
+ "WHERE is_deleted = 'N' AND apply_date = ? GROUP BY project_info_id,project_name ) r "
|
|||
|
|
+ "ON p.id = r.project_info_id WHERE p.is_deleted = 'N' AND p.project_id = ? order by create_time asc";
|
|||
|
|
List<Map<String, Object>> projectList = hibernateDao.queryForListWithSql(projectSql,new Object[]{applyDate,projectId});
|
|||
|
|
return new RestResult(Constant.SUCCESS, "初始化成功", projectList);
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "查询失败");
|
|||
|
|
}
|
|||
|
|
//return new RestResult(Constant.SUCCESS, "初始化成功");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**提交订单*/
|
|||
|
|
|
|||
|
|
@SuppressWarnings("deprecation")
|
|||
|
|
@RequestMapping(value="/saveSeekmedicalProjectRecord", method = RequestMethod.POST)
|
|||
|
|
@Transactional(rollbackFor=Exception.class)
|
|||
|
|
@ResponseBody
|
|||
|
|
public RestResult saveSeekmedicalProjectRecord(@RequestBody GreenSeekmedicalRecord greenSeekmedicalRecord){
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
lock.lock();
|
|||
|
|
|
|||
|
|
// String userId = greenSeekmedicalRecord.getApplyId();
|
|||
|
|
// GreenUserInfo info = getUserInfo(userId);
|
|||
|
|
// if(info==null){
|
|||
|
|
// return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
// }
|
|||
|
|
String projectSql = "SELECT p.id as \"id\",p.project_id as \"project_id\",p.project_time as \"project_time\","
|
|||
|
|
+ "p.project_num as \"project_num\",p.create_time as \"create_time\",p.create_by as \"create_by\",p.is_deleted as \"is_deleted\","
|
|||
|
|
+ "r.applyNum as \"applyNum\" FROM green_seekmedical_projectinfo p LEFT JOIN "
|
|||
|
|
+ "( SELECT count(project_info_id) AS applyNum, project_info_id FROM green_seekmedical_record "
|
|||
|
|
+ "WHERE is_deleted = 'N' AND apply_date = ? GROUP BY project_info_id ) r "
|
|||
|
|
+ "ON p.id = r.project_info_id WHERE p.is_deleted = 'N' and p.id= ?";
|
|||
|
|
List<Map<String, Object>> projectList = hibernateDao.queryForListWithSql(projectSql,new Object[]{greenSeekmedicalRecord.getApplyDate(),greenSeekmedicalRecord.getProjectInfoId()});
|
|||
|
|
Map<String, Object> map = projectList.get(0);
|
|||
|
|
Long applyNum = map.get("applyNum")==null?0:Long.parseLong(map.get("applyNum").toString());
|
|||
|
|
Integer project_num =Integer.parseInt(map.get("project_num").toString());
|
|||
|
|
if(project_num!=-1&&project_num-applyNum<=0){
|
|||
|
|
return new RestResult(Constant.FAILED,"该时间段剩余次数已全部被预约,请选择其他时间段!");
|
|||
|
|
}
|
|||
|
|
greenSeekmedicalRecord.setCreateTime(new Date());
|
|||
|
|
greenSeekmedicalRecord.setCreateBy(greenSeekmedicalRecord.getApplyId());
|
|||
|
|
|
|||
|
|
Long id = greenSeekmedicalRecord.getId();
|
|||
|
|
Integer type = greenSeekmedicalRecord.getEditType();
|
|||
|
|
if(type!=0&& id !=null){
|
|||
|
|
GreenSeekmedicalRecord greenSeekmedicalRecordOld = greenSeekmedicalRecordBizc.get(id);
|
|||
|
|
String applyDateOld = greenSeekmedicalRecordOld.getApplyDate()+" "+greenSeekmedicalRecordOld.getProjectInfoName();
|
|||
|
|
greenSeekmedicalRecordOld.setApplyDate(greenSeekmedicalRecord.getApplyDate());
|
|||
|
|
greenSeekmedicalRecordOld.setEditType(greenSeekmedicalRecord.getEditType());
|
|||
|
|
greenSeekmedicalRecordOld.setProjectId(greenSeekmedicalRecord.getProjectId());
|
|||
|
|
greenSeekmedicalRecordOld.setProjectName(greenSeekmedicalRecord.getProjectName());
|
|||
|
|
greenSeekmedicalRecordOld.setProjectInfoId(greenSeekmedicalRecord.getProjectInfoId());
|
|||
|
|
greenSeekmedicalRecordOld.setProjectInfoName(greenSeekmedicalRecord.getProjectInfoName());
|
|||
|
|
greenSeekmedicalRecordOld.setRemark(greenSeekmedicalRecord.getRemark());
|
|||
|
|
greenSeekmedicalRecordOld.setModifyBy(greenSeekmedicalRecord.getModifyBy());
|
|||
|
|
greenSeekmedicalRecordOld.setModifyTime(new Date());
|
|||
|
|
|
|||
|
|
if(type==1){
|
|||
|
|
greenSeekmedicalRecordOld.setEditOwn(1);
|
|||
|
|
} else if(type==2){
|
|||
|
|
greenSeekmedicalRecordOld.setEditOther(1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
String applyDateNew = greenSeekmedicalRecord.getApplyDate()+" "+greenSeekmedicalRecordOld.getProjectInfoName();
|
|||
|
|
hibernateDao.updateObject(greenSeekmedicalRecordOld, id);
|
|||
|
|
|
|||
|
|
if(type==1){
|
|||
|
|
Long applyInfoId = greenSeekmedicalRecordOld.getProjectId();
|
|||
|
|
String getParentIdSql = "select parent_id from green_seekmedical_project where id =? ";
|
|||
|
|
Long parentIdForProject = hibernateDao.queryForLongWithSql(getParentIdSql,new Object[]{applyInfoId});
|
|||
|
|
String role = "12009";
|
|||
|
|
if(parentIdForProject==100007){
|
|||
|
|
role = "12009,12014,12015";
|
|||
|
|
}else if(parentIdForProject==100008){
|
|||
|
|
role = "12009,12015,12016";
|
|||
|
|
}
|
|||
|
|
//查询所有有这个权限的人员
|
|||
|
|
String getUserSql = "SELECT u.id,p.permission_id,u.real_name FROM green_user_info u "
|
|||
|
|
+ " LEFT JOIN green_user_role_rel r ON u.id = r.user_id "
|
|||
|
|
+ " LEFT JOIN green_role_permission p ON p.role_id = r.role_id "
|
|||
|
|
+ " WHERE p.permission_id in ("+role+") ";
|
|||
|
|
List<Map<String,Object>> userList = hibernateDao.queryForListWithSql(getUserSql);
|
|||
|
|
String title = "就诊预约受理";
|
|||
|
|
String text = "您好,用户已修改就诊预约,请注意查看最新的预约信息。";
|
|||
|
|
String url = "";
|
|||
|
|
for(int i=0;i<userList.size();i++){
|
|||
|
|
Map<String,Object> obj = userList.get(i);
|
|||
|
|
Integer permission_id = Integer.parseInt(obj.get("permission_id").toString());
|
|||
|
|
if(permission_id==12009){
|
|||
|
|
url = "/pages/medical/see-doctor-sl";
|
|||
|
|
}else if(permission_id==12014){
|
|||
|
|
url = "/pages/medical/see-doctor-sl?parent_id=100007";
|
|||
|
|
}else if(permission_id==12015){
|
|||
|
|
url = "/pages/medical/see-doctor-sl?parent_id=100007,100008";
|
|||
|
|
}else if(permission_id==12016){
|
|||
|
|
url = "/pages/medical/see-doctor-sl?parent_id=100008";
|
|||
|
|
}
|
|||
|
|
aliasManageController.pushToSingle((String)obj.get("id"), title, text, url);
|
|||
|
|
}
|
|||
|
|
}else if(type==2){
|
|||
|
|
String userId2 = greenSeekmedicalRecordOld.getApplyId();
|
|||
|
|
String title="就诊预约";
|
|||
|
|
String text = "您好,您的预约已被诊所修改,请注意最新的预约信息。";
|
|||
|
|
String url = "/pages/medical/see-doctor?currentTabIndex=1";
|
|||
|
|
aliasManageController.pushToSingle(userId2, title, text, url);
|
|||
|
|
// GreenUserInfo userInfo = getUserInfo(userId);
|
|||
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|||
|
|
// String openIdString = userInfo.getWxOpenId();
|
|||
|
|
// Map<String, ContentVo> dataMap = new HashMap<String, ContentVo>();
|
|||
|
|
// dataMap.put("first", new ContentVo("诊所已更改您的预约,请注意最新预约", "#173177"));
|
|||
|
|
// dataMap.put("keyword1", new ContentVo(greenSeekmedicalRecordOld.getProjectName(), "#black"));
|
|||
|
|
// dataMap.put("keyword2", new ContentVo(applyDateOld, "#black"));
|
|||
|
|
// dataMap.put("keyword3", new ContentVo(greenSeekmedicalRecordOld.getApplyDate()+" "+greenSeekmedicalRecordOld.getProjectInfoName(), "#black"));
|
|||
|
|
// dataMap.put("remark", new ContentVo("感谢您的参于与支持", "#173177"));
|
|||
|
|
// wService.publishMsg(dataMap, openIdString, 8);
|
|||
|
|
}
|
|||
|
|
return new RestResult(Constant.SUCCESS,"修改成功");
|
|||
|
|
}else{
|
|||
|
|
String userId = greenSeekmedicalRecord.getApplyId();
|
|||
|
|
hibernateDao.saveObject(greenSeekmedicalRecord);
|
|||
|
|
String title="就诊预约";
|
|||
|
|
String text = "您好,您已成功预约就诊,请安排好您的时间。";
|
|||
|
|
String url = "/pages/medical/see-doctor?currentTabIndex=1";
|
|||
|
|
aliasManageController.pushToSingle(userId, title, text, url);
|
|||
|
|
//由就诊项目查询通知受理人群
|
|||
|
|
Long applyInfoId = greenSeekmedicalRecord.getProjectId();
|
|||
|
|
String getParentIdSql = "select parent_id from green_seekmedical_project where id =? ";
|
|||
|
|
Long parentIdForProject = hibernateDao.queryForLongWithSql(getParentIdSql,new Object[]{applyInfoId});
|
|||
|
|
String role = "12009";
|
|||
|
|
if(parentIdForProject==100007){
|
|||
|
|
role = "12009,12014,12015";
|
|||
|
|
}else if(parentIdForProject==100008){
|
|||
|
|
role = "12009,12015,12016";
|
|||
|
|
}
|
|||
|
|
//查询所有有这个权限的人员
|
|||
|
|
String getUserSql = "SELECT u.id,p.permission_id,u.real_name FROM green_user_info u "
|
|||
|
|
+ " LEFT JOIN green_user_role_rel r ON u.id = r.user_id "
|
|||
|
|
+ " LEFT JOIN green_role_permission p ON p.role_id = r.role_id "
|
|||
|
|
+ " WHERE p.permission_id in ("+role+") ";
|
|||
|
|
List<Map<String,Object>> userList = hibernateDao.queryForListWithSql(getUserSql);
|
|||
|
|
title = "就诊预约受理";
|
|||
|
|
text = "您好,您有新的就诊预约,请注意查看。";
|
|||
|
|
for(int i=0;i<userList.size();i++){
|
|||
|
|
Map<String,Object> obj = userList.get(i);
|
|||
|
|
Integer permission_id = Integer.parseInt(obj.get("permission_id").toString());
|
|||
|
|
if(permission_id==12009){
|
|||
|
|
url = "/pages/medical/see-doctor-sl";
|
|||
|
|
}else if(permission_id==12014){
|
|||
|
|
url = "/pages/medical/see-doctor-sl?parent_id=100007";
|
|||
|
|
}else if(permission_id==12015){
|
|||
|
|
url = "/pages/medical/see-doctor-sl?parent_id=100007,100008";
|
|||
|
|
}else if(permission_id==12016){
|
|||
|
|
url = "/pages/medical/see-doctor-sl?parent_id=100008";
|
|||
|
|
}
|
|||
|
|
aliasManageController.pushToSingle((String)obj.get("id"), title, text, url);
|
|||
|
|
}
|
|||
|
|
return new RestResult(Constant.SUCCESS,"预约成功");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}catch (ServiceValidatorBaseException e) {
|
|||
|
|
throw e;
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
//设置手动回滚
|
|||
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|||
|
|
return new RestResult(Constant.FAILED,"返回异常");
|
|||
|
|
}finally {
|
|||
|
|
if (lock.isLocked()) {
|
|||
|
|
lock.unlock();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**用户订单列表*/
|
|||
|
|
@RequestMapping(value="/getMySeekmedicalProjectRecord", method = RequestMethod.POST)
|
|||
|
|
@ResponseBody
|
|||
|
|
public RestResult getMySeekmedicalProjectRecord(@RequestBody GreenSeekmedicalRecord greenSeekmedicalRecord){
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
String userId = greenSeekmedicalRecord.getApplyId();
|
|||
|
|
Long id = greenSeekmedicalRecord.getId();
|
|||
|
|
GreenUserInfo info = getUserInfo(userId);
|
|||
|
|
if(info==null){
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
StringBuffer sb = new StringBuffer();
|
|||
|
|
//分页信息
|
|||
|
|
int pageSize = greenSeekmedicalRecord.getPageSize();
|
|||
|
|
int pageNum = greenSeekmedicalRecord.getPageNum();
|
|||
|
|
int limit = ((pageNum > 0 ? pageNum : 1) - 1) * pageSize;
|
|||
|
|
pageSize = pageSize*pageNum;
|
|||
|
|
//查询订单
|
|||
|
|
sb.append("select * from (select rn.*,rownum rw from ( "
|
|||
|
|
+ " Select id as \"id\",project_id as \"project_id\",project_name as \"project_name\",project_info_id as \"project_info_id\",project_info_name as \"project_info_name\",apply_id as \"apply_id\","
|
|||
|
|
+ "apply_name as \"apply_name\",apply_dept_id as \"apply_dept_id\",apply_dept_name as \"apply_dept_name\",apply_phone as \"apply_phone\",remark as \"remark\","
|
|||
|
|
+ "apply_date as \"apply_date\",create_by as \"create_by\",modify_time as \"modify_time\",modify_by as \"modify_by\",is_deleted as \"is_deleted\",status as \"status\","
|
|||
|
|
+ "edit_own as \"edit_own\",edit_other as \"edit_other\",comment_status as \"comment_status\""
|
|||
|
|
+ ",to_char(create_time,'YYYY-MM-DD HH24:MI') as \"createTime\" from green_seekmedical_record "
|
|||
|
|
+ " where is_deleted='N' ");
|
|||
|
|
// + " where is_deleted='N' ");
|
|||
|
|
if(id!=null){
|
|||
|
|
sb.append(" and id = "+id );
|
|||
|
|
}else{
|
|||
|
|
sb.append(" and apply_id = '"+userId+"'");
|
|||
|
|
}
|
|||
|
|
sb.append( " order by create_time desc) rn )where rw>? and rw<=? ");
|
|||
|
|
List<Map<String,Object>> applyList = hibernateDao.queryForListWithSql(sb.toString(),new Object[]{limit, pageSize});
|
|||
|
|
|
|||
|
|
|
|||
|
|
return new RestResult(Constant.SUCCESS,"成功",applyList);
|
|||
|
|
}catch (ServiceValidatorBaseException e) {
|
|||
|
|
throw e;
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED,"返回异常");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**用户订单列表*/
|
|||
|
|
@RequestMapping(value="/getAllSeekmedicalProjectRecord", method = RequestMethod.POST)
|
|||
|
|
@ResponseBody
|
|||
|
|
public RestResult getAllSeekmedicalProjectRecord(Map<String,Object> map){
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
String userId = map.get("userId").toString();
|
|||
|
|
Integer pageNum = (Integer)map.get("pageNum");
|
|||
|
|
Integer pageSize = (Integer)map.get("pageSize");
|
|||
|
|
String startDate = map.get("startDate").toString();
|
|||
|
|
String endDate = map.get("endDate").toString();
|
|||
|
|
GreenUserInfo info = getUserInfo(userId);
|
|||
|
|
if(info==null){
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//分页信息
|
|||
|
|
int limit = ((pageNum > 0 ? pageNum : 1) - 1) * pageSize;
|
|||
|
|
pageSize = pageSize*pageNum;
|
|||
|
|
//查询订单
|
|||
|
|
StringBuffer sb = new StringBuffer();
|
|||
|
|
sb.append("select * from (select rn.*,rownum rw from ("
|
|||
|
|
+ " Select id as \"id\",project_id as \"project_id\",project_name as \"project_name\","
|
|||
|
|
+ "project_info_id as \"project_info_id\",project_info_name as \"project_info_name\",apply_id as \"apply_id\","
|
|||
|
|
+ "apply_name as \"apply_name\",apply_dept_id as \"apply_dept_id\",apply_dept_name as \"apply_dept_name\","
|
|||
|
|
+ "apply_phone as \"apply_phone\",remark as \"remark\",apply_date as \"apply_date\","
|
|||
|
|
+ "create_by as \"create_by\",modify_time as \"modify_time\",modify_by as \"modify_by\",is_deleted as \"is_deleted\","
|
|||
|
|
+ "status as \"status\",edit_own as \"edit_own\",edit_other as \"edit_other\",comment_status as \"comment_status\",create_time as \"create_time\","
|
|||
|
|
+ "to_char(create_time,'yyyy-mm-dd hh24:mi:ss') as \"createTime\""
|
|||
|
|
+ " from green_seekmedical_record "
|
|||
|
|
+ " where is_deleted='N' "
|
|||
|
|
+ " and apply_date<=? "
|
|||
|
|
+ " and apply_date>=? "
|
|||
|
|
+ "");
|
|||
|
|
sb.append( " order by create_time desc ) rn )where rw>? and rw<=? ");
|
|||
|
|
List<Map<String,Object>> applyList = hibernateDao.queryForListWithSql(sb.toString()
|
|||
|
|
,new Object[]{endDate,startDate, limit, pageSize });
|
|||
|
|
String countSql = "select count(*) from green_seekmedical_record "
|
|||
|
|
+ " where is_deleted='N' "
|
|||
|
|
+ " and apply_date<=? "
|
|||
|
|
+ " and apply_date>=? ";
|
|||
|
|
Integer count = hibernateDao.queryForIntWithSql(countSql,new Object[] { endDate,startDate });
|
|||
|
|
Map<String,Object> rmap = new HashMap<String,Object>();
|
|||
|
|
rmap.put("list", applyList);
|
|||
|
|
rmap.put("count", count);
|
|||
|
|
return new RestResult(Constant.SUCCESS,"成功",rmap);
|
|||
|
|
}catch (ServiceValidatorBaseException e) {
|
|||
|
|
throw e;
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED,"返回异常");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
@RequestMapping("/getSeekmedicalProjectSl")
|
|||
|
|
public RestResult getSeekmedicalProjectSl(Map<String, Object> map) {
|
|||
|
|
try {
|
|||
|
|
String userId = (String) map.get("userId");
|
|||
|
|
GreenUserInfo userInfo = getUserInfo(userId);
|
|||
|
|
String applyDate = (String) map.get("applyDate");
|
|||
|
|
String parentId = (String) map.get("parentId");
|
|||
|
|
String parentIds[] = parentId.split(",");
|
|||
|
|
if (userInfo == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
// 所有时间段数据
|
|||
|
|
StringBuilder projectSql= new StringBuilder("select p.id as \"id\",p.project_name as \"project_name\",p.project_week as \"project_week\",p.is_deleted as \"is_deleted\","
|
|||
|
|
+ "p.create_time as \"create_time\",p.create_by as \"create_by\",p.parent_id as \"parent_id\",p.project_tips as \"project_tips\",p.project_day as \"project_day\",p.sort as \"sort\","
|
|||
|
|
+ "r.count as \"count\" from green_seekmedical_project p left join "
|
|||
|
|
+ "(select count(project_id) as count,project_id from green_seekmedical_record where is_deleted='N' and apply_date=? AND STATUS = 0 group by project_id) r on p.id= r.project_id where p.is_deleted='N'");
|
|||
|
|
List<Object> objList = new ArrayList<Object>();
|
|||
|
|
objList.add(applyDate);
|
|||
|
|
if(StringUtils.isEmpty(parentId)){
|
|||
|
|
projectSql.append(" and p.parent_id<>? ");
|
|||
|
|
objList.add("0");
|
|||
|
|
}else {
|
|||
|
|
projectSql.append(" and p.parent_id in (");
|
|||
|
|
String strP= "";
|
|||
|
|
for(String str:parentIds){
|
|||
|
|
if(StringUtils.isNotEmpty(strP)){
|
|||
|
|
projectSql.append(",?");
|
|||
|
|
|
|||
|
|
}else{
|
|||
|
|
projectSql.append("?");
|
|||
|
|
strP="1";
|
|||
|
|
}
|
|||
|
|
objList.add(str);
|
|||
|
|
}
|
|||
|
|
projectSql.append(")");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<Map<String, Object>> projectList = hibernateDao.queryForListWithSql(projectSql.toString(),objList.toArray());
|
|||
|
|
return new RestResult(Constant.SUCCESS, "初始化成功", projectList);
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "查询失败");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**用户订单列表*/
|
|||
|
|
@RequestMapping(value="/getSlSeekmedicalProjectRecord", method = RequestMethod.POST)
|
|||
|
|
@ResponseBody
|
|||
|
|
public RestResult getSlSeekmedicalProjectRecord(@RequestBody GreenSeekmedicalRecord greenSeekmedicalRecord){
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
// String userId = greenSeekmedicalRecord.getApplyId();
|
|||
|
|
// GreenUserInfo info = getUserInfo(userId);
|
|||
|
|
// if(info==null){
|
|||
|
|
// return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
// }
|
|||
|
|
Long project_id = greenSeekmedicalRecord.getProjectId();
|
|||
|
|
String apply_date = greenSeekmedicalRecord.getApplyDate();
|
|||
|
|
StringBuffer sb = new StringBuffer();
|
|||
|
|
//分页信息
|
|||
|
|
//查询订单
|
|||
|
|
sb.append(" Select id as \"id\",project_id as \"project_id\",project_name as \"project_name\","
|
|||
|
|
+ "project_info_id as \"project_info_id\",project_info_name as \"project_info_name\",apply_id as \"apply_id\","
|
|||
|
|
+ "apply_name as \"apply_name\",apply_dept_id as \"apply_dept_id\",apply_dept_name as \"apply_dept_name\","
|
|||
|
|
+ "apply_phone as \"apply_phone\",remark as \"remark\",apply_date as \"apply_date\","
|
|||
|
|
+ "create_by as \"create_by\",modify_time as \"modify_time\",modify_by as \"modify_by\",is_deleted as \"is_deleted\","
|
|||
|
|
+ "status as \"status\",edit_own as \"edit_own\",edit_other as \"edit_other\",comment_status as \"comment_status\","
|
|||
|
|
+ "to_char(create_time,'yyyy-mm-dd hh24:mi:ss') as \"createTime\""
|
|||
|
|
+ " from green_seekmedical_record "
|
|||
|
|
+ " where is_deleted='N' and project_id=? and apply_date=? and status=0 order by create_time desc ");
|
|||
|
|
List<Map<String,Object>> applyList = hibernateDao.queryForListWithSql(sb.toString()
|
|||
|
|
,new Object[]{ project_id,apply_date});
|
|||
|
|
|
|||
|
|
|
|||
|
|
return new RestResult(Constant.SUCCESS,"成功",applyList);
|
|||
|
|
}catch (ServiceValidatorBaseException e) {
|
|||
|
|
throw e;
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED,"返回异常");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
@SuppressWarnings("deprecation")
|
|||
|
|
@RequestMapping(value="/cancelSeekmedicalRecord", method = RequestMethod.POST)
|
|||
|
|
@Transactional(rollbackFor=Exception.class)
|
|||
|
|
@ResponseBody
|
|||
|
|
public RestResult cancelSeekmedicalRecord(@RequestBody GreenSeekmedicalRecord greenSeekmedicalRecord){
|
|||
|
|
|
|||
|
|
try {
|
|||
|
|
|
|||
|
|
Long id=greenSeekmedicalRecord.getId();
|
|||
|
|
String sql = "update green_seekmedical_record set status =1 where id="+id+" ";
|
|||
|
|
hibernateDao.updateWithSql(sql);
|
|||
|
|
return new RestResult(Constant.SUCCESS,"取消成功");
|
|||
|
|
}catch (ServiceValidatorBaseException e) {
|
|||
|
|
throw e;
|
|||
|
|
}catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
//设置手动回滚
|
|||
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|||
|
|
return new RestResult(Constant.FAILED,"取消失败");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|