Lijy vor 2 Monaten
Ursprung
Commit
a2f15d4b7a

+ 108 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -18,6 +18,7 @@ import com.management.platform.service.*;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.CellType;
@@ -54,6 +55,7 @@ import java.util.stream.Collectors;
  */
 @Service
 @Transactional
+@Slf4j
 public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, ExpenseSheet> implements ExpenseSheetService {
     @Value(value = "${upload.path}")
     private String path;
@@ -325,12 +327,14 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
             if (auditSetting==null||auditSetting.getAuditType() == null || auditSetting.getAuditType() == 0) {
                 expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
                 expenseItemService.saveBatch(itemList);
-            } else {
+            }
+            else {
                 if (isAuditor) {
                     //有审核权限的人修改,直接修改
                     expenseItemService.remove(new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId()));
                     expenseItemService.saveBatch(itemList);
-                } else {
+                }
+                else {
                     //已通过不能删除
                     QueryWrapper<ExpenseItem> queryWrapper = new QueryWrapper<ExpenseItem>().eq("expense_id", sheet.getId());
                     queryWrapper.eq("status", 0);
@@ -459,6 +463,108 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
             }
             informationService.saveBatch(informationList);
         }
+        //柘中下发报销单 给报销人发送信息提醒
+        else if (isNew && auditSetting != null && auditSetting.getAuditType() == 2&&org.apache.commons.lang3.StringUtils.isEmpty(sheet.getFirstCheckerId())) {
+            //给报销人发送信息提醒
+            log.info("柘中给报销人下发报销单");
+            List<User> targetUserList = new ArrayList<>();
+            User owner = userMapper.selectById(sheet.getOwnerId());
+            targetUserList.add(owner);
+            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("|"));
+                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="+owner.getCorpwxUserid()+"$"));
+                JSONObject jsonObj1=new JSONObject();
+                jsonObj1.put("key", "填报日期");
+                jsonObj1.put("value",sheet.getCreateDate()==null?"":sheet.getCreateDate());
+                JSONObject jsonObj2=new JSONObject();
+                jsonObj2.put("key", "票据类型");
+                jsonObj2.put("value",mainType.getName());
+                JSONObject jsonObj3=new JSONObject();
+                jsonObj2.put("key", "提示");
+                jsonObj2.put("value","请及时填写报销单信息");
+                dataJson.add(jsonObj);
+                dataJson.add(jsonObj1);
+                dataJson.add(jsonObj2);
+                dataJson.add(jsonObj3);
+                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);
+
+        }
+        //柘中报销人填写报销单信息,完善填报金额,第一审核人,第二审核人信息,给第一审核人发送信息
+        if (!isNew&& auditSetting != null && auditSetting.getAuditType() == 2&&sheet.getReviewProcess()==0){
+            log.info("柘中报销人填写报销单信息,完善填报金额,第一审核人,第二审核人信息,给第一审核人发送信息");
+            //发送给第一审核人审核
+            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;
     }
 

+ 66 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -4,6 +4,7 @@ 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.management.platform.constant.Constant;
 import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.*;
@@ -178,6 +179,15 @@ public class TimingTask {
     @Resource
     private TaskFilesMapper taskFilesMapper;
 
+    @Resource
+    private ExpenseSheetMapper expenseSheetMapper;
+
+    @Resource
+    private InformationService informationService;
+
+    @Resource
+    private ExpenseMainTypeService expenseMainTypeService;
+
 
     private static final List<Integer> VALID_TOKEN_CHARS = new ArrayList<>();
     static {
@@ -1187,6 +1197,62 @@ public class TimingTask {
         });
     }
 
+
+    //每天9点35分 自动检查柘中报销人填写报销单信息
+    @Scheduled(cron = "0 35 9 ? * *")
+    private void autoCheckZheZhongExpense() {
+        if (isDev) return;
+        List<ExpenseSheet> expenseSheetList = expenseSheetMapper.selectList(new QueryWrapper<ExpenseSheet>().eq("status", 4).eq("company_id", Constant.ZHE_ZHONG_COMPANY_ID));
+        if (!expenseSheetList.isEmpty()) {
+            List<Information> informationList=new ArrayList<>();
+            for (ExpenseSheet sheet : expenseSheetList) {
+                List<User> targetUserList = new ArrayList<>();
+                User owner = userMapper.selectById(sheet.getOwnerId());
+                targetUserList.add(owner);
+                WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", Constant.ZHE_ZHONG_COMPANY_ID));
+                if (wxCorpInfo != null) {
+                    String corpUserString = targetUserList.stream().map(tl -> tl.getCorpwxUserid()).collect(Collectors.joining("|"));
+                    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="+owner.getCorpwxUserid()+"$"));
+                    JSONObject jsonObj1=new JSONObject();
+                    jsonObj1.put("key", "填报日期");
+                    jsonObj1.put("value",sheet.getCreateDate()==null?"":sheet.getCreateDate());
+                    JSONObject jsonObj2=new JSONObject();
+                    jsonObj2.put("key", "票据类型");
+                    jsonObj2.put("value",mainType.getName());
+                    JSONObject jsonObj3=new JSONObject();
+                    jsonObj2.put("key", "提示");
+                    jsonObj2.put("value","请及时填写报销单信息");
+                    dataJson.add(jsonObj);
+                    dataJson.add(jsonObj1);
+                    dataJson.add(jsonObj2);
+                    dataJson.add(jsonObj3);
+                    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);
+                }
+
+                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);
+        }
+
+    }
+
     //每天2点10分 自动审核超过指定天数的日报
     @Scheduled(cron = "0 10 2 ? * *")
     private void autoApprove() {