18 changed files with 662 additions and 22 deletions
@ -0,0 +1,25 @@ |
|||||
|
package com.qs.serve.modules.oms.entity.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/10/7 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class OmsSpuToSkuKey2 { |
||||
|
|
||||
|
private String sourceInvCode; |
||||
|
|
||||
|
/** |
||||
|
* 实质为spuCode |
||||
|
*/ |
||||
|
private String skuCode; |
||||
|
|
||||
|
/** |
||||
|
* 实质为skuCode |
||||
|
*/ |
||||
|
private String invCode; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,103 @@ |
|||||
|
package com.qs.serve.modules.tbs.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-12-18 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("tbs_cost_change_info") |
||||
|
public class TbsCostChangeInfo implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 原费用申请ID */ |
||||
|
private Long sourceId; |
||||
|
|
||||
|
/** 新的费用申请ID */ |
||||
|
private Long extendId; |
||||
|
|
||||
|
/** 更变的表主体 */ |
||||
|
@Length(max = 255,message = "更变的表主体长度不能超过255字") |
||||
|
private String changeType; |
||||
|
|
||||
|
/** 修改信息 */ |
||||
|
@Length(max = 512,message = "修改信息长度不能超过512字") |
||||
|
private String changeInfo; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@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; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
|
||||
|
public static TbsCostChangeInfo toNewObject(String changeType,String changeInfo){ |
||||
|
TbsCostChangeInfo costChangeInfo = new TbsCostChangeInfo(); |
||||
|
costChangeInfo.setChangeType(changeType); |
||||
|
costChangeInfo.setChangeInfo(changeInfo); |
||||
|
return costChangeInfo; |
||||
|
} |
||||
|
|
||||
|
public static TbsCostChangeInfo toNewObject(TbsCostChangeInfo source){ |
||||
|
TbsCostChangeInfo costChangeInfo = new TbsCostChangeInfo(); |
||||
|
costChangeInfo.setId(source.getId()); |
||||
|
costChangeInfo.setSourceId(source.getSourceId()); |
||||
|
costChangeInfo.setExtendId(source.getExtendId()); |
||||
|
costChangeInfo.setChangeType(source.getChangeType()); |
||||
|
costChangeInfo.setChangeInfo(source.getChangeInfo()); |
||||
|
costChangeInfo.setCreateTime(source.getCreateTime()); |
||||
|
costChangeInfo.setUpdateTime(source.getUpdateTime()); |
||||
|
costChangeInfo.setTenantId(source.getTenantId()); |
||||
|
costChangeInfo.setCreateBy(source.getCreateBy()); |
||||
|
costChangeInfo.setUpdateBy(source.getUpdateBy()); |
||||
|
costChangeInfo.setDelFlag(source.getDelFlag()); |
||||
|
return costChangeInfo; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.tbs.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsCostChangeInfo; |
||||
|
|
||||
|
/** |
||||
|
* 异动信息 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2023-12-18 |
||||
|
*/ |
||||
|
public interface TbsCostChangeInfoMapper extends BaseMapper<TbsCostChangeInfo> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,16 @@ |
|||||
|
package com.qs.serve.modules.tbs.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.tbs.entity.TbsCostChangeInfo; |
||||
|
|
||||
|
/** |
||||
|
* 异动信息 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2023-12-18 |
||||
|
*/ |
||||
|
public interface TbsCostChangeInfoService extends IService<TbsCostChangeInfo> { |
||||
|
|
||||
|
void compareToBuildChangeInfo(Long orgId,Long newId); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,260 @@ |
|||||
|
package com.qs.serve.modules.tbs.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.qs.serve.common.config.properties.ProjectProperties; |
||||
|
import com.qs.serve.modules.bir.mapper.BirActivityCenterGoodsMapper; |
||||
|
import com.qs.serve.modules.bir.mapper.BirBaseActivityMapper; |
||||
|
import com.qs.serve.modules.bir.mapper.BirRoiRateMapper; |
||||
|
import com.qs.serve.modules.bir.service.BirCenterRateService; |
||||
|
import com.qs.serve.modules.bir.service.BirRoiRateService; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsSupplierTargetMapper; |
||||
|
import com.qs.serve.modules.bms.service.BmsSubjectService; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
||||
|
import com.qs.serve.modules.erp.mapper.ErpDispatchDataMapper; |
||||
|
import com.qs.serve.modules.seeyon.service.SeeYonRequestService; |
||||
|
import com.qs.serve.modules.sys.service.SysAttachService; |
||||
|
import com.qs.serve.modules.sys.service.SysUserService; |
||||
|
import com.qs.serve.modules.tbs.entity.*; |
||||
|
import com.qs.serve.modules.tbs.mapper.*; |
||||
|
import com.qs.serve.modules.tbs.service.*; |
||||
|
import com.qs.serve.modules.vtb.mapper.VtbVerificationMapper; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 异动信息 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-12-18 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class TbsCostChangeInfoServiceImpl extends ServiceImpl<TbsCostChangeInfoMapper,TbsCostChangeInfo> implements TbsCostChangeInfoService { |
||||
|
|
||||
|
private TbsCostApplyService costApplyService; |
||||
|
private TbsBudgetApplicationService budgetApplicationService; |
||||
|
private TbsBudgetCostItemService budgetCostItemService; |
||||
|
private TbsBudgetLogService budgetLogService; |
||||
|
private SysUserService sysUserService; |
||||
|
private SeeYonRequestService seeYonService; |
||||
|
private TbsActivityTemplateService tbsActivityTemplateService; |
||||
|
private TbsActivityCenterService tbsActivityCenterService; |
||||
|
private TbsActivitySubjectService tbsActivitySubjectService; |
||||
|
private TbsActivityGoodsService tbsActivityGoodsService; |
||||
|
private TbsCostUnItemService tbsCostUnItemService; |
||||
|
private BmsSupplierService bmsSupplierService; |
||||
|
private BmsRegionMapper regionMapper; |
||||
|
private BmsRegion2Mapper region2Mapper; |
||||
|
private BmsSubjectService subjectService; |
||||
|
private TbsCostTodoMapper tbsCostTodoMapper; |
||||
|
private TbsActivitySlottingFeeMapper activitySlottingFeeMapper; |
||||
|
private TbsActivityPayConditionMapper tbsActivityPayConditionMapper; |
||||
|
private TbsActivityService activityService; |
||||
|
private TbsActivitySubjectService activitySubjectService; |
||||
|
private TbsActivityCenterService activityCenterService; |
||||
|
private TbsActivityChannelService activityChannelService; |
||||
|
|
||||
|
@Override |
||||
|
public void compareToBuildChangeInfo(Long orgId, Long newId) { |
||||
|
List<TbsCostChangeInfo> changeInfoList = new ArrayList<>(); |
||||
|
TbsCostApply oldApply = costApplyService.getById(orgId); |
||||
|
TbsCostApply newApply = costApplyService.getById(newId); |
||||
|
if(!oldApply.getChargeTheme().equals(newApply.getChargeTheme())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("档案标题更变",newApply.getChargeTheme())); |
||||
|
} |
||||
|
List<TbsActivity> orgActivityList = activityService.listByCostApplyId(orgId); |
||||
|
List<TbsActivity> newActivityList = activityService.listByCostApplyId(newId); |
||||
|
|
||||
|
// 判断活动减少 && 活动内容变更
|
||||
|
for (TbsActivity orgAct : orgActivityList) { |
||||
|
boolean orgMatchNewAct = false; |
||||
|
for (TbsActivity newAct : newActivityList) { |
||||
|
if(orgAct.getActivityCode().equals(newAct.getActivityCode())){ |
||||
|
orgMatchNewAct = true; |
||||
|
if(orgAct.getActTitle().equals(newAct.getActTitle())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动活动简述及目的更变",newAct.getActTitle())); |
||||
|
} |
||||
|
if(!orgAct.getActStartDate().equals(newAct.getActStartDate())||!orgAct.getActEndDate().equals(newAct.getActEndDate())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+newAct.getActivityCode()+"]时间更变", |
||||
|
"原:"+orgAct.getActStartDate().toString()+"-"+orgAct.getActEndDate()+" ;"+ |
||||
|
"异动后:" +newAct.getActStartDate().toString()+"-"+newAct.getActEndDate()) |
||||
|
); |
||||
|
} |
||||
|
if(!orgAct.getPreStartDate().equals(newAct.getPreStartDate())|| |
||||
|
!orgAct.getPreEndDate().equals(newAct.getPreEndDate())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+newAct.getActivityCode()+"]预计核销日期更变", |
||||
|
"原:"+orgAct.getPreStartDate().toString()+"-"+orgAct.getPreEndDate()+" ;"+ |
||||
|
"异动后:" +newAct.getPreStartDate().toString()+"-"+newAct.getPreEndDate()) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
List<TbsActivitySubject> subjectNewList = activitySubjectService.listByActivityId(newAct.getId()); |
||||
|
List<TbsActivitySubject> subjectOrgList = activitySubjectService.listByActivityId(orgAct.getId()); |
||||
|
//处理科目异动
|
||||
|
this.buildByActivitySubject(orgAct,subjectNewList, subjectOrgList,changeInfoList ); |
||||
|
//处理网点异动
|
||||
|
this.buildChannelByActs(orgAct, newAct,changeInfoList); |
||||
|
this.buildPointByActs(orgAct, newAct,changeInfoList); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if(!orgMatchNewAct){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("移除活动","["+orgAct.getActivityCode()+"]"+orgAct.getActTitle())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 判断活动新增
|
||||
|
for (TbsActivity newAct : newActivityList) { |
||||
|
boolean matchNewAct = false; |
||||
|
for (TbsActivity orgAct : orgActivityList) { |
||||
|
if(orgAct.getActivityCode().equals(newAct.getActivityCode())){ |
||||
|
matchNewAct = true; |
||||
|
} |
||||
|
} |
||||
|
if(!matchNewAct){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("新增活动","["+newAct.getActivityCode()+"]"+newAct.getActTitle())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void buildPointByActs(TbsActivity orgAct, TbsActivity newAct,List<TbsCostChangeInfo> changeInfoList ) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void buildChannelByActs(TbsActivity orgAct, TbsActivity newAct,List<TbsCostChangeInfo> changeInfoList ) { |
||||
|
List<TbsActivityChannel> oldChannelList = activityChannelService.listByActivityId(orgAct.getId()); |
||||
|
List<TbsActivityChannel> newChannelList = activityChannelService.listByActivityId(newAct.getId()); |
||||
|
boolean hasChannel = oldChannelList.size()>0||newChannelList.size()>0; |
||||
|
if(hasChannel){ |
||||
|
for (TbsActivityChannel oldChannel : oldChannelList) { |
||||
|
boolean matchOld = false; |
||||
|
for (TbsActivityChannel newChannel : newChannelList) { |
||||
|
if(oldChannel.getChannelId().equals(newChannel.getChannelId())){ |
||||
|
matchOld = true; |
||||
|
if(oldChannel.getChannelRate().compareTo(newChannel.getChannelRate())!=0 || |
||||
|
!oldChannel.getPreCountPoint().equals(newChannel.getPreCountPoint()) |
||||
|
){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+orgAct.getActivityCode()+"]渠道更变", |
||||
|
"原费用占比:"+oldChannel.getChannelRate()+"% 投放网点数量: "+oldChannel.getPreCountPoint() |
||||
|
+"; 原费用占比:"+newChannel.getChannelRate()+"% 投放网点数量: "+newChannel.getPreCountPoint())); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
if(!matchOld){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+orgAct.getActivityCode()+"]渠道删除", |
||||
|
oldChannel.getChannelCode()+"/"+oldChannel.getChannelName()+",费用占比:"+ |
||||
|
oldChannel.getChannelRate()+"% 投放网点数量: "+oldChannel.getPreCountPoint())); |
||||
|
} |
||||
|
} |
||||
|
for (TbsActivityChannel newChannel : newChannelList) { |
||||
|
boolean matchNew = false; |
||||
|
for (TbsActivityChannel oldChannel : oldChannelList) { |
||||
|
if(oldChannel.getChannelId().equals(newChannel.getChannelId())){ |
||||
|
matchNew = true; |
||||
|
} |
||||
|
} |
||||
|
if(!matchNew){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+orgAct.getActivityCode()+"]渠道新增", |
||||
|
newChannel.getChannelCode()+"/"+newChannel.getChannelName()+",费用占比:"+ |
||||
|
newChannel.getChannelRate()+"% 投放网点数量: "+newChannel.getPreCountPoint())); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void buildByActivitySubject(TbsActivity activity,List<TbsActivitySubject> subjectNewList, List<TbsActivitySubject> subjectOrgList,List<TbsCostChangeInfo> changeInfoList ) { |
||||
|
for (TbsActivitySubject oldSubject : subjectOrgList) { |
||||
|
boolean matchNew = false; |
||||
|
for (TbsActivitySubject newSubject : subjectNewList) { |
||||
|
if(newSubject.getSubjectId().equals(oldSubject.getSubjectId())){ |
||||
|
matchNew = true; |
||||
|
if(!newSubject.getAmount().equals(oldSubject.getAmount())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+activity.getActivityCode()+"]的科目["+newSubject.getSubjectName()+"]金额调整", |
||||
|
"原来金额:"+oldSubject.getAmount()+" 异动后金额:"+newSubject.getAmount())); |
||||
|
} |
||||
|
if(!newSubject.getCountSession().equals(oldSubject.getCountSession())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+activity.getActivityCode()+"]的科目["+newSubject.getSubjectName()+"]场次调整", |
||||
|
"原来场次:"+oldSubject.getCountSession()+" 异动后场次:"+newSubject.getCountSession())); |
||||
|
} |
||||
|
if(!newSubject.getCountPerson().equals(oldSubject.getCountPerson())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+activity.getActivityCode()+"]的科目["+newSubject.getSubjectName()+"]场次调整", |
||||
|
"原来人数:"+oldSubject.getCountPerson()+" 异动后人数:"+newSubject.getCountPerson())); |
||||
|
} |
||||
|
//异动的成本中心
|
||||
|
this.buildCenterChangeLog(activity, oldSubject, newSubject,changeInfoList ); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if(!matchNew){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动移除科目", |
||||
|
"活动["+activity.getActivityCode()+"]移除科目["+oldSubject.getSubjectCode()+"]"+oldSubject.getSubjectName())); |
||||
|
} |
||||
|
} |
||||
|
for (TbsActivitySubject newSubject : subjectNewList) { |
||||
|
boolean matchOld = false; |
||||
|
for (TbsActivitySubject oldSubject : subjectOrgList) { |
||||
|
if(newSubject.getSubjectId().equals(oldSubject.getSubjectId())){ |
||||
|
matchOld = true; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
if(!matchOld){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动新增科目", |
||||
|
"活动["+activity.getActivityCode()+"]新科目["+newSubject.getSubjectCode()+"]"+newSubject.getSubjectName())); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void buildCenterChangeLog(TbsActivity activity, TbsActivitySubject oldSubject, TbsActivitySubject newSubject,List<TbsCostChangeInfo> changeInfoList ) { |
||||
|
List<TbsActivityCenter> newCenterList = activityCenterService.listByActivity(activity.getId(), newSubject.getId()); |
||||
|
List<TbsActivityCenter> oldCenterList = activityCenterService.listByActivity(activity.getId(), oldSubject.getId()); |
||||
|
for (TbsActivityCenter newCenter : newCenterList) { |
||||
|
boolean matchOld = false; |
||||
|
for (TbsActivityCenter oldCenter : oldCenterList) { |
||||
|
if(newCenter.getCenterType().equals(oldCenter.getCenterType()) |
||||
|
&&newCenter.getCenterId().equals(oldCenter.getCenterId())){ |
||||
|
matchOld = true; |
||||
|
if(!newCenter.getCenterRate().equals(oldCenter.getCenterRate()) |
||||
|
||!newCenter.getCenterAmount().equals(oldCenter.getCenterAmount())){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+activity.getActivityCode()+"]科目["+newSubject.getSubjectCode()+"]成本中心调整", |
||||
|
"原来占比:"+oldCenter.getCenterRate()+"% 合计:"+oldCenter.getCenterAmount()+" ;" + |
||||
|
" 异动后: "+newCenter.getCenterRate()+"% 合计: "+newCenter.getCenterAmount() |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
if(!matchOld){ |
||||
|
changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+activity.getActivityCode()+"]科目["+newSubject.getSubjectCode()+"]新增成本中心",newCenter.getCenterName())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for (TbsActivityCenter oldCenter : oldCenterList) { |
||||
|
boolean matchNew = false; |
||||
|
for (TbsActivityCenter newCenter : newCenterList) { |
||||
|
if(newCenter.getCenterType().equals(oldCenter.getCenterType()) |
||||
|
&&newCenter.getCenterId().equals(oldCenter.getCenterId())){ |
||||
|
matchNew = true; |
||||
|
} |
||||
|
} |
||||
|
if(!matchNew){changeInfoList.add(TbsCostChangeInfo.toNewObject("活动["+activity.getActivityCode()+"]科目["+newSubject.getSubjectCode()+"]移除成本中心", |
||||
|
oldCenter.getCenterName())); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue