parent
032ba98382
commit
2b31ce1b41
24 changed files with 814 additions and 27 deletions
@ -0,0 +1,96 @@ |
||||
package org.springblade.modules.business.contraller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.common.constant.CommonConstant; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.business.enums.InvoiceEnum; |
||||
import org.springblade.modules.business.pojo.dto.InvoiceApplyDto; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApply; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApplyDetail; |
||||
import org.springblade.modules.business.service.IInvoiceApplyDetailService; |
||||
import org.springblade.modules.business.service.IInvoiceApplyService; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 发票申请控制器 |
||||
* |
||||
* @author liuqingkun |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping(CommonConstant.APPLICATION_PROJECT + "/invoice-apply") |
||||
@Tag(name = "发票申请控制器", description = "发票申请控制器") |
||||
public class InvoiceApplyController extends BladeController { |
||||
|
||||
private final IInvoiceApplyService applyService; |
||||
|
||||
private final IInvoiceApplyDetailService applyDetailService; |
||||
|
||||
@GetMapping("/finish-work-list") |
||||
@Operation(summary = "列表", description = "列表") |
||||
public R finishWorkList() { |
||||
return R.data(applyService.finishWorkList()); |
||||
} |
||||
|
||||
@GetMapping("/page") |
||||
@Operation(summary = "列表", description = "列表") |
||||
public R<IPage<InvoiceApply>> page(InvoiceApply apply, Query query) { |
||||
LambdaQueryWrapper<InvoiceApply> wrapper = Wrappers.lambdaQuery(apply).orderByDesc(InvoiceApply::getCreateTime); |
||||
IPage<InvoiceApply> pages = this.applyService.page(Condition.getPage(query), wrapper); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
@GetMapping("/detail") |
||||
@Operation(summary = "明细", description = "明细") |
||||
public R detail(Long id) { |
||||
InvoiceApply apply = applyService.getById(id); |
||||
List<InvoiceApplyDetail> applyDetails = applyDetailService.list(); |
||||
|
||||
InvoiceApplyDto dto = InvoiceApplyDto.builder().apply(apply).detailList(applyDetails).build(); |
||||
return R.data(dto); |
||||
} |
||||
|
||||
@PostMapping("/save-submit") |
||||
@Operation(summary = "保存并提交", description = "保存并提交") |
||||
public R saveAndSubmit(@RequestBody InvoiceApplyDto dto) { |
||||
applyService.saveAndSubmit(dto); |
||||
return R.success(); |
||||
} |
||||
|
||||
@PostMapping("/delete") |
||||
@Operation(summary = "删除", description = "删除") |
||||
public R delete(@RequestParam String ids) { |
||||
return R.status(applyService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
@PostMapping("/apply") |
||||
@Operation(summary = "申请", description = "申请") |
||||
public R apply(@RequestParam Long id) { |
||||
InvoiceApply applyOld = applyService.getById(id); |
||||
applyOld.setUpdateUser(AuthUtil.getUserId()); |
||||
applyOld.setStatus(InvoiceEnum.INVOICE_STATUS_APPLY.getValue()); |
||||
applyService.updateById(applyOld); |
||||
return R.success(); |
||||
} |
||||
|
||||
@PostMapping("/confirm") |
||||
@Operation(summary = "确认开票", description = "确认开票") |
||||
public R confirm(@RequestParam Long id) { |
||||
applyService.confirm(id); |
||||
return R.success(); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,43 @@ |
||||
package org.springblade.modules.business.enums; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Getter; |
||||
|
||||
/** |
||||
* 发票字典枚举类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Getter |
||||
@AllArgsConstructor |
||||
public enum InvoiceEnum { |
||||
|
||||
/** |
||||
* 申请开票 |
||||
*/ |
||||
INVOICE_STATUS_CREATE(0), |
||||
|
||||
/** |
||||
* 申请开票 |
||||
*/ |
||||
INVOICE_STATUS_APPLY(1), |
||||
|
||||
/** |
||||
* 已开发票 |
||||
*/ |
||||
INVOICE_STATUS_CONFIRM(2), |
||||
|
||||
/** |
||||
* 业务类型-需求工单 |
||||
*/ |
||||
BUSINESS_TYPE_ORDER(1), |
||||
|
||||
/** |
||||
* 业务类型-巡检维修 |
||||
*/ |
||||
BUSINESS_TYPE_MAINTENANCE(2), |
||||
; |
||||
|
||||
final int value; |
||||
|
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApplyDetail; |
||||
|
||||
/** |
||||
* 发票申请明细表 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
|
||||
public interface InvoiceApplyDetailMapper extends BaseMapper<InvoiceApplyDetail> { |
||||
|
||||
} |
||||
@ -0,0 +1,25 @@ |
||||
|
||||
package org.springblade.modules.business.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApply; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 发票申请表 Mapper 接口 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
|
||||
public interface InvoiceApplyMapper extends BaseMapper<InvoiceApply> { |
||||
|
||||
/** |
||||
* 查询已完成工作列表 |
||||
* |
||||
* @return |
||||
*/ |
||||
List<Map<String, Object>> finishWorkList(); |
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
<?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="org.springblade.modules.business.mapper.InvoiceApplyMapper"> |
||||
|
||||
|
||||
<select id="finishWorkList" resultType="map"> |
||||
SELECT t.* |
||||
from ( |
||||
SELECT 1 as business_type, wo.id as business_id, wo.requirement_code as business_code, u.`name` as serviceman, IFNULL(wo.discount_price,0) as price |
||||
from lab_work_order wo |
||||
left join blade_user u on wo.repair_person = u.id |
||||
WHERE wo.is_deleted= 0 AND wo.`status` = 8 |
||||
UNION ALL |
||||
SELECT 2 as business_type, mt.id as buseness_id, mt.task_code as buseness_code, u.`name` as serviceman, COUNT(mtd.price) as price |
||||
from lab_maintenance_task mt |
||||
left join blade_user u on mt.serviceman_id = u.id |
||||
left join lab_maintenance_task_detail mtd on mt.id = mtd.task_id |
||||
WHERE mt.is_deleted= 0 and mt.repair_status = 7 |
||||
group by mt.id, mt.task_code |
||||
) t |
||||
left join lab_invoice_apply_detail d on t.buseness_id = d.business_id |
||||
where d.id is NULL |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
||||
@ -0,0 +1,20 @@ |
||||
package org.springblade.modules.business.pojo.dto; |
||||
|
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApply; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApplyDetail; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author 84018 |
||||
* @date 2024-11-25 16:16 |
||||
*/ |
||||
@Data |
||||
@Builder |
||||
public class InvoiceApplyDto { |
||||
InvoiceApply apply; |
||||
|
||||
List<InvoiceApplyDetail> detailList; |
||||
} |
||||
@ -0,0 +1,85 @@ |
||||
package org.springblade.modules.business.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 发票申请表 实体类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Data |
||||
@TableName("lab_invoice_apply") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InvoiceApply extends BaseEntity { |
||||
|
||||
/** |
||||
* 发票ID |
||||
*/ |
||||
private Long invoiceId; |
||||
|
||||
/** |
||||
* 公司名称 |
||||
*/ |
||||
private String companyName; |
||||
|
||||
/** |
||||
* 税号 |
||||
*/ |
||||
private String taxCode; |
||||
|
||||
/** |
||||
* 申请人 |
||||
*/ |
||||
private Long applyUser; |
||||
|
||||
/** |
||||
* 申请人名称 |
||||
*/ |
||||
private String applyUserName; |
||||
|
||||
/** |
||||
* 申请时间 |
||||
*/ |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
private Date applyTime; |
||||
|
||||
/** |
||||
* 开票人 |
||||
*/ |
||||
private Long confirmUser; |
||||
|
||||
/** |
||||
* 开票人 |
||||
*/ |
||||
private String confirmUserName; |
||||
|
||||
/** |
||||
* 开票时间 |
||||
*/ |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
private Date confirmTime; |
||||
|
||||
|
||||
/** |
||||
* 开票金额 |
||||
*/ |
||||
private BigDecimal price; |
||||
|
||||
/** |
||||
* 备注 |
||||
*/ |
||||
private String remark; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
package org.springblade.modules.business.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* 发票申请明细表 实体类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Data |
||||
@TableName("lab_invoice_apply_detail") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InvoiceApplyDetail extends BaseEntity { |
||||
|
||||
/** |
||||
* 申请ID |
||||
*/ |
||||
private Long applyId; |
||||
|
||||
/** |
||||
* 业务类型 |
||||
*/ |
||||
private String businessType; |
||||
|
||||
/** |
||||
* 业务ID |
||||
*/ |
||||
private Long businessId; |
||||
|
||||
/** |
||||
* 备注 |
||||
*/ |
||||
private String detailRemark; |
||||
} |
||||
@ -0,0 +1,14 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApplyDetail; |
||||
|
||||
/** |
||||
* 发票申请明细表 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IInvoiceApplyDetailService extends BaseService<InvoiceApplyDetail> { |
||||
|
||||
} |
||||
@ -0,0 +1,40 @@ |
||||
package org.springblade.modules.business.service; |
||||
|
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.modules.business.pojo.dto.InvoiceApplyDto; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApply; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 发票申请表 服务类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
public interface IInvoiceApplyService extends BaseService<InvoiceApply> { |
||||
|
||||
/** |
||||
* 查询已完成工作列表 |
||||
* |
||||
* @return |
||||
*/ |
||||
List<Map<String, Object>> finishWorkList(); |
||||
|
||||
/** |
||||
* 保存并提交 |
||||
* |
||||
* @param dto |
||||
*/ |
||||
void saveAndSubmit(InvoiceApplyDto dto); |
||||
|
||||
/** |
||||
* 确认开票 |
||||
* |
||||
* @param id |
||||
*/ |
||||
void confirm(Long id); |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,21 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.modules.business.mapper.InvoiceApplyDetailMapper; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApplyDetail; |
||||
import org.springblade.modules.business.service.IInvoiceApplyDetailService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 发票申请明细表 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
public class InvoiceApplyDetailServiceImpl extends BaseServiceImpl<InvoiceApplyDetailMapper, InvoiceApplyDetail> implements IInvoiceApplyDetailService { |
||||
|
||||
} |
||||
@ -0,0 +1,105 @@ |
||||
|
||||
package org.springblade.modules.business.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.modules.business.enums.InvoiceEnum; |
||||
import org.springblade.modules.business.enums.MaintenanceStatusEnum; |
||||
import org.springblade.modules.business.enums.WorkOrderStatusEnum; |
||||
import org.springblade.modules.business.mapper.InvoiceApplyMapper; |
||||
import org.springblade.modules.business.pojo.dto.InvoiceApplyDto; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApply; |
||||
import org.springblade.modules.business.pojo.entity.InvoiceApplyDetail; |
||||
import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTask; |
||||
import org.springblade.modules.business.pojo.entity.workorder.WorkOrder; |
||||
import org.springblade.modules.business.service.IInvoiceApplyService; |
||||
import org.springblade.modules.business.service.IMaintenanceTaskService; |
||||
import org.springblade.modules.business.service.IWorkOrderService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 发票申请表 服务实现类 |
||||
* |
||||
* @author BladeX |
||||
* @since 2024-10-14 |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
public class InvoiceApplyServiceImpl extends BaseServiceImpl<InvoiceApplyMapper, InvoiceApply> implements IInvoiceApplyService { |
||||
|
||||
private InvoiceApplyDetailServiceImpl detailService; |
||||
private final IWorkOrderService workOrderService; |
||||
private final IMaintenanceTaskService taskService; |
||||
|
||||
|
||||
@Override |
||||
public List<Map<String, Object>> finishWorkList() { |
||||
return baseMapper.finishWorkList(); |
||||
} |
||||
|
||||
@Override |
||||
public void saveAndSubmit(InvoiceApplyDto dto) { |
||||
// 先保存申请
|
||||
InvoiceApply apply = dto.getApply(); |
||||
InvoiceApply applyOld = getById(apply.getId()); |
||||
if (Func.isEmpty(applyOld)) { |
||||
applyOld = apply; |
||||
applyOld.setCreateUser(AuthUtil.getUserId()); |
||||
} |
||||
|
||||
applyOld.setApplyUser(AuthUtil.getUserId()); |
||||
applyOld.setApplyUserName(AuthUtil.getUserName()); |
||||
applyOld.setApplyTime(DateUtil.now()); |
||||
|
||||
applyOld.setUpdateUser(AuthUtil.getUserId()); |
||||
applyOld.setStatus(InvoiceEnum.INVOICE_STATUS_APPLY.getValue()); |
||||
saveOrUpdate(applyOld); |
||||
|
||||
List<InvoiceApplyDetail> applyDetails = dto.getDetailList(); |
||||
for (InvoiceApplyDetail applyDetail : applyDetails) { |
||||
applyDetail.setApplyId(applyOld.getId()); |
||||
} |
||||
detailService.saveOrUpdateBatch(applyDetails); |
||||
} |
||||
|
||||
@Override |
||||
public void confirm(Long id) { |
||||
InvoiceApply applyOld = getById(id); |
||||
applyOld.setUpdateUser(AuthUtil.getUserId()); |
||||
applyOld.setConfirmUser(AuthUtil.getUserId()); |
||||
applyOld.setConfirmUserName(AuthUtil.getUserName()); |
||||
applyOld.setConfirmTime(DateUtil.now()); |
||||
applyOld.setStatus(InvoiceEnum.INVOICE_STATUS_CONFIRM.getValue()); |
||||
updateById(applyOld); |
||||
|
||||
// 获取明细, 更新明细的开票状态
|
||||
List<InvoiceApplyDetail> applyDetails = detailService.list(Wrappers.lambdaQuery(InvoiceApplyDetail.class).eq(InvoiceApplyDetail::getApplyId, id)); |
||||
|
||||
List<MaintenanceTask> taskOldList = new ArrayList<>(); |
||||
List<WorkOrder> orderOldList = new ArrayList<>(); |
||||
|
||||
for (InvoiceApplyDetail applyDetail : applyDetails) { |
||||
if (String.valueOf(InvoiceEnum.BUSINESS_TYPE_ORDER.getValue()) == applyDetail.getBusinessType()) { |
||||
MaintenanceTask taskOld = taskService.getById(applyDetail.getBusinessId()); |
||||
taskOld.setRepairStatus(MaintenanceStatusEnum.REPAIR_INVOICE.getValue()); |
||||
taskOldList.add(taskOld); |
||||
} |
||||
if (String.valueOf(InvoiceEnum.BUSINESS_TYPE_MAINTENANCE.getValue()) == applyDetail.getBusinessType()) { |
||||
WorkOrder workOrderOld = workOrderService.getById(applyDetail.getBusinessId()); |
||||
workOrderOld.setStatus(WorkOrderStatusEnum.TICKET.getValue()); |
||||
orderOldList.add(workOrderOld); |
||||
} |
||||
} |
||||
|
||||
taskService.updateBatchById(taskOldList); |
||||
workOrderService.updateBatchById(orderOldList); |
||||
} |
||||
} |
||||
@ -0,0 +1,23 @@ |
||||
|
||||
package org.springblade.modules.system.pojo.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class LogDTO { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private String startTime; |
||||
private String endTime; |
||||
|
||||
// 日志类型:1登录日志 2修改日志
|
||||
private String logType; |
||||
|
||||
// 用户id
|
||||
private String userId; |
||||
} |
||||
@ -0,0 +1,23 @@ |
||||
|
||||
package org.springblade.modules.system.pojo.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class LogRecord { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
// 时间
|
||||
private String time; |
||||
|
||||
// 日志实体
|
||||
private List<LogVO> logs; |
||||
|
||||
} |
||||
@ -0,0 +1,31 @@ |
||||
|
||||
package org.springblade.modules.system.pojo.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class LogVO { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private String tenantId; |
||||
|
||||
private String createBy; |
||||
|
||||
@JsonIgnore |
||||
private Date createTime; |
||||
|
||||
private String time; |
||||
|
||||
private String title; |
||||
|
||||
// 真实姓名
|
||||
private String realName; |
||||
} |
||||
Loading…
Reference in new issue