Merge branch 'dev' of http://git.znkjfw.com/ak/zn-cloud into dev-erp

This commit is contained in:
aikai 2025-04-23 10:48:34 +08:00
commit b7dbc96181
60 changed files with 743 additions and 218 deletions

View File

@ -94,4 +94,13 @@ public class BpmOAExpensesController {
expensesService.refused(id, processInstanceId); expensesService.refused(id, processInstanceId);
return success(true); return success(true);
} }
@GetMapping("/oneClickPayment")
@Operation(summary = "一键支付")
@Parameter(name = "month", description = "月份", required = true, example = "2025-04")
public CommonResult<Boolean> oneClickPayment(String month) {
expensesService.oneClickPayment(month);
return success(true);
}
} }

View File

@ -42,10 +42,10 @@ public class BpmOASalaryController {
@Operation(summary = "创建请求申请") @Operation(summary = "创建请求申请")
public CommonResult<Long> createSalary(@Valid @RequestBody BpmOASalaryCreateReqVO createReqVO) { public CommonResult<Long> createSalary(@Valid @RequestBody BpmOASalaryCreateReqVO createReqVO) {
if (createReqVO.getFactoryId() != null) { // if (createReqVO.getFactoryId() != null) {
DeptRespDTO dto = deptApi.getDeptByFactoryId(createReqVO.getFactoryId()).getCheckedData(); // DeptRespDTO dto = deptApi.getDeptByFactoryId(createReqVO.getFactoryId()).getCheckedData();
createReqVO.setCompanyDeptId(dto.getId()); // createReqVO.setCompanyDeptId(dto.getId());
} // }
return success(salaryService.createSalary(getLoginUserId(), createReqVO)); return success(salaryService.createSalary(getLoginUserId(), createReqVO));
} }

View File

@ -30,4 +30,7 @@ public class BpmOAExpensesPageReqVO extends PageParam {
@Schema(description = "审批通过时间") @Schema(description = "审批通过时间")
private String[] endTime; private String[] endTime;
@Schema(description = "收款人姓名")
private String payeeName;
} }

View File

@ -47,7 +47,7 @@ public class BpmOAPaymentCreateReqVO {
private BigDecimal totalAmount; private BigDecimal totalAmount;
@Schema(description = "付款比例 | 针对分期付款情况", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @Schema(description = "付款比例 | 针对分期付款情况", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private Integer paymentRatio; private BigDecimal paymentRatio;
@Schema(description = "付款金额", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "付款金额", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "付款金额不能为空") @NotNull(message = "付款金额不能为空")

View File

@ -68,7 +68,7 @@ public class BpmOAPaymentRespVO extends BpmOABaseRespVO {
private BigDecimal totalAmount; private BigDecimal totalAmount;
@Schema(description = "付款比例 | 针对分期付款情况") @Schema(description = "付款比例 | 针对分期付款情况")
private Integer paymentRatio; private BigDecimal paymentRatio;
@Schema(description = "付款金额") @Schema(description = "付款金额")
private BigDecimal amount; private BigDecimal amount;
@ -92,7 +92,10 @@ public class BpmOAPaymentRespVO extends BpmOABaseRespVO {
private Long parentId; private Long parentId;
@Schema(description = "累计付款比列") @Schema(description = "累计付款比列")
private Integer ratio; private BigDecimal ratio;
@Schema(description = "累计付款金额")
private BigDecimal paymentAmount;
@Schema(description = "上传文件") @Schema(description = "上传文件")
private List<UploadUserFile> fileItems; private List<UploadUserFile> fileItems;

View File

@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 薪资付款申请 创建 Request VO * 薪资付款申请 创建 Request VO
@ -30,11 +31,15 @@ public class BpmOASalaryCreateReqVO {
@DateTimeFormat(pattern = "yyyy-MM") @DateTimeFormat(pattern = "yyyy-MM")
private String salaryDate; private String salaryDate;
@Schema(description = "公司类型 | 1公司 2工厂", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "公司类型不能为空")
private Integer deptType;
@Schema(description = "付款公司") @Schema(description = "付款公司")
private Long companyDeptId; private Long companyDeptId;
@Schema(description = "付款工厂编号") @Schema(description = "付款工厂的部门编号集合")
private Long factoryId; private Set<Long> factoryDeptId;
@Schema(description = "付款总额", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "付款总额", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "付款总额不能为空") @NotNull(message = "付款总额不能为空")
@ -47,6 +52,9 @@ public class BpmOASalaryCreateReqVO {
@Schema(description = "支付对象") @Schema(description = "支付对象")
private String paymentRecipient; private String paymentRecipient;
@Schema(description = "薪资主体明细")
private List<SalarySubjectItemsVO> salarySubjectItems;
@Schema(description = "流程实例编号") @Schema(description = "流程实例编号")
private String processInstanceId; private String processInstanceId;

View File

@ -8,9 +8,9 @@ import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author 符溶馨 * @author 符溶馨
@ -28,12 +28,21 @@ public class BpmOASalaryRespVO extends BpmOABaseRespVO {
@DateTimeFormat(pattern = "yyyy-MM") @DateTimeFormat(pattern = "yyyy-MM")
private String salaryDate; private String salaryDate;
@Schema(description = "公司类型 | 1公司 2工厂")
private Integer deptType;
@Schema(description = "付款公司") @Schema(description = "付款公司")
private Long companyDeptId; private Long companyDeptId;
@Schema(description = "付款公司名称") @Schema(description = "付款公司名称")
private String companyName; private String companyName;
@Schema(description = "付款工厂的部门编号集合")
private Set<Long> factoryDeptId;
@Schema(description = "付款工厂名称")
private String factoryName;
@Schema(description = "付款工厂") @Schema(description = "付款工厂")
private Long FactoryId; private Long FactoryId;
@ -46,6 +55,9 @@ public class BpmOASalaryRespVO extends BpmOABaseRespVO {
@Schema(description = "支付对象") @Schema(description = "支付对象")
private String paymentRecipient; private String paymentRecipient;
@Schema(description = "薪资主体明细")
private List<SalarySubjectItemsVO> salarySubjectItems;
@Schema(description = "流程实例编号") @Schema(description = "流程实例编号")
private String processInstanceId; private String processInstanceId;

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.salary;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 薪资付款申请创建 Request VO")
@Data
public class SalarySubjectItemsVO {
@Schema(description = "薪资主体编号")
private Integer salarySubjectId;
@Schema(description = "金额")
private BigDecimal amount;
}

View File

@ -78,9 +78,9 @@ public class BpmOAPaymentDO extends BaseDO {
private Long bankId; private Long bankId;
/** /**
* 付款方式 | 1预付款 2分期付款 3全额付款 * 付款方式 | 1分批付款 3全额付款 4指定金额付款
*/ */
private Integer paymentMethod; private BigDecimal paymentMethod;
/** /**
* 付款总额 | 针对预付款分期付款情况 * 付款总额 | 针对预付款分期付款情况

View File

@ -64,11 +64,11 @@ public class BpmOAReimbursementDO extends BaseDO {
*/ */
private String bankName; private String bankName;
/** // /**
* 报销明细数据JSON // * 报销明细数据JSON
*/ // */
@TableField(typeHandler = JacksonTypeHandler.class) // @TableField(typeHandler = JacksonTypeHandler.class)
private List<Reimbursement> reimbursements; // private List<Reimbursement> reimbursements;
/** /**
* 总报销金额 * 总报销金额
*/ */

View File

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile; import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.salary.SalarySubjectItemsVO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
@ -11,6 +13,7 @@ import lombok.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* OA 薪资付款 DO * OA 薪资付款 DO
@ -49,11 +52,22 @@ public class BpmOASalaryDO extends BaseDO {
*/ */
private String salaryDate; private String salaryDate;
/**
* 公司类型 | 1公司 2工厂
*/
private Integer deptType;
/** /**
* 付款公司 * 付款公司
*/ */
private Long companyDeptId; private Long companyDeptId;
/**
* 付款工厂的部门编号集合
*/
@TableField(typeHandler = JsonLongSetTypeHandler.class)
private Set<Long> factoryDeptId;
/** /**
* 付款总额 * 付款总额
*/ */
@ -69,6 +83,13 @@ public class BpmOASalaryDO extends BaseDO {
*/ */
private String paymentRecipient; private String paymentRecipient;
/**
* 薪资主体明细
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<SalarySubjectItemsVO> salarySubjectItems;
/** /**
* 薪资付款申请的结果 * 薪资付款申请的结果
* *

View File

@ -16,4 +16,6 @@ public interface BpmOAExpensesMapper extends BaseMapperX<BpmOAExpensesDO> {
@Param("pageReqVO") BpmOAExpensesPageReqVO pageReqVO); @Param("pageReqVO") BpmOAExpensesPageReqVO pageReqVO);
BpmOAExpensesTotal selectTotal(@Param("pageReqVO") BpmOAExpensesPageReqVO pageReqVO); BpmOAExpensesTotal selectTotal(@Param("pageReqVO") BpmOAExpensesPageReqVO pageReqVO);
void oneClickPayment(@Param("month") String month);
} }

View File

@ -91,4 +91,10 @@ public interface BpmOAExpensesService {
* @param processInstanceId 流程实例编号 * @param processInstanceId 流程实例编号
*/ */
void refused(Long id, String processInstanceId); void refused(Long id, String processInstanceId);
/**
* 一键支付
* @param month 月份
*/
void oneClickPayment(String month);
} }

View File

@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -112,6 +113,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
String type = bpmOAExpensesItemDOS.stream().map(item -> item.getType().toString()).collect(Collectors.joining(",")); String type = bpmOAExpensesItemDOS.stream().map(item -> item.getType().toString()).collect(Collectors.joining(","));
processInstanceVariables.put("type", type); processInstanceVariables.put("type", type);
processInstanceVariables.put("factoryType", expenses.getFactoryType()); processInstanceVariables.put("factoryType", expenses.getFactoryType());
processInstanceVariables.put("factory_id", bpmOAExpensesItemDOS.get(0).getDeptId());
String processInstanceId = processInstanceService.createProcessInstance(userId, String processInstanceId = processInstanceService.createProcessInstance(userId,
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(expenses.getId()))); .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(expenses.getId())));
@ -264,7 +266,10 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
CommonResult<AdminUserRespDTO> user = userApi.getUser(expenses.getUserId()); CommonResult<AdminUserRespDTO> user = userApi.getUser(expenses.getUserId());
// 获取收款人信息 // 获取收款人信息
BankRespDTO bankRespDTO = bankApi.getBank(expenses.getBankId()).getCheckedData(); BankRespDTO bankRespDTO = null;
if (expenses.getBankId() != null) {
bankRespDTO = bankApi.getBank(expenses.getBankId()).getCheckedData();
}
// 获取付款公司信息 // 获取付款公司信息
FactoryInfoDTO dto = new FactoryInfoDTO(); FactoryInfoDTO dto = new FactoryInfoDTO();
@ -284,7 +289,7 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
.setProcessInstanceName(processInstance.getName()) .setProcessInstanceName(processInstance.getName())
.setBeginTime(processInstance.getCreateTime()) .setBeginTime(processInstance.getCreateTime())
.setEndTime(processInstance.getEndTime()) .setEndTime(processInstance.getEndTime())
.setRecipientName(bankRespDTO.getNickname()) .setRecipientName(bankRespDTO != null ? bankRespDTO.getNickname() : "")
.setCompanyFactoryId(dto.getId()) .setCompanyFactoryId(dto.getId())
); );
} }
@ -310,4 +315,10 @@ public class BpmOAExpensesServiceImpl extends BpmOABaseService implements BpmOAE
// 同步更新流程实例表 // 同步更新流程实例表
processInstanceService.updateProcessInstanceResult(processInstanceId, BpmProcessInstanceResultEnum.BACK.getResult()); processInstanceService.updateProcessInstanceResult(processInstanceId, BpmProcessInstanceResultEnum.BACK.getResult());
} }
@Override
public void oneClickPayment(String month) {
expensesMapper.oneClickPayment(month);
}
} }

View File

@ -203,6 +203,11 @@ public class BpmOALoanServiceImpl extends BpmOABaseService implements BpmOALoanS
@Override @Override
public PageResult<BpmOAReturnVO> getReturnList(BpmOALoanPageReqVO pageReqVO) { public PageResult<BpmOAReturnVO> getReturnList(BpmOALoanPageReqVO pageReqVO) {
// 过滤之前老数据
if (pageReqVO.getLoanType() == null) {
return PageResult.empty();
}
IPage<BpmOAReturnVO> page = loanMapper.selectReturnList(pageReqVO, MyBatisUtils.buildPage(pageReqVO)); IPage<BpmOAReturnVO> page = loanMapper.selectReturnList(pageReqVO, MyBatisUtils.buildPage(pageReqVO));
return new PageResult<>(page.getRecords(), page.getTotal()); return new PageResult<>(page.getRecords(), page.getTotal());
} }

View File

@ -70,12 +70,14 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); .setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
salaryMapper.insert(salary) ; salaryMapper.insert(salary) ;
// 获取申请公司或工厂信息
DeptRespDTO dto = deptApi.getDept(salary.getCompanyDeptId()).getCheckedData();
// 配置申请公司或工厂部门flag // 配置申请公司或工厂部门flag
Map<String, Object> processInstanceVariables = new HashMap<>(); Map<String, Object> processInstanceVariables = new HashMap<>();
if (createReqVO.getDeptType() == 1) {
// 获取申请公司信息
DeptRespDTO dto = deptApi.getDept(salary.getCompanyDeptId()).getCheckedData();
processInstanceVariables.put("company_dept_flag", dto.getFlag()); processInstanceVariables.put("company_dept_flag", dto.getFlag());
}
processInstanceVariables.put("dept_type", createReqVO.getDeptType());
// 发起 BPM 流程 // 发起 BPM 流程
String processInstanceId = processInstanceService.createProcessInstance(userId, String processInstanceId = processInstanceService.createProcessInstance(userId,
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY) new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
@ -112,9 +114,6 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
// -- 插入到财务支付表中 // -- 插入到财务支付表中
CommonResult<AdminUserRespDTO> user = userApi.getUser(salaryDO.getUserId()); CommonResult<AdminUserRespDTO> user = userApi.getUser(salaryDO.getUserId());
// 从缓存中部门所属公司信息
DeptRespDTO deptRespDTO = deptApi.getDept(salaryDO.getCompanyDeptId()).getCheckedData();
financialPaymentService.save(new FinancialPaymentDO() financialPaymentService.save(new FinancialPaymentDO()
.setUserId(salaryDO.getUserId()) .setUserId(salaryDO.getUserId())
.setDeptId(user.getData() == null ? null : user.getData().getDeptId()) .setDeptId(user.getData() == null ? null : user.getData().getDeptId())
@ -127,7 +126,7 @@ public class BpmOASalaryServiceImpl extends BpmOABaseService implements BpmOASal
.setProcessInstanceName(processInstance.getName()) .setProcessInstanceName(processInstance.getName())
.setBeginTime(processInstance.getCreateTime()) .setBeginTime(processInstance.getCreateTime())
.setEndTime(processInstance.getEndTime()) .setEndTime(processInstance.getEndTime())
.setCompanyId(deptRespDTO != null && deptRespDTO.getFactoryId() == null ? deptRespDTO.getId() : null) .setCompanyId(salaryDO.getDeptType() == 1 ? salaryDO.getCompanyDeptId() : null)
); );
} }
} }

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAExpensesMapper"> <mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAExpensesMapper">
<!-- <!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
@ -50,12 +49,15 @@
<if test="pageReqVO.costSection != null"> <if test="pageReqVO.costSection != null">
AND a.cost_section = #{pageReqVO.costSection} AND a.cost_section = #{pageReqVO.costSection}
</if> </if>
<if test="pageReqVO.payeeName != null">
AND ub.nickname LIKE CONCAT('%', #{pageReqVO.payeeName}, '%')
</if>
<if test="pageReqVO.endTime != null and pageReqVO.endTime.length > 0"> <if test="pageReqVO.endTime != null and pageReqVO.endTime.length > 0">
<if test="pageReqVO.endTime[0] != null"> <if test="pageReqVO.endTime[0] != null">
and c.end_time &gt;= #{pageReqVO.endTime[0]} and DATE_FORMAT(c.end_time, '%Y-%m-%d') &gt;= #{pageReqVO.endTime[0]}
</if> </if>
<if test="pageReqVO.endTime[1] != null"> <if test="pageReqVO.endTime[1] != null">
and c.end_time &lt;= #{pageReqVO.endTime[1]} and DATE_FORMAT(c.end_time, '%Y-%m-%d') &lt;= #{pageReqVO.endTime[1]}
</if> </if>
</if> </if>
ORDER BY c.end_time DESC, a.expenses_id ORDER BY c.end_time DESC, a.expenses_id
@ -68,8 +70,9 @@
SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable SUM(a.total_money) - SUM(a.amount_paid) AS remainingPayable
FROM FROM
bpm_oa_expenses a bpm_oa_expenses a
JOIN bpm_oa_expenses_item b ON b.expenses_id = b.id LEFT JOIN bpm_oa_expenses_item b ON b.expenses_id = a.id
JOIN bpm_process_instance_ext c ON c.process_instance_id = a.process_instance_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 WHERE
a.deleted = 0 a.deleted = 0
AND b.deleted = 0 AND b.deleted = 0
@ -86,13 +89,26 @@
<if test="pageReqVO.costSection != null"> <if test="pageReqVO.costSection != null">
AND b.cost_section = #{pageReqVO.costSection} AND b.cost_section = #{pageReqVO.costSection}
</if> </if>
<if test="pageReqVO.payeeName != null">
AND ub.nickname LIKE CONCAT('%', #{pageReqVO.payeeName}, '%')
</if>
<if test="pageReqVO.endTime != null and pageReqVO.endTime.length > 0"> <if test="pageReqVO.endTime != null and pageReqVO.endTime.length > 0">
<if test="pageReqVO.endTime[0] != null"> <if test="pageReqVO.endTime[0] != null">
and c.end_time &gt;= #{pageReqVO.endTime[0]} and DATE_FORMAT(c.end_time, '%Y-%m-%d') &gt;= #{pageReqVO.endTime[0]}
</if> </if>
<if test="pageReqVO.endTime[1] != null"> <if test="pageReqVO.endTime[1] != null">
and c.end_time &lt;= #{pageReqVO.endTime[1]} and DATE_FORMAT(c.end_time, '%Y-%m-%d') &lt;= #{pageReqVO.endTime[1]}
</if> </if>
</if> </if>
</select> </select>
<update id="oneClickPayment">
UPDATE bpm_oa_expenses e
JOIN bpm_process_instance_ext b ON e.process_instance_id = b.process_instance_id
SET e.STATUS = 1, e.amount_paid = e.total_money
WHERE
e.result = 2
AND e.STATUS != 2
AND DATE_FORMAT( b.end_time, '%Y-%m' ) = #{month}
</update>
</mapper> </mapper>

View File

@ -59,7 +59,6 @@
1 AS type 1 AS type
FROM FROM
bpm_oa_expenses e bpm_oa_expenses e
JOIN bpm_oa_loan l ON e.user_id = l.user_id AND l.sf_user_id = #{pageReqVO.staffId}
LEFT JOIN system_users u ON e.user_id = u.id LEFT JOIN system_users u ON e.user_id = u.id
LEFT JOIN system_dept d ON u.dept_id = d.id LEFT JOIN system_dept d ON u.dept_id = d.id
LEFT JOIN bpm_process_instance_ext p ON e.process_instance_id = p.process_instance_id LEFT JOIN bpm_process_instance_ext p ON e.process_instance_id = p.process_instance_id
@ -67,7 +66,6 @@
e.deleted = 0 e.deleted = 0
AND e.result = 2 AND e.result = 2
AND e.status = 2 AND e.status = 2
AND l.deleted = 0
AND u.deleted = 0 AND u.deleted = 0
AND d.deleted = 0 AND d.deleted = 0
AND p.deleted = 0 AND p.deleted = 0

View File

@ -17,7 +17,8 @@
bank.nickname as nickname, bank.nickname as nickname,
bank.bank_no as bankNo, bank.bank_no as bankNo,
bank.bank_name as bankName, bank.bank_name as bankName,
COALESCE(SUM( b.payment_ratio ), 0) + COALESCE(a.payment_ratio,0) AS ratio COALESCE(SUM( b.payment_ratio ), 0) + COALESCE(a.payment_ratio,0) AS ratio,
COALESCE(SUM( b.amount ), 0) + COALESCE(a.amount, 0) AS paymentAmount
FROM FROM
bpm_oa_payment a bpm_oa_payment a
<if test="method != 1"> <if test="method != 1">
@ -35,6 +36,6 @@
GROUP BY GROUP BY
a.id a.id
HAVING HAVING
ratio &lt; 100 amount &lt; total_amount
</select> </select>
</mapper> </mapper>

View File

@ -9,10 +9,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi; 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.factoryInfo.dto.FactoryInfoDTO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementRespVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.SettlementItemVO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
@ -136,7 +133,7 @@ public class CustomerSettlementController {
item.setSettlementItems(BeanUtils.toBean(itemMap.get(item.getId()), SettlementItemVO.class)); item.setSettlementItems(BeanUtils.toBean(itemMap.get(item.getId()), SettlementItemVO.class));
} }
// 设置工厂名称 // 设置工厂名称
item.setCustomerName(factoryMap.get(item.getCustomerId()).getName()); item.setCustomerName(factoryMap.get(item.getCustomerId()).getShortName());
// 设置创建人名称 // 设置创建人名称
item.setCreatorName(userMap.get(item.getCreator()) == null ? "" : userMap.get(item.getCreator()).getNickname()); item.setCreatorName(userMap.get(item.getCreator()) == null ? "" : userMap.get(item.getCreator()).getNickname());
}); });
@ -145,6 +142,14 @@ public class CustomerSettlementController {
return success(respVO); return success(respVO);
} }
@GetMapping("/total")
@Operation(summary = "获得结算统计信息")
@PreAuthorize("@ss.hasPermission('system:customer-settlement:query')")
public CommonResult<StatisticsVO> getCustomerSettlementTotal(@Valid CustomerSettlementPageReqVO pageReqVO) {
return success(customerSettlementService.getCustomerSettlementTotal(pageReqVO));
}
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出客户结算信息 Excel") @Operation(summary = "导出客户结算信息 Excel")
@PreAuthorize("@ss.hasPermission('system:customer-settlement:export')") @PreAuthorize("@ss.hasPermission('system:customer-settlement:export')")

View File

@ -19,7 +19,7 @@ public class CustomerSettlementPageReqVO extends PageParam {
private Integer businessType; private Integer businessType;
@Schema(description = "结算月份") @Schema(description = "结算月份")
private String settlementMonth; private String[] settlementMonth;
@Schema(description = "结算公司id", example = "3044") @Schema(description = "结算公司id", example = "3044")
private Long companyId; private Long companyId;

View File

@ -6,6 +6,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@ -35,6 +36,9 @@ public class CustomerSettlementRespVO {
@Schema(description = "收款明细") @Schema(description = "收款明细")
private List<PaymentItem> paymentItem; private List<PaymentItem> paymentItem;
@Schema(description = "收款金额")
private BigDecimal paymentAmount;
@Schema(description = "备注") @Schema(description = "备注")
private String notes; private String notes;

View File

@ -6,6 +6,7 @@ import lombok.Data;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Schema(description = "管理后台 - 客户结算信息新增/修改 Request VO") @Schema(description = "管理后台 - 客户结算信息新增/修改 Request VO")
@ -29,6 +30,9 @@ public class CustomerSettlementSaveReqVO {
@Schema(description = "收款明细") @Schema(description = "收款明细")
private List<PaymentItem> paymentItem; private List<PaymentItem> paymentItem;
@Schema(description = "收款金额")
private BigDecimal paymentAmount;
@Schema(description = "备注") @Schema(description = "备注")
private String notes; private String notes;

View File

@ -27,6 +27,12 @@ public class SettlementItemVO {
@Schema(description = "扣款明细") @Schema(description = "扣款明细")
private List<OtherDeductionsVO> deductionItems; private List<OtherDeductionsVO> deductionItems;
@Schema(description = "扣款金额")
private BigDecimal deductionAmount;
@Schema(description = "结算金额") @Schema(description = "结算金额")
private BigDecimal settlementAmount; private BigDecimal settlementAmount;
@Schema(description = "已收款金额")
private BigDecimal receivedTotal;
} }

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 客户结算信息统计 Response VO")
@Data
public class StatisticsVO {
@Schema(description = "预结算金额")
private BigDecimal preSettlementTotal;
@Schema(description = "应结算金额")
private BigDecimal shouldSettlementTotal;
@Schema(description = "扣款金额")
private BigDecimal deductionTotal;
@Schema(description = "结算金额")
private BigDecimal settlementTotal;
@Schema(description = "已收款金额")
private BigDecimal receivedTotal;
}

View File

@ -23,8 +23,10 @@ public class LoanPageReqVO extends PageParam {
@Schema(description = "借支用户部门编号", example = "128") @Schema(description = "借支用户部门编号", example = "128")
private Long deptId; private Long deptId;
@Schema(description = "创建时间") @Schema(description = "借支类型")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private Integer loanType;
private LocalDateTime[] createTime;
@Schema(description = "查询方式 | 是否查询全部借支 0否 1是 为0时查询 剩余金额不为0的借支")
private Integer model = 0;
} }

View File

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*; import lombok.*;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
@ -48,6 +49,11 @@ public class CustomerSettlementDO extends BaseDO {
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private List<PaymentItem> paymentItem; private List<PaymentItem> paymentItem;
/**
* 收款金额
*/
private BigDecimal paymentAmount;
/** /**
* 备注 * 备注
*/ */

View File

@ -57,6 +57,11 @@ public class SettlementItemDO extends BaseDO {
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private List<OtherDeductionsVO> deductionItems; private List<OtherDeductionsVO> deductionItems;
/**
* 扣款金额
*/
private BigDecimal deductionAmount;
/** /**
* 结算金额 * 结算金额
*/ */

View File

@ -4,8 +4,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 客户结算信息 Mapper * 客户结算信息 Mapper
@ -18,8 +20,9 @@ public interface CustomerSettlementMapper extends BaseMapperX<CustomerSettlement
default PageResult<CustomerSettlementDO> selectPage(CustomerSettlementPageReqVO reqVO) { default PageResult<CustomerSettlementDO> selectPage(CustomerSettlementPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CustomerSettlementDO>() return selectPage(reqVO, new LambdaQueryWrapperX<CustomerSettlementDO>()
.eqIfPresent(CustomerSettlementDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(CustomerSettlementDO::getCustomerId, reqVO.getCustomerId())
.eqIfPresent(CustomerSettlementDO::getSettlementMonth, reqVO.getSettlementMonth()) .betweenIfPresent(CustomerSettlementDO::getSettlementMonth, reqVO.getSettlementMonth())
.orderByDesc(CustomerSettlementDO::getId)); .orderByDesc(CustomerSettlementDO::getId));
} }
StatisticsVO selectTotal(@Param("reqVO") CustomerSettlementPageReqVO pageReqVO);
} }

View File

@ -23,7 +23,9 @@ public interface LoanMapper extends BaseMapperX<LoanDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<LoanDO>() return selectPage(reqVO, new LambdaQueryWrapperX<LoanDO>()
.eqIfPresent(LoanDO::getUserId, reqVO.getUserId()) .eqIfPresent(LoanDO::getUserId, reqVO.getUserId())
.eqIfPresent(LoanDO::getDeptId, reqVO.getDeptId()) .eqIfPresent(LoanDO::getDeptId, reqVO.getDeptId())
.betweenIfPresent(LoanDO::getCreateTime, reqVO.getCreateTime()) .eqIfPresent(LoanDO::getLoanType, reqVO.getLoanType())
.ne(reqVO.getModel() == 0, LoanDO::getRemainingAmount, 0)
.orderByDesc(LoanDO::getRemainingAmount)
.orderByDesc(LoanDO::getUserId)); .orderByDesc(LoanDO::getUserId));
} }

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.customersettlement;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO;
@ -67,7 +68,14 @@ public interface CustomerSettlementService {
* 更新结算信息确认状态 * 更新结算信息确认状态
* *
* @param id 编号 * @param id 编号
* @param status * @param status 状态
*/ */
void updateConfirm(Long id, Integer status); void updateConfirm(Long id, Integer status);
/**
* 获得结算统计信息
* @param pageReqVO 查询信息
* @return 统计信息
*/
StatisticsVO getCustomerSettlementTotal(CustomerSettlementPageReqVO pageReqVO);
} }

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO;
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.upload.UploadUserFile; import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.upload.UploadUserFile;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO;
@ -98,6 +99,7 @@ public class CustomerSettlementServiceImpl implements CustomerSettlementService
// 获取需创建的 结算明细 // 获取需创建的 结算明细
List<SettlementItemDO> createDO = BeanUtils.toBean(updateReqVO.getSettlementItems(), SettlementItemDO.class).stream() List<SettlementItemDO> createDO = BeanUtils.toBean(updateReqVO.getSettlementItems(), SettlementItemDO.class).stream()
.filter(item -> item.getId() == null) .filter(item -> item.getId() == null)
.map(item -> item.setSettlementId(updateReqVO.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
// 获取需更新的 结算明细 // 获取需更新的 结算明细
List<SettlementItemDO> updateDO = BeanUtils.toBean(updateReqVO.getSettlementItems(), SettlementItemDO.class).stream() List<SettlementItemDO> updateDO = BeanUtils.toBean(updateReqVO.getSettlementItems(), SettlementItemDO.class).stream()
@ -162,4 +164,10 @@ public class CustomerSettlementServiceImpl implements CustomerSettlementService
.setId(id) .setId(id)
.setStatus(status)); .setStatus(status));
} }
@Override
public StatisticsVO getCustomerSettlementTotal(CustomerSettlementPageReqVO pageReqVO) {
return customerSettlementMapper.selectTotal(pageReqVO);
}
} }

View File

@ -338,7 +338,8 @@ public class DeptServiceImpl implements DeptService {
.eq(DeptDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) .eq(DeptDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.eq(DeptDO::getType, DeptTypeEnum.COMPANY.getValue()) .eq(DeptDO::getType, DeptTypeEnum.COMPANY.getValue())
.or() .or()
.eq(DeptDO::getType, DeptTypeEnum.HEAD_COMPANY.getValue())); .eq(DeptDO::getType, DeptTypeEnum.HEAD_COMPANY.getValue())
.ne(DeptDO::getLevel, 0));
} }

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.customersettlement.CustomerSettlementMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectTotal" resultType="cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO">
SELECT
SUM(b.pre_settlement_amount) AS preSettlementTotal,
SUM(b.should_settlement_amount) AS shouldSettlementTotal,
SUM(b.deduction_amount) AS deductionTotal,
SUM(b.settlement_amount) AS settlementTotal,
SUM(a.payment_amount) AS receivedTotal
FROM
system_customer_settlement a
LEFT JOIN system_settlement_item b ON b.settlement_id = a.id
WHERE
a.deleted = 0
AND b.deleted = 0
<if test="reqVO.customerId != null">
AND a.customer_id = #{reqVO.customerId}
</if>
<if test="reqVO.businessType != null">
AND b.business_type = #{reqVO.businessType}
</if>
<if test="reqVO.settlementMonth != null and reqVO.settlementMonth.length > 0">
<if test="reqVO.settlementMonth[0] != null">
and a.settlement_month &gt;= #{reqVO.settlementMonth[0]}
</if>
<if test="reqVO.settlementMonth[1] != null">
and a.settlement_month &lt;= #{reqVO.settlementMonth[1]}
</if>
</if>
</select>
</mapper>

View File

@ -24,7 +24,7 @@
AND b.deleted = 0 AND b.deleted = 0
AND a.loan_type = 1 AND a.loan_type = 1
AND a.user_id IN AND a.user_id IN
<foreach collection="userId" item="item" separator=","> <foreach collection="userId" item="item" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
GROUP BY GROUP BY

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.linefixedassetstemporarytable.LineFixedAssetsTemporaryTableMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -26,9 +26,9 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate; import java.util.Collections;
import java.time.format.DateTimeFormatter; import java.util.List;
import java.util.*; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -154,7 +154,7 @@ public class StaffAttendanceRecordController {
Map<Long, StaffDO> staffMap = convertMap(staffDOS, StaffDO::getId); Map<Long, StaffDO> staffMap = convertMap(staffDOS, StaffDO::getId);
if (CollUtil.isNotEmpty(recordDOS)) { if (CollUtil.isNotEmpty(recordDOS)) {
List<StaffAttendanceRecordRespVO> recordRespVO = convertRecord(reqVO, recordDOS, otherRecordDOS); List<StaffAttendanceRecordRespVO> recordRespVO = staffAttendanceRecordService.convertRecord(reqVO, recordDOS, otherRecordDOS);
// 筛选掉已经存在的员工 // 筛选掉已经存在的员工
List<Long> staffIds = staffDOS.stream() List<Long> staffIds = staffDOS.stream()
@ -215,128 +215,6 @@ public class StaffAttendanceRecordController {
} }
} }
private List<StaffAttendanceRecordRespVO> convertRecord(StaffAttendanceRecordReqVO reqVO,
List<StaffAttendanceRecordDO> recordDOS,
List<StaffAttendanceRecordDO> otherRecordDOS) {
// 根据考勤类型 生成对应得日期数据
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);
// 获取厂区信息
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);
// 重组数据
List<StaffAttendanceRecordRespVO> respVOs = new ArrayList<>();
for (Map.Entry<Long, List<StaffAttendanceRecordDO>> entry : recordMap.entrySet()) {
if (!staffMap.containsKey(entry.getKey())) {
continue;
}
// 设置所选厂区 员工得考勤信息
StaffAttendanceRecordRespVO respVO = new StaffAttendanceRecordRespVO(
entry.getKey(),
reqVO.getFactoryId(),
reqVO.getType(),
reqVO.getMonth());
Map<LocalDate, AttendanceRecordVO> records = entry.getValue().stream()
.filter(record -> record.getFactoryId().equals(reqVO.getFactoryId())) // 筛选同一个工厂打卡数据
.map(item -> BeanUtils.toBean(item, AttendanceRecordVO.class))
.collect(Collectors.toMap(AttendanceRecordVO::getPunchTime, value -> value));
// 设置打卡数据
respVO.setRecords(punchTimeList.stream()
.peek(record -> {
if (records.containsKey(record.getPunchTime())) {
record.setStatus(records.get(record.getPunchTime()).getStatus());
}})
.collect(Collectors.toList()));
// 设置员工名称
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)) {
// 获得该员工 在其他工厂的考勤记录
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);
}
// 插入集合
respVOs.add(respVO);
}
return respVOs;
}
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出厂区员工考勤记录 Excel") @Operation(summary = "导出厂区员工考勤记录 Excel")
@PreAuthorize("@ss.hasPermission('smartfactory:staff-attendance-record:export')") @PreAuthorize("@ss.hasPermission('smartfactory:staff-attendance-record:export')")
@ -347,7 +225,7 @@ public class StaffAttendanceRecordController {
List<StaffAttendanceRecordDO> recordDOS = staffAttendanceRecordService.getStaffAttendanceRecordList(reqVO); List<StaffAttendanceRecordDO> recordDOS = staffAttendanceRecordService.getStaffAttendanceRecordList(reqVO);
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "厂区员工考勤记录.xls", "数据", StaffAttendanceRecordRespVO.class, ExcelUtils.write(response, "厂区员工考勤记录.xls", "数据", StaffAttendanceRecordRespVO.class,
convertRecord(reqVO, recordDOS, null)); staffAttendanceRecordService.convertRecord(reqVO, recordDOS, null));
} }
@PutMapping("/review") @PutMapping("/review")

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications; package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -12,6 +13,8 @@ import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamount
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsSaveReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsService; import cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -24,8 +27,12 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
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.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Tag(name = "管理后台 - 搬运组工资规格关联") @Tag(name = "管理后台 - 搬运组工资规格关联")
@ -37,6 +44,9 @@ public class HandlingGroupAmountSpecificationsController {
@Resource @Resource
private HandlingGroupAmountSpecificationsService handlingGroupAmountSpecificationsService; private HandlingGroupAmountSpecificationsService handlingGroupAmountSpecificationsService;
@Resource
private DeptApi deptApi;
@PostMapping("/batchCreate") @PostMapping("/batchCreate")
@Operation(summary = "创建搬运组工资规格关联") @Operation(summary = "创建搬运组工资规格关联")
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:create')") @PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:create')")
@ -77,7 +87,20 @@ public class HandlingGroupAmountSpecificationsController {
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:query')") @PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:query')")
public CommonResult<PageResult<HandlingGroupAmountSpecificationsRespVO>> getHandlingGroupAmountSpecificationsPage(@Valid HandlingGroupAmountSpecificationsPageReqVO pageReqVO) { public CommonResult<PageResult<HandlingGroupAmountSpecificationsRespVO>> getHandlingGroupAmountSpecificationsPage(@Valid HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
PageResult<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsService.getHandlingGroupAmountSpecificationsPage(pageReqVO); PageResult<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsService.getHandlingGroupAmountSpecificationsPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, HandlingGroupAmountSpecificationsRespVO.class)); PageResult<HandlingGroupAmountSpecificationsRespVO> result = BeanUtils.toBean(pageResult, HandlingGroupAmountSpecificationsRespVO.class);
if (CollUtil.isNotEmpty(result.getList())) {
// 获取工厂信息
Set<Long> factoryIds = convertSet(result.getList(), HandlingGroupAmountSpecificationsRespVO::getFactoryId);
Map<Long, DeptRespDTO> factoryMap = convertMap(deptApi.getDeptList(factoryIds).getCheckedData(), DeptRespDTO::getId);
result.getList().forEach(data -> {
// 设置工厂名称
data.setFactoryName(factoryMap.get(data.getFactoryId()) != null ? factoryMap.get(data.getFactoryId()).getName() : null);
});
}
return success(result);
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")

View File

@ -20,6 +20,9 @@ public class HandlingGroupAmountSpecificationsRespVO {
@Schema(description = "工厂id", example = "23178") @Schema(description = "工厂id", example = "23178")
private Long factoryId; private Long factoryId;
@Schema(description = "工厂名称", example = "23178")
private String factoryName;
@Schema(description = "搬运规格id", example = "23178") @Schema(description = "搬运规格id", example = "23178")
@ExcelProperty("搬运规格id") @ExcelProperty("搬运规格id")
private Long handlingSpecificationsId; private Long handlingSpecificationsId;

View File

@ -74,6 +74,14 @@ public class StaffController {
return success(true); return success(true);
} }
@PutMapping("/update-salary")
@Operation(summary = "更新员工")
@PreAuthorize("@ss.hasPermission('factory:staff:update')")
public CommonResult<Boolean> updateStaffSalary(@RequestBody StaffSalaryUpdateVO updateReqVO) {
staffService.updateStaffSalary(updateReqVO);
return success(true);
}
@DeleteMapping("/delete") @DeleteMapping("/delete")
@Operation(summary = "删除员工") @Operation(summary = "删除员工")
@Parameter(name = "id", description = "编号", required = true) @Parameter(name = "id", description = "编号", required = true)

View File

@ -49,9 +49,21 @@ public class StaffRespVO {
@ExcelProperty("身份证号") @ExcelProperty("身份证号")
private String idCard; private String idCard;
@Schema(description = "银行卡名称")
private String bankName;
@Schema(description = "银行卡号")
private String bankNo;
@Schema(description = "薪资主体 | 字典值 sf_staff_salary_subject")
private Integer salarySubject;
@Schema(description = "0离职 1在职 2工伤") @Schema(description = "0离职 1在职 2工伤")
private Integer status; private Integer status;
@Schema(description = "备注")
private String notes;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime; private LocalDateTime createTime;

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 员工更新 Request VO")
@Data
public class StaffSalaryUpdateVO {
@Schema(description = "主键id")
private Long id;
@Schema(description = "薪资")
private BigDecimal salary;
@Schema(description = "薪资主体 | 字典值 sf_staff_salary_subject")
private Integer salarySubject;
}

View File

@ -43,9 +43,21 @@ public class StaffSaveReqVO {
@IdCard @IdCard
private String idCard; private String idCard;
@Schema(description = "银行卡名称")
private String bankName;
@Schema(description = "银行卡号")
private String bankNo;
@Schema(description = "薪资") @Schema(description = "薪资")
private BigDecimal salary; private BigDecimal salary;
@Schema(description = "薪资主体 | 字典值 sf_staff_salary_subject")
private Integer salarySubject;
@Schema(description = "备注")
private String notes;
@Schema(description = "0离职 1在职 2工伤") @Schema(description = "0离职 1在职 2工伤")
private Integer status; private Integer status;

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalaryTotalVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO;
@ -86,6 +87,14 @@ public class StaffSalaryController {
return success(pageResult); return success(pageResult);
} }
@GetMapping("/total")
@Operation(summary = "获取工资统计")
@PreAuthorize("@ss.hasPermission('smartfactory:staff-salary:query')")
public CommonResult<SalaryTotalVO> getStaffSalaryTotal(@Valid StaffSalaryPageReqVO pageReqVO) {
return success(staffSalaryService.getStaffSalaryTotal(pageReqVO));
}
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出厂区员工工资 Excel") @Operation(summary = "导出厂区员工工资 Excel")
@PreAuthorize("@ss.hasPermission('smartfactory:staff-salary:export')") @PreAuthorize("@ss.hasPermission('smartfactory:staff-salary:export')")

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 薪资主体明细 Response VO")
@Data
public class SalarySubjectItemsVO {
@Schema(description = "薪资主体编号")
private Integer salarySubjectId;
@Schema(description = "金额")
private BigDecimal amount;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Schema(description = "管理后台 - 薪资统计信息 Response VO")
@Data
public class SalaryTotalVO {
@Schema(description = "实发金额总计")
private BigDecimal realAmountTotal;
@Schema(description = "薪资主体明细总计")
private List<SalarySubjectItemsVO> salarySubjectItems;
}

View File

@ -6,6 +6,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 厂区员工工资分页 Request VO") @Schema(description = "管理后台 - 厂区员工工资分页 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -26,4 +28,7 @@ public class StaffSalaryPageReqVO extends PageParam {
@Schema(description = "复核状态 | 0未复核 1已复核", example = "0") @Schema(description = "复核状态 | 0未复核 1已复核", example = "0")
private Integer status; private Integer status;
@Schema(description = "工厂编码集合")
private List<Long> factoryIds;
} }

View File

@ -66,6 +66,9 @@ public class StaffSalaryRespVO {
@Schema(description = "扣款明细") @Schema(description = "扣款明细")
private List<DeductionItemsVO> deductionItems; private List<DeductionItemsVO> deductionItems;
@Schema(description = "薪资主体明细")
private List<SalarySubjectItemsVO> salarySubjectItems;
@Schema(description = "复核状态 | 0未复核 1已复核") @Schema(description = "复核状态 | 0未复核 1已复核")
private Integer status; private Integer status;

View File

@ -45,6 +45,9 @@ public class StaffSalarySaveReqVO {
@Schema(description = "扣款明细") @Schema(description = "扣款明细")
private List<DeductionItemsVO> deductionItems; private List<DeductionItemsVO> deductionItems;
@Schema(description = "薪资主体明细")
private List<SalarySubjectItemsVO> salarySubjectItems;
@Schema(description = "复核状态 | 0未复核 1已复核", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "0") @Schema(description = "复核状态 | 0未复核 1已复核", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "0")
private Integer status; private Integer status;

View File

@ -68,11 +68,31 @@ public class StaffDO extends BaseDO {
*/ */
private String idCard; private String idCard;
/**
* 银行名称
*/
private String bankName;
/**
* 银行卡号
*/
private String bankNo;
/** /**
* 工资 * 工资
*/ */
private BigDecimal salary; private BigDecimal salary;
/**
* 薪资主体 | 字典值 sf_staff_salary_subject
*/
private Integer salarySubject;
/**
* 备注
*/
private String notes;
/** /**
* 0离职 1在职 2工伤 * 0离职 1在职 2工伤
*/ */

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.smartfactory.dal.dataobject.staffsalary;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.DeductionItemsVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.DeductionItemsVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalarySubjectItemsVO;
import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
@ -69,6 +70,11 @@ public class StaffSalaryDO extends BaseDO {
*/ */
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private List<DeductionItemsVO> deductionItems; private List<DeductionItemsVO> deductionItems;
/**
* 薪资主体明细
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<SalarySubjectItemsVO> salarySubjectItems;
/** /**
* 复核状态 | 0未复核 1已复核 * 复核状态 | 0未复核 1已复核
*/ */

View File

@ -54,7 +54,7 @@ public interface StaffMapper extends BaseMapperX<StaffDO> {
.selectAs(StaffDO::getId, StaffSalaryRespVO::getStaffId) .selectAs(StaffDO::getId, StaffSalaryRespVO::getStaffId)
.selectAs(StaffDO::getNickName, StaffSalaryRespVO::getStaffName) .selectAs(StaffDO::getNickName, StaffSalaryRespVO::getStaffName)
.selectAs(StaffDO::getFactoryId, StaffSalaryRespVO::getFactoryId) .selectAs(StaffDO::getFactoryId, StaffSalaryRespVO::getFactoryId)
.selectAs(FactoryInfoDO::getName, StaffSalaryRespVO::getFactoryName) .selectAs(FactoryInfoDO::getShortName, StaffSalaryRespVO::getFactoryName)
.selectAs(StaffDO::getWorkTypeId, StaffSalaryRespVO::getWorkTypeId) .selectAs(StaffDO::getWorkTypeId, StaffSalaryRespVO::getWorkTypeId)
.selectAs(StaffSalaryDO::getMonth, StaffSalaryRespVO::getMonth) .selectAs(StaffSalaryDO::getMonth, StaffSalaryRespVO::getMonth)
.selectAs(StaffDO::getSalary, StaffSalaryRespVO::getSalary) .selectAs(StaffDO::getSalary, StaffSalaryRespVO::getSalary)
@ -66,6 +66,7 @@ public interface StaffMapper extends BaseMapperX<StaffDO> {
.selectAs(StaffSalaryDO::getRealAmount, StaffSalaryRespVO::getRealAmount) .selectAs(StaffSalaryDO::getRealAmount, StaffSalaryRespVO::getRealAmount)
.selectAs(StaffSalaryDO::getDeductionItems, StaffSalaryRespVO::getDeductionItems) .selectAs(StaffSalaryDO::getDeductionItems, StaffSalaryRespVO::getDeductionItems)
.selectAs(StaffSalaryDO::getStatus, StaffSalaryRespVO::getStatus) .selectAs(StaffSalaryDO::getStatus, StaffSalaryRespVO::getStatus)
.selectAs(StaffSalaryDO::getSalarySubjectItems, StaffSalaryRespVO::getSalarySubjectItems)
.selectAs(StaffSalaryDO::getCreateTime, StaffSalaryRespVO::getCreateTime); .selectAs(StaffSalaryDO::getCreateTime, StaffSalaryRespVO::getCreateTime);
query.leftJoin(StaffSalaryDO.class, on -> on query.leftJoin(StaffSalaryDO.class, on -> on
.eq(StaffDO::getId, StaffSalaryDO::getStaffId) .eq(StaffDO::getId, StaffSalaryDO::getStaffId)

View File

@ -3,13 +3,17 @@ package cn.iocoder.yudao.module.smartfactory.dal.mysql.staffsalary;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalarySubjectItemsVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalaryTotalVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO; 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.dataobject.staffsalary.StaffSalaryDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
@ -26,7 +30,7 @@ public interface StaffSalaryMapper extends BaseMapperX<StaffSalaryDO> {
.selectAll(StaffSalaryDO.class) .selectAll(StaffSalaryDO.class)
.selectAs(StaffDO::getNickName, StaffSalaryRespVO::getStaffName) .selectAs(StaffDO::getNickName, StaffSalaryRespVO::getStaffName)
.selectAs(StaffDO::getWorkTypeId, StaffSalaryRespVO::getWorkTypeId) .selectAs(StaffDO::getWorkTypeId, StaffSalaryRespVO::getWorkTypeId)
.selectAs(FactoryInfoDO::getName, StaffSalaryRespVO::getFactoryName) .selectAs(FactoryInfoDO::getShortName, StaffSalaryRespVO::getFactoryName)
.selectAs(StaffDO::getSalary, StaffSalaryRespVO::getSalary); .selectAs(StaffDO::getSalary, StaffSalaryRespVO::getSalary);
query.leftJoin(StaffDO.class, "staff", StaffDO::getId, StaffSalaryDO::getStaffId); query.leftJoin(StaffDO.class, "staff", StaffDO::getId, StaffSalaryDO::getStaffId);
@ -34,9 +38,26 @@ public interface StaffSalaryMapper extends BaseMapperX<StaffSalaryDO> {
query.eqIfPresent(StaffSalaryDO::getStaffId, reqVO.getStaffId()); query.eqIfPresent(StaffSalaryDO::getStaffId, reqVO.getStaffId());
query.eqIfPresent(StaffSalaryDO::getMonth, reqVO.getMonth()); query.eqIfPresent(StaffSalaryDO::getMonth, reqVO.getMonth());
query.eqIfPresent(StaffSalaryDO::getFactoryId, reqVO.getFactoryId()); query.eqIfPresent(StaffSalaryDO::getFactoryId, reqVO.getFactoryId());
query.inIfPresent(StaffSalaryDO::getFactoryId, reqVO.getFactoryIds());
query.eqIfPresent(StaffSalaryDO::getStatus, reqVO.getStatus()); query.eqIfPresent(StaffSalaryDO::getStatus, reqVO.getStatus());
query.apply(Objects.nonNull(reqVO.getWorkTypeId()), "staff.work_type_id = {0} ", reqVO.getWorkTypeId()); query.apply(Objects.nonNull(reqVO.getWorkTypeId()), "staff.work_type_id = {0} ", reqVO.getWorkTypeId());
return selectJoinPage(reqVO, StaffSalaryRespVO.class, query); return selectJoinPage(reqVO, StaffSalaryRespVO.class, query);
} }
SalaryTotalVO selectSalaryTotal(@Param("pageReqVO") StaffSalaryPageReqVO pageReqVO);
default List<StaffSalaryRespVO> selectListSalarySubjectItems(StaffSalaryPageReqVO reqVO) {
MPJLambdaWrapperX<StaffSalaryDO> query = new MPJLambdaWrapperX<StaffSalaryDO>();
query.selectAs(StaffSalaryDO::getSalarySubjectItems, StaffSalaryRespVO::getSalarySubjectItems);
query.leftJoin(StaffDO.class, "staff", StaffDO::getId, StaffSalaryDO::getStaffId);
query.eqIfPresent(StaffSalaryDO::getMonth, reqVO.getMonth());
query.eqIfPresent(StaffSalaryDO::getFactoryId, reqVO.getFactoryId());
query.eqIfPresent(StaffSalaryDO::getStatus, reqVO.getStatus());
query.apply(Objects.nonNull(reqVO.getWorkTypeId()), "staff.work_type_id = {0} ", reqVO.getWorkTypeId());
return selectJoinList(StaffSalaryRespVO.class, query);
}
} }

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.smartfactory.service.attendance; package cn.iocoder.yudao.module.smartfactory.service.attendance;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordSaveReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO;
@ -88,4 +89,8 @@ public interface StaffAttendanceRecordService {
* @return 是否已审核 * @return 是否已审核
*/ */
Integer getIsReview(Long factoryId, String month); Integer getIsReview(Long factoryId, String month);
List<StaffAttendanceRecordRespVO> convertRecord(StaffAttendanceRecordReqVO reqVO,
List<StaffAttendanceRecordDO> recordDOS,
List<StaffAttendanceRecordDO> otherRecordDOS);
} }

View File

@ -3,16 +3,19 @@ package cn.iocoder.yudao.module.smartfactory.service.attendance;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.AttendanceRecordVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordSaveReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.SfAttendanceReviewDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.SfAttendanceReviewDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance.SfAttendanceReviewMapper; import cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance.SfAttendanceReviewMapper;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance.StaffAttendanceRecordMapper; import cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance.StaffAttendanceRecordMapper;
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
import cn.iocoder.yudao.module.smartfactory.service.staffsalary.StaffSalaryService; import cn.iocoder.yudao.module.smartfactory.service.staffsalary.StaffSalaryService;
import cn.iocoder.yudao.module.smartfactory.framework.job.staffSalary.StaffSalaryJob;
import cn.iocoder.yudao.module.smartfactory.service.staffsalary.StaffSalaryService;
import org.springframework.data.redis.connection.stream.ObjectRecord;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -21,9 +24,12 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.STAFF_ATTENDANCE_RECORD_NOT_EXISTS; import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.STAFF_ATTENDANCE_RECORD_NOT_EXISTS;
/** /**
@ -44,6 +50,12 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
@Resource @Resource
private SfAttendanceReviewMapper attendanceReviewMapper; private SfAttendanceReviewMapper attendanceReviewMapper;
@Resource
private StaffService staffService;
@Resource
private FactoryInfoService factoryInfoService;
@Override @Override
public void createStaffAttendanceRecord(List<StaffAttendanceRecordSaveReqVO> createReqVO) { public void createStaffAttendanceRecord(List<StaffAttendanceRecordSaveReqVO> createReqVO) {
@ -199,4 +211,129 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe
.eq(SfAttendanceReviewDO::getMonth, month)); .eq(SfAttendanceReviewDO::getMonth, month));
return attendanceReviewDO != null ? attendanceReviewDO.getStatus() : 0; return attendanceReviewDO != null ? attendanceReviewDO.getStatus() : 0;
} }
@Override
public List<StaffAttendanceRecordRespVO> convertRecord(StaffAttendanceRecordReqVO reqVO,
List<StaffAttendanceRecordDO> recordDOS,
List<StaffAttendanceRecordDO> otherRecordDOS) {
// 根据考勤类型 生成对应得日期数据
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);
// 获取厂区信息
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);
// 重组数据
List<StaffAttendanceRecordRespVO> respVOs = new ArrayList<>();
for (Map.Entry<Long, List<StaffAttendanceRecordDO>> entry : recordMap.entrySet()) {
if (!staffMap.containsKey(entry.getKey())) {
continue;
}
// 设置所选厂区 员工得考勤信息
StaffAttendanceRecordRespVO respVO = new StaffAttendanceRecordRespVO(
entry.getKey(),
reqVO.getFactoryId(),
reqVO.getType(),
reqVO.getMonth());
Map<LocalDate, AttendanceRecordVO> records = entry.getValue().stream()
.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 -> {
AttendanceRecordVO recordVO = BeanUtils.toBean(record, AttendanceRecordVO.class);
if (records.containsKey(record.getPunchTime())) {
recordVO.setStatus(records.get(record.getPunchTime()).getStatus());
}
return recordVO;
}).collect(Collectors.toList());
respVO.setRecords(recordVOS);
// 设置员工名称
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)) {
// 获得该员工 在其他工厂的考勤记录
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);
}
// 插入集合
respVOs.add(respVO);
}
return respVOs;
}
} }

View File

@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.smartfactory.service.staff;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.StaffDataRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.StaffDataRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffImportExcelVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.*;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffImportRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
import javax.validation.Valid; import javax.validation.Valid;
@ -132,4 +129,10 @@ public interface StaffService {
* @return 员工信息 * @return 员工信息
*/ */
StaffDO getStaffByUserId(Long userId); StaffDO getStaffByUserId(Long userId);
/**
* 更新员工工资
* @param updateReqVO 更新信息
*/
void updateStaffSalary(StaffSalaryUpdateVO updateReqVO);
} }

View File

@ -11,10 +11,7 @@ import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.StaffDataRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.StaffDataRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffImportExcelVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.*;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffImportRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staff.vo.StaffSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.staff.StaffMapper; import cn.iocoder.yudao.module.smartfactory.dal.mysql.staff.StaffMapper;
import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi;
@ -288,4 +285,16 @@ public class StaffServiceImpl implements StaffService {
return staffMapper.selectStaffByUserId(userId); return staffMapper.selectStaffByUserId(userId);
} }
@Override
public void updateStaffSalary(StaffSalaryUpdateVO updateReqVO) {
if (staffMapper.selectById(updateReqVO.getId()) == null) {
throw exception(STAFF_NOT_EXISTS);
}
// 更新
StaffDO updateObj = BeanUtils.toBean(updateReqVO, StaffDO.class);
staffMapper.updateById(updateObj);
}
} }

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.smartfactory.service.staffsalary; package cn.iocoder.yudao.module.smartfactory.service.staffsalary;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalaryTotalVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO;
@ -65,4 +66,11 @@ public interface StaffSalaryService {
* @param vo 考勤信息 * @param vo 考勤信息
*/ */
void calculateSalary(List<StaffAttendanceRecordDO> vo); void calculateSalary(List<StaffAttendanceRecordDO> vo);
/**
* 获取工资统计
* @param pageReqVO 查询信息
* @return 统计信息
*/
SalaryTotalVO getStaffSalaryTotal(StaffSalaryPageReqVO pageReqVO);
} }

View File

@ -2,13 +2,12 @@ package cn.iocoder.yudao.module.smartfactory.service.staffsalary;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOALoanApi; 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.bpm.api.oa.vo.loan.BpmOALoanSumDTO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.*;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO; 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.dataobject.staffsalary.StaffSalaryDO;
@ -26,10 +25,7 @@ import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -113,7 +109,7 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
@Override @Override
public PageResult<StaffSalaryRespVO> getStaffSalaryPage(StaffSalaryPageReqVO pageReqVO) { public PageResult<StaffSalaryRespVO> getStaffSalaryPage(StaffSalaryPageReqVO pageReqVO) {
if (pageReqVO.getMonth() != null) { if (pageReqVO.getMonth() != null && pageReqVO.getStatus() == null) {
return staffMapper.selectSalaryPage(pageReqVO); return staffMapper.selectSalaryPage(pageReqVO);
}else { }else {
return staffSalaryMapper.selectSalaryPage(pageReqVO); return staffSalaryMapper.selectSalaryPage(pageReqVO);
@ -193,6 +189,10 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
List<StaffSalaryDO> salaryDOS = new ArrayList<>(); List<StaffSalaryDO> salaryDOS = new ArrayList<>();
for (Map.Entry<Long, List<StaffAttendanceRecordDO>> entry : recordMap.entrySet()) { for (Map.Entry<Long, List<StaffAttendanceRecordDO>> entry : recordMap.entrySet()) {
Long staffId = entry.getKey(); Long staffId = entry.getKey();
StaffDO staffDO = staffMap.get(staffId);
if (staffDO == null) {
continue;
}
// 获取该员工的上班考勤记录 // 获取该员工的上班考勤记录
List<StaffAttendanceRecordDO> items = entry.getValue().stream() List<StaffAttendanceRecordDO> items = entry.getValue().stream()
.filter(item -> item.getStatus() == 1) .filter(item -> item.getStatus() == 1)
@ -211,21 +211,38 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
long days = ChronoUnit.DAYS.between(date[0], date[1]); long days = ChronoUnit.DAYS.between(date[0], date[1]);
int workDays = (int) days + 1; int workDays = (int) days + 1;
// 设置扣款明细 默认扣除保险 50元
salaryDO.setDeductionItems(Collections.singletonList(
new DeductionItemsVO()
.setKey("insurance")
.setValue("50")
));
// 计算应发工资 // 计算应发工资
if (staffMap.get(staffId).getSalary() != null) { // 没有录入基本薪资时不做计算 BigDecimal salary = staffDO.getSalary();
if (salary != null) { // 没有录入基本薪资时不做计算
if (salaryDO.getAttendanceDays() == workDays) { if (salaryDO.getAttendanceDays() == workDays) {
// 设置应发工资 // 设置应发工资
salaryDO.setPayableAmount(staffMap.get(staffId).getSalary()); salaryDO.setPayableAmount(salary);
// 设置实发工资 // 设置实发工资
salaryDO.setRealAmount(staffMap.get(staffId).getSalary()); salaryDO.setRealAmount(salary.subtract(BigDecimal.valueOf(50)));
} else { } else {
BigDecimal payableAmount = staffMap.get(staffId).getSalary().divide(BigDecimal.valueOf(workDays), RoundingMode.HALF_UP) BigDecimal payableAmount = salary.divide(BigDecimal.valueOf(workDays), 0, RoundingMode.DOWN)
.multiply(BigDecimal.valueOf(salaryDO.getAttendanceDays())); .multiply(BigDecimal.valueOf(salaryDO.getAttendanceDays()));
// 设置应发工资 // 设置应发工资
salaryDO.setPayableAmount(payableAmount); salaryDO.setPayableAmount(payableAmount);
// 设置实发工资 // 设置实发工资
salaryDO.setRealAmount(payableAmount); salaryDO.setRealAmount(payableAmount.subtract(BigDecimal.valueOf(50)));
}
// 设置薪资主体数据
if (staffDO.getSalarySubject() != null) {
salaryDO.setSalarySubjectItems(Collections.singletonList(
new SalarySubjectItemsVO()
.setSalarySubjectId(staffDO.getSalarySubject())
.setAmount(salaryDO.getPayableAmount())
));
} }
} }
@ -236,4 +253,38 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
// 插入工资记录 // 插入工资记录
staffSalaryMapper.insertBatch(salaryDOS); staffSalaryMapper.insertBatch(salaryDOS);
} }
@Override
public SalaryTotalVO getStaffSalaryTotal(StaffSalaryPageReqVO pageReqVO) {
// 获取实发工资的合计
SalaryTotalVO salaryTotalVO = staffSalaryMapper.selectSalaryTotal(pageReqVO);
// 获取主体薪资的合计
List<StaffSalaryRespVO> salarySubjectItemsVO = staffSalaryMapper.selectListSalarySubjectItems(pageReqVO);
//直接从数据库取出来的List<Reimbursement> 实际上是List<LinkedHashMap>类型 所以不能直接遍历
//将list再次转为json串然后由json串再转为list
String json = JsonUtils.toJsonString(salarySubjectItemsVO);
salarySubjectItemsVO = JsonUtils.parseArray(json, StaffSalaryRespVO.class);
if (CollUtil.isNotEmpty(salarySubjectItemsVO)) {
Map<Integer, SalarySubjectItemsVO> sumMap = salarySubjectItemsVO.stream()
.filter(Objects::nonNull)
.map(StaffSalaryRespVO::getSalarySubjectItems)
.flatMap(List::stream)
.collect(Collectors.toMap(
SalarySubjectItemsVO::getSalarySubjectId,
vo -> new SalarySubjectItemsVO()
.setSalarySubjectId(vo.getSalarySubjectId())
.setAmount(vo.getAmount()),
(vo1, vo2) -> {
vo1.setAmount(vo1.getAmount().add(vo2.getAmount()));
return vo1;
}
));
salaryTotalVO.setSalarySubjectItems(new ArrayList<>(sumMap.values()));
}
return salaryTotalVO;
}
} }

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.smartfactory.dal.mysql.staffsalary.StaffSalaryMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectSalaryTotal" resultType="cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.SalaryTotalVO">
SELECT
SUM(a.real_amount) AS realAmountTotal
FROM
sf_staff_salary a
LEFT JOIN sf_staff b ON b.id = a.staff_id
WHERE
a.deleted = 0
<if test="pageReqVO.factoryId != null">
AND a.factory_id = #{pageReqVO.factoryId}
</if>
<if test="pageReqVO.month != null">
AND a.month = #{pageReqVO.month}
</if>
<if test="pageReqVO.status != null">
AND a.status = #{pageReqVO.status}
</if>
<if test="pageReqVO.workTypeId != null">
AND b.work_type_id = #{pageReqVO.workTypeId}
</if>
</select>
</mapper>