|
@@ -2,6 +2,7 @@ package com.management.platform.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@@ -117,6 +118,14 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
|
} else if (auditSetting.getAuditType() == 1) {
|
|
|
//项目经理审核,默认为待审核状态
|
|
|
sheet.setStatus(1);
|
|
|
+ }else if(auditSetting.getAuditType()==2){
|
|
|
+ if(sheet.getFirstCheckerId().equals(user.getId())){
|
|
|
+ sheet.setReviewProcess(1);
|
|
|
+ sheet.setStatus(1);
|
|
|
+ }else if(sheet.getFirstCheckerId().equals(user.getId())&&sheet.getSecondCheckerId().equals(user.getId())){
|
|
|
+ sheet.setReviewProcess(2);
|
|
|
+ sheet.setStatus(0);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -290,55 +299,107 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
|
//发送给项目经理审核
|
|
|
List<Integer> collect = itemList.stream().map(ExpenseItem::getProjectId).collect(Collectors.toList());
|
|
|
if (collect.size() > 0) {
|
|
|
- List<String> inchargerIds = projectMapper.selectList(new QueryWrapper<Project>().select("incharger_id").in("id", collect)).stream().map(Project::getInchargerId).distinct().collect(Collectors.toList());
|
|
|
- List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("id", inchargerIds));
|
|
|
- WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
- if (wxCorpInfo != null) {
|
|
|
- String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
- User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
- ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
- //推送到企业微信
|
|
|
- JSONObject json=new JSONObject();
|
|
|
- JSONArray dataJson=new JSONArray();
|
|
|
- JSONObject jsonObj=new JSONObject();
|
|
|
- jsonObj.put("key", "报销人");
|
|
|
- jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
- JSONObject jsonObj1=new JSONObject();
|
|
|
- jsonObj1.put("key", "填报日期");
|
|
|
- jsonObj1.put("value",sheet.getCreateDate());
|
|
|
- JSONObject jsonObj2=new JSONObject();
|
|
|
- jsonObj2.put("key", "票据类型");
|
|
|
- jsonObj2.put("value",mainType.getName());
|
|
|
- JSONObject jsonObj3=new JSONObject();
|
|
|
- jsonObj3.put("key", "金额");
|
|
|
- jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
- JSONObject jsonObj4=new JSONObject();
|
|
|
- jsonObj4.put("key", "备注");
|
|
|
- jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
- dataJson.add(jsonObj);
|
|
|
- dataJson.add(jsonObj1);
|
|
|
- dataJson.add(jsonObj2);
|
|
|
- dataJson.add(jsonObj3);
|
|
|
- dataJson.add(jsonObj4);
|
|
|
- json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
- json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
- json.put("content_item",dataJson);
|
|
|
- wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
- }
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().select("incharger_id").isNotNull("incharger_id").in("id", collect));
|
|
|
+ if(projectList.size()>0){
|
|
|
+ List<String> inchargerIds = projectList.stream().map(Project::getInchargerId).distinct().collect(Collectors.toList());
|
|
|
+ List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("id", inchargerIds));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
+ String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
+ User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
+ ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
+ //推送到企业微信
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
+ jsonObj.put("key", "报销人");
|
|
|
+ jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
+ jsonObj1.put("key", "填报日期");
|
|
|
+ jsonObj1.put("value",sheet.getCreateDate());
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
+ jsonObj2.put("key", "票据类型");
|
|
|
+ jsonObj2.put("value",mainType.getName());
|
|
|
+ JSONObject jsonObj3=new JSONObject();
|
|
|
+ jsonObj3.put("key", "金额");
|
|
|
+ jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
+ jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
+ dataJson.add(jsonObj);
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
+ dataJson.add(jsonObj3);
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
+ json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
+ json.put("content_item",dataJson);
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
+ }
|
|
|
|
|
|
- List<Information> informationList=new ArrayList<>();
|
|
|
- for (User item : targetUserList) {
|
|
|
- Information information=new Information();
|
|
|
- information.setUserId(item.getId());
|
|
|
- information.setTime(LocalDateTime.now());
|
|
|
- information.setMsg("费用报销待审核");
|
|
|
- information.setType(3);
|
|
|
- information.setContent(sheet.getCreateDate()+"");
|
|
|
- informationList.add(information);
|
|
|
+ List<Information> informationList=new ArrayList<>();
|
|
|
+ for (User item : targetUserList) {
|
|
|
+ Information information=new Information();
|
|
|
+ information.setUserId(item.getId());
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
+ information.setMsg("费用报销待审核");
|
|
|
+ information.setType(3);
|
|
|
+ information.setContent(sheet.getCreateDate()+"");
|
|
|
+ informationList.add(information);
|
|
|
+ }
|
|
|
+ informationService.saveBatch(informationList);
|
|
|
}
|
|
|
- informationService.saveBatch(informationList);
|
|
|
+ }
|
|
|
+ }else if (isNew && auditSetting != null && auditSetting.getAuditType() == 2) {
|
|
|
+ //发送给第一审核人审核
|
|
|
+ List<User> targetUserList = new ArrayList<>();
|
|
|
+ User firstChecker = userMapper.selectById(sheet.getFirstCheckerId());
|
|
|
+ targetUserList.add(firstChecker);
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
+ String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
+ User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
+ ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
+ //推送到企业微信
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
+ jsonObj.put("key", "报销人");
|
|
|
+ jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
+ jsonObj1.put("key", "填报日期");
|
|
|
+ jsonObj1.put("value",sheet.getCreateDate());
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
+ jsonObj2.put("key", "票据类型");
|
|
|
+ jsonObj2.put("value",mainType.getName());
|
|
|
+ JSONObject jsonObj3=new JSONObject();
|
|
|
+ jsonObj3.put("key", "金额");
|
|
|
+ jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
+ jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
+ dataJson.add(jsonObj);
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
+ dataJson.add(jsonObj3);
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
+ json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
+ json.put("content_item",dataJson);
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
}
|
|
|
|
|
|
+ List<Information> informationList=new ArrayList<>();
|
|
|
+ for (User item : targetUserList) {
|
|
|
+ Information information=new Information();
|
|
|
+ information.setUserId(item.getId());
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
+ information.setMsg("费用报销待审核");
|
|
|
+ information.setType(3);
|
|
|
+ information.setContent(sheet.getCreateDate()+"");
|
|
|
+ informationList.add(information);
|
|
|
+ }
|
|
|
+ informationService.saveBatch(informationList);
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
@@ -373,7 +434,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
|
if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else if(expenseAuditSetting.getAuditType() == 1){
|
|
|
//增加按项目经理审核模式下,项目经理可以查看相关费用报销单的条件
|
|
|
if (sheet.getStatus() != null) {
|
|
|
//取待审核的
|
|
@@ -398,6 +459,19 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
|
queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
}
|
|
|
}
|
|
|
+ }else if(expenseAuditSetting.getAuditType() == 2){
|
|
|
+ if (sheet.getStatus() != null) {
|
|
|
+ //增加多层审核人审核模式 过滤第一或者第二审核人为当前用户的数据
|
|
|
+ queryWrapper.and(wrapper->wrapper.and(wr->wr.eq("first_checker_id",token).eq("review_process",0)).or(wr->wr.eq("second_checker_id",token).eq("review_process",1)));
|
|
|
+ if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
+ queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //按人员过滤
|
|
|
+ if (!StringUtils.isEmpty(sheet.getOwnerId())) {
|
|
|
+ queryWrapper.eq("owner_id", sheet.getOwnerId());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isEmpty(sheet.getType())) {
|
|
@@ -485,9 +559,69 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
|
|
|
public HttpRespMsg approve(Integer id) {
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
- ExpenseSheet sheet = new ExpenseSheet();
|
|
|
- sheet.setId(id);
|
|
|
- sheet.setStatus(0);
|
|
|
+ ExpenseSheet sheet = expenseSheetMapper.selectById(id);
|
|
|
+ ExpenseAuditSetting expenseAuditSetting = expenseAuditSettingMapper.selectById(user.getCompanyId());
|
|
|
+ if(expenseAuditSetting!=null&&expenseAuditSetting.getAuditType()==2){
|
|
|
+ if(sheet.getReviewProcess()!=null&&sheet.getReviewProcess()==0){
|
|
|
+ sheet.setReviewProcess(1);
|
|
|
+ sheet.setStatus(1);
|
|
|
+ //发送审核消息给第二审核人
|
|
|
+ List<User> targetUserList = new ArrayList<>();
|
|
|
+ User secondChecker = userMapper.selectById(sheet.getSecondCheckerId());
|
|
|
+ targetUserList.add(secondChecker);
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
+ String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
|
|
|
+ User targetUser = userMapper.selectById(sheet.getOwnerId());
|
|
|
+ ExpenseMainType mainType = expenseMainTypeService.getById(sheet.getType());
|
|
|
+ //推送到企业微信
|
|
|
+ JSONObject json=new JSONObject();
|
|
|
+ JSONArray dataJson=new JSONArray();
|
|
|
+ JSONObject jsonObj=new JSONObject();
|
|
|
+ jsonObj.put("key", "报销人");
|
|
|
+ jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
|
|
|
+ JSONObject jsonObj1=new JSONObject();
|
|
|
+ jsonObj1.put("key", "填报日期");
|
|
|
+ jsonObj1.put("value",sheet.getCreateDate());
|
|
|
+ JSONObject jsonObj2=new JSONObject();
|
|
|
+ jsonObj2.put("key", "票据类型");
|
|
|
+ jsonObj2.put("value",mainType.getName());
|
|
|
+ JSONObject jsonObj3=new JSONObject();
|
|
|
+ jsonObj3.put("key", "金额");
|
|
|
+ jsonObj3.put("value",sheet.getTotalAmount());
|
|
|
+ JSONObject jsonObj4=new JSONObject();
|
|
|
+ jsonObj4.put("key", "备注");
|
|
|
+ jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
|
|
|
+ dataJson.add(jsonObj);
|
|
|
+ dataJson.add(jsonObj1);
|
|
|
+ dataJson.add(jsonObj2);
|
|
|
+ dataJson.add(jsonObj3);
|
|
|
+ dataJson.add(jsonObj4);
|
|
|
+ json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
|
|
|
+ json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
|
|
|
+ json.put("content_item",dataJson);
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,corpUserString, json);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Information> informationList=new ArrayList<>();
|
|
|
+ for (User item : targetUserList) {
|
|
|
+ Information information=new Information();
|
|
|
+ information.setUserId(item.getId());
|
|
|
+ information.setTime(LocalDateTime.now());
|
|
|
+ information.setMsg("费用报销待审核");
|
|
|
+ information.setType(3);
|
|
|
+ information.setContent(sheet.getCreateDate()+"");
|
|
|
+ informationList.add(information);
|
|
|
+ }
|
|
|
+ informationService.saveBatch(informationList);
|
|
|
+ }else if(sheet.getReviewProcess()!=null&&sheet.getReviewProcess()==1){
|
|
|
+ sheet.setReviewProcess(2);
|
|
|
+ sheet.setStatus(0);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ sheet.setStatus(0);
|
|
|
+ }
|
|
|
+
|
|
|
expenseSheetMapper.updateById(sheet);
|
|
|
|
|
|
sheet = expenseSheetMapper.selectById(id);
|