Compare commits

..

No commits in common. "dev" and "dev-aikai-开支日报导出" have entirely different histories.

22 changed files with 164 additions and 222 deletions

View File

@ -7,6 +7,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 开支日报分页 Request VO")
@Data
@NoArgsConstructor
@ -23,9 +25,6 @@ public class BpmOAExpensesPageReqVO extends PageParam {
@Schema(description = "费用类型 | 字典值参照bpm_oa_expenses_type")
private Integer type;
@Schema(description = "支付状态 | 0未支付 1已支付")
private Integer status;
@Schema(description = "费用板块 | 1叉车 2打包 3搬运 4运输")
private Integer costSection;

View File

@ -335,7 +335,6 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
costSectionMap.put(2, "打包");
costSectionMap.put(3, "搬运");
costSectionMap.put(4, "运输");
costSectionMap.put(5, "管理成本");
List<DictDataRespDTO> bpmOaExpensesType = dictDataApi.getDictDataList("bpm_oa_expenses_type").getCheckedData();
Map<String, String> typeMap = bpmOaExpensesType.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
List<BpmOAExpensesExportVO> vos = new ArrayList<>();

View File

@ -362,8 +362,6 @@ public class BpmOAReimbursementServiceImpl extends BpmOABaseService implements B
List<ReimbursementDTO> reimbursementDTOS = BeanUtils.toBean(reimbursements, ReimbursementDTO.class);
BpmOAReimbursementRespVO bpmOAReimbursementRespVO = BeanUtils.toBean(reimbursementDO, BpmOAReimbursementRespVO.class);
DeptRespDTO deptRespDTO = deptMap.get(reimbursementDO.getPaymentCompany());
bpmOAReimbursementRespVO.setPaymentCompanyName(deptRespDTO == null ? null : deptRespDTO.getName());
bpmOAReimbursementRespVO.setReimbursements(BpmOAReimbursementConvert.INSTANCE.convertList(reimbursementDTOS, deptMap)); //拼接数据
return bpmOAReimbursementRespVO;

View File

@ -29,6 +29,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
import cn.iocoder.yudao.module.bpm.convert.task.BpmProcessInstanceConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessCcDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;

View File

@ -40,9 +40,6 @@
<if test="pageReqVO.userId != null">
AND b.user_id = #{pageReqVO.userId}
</if>
<if test="pageReqVO.status != null">
AND b.status = #{pageReqVO.status}
</if>
<if test="pageReqVO.factoryId != null">
AND a.dept_id = #{pageReqVO.factoryId}
</if>

View File

@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProduc
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO;
@ -32,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -77,7 +77,7 @@ public class ErpStockOutController {
@Operation(summary = "更新其它出库单的状态")
@PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')")
public CommonResult<Boolean> updateStockOutStatus(@RequestParam("id") Long id,
@RequestParam("status") Integer status) {
@RequestParam("status") Integer status) {
stockOutService.updateStockOutStatus(id, status);
return success(true);
}
@ -103,16 +103,13 @@ public class ErpStockOutController {
List<ErpStockOutItemDO> stockOutItemList = stockOutService.getStockOutItemListByOutId(id);
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
Map<Long, AdminUserRespDTO> customerMap = adminUserApi.getUserMap(Collections.singletonList(stockOut.getCustomerId()));
return success(BeanUtils.toBean(stockOut, ErpStockOutRespVO.class, stockOutVO ->
stockOutVO.setItems(BeanUtils.toBean(stockOutItemList, ErpStockOutRespVO.Item.class, item -> {
ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId());
item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO);
MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()));
})).setCustomerName(customerMap.get(stockOut.getCustomerId()) != null ? customerMap.get(stockOut.getCustomerId()).getNickname() : null)
));
}))));
}
@GetMapping("/page")
@ -128,7 +125,7 @@ public class ErpStockOutController {
@PreAuthorize("@ss.hasPermission('erp:stock-out:export')")
public void exportStockOutExcel(@Valid ErpStockOutPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ErpStockOutRespVO> list = buildStockOutVOPageResult(stockOutService.getStockOutPage(pageReqVO)).getList();
// 导出 Excel
@ -147,7 +144,7 @@ public class ErpStockOutController {
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
// 1.3 客户信息
Map<Long, AdminUserRespDTO> customerMap = adminUserApi.getUserMap(
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId));
// 1.4 管理员信息
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
@ -158,7 +155,7 @@ public class ErpStockOutController {
item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()))));
stockOut.setProductNames(CollUtil.join(stockOut.getItems(), "", ErpStockOutRespVO.Item::getProductName));
MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getNickname()));
MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getName()));
MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname()));
});
}

View File

@ -6,7 +6,6 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@ -16,7 +15,6 @@ import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS;
@Schema(description = "管理后台 - ERP 其它出库单 Response VO")
@Data
@Accessors(chain = true)
@ExcelIgnoreUnannotated
public class ErpStockOutRespVO {
@ -109,4 +107,4 @@ public class ErpStockOutRespVO {
}
}
}

View File

@ -17,11 +17,11 @@ import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Collections;
@ -66,7 +66,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
// 1.1 校验出库项的有效性
List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(createReqVO.getItems());
// 1.2 校验客户
// customerService.validateCustomer(createReqVO.getCustomerId());
customerService.validateCustomer(createReqVO.getCustomerId());
// 1.3 生成出库单号并校验唯一性
String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_OUT_NO_PREFIX);
if (stockOutMapper.selectByNo(no) != null) {
@ -94,7 +94,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
throw exception(STOCK_OUT_UPDATE_FAIL_APPROVE, stockOut.getNo());
}
// 1.2 校验客户
// customerService.validateCustomer(updateReqVO.getCustomerId());
customerService.validateCustomer(updateReqVO.getCustomerId());
// 1.3 校验出库项的有效性
List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(updateReqVO.getItems());
@ -225,4 +225,4 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
return stockOutItemMapper.selectListByOutIds(outIds);
}
}
}

View File

@ -4,19 +4,23 @@ spring:
cloud:
nacos:
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
username: # Nacos 账号
password: # Nacos 密码
discovery: # 【配置中心】配置项
namespace: prod # 命名空间。这里使用 dev 开发环境
namespace: dev # 命名空间。这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
metadata:
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
config: # 【注册中心】配置项
namespace: prod # 命名空间。这里使用 dev 开发环境
namespace: dev # 命名空间。这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
--- #################### 数据库相关配置 ####################
spring:
# 数据源配置项
autoconfigure:
exclude:
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
datasource:
druid: # Druid 【监控】相关的全局配置
web-stat-filter:
@ -38,8 +42,8 @@ spring:
multi-statement-allow: true
dynamic: # 多数据源配置
druid: # Druid 【连接池】相关的全局配置
initial-size: 5 # 初始连接数
min-idle: 10 # 最小连接池数量
initial-size: 1 # 初始连接数
min-idle: 1 # 最小连接池数量
max-active: 20 # 最大连接池数量
max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
@ -69,9 +73,12 @@ spring:
database: 0 # 数据库索引
password: yhtkj@2024! # 密码,建议生产环境开启
--- #################### MQ 消息队列相关配置 ####################
--- #################### 定时任务相关配置 ####################
xxl:
job:
enabled: false # 是否开启调度中心,默认为 true 开启
admin:
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
--- #################### 服务保障相关配置 ####################
@ -99,11 +106,20 @@ spring:
instance:
service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME]
# 日志文件配置
logging:
level:
# 配置自己写的 MyBatis Mapper 打印日志
cn.iocoder.yudao.module.erp.dal.mysql: debug
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿先禁用Spring Boot 3.X 存在部分错误的 WARN 提示
--- #################### 芋道相关配置 ####################
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
env: # 多环境的配置项
tag: ${HOSTNAME}
security:
mock-enable: true
access-log: # 访问日志的配置项
enable: false
demo: false # 关闭演示模式

View File

@ -13,6 +13,3 @@ server:
logging:
file:
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
level:
# 配置自己写的 MyBatis Mapper 打印日志
cn.iocoder.yudao.module.erp.dal.mysql: debug

View File

@ -149,9 +149,8 @@ public class StaffAttendanceRecordController {
// 查询该厂区员工在 其他厂区得考勤记录
List<StaffAttendanceRecordDO> otherRecordDOS = staffAttendanceRecordService.getOtherRecord(reqVO);
// 获取工厂员工列表支持工种筛选
List<Integer> workTypeIds = reqVO.getWorkTypeId() != null ? Collections.singletonList(reqVO.getWorkTypeId()) : null;
List<StaffDO> staffDOS = staffService.getListByFactory(reqVO.getFactoryId(), true, workTypeIds);
// 获取工厂员工列表
List<StaffDO> staffDOS = staffService.getListByFactory(reqVO.getFactoryId(), true);
Map<Long, StaffDO> staffMap = convertMap(staffDOS, StaffDO::getId);
if (CollUtil.isNotEmpty(recordDOS)) {
@ -181,7 +180,7 @@ public class StaffAttendanceRecordController {
recordRespVO.addAll(otherRespVO);
return success(recordRespVO);
} else {
}else {
// 判断是否 新增考勤情况
if (reqVO.getFactoryId() != null && reqVO.getMonth() != null && reqVO.getType() != null) {
@ -197,7 +196,7 @@ public class StaffAttendanceRecordController {
.setStaffName(staffDO.getNickName())
.setWorkTypeId(staffDO.getWorkTypeId());
return success(Collections.singletonList(respVO));
} else {
}else {
List<StaffAttendanceRecordRespVO> respVO = staffDOS.stream()
.map(staffDO -> new StaffAttendanceRecordRespVO()
.setStaffId(staffDO.getId())
@ -221,7 +220,7 @@ public class StaffAttendanceRecordController {
@PreAuthorize("@ss.hasPermission('smartfactory:staff-attendance-record:export')")
@OperateLog(type = EXPORT)
public void exportStaffAttendanceRecordExcel(@Valid StaffAttendanceRecordReqVO reqVO,
HttpServletResponse response) throws IOException {
HttpServletResponse response) throws IOException {
List<StaffAttendanceRecordDO> recordDOS = staffAttendanceRecordService.getStaffAttendanceRecordList(reqVO);
// 导出 Excel
@ -240,4 +239,4 @@ public class StaffAttendanceRecordController {
staffAttendanceRecordService.updateReview(factoryId, month);
return success(true);
}
}
}

View File

@ -20,7 +20,4 @@ public class StaffAttendanceRecordReqVO {
@Schema(description = "考勤方式 | 1.正常月份 2.25号开始计算至下个月24号", example = "1")
private Integer type;
@Schema(description = "工种id", example = "1")
private Integer workTypeId;
}
}

View File

@ -142,15 +142,6 @@ public class FactoryInfoController {
return success(BeanUtils.toBean(factoryInfo, FactorySimpleRespVO.class));
}
@GetMapping("/factory-list-all")
@Operation(summary = "取登录用户工厂列表, 登陆用户无工厂则拉取所有工厂 | 用于前端下拉框 | 无工厂类型限制")
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
public CommonResult<List<FactorySimpleRespVO>> getFactoryALlListByLoginUser() {
List<FactoryInfoDO> factoryInfo = factoryInfoService.getFactoryALlListByLoginUser();
return success(BeanUtils.toBean(factoryInfo, FactorySimpleRespVO.class));
}
@GetMapping("/get-tree")
@Operation(summary = "获得工厂树结构")
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
@ -214,4 +205,4 @@ public class FactoryInfoController {
ExcelUtils.write(response, "工厂信息.xls", "数据", FactoryInfoRespVO.class,
BeanUtils.toBean(list, FactoryInfoRespVO.class));
}
}
}

View File

@ -34,14 +34,11 @@ public interface FactoryInfoMapper extends BaseMapperX<FactoryInfoDO> {
}
default List<FactoryInfoDO> selectListByType(List<Long> factoryId) {
return this.selectListByType(factoryId, Arrays.asList("2","3"));
}
default List<FactoryInfoDO> selectListByType(List<Long> factoryId, List<String> types) {
return selectList(new LambdaQueryWrapperX<FactoryInfoDO>()
.eq(FactoryInfoDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.inIfPresent(FactoryInfoDO::getId, factoryId)
.inIfPresent(FactoryInfoDO::getType, types));
.inIfPresent(FactoryInfoDO::getType, Arrays.asList(2,3)));
}
/**
@ -61,4 +58,4 @@ public interface FactoryInfoMapper extends BaseMapperX<FactoryInfoDO> {
List<FactoryProfitVO> selectProfit(@Param("factoryId") Long factoryId,
@Param("month") String month);
}
}

View File

@ -76,7 +76,7 @@ public interface StaffMapper extends BaseMapperX<StaffDO> {
query.eqIfPresent(StaffDO::getFactoryId, pageReqVO.getFactoryId());
query.eqIfPresent(StaffDO::getWorkTypeId, pageReqVO.getWorkTypeId());
query.eqIfPresent(StaffDO::getId, pageReqVO.getStaffId());
query.orderByDesc(StaffSalaryDO::getCreateTime);
return selectJoinPage(pageReqVO, StaffSalaryRespVO.class, query);
}

View File

@ -41,7 +41,7 @@ public interface StaffSalaryMapper extends BaseMapperX<StaffSalaryDO> {
query.eqIfPresent(StaffSalaryDO::getStatus, reqVO.getStatus());
query.eqIfPresent(StaffSalaryDO::getIsGrant, reqVO.getIsGrant());
query.apply(Objects.nonNull(reqVO.getWorkTypeId()), "staff.work_type_id = {0} ", reqVO.getWorkTypeId());
query.orderByDesc(StaffSalaryDO::getCreateTime);
return selectJoinPage(reqVO, StaffSalaryRespVO.class, query);
}
@ -60,4 +60,4 @@ public interface StaffSalaryMapper extends BaseMapperX<StaffSalaryDO> {
return selectJoinList(StaffSalaryRespVO.class, query);
}
}
}

View File

@ -124,7 +124,7 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
List<StaffAttendanceRecordDO> lastMonthRecord = staffAttendanceRecordMapper.selectList(new LambdaQueryWrapperX<StaffAttendanceRecordDO>()
.eq(StaffAttendanceRecordDO::getStaffId, staffId)
.betweenIfPresent(StaffAttendanceRecordDO::getPunchTime, new LocalDate[]{beginDate, lastMonthEnd}));
.betweenIfPresent(StaffAttendanceRecordDO::getPunchTime, new LocalDate[]{ beginDate, lastMonthEnd }));
recordDOS.addAll(lastMonthRecord);
}
@ -176,7 +176,7 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
// 获取查询月份得第25日日期
LocalDate lastMonthEnd = now.withDayOfMonth(25);
date = new LocalDate[]{beginDate, lastMonthEnd};
date = new LocalDate[]{ beginDate, lastMonthEnd };
}
return staffAttendanceRecordMapper.selectRecordList(reqVO, date);
}
@ -216,20 +216,48 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
public List<StaffAttendanceRecordRespVO> convertRecord(StaffAttendanceRecordReqVO reqVO,
List<StaffAttendanceRecordDO> recordDOS,
List<StaffAttendanceRecordDO> otherRecordDOS) {
// 根据考勤类型生成对应的日期列表
List<AttendanceRecordVO> punchTimeList = generatePunchTimeList(reqVO);
// 根据考勤类型 生成对应得日期数据
List<AttendanceRecordVO> punchTimeList = new ArrayList<>();
// 获取员工信息 - 在当前厂区打卡的员工信息
// 获取所选月份的第一天
LocalDate now = LocalDate.parse(reqVO.getMonth() + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
if (reqVO.getType() == 1) {
// 获取上月26日日期
LocalDate beginDate = now.minusMonths(1).withDayOfMonth(26);
// 本月25日日期
LocalDate lastMonthEnd = now.withDayOfMonth(25);
while (!beginDate.isAfter(lastMonthEnd)) {
AttendanceRecordVO attendanceRecordVO = new AttendanceRecordVO()
.setPunchTime(beginDate);
punchTimeList.add(attendanceRecordVO);
beginDate = beginDate.plusDays(1);
}
}
if (reqVO.getType() == 2) {
// 获取所选月份的第一天
LocalDate firstDayOfMonth = LocalDate.parse(reqVO.getMonth() + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
// 生成当月每一天的 LocalDate
for (int i = 0; i < firstDayOfMonth.lengthOfMonth(); i++) {
AttendanceRecordVO attendanceRecordVO = new AttendanceRecordVO()
.setPunchTime(firstDayOfMonth.plusDays(i));
punchTimeList.add(attendanceRecordVO);
}
}
// 获取员工信息
List<StaffDO> staffDOS = staffService.getList(convertSet(recordDOS, StaffAttendanceRecordDO::getStaffId));
Map<Long, StaffDO> staffMap = convertMap(staffDOS, StaffDO::getId);
// 获取厂区信息 - 获取员工所打卡的所有厂区ids - 获取所有厂区信息
// 获取厂区信息
Set<Long> factoryIds = convertSet(recordDOS, StaffAttendanceRecordDO::getFactoryId);
factoryIds.addAll(convertList(otherRecordDOS, StaffAttendanceRecordDO::getFactoryId));
List<FactoryInfoDO> factoryDOS = factoryInfoService.getFactoryList(factoryIds);
Map<Long, FactoryInfoDO> factoryMap = convertMap(factoryDOS, FactoryInfoDO::getId);
// 根据用户分组打卡记录
// 根据用户 分组打卡记录
Map<Long, List<StaffAttendanceRecordDO>> recordMap = convertMultiMap(recordDOS, StaffAttendanceRecordDO::getStaffId);
// 重组数据
@ -247,12 +275,10 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
reqVO.getType(),
reqVO.getMonth());
// 筛选同一个工厂打卡数据并按日期建立映射
Map<LocalDate, AttendanceRecordVO> records = entry.getValue().stream()
.filter(record -> record.getFactoryId().equals(reqVO.getFactoryId()))
.filter(record -> record.getFactoryId().equals(reqVO.getFactoryId())) // 筛选同一个工厂打卡数据
.map(item -> BeanUtils.toBean(item, AttendanceRecordVO.class))
.collect(Collectors.toMap(AttendanceRecordVO::getPunchTime, value -> value));
// 设置打卡数据
List<AttendanceRecordVO> recordVOS = punchTimeList.stream()
.map(record -> {
@ -263,16 +289,44 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
return recordVO;
}).collect(Collectors.toList());
respVO.setRecords(recordVOS);
// 设置员工名称工种厂区名称
StaffDO staffDO = staffMap.get(entry.getKey());
respVO.setStaffName(staffDO.getNickName());
respVO.setWorkTypeId(staffDO.getWorkTypeId());
// 设置员工名称
respVO.setStaffName(staffMap.get(entry.getKey()).getNickName());
// 设置工种
respVO.setWorkTypeId(staffMap.get(entry.getKey()).getWorkTypeId());
// 设置厂区名称
respVO.setFactoryName(factoryMap.get(reqVO.getFactoryId()) != null ? factoryMap.get(reqVO.getFactoryId()).getName() : null);
// 处理其他厂区的考勤记录
if (CollUtil.isNotEmpty(otherRecordDOS)) {
List<StaffAttendanceRecordRespVO> childRespVO = processOtherFactoryRecords(otherRecordDOS, staffMap, factoryMap);
// 获得该员工 在其他工厂的考勤记录
Map<Long, List<StaffAttendanceRecordDO>> factoryRecordMap = convertMultiMap(otherRecordDOS, StaffAttendanceRecordDO::getFactoryId);
List<StaffAttendanceRecordRespVO> childRespVO = otherRecordDOS.stream()
.map(recordDO -> new StaffAttendanceRecordRespVO(
recordDO.getStaffId(),
recordDO.getFactoryId(),
recordDO.getType(),
recordDO.getMonth()))
.distinct()
.collect(Collectors.toList());
childRespVO.forEach(vo -> {
if (!staffMap.containsKey(vo.getStaffId())) {
return;
}
// 设置员工名称
vo.setStaffName(staffMap.get(vo.getStaffId()).getNickName());
// 设置工种
vo.setWorkTypeId(staffMap.get(vo.getStaffId()).getWorkTypeId());
// 设置厂区名称
vo.setFactoryName(factoryMap.get(vo.getFactoryId()) != null ? factoryMap.get(vo.getFactoryId()).getName() : null);
if (factoryRecordMap.containsKey(vo.getFactoryId())) {
// 设置打卡记录
vo.setRecords(BeanUtils.toBean(factoryRecordMap.get(vo.getFactoryId()), AttendanceRecordVO.class));
}
});
// 插入其他考勤记录
respVO.setChildRecords(childRespVO);
}
@ -282,65 +336,4 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
return respVOs;
}
/**
* 根据考勤类型生成对应的日期列表
*/
private List<AttendanceRecordVO> generatePunchTimeList(StaffAttendanceRecordReqVO reqVO) {
List<AttendanceRecordVO> punchTimeList = new ArrayList<>();
LocalDate now = LocalDate.parse(reqVO.getMonth() + "-01", DateTimeFormatter.ISO_LOCAL_DATE);
if (reqVO.getType() == 1) {
LocalDate beginDate = now.minusMonths(1).withDayOfMonth(26);
LocalDate lastMonthEnd = now.withDayOfMonth(25);
while (!beginDate.isAfter(lastMonthEnd)) {
punchTimeList.add(new AttendanceRecordVO().setPunchTime(beginDate));
beginDate = beginDate.plusDays(1);
}
} else if (reqVO.getType() == 2) {
LocalDate firstDayOfMonth = now;
int lengthOfMonth = firstDayOfMonth.lengthOfMonth();
for (int i = 0; i < lengthOfMonth; i++) {
punchTimeList.add(new AttendanceRecordVO().setPunchTime(firstDayOfMonth.plusDays(i)));
}
}
return punchTimeList;
}
/**
* 处理其他厂区的考勤记录
*/
private List<StaffAttendanceRecordRespVO> processOtherFactoryRecords(List<StaffAttendanceRecordDO> otherRecordDOS,
Map<Long, StaffDO> staffMap,
Map<Long, FactoryInfoDO> factoryMap) {
Map<Long, List<StaffAttendanceRecordDO>> factoryRecordMap = convertMultiMap(otherRecordDOS, StaffAttendanceRecordDO::getFactoryId);
return otherRecordDOS.stream()
.map(recordDO -> new StaffAttendanceRecordRespVO(
recordDO.getStaffId(),
recordDO.getFactoryId(),
recordDO.getType(),
recordDO.getMonth()))
.distinct()
.peek(vo -> {
if (staffMap.containsKey(vo.getStaffId())) {
StaffDO staffDO = staffMap.get(vo.getStaffId());
vo.setStaffName(staffDO.getNickName());
vo.setWorkTypeId(staffDO.getWorkTypeId());
if (factoryMap.containsKey(vo.getFactoryId())) {
vo.setFactoryName(factoryMap.get(vo.getFactoryId()).getName());
}
if (factoryRecordMap.containsKey(vo.getFactoryId())) {
vo.setRecords(BeanUtils.toBean(factoryRecordMap.get(vo.getFactoryId()), AttendanceRecordVO.class));
}
}
})
.filter(vo -> staffMap.containsKey(vo.getStaffId()))
.collect(Collectors.toList());
}
}
}

View File

@ -164,10 +164,4 @@ public interface FactoryInfoService {
* @return 工厂列表
*/
List<FactoryInfoDO> getList();
/**
* 取登录用户工厂列表, 登陆用户无工厂则拉取所有工厂 | 用于前端下拉框 | 无工厂类型限制
* @return
*/
List<FactoryInfoDO> getFactoryALlListByLoginUser();
}

View File

@ -9,10 +9,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.ip.core.Area;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryProfitVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryUpdateStatusReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.*;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.FactoryRollDataRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.ProvincesDataRespVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
@ -26,7 +23,6 @@ import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespD
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -36,8 +32,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTORY_INFO_NOT_EXISTS;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTOYRY_EXISTS_STAFF;
@ -47,7 +42,6 @@ import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACT
*
* @author 姚君
*/
@Slf4j
@Service
@Validated
public class FactoryInfoServiceImpl implements FactoryInfoService {
@ -245,7 +239,27 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
@Override
public List<FactoryInfoDO> getFactoryListByAuthority() {
List<Long> factoryIds = this.getFactoryIdsByUserId(getLoginUserId());
List<Long> factoryIds = new ArrayList<>();
DeptDataPermissionRespDTO deptDataPermission = permissionApi.getDeptDataPermission(getLoginUserId()).getCheckedData();
// 如果当前登录用户数据权限 不是查看全部数据
if (!deptDataPermission.getAll()) {
// 获取自己所在工厂
DeptRespDTO respDTO = deptApi.getDept(userApi.getUser(getLoginUserId()).getCheckedData().getDeptId()).getCheckedData();
if (respDTO != null && respDTO.getFactoryId() != null) {
factoryIds.add(respDTO.getFactoryId());
}
// 查找担任负责人的工厂信息
List<DeptRespDTO> deptRespDTO = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
if (deptRespDTO != null) {
factoryIds.addAll(convertList(deptRespDTO, DeptRespDTO::getFactoryId));
}
}
return factoryInfoMapper.selectListByType(factoryIds);
}
@ -305,19 +319,19 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
// 获取打包扣款明细
List<SettlementItemDTO.Deduction> packageDeduction = item.stream()
.filter(data -> data.getBusinessType() == 1)
.flatMap(data -> data.getDeductionItems().stream())
.flatMap( data -> data.getDeductionItems().stream())
.collect(Collectors.toList());
// 获取叉车扣款明细
List<SettlementItemDTO.Deduction> forkliftDeduction = item.stream()
.filter(data -> data.getBusinessType() == 2)
.flatMap(data -> data.getDeductionItems().stream())
.flatMap( data -> data.getDeductionItems().stream())
.collect(Collectors.toList());
// 获取搬运扣款明细
List<SettlementItemDTO.Deduction> porterageDeduction = item.stream()
.filter(data -> data.getBusinessType() == 3)
.flatMap(data -> data.getDeductionItems().stream())
.flatMap( data -> data.getDeductionItems().stream())
.collect(Collectors.toList());
// 设置打包扣款
@ -326,7 +340,7 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
vo.setForkliftDeductionItem(getDeduction(forkliftDeduction));
// 设置搬运扣款
vo.setPorterageDeductionItem(getDeduction(porterageDeduction));
} else {
}else {
// 设置打包扣款
vo.setPackageDeductionItem(getDeduction(null));
// 设置叉车扣款
@ -378,14 +392,14 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
}
return deduction;
}
}
@Override
public List<FactoryInfoDO> getCompanyFactoryList() {
return factoryInfoMapper.selectList(new LambdaQueryWrapperX<FactoryInfoDO>()
.eq(FactoryInfoDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.in(FactoryInfoDO::getType, Arrays.asList(0, 1)));
.in(FactoryInfoDO::getType, Arrays.asList(0,1)));
}
@Override
@ -416,38 +430,4 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
.eq(FactoryInfoDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.orderByAsc(FactoryInfoDO::getType));
}
@Override
public List<FactoryInfoDO> getFactoryALlListByLoginUser() {
List<Long> factoryIds = this.getFactoryIdsByUserId(getLoginUserId());
return factoryInfoMapper.selectListByType(factoryIds, null);
}
/**
* 根据当前登录用户获取到工厂ID - {获取当前登录用户所在部门 - 根据所在部门找到所对应的工厂(如果所在部门没有工厂则全部) 返回对应工厂id}
*
* @param userId
* @return
*/
public List<Long> getFactoryIdsByUserId(Long userId) {
List<Long> factoryIds = new ArrayList<>();
DeptDataPermissionRespDTO deptDataPermission = permissionApi.getDeptDataPermission(userId).getCheckedData();
// 如果当前登录用户数据权限 不是查看全部数据
if (!deptDataPermission.getAll()) {
// 获取自己所在工厂
DeptRespDTO respDTO = deptApi.getDept(userApi.getUser(userId).getCheckedData().getDeptId()).getCheckedData();
if (respDTO != null && respDTO.getFactoryId() != null) {
factoryIds.add(respDTO.getFactoryId());
}
// 查找担任负责人的工厂信息
List<DeptRespDTO> deptRespDTO = deptApi.getDeptByLeaderId(userId).getCheckedData();
if (deptRespDTO != null) {
factoryIds.addAll(convertList(deptRespDTO, DeptRespDTO::getFactoryId));
}
}
return factoryIds;
}
}

View File

@ -92,8 +92,6 @@ public interface StaffService {
*/
List<StaffDO> getListByFactory(Long factoryId, Boolean isIn);
List<StaffDO> getListByFactory(Long factoryId, Boolean isIn, List<Integer> workTypeIds);
/**
* 获取指定厂区得员工列表
*

View File

@ -250,16 +250,10 @@ public class StaffServiceImpl implements StaffService {
@Override
public List<StaffDO> getListByFactory(Long factoryId, Boolean isIn) {
return this.getListByFactory(factoryId, isIn, null);
}
@Override
public List<StaffDO> getListByFactory(Long factoryId, Boolean isIn, List<Integer> workTypeIds) {
return staffMapper.selectList(new LambdaQueryWrapperX<StaffDO>()
.eq(isIn, StaffDO::getFactoryId, factoryId)
.ne(!isIn, StaffDO::getFactoryId, factoryId)
.ne(StaffDO::getStatus, 0)
.in(CollUtil.isNotEmpty(workTypeIds), StaffDO::getWorkTypeId, workTypeIds));
.ne(StaffDO::getStatus, 0));
}
@Override

View File

@ -111,7 +111,7 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
if (pageReqVO.getMonth() != null && pageReqVO.getStatus() == null) {
return staffMapper.selectSalaryPage(pageReqVO);
} else {
}else {
return staffSalaryMapper.selectSalaryPage(pageReqVO);
}
}
@ -154,7 +154,7 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
firstDayOfMonth.minusMonths(1).withDayOfMonth(26),
firstDayOfMonth.withDayOfMonth(25)
};
} else if (type == 2) {
}else if (type == 2) {
date = new LocalDate[]{
firstDayOfMonth,
@ -213,12 +213,10 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
// 设置扣款明细 默认扣除保险 50元
salaryDO.setDeductionItems(Collections.singletonList(
new DeductionItemsVO()
.setKey("insurance")
.setValue("50")
));
// 设置扣款金额
salaryDO.setDeductionAmount(BigDecimal.valueOf(50));
new DeductionItemsVO()
.setKey("insurance")
.setValue("50")
));
// 计算应发工资
BigDecimal salary = staffDO.getSalary();
@ -228,14 +226,14 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
// 设置应发工资
salaryDO.setPayableAmount(salary);
// 设置实发工资
salaryDO.setRealAmount(salary.subtract(salaryDO.getDeductionAmount()));
salaryDO.setRealAmount(salary.subtract(BigDecimal.valueOf(50)));
} else {
BigDecimal payableAmount = salary.divide(BigDecimal.valueOf(workDays), 0, RoundingMode.DOWN)
.multiply(BigDecimal.valueOf(salaryDO.getAttendanceDays()));
// 设置应发工资
salaryDO.setPayableAmount(payableAmount);
// 设置实发工资
salaryDO.setRealAmount(payableAmount.subtract(salaryDO.getDeductionAmount()));
salaryDO.setRealAmount(payableAmount.subtract(BigDecimal.valueOf(50)));
}
// 设置薪资主体数据
@ -264,10 +262,9 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
.setId(id)
.setIsGrant(isGrant))
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(salaryDOS)) {
// 更新
staffSalaryMapper.updateBatch(salaryDOS);
}
// 更新
staffSalaryMapper.updateBatch(salaryDOS);
}
@Override
@ -303,4 +300,4 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
return salaryTotalVO;
}
}
}