15 changed files with 851 additions and 60 deletions
@ -0,0 +1,126 @@ |
|||||
|
package com.qs.serve.modules.bir.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 预算考核期项 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-07-07 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("bir_schedule_item_budget") |
||||
|
public class BirScheduleItemBudget implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 考核id */ |
||||
|
@NotNull(message = "考核id不能为空") |
||||
|
private Long scheduleId; |
||||
|
|
||||
|
/** 考核期项id */ |
||||
|
@NotNull(message = "考核期项id不能为空") |
||||
|
private Long scheduleItemId; |
||||
|
|
||||
|
/** 考核编码 */ |
||||
|
@NotBlank(message = "考核编码不能为空") |
||||
|
@Length(max = 30,message = "考核编码长度不能超过30字") |
||||
|
private String itemName; |
||||
|
|
||||
|
/** 开始时间 */ |
||||
|
@NotNull(message = "开始时间不能为空") |
||||
|
@Length(max = 0,message = "开始时间长度不能超过0字") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime budgetStartDate; |
||||
|
|
||||
|
/** 结束时间 */ |
||||
|
@NotNull(message = "结束时间不能为空") |
||||
|
@Length(max = 0,message = "结束时间长度不能超过0字") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime budgetEndDate; |
||||
|
|
||||
|
/** 预算id */ |
||||
|
@NotNull(message = "预算id不能为空") |
||||
|
private Long budgetId; |
||||
|
|
||||
|
/** 预算金额 */ |
||||
|
@NotNull(message = "预算金额不能为空") |
||||
|
private BigDecimal budgetAmount; |
||||
|
|
||||
|
/** */ |
||||
|
private BigDecimal preDispatchAmount; |
||||
|
|
||||
|
private BigDecimal splitBudgetAmount; |
||||
|
private BigDecimal splitPreDispatchAmount; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
/** 键值(日期数) */ |
||||
|
@NotNull(message = "键值(日期数)不能为空") |
||||
|
private Integer keyNum; |
||||
|
|
||||
|
/** 当月有多少天 */ |
||||
|
private Integer monthDays; |
||||
|
|
||||
|
/** 活动总天数 */ |
||||
|
private Integer totalDays; |
||||
|
|
||||
|
/** 当月分割开始 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
||||
|
private LocalDate startDate; |
||||
|
|
||||
|
/** 当月分割结束 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
||||
|
private LocalDate endDate; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
package com.qs.serve.modules.bir.entity.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/7/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BirCenterGoodSplitDTO { |
||||
|
|
||||
|
//当前CenterGoods分割项金额
|
||||
|
BigDecimal currentSplitAmount; |
||||
|
|
||||
|
//当前CenterGoods分割项核销金额(粗略计算)
|
||||
|
BigDecimal currentSplitCheckAmount; |
||||
|
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.bir.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.bir.entity.BirScheduleItemBudget; |
||||
|
|
||||
|
/** |
||||
|
* 预算考核期项 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2023-07-07 |
||||
|
*/ |
||||
|
public interface BirScheduleItemBudgetMapper extends BaseMapper<BirScheduleItemBudget> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,19 @@ |
|||||
|
package com.qs.serve.modules.bir.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.bir.entity.BirScheduleItemBudget; |
||||
|
|
||||
|
/** |
||||
|
* 预算考核期项 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2023-07-07 |
||||
|
*/ |
||||
|
public interface BirScheduleItemBudgetService extends IService<BirScheduleItemBudget> { |
||||
|
|
||||
|
/** |
||||
|
* 创建数据 |
||||
|
*/ |
||||
|
void buildScheduleItemBudget(); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,194 @@ |
|||||
|
package com.qs.serve.modules.bir.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.qs.serve.common.model.dto.DateSplitDTO; |
||||
|
import com.qs.serve.common.model.enums.BudgetLogOptFlag; |
||||
|
import com.qs.serve.common.util.Assert; |
||||
|
import com.qs.serve.common.util.DateSplitUtil; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsBudget; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsBudgetLog; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsScheduleItemBudget; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsBudgetMapper; |
||||
|
import com.qs.serve.modules.tbs.mapper.TbsScheduleItemBudgetMapper; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.jetbrains.annotations.NotNull; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.bir.entity.BirScheduleItemBudget; |
||||
|
import com.qs.serve.modules.bir.service.BirScheduleItemBudgetService; |
||||
|
import com.qs.serve.modules.bir.mapper.BirScheduleItemBudgetMapper; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDate; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 预算考核期项 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-07-07 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BirScheduleItemBudgetServiceImpl extends ServiceImpl<BirScheduleItemBudgetMapper,BirScheduleItemBudget> implements BirScheduleItemBudgetService { |
||||
|
|
||||
|
private final TbsBudgetMapper budgetMapper; |
||||
|
private final TbsBudgetLogMapper budgetLogMapper; |
||||
|
private final TbsScheduleItemBudgetMapper scheduleItemBudgetMapper; |
||||
|
|
||||
|
@Override |
||||
|
public void buildScheduleItemBudget() { |
||||
|
//加载所有启用的预算
|
||||
|
LambdaQueryWrapper<TbsBudget> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.select(TbsBudget::getId); |
||||
|
lqw.eq(TbsBudget::getBudgetState,1); |
||||
|
lqw.eq(TbsBudget::getBirFlag,0); |
||||
|
List<TbsBudget> budgetList = budgetMapper.selectList(lqw); |
||||
|
List<Long> budgetIds = budgetList.stream().map(TbsBudget::getId).collect(Collectors.toList()); |
||||
|
//清空异动数据
|
||||
|
LambdaQueryWrapper<BirScheduleItemBudget> rmLqw = new LambdaQueryWrapper<>(); |
||||
|
rmLqw.in(BirScheduleItemBudget::getBudgetId,budgetIds); |
||||
|
this.remove(rmLqw); |
||||
|
//加载所有的调增调减预算
|
||||
|
Map<Long, BigDecimal> budgetLogAmtMap = buildAdjustBudgetAmount(budgetIds); |
||||
|
//加载预算的周期金额
|
||||
|
LambdaQueryWrapper<TbsScheduleItemBudget> sibLqw = new LambdaQueryWrapper<>(); |
||||
|
sibLqw.in(TbsScheduleItemBudget::getBudgetId,budgetIds); |
||||
|
List<TbsScheduleItemBudget> scheduleItemBudgetList = scheduleItemBudgetMapper.selectList(sibLqw); |
||||
|
List<BirScheduleItemBudget> maintenanceList = new ArrayList<>(); |
||||
|
for (TbsScheduleItemBudget scheduleItemBudget : scheduleItemBudgetList) { |
||||
|
// 调整金额
|
||||
|
BigDecimal adjustAmount = budgetLogAmtMap.get(scheduleItemBudget.getId()); |
||||
|
if(adjustAmount!=null){ |
||||
|
scheduleItemBudget.setBudgetAmount(scheduleItemBudget.getBudgetAmount().add(adjustAmount)); |
||||
|
} |
||||
|
// 按时间分割
|
||||
|
LocalDate actStartDate = scheduleItemBudget.getStartDate().toLocalDate(); |
||||
|
LocalDate actEndDate = scheduleItemBudget.getEndDate().toLocalDate(); |
||||
|
int currentActDays = (int) (actEndDate.toEpochDay()-actStartDate.toEpochDay()+1); |
||||
|
List<DateSplitDTO> dateSplitList = DateSplitUtil.getSplitDto(actStartDate,actEndDate); |
||||
|
if(dateSplitList.size()>1){ |
||||
|
//计算剩余
|
||||
|
BigDecimal surplusScheduleBudget = scheduleItemBudget.getBudgetAmount(); |
||||
|
BigDecimal surplusScheduleDispatch = scheduleItemBudget.getPreDispatchAmount(); |
||||
|
for (DateSplitDTO currDateSplit : dateSplitList) { |
||||
|
//日期占比
|
||||
|
BigDecimal dayRate = new BigDecimal(currDateSplit.getDays() + "") |
||||
|
.divide(new BigDecimal(currentActDays + ""), 2, BigDecimal.ROUND_HALF_DOWN); |
||||
|
//分割的金额
|
||||
|
BigDecimal splitBudgetAmt; |
||||
|
BigDecimal splitDispatchAmt; |
||||
|
//最后一项
|
||||
|
if(currDateSplit.getSort().equals(dateSplitList.size())){ |
||||
|
splitBudgetAmt = surplusScheduleBudget; |
||||
|
splitDispatchAmt = surplusScheduleDispatch; |
||||
|
}else { |
||||
|
splitBudgetAmt = scheduleItemBudget.getBudgetAmount().multiply(dayRate); |
||||
|
splitDispatchAmt = scheduleItemBudget.getPreDispatchAmount().multiply(dayRate); |
||||
|
surplusScheduleBudget = surplusScheduleBudget.subtract(splitBudgetAmt); |
||||
|
surplusScheduleDispatch = surplusScheduleDispatch.subtract(splitDispatchAmt); |
||||
|
} |
||||
|
maintenanceList.add( |
||||
|
this.buildMainEntity( |
||||
|
scheduleItemBudget, |
||||
|
currDateSplit, |
||||
|
currentActDays, |
||||
|
splitBudgetAmt, |
||||
|
splitDispatchAmt) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
}else if (dateSplitList.size()==1){ |
||||
|
maintenanceList.add( |
||||
|
this.buildMainEntity( |
||||
|
scheduleItemBudget, |
||||
|
dateSplitList.get(0), |
||||
|
currentActDays, |
||||
|
scheduleItemBudget.getBudgetAmount(), |
||||
|
scheduleItemBudget.getPreDispatchAmount()) |
||||
|
); |
||||
|
}else { |
||||
|
Assert.throwEx("Invalid date"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Builds the main entity |
||||
|
* @param source |
||||
|
* @param dateSplit |
||||
|
* @param totalDays |
||||
|
* @param splitBudgetAmount |
||||
|
* @param splitPreDispatchAmount |
||||
|
* @return |
||||
|
*/ |
||||
|
public BirScheduleItemBudget buildMainEntity(TbsScheduleItemBudget source,DateSplitDTO dateSplit, |
||||
|
Integer totalDays, |
||||
|
BigDecimal splitBudgetAmount, |
||||
|
BigDecimal splitPreDispatchAmount){ |
||||
|
BirScheduleItemBudget scheduleItemBudget = new BirScheduleItemBudget(); |
||||
|
scheduleItemBudget.setId(source.getId()); |
||||
|
scheduleItemBudget.setScheduleId(source.getScheduleId()); |
||||
|
scheduleItemBudget.setScheduleItemId(source.getScheduleItemId()); |
||||
|
scheduleItemBudget.setItemName(source.getItemName()); |
||||
|
scheduleItemBudget.setBudgetStartDate(source.getStartDate()); |
||||
|
scheduleItemBudget.setBudgetEndDate(source.getEndDate()); |
||||
|
scheduleItemBudget.setBudgetId(source.getBudgetId()); |
||||
|
scheduleItemBudget.setBudgetAmount(source.getBudgetAmount()); |
||||
|
scheduleItemBudget.setPreDispatchAmount(source.getPreDispatchAmount()); |
||||
|
scheduleItemBudget.setSplitBudgetAmount(splitBudgetAmount); |
||||
|
scheduleItemBudget.setSplitPreDispatchAmount(splitPreDispatchAmount); |
||||
|
scheduleItemBudget.setRemark(source.getRemark()); |
||||
|
scheduleItemBudget.setCreateTime(source.getCreateTime()); |
||||
|
scheduleItemBudget.setUpdateTime(source.getUpdateTime()); |
||||
|
scheduleItemBudget.setTenantId(source.getTenantId()); |
||||
|
scheduleItemBudget.setCreateBy(source.getCreateBy()); |
||||
|
scheduleItemBudget.setUpdateBy(source.getUpdateBy()); |
||||
|
|
||||
|
scheduleItemBudget.setKeyNum(dateSplit.getYearMonth()); |
||||
|
scheduleItemBudget.setMonthDays(dateSplit.getDays()); |
||||
|
scheduleItemBudget.setTotalDays(totalDays); |
||||
|
scheduleItemBudget.setStartDate(dateSplit.getStartDate()); |
||||
|
scheduleItemBudget.setEndDate(dateSplit.getEndDate()); |
||||
|
|
||||
|
return scheduleItemBudget; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 加载所有的调增调减预算 |
||||
|
* @param budgetIds |
||||
|
* @return key -> scheduleItemBudgetId ; value -> 调整金额 |
||||
|
*/ |
||||
|
@NotNull |
||||
|
private Map<Long, BigDecimal> buildAdjustBudgetAmount(List<Long> budgetIds) { |
||||
|
LambdaQueryWrapper<TbsBudgetLog> budgetLogLqw = new LambdaQueryWrapper<>(); |
||||
|
budgetLogLqw.select(TbsBudgetLog::getBudgetId,TbsBudgetLog::getAmount); |
||||
|
budgetLogLqw.in(TbsBudgetLog::getBudgetId,budgetIds); |
||||
|
budgetLogLqw.in(TbsBudgetLog::getOptType, |
||||
|
BudgetLogOptFlag.State_2.getCode(), |
||||
|
BudgetLogOptFlag.State_3.getCode()); |
||||
|
List<TbsBudgetLog> budgetLogs = budgetLogMapper.selectList(budgetLogLqw); |
||||
|
Map<Long, BigDecimal> budgetLogAmtMap = new HashMap<>(); |
||||
|
Map<Long,List<TbsBudgetLog>> budgetLogsGroup = budgetLogs.stream().collect(Collectors.groupingBy(TbsBudgetLog::getScheduleItemBudgetId)); |
||||
|
for (Long budgetId : budgetLogsGroup.keySet()) { |
||||
|
BigDecimal adjustedAmount = BigDecimal.ZERO; |
||||
|
for (TbsBudgetLog budgetLog : budgetLogsGroup.get(budgetId)) { |
||||
|
if(budgetLog.getAmount() != null) { |
||||
|
adjustedAmount = adjustedAmount.add(budgetLog.getAmount()); |
||||
|
} |
||||
|
} |
||||
|
budgetLogAmtMap.put(budgetId, adjustedAmount); |
||||
|
} |
||||
|
return budgetLogAmtMap; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,128 @@ |
|||||
|
<?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.qs.serve.modules.bir.mapper.BirActivityCenterGoodsMapper"> |
||||
|
|
||||
|
<resultMap id="birActivityCenterGoodsMap" type="com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods" > |
||||
|
<result property="id" column="id"/> |
||||
|
<result property="centerGoodsCode" column="center_goods_code"/> |
||||
|
<result property="costApplyId" column="cost_apply_id"/> |
||||
|
<result property="activityId" column="activity_id"/> |
||||
|
<result property="activityCode" column="activity_code"/> |
||||
|
<result property="subjectId" column="subject_id"/> |
||||
|
<result property="subjectCode" column="subject_code"/> |
||||
|
<result property="subjectName" column="subject_name"/> |
||||
|
<result property="centerType" column="center_type"/> |
||||
|
<result property="centerId" column="center_id"/> |
||||
|
<result property="centerCode" column="center_code"/> |
||||
|
<result property="centerName" column="center_name"/> |
||||
|
<result property="centerAmount" column="center_amount"/> |
||||
|
<result property="centerRate" column="center_rate"/> |
||||
|
<result property="centerGoodsAmount" column="center_goods_amount"/> |
||||
|
<result property="centerGoodsRate" column="center_goods_rate"/> |
||||
|
<result property="usedAmount" column="used_amount"/> |
||||
|
<result property="targetType" column="target_type"/> |
||||
|
<result property="targetId" column="target_id"/> |
||||
|
<result property="targetCode" column="target_code"/> |
||||
|
<result property="targetName" column="target_name"/> |
||||
|
<result property="targetLevelPathIds" column="target_level_path_ids"/> |
||||
|
<result property="targetLevelPathNames" column="target_level_path_names"/> |
||||
|
<result property="remark" column="remark"/> |
||||
|
<result property="createTime" column="create_time"/> |
||||
|
<result property="updateTime" column="update_time"/> |
||||
|
<result property="tenantId" column="tenant_id"/> |
||||
|
<result property="createBy" column="create_by"/> |
||||
|
<result property="updateBy" column="update_by"/> |
||||
|
<result property="delFlag" column="del_flag"/> |
||||
|
<result property="actStartDate" column="act_start_date"/> |
||||
|
<result property="actEndDate" column="act_end_date"/> |
||||
|
<result property="preStartDate" column="pre_start_date"/> |
||||
|
<result property="preEndDate" column="pre_end_date"/> |
||||
|
<result property="preCheckDate" column="pre_check_date"/> |
||||
|
<result property="tmpUk" column="tmp_uk"/> |
||||
|
<result property="supplierId" column="supplier_id"/> |
||||
|
<result property="supplierCode" column="supplier_code"/> |
||||
|
<result property="supplierName" column="supplier_name"/> |
||||
|
|
||||
|
<result property="activityAmt" column="activity_amt"/> |
||||
|
<result property="activityFinishedFlag" column="activity_finished_flag"/> |
||||
|
<result property="activityCheckAmt" column="activity_check_amt"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<sql id="tbsActivityCenterGoodsSql"> |
||||
|
tbs_activity_center_goods.`id`, |
||||
|
tbs_activity_center_goods.`center_goods_code`, |
||||
|
tbs_activity_center_goods.`cost_apply_id`, |
||||
|
tbs_activity_center_goods.`activity_id`, |
||||
|
tbs_activity_center_goods.`activity_code`, |
||||
|
tbs_activity_center_goods.`subject_id`, |
||||
|
tbs_activity_center_goods.`subject_code`, |
||||
|
tbs_activity_center_goods.`subject_name`, |
||||
|
tbs_activity_center_goods.`center_type`, |
||||
|
tbs_activity_center_goods.`center_id`, |
||||
|
tbs_activity_center_goods.`center_code`, |
||||
|
tbs_activity_center_goods.`center_name`, |
||||
|
tbs_activity_center_goods.`center_amount`, |
||||
|
tbs_activity_center_goods.`center_rate`, |
||||
|
tbs_activity_center_goods.`center_goods_amount`, |
||||
|
tbs_activity_center_goods.`center_goods_rate`, |
||||
|
tbs_activity_center_goods.`used_amount`, |
||||
|
tbs_activity_center_goods.`target_type`, |
||||
|
tbs_activity_center_goods.`target_id`, |
||||
|
tbs_activity_center_goods.`target_code`, |
||||
|
tbs_activity_center_goods.`target_name`, |
||||
|
tbs_activity_center_goods.`target_level_path_ids`, |
||||
|
tbs_activity_center_goods.`target_level_path_names`, |
||||
|
tbs_activity_center_goods.`remark`, |
||||
|
tbs_activity_center_goods.`create_time`, |
||||
|
tbs_activity_center_goods.`update_time`, |
||||
|
tbs_activity_center_goods.`tenant_id`, |
||||
|
tbs_activity_center_goods.`create_by`, |
||||
|
tbs_activity_center_goods.`update_by`, |
||||
|
tbs_activity_center_goods.`del_flag`, |
||||
|
tbs_activity_center_goods.`act_start_date`, |
||||
|
tbs_activity_center_goods.`act_end_date`, |
||||
|
tbs_activity_center_goods.`pre_start_date`, |
||||
|
tbs_activity_center_goods.`pre_end_date`, |
||||
|
tbs_activity_center_goods.`pre_check_date`, |
||||
|
tbs_activity_center_goods.`tmp_uk`, |
||||
|
tbs_activity_center_goods.`supplier_id`, |
||||
|
tbs_activity_center_goods.`supplier_code`, |
||||
|
tbs_activity_center_goods.`supplier_name` </sql> |
||||
|
|
||||
|
<select id="selectChangeCenterGoods" resultType="com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods"> |
||||
|
select |
||||
|
tbs_activity.total_amount as activity_amt, |
||||
|
tbs_activity.used_amount as activity_check_amt, |
||||
|
tbs_activity.finished_flag as activity_finished_flag, |
||||
|
tbs_activity_center_goods.* |
||||
|
from tbs_activity_center_goods |
||||
|
left join tbs_activity |
||||
|
on tbs_activity.id = tbs_activity_center_goods.activity_id |
||||
|
left join bir_activity_center_goods |
||||
|
on tbs_activity_center_goods.id = bir_activity_center_goods.activity_center_goods_id |
||||
|
left join `tbs_cost_apply` |
||||
|
on `tbs_activity`.cost_apply_id = `tbs_cost_apply`.id |
||||
|
where |
||||
|
1=1 |
||||
|
and tbs_activity.del_flag = 0 |
||||
|
and tbs_cost_apply.charge_state !=0 |
||||
|
and ( |
||||
|
bir_activity_center_goods.activity_id is null |
||||
|
or bir_activity_center_goods.activity_total_amount != tbs_activity.total_amount |
||||
|
or bir_activity_center_goods.activity_total_check_amount != tbs_activity.used_amount |
||||
|
or bir_activity_center_goods.pre_start_date != tbs_activity.pre_start_date |
||||
|
or bir_activity_center_goods.pre_end_date != tbs_activity.pre_end_date |
||||
|
or bir_activity_center_goods.activity_finished_flag != `tbs_activity`.finished_flag |
||||
|
) |
||||
|
and ( |
||||
|
(tbs_activity.act_start_date between #{startDate} and #{endDate}) |
||||
|
or |
||||
|
(tbs_activity.act_end_date between #{startDate} and #{endDate}) |
||||
|
or |
||||
|
(tbs_activity.act_end_date >= #{endDate} and tbs_activity.act_start_date <= #{startDate}) |
||||
|
) |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
</mapper> |
||||
|
|
Loading…
Reference in new issue