Forráskód Böngészése

财务核算成本添加部门筛选条件

yusm 1 hónapja
szülő
commit
5e16490a7b

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/DingTalkController.java

@@ -43,10 +43,10 @@ public class DingTalkController {
         DingTalkUserInfo userInfo = dingTalkService.getUserInfoByCode(code);
         
         // 2. 业务系统登录逻辑
-        String token = "";
+        String userId = "";
         
         // 3. 重定向到前端并携带token
-        response.sendRedirect(dingTalkConfig.getRedirectUri() + "?token=" + token);
+        response.sendRedirect(dingTalkConfig.getRedirectUri() + "?userId=" + userId);
         return ResponseEntity.ok().build();
     }
 }

+ 10 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceController.java

@@ -61,8 +61,8 @@ public class FinanceController {
     private String path;
 
     @RequestMapping("/getByMonth")
-    public HttpRespMsg getByMonth(Integer companyId, String yearMonth) {
-        return financeService.getByMonth(companyId, yearMonth);
+    public HttpRespMsg getByMonth(Integer companyId, String yearMonth,Integer deptId) {
+        return financeService.getByMonth(companyId, yearMonth,deptId);
     }
 
     @RequestMapping("/getProjects")
@@ -103,8 +103,10 @@ public class FinanceController {
     @RequestMapping("/exportData")
     public HttpRespMsg exportData(@RequestParam(required = false, defaultValue = "0") Integer groupByCategory,
                                   @RequestParam(defaultValue = "0")Integer onlyTotal,
-                                  @RequestParam String date, Boolean assignNoProUser,HttpServletRequest request) {
-        return financeService.exportData(groupByCategory,onlyTotal, date, assignNoProUser, request);
+                                  @RequestParam String date, Boolean assignNoProUser,
+                                  Integer deptId,
+                                  HttpServletRequest request) {
+        return financeService.exportData(groupByCategory,onlyTotal, date, assignNoProUser,deptId, request);
     }
 
     /**
@@ -114,14 +116,14 @@ public class FinanceController {
      * @return
      */
     @RequestMapping("/exportFinance")
-    public HttpRespMsg exportFinance(@RequestParam String date, HttpServletRequest request) {
-        return financeService.exportFinance(date, request);
+    public HttpRespMsg exportFinance(@RequestParam String date,Integer deptId, HttpServletRequest request) {
+        return financeService.exportFinance(date,deptId, request);
     }
 
     //按照项目分配财务成本
     @RequestMapping("/getTimeCost")
-    public HttpRespMsg getTimeCost(String yearMonth, Boolean assignNoProUser,HttpServletRequest request) {
-        return financeService.getTimeCost(yearMonth, assignNoProUser,request);
+    public HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser,HttpServletRequest request) {
+        return financeService.getTimeCost(yearMonth,deptId, assignNoProUser,request);
     }
 
     @RequestMapping("/getNoProjectUsers")

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/FinanceMapper.java

@@ -3,6 +3,8 @@ package com.management.platform.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.management.platform.entity.Finance;
 
+import java.util.List;
+
 /**
  * <p>
  *  Mapper 接口
@@ -13,4 +15,5 @@ import com.management.platform.entity.Finance;
  */
 public interface FinanceMapper extends BaseMapper<Finance> {
 
+    List<Finance> selectListByDept(Integer companyId, String yearMonth, Integer deptId);
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -129,7 +129,7 @@ public interface ReportMapper extends BaseMapper<Report> {
 
     List<Map<String, Object>> getRealProjectTime(@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, Integer companyId);
 
-    List<Map<String, Object>> getRealProjectTimeNew(@Param("ym")String ym,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, Integer companyId);
+    List<Map<String, Object>> getRealProjectTimeNew(@Param("ym")String ym,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate, Integer companyId,Integer deptId);
 
     List<Map<String, Object>> getReportFillStatus(String startDate, String endDate, String userId);
 

+ 4 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceService.java

@@ -17,17 +17,17 @@ import javax.servlet.http.HttpServletRequest;
  */
 public interface FinanceService extends IService<Finance> {
 
-    HttpRespMsg getByMonth(Integer companyId, String yearMonth);
+    HttpRespMsg getByMonth(Integer companyId, String yearMonth,Integer deptId);
 
     HttpRespMsg importData(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile multipartFile, HttpServletRequest request) throws Exception;
 
-    HttpRespMsg exportData(Integer groupByCategory,Integer onlyTotal, String date, Boolean assignNoProUser, HttpServletRequest request);
+    HttpRespMsg exportData(Integer groupByCategory,Integer onlyTotal, String date, Boolean assignNoProUser,Integer deptId, HttpServletRequest request);
 
-    HttpRespMsg getTimeCost(String yearMonth, Boolean assignNoProUser, HttpServletRequest request);
+    HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser, HttpServletRequest request);
 
     HttpRespMsg getNoProjectUsers(String yearMonth, HttpServletRequest request);
 
     HttpRespMsg getProjects(Integer companyId, String yearMonth);
 
-    HttpRespMsg exportFinance(String date, HttpServletRequest request);
+    HttpRespMsg exportFinance(String date,Integer deptId, HttpServletRequest request);
 }

+ 15 - 11
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -100,9 +100,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     private String path;
 
     @Override
-    public HttpRespMsg getByMonth(Integer companyId, String yearMonth) {
+    public HttpRespMsg getByMonth(Integer companyId, String yearMonth,Integer deptId) {
         HttpRespMsg msg = new HttpRespMsg();
-        List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+//        List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+        List<Finance> financeList = financeMapper.selectListByDept(companyId, yearMonth,deptId);
         TimeType timeType = timeTypeMapper.selectById(companyId);
         //当前月是否有项目日报数据
         List<Map<String, Object>> userList = reportMapper.selectFillReportUserList(companyId, yearMonth+"-01", yearMonth+"-31");
@@ -655,7 +656,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     }
 
     @Override
-    public HttpRespMsg exportData(Integer groupByCategory,Integer onlyTotal, String yearMonth, Boolean assignNoProUser, HttpServletRequest request) {
+    public HttpRespMsg exportData(Integer groupByCategory,Integer onlyTotal, String yearMonth, Boolean assignNoProUser, Integer deptId,HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
@@ -776,7 +777,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
 //            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
             /**添加非分摊项目过滤*/
-            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId);
+            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId,deptId);
             //如果定义了可分摊项目的过滤,按照数据处理一下
             CostProjectSetting setting = costProjectSettingMapper.selectOne(new QueryWrapper<CostProjectSetting>().eq("company_id", companyId));
             if (setting != null && setting.getSettingType() > 0) {
@@ -817,7 +818,8 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                     userTime.get(creatorId).workingTime = userTime.get(creatorId).workingTime.add(new BigDecimal((Double)map.get("workingTime")));
                 }
             }
-            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+//            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+            List<Finance> finances = financeMapper.selectListByDept(companyId,yearMonth,deptId);
             List<Finance> noProjectUser = new ArrayList<>();
             //计算无项目的人员
             for (Finance f : finances) {
@@ -1990,7 +1992,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     }
 
     @Override
-    public HttpRespMsg getTimeCost(String yearMonth, Boolean assignNoProUser, HttpServletRequest request) {
+    public HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
@@ -2004,7 +2006,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
 //            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
             /**添加非分摊项目过滤*/
-            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId);
+            List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTimeNew(yearMonth,startDate, endDate, companyId,deptId);
             //如果定义了可分摊项目的过滤,按照数据处理一下
             CostProjectSetting setting = costProjectSettingMapper.selectOne(new QueryWrapper<CostProjectSetting>().eq("company_id", companyId));
             if (setting != null && setting.getSettingType() > 0) {
@@ -2043,7 +2045,8 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                     userTime.put(creatorId, d);
                 }
             }
-            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+//            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+            List<Finance> finances = financeMapper.selectListByDept(companyId,yearMonth,deptId);
             //未投入项目的人员
             ProjectSumItem noProjectItem = new ProjectSumItem();
             List<Finance> noProjectUser = new ArrayList<>();
@@ -2216,7 +2219,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             resultMap.put("noProjectItem", noProjectItem);
             resultMap.put("totalMoneyCost", totalMoneyCost);
             if (missingFinanceUserIds.size() > 0) {
-                List<Map<String, Object>> userList = userMapper.getSimpleNameList(new QueryWrapper<User>().in("id", missingFinanceUserIds));
+                List<Map<String, Object>> userList = userMapper.getSimpleNameList(new QueryWrapper<User>().in("id", missingFinanceUserIds).eq("department_id",deptId));
                 resultMap.put("missingFinanceUserList", userList);
             } else {
                 resultMap.put("missingFinanceUserList", new ArrayList<>());
@@ -2286,7 +2289,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     }
 
     @Override
-    public HttpRespMsg exportFinance(String yearMonth, HttpServletRequest request) {
+    public HttpRespMsg exportFinance(String yearMonth,Integer deptId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
@@ -2337,7 +2340,8 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
 
 
             //获取月成本列表
-            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+//            List<Finance> finances = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
+            List<Finance> finances = financeMapper.selectListByDept(companyId,yearMonth,deptId);
             for (Finance f : finances) {
                 User user = userList.stream().filter(ul -> ul.getId().equals(f.getUserId())).findFirst().get();
                 BigDecimal cost = f.getTotalCost();

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

@@ -34,5 +34,21 @@
     <sql id="Base_Column_List">
         id, user_id, job_number, name, company_id, dept_name, month_cost, bonus, allowance, insurance_old, insurance_medical, insurance_losejob, insurance_injury, house_fund, others, total_cost, ymonth, custom_field1, custom_field2, custom_field3, custom_field4, custom_field5, custom_field6, custom_field7
     </sql>
+    <select id="selectListByDept" resultType="com.management.platform.entity.Finance">
+        SELECT f.* FROM finance f
+                left JOIN user on f.user_id=user.id
+                left JOIN department d on d.department_id=`user`.department_id
+        <where>
+            <if test="deptId !=null">
+                and d.department_id=#{deptId}
+            </if>
+            <if test="companyId !=null">
+                and f.company_id=#{companyId}
+            </if>
+            <if test="yearMonth !=null and yearMonth !='' ">
+                and f.ymonth=#{yearMonth}
+            </if>
+        </where>
+    </select>
 
 </mapper>

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -934,6 +934,9 @@
         <if test="endDate != null">
             AND report.create_date &lt; #{endDate}
         </if>
+        <if test="deptId != null">
+            AND report.dept_id= #{deptId}
+        </if>
         AND not exists(
         select 1 from finance_exclude_project fep where fep.company_id = report.company_id and fep.use_ym = #{ym} and fep.project_id = report.project_id
         )