|
@@ -1,7 +1,10 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.management.platform.controller.WeiXinCorpController;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.vo.DepartmentVO;
|
|
import com.management.platform.entity.vo.DepartmentVO;
|
|
import com.management.platform.entity.vo.UserMonthWork;
|
|
import com.management.platform.entity.vo.UserMonthWork;
|
|
@@ -19,7 +22,10 @@ import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -51,6 +57,8 @@ import java.util.stream.Collectors;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
|
|
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
|
|
|
|
+// @Resource
|
|
|
|
+// AsyncTaskExecutor asyncTaskExecutor;//注入线程池对象
|
|
|
|
|
|
@Value("${wx.template_report_pass}")
|
|
@Value("${wx.template_report_pass}")
|
|
public String TEMPLATE_REPORT_PASS;
|
|
public String TEMPLATE_REPORT_PASS;
|
|
@@ -273,6 +281,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
list.add(report);
|
|
list.add(report);
|
|
total = total.add((BigDecimal) report.get("cost"));
|
|
total = total.add((BigDecimal) report.get("cost"));
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
map.put("data", list);
|
|
map.put("data", list);
|
|
map.put("cost", total);
|
|
map.put("cost", total);
|
|
@@ -310,6 +319,23 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //设置照片
|
|
|
|
+ for (Map map : nameList) {
|
|
|
|
+ List<Map<String, Object>> reportList = (List<Map<String, Object>>)map.get("data");
|
|
|
|
+ for (Map<String, Object> report : reportList) {
|
|
|
|
+ String picStr = (String)report.get("picStr");
|
|
|
|
+ if (picStr != null) {
|
|
|
|
+ JSONArray array = JSONArray.parseArray(picStr.replaceAll("@", ","));
|
|
|
|
+ List<String> picList = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
|
+ String string = array.getString(i);
|
|
|
|
+ string = "/upload/" + string + ".jpg";
|
|
|
|
+ picList.add(string);
|
|
|
|
+ }
|
|
|
|
+ report.put("pics", picList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
httpRespMsg.data = nameList;
|
|
httpRespMsg.data = nameList;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -365,6 +391,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
if (company.getPackageProject() == 1) {
|
|
if (company.getPackageProject() == 1) {
|
|
r.setStages(stagesMapper.getProjectStages(r.getProjectId()));
|
|
r.setStages(stagesMapper.getProjectStages(r.getProjectId()));
|
|
}
|
|
}
|
|
|
|
+ //处理图片
|
|
|
|
+ if (!StringUtils.isEmpty(r.getPicStr())) {
|
|
|
|
+ JSONArray array = JSONArray.parseArray(r.getPicStr().replaceAll("@", ","));
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
|
+ list.add("/upload/"+array.getString(i)+".jpg");
|
|
|
|
+ }
|
|
|
|
+ r.setPics(list);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
resultMap.put("report", reports);
|
|
resultMap.put("report", reports);
|
|
//顺便再获取一下可分配时间
|
|
//顺便再获取一下可分配时间
|
|
@@ -401,11 +436,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
//新增或编辑报告
|
|
//新增或编辑报告
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg editReport(List<Report> reportList, String date, List<User> userList, BigDecimal hourCost) {
|
|
|
|
|
|
+ public HttpRespMsg editReport(List<Report> reportList, String date, List<User> userList, BigDecimal hourCost, Integer companyId) {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
List<Integer> idList = new ArrayList<>();
|
|
List<Integer> idList = new ArrayList<>();
|
|
|
|
|
|
- Integer companyId = userMapper.selectById(reportList.get(0).getCreatorId()).getCompanyId();
|
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
double totalWorkTime = 0;
|
|
double totalWorkTime = 0;
|
|
for (Report report : reportList) {
|
|
for (Report report : reportList) {
|
|
@@ -496,9 +530,43 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //异步下载图片
|
|
|
|
+
|
|
|
|
+ loadPicFromCorpWXServer(companyId, reportList);
|
|
|
|
+
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private void loadPicFromCorpWXServer(Integer companyId, List<Report> reportList) {
|
|
|
|
+ List<Report> batchUpdateList = new ArrayList<>();
|
|
|
|
+ if (wxCorpInfoMapper.selectCount(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId)) > 0) {
|
|
|
|
+ WxCorpInfo corpInfo = wxCorpInfoMapper.selectList(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId)).get(0);
|
|
|
|
+ for (Report report : reportList) {
|
|
|
|
+ if (!StringUtils.isEmpty(report.getPicAdd()) && !report.getPicAdd().equals("@")) {
|
|
|
|
+ report.setPicStr(report.getPicStr());
|
|
|
|
+ Report item = new Report();
|
|
|
|
+ item.setId(report.getId());
|
|
|
|
+ item.setPicStr(report.getPicAdd());
|
|
|
|
+ batchUpdateList.add(item);
|
|
|
|
+
|
|
|
|
+ String s = item.getPicStr().replaceAll("@", ",");
|
|
|
|
+ JSONArray array = JSONArray.parseArray(s);
|
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
|
+ String string = array.getString(i);
|
|
|
|
+ wxCorpInfoService.downloadFile(corpInfo, string);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (batchUpdateList.size() > 0) {
|
|
|
|
+ updateBatchById(batchUpdateList);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
//删除报告
|
|
//删除报告
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg deleteReport(String userId, String date) {
|
|
public HttpRespMsg deleteReport(String userId, String date) {
|
|
@@ -598,6 +666,24 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
map2.put("state", list2.get(0).get("state"));
|
|
map2.put("state", list2.get(0).get("state"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //设置照片显示
|
|
|
|
+ for (Map map : nameList) {
|
|
|
|
+ List<Map<String, Object>> reportList = (List<Map<String, Object>>)map.get("data");
|
|
|
|
+ for (Map<String, Object> report : reportList) {
|
|
|
|
+ String picStr = (String)report.get("picStr");
|
|
|
|
+ if (picStr != null) {
|
|
|
|
+ JSONArray array = JSONArray.parseArray(picStr.replaceAll("@", ","));
|
|
|
|
+ List<String> picList = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
|
+ String string = array.getString(i);
|
|
|
|
+ string = "/upload/" + string + ".jpg";
|
|
|
|
+ picList.add(string);
|
|
|
|
+ }
|
|
|
|
+ report.put("pics", picList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
httpRespMsg.data = nameList;
|
|
httpRespMsg.data = nameList;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
httpRespMsg.setError("验证失败");
|
|
httpRespMsg.setError("验证失败");
|
|
@@ -1116,6 +1202,23 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
map2.put("state", list2.get(0).get("state"));
|
|
map2.put("state", list2.get(0).get("state"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //设置照片
|
|
|
|
+ for (Map map : nameList) {
|
|
|
|
+ List<Map<String, Object>> reportList = (List<Map<String, Object>>)map.get("data");
|
|
|
|
+ for (Map<String, Object> report : reportList) {
|
|
|
|
+ String picStr = (String)report.get("picStr");
|
|
|
|
+ if (picStr != null) {
|
|
|
|
+ JSONArray array = JSONArray.parseArray(picStr.replaceAll("@", ","));
|
|
|
|
+ List<String> picList = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
|
+ String string = array.getString(i);
|
|
|
|
+ string = "/upload/" + string + ".jpg";
|
|
|
|
+ picList.add(string);
|
|
|
|
+ }
|
|
|
|
+ report.put("pics", picList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
httpRespMsg.data = nameList;
|
|
httpRespMsg.data = nameList;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
httpRespMsg.setError("验证失败");
|
|
httpRespMsg.setError("验证失败");
|
|
@@ -1187,6 +1290,24 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
map2.put("state", list2.get(0).get("state"));
|
|
map2.put("state", list2.get(0).get("state"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //设置照片
|
|
|
|
+ for (Map map : nameList) {
|
|
|
|
+ List<Map<String, Object>> reportList = (List<Map<String, Object>>)map.get("data");
|
|
|
|
+ for (Map<String, Object> report : reportList) {
|
|
|
|
+ String picStr = (String)report.get("picStr");
|
|
|
|
+ if (picStr != null) {
|
|
|
|
+ JSONArray array = JSONArray.parseArray(picStr.replaceAll("@", ","));
|
|
|
|
+ List<String> picList = new ArrayList<>();
|
|
|
|
+ for (int i=0;i<array.size(); i++) {
|
|
|
|
+ String string = array.getString(i);
|
|
|
|
+ string = "/upload/" + string + ".jpg";
|
|
|
|
+ picList.add(string);
|
|
|
|
+ }
|
|
|
|
+ report.put("pics", picList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
httpRespMsg.data = nameList;
|
|
httpRespMsg.data = nameList;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
httpRespMsg.setError("验证失败");
|
|
httpRespMsg.setError("验证失败");
|
|
@@ -1326,7 +1447,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
dataList.add(dataItem);
|
|
dataList.add(dataItem);
|
|
}
|
|
}
|
|
//生成excel文件导出
|
|
//生成excel文件导出
|
|
- String fileName = "人员每日工时统计_"+month+"月"+System.currentTimeMillis();
|
|
|
|
|
|
+ String fileName = "人员每日工时统计_"+month.split("-")[1]+"月"+System.currentTimeMillis();
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
httpRespMsg.data = resp;
|
|
httpRespMsg.data = resp;
|