|
@ -1,10 +1,12 @@
|
|
|
package com.yihu.ehr.svrinspection.service;
|
|
|
|
|
|
import com.yihu.ehr.query.BaseJpaService;
|
|
|
import com.yihu.ehr.redis.schema.OrgKeySchema;
|
|
|
import com.yihu.ehr.svrinspection.commons.exception.ManageException;
|
|
|
import com.yihu.ehr.svrinspection.dao.AssistanceApplyDao;
|
|
|
import com.yihu.ehr.svrinspection.model.AssistanceApplyModel;
|
|
|
import com.yihu.ehr.util.datetime.DateUtil;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -13,34 +15,59 @@ import java.util.Date;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 检验申请 业务类
|
|
|
* 检验申请 业务类
|
|
|
*
|
|
|
* @author HZY
|
|
|
* @created 2018/11/14 9:21
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Service
|
|
|
public class AssistanceApplyService extends BaseJpaService<AssistanceApplyModel, AssistanceApplyDao> {
|
|
|
public class AssistanceApplyService extends BaseJpaService<AssistanceApplyModel, AssistanceApplyDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private AssistanceApplyDao assistanceApplyDao;
|
|
|
@Autowired
|
|
|
private OrgKeySchema orgKeySchema;
|
|
|
|
|
|
public AssistanceApplyModel findById(int id){
|
|
|
public AssistanceApplyModel findById(int id) {
|
|
|
return assistanceApplyDao.findOne(id);
|
|
|
}
|
|
|
|
|
|
public AssistanceApplyModel saveApply(AssistanceApplyModel assistanceApplyModel) throws ManageException {
|
|
|
if (assistanceApplyModel.getId() == null ){
|
|
|
assistanceApplyModel.setCreateTime(new Date());
|
|
|
//已申请
|
|
|
assistanceApplyModel.setSolutionStatus(0);
|
|
|
assistanceApplyModel.setIsRead(0);
|
|
|
}
|
|
|
assistanceApplyModel = assistanceApplyDao.save(assistanceApplyModel);
|
|
|
public AssistanceApplyModel addApply(AssistanceApplyModel assistanceApplyModel) throws ManageException {
|
|
|
assistanceApplyModel.setCreateTime(new Date());
|
|
|
assistanceApplyModel.setSolutionStatus(-1);
|
|
|
assistanceApplyModel.setIsRead(0);
|
|
|
assistanceApplyModel = assistanceApplyDao.save(assistanceApplyModel);
|
|
|
return assistanceApplyModel;
|
|
|
}
|
|
|
|
|
|
//申请
|
|
|
public AssistanceApplyModel saveOrUpdateApply(AssistanceApplyModel assistanceApplyModel) throws ManageException {
|
|
|
//申请机构名
|
|
|
String applyOrgName = getOrgName(assistanceApplyModel.getApplyOrg());
|
|
|
//处理机构名
|
|
|
String solutionOrgName = getOrgName(assistanceApplyModel.getSolutionOrg());
|
|
|
assistanceApplyModel.setCreateTime(new Date());
|
|
|
//已申请
|
|
|
assistanceApplyModel.setSolutionStatus(0);
|
|
|
assistanceApplyModel.setIsRead(0);
|
|
|
assistanceApplyModel.setApplyOrgName(applyOrgName);
|
|
|
assistanceApplyModel.setSolutionOrgName(solutionOrgName);
|
|
|
assistanceApplyModel = assistanceApplyDao.save(assistanceApplyModel);
|
|
|
return assistanceApplyModel;
|
|
|
}
|
|
|
|
|
|
|
|
|
public AssistanceApplyModel solutionApply(int id,String replyUserId,String replyContent) throws ManageException {
|
|
|
/**
|
|
|
* 申请处理
|
|
|
*
|
|
|
* @param id 申请记录ID
|
|
|
* @param replyUserId 处理人ID
|
|
|
* @param replyContent 回复内容
|
|
|
* @return
|
|
|
* @throws ManageException
|
|
|
*/
|
|
|
public AssistanceApplyModel solutionApply(int id, String replyUserId, String replyContent) throws ManageException {
|
|
|
AssistanceApplyModel applyModel = findById(id);
|
|
|
if (applyModel == null) {
|
|
|
throw new ManageException("申请记录不存在!");
|
|
@ -55,13 +82,14 @@ public class AssistanceApplyService extends BaseJpaService<AssistanceApplyModel
|
|
|
|
|
|
/**
|
|
|
* 根据申请状态-获取今日统计量
|
|
|
*
|
|
|
* @param status
|
|
|
* @return
|
|
|
*/
|
|
|
public long toDayCount(int status) {
|
|
|
String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
long todayCount = assistanceApplyDao.countAllBySolutionStatusAndCreateTimeBetween(status, start, end);
|
|
|
return todayCount;
|
|
|
}
|
|
@ -71,25 +99,27 @@ public class AssistanceApplyService extends BaseJpaService<AssistanceApplyModel
|
|
|
|
|
|
/**
|
|
|
* 通过申请机构 获取检验处理总数
|
|
|
* @param applyOrg 申请机构编码
|
|
|
* @param status 处理状态
|
|
|
*
|
|
|
* @param applyOrg 申请机构编码
|
|
|
* @param status 处理状态
|
|
|
* @return
|
|
|
*/
|
|
|
public long toDayIncreaseByApplyOrg(String applyOrg,int status){
|
|
|
public long toDayIncreaseByApplyOrg(String applyOrg, int status) {
|
|
|
long count = assistanceApplyDao.countAllByApplyOrgAndSolutionStatus(applyOrg, status);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过申请机构获取 今日已处理/未处理量
|
|
|
* @param solutionOrg 申请处理机构
|
|
|
*
|
|
|
* @param solutionOrg 申请处理机构
|
|
|
* @return
|
|
|
*/
|
|
|
public long toDayCountByApplyOrg(String solutionOrg,int status) {
|
|
|
public long toDayCountByApplyOrg(String solutionOrg, int status) {
|
|
|
String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
long todayCount = assistanceApplyDao.countAllByApplyOrgAndSolutionStatusAndCreateTimeBetween(solutionOrg,status, start, end);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
long todayCount = assistanceApplyDao.countAllByApplyOrgAndSolutionStatusAndCreateTimeBetween(solutionOrg, status, start, end);
|
|
|
return todayCount;
|
|
|
}
|
|
|
|
|
@ -98,39 +128,42 @@ public class AssistanceApplyService extends BaseJpaService<AssistanceApplyModel
|
|
|
|
|
|
/**
|
|
|
* 通过处理机构获取 今日新增申请量
|
|
|
* @param solutionOrg 申请处理机构
|
|
|
*
|
|
|
* @param solutionOrg 申请处理机构
|
|
|
* @return
|
|
|
*/
|
|
|
public long toDayIncreaseBySolutionOrg(String solutionOrg){
|
|
|
public long toDayIncreaseBySolutionOrg(String solutionOrg) {
|
|
|
String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
long count = assistanceApplyDao.countAllBySolutionOrgAndCreateTimeBetween(solutionOrg, start, end);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过处理机构获取 今日已处理/未处理量
|
|
|
* @param solutionOrg 申请处理机构
|
|
|
*
|
|
|
* @param solutionOrg 申请处理机构
|
|
|
* @return
|
|
|
*/
|
|
|
public long toDayCountBySolutionOrg(String solutionOrg,int status) {
|
|
|
public long toDayCountBySolutionOrg(String solutionOrg, int status) {
|
|
|
String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
long todayCount = assistanceApplyDao.countAllBySolutionOrgAndSolutionStatusAndCreateTimeBetween(solutionOrg,status, start, end);
|
|
|
Date start = DateUtil.parseDate(toDay + " 00:00:00", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
Date end = DateUtil.parseDate(toDay + " 23:59:59", DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
long todayCount = assistanceApplyDao.countAllBySolutionOrgAndSolutionStatusAndCreateTimeBetween(solutionOrg, status, start, end);
|
|
|
return todayCount;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 申请撤回
|
|
|
* @param id 申请记录id
|
|
|
* @param status 申请记录状态
|
|
|
*
|
|
|
* @param id 申请记录id
|
|
|
* @param status 申请记录状态
|
|
|
* @return
|
|
|
* @throws ManageException
|
|
|
*/
|
|
|
public AssistanceApplyModel retractApply(int id,int status) throws ManageException {
|
|
|
public AssistanceApplyModel retractApply(int id, int status) throws ManageException {
|
|
|
AssistanceApplyModel applyModel = findById(id);
|
|
|
if (applyModel == null) {
|
|
|
throw new ManageException("申请记录不存在!");
|
|
@ -141,4 +174,16 @@ public class AssistanceApplyService extends BaseJpaService<AssistanceApplyModel
|
|
|
return applyModel;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取机构名称redis
|
|
|
* @return
|
|
|
*/
|
|
|
public String getOrgName(String key) {
|
|
|
if (StringUtils.isEmpty(key)) {
|
|
|
return "";
|
|
|
}else {
|
|
|
return orgKeySchema.get(key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|