|
@@ -972,69 +972,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 totalBudgetAmount = jsonObject.getInteger("totalBudgetAmount");
|
|
|
- Integer occurredBudgetAmount = jsonObject.getInteger("occurredBudgetAmount");
|
|
|
- BigDecimal divide = (new BigDecimal(occurredBudgetAmount).add(new BigDecimal(jsonObject.getInteger("amount")))).divide(new BigDecimal(totalBudgetAmount), 3, RoundingMode.HALF_UP);
|
|
|
- if(divide.doubleValue()>0.85){
|
|
|
- HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
- httpRespMsg.setMsg("当前预算占用已到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) {
|
|
@@ -1358,29 +1295,6 @@ public class ReportController {
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private String getTokenOfYiWei(){
|
|
|
- String url = "http://183.194.0.98:3202/api/web-server/controlCenter/token";
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- String token="";
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- JSONObject jsonObject=new JSONObject();
|
|
|
- jsonObject.put("appId","GongShi");
|
|
|
- jsonObject.put("appSecret","858a6e0b60d228a556d8e353ebbd2c5c");
|
|
|
- HttpEntity<String> requestEntity;
|
|
|
- requestEntity = new HttpEntity<String>(jsonObject.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){
|
|
|
- token= json.getString("data");
|
|
|
- }
|
|
|
- }
|
|
|
- return token;
|
|
|
- }
|
|
|
-
|
|
|
private void fillReportHours(Report report, BigDecimal hourCost, Double workingTime, Integer timeType, String startTime, String endTime, SimpleDateFormat sdf, TimeType comTimeType, List<TimeAutoExclude> excludeTimeList) {
|
|
|
if (report.getMultiWorktime() == 0) {
|
|
|
//普通工时成本计算
|