|
@@ -907,71 +907,6 @@ public class ReportController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* if(company.getId()==862){
|
|
|
- Collection<Integer> projectIds = reportList.stream().map(Report::getProjectId).distinct().collect(Collectors.toList());
|
|
|
- List<Project> targetProjectList = projectList.stream().filter(pl -> projectIds.contains(pl.getId())).collect(Collectors.toList());
|
|
|
- String creatorId = reportList.get(0).getCreatorId();
|
|
|
- User reportUser = userMapper.selectById(creatorId);
|
|
|
- DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
|
|
|
- LocalDateTime time = LocalDateTime.now();
|
|
|
- String format = time.format(df);
|
|
|
- String tokenOfYiWei = getTokenOfYiWei();
|
|
|
- String url = "http://183.194.0.98:3202/api/web-server/controlCenter/billApply";
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- headers.add("token",tokenOfYiWei);
|
|
|
- headers.add("Accept-Language","zh-CN");
|
|
|
- JSONObject body=new JSONObject();
|
|
|
- body.put("dataSource","工时管家");
|
|
|
- body.put("type","EXPENSE");
|
|
|
- body.put("applicant",reportUser.getName());
|
|
|
- body.put("applyTime",format);
|
|
|
- body.put("billNo","GS"+ reportUser.getId()+reportList.get(0).getCreateDate());
|
|
|
- JSONArray expenseDetails=new JSONArray();
|
|
|
- for (Report report : reportList) {
|
|
|
- Optional<Project> first = targetProjectList.stream().filter(tl -> tl.getId().equals(report.getProjectId())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- JSONObject expenseDetail =new JSONObject();
|
|
|
- expenseDetail.put("company","FONE");
|
|
|
- expenseDetail.put("department","DEFAULT");
|
|
|
- expenseDetail.put("project",first.get().getProjectCode());
|
|
|
- expenseDetail.put("expenseItem","DEFAULT");
|
|
|
- expenseDetail.put("amount",report.getWorkingTime());
|
|
|
- expenseDetails.add(expenseDetail);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- body.put("expenseDetails",expenseDetails);
|
|
|
- HttpEntity<String> requestEntity = new HttpEntity<String>(body.toJSONString(), headers);
|
|
|
- ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
|
|
|
- HttpMethod.POST, requestEntity, String.class);
|
|
|
- if (responseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
- String resp = responseEntity.getBody();
|
|
|
- JSONObject json = JSONObject.parseObject(resp);
|
|
|
- if(json.getIntValue("status")==0){
|
|
|
- JSONArray data = json.getJSONArray("data");
|
|
|
- JSONObject jsonObject = data.getJSONObject(0);
|
|
|
- Integer availableBudgetAmount = jsonObject.getInteger("availableBudgetAmount");
|
|
|
- Integer occurredBudgetAmount = jsonObject.getInteger("occurredBudgetAmount");
|
|
|
- BigDecimal divide = new BigDecimal(occurredBudgetAmount).add(new BigDecimal(jsonObject.getInteger("amount"))).divide(new BigDecimal(availableBudgetAmount), 3, RoundingMode.HALF_UP);
|
|
|
- if(divide.doubleValue()>0.85){
|
|
|
- HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
- httpRespMsg.setError("当前预算占用已到85%");
|
|
|
- }
|
|
|
- } else if(json.getIntValue("status")==14001){
|
|
|
- HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
- httpRespMsg.setError("当前项目预算不足,无法填报");
|
|
|
- return httpRespMsg;
|
|
|
- }else if(json.getIntValue("status")==14002){
|
|
|
- HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
- httpRespMsg.setError("未找到预算控制单元:"+json.getString("message"));
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//如果锁定工作时长上限的话,需要校验每日的合计工作时长
|
|
|
if (comTimeType.getLockWorktime() == 1) {
|
|
|
for (Report report : reportList) {
|
|
@@ -1067,22 +1002,46 @@ public class ReportController {
|
|
|
|
|
|
if(comTimeType.getReportAuditType()==5){
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
|
|
|
+ List<User> tempAuditorUserList = new ArrayList<>();
|
|
|
+ List<String> creatorIdList = reportList.stream().map(Report::getCreatorId).collect(Collectors.toList());
|
|
|
+ List<User> creatorList = userMapper.selectList(new QueryWrapper<User>().in("id", creatorIdList));
|
|
|
+ //查询creatorList的直属审核人
|
|
|
+ for (User creator : creatorList) {
|
|
|
+ if (!StringUtils.isEmpty(creator.getSuperiorId())) {
|
|
|
+ User superior = userMapper.selectById(creator.getSuperiorId());
|
|
|
+ if (!tempAuditorUserList.stream().anyMatch(item -> item.getId().equals(superior.getId()))) {
|
|
|
+ tempAuditorUserList.add(superior);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
for (Report report : reportList) {
|
|
|
report.setDepartmentAuditState(0);
|
|
|
- Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(report.getDeptId())).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- if(StringUtils.isEmpty(first.get().getManagerId())){
|
|
|
- HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
- httpRespMsg.setError("当前所在部门["+first.get().getDepartmentName()+"]不存在负责人,请联系管理员设置");
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
- report.setAuditDeptid(first.get().getDepartmentId());
|
|
|
- report.setProjectAuditorId(null);
|
|
|
+ //优先按照当前日报填写人的直属审核人审核
|
|
|
+ User reportOwner = creatorList.stream().filter(c->c.getId().equals(report.getCreatorId())).findFirst().get();
|
|
|
+ if (!StringUtils.isEmpty(reportOwner.getSuperiorId())) {
|
|
|
+ User auditor = tempAuditorUserList.stream().filter(t -> t.getId().equals(reportOwner.getSuperiorId())).findFirst().get();
|
|
|
+ report.setProjectAuditorId(auditor.getId());
|
|
|
+ report.setProjectAuditorName(auditor.getName());
|
|
|
report.setProjectAuditState(0);
|
|
|
- report.setAuditDeptManagerid(first.get().getManagerId());
|
|
|
- report.setIsDeptAudit(1);
|
|
|
- if(report.getCreatorId().equals(first.get().getManagerId())){
|
|
|
- report.setState(0);
|
|
|
+ if (report.getCreatorId().equals(auditor.getId())) {
|
|
|
+ report.setState(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(report.getDeptId())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ if(StringUtils.isEmpty(first.get().getManagerId())){
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
+ httpRespMsg.setError("当前所在部门["+first.get().getDepartmentName()+"]不存在负责人,请联系管理员设置");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ report.setAuditDeptid(first.get().getDepartmentId());
|
|
|
+ report.setProjectAuditorId(null);
|
|
|
+ report.setProjectAuditState(0);
|
|
|
+ report.setAuditDeptManagerid(first.get().getManagerId());
|
|
|
+ report.setIsDeptAudit(1);
|
|
|
+ if(report.getCreatorId().equals(first.get().getManagerId())){
|
|
|
+ report.setState(1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|