|
@ -22,6 +22,7 @@ import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.util.common.PwdUtil;
|
|
import com.yihu.jw.util.common.PwdUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
|
import com.yihu.jw.util.file.FileUtil;
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
|
|
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
|
|
import com.yihu.jw.utils.StringUtil;
|
|
import com.yihu.jw.utils.StringUtil;
|
|
@ -30,6 +31,7 @@ import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
|
|
import com.yihu.jw.wechat.enterprise.EnterpriseService;
|
|
import com.yihu.jw.wechat.enterprise.EnterpriseService;
|
|
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseUserDao;
|
|
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseUserDao;
|
|
import com.yihu.jw.wechat.service.WxAccessTokenService;
|
|
import com.yihu.jw.wechat.service.WxAccessTokenService;
|
|
|
|
import jxl.write.WritableWorkbook;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@ -44,9 +46,12 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.*;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by Bing on 2022/7/25.
|
|
* Created by Bing on 2022/7/25.
|
|
@ -1622,23 +1627,30 @@ public class DailyReportUploadService {
|
|
if (1==member_type){//指定成员
|
|
if (1==member_type){//指定成员
|
|
List<String> membersList = Arrays.asList(members.split(","));
|
|
List<String> membersList = Arrays.asList(members.split(","));
|
|
for (String tmp:membersList){
|
|
for (String tmp:membersList){
|
|
BaseDailyReportItemMembersDO membersDOTmp = new BaseDailyReportItemMembersDO();
|
|
|
|
membersDOTmp.setReportItemId(reportItemDO.getId());
|
|
|
|
membersDOTmp.setUserId(tmp);
|
|
|
|
membersDOTmp.setDel(1);
|
|
|
|
membersDOS.add(membersDOTmp);
|
|
|
|
|
|
BaseDoctorDO docMemberTmp = baseDoctorDao.findById(tmp);
|
|
|
|
if (null!=docMemberTmp){
|
|
|
|
BaseDailyReportItemMembersDO membersDOTmp = new BaseDailyReportItemMembersDO();
|
|
|
|
membersDOTmp.setReportItemId(reportItemDO.getId());
|
|
|
|
membersDOTmp.setUserId(tmp);
|
|
|
|
membersDOTmp.setUserName(docMemberTmp.getName());
|
|
|
|
membersDOTmp.setDel(1);
|
|
|
|
membersDOS.add(membersDOTmp);
|
|
|
|
}
|
|
}
|
|
}
|
|
}else if (2==member_type){
|
|
}else if (2==member_type){
|
|
List<String> depts = Arrays.asList(members.split(","));
|
|
List<String> depts = Arrays.asList(members.split(","));
|
|
for (String dept:depts){
|
|
for (String dept:depts){
|
|
sql = " select distinct doc.id from base_doctor doc inner join base_doctor_hospital dh " +
|
|
|
|
|
|
sql = " select distinct doc.id,doc.name from base_doctor doc inner join base_doctor_hospital dh " +
|
|
"on doc.id = dh.doctor_code and doc.del=1 and dh.del=1 " +
|
|
"on doc.id = dh.doctor_code and doc.del=1 and dh.del=1 " +
|
|
"where dh.dept_code='"+dept+"' ";
|
|
"where dh.dept_code='"+dept+"' ";
|
|
List<String> membersList = jdbcTemplate.queryForList(sql,String.class);
|
|
|
|
for (String tmp:membersList){
|
|
|
|
|
|
List<Map<String,Object>> membersList = jdbcTemplate.queryForList(sql);
|
|
|
|
for (Map<String,Object> tmp:membersList){
|
|
|
|
String docTmp = tmp.get("id").toString();
|
|
|
|
String docNameTmp = tmp.get("name").toString();
|
|
BaseDailyReportItemMembersDO membersDOTmp = new BaseDailyReportItemMembersDO();
|
|
BaseDailyReportItemMembersDO membersDOTmp = new BaseDailyReportItemMembersDO();
|
|
membersDOTmp.setReportItemId(reportItemDO.getId());
|
|
membersDOTmp.setReportItemId(reportItemDO.getId());
|
|
membersDOTmp.setUserId(tmp);
|
|
|
|
|
|
membersDOTmp.setUserId(docTmp);
|
|
|
|
membersDOTmp.setUserName(docNameTmp);
|
|
membersDOTmp.setDel(1);
|
|
membersDOTmp.setDel(1);
|
|
membersDOS.add(membersDOTmp);
|
|
membersDOS.add(membersDOTmp);
|
|
}
|
|
}
|
|
@ -1723,6 +1735,9 @@ public class DailyReportUploadService {
|
|
reportItemDO.setState(1);
|
|
reportItemDO.setState(1);
|
|
if (StringUtils.isNoneBlank(completionUser)){
|
|
if (StringUtils.isNoneBlank(completionUser)){
|
|
reportItemDO.setCompletionUser(completionUser);
|
|
reportItemDO.setCompletionUser(completionUser);
|
|
|
|
}else {
|
|
|
|
reportItemDO.setCompletionUser(user);
|
|
|
|
reportItemDO.setCompletionUserName(doctorDO.getName());
|
|
}
|
|
}
|
|
if (StringUtils.isNoneBlank(completionHour)){
|
|
if (StringUtils.isNoneBlank(completionHour)){
|
|
reportItemDO.setCompletionHour(completionHour);
|
|
reportItemDO.setCompletionHour(completionHour);
|
|
@ -1795,7 +1810,7 @@ public class DailyReportUploadService {
|
|
throw new Exception("您无权限操作");
|
|
throw new Exception("您无权限操作");
|
|
}
|
|
}
|
|
List<BaseDailyReportItemDO> itemDOS = new ArrayList<>();
|
|
List<BaseDailyReportItemDO> itemDOS = new ArrayList<>();
|
|
sql = " select i.* from base_daily_report_item i where 1=1 ";
|
|
|
|
|
|
sql = " select i.* from base_daily_report_item i where 1=1 and i.del=1 ";
|
|
if (StringUtils.isNotBlank(title)){
|
|
if (StringUtils.isNotBlank(title)){
|
|
sql +=" and i.title like '%"+title+"%' ";
|
|
sql +=" and i.title like '%"+title+"%' ";
|
|
}
|
|
}
|
|
@ -2005,6 +2020,138 @@ public class DailyReportUploadService {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出项目计划周报月报用时情况
|
|
|
|
* @param user
|
|
|
|
* @param type 1周报2月报
|
|
|
|
* @param date
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<Map<String,Object>> getProjectItemReport(HttpServletResponse response, String user, Integer type, String date) throws Exception {
|
|
|
|
//判断导出人权限
|
|
|
|
String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
|
|
|
|
List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
|
|
|
|
boolean adminFlag = false;//true 为总管理员 false为部门管理员
|
|
|
|
String startTime = "";
|
|
|
|
String endTime = "";
|
|
|
|
if (userRoles.size()==0){
|
|
|
|
throw new Exception("您无权限操作");
|
|
|
|
}else {
|
|
|
|
String role_code = userRoles.get(0).get("role_code").toString();
|
|
|
|
if ("admin".equals(role_code)){
|
|
|
|
adminFlag = true;
|
|
|
|
} else if ("deptAdmin".equals(role_code)) {
|
|
|
|
adminFlag = false;
|
|
|
|
}else {
|
|
|
|
throw new Exception("您无权限操作");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(1==type){
|
|
|
|
//获取日期对应月、周范围
|
|
|
|
startTime = DateUtil.getFristDayOfMonthThisDate(new Date())+" 00:00:00";
|
|
|
|
endTime = DateUtil.getLastDayOfMonthThisDate(new Date())+" 23:59:59";
|
|
|
|
}else if (2==type){
|
|
|
|
startTime = DateUtil.getMondayOfThisWeek(DateUtil.strToDate(date))+" 00:00:00";
|
|
|
|
endTime = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(date))+" 23:59:59";
|
|
|
|
}else {
|
|
|
|
throw new Exception("导出失败,请检查传入参数");
|
|
|
|
}
|
|
|
|
sql = " select it.title,it.content,sum(IFNULL(pd.actual_completion_hour,IFNULL(pd.completion_hour,0))),it.state " +
|
|
|
|
"from base_daily_report_item it LEFT JOIN base_daily_report_detail pd " +
|
|
|
|
"on it.id = pd.report_item_id " +
|
|
|
|
"where it.del=1 and it.state>=0 and pd.create_time>='"+startTime+"' and pd.create_time<='"+endTime+"' " +
|
|
|
|
"and (it.completion_time is null or it.completion_time>='"+startTime+"') " +
|
|
|
|
"GROUP BY it.id ORDER BY it.create_time desc ";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
projectItemReportToOutStream(response,list,DateUtil.dateToStrShort(DateUtil.strToDate(startTime)),DateUtil.dateToStrShort(DateUtil.strToDate(endTime)));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出员工周报月报提交情况
|
|
|
|
* @param user
|
|
|
|
* @param type 1周报2月报
|
|
|
|
* @param date
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<Map<String,Object>> getUserReportList(HttpServletResponse response,String user,Integer type,String date) throws Exception {
|
|
|
|
//判断导出人权限
|
|
|
|
String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
|
|
|
|
List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
|
|
|
|
boolean adminFlag = false;//true 为总管理员 false为部门管理员
|
|
|
|
if (userRoles.size()==0){
|
|
|
|
throw new Exception("您无权限操作");
|
|
|
|
}else {
|
|
|
|
String role_code = userRoles.get(0).get("role_code").toString();
|
|
|
|
if ("admin".equals(role_code)){
|
|
|
|
adminFlag = true;
|
|
|
|
} else if ("deptAdmin".equals(role_code)) {
|
|
|
|
adminFlag = false;
|
|
|
|
}else {
|
|
|
|
throw new Exception("您无权限操作");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(1==type){
|
|
|
|
|
|
|
|
}else if (2==type){
|
|
|
|
|
|
|
|
}else {
|
|
|
|
throw new Exception("导出失败,请检查传入参数");
|
|
|
|
}
|
|
|
|
//获取日期对应月、周范围
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void projectItemReportToOutStream(HttpServletResponse response,List<Map<String,Object>> list,String startDate,String endDate) throws Exception {
|
|
|
|
Map<String,List<Map<String,Object>>> projectMap = list.stream().collect(Collectors.groupingBy(e -> e.get("title").toString()));
|
|
|
|
String zipFileName = "项目周(月)报完成情况"+startDate+"-"+endDate;
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
String exportConclusionList = time+"exportList";
|
|
|
|
String path = this.getClass().getResource("/").getPath() + exportConclusionList;
|
|
|
|
File file = new File(path);
|
|
|
|
// 删除文件夹、文件
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
|
|
|
System.out.println("创建文件夹时间:"+sdf.format(new Date()));
|
|
|
|
if (file.exists()) {
|
|
|
|
if (file != null){
|
|
|
|
deleteFolder(file);
|
|
|
|
file.mkdir();
|
|
|
|
}else {
|
|
|
|
file.delete();
|
|
|
|
file.mkdir();
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
file.mkdir();
|
|
|
|
}
|
|
|
|
// 打包文件夹
|
|
|
|
if (FileUtil.fileToZip(path, path.replace(exportConclusionList, ""), zipFileName)) {
|
|
|
|
new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
|
|
|
|
} else {
|
|
|
|
file = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file != null) {
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
response.setContentType("multipart/form-data");
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=项目日(月)报完成情况.zip");
|
|
|
|
|
|
|
|
InputStream inputStream = new FileInputStream(file);
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
byte[] b = new byte[2048];
|
|
|
|
int length = 0;
|
|
|
|
while ((length = inputStream.read(b)) > 0) {
|
|
|
|
outputStream.write(b, 0, length);
|
|
|
|
}
|
|
|
|
outputStream.flush();
|
|
|
|
outputStream.close();
|
|
|
|
inputStream.close();
|
|
|
|
} else {
|
|
|
|
response.setStatus(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getRangeDouble(Double first, Double second) {
|
|
public double getRangeDouble(Double first, Double second) {
|
|
if (second == 0 && first > 0) {
|
|
if (second == 0 && first > 0) {
|
|
//如果分母为0 分子不为0 返回100%
|
|
//如果分母为0 分子不为0 返回100%
|
|
@ -2018,4 +2165,18 @@ public class DailyReportUploadService {
|
|
String filesize = df.format(result);
|
|
String filesize = df.format(result);
|
|
return Double.parseDouble(filesize);
|
|
return Double.parseDouble(filesize);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void deleteFolder(File folder){
|
|
|
|
File[] files = folder.listFiles();
|
|
|
|
if (files != null){
|
|
|
|
for(File f: files){
|
|
|
|
if (f.isDirectory()){
|
|
|
|
deleteFolder(f);
|
|
|
|
}else {
|
|
|
|
f.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
folder.delete();
|
|
|
|
}
|
|
}
|
|
}
|