Pārlūkot izejas kodu

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

ggooalice 2 gadi atpakaļ
vecāks
revīzija
4b1f9b94d7

+ 17 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -361,6 +361,23 @@ public class WeiXinCorpController {
                     param.setIndate(LocalDateTime.now());
                     sysConfigMapper.updateById(param);
                 }
+            } else if (jsonObject.has("ChangeType")) {
+                //{"xml":{"ChangeType":"delete_user","UserID":"ShanShuiGongZhangTianYiSe",
+                // "SuiteId":"ww4e237fd6abb635af","InfoType":"change_contact","AuthCorpId":"wwf11426cf618e1703",
+                // "TimeStamp":1655908762,"OpenUserID":"woy9TkCAAApdqSxsfJbmK4cBJhbzI5Ug"}}
+                String changeType = jsonObject.getString("ChangeType");
+                if ("delete_user".equals(changeType)) {
+                    //监听到员工离职
+                    String corpId = jsonObject.getString("AuthCorpId");
+                    String corpWxUserId = jsonObject.getString("UserID");
+                    Integer companyId = wxCorpInfoMapper.selectById(corpId).getCompanyId();
+                    User user = userMapper.selectOne(new QueryWrapper<User>().eq("corpwx_userid", corpWxUserId).eq("company_id", companyId));
+                    if (user.getIsActive() == 1) {
+                        user.setIsActive(0);
+                        user.setInactiveDate(LocalDate.now());
+                        userMapper.updateById(user);
+                    }
+                }
             }
         } catch (Exception e) {
             // TODO

+ 5 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Company.java

@@ -1,15 +1,16 @@
 package com.management.platform.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
 /**
  * <p>
  * 

+ 68 - 28
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -6,14 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.management.platform.entity.ExpenseItem;
-import com.management.platform.entity.ExpenseSheet;
-import com.management.platform.entity.Project;
-import com.management.platform.entity.User;
-import com.management.platform.mapper.ExpenseItemMapper;
-import com.management.platform.mapper.ExpenseSheetMapper;
-import com.management.platform.mapper.ProjectMapper;
-import com.management.platform.mapper.UserMapper;
+import com.management.platform.entity.*;
+import com.management.platform.entity.vo.SysRichFunction;
+import com.management.platform.mapper.*;
 import com.management.platform.service.ExpenseItemService;
 import com.management.platform.service.ExpenseSheetService;
 import com.management.platform.util.ExcelUtil;
@@ -39,6 +34,7 @@ import java.time.LocalDate;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -61,6 +57,10 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     private ExpenseItemMapper expenseItemMapper;
     @Resource
     private ProjectMapper projectMapper;
+    @Resource
+    private SysFunctionMapper sysFunctionMapper;
+    @Resource
+    private ExpenseTypeMapper expenseTypeMapper;
     @Override
     public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -200,7 +200,6 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
         //然后处理文件
-//        List<MultipartFile> multipartFiles = JSONArray.parseArray(files, MultipartFile.class);
         for (MultipartFile multipartFile : files) {
             String fileName = multipartFile.getOriginalFilename();
             File file = new File(fileName == null ? "file" : fileName);
@@ -223,7 +222,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 //获取全部人员
                 List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
                 List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
-                System.out.println(projectList);
+                List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "费用审核");
+                List<ExpenseType> expenseTypeList = expenseTypeMapper.selectList(null);
                 //由于第一行需要指明报销人列对应的标题
                 XSSFRow firstRow = sheet.getRow(2);
                 if (firstRow == null) {
@@ -246,7 +246,15 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 if (expenseTypeCell == null) {
                     throw new Exception("费用类型不能为空");
                 }
+                if (reportDateCell == null) {
+                    throw new Exception("填报日期不能为空");
+                }
                 ExpenseSheet expenseSheet = new ExpenseSheet();
+                if(functionList.size()>0){
+                    expenseSheet.setStatus(0);
+                }else {
+                    expenseSheet.setStatus(1);
+                }
                 //处理编号
                 DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd");
                 String format = yyyyMMdd.format(LocalDate.now());
@@ -293,6 +301,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 //计算总费用
                 BigDecimal bigDecimal = new BigDecimal(0);
                 List<ExpenseItem> expenseItemList = new ArrayList<>();
+                int i=0;
                 for (int rowIndex = 5; rowIndex <= rowNum; rowIndex++) {
                     XSSFRow row = sheet.getRow(rowIndex);
                     if (row == null) {
@@ -320,38 +329,69 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     if (invoiceNoCell != null) invoiceNoCell.setCellType(CellType.STRING);
                     if (taxPercentCell != null) taxPercentCell.setCellType(CellType.NUMERIC);
                     if (remarkCell != null) remarkCell.setCellType(CellType.STRING);
+                    //项目为空 直接跳过
+                    if(codeCell==null){
+                        continue;
+                    }
+                    if(happenDateCell.toString().trim().equals("")||happenDateCell==null){
+                        msg.setError("费用日期不能为空");
+                        return msg;
+                    }
                     ExpenseItem expenseItem = new ExpenseItem();
+                    System.out.println(codeCell.getStringCellValue());
                     Optional<Project> project = projectList.stream().filter(pro ->(StringUtils.isEmpty(pro.getProjectCode())?"":pro.getProjectCode()).equals(codeCell.getStringCellValue())
                             || (StringUtils.isEmpty(pro.getProjectName())?"":pro.getProjectName()).equals(codeCell.getStringCellValue())).findFirst();
                     if (project.isPresent()) {
                         expenseItem.setProjectId(project.get().getId());
                     } else {
-                        throw new Exception("项目编号为[" + codeCell.getStringCellValue() + "]的项目不存在");
+                        throw new Exception("项目编号/项目名称为[" + codeCell.getStringCellValue() + "]的项目不存在");
                     }
                     expenseItem.setExpenseId(expenseSheet.getId());
                     LocalDate happenDate = Instant.ofEpochMilli(happenDateCell.getDateCellValue().getTime())
                             .atZone(ZoneId.systemDefault()).toLocalDate();
                     expenseItem.setHappenDate(String.valueOf(happenDate));
-                    switch (invoiceTypeCell.getStringCellValue()) {
-                        case "增值税专用发票":
-                            expenseItem.setInvoiceType(0);
-                            break;
-                        case "增值税普通发票":
-                            expenseItem.setInvoiceType(1);
-                            break;
+                    if(invoiceTypeCell!=null){
+                        switch (invoiceTypeCell.getStringCellValue()) {
+                            case "增值税专用发票":
+                                expenseItem.setInvoiceType(0);
+                                break;
+                            case "增值税普通发票":
+                                expenseItem.setInvoiceType(1);
+                                break;
+                        }
                     }
-                    expenseItem.setInvoiceNo(invoiceNoCell.getStringCellValue());
-                    expenseItem.setAmount(amountCell.getNumericCellValue());
-                    expenseItem.setRemark(remarkCell.getStringCellValue());
-                    //计算税额
-                    BigDecimal bd = new BigDecimal(amountCell.getNumericCellValue());
-                    //原始金额
-                    BigDecimal divide = bd.divide(BigDecimal.valueOf((1 + taxPercentCell.getNumericCellValue())),2,BigDecimal.ROUND_HALF_UP);
-                    BigDecimal subtract = bd.subtract(divide);
-                    expenseItem.setTaxValue(subtract.doubleValue());
-                    bigDecimal.add(BigDecimal.valueOf(amountCell.getNumericCellValue()));
+                    if(subExpenseTypeCell!=null){
+                        List<String> stringList = expenseTypeList.stream().filter(et -> et.getMainType().equals(expenseSheet.getType())).map(et -> et.getTypeName()).collect(Collectors.toList());
+                        if(!stringList.contains(subExpenseTypeCell.getStringCellValue())){
+                            msg.setError("当前费用类型["+expenseTypeCell.getStringCellValue()+"]中不存在["+subExpenseTypeCell.getStringCellValue()+"]类型");
+                            return msg;
+                        }
+                        expenseItem.setExpenseType(subExpenseTypeCell.getStringCellValue());
+                    }
+                    if(invoiceNoCell!=null){
+                        expenseItem.setInvoiceNo(invoiceNoCell.getStringCellValue());
+                    }
+                    if(amountCell!=null){
+                        expenseItem.setAmount(amountCell.getNumericCellValue());
+                        //计算税额
+                        BigDecimal bd = new BigDecimal(amountCell.getNumericCellValue());
+                        //原始金额
+                        BigDecimal divide = bd.divide(BigDecimal.valueOf((1 + taxPercentCell.getNumericCellValue())),2,BigDecimal.ROUND_HALF_UP);
+                        BigDecimal subtract = bd.subtract(divide);
+                        bigDecimal=bigDecimal.add(BigDecimal.valueOf(amountCell.getNumericCellValue()));
+                        expenseItem.setTaxValue(subtract.doubleValue());
+                    }
+                    if(remarkCell!=null){
+                        expenseItem.setRemark(remarkCell.getStringCellValue());
+                    }
+                    if(taxPercentCell!=null){
+                        expenseItem.setTaxPercent(taxPercentCell.getNumericCellValue());
+                    }
+
                     expenseItemList.add(expenseItem);
+                    i++;
                 }
+                expenseSheet.setTicketNum(i);
                 expenseSheet.setTotalAmount(bigDecimal.doubleValue());
                 expenseSheetMapper.updateById(expenseSheet);
                 expenseItemService.saveBatch(expenseItemList);

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/SysRoleServiceImpl.java

@@ -129,7 +129,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         queryWrapper.orderByAsc("orderitem");
 
         List<SysModule> modules = sysModuleMapper.selectList(queryWrapper);
-
+        if (modules.size() == 0) {
+            System.err.println("请先初始化sys_module和sys_function表");
+            return null;
+        }
         QueryWrapper<SysFunction> functionQueryWrapper = new QueryWrapper<SysFunction>().eq("package_time", 1);
         if (company.getPackageProject() == 1) {
             functionQueryWrapper.or().eq("package_project", 1);