Compare commits
2 Commits
52fc51c738
...
32cc7a4f65
Author | SHA1 | Date | |
---|---|---|---|
![]() |
32cc7a4f65 | ||
![]() |
3aef43868f |
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOARei
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.BpmOAReimbursementRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReimbursementDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAReimbursementService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.ProjectApi;
|
||||
import cn.iocoder.yudao.module.system.api.project.dto.ProjectDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -37,6 +38,9 @@ public class BpmOAReimbursementController {
|
||||
@Resource
|
||||
private ProjectApi projectApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
// @PreAuthorize("@ss.hasPermission('bpm:oa-reimbursement:create')")
|
||||
@Operation(summary = "创建请求申请")
|
||||
@ -52,10 +56,16 @@ public class BpmOAReimbursementController {
|
||||
|
||||
BpmOAReimbursementDO reimbursement = service.getReimbursement(id);
|
||||
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
||||
if (respVO != null && StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
if (respVO != null) {
|
||||
if (StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
}
|
||||
if (respVO.getPaymentCompany() != null) {
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(deptApi.getDept(respVO.getPaymentCompany()).getCheckedData().getName());
|
||||
}
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
@ -82,10 +92,16 @@ public class BpmOAReimbursementController {
|
||||
|
||||
BpmOAReimbursementDO reimbursement = service.getByProcessInstanceId(processInstanceId);
|
||||
BpmOAReimbursementRespVO respVO = service.convert(reimbursement);
|
||||
if (respVO != null && StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
if (respVO != null) {
|
||||
if (StringUtil.isNotEmpty(respVO.getProjectNo())) {
|
||||
// 设置项目名称
|
||||
ProjectDTO projectDTO = projectApi.getProject(respVO.getProjectNo()).getCheckedData();
|
||||
respVO.setProjectName(projectDTO.getName());
|
||||
}
|
||||
if (respVO.getPaymentCompany() != null) {
|
||||
// 设置付款公司名称
|
||||
respVO.setPaymentCompanyName(deptApi.getDept(respVO.getPaymentCompany()).getCheckedData().getName());
|
||||
}
|
||||
}
|
||||
return success(respVO);
|
||||
}
|
||||
|
@ -26,4 +26,7 @@ public class BpmOAPaymentPageReqVO extends PageParam {
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private String[] createTime;
|
||||
|
||||
@Schema(description = "申请人用户编号")
|
||||
private Long userId;
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ public class BpmOAReimbursementCreateReqVO {
|
||||
@Schema(description = "开户行信息")
|
||||
private String bankName;
|
||||
|
||||
@Schema(description = "付款公司")
|
||||
private Long paymentCompany;
|
||||
|
||||
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销项目不能为空")
|
||||
private List<Reimbursement> reimbursements;
|
||||
|
@ -27,6 +27,12 @@ public class BpmOAReimbursementRespVO extends BpmOABaseRespVO {
|
||||
@Schema(description = "收款人卡号")
|
||||
private String bankNo;
|
||||
|
||||
@Schema(description = "付款公司")
|
||||
private Long paymentCompany;
|
||||
|
||||
@Schema(description = "付款公司名称")
|
||||
private String paymentCompanyName;
|
||||
|
||||
@Schema(description = "报销项目明细", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "报销项目不能为空")
|
||||
private List<ReimbursementDTO> reimbursements;
|
||||
|
@ -1,8 +1,7 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.reimbursement.Reimbursement;
|
||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -64,6 +63,11 @@ public class BpmOAReimbursementDO extends BaseDO {
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 付款公司编号
|
||||
*/
|
||||
private Long paymentCompany;
|
||||
|
||||
// /**
|
||||
// * 报销明细数据JSON
|
||||
// */
|
||||
|
@ -26,6 +26,7 @@ public interface BpmOAPaymentMapper extends BaseMapperX<BpmOAPaymentDO> {
|
||||
.eq(BpmOAPaymentDO::getIsTickets, 1)
|
||||
.eqIfPresent(BpmOAPaymentDO::getStatus, pageReqVO.getStatus())
|
||||
.betweenIfPresent(BpmOAPaymentDO::getCreateTime, pageReqVO.getCreateTime())
|
||||
.eqIfPresent(BpmOAPaymentDO::getUserId, pageReqVO.getUserId())
|
||||
.eq(pageReqVO.getIsMy(), BpmOAPaymentDO::getUserId, userId)
|
||||
.orderByAsc(BpmOAPaymentDO::getStatus)
|
||||
.orderByDesc(BpmOAPaymentDO::getId));
|
||||
|
@ -20,6 +20,8 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.dto.FactoryInfoDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.StaffApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
import cn.iocoder.yudao.module.system.api.bank.BankApi;
|
||||
@ -77,6 +79,9 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
@Resource
|
||||
private BankApi bankApi;
|
||||
|
||||
@Resource
|
||||
private FactoryInfoApi factoryInfoApi;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -97,8 +102,18 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
loanMapper.insert(loan);
|
||||
|
||||
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
// 提交是费用借支时
|
||||
if (vo.getLoanType() == 2) {
|
||||
|
||||
// 获取借支人所属厂区信息
|
||||
FactoryInfoDTO factoryInfoDTO = factoryInfoApi.getFactoryInfo(loan.getFactoryId()).getCheckedData();
|
||||
processInstanceVariables.put("factoryType", factoryInfoDTO.getType());
|
||||
}
|
||||
|
||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(loan.getId())));
|
||||
|
File diff suppressed because one or more lines are too long
@ -70,12 +70,10 @@
|
||||
SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable
|
||||
FROM
|
||||
bpm_oa_expenses a
|
||||
LEFT JOIN bpm_oa_expenses_item b ON b.expenses_id = a.id
|
||||
LEFT JOIN bpm_process_instance_ext c ON c.process_instance_id = a.process_instance_id
|
||||
LEFT JOIN system_bank ub ON ub.id = a.bank_id
|
||||
WHERE
|
||||
a.deleted = 0
|
||||
AND b.deleted = 0
|
||||
AND a.result = 2
|
||||
<if test="pageReqVO.userId != null">
|
||||
AND a.user_id = #{pageReqVO.userId}
|
||||
|
@ -40,6 +40,6 @@ public interface ErrorCodeConstants {
|
||||
// ========== 搬运模块 1_000_005_000 ==========
|
||||
ErrorCode CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION = new ErrorCode(1_000_005_001, "找不到对应的工厂搬运规格");
|
||||
ErrorCode FACTORY_HANDLING_SPECIFICATION_EXISTS = new ErrorCode(1_000_005_002, "工厂搬运规格已存在");
|
||||
|
||||
ErrorCode SPECIFICATION_USER_AMOUNT_NOT_EXISTS = new ErrorCode(1_000_005_003, "工厂当前月份存在未分配人员数据!");
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,8 @@ import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamount
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountItemVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsService;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount.HandlingGroupUserAmountService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -47,9 +45,6 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
@Resource
|
||||
private HandlingGroupUserAmountService handlingGroupUserAmountService;
|
||||
|
||||
@Resource
|
||||
private FactoryInfoService factoryInfoService;
|
||||
|
||||
@PostMapping("/batchCreate")
|
||||
@Operation(summary = "批量创建搬运组工资规格关联")
|
||||
public CommonResult<Boolean> batchCreate(@Valid @RequestBody HandlingGroupAmountSpecificationsBatchCreateVO vo) {
|
||||
@ -119,7 +114,7 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
List<HandlingGroupUserAmountDO> items = handlingGroupUserAmountMap.get(handlingGroupAmountSpecificationsDO.getId());
|
||||
if (CollUtil.isNotEmpty(items)) {
|
||||
List<HandlingGroupUserAmountItemVO> handlingGroupUserAmountItemVOS = BeanUtils.toBean(items, HandlingGroupUserAmountItemVO.class);
|
||||
handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS);
|
||||
handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS);
|
||||
}
|
||||
}
|
||||
return success(result);
|
||||
|
@ -99,6 +99,15 @@ public class HandlingGroupUserAmountController {
|
||||
return success(pageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/confirm")
|
||||
@Operation(summary = "确认搬运组薪资")
|
||||
public CommonResult<Boolean> confirmHandlingGroupUserAmount(@RequestParam("factoryId") Long factoryId,
|
||||
@RequestParam("month") String month) {
|
||||
|
||||
handlingGroupUserAmountService.confirmHandlingGroupUserAmount(factoryId, month);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出搬运组每日个人工资记录 Excel")
|
||||
@OperateLog(type = EXPORT)
|
||||
|
@ -6,7 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@ -22,4 +21,7 @@ public class HandlingGroupUserAmountItemVO {
|
||||
@Schema(description = "搬运组每日个人工资")
|
||||
@ExcelProperty("搬运组每日个人工资")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "状态 0未确认 1已确认")
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 搬运组每日个人工资记录 Response VO")
|
||||
@Data
|
||||
@ -38,6 +37,9 @@ public class HandlingGroupUserAmountRespVO {
|
||||
@ExcelProperty("搬运组每日个人工资")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "状态 0.未确认 1.已确认")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -64,4 +63,8 @@ public class HandlingGroupUserAmountDO extends BaseDO {
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 状态 1未确认 2已确认
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 搬运组每日个人工资记录 Mapper
|
||||
@ -72,4 +71,8 @@ public interface HandlingGroupUserAmountMapper extends BaseMapperX<HandlingGroup
|
||||
* @return
|
||||
*/
|
||||
List<HandlingGroupUserAmountDO> getByHandlingGroupAmountSpecificationsId(@Param("handlingGroupAmountSpecificationsIds") List<Long> handlingGroupAmountSpecificationsIds);
|
||||
|
||||
List<HandlingGroupUserAmountDO> selectAmountSum(@Param("factoryId") Long factoryId, @Param("month") String month);
|
||||
|
||||
Long selectIsExists(@Param("factoryId") Long factoryId, @Param("month") String month);
|
||||
}
|
||||
|
@ -95,4 +95,11 @@ public interface HandlingGroupUserAmountService extends IService<HandlingGroupUs
|
||||
* @return
|
||||
*/
|
||||
List<HandlingGroupUserAmountDO> getByHandlingGroupAmountSpecificationsId(List<Long> handlingGroupAmountSpecificationsIds);
|
||||
|
||||
/**
|
||||
* 确认搬运工组薪资,确认后添加至员工薪资表
|
||||
* @param factoryId
|
||||
* @param month
|
||||
*/
|
||||
void confirmHandlingGroupUserAmount(Long factoryId, String month);
|
||||
}
|
||||
|
@ -1,15 +1,27 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOALoanApi;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.dto.StaffWagesPageDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.*;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.DeductionItemsVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalarySubjectItemsVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staffsalary.StaffSalaryDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupuseramount.HandlingGroupUserAmountMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.staffsalary.StaffSalaryMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
|
||||
import cn.iocoder.yudao.module.system.api.loan.LoanApi;
|
||||
import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -17,8 +29,15 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
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.convertMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.SPECIFICATION_USER_AMOUNT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 搬运组每日个人工资记录 Service 实现类
|
||||
@ -33,6 +52,19 @@ public class HandlingGroupUserAmountServiceImpl extends ServiceImpl<HandlingGrou
|
||||
private HandlingGroupUserAmountMapper handlingGroupUserAmountMapper;
|
||||
@Resource
|
||||
private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper;
|
||||
|
||||
@Resource
|
||||
private BpmOALoanApi bpmOALoanApi;
|
||||
|
||||
@Resource
|
||||
private LoanApi loanApi;
|
||||
|
||||
@Resource
|
||||
private StaffService staffService;
|
||||
|
||||
@Resource
|
||||
private StaffSalaryMapper staffSalaryMapper;
|
||||
|
||||
private static final String NAME = "姓名";
|
||||
private static final String TOTAL_AMOUNT = "总金额";
|
||||
// 提取常量
|
||||
@ -144,5 +176,76 @@ public class HandlingGroupUserAmountServiceImpl extends ServiceImpl<HandlingGrou
|
||||
return handlingGroupUserAmountMapper.getByHandlingGroupAmountSpecificationsId(handlingGroupAmountSpecificationsIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmHandlingGroupUserAmount(Long factoryId, String month) {
|
||||
|
||||
// 查询搬运工 月工资总额
|
||||
List<HandlingGroupUserAmountDO> userAmountSums = handlingGroupUserAmountMapper.selectAmountSum(factoryId, month);
|
||||
if (CollUtil.isEmpty(userAmountSums)) {
|
||||
throw exception(SPECIFICATION_USER_AMOUNT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 校验 工厂当前月份是否存在未分配搬运工数据
|
||||
Long count = handlingGroupUserAmountMapper.selectIsExists(factoryId, month);
|
||||
if (count > 0L) {
|
||||
throw exception(SPECIFICATION_USER_AMOUNT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 更新搬运组薪资 状态
|
||||
handlingGroupUserAmountMapper.update(null, new LambdaUpdateWrapper<HandlingGroupUserAmountDO>()
|
||||
.set(HandlingGroupUserAmountDO::getStatus, 1)
|
||||
.eq(HandlingGroupUserAmountDO::getFactoryId, factoryId)
|
||||
.like(HandlingGroupUserAmountDO::getDateStr, month));
|
||||
|
||||
// 获取厂区得员工信息
|
||||
Set<Long> staffIds = convertSet(userAmountSums, HandlingGroupUserAmountDO::getUserId);
|
||||
List<StaffDO> staffDOS = staffService.getList(staffIds);
|
||||
Map<Long, StaffDO> staffMap = convertMap(staffDOS, StaffDO::getId);
|
||||
|
||||
// 获取员工借支记录
|
||||
List<BpmOALoanSumDTO> loanDOS = bpmOALoanApi.getListByStaffId(staffIds, month).getCheckedData();
|
||||
Map<Long, BigDecimal> loanMap = loanDOS.stream()
|
||||
.collect(Collectors.toMap(
|
||||
BpmOALoanSumDTO::getSfUserId,
|
||||
BpmOALoanSumDTO::getTotalAmount,
|
||||
BigDecimal::add
|
||||
));
|
||||
|
||||
// 获取员工剩余的 工资借支金额
|
||||
List<LoanDTO> sysLoanDOS = loanApi.getListByMonth(staffIds, month).getCheckedData();
|
||||
Map<Long, BigDecimal> sysLoanMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(sysLoanDOS)) {
|
||||
sysLoanMap = sysLoanDOS.stream()
|
||||
.collect(Collectors.toMap(LoanDTO::getUserId, LoanDTO::getRemainingAmount));
|
||||
}
|
||||
|
||||
Map<Long, BigDecimal> finalSysLoanMap = sysLoanMap;
|
||||
List<StaffSalaryDO> salaryDOS = userAmountSums.stream().map(item -> {
|
||||
StaffSalaryDO salaryDO = new StaffSalaryDO()
|
||||
.setStaffId(item.getUserId())
|
||||
.setFactoryId(item.getFactoryId())
|
||||
.setMonth(month)
|
||||
.setPayableAmount(item.getAmount())
|
||||
.setReturnAmount(loanMap.getOrDefault(item.getUserId(), BigDecimal.ZERO)
|
||||
.add(finalSysLoanMap.getOrDefault(item.getUserId(), BigDecimal.ZERO)))
|
||||
.setDeductionItems(Collections.singletonList(
|
||||
new DeductionItemsVO()
|
||||
.setKey("insurance")
|
||||
.setValue("50")));
|
||||
// 设置实发工资
|
||||
salaryDO.setRealAmount(salaryDO.getPayableAmount().subtract(salaryDO.getReturnAmount()));
|
||||
// 设置薪资主体数据
|
||||
if (staffMap.get(item.getUserId()).getSalarySubject() != null) {
|
||||
salaryDO.setSalarySubjectItems(Collections.singletonList(
|
||||
new SalarySubjectItemsVO()
|
||||
.setSalarySubjectId(staffMap.get(item.getUserId()).getSalarySubject())
|
||||
.setAmount(salaryDO.getPayableAmount())
|
||||
));
|
||||
}
|
||||
return salaryDO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
// 插入工资记录
|
||||
staffSalaryMapper.insertBatch(salaryDOS);
|
||||
}
|
||||
}
|
||||
|
@ -149,4 +149,35 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAmountSum" resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO">
|
||||
SELECT
|
||||
user_id AS userId,
|
||||
SUM(amount) AS amount
|
||||
FROM
|
||||
sf_handling_group_user_amount
|
||||
WHERE
|
||||
deleted = 0
|
||||
AND status = 0
|
||||
AND factory_id = #{factoryId}
|
||||
AND date_str LIKE CONCAT('%', #{month}, '%')
|
||||
GROUP BY
|
||||
user_id
|
||||
</select>
|
||||
|
||||
<select id="selectIsExists" resultType="java.lang.Long">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
sf_handling_group_amount_specifications a
|
||||
WHERE
|
||||
NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sf_handling_group_user_amount b
|
||||
WHERE a.factory_id = b.factory_id AND a.date_str = b.date_str
|
||||
)
|
||||
AND a.factory_id = #{factoryId}
|
||||
AND a.date_str LIKE CONCAT('%', #{month}, '%')
|
||||
AND a.deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user