考勤优化
This commit is contained in:
@ -0,0 +1,160 @@
|
||||
package org.dromara.cailiaoshebei.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo;
|
||||
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
|
||||
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
|
||||
import org.dromara.cailiaoshebei.domain.vo.BusMrpBaseVo;
|
||||
import org.dromara.cailiaoshebei.domain.vo.BusMrpVo;
|
||||
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.enums.BusinessStatusEnum;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.design.domain.BusBillofquantities;
|
||||
import org.dromara.design.domain.BusBillofquantitiesVersions;
|
||||
import org.dromara.design.domain.bo.CoryObtainTheListReq;
|
||||
import org.dromara.design.domain.bo.ObtainAllVersionNumbersReq;
|
||||
import org.dromara.design.domain.vo.BusBillofquantitiesVo;
|
||||
import org.dromara.design.domain.vo.ObtainTheListRes;
|
||||
import org.dromara.design.service.IBusBillofquantitiesService;
|
||||
import org.dromara.design.service.IBusBillofquantitiesVersionsService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* app物资-批次需求计划基础信息
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-13
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/cailiaoshebei/mrpBase")
|
||||
public class BusMrpBaseAppController extends BaseController {
|
||||
|
||||
private final IBusMrpBaseService busMrpBaseService;
|
||||
|
||||
private final IBusBillofquantitiesVersionsService busBillofquantitiesVersionsService;
|
||||
|
||||
private final IBusBillofquantitiesService busBillofquantitiesService;
|
||||
|
||||
/**
|
||||
* 查询物资-批次需求计划基础信息列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BusMrpBaseVo> list(BusMrpBaseBo bo, PageQuery pageQuery) {
|
||||
return busMrpBaseService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取物资-批次需求计划基础信息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<BusMrpVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(busMrpBaseService.queryById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除物资-批次需求计划基础信息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@Log(title = "物资-批次需求计划基础信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(busMrpBaseService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增或修改
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/batch")
|
||||
public R<Void> batchAddOrUpdate(@RequestBody BusMrpDto dto) {
|
||||
return toAjax(busMrpBaseService.batchAddOrUpdate(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取剩余量
|
||||
*/
|
||||
@GetMapping("/remaining")
|
||||
public R<Map<String,Object>> remaining(Long projectId, String suppliespriceName,String specification,Long mrpBaseId) {
|
||||
return R.ok(busMrpBaseService.remaining(projectId,suppliespriceName,specification,mrpBaseId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有大类
|
||||
*/
|
||||
@GetMapping("/obtainAllClassification")
|
||||
public R<List<BusBillofquantitiesVo>> obtainAllClassification(ObtainAllVersionNumbersReq bo) {
|
||||
return R.ok(busBillofquantitiesVersionsService.obtainAllClassification(bo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取工程量清单列表
|
||||
*/
|
||||
@GetMapping("/coryEngineeringList")
|
||||
public R<List<BusBillofquantities>> obtainTheList(CoryObtainTheListReq req) {
|
||||
List<BusBillofquantities> busBillofquantities = busBillofquantitiesService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<BusBillofquantities>()
|
||||
.eq(BusBillofquantities::getProjectId, req.getProjectId())
|
||||
.eq(BusBillofquantities::getName, req.getSid()));
|
||||
List<String> sids = new ArrayList<>();
|
||||
busBillofquantities.forEach(busBillofquantities1 -> {
|
||||
sids.add(busBillofquantities1.getSid());
|
||||
});
|
||||
return R.ok(busBillofquantitiesService
|
||||
.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<BusBillofquantities>()
|
||||
.eq(BusBillofquantities::getProjectId, req.getProjectId())
|
||||
.in(BusBillofquantities::getPid, sids)));
|
||||
}
|
||||
|
||||
private List<ObtainTheListRes> buildTree(String parentId, Map<String, List<ObtainTheListRes>> parentMap) {
|
||||
// 获取当前父节点的所有直接子节点
|
||||
List<ObtainTheListRes> children = parentMap.getOrDefault(parentId, Collections.emptyList());
|
||||
if (children.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 为每个子节点递归设置其下一级子节点
|
||||
for (ObtainTheListRes child : children) {
|
||||
// 递归查询当前子节点的子节点,设置为它的子树
|
||||
List<ObtainTheListRes> subChildren = buildTree(child.getSid(), parentMap);
|
||||
// 注意:需要在Vo中添加子节点列表字段,用于存储子树
|
||||
child.setChildren(subChildren);
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,214 @@
|
||||
package org.dromara.cailiaoshebei.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation;
|
||||
import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo;
|
||||
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
|
||||
import org.dromara.cailiaoshebei.domain.bo.FeedbackDto;
|
||||
import org.dromara.cailiaoshebei.domain.vo.BusMaterialbatchdemandplanVo;
|
||||
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
|
||||
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
|
||||
import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService;
|
||||
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.design.service.IBusBillofquantitiesService;
|
||||
import org.dromara.design.service.IBusBillofquantitiesVersionsService;
|
||||
import org.dromara.tender.domain.bo.TenderSupplierInputBo;
|
||||
import org.dromara.tender.domain.vo.TenderSupplierInputVo;
|
||||
import org.dromara.tender.service.ITenderSupplierInputService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* app物资-采购联系单
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-13
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/cailiaoshebei/purchaseDoc")
|
||||
public class BusPurchaseDocAppController extends BaseController {
|
||||
|
||||
private final IBusPurchaseDocService busPurchaseDocService;
|
||||
|
||||
private final IBusMaterialbatchdemandplanService materialbatchdemandplanService;
|
||||
|
||||
private final IBusPlanDocAssociationService planDocAssociationService;
|
||||
|
||||
private final IBusBillofquantitiesVersionsService busBillofquantitiesVersionsService;
|
||||
|
||||
private final IBusBillofquantitiesService busBillofquantitiesService;
|
||||
|
||||
private final ITenderSupplierInputService tenderSupplierInputService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询物资-采购联系单列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<BusPurchaseDocVo> list(BusPurchaseDocBo bo, PageQuery pageQuery) {
|
||||
return busPurchaseDocService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询供应商入库列表
|
||||
*/
|
||||
@GetMapping("/supList")
|
||||
public TableDataInfo<TenderSupplierInputVo> list(TenderSupplierInputBo bo, PageQuery pageQuery) {
|
||||
return tenderSupplierInputService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物资-批次需求计划列表
|
||||
*/
|
||||
@GetMapping("/planList")
|
||||
public TableDataInfo<BusMaterialbatchdemandplanVo> list(BusMaterialbatchdemandplanBo bo, PageQuery pageQuery) {
|
||||
return materialbatchdemandplanService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取物资-采购联系单详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<BusPurchaseDocVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(busPurchaseDocService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取物资-采购联系单详细PDF
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:purchaseDoc:pdf")
|
||||
@GetMapping("/pdf/{id}")
|
||||
public R<String> getPic(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok("操作成功", busPurchaseDocService.queryPicBase64ById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增物资-采购联系单
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:purchaseDoc:add")
|
||||
@Log(title = "物资-采购联系单", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody BusPurchaseDocBo bo) {
|
||||
return toAjax(busPurchaseDocService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改物资-采购联系单
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:purchaseDoc:edit")
|
||||
@Log(title = "物资-采购联系单", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusPurchaseDocBo bo) {
|
||||
return toAjax(busPurchaseDocService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物资-采购联系单
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:purchaseDoc:remove")
|
||||
@Log(title = "物资-采购联系单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(busPurchaseDocService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询采购单关联的计划
|
||||
*/
|
||||
@GetMapping("/planList/{id}")
|
||||
public R<List<BusMaterialbatchdemandplanVo>> list(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
|
||||
.eq(BusPlanDocAssociation::getDocId, id));
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return R.ok(new ArrayList<>());
|
||||
}
|
||||
Map<Long, BigDecimal> collect = list.stream()
|
||||
.filter(Objects::nonNull) // 过滤空对象
|
||||
.collect(Collectors.toMap(
|
||||
BusPlanDocAssociation::getPlanId,
|
||||
BusPlanDocAssociation::getDemandQuantity,
|
||||
(existing, replacement) -> existing // 保留第一个遇到的重复键
|
||||
));
|
||||
BusMaterialbatchdemandplanBo bo = new BusMaterialbatchdemandplanBo();
|
||||
bo.setIds(new ArrayList<>(collect.keySet()));
|
||||
List<BusMaterialbatchdemandplanVo> busMaterialbatchdemandplanVos = materialbatchdemandplanService.queryList(bo);
|
||||
for (BusMaterialbatchdemandplanVo busMaterialbatchdemandplanVo : busMaterialbatchdemandplanVos) {
|
||||
busMaterialbatchdemandplanVo.setDemandQuantity(collect.get(busMaterialbatchdemandplanVo.getId()));
|
||||
}
|
||||
return R.ok(busMaterialbatchdemandplanVos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改回单
|
||||
*/
|
||||
@Log(title = "物资-采购联系单", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/updateFeedback")
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FeedbackDto bo) {
|
||||
return toAjax(busPurchaseDocService.updateFeedback(bo));
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 获取工程量清单列表
|
||||
// */
|
||||
// @SaCheckPermission("cailiaoshebei:purchaseDoc:add")
|
||||
// @GetMapping("/engineeringList")
|
||||
// public R<List<BusBillofquantities>> obtainTheList(Long projectId) {
|
||||
// BusBillofquantitiesVersions one = busBillofquantitiesVersionsService.getOne(Wrappers.<BusBillofquantitiesVersions>lambdaQuery()
|
||||
// .eq(BusBillofquantitiesVersions::getWorkOrderType, "3") //物资工程量清单
|
||||
// .eq(BusBillofquantitiesVersions::getProjectId, projectId)
|
||||
// .eq(BusBillofquantitiesVersions::getStatus, BusinessStatusEnum.FINISH.getStatus())
|
||||
// .last("limit 1")
|
||||
// );
|
||||
// if (one == null) {
|
||||
// throw new ServiceException("请先完成物资工程量清单");
|
||||
// }
|
||||
// List<BusBillofquantities> list = busBillofquantitiesService.list(Wrappers.<BusBillofquantities>lambdaQuery()
|
||||
// .eq(BusBillofquantities::getVersions, one.getVersions())
|
||||
// );
|
||||
//
|
||||
// return R.ok(list);
|
||||
// }
|
||||
}
|
||||
@ -76,6 +76,8 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.ATTENDANCE_LIST;
|
||||
|
||||
/**
|
||||
* 施工人员Service业务层处理
|
||||
*
|
||||
@ -1194,8 +1196,11 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
|
||||
unClockDays++;
|
||||
}
|
||||
}
|
||||
if(ATTENDANCE_LIST.contains(clockInStatus) || ATTENDANCE_LIST.contains(clockOutStatus)){
|
||||
attendanceDays++;
|
||||
}
|
||||
|
||||
}
|
||||
attendanceDays = dailyMap.size() - leaveDays;
|
||||
}
|
||||
}
|
||||
constructionUserAttendanceTotalResp.setAttendanceDays(attendanceDays);
|
||||
|
||||
@ -353,6 +353,9 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
|
||||
lqw.eq(BusBillofquantitiesVersions::getWorkOrderType, "3");
|
||||
lqw.eq(BusBillofquantitiesVersions::getStatus, BusinessStatusEnum.FINISH.getStatus());
|
||||
List<BusBillofquantitiesVersionsVo> result = baseMapper.selectVoList(lqw);
|
||||
if (CollUtil.isEmpty(result)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> versionss = new ArrayList<>();
|
||||
result.forEach(v -> versionss.add(v.getVersions()));
|
||||
List<BusBillofquantities> busBillofquantities = busBillofquantitiesService.getBaseMapper().selectList(new LambdaQueryWrapper<BusBillofquantities>()
|
||||
|
||||
@ -114,11 +114,20 @@ public class BusAttendanceController extends BaseController {
|
||||
return toAjax(busAttendanceService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询项目施工人员前14天考勤状况
|
||||
*/
|
||||
@GetMapping("/list/clockDate/twoWeek")
|
||||
public R<List<BusAttendanceClockDateForTwoWeekVo>> getClockDateForTwoWeekList(Long projectId) {
|
||||
return R.ok(busAttendanceService.getClockDateForTwoWeekList(projectId));
|
||||
}
|
||||
/**
|
||||
* 查询项目施工人员当天考勤状况
|
||||
*/
|
||||
@GetMapping("/list/clockDate/today")
|
||||
public R<BusAttendanceClockDateForTwoWeekVo> getTodayAttendanceData(Long projectId) {
|
||||
return R.ok(busAttendanceService.getTodayAttendanceData(projectId));
|
||||
}
|
||||
|
||||
@PostMapping("/exportList")
|
||||
public void exportList(AttendanceExportDto dto, HttpServletResponse response) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.project.controller.app;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -128,8 +129,8 @@ public class BusAttendanceAppController extends BaseController {
|
||||
* 获取用户打卡异常记录
|
||||
*/
|
||||
@GetMapping("/getAbnormalAttendance/{projectId}")
|
||||
public R<List<BusAttendanceVo>> getAbnormalAttendance(@NotNull @PathVariable("projectId") Long projectId){
|
||||
return R.ok(attendanceService.getAbnormalAttendance(projectId));
|
||||
public TableDataInfo<BusAttendanceVo> getAbnormalAttendance(@NotNull @PathVariable("projectId") Long projectId, PageQuery pageQuery){
|
||||
return attendanceService.getAbnormalAttendance(projectId,pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,6 +2,8 @@ package org.dromara.project.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025/4/7 11:31
|
||||
@ -9,6 +11,8 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum BusAttendanceClockStatusEnum {
|
||||
|
||||
|
||||
|
||||
NORMAL("正常", "1"),
|
||||
LATE("迟到", "2"),
|
||||
LEAVEEARLY("早退", "3"),
|
||||
@ -24,5 +28,7 @@ public enum BusAttendanceClockStatusEnum {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
//算出勤状态
|
||||
public static final List<String> ATTENDANCE_LIST = List.of(NORMAL.value, LATE.value, LEAVEEARLY.value, REISSUE.value);
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package org.dromara.project.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.project.domain.dto.attendance.*;
|
||||
import org.dromara.project.domain.vo.BusAttendanceVo;
|
||||
import org.dromara.project.domain.bo.BusAttendanceBo;
|
||||
@ -13,12 +13,9 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.project.domain.vo.BusMonthAttendanceVo;
|
||||
import org.dromara.project.domain.vo.attendance.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -132,9 +129,9 @@ public interface IBusAttendanceService extends IService<BusAttendance>{
|
||||
List<BusMonthAttendanceVo> getMonthAttendance(Long projectId, String month);
|
||||
|
||||
/**
|
||||
* 获取用户指定月份的打卡记录
|
||||
* 获取用户打卡异常记录
|
||||
*/
|
||||
List<BusAttendanceVo> getAbnormalAttendance(@NotNull @PathVariable("projectId") Long projectId);
|
||||
TableDataInfo<BusAttendanceVo> getAbnormalAttendance(@NotNull @PathVariable("projectId") Long projectId, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 统计指定日期的打卡人员
|
||||
@ -167,6 +164,11 @@ public interface IBusAttendanceService extends IService<BusAttendance>{
|
||||
*/
|
||||
List<BusAttendanceClockDateForTwoWeekVo> getClockDateForTwoWeekList(Long projectId);
|
||||
|
||||
/**
|
||||
* 获取项目当天的考勤数据
|
||||
*/
|
||||
BusAttendanceClockDateForTwoWeekVo getTodayAttendanceData(Long projectId);
|
||||
|
||||
/**
|
||||
* 获取导出的考勤数据
|
||||
*/
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -14,7 +15,6 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
@ -64,6 +64,8 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.project.domain.enums.BusAttendanceClockStatusEnum.ATTENDANCE_LIST;
|
||||
|
||||
/**
|
||||
* 考勤Service业务层处理
|
||||
*
|
||||
@ -707,7 +709,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
|
||||
@Override
|
||||
public List<BusAttendanceVo> getAbnormalAttendance(Long projectId) {
|
||||
public TableDataInfo<BusAttendanceVo> getAbnormalAttendance(Long projectId, PageQuery pageQuery) {
|
||||
|
||||
List<String> abnormalList = Arrays.asList(BusAttendanceClockStatusEnum.LATE.getValue(),
|
||||
BusAttendanceClockStatusEnum.LEAVEEARLY.getValue(),
|
||||
@ -722,16 +724,16 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
boolean b = relevancyList.stream().allMatch(relevancy -> "1".equals(relevancy.getUserType()));
|
||||
|
||||
List<BusAttendanceVo> busAttendanceVos = baseMapper.selectVoList(Wrappers.lambdaQuery(BusAttendance.class)
|
||||
IPage<BusAttendanceVo> busAttendanceVoIPage = baseMapper.selectVoPage(pageQuery.build(), Wrappers.lambdaQuery(BusAttendance.class)
|
||||
.eq(BusAttendance::getUserId, userId)
|
||||
.eq(b, BusAttendance::getProjectId, projectId)
|
||||
.in(BusAttendance::getClockStatus, abnormalList)
|
||||
);
|
||||
//转换星期几
|
||||
for (BusAttendanceVo busAttendanceVo : busAttendanceVos) {
|
||||
for (BusAttendanceVo busAttendanceVo : busAttendanceVoIPage.getRecords()) {
|
||||
busAttendanceVo.setWeek(busAttendanceVo.getClockDate().getDayOfWeek().getValue());
|
||||
}
|
||||
return busAttendanceVos;
|
||||
return TableDataInfo.build(busAttendanceVoIPage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1183,7 +1185,6 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
// 统计全勤、半勤、缺卡人数
|
||||
List<BusAttendanceClockDateForTwoWeekVo> result = new ArrayList<>();
|
||||
List<String> validStatusList = Arrays.asList("1", "2", "3", "5");
|
||||
|
||||
LocalDate currentDate = startDate;
|
||||
while (!currentDate.isAfter(now)) {
|
||||
@ -1196,7 +1197,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
|
||||
long validCount = records.stream()
|
||||
.map(BusAttendance::getClockStatus)
|
||||
.filter(validStatusList::contains)
|
||||
.filter(ATTENDANCE_LIST::contains)
|
||||
.count();
|
||||
|
||||
if (validCount >= 2) {
|
||||
@ -1228,6 +1229,65 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BusAttendanceClockDateForTwoWeekVo getTodayAttendanceData(Long projectId) {
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
|
||||
//查询所有管理员和分包人员 排除
|
||||
List<Long> excludeUserIds = constructionUserService.list(Wrappers.<SubConstructionUser>lambdaQuery()
|
||||
.ne(SubConstructionUser::getUserRole, "0")
|
||||
).stream().map(SubConstructionUser::getSysUserId).toList();
|
||||
|
||||
List<Long> allUserIds = constructionUserService.list(Wrappers.<SubConstructionUser>lambdaQuery()
|
||||
.eq(SubConstructionUser::getUserRole, "0")
|
||||
.eq(SubConstructionUser::getProjectId,projectId)
|
||||
).stream().map(SubConstructionUser::getSysUserId).toList();
|
||||
|
||||
|
||||
List<BusAttendance> list = list(Wrappers.<BusAttendance>lambdaQuery()
|
||||
.eq(BusAttendance::getProjectId, projectId)
|
||||
.notIn(CollectionUtil.isNotEmpty(excludeUserIds),BusAttendance::getUserId, excludeUserIds)
|
||||
.eq(BusAttendance::getClockDate, now)
|
||||
.orderByAsc(BusAttendance::getClockDate)
|
||||
);
|
||||
|
||||
Map<Long, List<BusAttendance>> collect = list.stream().collect(Collectors.groupingBy(BusAttendance::getUserId));
|
||||
|
||||
int full = 0, half = 0, absent = 0;
|
||||
|
||||
for (Map.Entry<Long, List<BusAttendance>> userEntry : collect.entrySet()) {
|
||||
List<BusAttendance> records = userEntry.getValue();
|
||||
|
||||
long validCount = records.stream()
|
||||
.map(BusAttendance::getClockStatus)
|
||||
.filter(ATTENDANCE_LIST::contains)
|
||||
.count();
|
||||
|
||||
if (validCount >= 2) {
|
||||
full++;
|
||||
} else if (validCount == 1) {
|
||||
half++;
|
||||
} else {
|
||||
absent++;
|
||||
}
|
||||
}
|
||||
|
||||
BusAttendanceClockDateForTwoWeekVo vo = new BusAttendanceClockDateForTwoWeekVo();
|
||||
vo.setClockDate(now);
|
||||
vo.setAttendance(full);
|
||||
vo.setHalfAttendance(half);
|
||||
vo.setAbsenteeism(absent);
|
||||
//计算考勤率
|
||||
vo.setAllUserNum(allUserIds.size());
|
||||
vo.setClockNum(full+half);
|
||||
vo.setAttendanceRate(BigDecimalUtil.toPercentage(new BigDecimal(full+half),
|
||||
new BigDecimal(allUserIds.size())));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getExportList(AttendanceExportDto dto, HttpServletResponse response) {
|
||||
try (OutputStream outputStream = response.getOutputStream()) {
|
||||
|
||||
@ -25,6 +25,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.dromara.workflow.listener.WorkflowGlobalListener.getType;
|
||||
|
||||
@ConditionalOnEnable
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@ -48,7 +50,8 @@ public class FlowAppController {
|
||||
}
|
||||
|
||||
List<FlowHisTaskVo> list= (List<FlowHisTaskVo>) stringObjectMap.get("list");
|
||||
Map<String, FlowHisTaskVo> map = list.stream().collect(Collectors.toMap(FlowHisTaskVo::getNodeCode, vo -> vo));
|
||||
Map<String, FlowHisTaskVo> map = list.stream().filter(vo -> !"copy".equals(vo.getFlowStatus()))
|
||||
.collect(Collectors.toMap(FlowHisTaskVo::getNodeCode, vo -> vo));
|
||||
|
||||
|
||||
Long instanceId = (Long) stringObjectMap.get("instanceId");
|
||||
@ -86,9 +89,24 @@ public class FlowAppController {
|
||||
appVo.setFlowStatus(BusinessStatusEnum.WAITING.getStatus());
|
||||
if(nodeJson.getNodeType()==1){
|
||||
String permissionFlag = nodeJson.getPermissionFlag();
|
||||
if(StrUtil.isNotBlank(permissionFlag)){
|
||||
permissionFlag = permissionFlag.replace("@@", ",");
|
||||
}
|
||||
List<UserDTO> userDTOS = flwTaskAssigneeService.fetchUsersByStorageIds(permissionFlag, projectId);
|
||||
String auditName = userDTOS.stream().map(UserDTO::getNickName).collect(Collectors.joining(","));
|
||||
appVo.setAuditName(auditName);
|
||||
String type = getType(permissionFlag);
|
||||
if(type != null){
|
||||
try {
|
||||
String flowCode = defJson.getFlowCode();
|
||||
List<String> longs = userService.selectUserByProfession(flowCode.split("_")[1], businessId, type,projectId);
|
||||
String s = userService.selectNicknameByIds(longs.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||
appVo.setAuditName(s);
|
||||
}catch (Exception e) {
|
||||
appVo.setAuditName(auditName);
|
||||
}
|
||||
}else {
|
||||
appVo.setAuditName(auditName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ public class WorkflowGlobalListener implements GlobalListener {
|
||||
}
|
||||
|
||||
|
||||
public String getType(String permissionFlag){
|
||||
public static String getType(String permissionFlag){
|
||||
// 1961314792461586433 校审员(系统)
|
||||
// 1961315028017893378 审核员(系统)
|
||||
// 1961315147199041537 审定员(系统)
|
||||
|
||||
Reference in New Issue
Block a user