Browse Source

fix:增加修复品类预算脚本

checkBack
Yen 1 year ago
parent
commit
22cc8e36c5
  1. 4
      src/main/java/com/qs/serve/modules/bir/controller/BirActivityCenterGoodsController.java
  2. 5
      src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java
  3. 6
      src/main/java/com/qs/serve/modules/bms/entity/bo/BmsSupplierBo.java
  4. 36
      src/main/java/com/qs/serve/modules/sys/mapper/SysTableTempMapper.java
  5. 10
      src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java
  6. 86
      src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyTestController.java
  7. 2
      src/main/java/com/qs/serve/modules/tbs/service/TbsCostApplyService.java
  8. 26
      src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java
  9. 14
      src/main/java/com/qs/serve/modules/vtb/service/impl/VtbVerificationServiceImpl.java
  10. 4
      src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java

4
src/main/java/com/qs/serve/modules/bir/controller/BirActivityCenterGoodsController.java

@ -155,8 +155,8 @@ public class BirActivityCenterGoodsController {
.eq(TbsCostApply::getCancelFlag,0) .eq(TbsCostApply::getCancelFlag,0)
.gt(TbsCostApply::getTotalActivity,0) .gt(TbsCostApply::getTotalActivity,0)
.ne(TbsCostApply::getTmpState,11) .ne(TbsCostApply::getTmpState,11)
//.le(TbsCostApply::getCreateTime, LocalDate.of(2024,1,1).atStartOfDay()) .le(TbsCostApply::getCreateTime, LocalDate.of(2024,1,1).atStartOfDay())
.ge(TbsCostApply::getCreateTime, LocalDate.of(2024,1,1).atStartOfDay()) ; .ge(TbsCostApply::getCreateTime, LocalDate.of(2024,2,1).atStartOfDay()) ;
boolean ex = extracted(lqw); boolean ex = extracted(lqw);
while (!ex){ while (!ex){
ex = extracted(lqw); ex = extracted(lqw);

5
src/main/java/com/qs/serve/modules/bir/service/impl/BirCenterRateServiceImpl.java

@ -373,6 +373,11 @@ public class BirCenterRateServiceImpl implements BirCenterRateService {
log.error("[{}]创建客户成本中心的费率出现异常:{}",supplierCode,e.getMessage()); log.error("[{}]创建客户成本中心的费率出现异常:{}",supplierCode,e.getMessage());
} }
} }
costCenter.setCenterCode(centerKey);
costCenter.setCentertype(centerType);
costCenter.setCenterId(centerId);
return costCenter; return costCenter;
} }

6
src/main/java/com/qs/serve/modules/bms/entity/bo/BmsSupplierBo.java

@ -101,4 +101,10 @@ public class BmsSupplierBo {
private String comRegionCode; private String comRegionCode;
/**
* CD订单
* 0-> 非必填
* 1-> 下单时必须填写CD订单信息
*/
private Integer cdOrderFlag;
} }

36
src/main/java/com/qs/serve/modules/sys/mapper/SysTableTempMapper.java

@ -1,7 +1,14 @@
package com.qs.serve.modules.sys.mapper; package com.qs.serve.modules.sys.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.modules.sys.entity.SysTableTemp; import com.qs.serve.modules.sys.entity.SysTableTemp;
import com.qs.serve.modules.tbs.entity.TbsBudgetCostItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/** /**
* 临时数据表 Mapper * 临时数据表 Mapper
@ -10,5 +17,34 @@ import com.qs.serve.modules.sys.entity.SysTableTemp;
*/ */
public interface SysTableTempMapper extends BaseMapper<SysTableTemp> { public interface SysTableTempMapper extends BaseMapper<SysTableTemp> {
@InterceptorIgnore(tenantLine = "1")
@Select("select t1.* from tbs_budget_cost_item t1 " +
" left join tbs_activity t2 on t1.activity_id = t2.id " +
" left join tbs_cost_apply t3 on t1.cost_apply_id = t3.id " +
" where 1=1 " +
" and t1.del_flag = 0 " +
" and t2.del_flag = 0 " +
" and t3.del_flag = 0 " +
" and t2.cancel_flag = 0 " +
" and t3.cancel_flag = 0 " +
" and t3.charge_state in (1,2,3) " +
//" and t1.id = 2009163" )
" and (t1.check_state is null or t1.check_state = 0)" +
" and t3.code like '24%' limit 1000 ")
List<TbsBudgetCostItem> getListByCostId();
@InterceptorIgnore(tenantLine = "1")
@Update("<script>"+
"update tbs_budget_cost_item set check_state = #{state} where id in " +
" <foreach collection='itemIds' item='id' open='(' separator=',' close=')'>"+
" #{id} "+
" </foreach> "+
"</script>")
int updateBudgetCoistItemState(@Param("itemIds") List<Long> itemId,@Param("state") Integer state);
@InterceptorIgnore(tenantLine = "1")
@Select("select cost_apply_id from `tbs_budget_cost_item` where check_state = 2 group by cost_apply_id ")
List<Long> getGoodsUnMatchCostIds();
} }

10
src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyCheckController.java

@ -108,13 +108,17 @@ public class TbsCostApplyCheckController {
LambdaQueryWrapper<TbsCostApply> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TbsCostApply> lqw = new LambdaQueryWrapper<>();
lqw.in(TbsCostApply::getId,Arrays.asList(ids)); lqw.in(TbsCostApply::getId,Arrays.asList(ids));
//lqw.notIn(TbsCostApply::getId,Arrays.asList(notIds)); //lqw.notIn(TbsCostApply::getId,Arrays.asList(notIds));
lqw.notLike(TbsCostApply::getRemark,"审批节点重置"); //lqw.notLike(TbsCostApply::getRemark,"审批节点重置");
lqw.select(TbsCostApply::getId); lqw.in(TbsCostApply::getChargeState,1,2,3);
lqw.select(TbsCostApply::getId,TbsCostApply::getChargeState,TbsCostApply::getCode);
List<TbsCostApply> costApplyList = tbsCostApplyService.list(lqw); List<TbsCostApply> costApplyList = tbsCostApplyService.list(lqw);
List<String> msgs = new ArrayList<>();
for (TbsCostApply costApply : costApplyList) { for (TbsCostApply costApply : costApplyList) {
tbsCostApplyService.replaceApplySyData(costApply.getId()+""); String msg = tbsCostApplyService.replaceApplySyData(costApply.getId()+"");
msgs.add(costApply.getCode() + " : " + msg);
} }
msgs.forEach(System.out::println);
return R.ok(); return R.ok();
} }

86
src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyTestController.java

@ -34,6 +34,7 @@ import com.qs.serve.modules.tbs.entity.dto.TbsCostErrorBudgetDTO;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableResultVo; import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableResultVo;
import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo; import com.qs.serve.modules.tbs.entity.vo.TbsBudgetTableVo;
import com.qs.serve.modules.tbs.entity.vo.TbsCostApplyVo; import com.qs.serve.modules.tbs.entity.vo.TbsCostApplyVo;
import com.qs.serve.modules.tbs.mapper.TbsBudgetConditionMapper;
import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper; import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper;
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper; import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper;
import com.qs.serve.modules.tbs.service.*; import com.qs.serve.modules.tbs.service.*;
@ -87,38 +88,87 @@ public class TbsCostApplyTestController {
private TbsBudgetCostItemService budgetCostItemService; private TbsBudgetCostItemService budgetCostItemService;
private TbsBudgetLogService budgetLogService; private TbsBudgetLogService budgetLogService;
private SysTableTempMapper sysTableTempMapper; private SysTableTempMapper sysTableTempMapper;
private TbsBudgetConditionMapper tbsBudgetConditionMapper;
/**
* 判断预算商品的条件是否匹配
* @return
*/
@GetMapping("matchGoods")
public R<?> matchGoods(){
for (int i = 0; i < 1000; i++) {
matchGoods1000();
}
return R.ok();
}
@GetMapping("reBuildGoods")
//@GetMapping("/overspendRebuildAll") public R<?> reBuildGoods(){
public R<?> ss(){ List<Long> costIds = sysTableTempMapper.getGoodsUnMatchCostIds();
LambdaQueryWrapper<SysTableTemp> lqw = new LambdaQueryWrapper<>(); for (Long costId : costIds) {
lqw.eq(SysTableTemp::getOptionTitle,"rebuildCost"); overRebuildCost(costId);
lqw.likeRight(SysTableTemp::getResultMsg,"预算未匹配");
lqw.eq(SysTableTemp::getDealState,0);
List<SysTableTemp> sysTableTempList = sysTableTempMapper.selectList(lqw);
for (SysTableTemp tableTemp : sysTableTempList) {
overRebuildCost(Long.parseLong(tableTemp.getTableId()));
} }
return R.ok(sysTableTempList.size()); return R.ok();
} }
@GetMapping("/overspendRebuild")
public R<?> ss2(Long costId){ private void matchGoods1000() {
return overRebuildCost(costId); List<TbsBudgetCondition> conditionList = tbsBudgetConditionMapper.selectList(new QueryWrapper<>());
Map<Long,List<TbsBudgetCondition>> conditionListMap = conditionList.stream().collect(Collectors.groupingBy(TbsBudgetCondition::getBudgetId));
List<TbsBudgetCostItem> budgetCostItemList = sysTableTempMapper.getListByCostId();
if(budgetCostItemList.size()<1){
Assert.throwEx("匹配完成");
}
List<Long> mIds = new ArrayList<>();
mIds.add(0L);
List<Long> umIds = new ArrayList<>();
umIds.add(0L);
for (TbsBudgetCostItem item : budgetCostItemList) {
List<TbsBudgetCondition> conditions = conditionListMap.get(item.getBudgetId());
if(conditions==null||conditions.size()<1){
mIds.add(item.getId());
continue;
}
boolean m = false;
for (TbsBudgetCondition condition : conditions) {
String itemLevels = item.getTargetLevelPathIds();
String conGoodsId = condition.getTargetId()+"";
if(itemLevels.equals(conGoodsId) || itemLevels.contains(conGoodsId+"_")){
mIds.add(item.getId());
m = true;
break;
}
}
//没有匹配到预算
if(!m){
umIds.add(item.getId());
}
}
sysTableTempMapper.updateBudgetCoistItemState(mIds,1);
sysTableTempMapper.updateBudgetCoistItemState(umIds,2);
} }
public void saveTableTmp(SysTableTemp sysTableTemp){ public void saveTableTmp(SysTableTemp sysTableTemp){
sysTableTempMapper.insert(sysTableTemp); sysTableTempMapper.insert(sysTableTemp);
} }
//@GetMapping("/overRebuildCost")
public R<?> overRebuildCost(Long costApplyId){ public R<?> overRebuildCost(Long costApplyId){
SysTableTemp sysTableTemp = new SysTableTemp(); SysTableTemp sysTableTemp = new SysTableTemp();
sysTableTemp.setTableName("tbs_cost_apply"); sysTableTemp.setTableName("tbs_cost_apply");
sysTableTemp.setTableId(""+costApplyId); sysTableTemp.setTableId(""+costApplyId);
sysTableTemp.setOptionTitle("overRebuildCost"); //后缀数字 2 标识第几次批次
sysTableTemp.setOptionTitle("overRebuildCost2");
LambdaQueryWrapper<SysTableTemp> checkExist = new LambdaQueryWrapper<>();
long count = sysTableTempMapper.selectCount(checkExist.eq(SysTableTemp::getTableId,costApplyId)
.eq(SysTableTemp::getOptionTitle,sysTableTemp.getOptionTitle()));
if(count>0){
return R.ok();
}
TbsCostApply costApply = tbsCostApplyService.getById(costApplyId); TbsCostApply costApply = tbsCostApplyService.getById(costApplyId);
TbsBudgetTableResultVo resultVo = tbsBudgetMatchApplication.getMatchResult(costApplyId ,false,true); TbsBudgetTableResultVo resultVo = tbsBudgetMatchApplication.getMatchResult(costApplyId ,false,true);
@ -258,7 +308,7 @@ public class TbsCostApplyTestController {
// 设置remark标记防止误删,移除旧的记录 // 设置remark标记防止误删,移除旧的记录
for (TbsBudgetCostItem costItem : itemList) { for (TbsBudgetCostItem costItem : itemList) {
costItem.setRemark("toDel"); costItem.setRemark("toDel2");
} }
budgetCostItemService.updateBatchById(itemList); budgetCostItemService.updateBatchById(itemList);
List<Long> itemIds = itemList.stream().map(TbsBudgetCostItem::getId).collect(Collectors.toList()); List<Long> itemIds = itemList.stream().map(TbsBudgetCostItem::getId).collect(Collectors.toList());
@ -271,7 +321,7 @@ public class TbsCostApplyTestController {
bLqw.eq(TbsBudgetLog::getCostApplyId,costApplyId); bLqw.eq(TbsBudgetLog::getCostApplyId,costApplyId);
List<TbsBudgetLog> dbbudgetLogs = budgetLogService.list(bLqw); List<TbsBudgetLog> dbbudgetLogs = budgetLogService.list(bLqw);
for (TbsBudgetLog budgetLog : dbbudgetLogs) { for (TbsBudgetLog budgetLog : dbbudgetLogs) {
budgetLog.setRemark("toDel"); budgetLog.setRemark("toDel2");
} }
budgetLogService.updateBatchById(dbbudgetLogs); budgetLogService.updateBatchById(dbbudgetLogs);
List<Long> budIds = dbbudgetLogs.stream().map(TbsBudgetLog::getId).collect(Collectors.toList()); List<Long> budIds = dbbudgetLogs.stream().map(TbsBudgetLog::getId).collect(Collectors.toList());

2
src/main/java/com/qs/serve/modules/tbs/service/TbsCostApplyService.java

@ -61,7 +61,7 @@ public interface TbsCostApplyService extends IService<TbsCostApply> {
* 事故修复方法替换原来的审批流程(仅支持无核销的审批) * 事故修复方法替换原来的审批流程(仅支持无核销的审批)
* @param id * @param id
*/ */
void replaceApplySyData(String id); String replaceApplySyData(String id);
/** /**
* 获取致远data * 获取致远data

26
src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java

@ -353,18 +353,18 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
} }
@Override @Override
public void replaceApplySyData(String id) { public String replaceApplySyData(String id) {
TbsCostApply tbsCostApply = this.getById(id); TbsCostApply tbsCostApply = this.getById(id);
//确保只能执行一次 //确保只能执行一次
if(tbsCostApply.getRemark()!=null && tbsCostApply.getRemark().contains("审批节点重置")){ if(tbsCostApply.getRemark()!=null && tbsCostApply.getRemark().contains("审批节点重置")){
return; return "已存在";
} }
LambdaQueryWrapper<VtbVerification> vtbLqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<VtbVerification> vtbLqw = new LambdaQueryWrapper<>();
vtbLqw.eq(VtbVerification::getCostApplyId,id).in(VtbVerification::getVerificationState,0,1); vtbLqw.eq(VtbVerification::getCostApplyId,id).in(VtbVerification::getVerificationState,0,1);
if(vtbVerificationMapper.selectCount(vtbLqw)>0){ if(vtbVerificationMapper.selectCount(vtbLqw)>0){
return; return "有核销";
} }
BmsSupplier supplier = bmsSupplierService.getById(tbsCostApply.getSupplierId()); BmsSupplier supplier = bmsSupplierService.getById(tbsCostApply.getSupplierId());
@ -463,6 +463,9 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
if(flowIdResult==null||flowIdResult.getStatus()!=200){ if(flowIdResult==null||flowIdResult.getStatus()!=200){
Assert.throwEx("远程服务调用失败:"+flowIdResult.getMsg()); Assert.throwEx("远程服务调用失败:"+flowIdResult.getMsg());
} }
if(flowIdResult.getData().contains("按登录名查找发起人出错")){
return "按登录名查找发起人出错";
}
String flowId = flowIdResult.getData(); String flowId = flowIdResult.getData();
if(flowId!=null&&flowId.length()>45){ if(flowId!=null&&flowId.length()>45){
flowId = flowId.substring(0,40); flowId = flowId.substring(0,40);
@ -480,12 +483,13 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
costApply.setChargeState(TbsCostApplyState.State_1_apply.getCode()); costApply.setChargeState(TbsCostApplyState.State_1_apply.getCode());
costApply.setSubmitTime(LocalDateTime.now()); costApply.setSubmitTime(LocalDateTime.now());
costApply.setRemark("审批节点重置("+tbsCostApply.getSyFormId()+");" costApply.setRemark("审批节点重置("+tbsCostApply.getSyFormId()+");"
+tbsCostApply.getRemark()==null?"":tbsCostApply.getRemark()); +(tbsCostApply.getRemark()==null?"":tbsCostApply.getRemark()));
this.updateById(costApply); this.updateById(costApply);
//创建流程后回调 //创建流程后回调
BaseCreateCallbackBo callbackBo = new BaseCreateCallbackBo(templateCode,costApply.getId()+""); BaseCreateCallbackBo callbackBo = new BaseCreateCallbackBo(templateCode,costApply.getId()+"");
seeYonService.createCallbackStatus(callbackBo); seeYonService.createCallbackStatus(callbackBo);
return "success";
} }
@Override @Override
@ -1317,9 +1321,19 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
List<TbsActivityCenter> centerList = centerMapList.values().stream().map(a->a.get(0)).collect(Collectors.toList()); List<TbsActivityCenter> centerList = centerMapList.values().stream().map(a->a.get(0)).collect(Collectors.toList());
for(TbsActivityCenter center : centerList){ for(TbsActivityCenter center : centerList){
TbsCostSubItem.CostCenterTranStr costCenter = BirHttpUtil.buildCostCenter(center.getCenterType(),center.getCenterId(),center.getCenterName(),supplierCode); TbsCostSubItem.CostCenterTranStr costCenter = BirHttpUtil.buildCostCenter(center.getCenterType(),center.getCenterId(),center.getCenterName(),supplierCode);
if(costCenter!=null){ if(costCenter==null ){
subList.add(costCenter); log.error("BIR 成本中心缺失:{},{},{},{}",
center.getCenterType(),
center.getCenterId(),
center.getCenterName(),
supplierCode);
Assert.throwEx("成本中心缺失,请联系工作人员");
}
if(costCenter.getChengBenZhongXin()==null){
costCenter.setChengBenZhongXin(center.getCenterName());
costCenter.setChengBenZhongXinId(center.getCenterType()+"-"+center.getId());
} }
subList.add(costCenter);
} }
} }

14
src/main/java/com/qs/serve/modules/vtb/service/impl/VtbVerificationServiceImpl.java

@ -1124,9 +1124,19 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
List<TbsActivityCenter> activityCenter = activityCenterService.listByActivity(verification.getActivityId()); List<TbsActivityCenter> activityCenter = activityCenterService.listByActivity(verification.getActivityId());
for(TbsActivityCenter center : activityCenter){ for(TbsActivityCenter center : activityCenter){
TbsCostSubItem.CostCenterTranStr costCenter = BirHttpUtil.buildCostCenter(center.getCenterType(),center.getCenterId(),center.getCenterName(),activity.getSupplierCode()); TbsCostSubItem.CostCenterTranStr costCenter = BirHttpUtil.buildCostCenter(center.getCenterType(),center.getCenterId(),center.getCenterName(),activity.getSupplierCode());
if(costCenter!=null){ if(costCenter==null ){
subList.add(costCenter); log.error("BIR 成本中心缺失(核销):{},{},{},{}",
center.getCenterType(),
center.getCenterId(),
center.getCenterName(),
activity.getSupplierCode());
Assert.throwEx("成本中心缺失,请联系工作人员");
}
if(costCenter.getChengBenZhongXin()==null){
costCenter.setChengBenZhongXin(center.getCenterName());
costCenter.setChengBenZhongXinId(center.getCenterType()+"-"+center.getId());
} }
subList.add(costCenter);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

4
src/main/java/com/qs/serve/modules/wx/service/impl/WxPushServiceImpl.java

@ -41,9 +41,9 @@ public class WxPushServiceImpl implements WxPushService {
// 发送模板消息 // 发送模板消息
msgId = wxMpConfig.wxMpService().switchoverTo(appId).getTemplateMsgService().sendTemplateMsg(message); msgId = wxMpConfig.wxMpService().switchoverTo(appId).getTemplateMsgService().sendTemplateMsg(message);
} catch (WxErrorException e) { } catch (WxErrorException e) {
e.printStackTrace(); log.warn("推送微信模板失败,{}",e.getMessage());
} }
log.warn("推送微信模板信息:{}\n{}", msgId != null ? "成功" : "失败", JsonUtil.objectToJson(message)); log.info("推送微信模板信息:{}\n{}", msgId != null ? "成功" : "失败", JsonUtil.objectToJson(message));
} }
@Override @Override

Loading…
Cancel
Save