Selaa lähdekoodia

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Lijy 1 vuosi sitten
vanhempi
commit
4189de5abf

+ 50 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/CommonUploadController.java

@@ -7,6 +7,7 @@ import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -15,6 +16,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.List;
 import java.util.UUID;
 
 @RestController
@@ -66,4 +68,52 @@ public class CommonUploadController {
 
         return msg;
     }
+
+    @RequestMapping(value="uploadFileArray")
+    public HttpRespMsg uploadFileArray(@RequestParam("multipartFiles") List<MultipartFile> multipartFiles) {
+        HttpRespMsg msg = new HttpRespMsg();
+        StringBuilder stringBuilder=new StringBuilder();
+
+        for (int i = 0; i < multipartFiles.size(); i++) {
+            MultipartFile multipartFile=multipartFiles.get(i);
+            //然后处理文件
+            String fileName = multipartFile.getOriginalFilename();
+            String[] split = fileName.split("\\.");
+            String serverName = UUID.randomUUID().toString().replaceAll("-", "") + "."+split[split.length-1];
+
+            //检查目录
+            File dir = new File(path);
+            if (!dir.exists()) {
+                dir.mkdir();
+            }
+            File file = new File(dir, serverName);
+            InputStream inputStream = null;
+            OutputStream outputStream = null;
+            try {
+                inputStream = multipartFile.getInputStream();
+                outputStream = new FileOutputStream(file);
+                byte[] buffer = new byte[4096];
+                int temp = 0;
+                while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
+                    outputStream.write(buffer, 0, temp);
+                }
+                inputStream.close();
+                outputStream.close();
+                if(i==multipartFiles.size()-1){
+                    stringBuilder.append(serverName);
+                }else {
+                    stringBuilder.append(serverName+";");
+                }
+
+                // 上传到SFTP服务器
+                sftpAsyncUploader.uploadFileAsync(file);
+
+            } catch (Exception exception) {
+                exception.printStackTrace();
+                logger.error(exception.getMessage());
+            }
+        }
+        msg.data = stringBuilder.toString();
+        return msg;
+    }
 }

+ 19 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ExpenseSheet.java

@@ -20,7 +20,7 @@ import org.springframework.format.annotation.DateTimeFormat;
  * </p>
  *
  * @author Seyason
- * @since 2023-11-07
+ * @since 2023-12-16
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -112,6 +112,24 @@ public class ExpenseSheet extends Model<ExpenseSheet> {
     @TableField("send_state")
     private Integer sendState;
 
+    /**
+     * 第一审核人id
+     */
+    @TableField("first_checker_id")
+    private String firstCheckerId;
+
+    /**
+     * 第二审核人id
+     */
+    @TableField("second_checker_id")
+    private String secondCheckerId;
+
+    /**
+     * 0-待第一审核人审核 1-待第二审核人审核 2-审核完成
+     */
+    @TableField("review_process")
+    private Integer reviewProcess;
+
     @TableField(exist = false)
     private List<ExpenseItem> invoiceList;
 

+ 183 - 49
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -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);

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ExpenseSheetMapper.xml

@@ -18,11 +18,14 @@
         <result column="operator_id" property="operatorId" />
         <result column="deny_reason" property="denyReason" />
         <result column="send_state" property="sendState" />
+        <result column="first_checker_id" property="firstCheckerId" />
+        <result column="second_checker_id" property="secondCheckerId" />
+        <result column="review_process" property="reviewProcess" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, code, company_id, owner_id, owner_name, create_date, ticket_num, type, status, remark, total_amount, operator_id, deny_reason, send_state
+        id, code, company_id, owner_id, owner_name, create_date, ticket_num, type, status, remark, total_amount, operator_id, deny_reason, send_state, first_checker_id, second_checker_id, review_process
     </sql>
 
 </mapper>