|
@@ -34,6 +34,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
+import java.text.NumberFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -3025,6 +3026,61 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request) {
|
|
|
+ //1.获取分页结果
|
|
|
+ Integer size=pageSize;//查询条数
|
|
|
+ Integer start =(pageIndex-1)*size;//limit开始
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size);
|
|
|
+ long total=projectMapper.findCountWithUser(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
|
|
|
+ list.forEach(li->{
|
|
|
+ double isPublic = (double) li.get("isPublic");
|
|
|
+ double workingTime = (double) li.get("workingTime");
|
|
|
+ BigDecimal bdIsPublic=new BigDecimal(isPublic);
|
|
|
+ BigDecimal divide = bdIsPublic.divide(BigDecimal.valueOf(workingTime),2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ NumberFormat nf = NumberFormat.getPercentInstance();
|
|
|
+ li.put("proportion",nf.format(divide));
|
|
|
+ });
|
|
|
+ HashMap map=new HashMap();
|
|
|
+ map.put("total",total);
|
|
|
+ map.put("result",list);
|
|
|
+ msg.data = map;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate,HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
|
|
|
+ String[] string={"人员","普通项目工时","公共项目工时","总工时","公共项目工时占比"};
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ dataList.add(Arrays.asList(string));
|
|
|
+ for(Map<String,Object> item:list){
|
|
|
+ List<String> subList=new ArrayList<>();
|
|
|
+ double isPublic = (double) item.get("isPublic");
|
|
|
+ double workingTime = (double) item.get("workingTime");
|
|
|
+ BigDecimal bdIsPublic=new BigDecimal(isPublic);
|
|
|
+ BigDecimal divide = bdIsPublic.divide(BigDecimal.valueOf(workingTime),2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ NumberFormat nf = NumberFormat.getPercentInstance();
|
|
|
+ subList.add(String.valueOf(item.get("username")));
|
|
|
+ subList.add(String.valueOf(item.get("unPublic")));
|
|
|
+ subList.add(String.valueOf(item.get("isPublic")));
|
|
|
+ subList.add(String.valueOf(item.get("workingTime")));
|
|
|
+ subList.add(String.valueOf(nf.format(divide)));
|
|
|
+ dataList.add(subList);
|
|
|
+ }
|
|
|
+ //生成excel文件导出
|
|
|
+ String fileName = "人员工时分配统计_"+System.currentTimeMillis();
|
|
|
+ String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
|
|
|
+ msg.data = resp;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;
|