diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/SalaryStatisticsController.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/SalaryStatisticsController.java new file mode 100644 index 0000000..6bc9fe2 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/SalaryStatisticsController.java @@ -0,0 +1,50 @@ +package com.bonus.bmw.controller; + +import com.bonus.bmw.domain.vo.ProStatisticsPo; +import com.bonus.bmw.service.SalaryStatisticsService; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; +import com.bonus.common.security.annotation.InnerAuth; +import com.bonus.common.security.annotation.RequiresPermissions; +import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** +* 工资统计 +* @author fly +*/ +@RestController +@RequestMapping("/salaryStatistics") +public class SalaryStatisticsController extends BaseController { +/** +* 服务对象 +*/ + @Autowired + private SalaryStatisticsService service; + + /** + * 人员统计 + * @param o + * @return + */ + @RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("salary:statistics:query")) + @GetMapping("/getSalaryStatisticsTable") + @SysLog(title = "工资统计", businessType = OperaType.QUERY, logType = 0, module = "工资统计->工资统计", details = "工资统计") + public AjaxResult getProStatisticsTable(ProStatisticsPo o) { + try { + Map list = service.getSalaryStatisticsTable(o); + return AjaxResult.success(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return AjaxResult.error("查询失败"); + } + +} diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/WorkerStatisticsController.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/WorkerStatisticsController.java new file mode 100644 index 0000000..140565c --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/controller/WorkerStatisticsController.java @@ -0,0 +1,53 @@ +package com.bonus.bmw.controller; + +import com.bonus.bmw.domain.po.HomePagePo; +import com.bonus.bmw.domain.vo.HomePageSubProVo; +import com.bonus.bmw.service.WorkerStatisticsService; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; +import com.bonus.common.security.annotation.InnerAuth; +import com.bonus.common.security.annotation.RequiresPermissions; +import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +/** +* 人员统计 +* @author fly +*/ +@RestController +@RequestMapping("/workerStatistics") +public class WorkerStatisticsController extends BaseController { +/** +* 服务对象 +*/ + @Autowired + private WorkerStatisticsService service; + + /** + * 人员统计 + * @param o + * @return + */ + @RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("worker:statistics:query")) + @GetMapping("/getWorkerStatisticsTable") + @SysLog(title = "人员统计", businessType = OperaType.QUERY, logType = 0, module = "人员统计->人员统计", details = "人员统计") + public TableDataInfo getWorkerStatisticsTable(HomePagePo o) { + try { + startPage(); + List list = service.getWorkerStatisticsTable(o); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + +} diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/domain/vo/SalaryStatisticsVo.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/domain/vo/SalaryStatisticsVo.java new file mode 100644 index 0000000..ae61629 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/domain/vo/SalaryStatisticsVo.java @@ -0,0 +1,22 @@ +package com.bonus.bmw.domain.vo; + +import lombok.Data; + +@Data +public class SalaryStatisticsVo { + + + private Integer proId; + private String proName; + private Integer subCompanyId; + private String subCompanyName; + private Integer companyId; + private String companyName; + private String month; + private String proNum; + private Integer subNum; + private Double netSalary; + private String subName; + private Double allSalary; + private Integer subId; +} diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/mapper/SalaryStatisticsMapper.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/mapper/SalaryStatisticsMapper.java new file mode 100644 index 0000000..1fd9119 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/mapper/SalaryStatisticsMapper.java @@ -0,0 +1,21 @@ +package com.bonus.bmw.mapper; + +import com.bonus.bmw.domain.vo.SalaryStatisticsVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface SalaryStatisticsMapper { + + + List getSalaryStatisticsTable(@Param("year") String year, @Param("list") List list); + + List getSalaryStatisticsSubComTable(@Param("year") String year, @Param("list") List list); + + List getSalaryStatisticsComTable(@Param("year") String year, @Param("list") List list); + + List salaryStatisticsSubTable(@Param("year") String year, @Param("list") List list); +} + diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/mapper/WorkerStatisticsMapper.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/mapper/WorkerStatisticsMapper.java new file mode 100644 index 0000000..6fb6882 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/mapper/WorkerStatisticsMapper.java @@ -0,0 +1,16 @@ +package com.bonus.bmw.mapper; + +import com.bonus.bmw.domain.po.HomePagePo; +import com.bonus.bmw.domain.vo.HomePageSubProVo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface WorkerStatisticsMapper { + + + List getWorkerStatisticsTable(HomePagePo o); + +} + diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/SalaryStatisticsService.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/SalaryStatisticsService.java new file mode 100644 index 0000000..56a67d2 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/SalaryStatisticsService.java @@ -0,0 +1,16 @@ +package com.bonus.bmw.service; + +import com.bonus.bmw.domain.vo.ProStatisticsPo; + +import java.util.Map; + +public interface SalaryStatisticsService { + + /** + * 获取工程统计 + * @param o + * @return + */ + Map getSalaryStatisticsTable(ProStatisticsPo o); + +} diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/WorkerStatisticsService.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/WorkerStatisticsService.java new file mode 100644 index 0000000..589b7f2 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/WorkerStatisticsService.java @@ -0,0 +1,17 @@ +package com.bonus.bmw.service; + +import com.bonus.bmw.domain.po.HomePagePo; +import com.bonus.bmw.domain.vo.HomePageSubProVo; + +import java.util.List; + +public interface WorkerStatisticsService { + + /** + * 获取工程统计 + * @param o + * @return + */ + List getWorkerStatisticsTable(HomePagePo o); + +} diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/SalaryStatisticsServiceImpl.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/SalaryStatisticsServiceImpl.java new file mode 100644 index 0000000..7da7151 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/SalaryStatisticsServiceImpl.java @@ -0,0 +1,127 @@ +package com.bonus.bmw.service.impl; + +import com.bonus.bmw.domain.vo.ProStatisticsPo; +import com.bonus.bmw.domain.vo.SalaryStatisticsVo; +import com.bonus.bmw.mapper.SalaryStatisticsMapper; +import com.bonus.bmw.service.SalaryStatisticsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +public class SalaryStatisticsServiceImpl implements SalaryStatisticsService { + + @Autowired + private SalaryStatisticsMapper mapper; + + + @Override + public Map getSalaryStatisticsTable(ProStatisticsPo o) { + List listMonth = new ArrayList<>(); + if(o.getMonth() != null){ + String[] split = o.getMonth().split(","); + listMonth.addAll(Arrays.asList(split)); + } + List salaryStatisticsTable = mapper.getSalaryStatisticsTable(o.getYear(),listMonth); + List salaryStatisticsTable2 = mapper.getSalaryStatisticsTable(null,null); + // 创建以 proId 为键的映射表,用于快速查找 + Map proTable2Map = new HashMap<>(); + if (salaryStatisticsTable2 != null) { + for (SalaryStatisticsVo vo2 : salaryStatisticsTable2) { + if (vo2.getProId() != null) { + proTable2Map.put(vo2.getProId(), vo2); + } + } + } + // 将 salaryStatisticsTable2 中的 netSalary 根据 proId 匹配存入 salaryStatisticsTable 的 allSalary + if (salaryStatisticsTable != null && !proTable2Map.isEmpty()) { + for (SalaryStatisticsVo vo1 : salaryStatisticsTable) { + if (vo1.getProId() != null) { + SalaryStatisticsVo matchedVo = proTable2Map.get(vo1.getProId()); + if (matchedVo != null && matchedVo.getNetSalary() != null) { + vo1.setAllSalary(matchedVo.getNetSalary()); + } + } + } + } + + List salaryStatisticsSubComTable = mapper.getSalaryStatisticsSubComTable(o.getYear(),listMonth); + List salaryStatisticsSubComTable2 = mapper.getSalaryStatisticsTable(null,null); + // 创建以 proId 为键的映射表,用于快速查找 + Map subComTable2Map = new HashMap<>(); + if (salaryStatisticsSubComTable2 != null) { + for (SalaryStatisticsVo vo2 : salaryStatisticsSubComTable2) { + if (vo2.getSubCompanyId() != null) { + subComTable2Map.put(vo2.getSubCompanyId(), vo2); + } + } + } + // 将 salaryStatisticsSubComTable2 中的 netSalary 根据 proId 匹配存入 salaryStatisticsTable 的 allSalary + if (salaryStatisticsSubComTable != null && !subComTable2Map.isEmpty()) { + for (SalaryStatisticsVo vo1 : salaryStatisticsSubComTable) { + if (vo1.getSubCompanyId() != null) { + SalaryStatisticsVo matchedVo = subComTable2Map.get(vo1.getSubCompanyId()); + if (matchedVo != null && matchedVo.getNetSalary() != null) { + vo1.setAllSalary(matchedVo.getNetSalary()); + } + } + } + } + + List salaryStatisticsComTable = mapper.getSalaryStatisticsComTable(o.getYear(),listMonth); + List salaryStatisticsComTable2 = mapper.getSalaryStatisticsTable(null,null); + + // 创建以 proId 为键的映射表,用于快速查找 + Map comTable2Map = new HashMap<>(); + if (salaryStatisticsComTable2 != null) { + for (SalaryStatisticsVo vo2 : salaryStatisticsComTable2) { + if (vo2.getCompanyId() != null) { + comTable2Map.put(vo2.getCompanyId(), vo2); + } + } + } + // 将 salaryStatisticsSubComTable2 中的 netSalary 根据 proId 匹配存入 salaryStatisticsTable 的 allSalary + if (salaryStatisticsComTable != null && !comTable2Map.isEmpty()) { + for (SalaryStatisticsVo vo1 : salaryStatisticsComTable) { + if (vo1.getCompanyId() != null) { + SalaryStatisticsVo matchedVo = comTable2Map.get(vo1.getCompanyId()); + if (matchedVo != null && matchedVo.getNetSalary() != null) { + vo1.setAllSalary(matchedVo.getNetSalary()); + } + } + } + } + + List salaryStatisticsSubTable = mapper.salaryStatisticsSubTable(o.getYear(),listMonth); + List salaryStatisticsSubTable2 = mapper.getSalaryStatisticsTable(null,null); +// 创建以 proId 为键的映射表,用于快速查找 + Map subTable2Map = new HashMap<>(); + if (salaryStatisticsSubTable2 != null) { + for (SalaryStatisticsVo vo2 : salaryStatisticsSubTable2) { + if (vo2.getSubId() != null) { + subTable2Map.put(vo2.getSubId(), vo2); + } + } + } + // 将 salaryStatisticsSubTable2 中的 netSalary 根据 proId 匹配存入 salaryStatisticsTable 的 allSalary + if (salaryStatisticsSubTable != null && !subTable2Map.isEmpty()) { + for (SalaryStatisticsVo vo1 : salaryStatisticsSubTable) { + if (vo1.getSubId() != null) { + SalaryStatisticsVo matchedVo = subTable2Map.get(vo1.getSubId()); + if (matchedVo != null && matchedVo.getNetSalary() != null) { + vo1.setAllSalary(matchedVo.getNetSalary()); + } + } + } + } + + Map map = new HashMap<>(); + map.put("工程", salaryStatisticsTable); + map.put("分公司", salaryStatisticsSubComTable); + map.put("公司", salaryStatisticsComTable); + map.put("分包", salaryStatisticsSubTable); + return map; + } + +} diff --git a/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/WorkerStatisticsServiceImpl.java b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/WorkerStatisticsServiceImpl.java new file mode 100644 index 0000000..9911957 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/java/com/bonus/bmw/service/impl/WorkerStatisticsServiceImpl.java @@ -0,0 +1,24 @@ +package com.bonus.bmw.service.impl; + +import com.bonus.bmw.domain.po.HomePagePo; +import com.bonus.bmw.domain.vo.HomePageSubProVo; +import com.bonus.bmw.mapper.WorkerStatisticsMapper; +import com.bonus.bmw.service.WorkerStatisticsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class WorkerStatisticsServiceImpl implements WorkerStatisticsService { + + @Autowired + private WorkerStatisticsMapper mapper; + + + @Override + public List getWorkerStatisticsTable(HomePagePo o) { + return mapper.getWorkerStatisticsTable(o); + } + +} diff --git a/bonus-modules/bonus-bmw/src/main/resources/mapper/bmw/SalaryStatisticsMapper.xml b/bonus-modules/bonus-bmw/src/main/resources/mapper/bmw/SalaryStatisticsMapper.xml new file mode 100644 index 0000000..16caa95 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/resources/mapper/bmw/SalaryStatisticsMapper.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/bonus-bmw/src/main/resources/mapper/bmw/WorkerStatisticsMapper.xml b/bonus-modules/bonus-bmw/src/main/resources/mapper/bmw/WorkerStatisticsMapper.xml new file mode 100644 index 0000000..5a5d371 --- /dev/null +++ b/bonus-modules/bonus-bmw/src/main/resources/mapper/bmw/WorkerStatisticsMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + +