减免接口开发
This commit is contained in:
parent
0816be447e
commit
32c403c8b5
|
|
@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新购验收任务详细Mapper接口
|
* 新购验收任务详细Mapper接口
|
||||||
*
|
*
|
||||||
* @author xsheng
|
* @author xsheng
|
||||||
* @date 2024-10-16
|
* @date 2024-10-16
|
||||||
*/
|
*/
|
||||||
|
|
@ -27,7 +27,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询新购验收任务详细
|
* 查询新购验收任务详细
|
||||||
*
|
*
|
||||||
* @param id 新购验收任务详细主键
|
* @param id 新购验收任务详细主键
|
||||||
* @return 新购验收任务详细
|
* @return 新购验收任务详细
|
||||||
*/
|
*/
|
||||||
|
|
@ -47,7 +47,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询新购验收任务详细列表
|
* 查询新购验收任务详细列表
|
||||||
*
|
*
|
||||||
* @param purchaseCheckDetails 新购验收任务详细
|
* @param purchaseCheckDetails 新购验收任务详细
|
||||||
* @return 新购验收任务详细集合
|
* @return 新购验收任务详细集合
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,7 +57,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增新购验收任务详细
|
* 新增新购验收任务详细
|
||||||
*
|
*
|
||||||
* @param purchaseCheckDetails 新购验收任务详细
|
* @param purchaseCheckDetails 新购验收任务详细
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,7 +71,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改新购验收任务详细
|
* 修改新购验收任务详细
|
||||||
*
|
*
|
||||||
* @param purchaseCheckDetails 新购验收任务详细
|
* @param purchaseCheckDetails 新购验收任务详细
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -82,7 +82,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
* @param taskId 任务id
|
* @param taskId 任务id
|
||||||
* @param newTaskStatus 新状态
|
* @param newTaskStatus 新状态
|
||||||
*/
|
*/
|
||||||
int batchUpdateDetailsTaskStatus(@Param("taskId") Long taskId, @Param("newTaskStatus") Integer newTaskStatus, @Param("checkResult") String checkResult);
|
int batchUpdateDetailsTaskStatus(@Param("taskId") Long taskId,@Param("newTaskStatus") Integer newTaskStatus, @Param("checkResult") String checkResult);
|
||||||
|
|
||||||
// int updatePurchaseDetails(PurchaseCheckDetails details);
|
// int updatePurchaseDetails(PurchaseCheckDetails details);
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除新购验收任务详细
|
* 删除新购验收任务详细
|
||||||
*
|
*
|
||||||
* @param id 新购验收任务详细主键
|
* @param id 新购验收任务详细主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
@ -102,7 +102,7 @@ public interface PurchaseCheckDetailsMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除新购验收任务详细
|
* 批量删除新购验收任务详细
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据主键集合
|
* @param ids 需要删除的数据主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.bonus.material.settlement.controller;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.bonus.common.log.annotation.SysLog;
|
||||||
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||||
|
import com.bonus.material.settlement.service.ISltAgreementReduceService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算协议申请Controller
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2024-10-16
|
||||||
|
*/
|
||||||
|
@Api(tags = "结算协议减免接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/slt_agreement_reduce")
|
||||||
|
public class SltAgreementReduceController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private ISltAgreementReduceService sltAgreementReduceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询结算协议减免申请列表
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询结算协议减免申请列表")
|
||||||
|
@RequiresPermissions("settlement:apply:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SltAgreementReduce sltAgreement) {
|
||||||
|
startPage();
|
||||||
|
List<SltAgreementReduce> list = sltAgreementReduceService.selectSltAgreementReduceList(sltAgreement);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询协议申请减免明细
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询协议申请减免明细")
|
||||||
|
// @RequiresPermissions("settlement:apply:list")
|
||||||
|
@GetMapping("/applyByParam")
|
||||||
|
public AjaxResult applyByParam(SltAgreementReduce sltAgreement) {
|
||||||
|
List<SltAgreementReduce> list = null;
|
||||||
|
if(sltAgreement!=null){
|
||||||
|
if (sltAgreement.getAgreementId()!=null){
|
||||||
|
list = sltAgreementReduceService.getApplyReduceList(sltAgreement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询协议申请减免明细
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "查询协议申请减免明细")
|
||||||
|
// @RequiresPermissions("settlement:apply:list")
|
||||||
|
@SysLog(title = "申请减免", businessType = OperaType.INSERT, logType = 1,module = "结算关联->申请减免")
|
||||||
|
@PostMapping("/addApply")
|
||||||
|
public AjaxResult addApply( @RequestBody SltAgreementReduce sltAgreement) {
|
||||||
|
try {
|
||||||
|
return sltAgreementReduceService.addApply(sltAgreement);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
package com.bonus.material.settlement.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.BmFileInfo;
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.apache.poi.hpsf.Decimal;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算协议申请对象 slt_agreement_reduce
|
||||||
|
*
|
||||||
|
* @author csyue
|
||||||
|
* @date 2025-10-16
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class SltAgreementReduce extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 协议id */
|
||||||
|
@ApiModelProperty(value = "协议id")
|
||||||
|
private Long agreementId;
|
||||||
|
|
||||||
|
/** 结算单号(例如:JM202402-1) */
|
||||||
|
@Excel(name = "减免单号", readConverterExp = "例=如:JM202402-1")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 创建人 */
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
/** 状态0未结算1待审核2审核通过3审核驳回 */
|
||||||
|
@Excel(name = "状态0未结算1待审核2审核通过3审核驳回")
|
||||||
|
@ApiModelProperty(value = "状态0未结算1待审核2审核通过3审核驳回")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 数据所属 */
|
||||||
|
@Excel(name = "数据所属")
|
||||||
|
@ApiModelProperty(value = "数据所属")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
/** 结算总费用 */
|
||||||
|
@Excel(name = "结算总费用")
|
||||||
|
@ApiModelProperty(value = "结算总费用")
|
||||||
|
private BigDecimal cost;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "原因")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具规格id")
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具名称")
|
||||||
|
private String maName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具规格")
|
||||||
|
private String maModel;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机具单位")
|
||||||
|
private String maUnit;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "租赁数量")
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "租赁单价")
|
||||||
|
private BigDecimal leasePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "租赁开始时间")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "租赁结束时间")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "租赁天数")
|
||||||
|
private Long days;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "租赁金额")
|
||||||
|
private BigDecimal leaseMoney;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "减免数量")
|
||||||
|
private BigDecimal reduceNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "减免租赁单价")
|
||||||
|
private BigDecimal reduceLeasePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "减免开始时间")
|
||||||
|
private Date reduceStartTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "减免结束时间")
|
||||||
|
private Date reduceEndTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "减免租赁费用")
|
||||||
|
private BigDecimal reduceLeaseMoney;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "减免天数")
|
||||||
|
private Long reduceDays;
|
||||||
|
|
||||||
|
private BmFileInfo file;
|
||||||
|
|
||||||
|
private List<SltAgreementReduce> detailList;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.bonus.material.settlement.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算协议减免Mapper接口
|
||||||
|
*
|
||||||
|
* @author yuecs
|
||||||
|
* @date 2025-10-16
|
||||||
|
*/
|
||||||
|
public interface SltAgreementReduceMapper {
|
||||||
|
|
||||||
|
List<SltAgreementReduce> selectSltAgreementReduceList(SltAgreementReduce sltAgreement);
|
||||||
|
|
||||||
|
List<SltAgreementReduce> getApplyReduceList(SltAgreementReduce sltAgreement);
|
||||||
|
|
||||||
|
String getMaxCode(String date);
|
||||||
|
|
||||||
|
Long insertReduce(SltAgreementReduce sltAgreement);
|
||||||
|
|
||||||
|
void insertReduceDetail(SltAgreementReduce sltAgreementReduce);
|
||||||
|
|
||||||
|
void insertBatchReduceDetail(@Param("detailList") List<SltAgreementReduce> detailList);
|
||||||
|
|
||||||
|
List<SltAgreementReduce> findOverlappingReductions(SltAgreementReduce detail);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.bonus.material.settlement.service;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算协议减免Service接口
|
||||||
|
*
|
||||||
|
* @author yuecs
|
||||||
|
* @date 2025-10-16
|
||||||
|
*/
|
||||||
|
public interface ISltAgreementReduceService {
|
||||||
|
|
||||||
|
List<SltAgreementReduce> selectSltAgreementReduceList(SltAgreementReduce sltAgreement);
|
||||||
|
|
||||||
|
List<SltAgreementReduce> getApplyReduceList(SltAgreementReduce sltAgreement);
|
||||||
|
|
||||||
|
AjaxResult addApply(SltAgreementReduce sltAgreement);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,172 @@
|
||||||
|
package com.bonus.material.settlement.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||||
|
import com.bonus.material.settlement.domain.SltAgreementReduce;
|
||||||
|
import com.bonus.material.settlement.mapper.SltAgreementReduceMapper;
|
||||||
|
import com.bonus.material.settlement.service.ISltAgreementReduceService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算协议减免Service业务层处理
|
||||||
|
*
|
||||||
|
* @author yuecs
|
||||||
|
* @date 2025-10-16
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SltAgreementReduceServiceImpl implements ISltAgreementReduceService {
|
||||||
|
@Autowired
|
||||||
|
private SltAgreementReduceMapper sltAgreementRecudceMapper;
|
||||||
|
@Autowired
|
||||||
|
private BmFileInfoMapper bmFileInfoMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SltAgreementReduce> selectSltAgreementReduceList(SltAgreementReduce sltAgreement) {
|
||||||
|
return sltAgreementRecudceMapper.selectSltAgreementReduceList(sltAgreement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SltAgreementReduce> getApplyReduceList(SltAgreementReduce sltAgreement) {
|
||||||
|
return sltAgreementRecudceMapper.getApplyReduceList(sltAgreement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class) // 对所有异常回滚
|
||||||
|
public AjaxResult addApply(SltAgreementReduce sltAgreement) {
|
||||||
|
try {
|
||||||
|
List<SltAgreementReduce> list = sltAgreement.getDetailList();
|
||||||
|
//bmFileInfoMapper.insertBmFileInfo()
|
||||||
|
// 初始化 SltAgreementReduce 对象
|
||||||
|
initSltAgreement(sltAgreement);
|
||||||
|
|
||||||
|
List<SltAgreementReduce> applyReduction = applyReduction(sltAgreement);
|
||||||
|
|
||||||
|
Long rs = sltAgreementRecudceMapper.insertReduce(sltAgreement);
|
||||||
|
Long id = sltAgreement.getId();
|
||||||
|
if (rs > 0 && list != null) {
|
||||||
|
// 批量插入明细
|
||||||
|
List<SltAgreementReduce> detailList = list.stream()
|
||||||
|
.peek(detail -> detail.setId(id))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
sltAgreementRecudceMapper.insertBatchReduceDetail(detailList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
// 记录详细的数据库操作异常日志
|
||||||
|
log.error("数据库操作失败: {}", e.getMessage(), e);
|
||||||
|
return AjaxResult.error("系统错误, 数据库操作失败");
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 记录其他异常日志
|
||||||
|
log.error("系统错误: {}", e.getMessage(), e);
|
||||||
|
return AjaxResult.error("系统错误, " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSltAgreement(SltAgreementReduce sltAgreement) {
|
||||||
|
sltAgreement.setCode(generateCode());
|
||||||
|
sltAgreement.setCreateTime(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<SltAgreementReduce> applyReduction(SltAgreementReduce sltAgreement) {
|
||||||
|
// 初始化结果列表
|
||||||
|
List<SltAgreementReduce> newReductions = new ArrayList<>();
|
||||||
|
|
||||||
|
// 遍历申请减免的每个区间
|
||||||
|
for (SltAgreementReduce detail : sltAgreement.getDetailList()) {
|
||||||
|
if (detail.getReduceStartTime() != null && detail.getReduceEndTime() != null) {
|
||||||
|
// 将当前区间添加到结果列表中
|
||||||
|
|
||||||
|
// 查询与当前区间有重叠的历史减免记录
|
||||||
|
List<SltAgreementReduce> historyReductions = sltAgreementRecudceMapper.findOverlappingReductions(detail);
|
||||||
|
|
||||||
|
// 对比并去掉重叠部分
|
||||||
|
for (SltAgreementReduce history : historyReductions) {
|
||||||
|
List<SltAgreementReduce> temp = new ArrayList<>();
|
||||||
|
for (SltAgreementReduce current : newReductions) {
|
||||||
|
// 如果当前区间与历史区间没有重叠,直接保留
|
||||||
|
if (current.getEndTime().before(history.getStartTime()) || current.getStartTime().after(history.getEndTime())) {
|
||||||
|
temp.add(current);
|
||||||
|
} else {
|
||||||
|
// 如果有重叠,拆分当前区间
|
||||||
|
if (current.getStartTime().before(history.getStartTime())) {
|
||||||
|
// 生成新的区间:申请开始时间到历史开始时间的前一天
|
||||||
|
SltAgreementReduce newReduction = new SltAgreementReduce();
|
||||||
|
//计算新的租赁情况
|
||||||
|
newReduction.setStartTime(current.getStartTime());
|
||||||
|
newReduction.setEndTime(new Date(history.getStartTime().getTime() - 86400000));
|
||||||
|
long days = (history.getStartTime().getTime() - current.getStartTime().getTime()) / (24 * 60 * 60 * 1000) +1;
|
||||||
|
BigDecimal num = current.getNum();
|
||||||
|
BigDecimal leasePrice = current.getLeasePrice();
|
||||||
|
newReduction.setLeasePrice(leasePrice);
|
||||||
|
BigDecimal leaseMoney = new BigDecimal(days).multiply(num).multiply(leasePrice);
|
||||||
|
newReduction.setLeaseMoney(leaseMoney);
|
||||||
|
temp.add(
|
||||||
|
newReduction
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (current.getEndTime().after(history.getEndTime())) {
|
||||||
|
// 生成新的区间:历史结束时间的后一天到申请结束时间
|
||||||
|
SltAgreementReduce newReduction = new SltAgreementReduce();
|
||||||
|
//计算新的租赁情况
|
||||||
|
newReduction.setStartTime( new Date(history.getEndTime().getTime() + 86400000));
|
||||||
|
newReduction.setEndTime( current.getEndTime());
|
||||||
|
long days = (current.getEndTime().getTime() - history.getEndTime().getTime()) / (24 * 60 * 60 * 1000) +1;
|
||||||
|
BigDecimal num = current.getNum();
|
||||||
|
BigDecimal leasePrice = current.getLeasePrice();
|
||||||
|
newReduction.setLeasePrice(leasePrice);
|
||||||
|
BigDecimal leaseMoney = new BigDecimal(days).multiply(num).multiply(leasePrice);
|
||||||
|
newReduction.setLeaseMoney(leaseMoney);
|
||||||
|
temp.add(
|
||||||
|
newReduction
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newReductions = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return newReductions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String generateCode() {
|
||||||
|
// 获取当前日期,格式为 YYYYMMDD
|
||||||
|
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||||
|
// 获取当前日期,格式为 YYY-YM-MDD
|
||||||
|
// 查询当前最大单号
|
||||||
|
String maxCode = sltAgreementRecudceMapper.getMaxCode(date);
|
||||||
|
|
||||||
|
// 生成新单号
|
||||||
|
String newCode;
|
||||||
|
if (maxCode == null) {
|
||||||
|
// 如果当天没有单号,生成第一个单号
|
||||||
|
newCode = "JM" + date + "-0001";
|
||||||
|
} else {
|
||||||
|
// 提取序号部分并加 1
|
||||||
|
int lastNumber = Integer.parseInt(maxCode.substring(maxCode.length() - 4));
|
||||||
|
// 补零到 4 位
|
||||||
|
String newNumber = String.format("%04d", lastNumber + 1);
|
||||||
|
newCode = "JM" + date + "-" + newNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -342,6 +342,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
bm_qrcode_info bqi
|
bm_qrcode_info bqi
|
||||||
WHERE
|
WHERE
|
||||||
qr_code = #{qrCode}
|
qr_code = #{qrCode}
|
||||||
|
<if test="taskId != null">
|
||||||
|
AND bqi.task_id = #{taskId}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPurchaseCheckDetailsById" resultType="com.bonus.material.purchase.domain.vo.PurchaseVo">
|
<select id="selectPurchaseCheckDetailsById" resultType="com.bonus.material.purchase.domain.vo.PurchaseVo">
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
update
|
update
|
||||||
purchase_check_details
|
purchase_check_details
|
||||||
set
|
set
|
||||||
`status` = #{newTaskStatus}, check_result = #{checkResult}
|
pre_status = #{status}, `status` = #{newTaskStatus}, check_result = #{checkResult}
|
||||||
where
|
where
|
||||||
task_id = #{taskId}
|
task_id = #{taskId}
|
||||||
and
|
and
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,191 @@
|
||||||
|
<?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.bonus.material.settlement.mapper.SltAgreementReduceMapper">
|
||||||
|
<resultMap type="com.bonus.material.settlement.domain.SltAgreementReduce" id="SltAgreementReudceResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="code" column="code" />
|
||||||
|
<result property="creator" column="creator" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="companyId" column="company_id" />
|
||||||
|
<result property="cost" column="cost" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="typeId" column="typeId" />
|
||||||
|
<result property="maName" column="maName" />
|
||||||
|
<result property="maModel" column="maModel" />
|
||||||
|
<result property="num" column="num" />
|
||||||
|
<result property="leasePrice" column="leasePrice" />
|
||||||
|
<result property="startTime" column="startTime" />
|
||||||
|
<result property="endTime" column="endTime" />
|
||||||
|
<result property="days" column="days" />
|
||||||
|
<result property="leaseMoney" column="leaseMoney" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectSltAgreementReduceVo">
|
||||||
|
select id, code, creator, create_time, update_time, status, company_id, cost, remark from slt_reduce_apply
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSltAgreementReduceList" parameterType="com.bonus.material.settlement.domain.SltAgreementReduce" resultMap="SltAgreementReudceResult">
|
||||||
|
<include refid="selectSltAgreementReduceVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="code != null and code != ''"> and code = #{code}</if>
|
||||||
|
<if test="creator != null and creator != ''"> and creator = #{creator}</if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
<if test="companyId != null "> and company_id = #{companyId}</if>
|
||||||
|
<if test="cost != null "> and cost = #{cost}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getApplyReduceList" resultMap="SltAgreementReudceResult">
|
||||||
|
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
rs.id,
|
||||||
|
rs.typeId,
|
||||||
|
rs.agreementId,
|
||||||
|
rs.maName,
|
||||||
|
rs.maModel,
|
||||||
|
rs.maUnit,
|
||||||
|
SUM(rs.num) as num,
|
||||||
|
rs.leasePrice,
|
||||||
|
LEFT(rs.startTime,10) startTime,
|
||||||
|
LEFT(rs.endTime,10) endTime,
|
||||||
|
DATEDIFF(rs.endTime,rs.startTime)+1 as days ,
|
||||||
|
ROUND(SUM(rs.num)*rs.leasePrice*(DATEDIFF(rs.endTime,rs.startTime)+1) ,2)AS leaseMoney
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
sai.id,
|
||||||
|
sai.agreement_id as agreementId,
|
||||||
|
sai.type_id as typeId,
|
||||||
|
sai.ma_id,
|
||||||
|
mt2.type_name as maName,
|
||||||
|
mt.type_name as maModel,
|
||||||
|
mt.unit_name as maUnit,
|
||||||
|
sai.num,
|
||||||
|
sai.start_time as startTime,
|
||||||
|
IFNULL(sai.end_time,NOW()) as endTime,
|
||||||
|
DATEDIFF(IFNULL(sai.end_time,NOW()),sai.start_time)+1 as days,
|
||||||
|
sai.`status`,
|
||||||
|
sai.lease_price as leasePrice
|
||||||
|
FROM
|
||||||
|
slt_agreement_info sai
|
||||||
|
left join ma_type mt on sai.type_id = mt.type_id
|
||||||
|
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||||
|
where
|
||||||
|
sai.agreement_id = #{agreementId}
|
||||||
|
<if test="startTime != null">
|
||||||
|
AND start_time <= #{endTime}
|
||||||
|
AND (end_time >= #{startTime} OR end_time IS NULL)
|
||||||
|
</if>
|
||||||
|
) rs
|
||||||
|
GROUP BY rs.typeId,rs.startTime
|
||||||
|
ORDER BY rs.maName
|
||||||
|
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getMaxCode" resultType="java.lang.String">
|
||||||
|
SELECT
|
||||||
|
MAX( CODE ) AS maxCode
|
||||||
|
FROM
|
||||||
|
slt_reduce_apply
|
||||||
|
WHERE
|
||||||
|
code LIKE CONCAT('%', #{date},'%')
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertReduce" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into slt_reduce_apply
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="code != null">code,</if>
|
||||||
|
<if test="creator != null">creator,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="agreementId != null">agreement_id,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="companyId != null">company_id,</if>
|
||||||
|
<if test="cost != null">cost,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="code != null">#{code},</if>
|
||||||
|
<if test="creator != null">#{creator},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="agreementId != null">#{agreementId},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="companyId != null">#{companyId},</if>
|
||||||
|
<if test="cost != null">#{cost},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
</trim>
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertReduceDetail">
|
||||||
|
insert into slt_reduce_details
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null">apply_id,</if>
|
||||||
|
<if test="startTime != null">start_time,</if>
|
||||||
|
<if test="endTime != null">end_time,</if>
|
||||||
|
<if test="typeId != null">type_id,</if>
|
||||||
|
<if test="num != null">num,</if>
|
||||||
|
<if test="reduceNum != null">reduce_num,</if>
|
||||||
|
<if test="reduceStartTime != null">r_start_time,</if>
|
||||||
|
<if test="reduceEndTime != null">r_end_time,</if>
|
||||||
|
<if test="reduceLeasePrice != null">lease_price,</if>
|
||||||
|
<if test="reduceLeaseMoney != null">lease_money,</if>
|
||||||
|
<if test="reduceDays != null">days,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="code != null">#{id},</if>
|
||||||
|
<if test="startTime != null">#{startTime},</if>
|
||||||
|
<if test="endTime != null">#{endTime},</if>
|
||||||
|
<if test="typeId != null">#{typeId},</if>
|
||||||
|
<if test="num != null">#{num},</if>
|
||||||
|
<if test="reduceNum != null">#{reduceNum},</if>
|
||||||
|
<if test="reduceStartTime != null">#{reduceStartTime},</if>
|
||||||
|
<if test="reduceEndTime != null">#{reduceEndTime},</if>
|
||||||
|
<if test="reduceLeasePrice != null">#{reduceLeasePrice},</if>
|
||||||
|
<if test="reduceLeaseMoney != null">#{reduceLeaseMoney},</if>
|
||||||
|
<if test="reduceDays != null">#{reduceDays},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertBatchReduceDetail" parameterType="java.util.List">
|
||||||
|
INSERT INTO slt_reduce_details
|
||||||
|
(apply_id, start_time, end_time, type_id, num, reduce_num, r_start_time, r_end_time, lease_price, lease_money, days)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="detailList" item="item" index="index" separator=",">
|
||||||
|
(
|
||||||
|
#{item.id},
|
||||||
|
#{item.startTime},
|
||||||
|
#{item.endTime},
|
||||||
|
#{item.typeId},
|
||||||
|
#{item.num},
|
||||||
|
#{item.reduceNum},
|
||||||
|
#{item.reduceStartTime},
|
||||||
|
#{item.reduceEndTime},
|
||||||
|
#{item.leasePrice},
|
||||||
|
#{item.reduceLeaseMoney},
|
||||||
|
#{item.reduceDays}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="findOverlappingReductions" resultMap="SltAgreementReudceResult">
|
||||||
|
|
||||||
|
SELECT *
|
||||||
|
FROM slt_reduce_details sd
|
||||||
|
left join slt_reduce_apply sa on sd.apply_id = sa.id
|
||||||
|
WHERE
|
||||||
|
sa.agreement_id = #{agreementId}
|
||||||
|
AND sd.type_id = #{typeId}
|
||||||
|
AND start_time <= #{endTime}
|
||||||
|
AND end_time >= #{startTime}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
8
pom.xml
8
pom.xml
|
|
@ -271,6 +271,9 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<version>3.12.0</version>
|
<version>3.12.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
@ -288,5 +291,10 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue