Przeglądaj źródła

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

17613754660 3 lat temu
rodzic
commit
5e653fe787
19 zmienionych plików z 1153 dodań i 3 usunięć
  1. 48 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceAuditorController.java
  2. 94 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceImportController.java
  3. 52 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportImportLogController.java
  4. 38 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/FinanceAuditor.java
  5. 104 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/FinanceImport.java
  6. 75 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ReportImportLog.java
  7. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/FinanceAuditorMapper.java
  8. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/FinanceImportMapper.java
  9. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportImportLogMapper.java
  10. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceAuditorService.java
  11. 25 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceImportService.java
  12. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportImportLogService.java
  13. 20 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceAuditorServiceImpl.java
  14. 529 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceImportServiceImpl.java
  15. 20 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportImportLogServiceImpl.java
  16. 16 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/FinanceAuditorMapper.xml
  17. 28 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/FinanceImportMapper.xml
  18. 21 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportImportLogMapper.xml
  19. 3 3
      fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

+ 48 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceAuditorController.java

@@ -0,0 +1,48 @@
+package com.management.platform.controller;
+
+
+import com.management.platform.entity.Finance;
+import com.management.platform.entity.FinanceAuditor;
+import com.management.platform.mapper.FinanceAuditorMapper;
+import com.management.platform.service.FinanceAuditorService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+@RestController
+@RequestMapping("/finance-auditor")
+public class FinanceAuditorController {
+
+    @Resource
+    private FinanceAuditorService financeAuditorService;
+    @Resource
+    private HttpServletRequest request;
+
+    @RequestMapping("/save")
+    public HttpRespMsg save(FinanceAuditor item) {
+        HttpRespMsg msg = new HttpRespMsg();
+        financeAuditorService.saveOrUpdate(item);
+        return msg;
+    }
+
+    @RequestMapping("/get")
+    public HttpRespMsg get(Integer companyId) {
+        HttpRespMsg msg = new HttpRespMsg();
+        FinanceAuditor item = financeAuditorService.getById(companyId);
+        msg.data = item;
+        return msg;
+    }
+}
+

+ 94 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceImportController.java

@@ -0,0 +1,94 @@
+package com.management.platform.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.FinanceImport;
+import com.management.platform.entity.User;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.service.FinanceImportService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+@RestController
+@RequestMapping("/finance-import")
+public class FinanceImportController {
+
+    @Resource
+    private FinanceImportService financeImportService;
+    @Resource
+    private UserMapper userMapper;
+
+    @RequestMapping("submitImport")
+    public HttpRespMsg submitImport(Integer companyId, String yearMonth,
+                                  Boolean syncUserCost, Boolean syncHistoryReport,
+                                  MultipartFile file, HttpServletRequest request) {
+        return financeImportService.submitImport(companyId, yearMonth, syncUserCost, syncHistoryReport, file, request);
+    }
+
+    @RequestMapping("list")
+    public HttpRespMsg list(Integer companyId, HttpServletRequest request) {
+        return financeImportService.list(companyId, request);
+    }
+
+    @RequestMapping("/agree")
+    public HttpRespMsg agree(Integer id, HttpServletRequest request) {
+
+        return financeImportService.agree(id, request);
+    }
+
+    @RequestMapping("/getStatus")
+    public HttpRespMsg getStatus(Integer companyId, String yearMonth) {
+        FinanceImport item = financeImportService.getOne(new QueryWrapper<FinanceImport>().eq("company_id", companyId).eq("ymonth", yearMonth).orderByDesc("indate").last("limit 1"));
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.data = item;
+        return msg;
+    }
+
+    @RequestMapping("/deny")
+    public HttpRespMsg deny(Integer id, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        FinanceImport item = new FinanceImport();
+        item.setId(id);
+        item.setState(2);
+        FinanceImport old = financeImportService.getById(id);
+        if (old.getState() == 0) {
+            User auditor = userMapper.selectById(request.getHeader("TOKEN"));
+            item.setAuditorId(auditor.getId());
+            item.setAuditorName(auditor.getName());
+            financeImportService.updateById(item);
+        } else {
+            msg.setError("只有待审核状态才可以操作");
+        }
+        return msg;
+    }
+
+    @RequestMapping("/cancel")
+    public HttpRespMsg cancel(Integer id, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        FinanceImport item = new FinanceImport();
+        item.setId(id);
+        item.setState(-1);
+        FinanceImport old = financeImportService.getById(id);
+        if (old.getState() == 1) {
+            financeImportService.updateById(item);
+        } else {
+            msg.setError("只有审核通过状态才可以撤销");
+        }
+        return msg;
+    }
+}
+

+ 52 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportImportLogController.java

@@ -0,0 +1,52 @@
+package com.management.platform.controller;
+
+
+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.management.platform.entity.Project;
+import com.management.platform.entity.ReportImportLog;
+import com.management.platform.mapper.ReportImportLogMapper;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-20
+ */
+@RestController
+@RequestMapping("/report-import-log")
+public class ReportImportLogController {
+
+    @Resource
+    private ReportImportLogMapper reportImportLogMapper;
+
+    @RequestMapping("/getList")
+    public HttpRespMsg getList(Integer companyId, @RequestParam Integer pageIndex, @RequestParam Integer pageSize) {
+        HttpRespMsg msg = new HttpRespMsg();
+        QueryWrapper<ReportImportLog> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("company_id", companyId).orderByDesc("indate");
+        IPage<ReportImportLog> iPage = reportImportLogMapper.selectPage(new Page<>(pageIndex, pageSize),
+                queryWrapper);
+        List<ReportImportLog> list = iPage.getRecords();
+        Long total = iPage.getTotal();
+        Map<String, Object> map = new HashMap<>();
+        map.put("records", list);
+        map.put("total", total);
+        msg.data = map;
+        return msg;
+    }
+}
+

+ 38 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/FinanceAuditor.java

@@ -0,0 +1,38 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class FinanceAuditor extends Model<FinanceAuditor> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId("company_id")
+    private Integer companyId;
+
+    @TableField("auditor_id")
+    private String auditorId;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.companyId;
+    }
+
+}

+ 104 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/FinanceImport.java

@@ -0,0 +1,104 @@
+package com.management.platform.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+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.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class FinanceImport extends Model<FinanceImport> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @TableField("company_id")
+    private Integer companyId;
+
+    @TableField("ymonth")
+    private String ymonth;
+
+    @TableField("file_name")
+    private String fileName;
+
+    @TableField("server_name")
+    private String serverName;
+
+    @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    private LocalDateTime indate;
+
+    /**
+     * 操作人id
+     */
+    @TableField("user_id")
+    private String userId;
+
+    /**
+     * 操作人姓名
+     */
+    @TableField("user_name")
+    private String userName;
+
+    /**
+     * 0-待审核,1-已通过,2-已驳回,-1 -已撤销
+     */
+    @TableField("state")
+    private Integer state;
+
+    /**
+     * 审核人id
+     */
+    @TableField("auditor_id")
+    private String auditorId;
+
+    /**
+     * 审核人姓名
+     */
+    @TableField("auditor_name")
+    private String auditorName;
+
+    /**
+     * 是否重新计算日报
+     */
+    @TableField("recover_report")
+    private Integer recoverReport;
+
+    /**
+     * 是否覆盖月薪
+     */
+    @TableField("recover_monthcost")
+    private Integer recoverMonthcost;
+
+    /**
+     * 驳回原因
+     */
+    @TableField("reject_reason")
+    private String rejectReason;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 75 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ReportImportLog.java

@@ -0,0 +1,75 @@
+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.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class ReportImportLog extends Model<ReportImportLog> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 导入人id
+     */
+    @TableField("user_id")
+    private String userId;
+
+    /**
+     * 导入人姓名
+     */
+    @TableField("user_name")
+    private String userName;
+
+    /**
+     * 原文件名称
+     */
+    @TableField("file_name")
+    private String fileName;
+
+    /**
+     * 服务器上的文件名称
+     */
+    @TableField("server_name")
+    private String serverName;
+
+    /**
+     * 导入时间
+     */
+    @TableField("indate")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    private LocalDateTime indate;
+
+    @TableField("company_id")
+    private Integer companyId;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/FinanceAuditorMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.FinanceAuditor;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+public interface FinanceAuditorMapper extends BaseMapper<FinanceAuditor> {
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/FinanceImportMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.FinanceImport;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+public interface FinanceImportMapper extends BaseMapper<FinanceImport> {
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportImportLogMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.ReportImportLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-20
+ */
+public interface ReportImportLogMapper extends BaseMapper<ReportImportLog> {
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceAuditorService.java

@@ -0,0 +1,16 @@
+package com.management.platform.service;
+
+import com.management.platform.entity.FinanceAuditor;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+public interface FinanceAuditorService extends IService<FinanceAuditor> {
+
+}

+ 25 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceImportService.java

@@ -0,0 +1,25 @@
+package com.management.platform.service;
+
+import com.management.platform.entity.FinanceImport;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+public interface FinanceImportService extends IService<FinanceImport> {
+
+    HttpRespMsg submitImport(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile file, HttpServletRequest request);
+
+    HttpRespMsg list(Integer companyId, HttpServletRequest request);
+
+    HttpRespMsg agree(Integer id, HttpServletRequest request);
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportImportLogService.java

@@ -0,0 +1,16 @@
+package com.management.platform.service;
+
+import com.management.platform.entity.ReportImportLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-20
+ */
+public interface ReportImportLogService extends IService<ReportImportLog> {
+
+}

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceAuditorServiceImpl.java

@@ -0,0 +1,20 @@
+package com.management.platform.service.impl;
+
+import com.management.platform.entity.FinanceAuditor;
+import com.management.platform.mapper.FinanceAuditorMapper;
+import com.management.platform.service.FinanceAuditorService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+@Service
+public class FinanceAuditorServiceImpl extends ServiceImpl<FinanceAuditorMapper, FinanceAuditor> implements FinanceAuditorService {
+
+}

+ 529 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceImportServiceImpl.java

@@ -0,0 +1,529 @@
+package com.management.platform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.*;
+import com.management.platform.mapper.*;
+import com.management.platform.service.FinanceImportService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.service.FinanceService;
+import com.management.platform.service.ReportService;
+import com.management.platform.service.UserService;
+import com.management.platform.util.ExcelUtil;
+import com.management.platform.util.HttpRespMsg;
+import com.management.platform.util.UserNotFoundException;
+import org.apache.commons.io.FileUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-22
+ */
+@Service
+public class FinanceImportServiceImpl extends ServiceImpl<FinanceImportMapper, FinanceImport> implements FinanceImportService {
+    @Value(value = "${upload.path}")
+    private String path;
+
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private FinanceImportMapper financeImportMapper;
+    @Resource
+    private DepartmentMapper departmentMapper;
+    @Resource
+    private FinanceMapper financeMapper;
+    @Resource
+    private TimeTypeMapper timeTypeMapper;
+    @Resource
+    private FinanceTblcuscolMapper financeTblcuscolMapper;
+    @Resource
+    private ReportMapper reportMapper;
+    @Resource
+    private FinanceService financeService;
+    @Resource
+    private UserService userService;
+    @Resource
+    private ReportService reportService;
+
+
+    @Override
+    @Transactional
+    public HttpRespMsg submitImport(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile multipartFile, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("TOKEN"));
+        //检查当月是否已经存在审核通过的
+        FinanceImport oldItem = financeImportMapper.selectOne(new QueryWrapper<FinanceImport>().eq("company_id", companyId).eq("ymonth", yearMonth).orderByDesc("indate").last("limit 1"));
+        if (oldItem != null) {
+            if (oldItem.getState() == 1) {
+                msg.setError(yearMonth+"月薪资已审核通过,无法上传。");
+                return msg;
+            } else {
+                if (oldItem.getState() == 0) {
+                    String[] fname = oldItem.getServerName().split("\\/");
+                    File oldFile = new File(new File(path, fname[0]), fname[1]);
+                    oldFile.delete();
+                    financeImportMapper.deleteById(oldItem.getId());
+                }
+            }
+        }
+
+        //然后处理文件
+        String fileName = multipartFile.getOriginalFilename();
+        File file = new File(fileName == null ? "file" : fileName);
+        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();
+            //然后解析表格, 进行数据格式校验
+            Workbook wb = WorkbookFactory.create(new FileInputStream(file));
+            Sheet sheet = wb.getSheetAt(0);
+            //要插入的账号列表
+            List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+            List<Finance> financeList = new ArrayList<Finance>();
+            //需要更新成本的人员数据
+            List<User> updateUserList = new ArrayList<>();
+
+            String startStr = yearMonth + "-01";
+            String endStr = yearMonth + "-31";
+            //由于第一行需要指明列对应的标题
+            int rowNum = sheet.getLastRowNum();
+            for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
+                Row row = sheet.getRow(rowIndex);
+                if (row == null) {
+                    continue;
+                }
+                if (ExcelUtil.isRowEmpty(row)) {
+                    continue;
+                }
+                //姓名	工资	奖金	津贴	养老保险	医疗保险	失业保险	(新增工伤保险) 住房公积金	其他; 可能有自定义的项
+                Cell nameCell = row.getCell(0);
+                nameCell.setCellType(CellType.STRING);
+
+                String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
+                Finance finance = new Finance();
+
+                if (name.equals("姓名") && rowIndex == 0) {
+                    continue;
+                }
+                finance.setName(name);
+                Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
+                if (first.isPresent()) {
+                    finance.setUserId(first.get().getId());
+                    //如果需要更新员工成本
+                    if (syncUserCost || syncHistoryReport) {
+                        //设置人员总id
+                        User localUser = new User();
+                        localUser.setId(finance.getUserId());
+                        updateUserList.add(localUser);
+                    }
+                } else {
+                    msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
+                    return msg;
+                }
+                finance.setYmonth(yearMonth);
+                financeList.add(finance);
+            }
+            if (financeList.size() == 0) {
+                msg.setError("请填写数据再上传");
+                return msg;
+            }
+
+            //如果有必要,更新该月份的日报相关的成本
+            if (syncHistoryReport) {
+                List<Report> reportList = reportMapper.selectSimpleTime(companyId, startStr, endStr);
+                if (reportList.size() > 0) {
+                    for (Report r : reportList) {
+                        Optional<User> first = updateUserList.stream().filter(u -> u.getId().equals(r.getCreatorId())).findFirst();
+                        if (!first.isPresent()) {
+                            String notFillUser = userMapper.selectById(r.getCreatorId()).getName();
+                            System.out.println("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
+                            throw new UserNotFoundException("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
+                        }
+                    }
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            msg.setError("文件处理出错");
+            return msg;
+        } catch (UserNotFoundException e) {
+            e.printStackTrace();
+            msg.setError(e.getMessage());
+            return msg;
+        } catch (NullPointerException e) {
+            e.printStackTrace();
+            msg.setError("数据格式有误或存在空数据 导入失败");
+            return msg;
+        } catch (Exception e) {
+            e.printStackTrace();
+            msg.setError("发生其他错误");
+            return msg;
+        } finally {
+            //关闭流
+            try {
+                if (outputStream != null && inputStream != null) {
+                    outputStream.close();
+                    inputStream.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        //保存导入记录
+        String originName = fileName;
+        System.out.println("fileName=="+originName);
+        String[] names = originName.split("\\.");
+        String destFileName = names[0] + "_"+System.currentTimeMillis()+"."+names[1];
+        String financeFolder = "finance";
+        File dir = new File(path, financeFolder);
+        if (!dir.exists()) {
+            dir.mkdir();
+        }
+        File destFile = new File(dir, destFileName);
+        try {
+            multipartFile.transferTo(destFile);
+//            FileUtils.copyFile(new File(multipartFile.getOriginalFilename()), destFile);
+            FinanceImport log = new FinanceImport();
+            log.setCompanyId(companyId);
+            log.setFileName(originName);
+            log.setServerName(financeFolder+"/"+destFileName);
+            log.setUserId(user.getId());
+            log.setUserName(user.getName());
+            log.setYmonth(yearMonth);
+            log.setRecoverMonthcost(syncUserCost?1:0);
+            log.setRecoverReport(syncHistoryReport?1:0);
+            financeImportMapper.insert(log);
+        } catch (IOException e) {
+            e.printStackTrace();
+            msg.setError(e.getMessage());
+        } finally {
+            System.out.println("删除临时文件:"+file.delete());
+        }
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg list(Integer companyId, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        List<FinanceImport> all = financeImportMapper.selectList(new QueryWrapper<FinanceImport>().eq("company_id", companyId).orderByDesc("indate"));
+        List<FinanceImport> pendingList = all.stream().filter(a->a.getState() == 0).collect(Collectors.toList());
+        List<FinanceImport> passList = all.stream().filter(a->a.getState() == 1).collect(Collectors.toList());
+        List<FinanceImport> rejectList = all.stream().filter(a->a.getState() == 2).collect(Collectors.toList());
+        List<FinanceImport> cancelList = all.stream().filter(a->a.getState() == -1).collect(Collectors.toList());
+        HashMap map = new HashMap();
+        map.put("pendingList", pendingList);
+        map.put("passList", passList);
+        map.put("rejectList", rejectList);
+        map.put("cancelList", cancelList);
+        msg.data = map;
+        return msg;
+    }
+
+    @Override
+    @Transactional
+    public HttpRespMsg agree(Integer id, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        FinanceImport curItem = new FinanceImport();
+        curItem.setId(id);
+        curItem.setState(1);
+        User auditor = userMapper.selectById(request.getHeader("TOKEN"));
+        curItem.setAuditorId(auditor.getId());
+        curItem.setAuditorName(auditor.getName());
+
+        FinanceImport oldItem = financeImportMapper.selectById(id);
+        if (oldItem == null) {
+            msg.setError("该数据不存在");
+            return msg;
+        }
+        if (oldItem.getState() == 0) {
+            //读取文件进行更新
+            oldItem.getServerName();
+            String[] fname = oldItem.getServerName().split("\\/");
+            File oldFile = new File(new File(path, fname[0]), fname[1]);
+            FinanceImport financeImport = oldItem;
+            //然后处理文件
+            try {
+                //然后解析表格
+                Workbook wb = WorkbookFactory.create(new FileInputStream(oldFile));
+                Sheet sheet = wb.getSheetAt(0);
+                //要插入的账号列表
+                Integer companyId = financeImport.getCompanyId();
+                String yearMonth = financeImport.getYmonth();
+                List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+                List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+                List<Finance> financeList = new ArrayList<Finance>();
+                List<Finance> oldFinanceList = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+                //获取月成本列表
+                DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                String dateStr = yearMonth+"-01 00:00:00";
+                LocalDateTime startDate = LocalDateTime.parse(dateStr,df);
+                LocalDateTime endDate = LocalDateTime.parse(dateStr,df);
+                endDate = endDate.plusMonths(1);
+
+                TimeType timeType = timeTypeMapper.selectById(companyId);
+                BigDecimal monthHours = timeType.getMonthDays().multiply(new BigDecimal(timeType.getAllday()));
+
+                //需要更新成本的人员数据
+                List<User> updateUserList = new ArrayList<>();
+
+                String startStr = yearMonth + "-01";
+                String endStr = yearMonth + "-31";
+                //获取人员该月份填写的日报的总时长
+                List<Map<String, Object>> userTimeList = null;
+                if (financeImport.getRecoverMonthcost()==1 || financeImport.getRecoverReport()==1) {
+                    userTimeList = reportMapper.getUserWorkingTimeByRange(companyId, startStr, endStr);
+                }
+
+                List<FinanceTblcuscol> cusColList = financeTblcuscolMapper.selectList(new QueryWrapper<FinanceTblcuscol>().eq("company_id", companyId));
+
+                //由于第一行需要指明列对应的标题
+                int rowNum = sheet.getLastRowNum();
+                for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
+                    Row row = sheet.getRow(rowIndex);
+                    if (row == null) {
+                        continue;
+                    }
+                    if (ExcelUtil.isRowEmpty(row)) {
+                        continue;
+                    }
+                    //姓名	工资	奖金	津贴	养老保险	医疗保险	失业保险	(新增工伤保险) 住房公积金	其他; 可能有自定义的项
+                    Cell nameCell = row.getCell(0);
+                    Cell salaryCell = row.getCell(1);
+                    Cell bonusCell = row.getCell(2);
+                    Cell allowanceCell = row.getCell(3);
+                    Cell inOldCell = row.getCell(4);
+                    Cell inMedicalCell = row.getCell(5);
+                    Cell inJobCell = row.getCell(6);
+                    Cell injuryCell = row.getCell(7);
+
+                    nameCell.setCellType(CellType.STRING);
+
+                    String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
+                    Finance finance = new Finance();
+
+                    if (name.equals("姓名") && rowIndex == 0) {
+                        continue;
+                    }
+                    Cell houseFundCell = row.getCell(8);
+                    Cell field1 = cusColList.size() > 0?row.getCell(9):null;
+                    Cell field2 = cusColList.size() > 1?row.getCell(10):null;
+                    Cell field3 = cusColList.size() > 2?row.getCell(11):null;
+
+                    if (field1 != null)field1.setCellType(CellType.STRING);
+                    if (field2 != null)field2.setCellType(CellType.STRING);
+                    if (field3 != null)field3.setCellType(CellType.STRING);
+
+                    finance.setCompanyId(companyId);
+                    finance.setName(name);
+
+                    Optional<User> first = userList.stream().filter(u -> u.getName().equals(name)).findFirst();
+                    if (first.isPresent()) {
+                        finance.setUserId(first.get().getId());
+                        BigDecimal total = new BigDecimal(0);
+                        if (salaryCell != null) {
+                            salaryCell.setCellType(CellType.STRING);
+                            String item = salaryCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setMonthCost(value);
+                            total = total.add(value);
+                        }
+
+                        //按姓名做匹配
+                        Optional<Finance> matchItem = oldFinanceList.stream().filter(o -> o.getName().equals(finance.getName())).findFirst();
+                        if (matchItem.isPresent()) {
+                            finance.setId(matchItem.get().getId());
+                        }
+
+                        if (bonusCell != null) {
+                            bonusCell.setCellType(CellType.STRING);
+                            String bonusString = bonusCell.getStringCellValue();
+                            BigDecimal bonus = bonusString != null ? new BigDecimal(bonusString.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setBonus(bonus);
+                            total = total.add(bonus);
+                        }
+                        if (allowanceCell != null) {
+                            allowanceCell.setCellType(CellType.STRING);
+                            String item = allowanceCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setAllowance(value);
+                            total = total.add(value);
+                        }
+                        if (inJobCell != null) {
+                            inJobCell.setCellType(CellType.STRING);
+                            String item = inJobCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setInsuranceLosejob(value);
+                            total = total.add(value);
+                        }
+                        if (inMedicalCell != null) {
+                            inMedicalCell.setCellType(CellType.STRING);
+                            String item = inMedicalCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setInsuranceMedical(value);
+                            total = total.add(value);
+                        }
+                        if (inOldCell != null) {
+                            inOldCell.setCellType(CellType.STRING);
+                            String item = inOldCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setInsuranceOld(value);
+                            total = total.add(value);
+                        }
+                        if (injuryCell != null) {
+                            injuryCell.setCellType(CellType.STRING);
+                            String item = injuryCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setInsuranceInjury(value);
+                            total = total.add(value);
+                        }
+                        if (houseFundCell != null) {
+                            houseFundCell.setCellType(CellType.STRING);
+                            String item = houseFundCell.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setHouseFund(value);
+                            total = total.add(value);
+                        }
+                        if (field1 != null) {
+                            field1.setCellType(CellType.STRING);
+                            String item = field1.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setCustomField1(value);
+                            total = total.add(value);
+                        }
+                        if (field2 != null) {
+                            field2.setCellType(CellType.STRING);
+                            String item = field2.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setCustomField2(value);
+                            total = total.add(value);
+                        }
+                        if (field3 != null) {
+                            field3.setCellType(CellType.STRING);
+                            String item = field3.getStringCellValue();
+                            BigDecimal value = item != null ? new BigDecimal(item.trim().replaceAll("\\u00a0", "")) : BigDecimal.valueOf(0);
+                            finance.setCustomField3(value);
+                            total = total.add(value);
+                        }
+                        finance.setTotalCost(total);
+
+                        //如果需要更新员工成本
+                        if (financeImport.getRecoverMonthcost()==1 || financeImport.getRecoverReport()==1) {
+                            //设置人员总成本,计算时薪
+                            User localUser = new User();
+                            localUser.setId(finance.getUserId());
+                            localUser.setMonthCost(total);
+                            for (int i=0;i<userTimeList.size(); i++) {
+                                Map<String, Object> map = userTimeList.get(i);
+                                if (map.get("creatorId").equals(finance.getUserId())) {
+                                    double time = (Double)map.get("workingTime");
+                                    localUser.setCost(total.divide(new BigDecimal(time), 6, BigDecimal.ROUND_HALF_UP));
+                                    break;
+                                }
+                            }
+
+                            updateUserList.add(localUser);
+                        }
+                    } else {
+                        msg.setError("用户["+name+"]不存在,请在组织结构中添加该成员");
+                        return msg;
+                    }
+                    finance.setYmonth(yearMonth);
+                    financeList.add(finance);
+
+                }
+                if (financeList.size() == 0) {
+                    msg.setError("请填写数据再上传");
+                    return msg;
+                }
+                //批量插入
+                financeService.saveOrUpdateBatch(financeList);
+                if (financeImport.getRecoverMonthcost()==1) {
+                    userService.updateBatchById(updateUserList);
+                }
+                //检查是否有删除的,需要删除掉
+                List<Integer> readyForDelete = new ArrayList<>();
+                oldFinanceList.forEach(old->{
+                    boolean exists = false;
+                    if (financeList.stream().filter(f->f.getName().equals(old.getName())).findAny().isPresent()) {
+                        exists = true;
+                    }
+                    if (!exists) {
+                        readyForDelete.add(old.getId());
+                    }
+                });
+                if (readyForDelete.size() > 0) {
+                    financeService.removeByIds(readyForDelete);
+                }
+                //如果有必要,更新该月份的日报相关的成本
+                if (financeImport.getRecoverReport()==1) {
+
+                    List<Report> reportList = reportMapper.selectSimpleTime(companyId, startStr, endStr);
+                    if (reportList.size() > 0) {
+                        for (Report r : reportList) {
+                            Optional<User> first = updateUserList.stream().filter(u -> u.getId().equals(r.getCreatorId())).findFirst();
+                            if (!first.isPresent()) {
+                                String notFillUser = userMapper.selectById(r.getCreatorId()).getName();
+                                System.out.println("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
+                                throw new UserNotFoundException("缺少[" + notFillUser + "]的薪资成本, 请修改数据重新上传");
+                            }
+                            BigDecimal hourCost = first.get().getCost();
+                            r.setCost(hourCost.multiply(new BigDecimal(r.getWorkingTime())));
+                            r.setCreatorId(null);
+                            r.setWorkingTime(null);
+                        }
+                        //批量更新日报的成本
+                        reportService.updateBatchById(reportList);
+                    }
+                }
+
+                financeImportMapper.updateById(curItem);
+            } catch (IOException e) {
+                e.printStackTrace();
+                msg.setError("文件处理出错");
+                return msg;
+            } catch (UserNotFoundException e) {
+                e.printStackTrace();
+                msg.setError(e.getMessage());
+                return msg;
+            } catch (NullPointerException e) {
+                e.printStackTrace();
+                msg.setError("数据格式有误或存在空数据 导入失败");
+                return msg;
+            } catch (Exception e) {
+                e.printStackTrace();
+                msg.setError("发生其他错误");
+                return msg;
+            } finally {
+            }
+        } else {
+            msg.setError("只有待审核状态才可以操作");
+        }
+        return msg;
+    }
+
+}

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportImportLogServiceImpl.java

@@ -0,0 +1,20 @@
+package com.management.platform.service.impl;
+
+import com.management.platform.entity.ReportImportLog;
+import com.management.platform.mapper.ReportImportLogMapper;
+import com.management.platform.service.ReportImportLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-03-20
+ */
+@Service
+public class ReportImportLogServiceImpl extends ServiceImpl<ReportImportLogMapper, ReportImportLog> implements ReportImportLogService {
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/FinanceAuditorMapper.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.FinanceAuditorMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.FinanceAuditor">
+        <id column="company_id" property="companyId" />
+        <result column="auditor_id" property="auditorId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        company_id, auditor_id
+    </sql>
+
+</mapper>

+ 28 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/FinanceImportMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.FinanceImportMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.FinanceImport">
+        <id column="id" property="id" />
+        <result column="company_id" property="companyId" />
+        <result column="ymonth" property="ymonth" />
+        <result column="file_name" property="fileName" />
+        <result column="server_name" property="serverName" />
+        <result column="indate" property="indate" />
+        <result column="user_id" property="userId" />
+        <result column="user_name" property="userName" />
+        <result column="state" property="state" />
+        <result column="auditor_id" property="auditorId" />
+        <result column="auditor_name" property="auditorName" />
+        <result column="recover_report" property="recoverReport" />
+        <result column="recover_monthcost" property="recoverMonthcost" />
+        <result column="reject_reason" property="rejectReason" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, company_id, ymonth, file_name, server_name, indate, user_id, user_name, state, auditor_id, auditor_name, recover_report, recover_monthcost, reject_reason
+    </sql>
+
+</mapper>

+ 21 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportImportLogMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.ReportImportLogMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.ReportImportLog">
+        <id column="id" property="id" />
+        <result column="user_id" property="userId" />
+        <result column="user_name" property="userName" />
+        <result column="file_name" property="fileName" />
+        <result column="server_name" property="serverName" />
+        <result column="indate" property="indate" />
+        <result column="company_id" property="companyId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, user_id, user_name, file_name, server_name, indate, company_id
+    </sql>
+
+</mapper>

+ 3 - 3
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -82,7 +82,7 @@
                 </el-form-item>
                 
                 <el-form-item label="选择人员" v-if="radio == '项目' || radio == '部门'">
-                    <el-select v-model="exportParam.userId"  placeholder="请选择人员" style="width: 350px" filterable="true">
+                    <el-select v-model="exportParam.userId"  placeholder="请选择人员" style="width: 350px" filterable="true" clearable="true">
                         <span v-for="(item, index) in users" :key="index">
                         <el-option :label="item.name" :value="item.id"></el-option>
                         </span> 
@@ -230,10 +230,10 @@
                      }
                  } 
                 
-                if (this.exportParam.projectId != null) {
+                if (this.exportParam.projectId) {
                     param.projectId = this.exportParam.projectId;
                 }
-                if (this.exportParam.userId != null) {
+                if (this.exportParam.userId) {
                     if(this.radio == '项目' || this.radio == '部门' || this.radio == '人员'){
                         param.userId = this.exportParam.userId;
                     }