fix(票据):

将票据和审核表合并,修改审核,新增首页
This commit is contained in:
Ftz123456 2024-03-19 19:23:29 +08:00
parent ea48169098
commit 7d73f52dd0
18 changed files with 95 additions and 378 deletions

View File

@ -1,66 +0,0 @@
package com.zsc.edu.bill.modules.audited.audit;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonValue;
import com.zsc.edu.bill.modules.system.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* @author ftz
* 创建时间:30/1/2024 下午8:58
* 描述: TODO
*/
@EqualsAndHashCode(callSuper = true)
@TableName(value ="audit")
@Getter
@Setter
public class Audit extends BaseEntity {
/*
* 票据Id
* */
private Long ticketId;
/*
*审核员id
* */
private Long auditorId;
/*
*审核意见
*/
private String comment;
/*
* 审核状态
* */
private Result result;
@Getter
public enum Result{
PASS(2, "审核通过"),
FAILED(3, "审核未通过");
@EnumValue
private final int code;
@JsonValue
private final String name;
Result(int code, String name) {
this.code = code;
this.name = name;
}
public static Result get(String name) {
for (Result item : values()) {
if (item.getName() .equals(name)) {
return item;
}
}
return null;
}
}
}

View File

@ -1,17 +0,0 @@
package com.zsc.edu.bill.modules.audited.controller;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ftz
* 创建时间:31/1/2024 下午6:52
* 描述: TODO
*/
@AllArgsConstructor
@RestController
@RequestMapping("api/rest/audit")
public class AuditeController {
}

View File

@ -1,30 +0,0 @@
package com.zsc.edu.bill.modules.audited.dto;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import lombok.Data;
/**
* @author ftz
* 创建时间:31/1/2024 下午6:47
* 描述: TODO
*/
@Data
public class Auditdto {
private Long id;
/*
* 票据Id
* */
private Long ticketId;
/*
*审核员id
* */
private Long auditorId;
/*
*审核意见
*/
private String comment;
/*
* 审核状态
* */
private String result;
}

View File

@ -1,22 +0,0 @@
package com.zsc.edu.bill.modules.audited.mapper;
import com.zsc.edu.bill.common.mapstruct.BaseMapper;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import com.zsc.edu.bill.modules.audited.dto.Auditdto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author fantianzhi
* @description 针对表audit(票据审核表 )的数据库操作Mapper
* @createDate 2024-01-31 18:30:42
* @Entity com.zsc.edu.bill.modules.audited.audit.Audit
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface AuditMapper extends BaseMapper<Auditdto,Audit> {
}

View File

@ -1,12 +0,0 @@
package com.zsc.edu.bill.modules.audited.repo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsc.edu.bill.modules.audited.audit.Audit;
/**
* @author ftz
* 创建时间:31/1/2024 下午6:44
* 描述: TODO
*/
public interface AuditRepository extends BaseMapper<Audit>{
}

View File

@ -1,13 +0,0 @@
package com.zsc.edu.bill.modules.audited.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zsc.edu.bill.modules.audited.audit.Audit;
/**
* @author fantianzhi
* @description 针对表audit(票据审核表 )的数据库操作Service
* @createDate 2024-01-31 18:30:42
*/
public interface AuditService extends IService<Audit> {
}

View File

@ -1,23 +0,0 @@
package com.zsc.edu.bill.modules.audited.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import com.zsc.edu.bill.modules.audited.repo.AuditRepository;
import com.zsc.edu.bill.modules.audited.service.AuditService;
import com.zsc.edu.bill.modules.audited.mapper.AuditMapper;
import org.springframework.stereotype.Service;
/**
* @author fantianzhi
* @description 针对表audit(票据审核表 )的数据库操作Service实现
* @createDate 2024-01-31 18:30:42
*/
@Service
public class AuditServiceImpl extends ServiceImpl<AuditRepository, Audit>
implements AuditService{
}

View File

@ -1,31 +0,0 @@
package com.zsc.edu.bill.modules.audited.vo;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import lombok.Data;
/**
* @author ftz
* 创建时间:5/2/2024 下午3:24
* 描述:
*/
@Data
public class auditVo {
private Long auditId;
/*
* 票据Id
* */
private Long ticketId;
/*
*审核员id
* */
private Long auditorId;
/*
*审核意见
*/
private String comment;
/*
* 审核状态
* */
private Audit.Result result;
private String remark;
}

View File

@ -1,19 +1,18 @@
package com.zsc.edu.bill.modules.bills.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import com.zsc.edu.bill.modules.audited.dto.Auditdto;
import com.zsc.edu.bill.modules.audited.service.AuditService;
import com.zsc.edu.bill.framework.security.SecurityUtil;
import com.zsc.edu.bill.framework.security.UserDetailsImpl;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import com.zsc.edu.bill.modules.bills.service.BillService;
import com.zsc.edu.bill.modules.bills.vo.BillVo;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author ftz
@ -27,7 +26,6 @@ import java.util.List;
public class BillController {
private final BillService service;
private final AuditService auditService;
/**
* 分页查询票据列表
* @return 票据列表
@ -37,6 +35,15 @@ public class BillController {
public Page<Bill> list(BillQuery query, Page<Bill> page) {
return service.page(page, query.wrapper());
}
/**
* 首页数据
* <p>
* */
@GetMapping("home")
public List<Map<String, Object>> Home( BillDto dto){
return service.getHomes(dto);
}
/**
* 创建票据
* @return ture/false
@ -84,28 +91,16 @@ public class BillController {
*/
@GetMapping("{id}")
@PreAuthorize("hasAuthority('BILL_QUERY')")
public BillVo detail(@PathVariable Long id){
return service.findById(id);
public Bill detail(@PathVariable Long id){
return service.getById(id);
}
/**
* 选择审核人
* */
@PatchMapping("choose/{id}")
@PreAuthorize("hasAuthority('BILL_CHOOSE_AUDITOR')")
public Boolean audit(@PathVariable Long id, @RequestBody Long auditorId){
Audit audit = new Audit();
audit.setAuditorId(auditorId);
audit.setTicketId(id);
return auditService.save(audit);
}
/*
*审核票据
**/
@PatchMapping("audit/{id}")@PreAuthorize("hasAuthority('BILL_AUDIT')")
public Boolean audit(@PathVariable Long id, @RequestBody Auditdto audit){
return service.audit(id, audit);
@PatchMapping("audit/{id}")
@PreAuthorize("hasAuthority('BILL_AUDIT')")
public Boolean audit(@PathVariable Long id, @RequestBody BillDto dto){
return service.audit(id, dto);
}
/**
@ -114,7 +109,10 @@ public class BillController {
@GetMapping("audit/list")
@PreAuthorize("hasAuthority('BILL_QUERY')")
public Page<Bill> list1(BillQuery query, Page<Bill> page) {
UserDetailsImpl userInfo = SecurityUtil.getUserInfo();
query.setAuditorId(userInfo.getId());
return service.auditPage(page, query);
}
}

View File

@ -1,6 +1,6 @@
package com.zsc.edu.bill.modules.bills.dto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -17,6 +17,7 @@ public class BillDto {
/**
*userID
* */
@NotNull
private Long userId;
/**
@ -59,10 +60,15 @@ public class BillDto {
/**
* 审核人id
*/
@NotNull
private Long auditorId;
/**
* 提交状态 true/false
*/
private Boolean submit;
/*
*审核意见
*/
private String comment;
}

View File

@ -19,10 +19,6 @@ import java.math.BigDecimal;
@Setter
public class Bill extends BaseEntity {
/**
* 票据uuid 提供给前端显示用
*/
private String uuid;
/**
* 用户id 票据创建者id
@ -68,6 +64,14 @@ public class Bill extends BaseEntity {
*附件id
*/
private String attachId;
/*
*审核员id
* */
private Long auditorId;
/*
*审核意见
*/
private String comment;
@Getter
@ -97,6 +101,16 @@ public class Bill extends BaseEntity {
return null;
}
public static Object getByCode(Integer status) {
for (Status item : values()) {
if (item.getCode() == status) {
return item;
}
}
return null;
}
}
@Getter
public enum billType {

View File

@ -53,20 +53,24 @@ public class BillQuery {
* 客户公司名称 票据对应的企业名称
*/
private String companyName;
/**
* 审核人id
*/
private Long auditorId;
/**
* 拼接查询条件
* @return
*/
public LambdaQueryWrapper<Bill> wrapper() {
LambdaQueryWrapper<Bill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StringUtils.hasText(this.uuid), Bill::getUuid, this.uuid);
queryWrapper.eq(Objects.nonNull(this.userId), Bill::getUserId, this.userId);
queryWrapper.like(StringUtils.hasText(this.title), Bill::getTitle, this.title);
queryWrapper.eq(Objects.nonNull(this.money), Bill::getMoney, this.money);
queryWrapper.eq(Objects.nonNull(this.status), Bill::getStatus, this.status);
queryWrapper.eq(Objects.nonNull(this.type), Bill::getType, this.type);
queryWrapper.eq(Objects.nonNull(this.auditorId), Bill::getAuditorId, this.auditorId);
queryWrapper.like(StringUtils.hasText(this.companyName), Bill::getCompanyName, this.companyName);
queryWrapper.orderByAsc(Bill::getStatus);
return queryWrapper;
}
}

View File

@ -1,17 +1,13 @@
package com.zsc.edu.bill.modules.bills.repo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.vo.BillVo;
import org.apache.ibatis.annotations.Select;
/**
* @author yao
*/
public interface BillRepository extends BaseMapper<Bill> {
BillVo findById(Long id);
}

View File

@ -1,14 +1,14 @@
package com.zsc.edu.bill.modules.bills.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zsc.edu.bill.modules.audited.dto.Auditdto;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import com.zsc.edu.bill.modules.bills.vo.BillVo;
import java.util.List;
import java.util.Map;
/**
* @author fantianzhi
@ -21,10 +21,12 @@ public interface BillService extends IService<Bill> {
Boolean update(BillDto dto, Long id);
BillVo findById(Long id);
Boolean audit(Long id, Auditdto audit);
Boolean audit(Long id, BillDto dto);
Page<Bill> auditPage(Page<Bill> page, BillQuery query);
List<Map<String, Object>> getHomes(BillDto dto);
}

View File

@ -1,25 +1,23 @@
package com.zsc.edu.bill.modules.bills.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsc.edu.bill.framework.security.SecurityUtil;
import com.zsc.edu.bill.framework.security.UserDetailsImpl;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import com.zsc.edu.bill.modules.audited.dto.Auditdto;
import com.zsc.edu.bill.modules.audited.repo.AuditRepository;
import com.zsc.edu.bill.modules.audited.service.AuditService;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.mapper.BillMapper;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import com.zsc.edu.bill.modules.bills.repo.BillRepository;
import com.zsc.edu.bill.modules.bills.service.BillService;
import com.zsc.edu.bill.modules.bills.vo.BillVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.UUID;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author yao
@ -30,71 +28,30 @@ public class BillServiceImpl extends ServiceImpl<BillRepository, Bill> implement
private final BillMapper mapper;
private final BillRepository repository;
private final AuditRepository auditRepository;
private final AuditService auditService;
@Override
public Boolean create(BillDto dto) {
Bill bill = mapper.toEntity(dto);
String uuid=UUID.randomUUID().toString();
bill.setUuid(uuid);
if (dto.getSubmit()) {
bill.setStatus(Bill.Status.EXAMINE);
}else {
bill.setStatus(Bill.Status.SUBMIT);}
if (dto.getUserId()==null){
bill.setStatus(dto.getSubmit() ? Bill.Status.EXAMINE : Bill.Status.SUBMIT);
UserDetailsImpl userInfo = SecurityUtil.getUserInfo();
bill.setUserId(userInfo.getId());
}
save(bill);
Bill one = repository.selectOne(new LambdaQueryWrapper<Bill>().eq(Bill::getUuid, uuid));
Audit audit = new Audit();
audit.setTicketId(one.getId());
audit.setAuditorId(dto.getAuditorId());
return auditService.save(audit);
return save(bill);
}
@Override
public Boolean update(BillDto dto, Long id) {
Bill bill = getById(id);
mapper.convert(dto, bill);
if (dto.getAuditorId()!=null) {
Audit audit = auditService.getOne(new LambdaQueryWrapper<Audit>().eq(Audit::getTicketId, id));
audit.setAuditorId(dto.getAuditorId());
auditService.updateById(audit);
}
return updateById(bill);
}
@Override
public BillVo findById(Long id) {
Bill bill = getById(id);
BillVo vo = new BillVo();
Audit audit = auditRepository.selectOne(new LambdaQueryWrapper<Audit>().eq(Audit::getTicketId, id));
vo.setBill(bill);
vo.setAudit(audit);
return vo;
}
@Override
public Boolean audit(Long id, Auditdto audit) {
public Boolean audit(Long id, BillDto dto) {
Bill bill = getById(id);
Audit audit1 = auditRepository.selectById(audit.getId());
audit1.setComment( audit.getComment());
if ("PASS".equals(audit.getResult())) {
bill.setStatus(Bill.Status.PASS);
audit1.setResult(Audit.Result.PASS);
}else if ("FAILED".equals(audit.getResult())) {
bill.setStatus(Bill.Status.FAILED);
audit1.setResult(Audit.Result.FAILED);
}if (bill!=null ) {
updateById(bill);
}
auditService.updateById(audit1);
return auditService.updateById(audit1);
mapper.convert(dto, bill);
return updateById(bill);
}
/**
* 审核员分页
@ -102,13 +59,29 @@ public class BillServiceImpl extends ServiceImpl<BillRepository, Bill> implement
@Override
public Page<Bill> auditPage(Page<Bill> page, BillQuery query) {
UserDetailsImpl userInfo = SecurityUtil.getUserInfo();
LambdaQueryWrapper<Bill> wrappered = query.wrapper();
wrappered.ne(Bill::getStatus, Bill.Status.SUBMIT);
wrappered.inSql(Bill::getId, "select ticket_id from audit where auditor_id = " + userInfo.getId());
return repository.selectPage(page, wrappered);
}
@Override
public List<Map<String, Object>> getHomes(BillDto dto) {
QueryWrapper<Bill> queryWrapper = new QueryWrapper<>();
queryWrapper
.select("status as 'status',IFNULL(count(status),0) as 'number'")
.eq(Objects.nonNull(dto.getUserId()),"user_id",dto.getUserId())
.eq(Objects.nonNull(dto.getAuditorId()),"auditor_id",dto.getAuditorId())
.orderByAsc("status")
.groupBy("status");
List<Map<String, Object>> maps = listMaps(queryWrapper);
maps.forEach(map -> {
Integer status = (Integer) map.get("status");
map.put("status", Bill.Status.getByCode(status));
});
return maps;
}
}

View File

@ -1,6 +1,5 @@
package com.zsc.edu.bill.modules.bills.vo;
import com.zsc.edu.bill.modules.audited.audit.Audit;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import lombok.Data;
@ -12,5 +11,5 @@ import lombok.Data;
@Data
public class BillVo {
Bill bill;
Audit audit;
}

View File

@ -1,26 +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="com.zsc.edu.bill.modules.audited.mapper.AuditMapper">
<resultMap id="BaseResultMap" type="com.zsc.edu.bill.modules.audited.audit.Audit">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="ticketId" column="ticket_id" jdbcType="BIGINT"/>
<result property="auditorId" column="auditor_id" jdbcType="BIGINT"/>
<result property="comment" column="comment" jdbcType="VARCHAR"/>
<result property="result" column="result" jdbcType="TINYINT"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,ticket_id,auditor_id,
comment,result,create_by,
create_time,update_by,update_time,
remark
</sql>
</mapper>

View File

@ -6,7 +6,6 @@
<resultMap id="BaseResultMap" type="com.zsc.edu.bill.modules.bills.entity.Bill">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="uuid" column="uuid" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="BIGINT"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="body" column="body" jdbcType="VARCHAR"/>
@ -21,34 +20,8 @@
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="attachId" column="attach_id" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="BaseResultMap1" type="com.zsc.edu.bill.modules.bills.vo.BillVo">
<collection property="bill" ofType="com.zsc.edu.bill.modules.bills.entity.Bill">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="uuid" column="uuid" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" jdbcType="BIGINT"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="body" column="body" jdbcType="VARCHAR"/>
<result property="money" column="money" jdbcType="DECIMAL"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="type" column="type" jdbcType="TINYINT"/>
<result property="contactEmail" column="contact_email" jdbcType="VARCHAR"/>
<result property="companyName" column="company_name" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="attachId" column="attach_id" jdbcType="VARCHAR"/>
</collection>
<collection property="audit" ofType="com.zsc.edu.bill.modules.audited.vo.auditVo">
<id property="auditId" column="id" jdbcType="BIGINT"/>
<result property="ticketId" column="ticket_id" jdbcType="BIGINT"/>
<result property="auditorId" column="auditor_id" jdbcType="BIGINT"/>
<result property="result" column="result" jdbcType="TINYINT"/>
<result property="comment" column="comment" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
</collection>
<result property="comment" column="audit_time" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
@ -58,14 +31,6 @@
company_name,create_by,create_time,
update_by,update_time,remark
</sql>
<select id="findById" parameterType="java.lang.Long" resultMap="BaseResultMap1">
SELECT
*
FROM
bill AS a
LEFT JOIN ( audit AS b ) ON a.id = b.ticket_id
WHERE
a.id = ${id}
</select>
</mapper>