19 changed files with 739 additions and 15 deletions
@ -0,0 +1,32 @@ |
|||||
|
package com.qs.serve.modules.check.common; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/31 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DataSupplierSo { |
||||
|
|
||||
|
/** |
||||
|
* 供应商id |
||||
|
*/ |
||||
|
private String supplierId; |
||||
|
|
||||
|
/** |
||||
|
* 开始时间 |
||||
|
*/ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private LocalDate startDate; |
||||
|
|
||||
|
/** |
||||
|
* 结束时间 |
||||
|
*/ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private LocalDate endDate; |
||||
|
|
||||
|
} |
@ -0,0 +1,101 @@ |
|||||
|
package com.qs.serve.modules.check.controller; |
||||
|
|
||||
|
import com.qs.serve.common.model.annotation.RepeatSubmit; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
||||
|
import com.qs.serve.modules.check.common.DataSupplierSo; |
||||
|
import com.qs.serve.modules.check.entity.DataCheckApplyDetailInfo; |
||||
|
import com.qs.serve.modules.check.entity.DataCheckApplyDetailItem; |
||||
|
import com.qs.serve.modules.check.entity.DataCheckApplyMainInfo; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDate; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
/** |
||||
|
* 数据 对账单 |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/31 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("data/checkApply") |
||||
|
public class DateCheckApplyController { |
||||
|
|
||||
|
private BmsSupplierMapper supplierMapper; |
||||
|
|
||||
|
/** |
||||
|
* 汇总账单 |
||||
|
* @return |
||||
|
*/ |
||||
|
@RepeatSubmit |
||||
|
@GetMapping("/summary") |
||||
|
@SysLog(module = SystemModule.Verification, title = "客户汇总账单", biz = BizType.EXPORT) |
||||
|
public R<DataCheckApplyMainInfo> getSummary(DataSupplierSo param){ |
||||
|
param.getSupplierId(); |
||||
|
DataCheckApplyMainInfo info = new DataCheckApplyMainInfo(); |
||||
|
info.setCostApplyAmt(BigDecimal.ONE); |
||||
|
info.setCheckedAmt(BigDecimal.ONE); |
||||
|
info.setCheckingAmt(BigDecimal.ONE); |
||||
|
info.setNotCheckAmt(BigDecimal.ONE); |
||||
|
info.setDontCheckAmt(BigDecimal.ONE); |
||||
|
info.setPayAmt(BigDecimal.ONE); |
||||
|
info.setUnPayAmt(BigDecimal.ONE); |
||||
|
info.setNotPayAmt(BigDecimal.ONE); |
||||
|
info.setCusName("测试一同胡"); |
||||
|
info.setCusAddress("辽宁省-本溪市-本溪满族自治县-ABKDJFflJKLSDF"); |
||||
|
info.setCusCode("465465465"); |
||||
|
info.setContactUser("测试人"); |
||||
|
info.setContactMobile("13200000000"); |
||||
|
info.setStartDate(LocalDate.now()); |
||||
|
info.setEndDate(LocalDate.now()); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 明细帐 |
||||
|
* @return |
||||
|
*/ |
||||
|
@RepeatSubmit |
||||
|
@GetMapping("/itemized") |
||||
|
@SysLog(module = SystemModule.Verification, title = "客户明细帐", biz = BizType.EXPORT) |
||||
|
public R<DataCheckApplyDetailInfo> getItemized(DataSupplierSo param){ |
||||
|
DataCheckApplyDetailInfo info = new DataCheckApplyDetailInfo(); |
||||
|
|
||||
|
info.setCusName("测试一同胡"); |
||||
|
info.setCusAddress("辽宁省-本溪市-本溪满族自治县-ABKDJFflJKLSDF"); |
||||
|
info.setCusCode("465465465"); |
||||
|
info.setContactUser("测试人"); |
||||
|
info.setContactMobile("13200000000"); |
||||
|
info.setStartDate(LocalDate.now()); |
||||
|
info.setEndDate(LocalDate.now()); |
||||
|
List<DataCheckApplyDetailItem> detailItemList = new ArrayList<>(); |
||||
|
for (int i = 1; i < 31; i++) { |
||||
|
DataCheckApplyDetailItem item = new DataCheckApplyDetailItem(); |
||||
|
item.setActivityCode(System.currentTimeMillis()+""); |
||||
|
item.setActivityDate("2023-12-"+i); |
||||
|
item.setActivityTheme("2023年12月"+i+"日 375g果乐活动档期补差:0.8/包*12000=9600元"); |
||||
|
item.setCostApplyAmt(BigDecimal.ONE); |
||||
|
item.setCheckedAmt(BigDecimal.ONE); |
||||
|
item.setCheckingAmt(BigDecimal.ONE); |
||||
|
item.setNotCheckAmt(BigDecimal.ONE); |
||||
|
item.setDontCheckAmt(BigDecimal.ONE); |
||||
|
item.setPayAmt(BigDecimal.ONE); |
||||
|
item.setUnPayAmt(BigDecimal.ONE); |
||||
|
item.setNotPayAmt(BigDecimal.ONE); |
||||
|
detailItemList.add(item); |
||||
|
} |
||||
|
info.setDetailList(detailItemList); |
||||
|
return R.ok(info); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,58 @@ |
|||||
|
package com.qs.serve.modules.check.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDate; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 对账单 |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/30 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DataCheckApplyDetailInfo { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 客户名 |
||||
|
*/ |
||||
|
private String cusName; |
||||
|
|
||||
|
/** |
||||
|
* 客户地址 |
||||
|
*/ |
||||
|
private String cusAddress; |
||||
|
|
||||
|
/** |
||||
|
* 客户编码 |
||||
|
*/ |
||||
|
private String cusCode; |
||||
|
|
||||
|
/** |
||||
|
* 联系人用户 |
||||
|
*/ |
||||
|
private String contactUser; |
||||
|
|
||||
|
/** |
||||
|
* 联系人 |
||||
|
*/ |
||||
|
private String contactMobile; |
||||
|
|
||||
|
/** |
||||
|
* 起始日期 |
||||
|
*/ |
||||
|
private LocalDate startDate; |
||||
|
|
||||
|
/** |
||||
|
* 截止日期 |
||||
|
*/ |
||||
|
private LocalDate endDate; |
||||
|
|
||||
|
/** |
||||
|
* 明细列表 |
||||
|
*/ |
||||
|
private List<DataCheckApplyDetailItem> detailList; |
||||
|
|
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
package com.qs.serve.modules.check.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDate; |
||||
|
|
||||
|
/** |
||||
|
* 对账单 |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/30 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DataCheckApplyDetailItem { |
||||
|
|
||||
|
/** |
||||
|
* 活动编号 |
||||
|
*/ |
||||
|
private String activityCode; |
||||
|
|
||||
|
/** |
||||
|
* 申请时间 |
||||
|
*/ |
||||
|
private String activityDate; |
||||
|
|
||||
|
/** |
||||
|
* 活动主题 |
||||
|
*/ |
||||
|
private String activityTheme; |
||||
|
|
||||
|
/** |
||||
|
* 已批准(费用申请) |
||||
|
*/ |
||||
|
private BigDecimal costApplyAmt; |
||||
|
|
||||
|
/** |
||||
|
* 已核销 |
||||
|
*/ |
||||
|
private BigDecimal checkedAmt; |
||||
|
|
||||
|
/** |
||||
|
* 申请中 |
||||
|
*/ |
||||
|
private BigDecimal checkingAmt; |
||||
|
|
||||
|
/** |
||||
|
* 未申请 |
||||
|
*/ |
||||
|
private BigDecimal notCheckAmt; |
||||
|
|
||||
|
/** |
||||
|
* 不予核销 |
||||
|
*/ |
||||
|
private BigDecimal dontCheckAmt; |
||||
|
|
||||
|
/** |
||||
|
* 已支付 |
||||
|
*/ |
||||
|
private BigDecimal payAmt; |
||||
|
|
||||
|
/** |
||||
|
* 待支付 |
||||
|
*/ |
||||
|
private BigDecimal unPayAmt; |
||||
|
|
||||
|
/** |
||||
|
* 不再支付 |
||||
|
*/ |
||||
|
private BigDecimal notPayAmt; |
||||
|
|
||||
|
} |
@ -0,0 +1,134 @@ |
|||||
|
package com.qs.serve.modules.his.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-05-31 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("his_user_supplier_temp") |
||||
|
public class HisUserSupplierTemp implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 用户id */ |
||||
|
@NotBlank(message = "用户id不能为空") |
||||
|
@Length(max = 32,message = "用户id长度不能超过32字") |
||||
|
private String userId; |
||||
|
|
||||
|
/** 供应商id */ |
||||
|
@NotNull(message = "供应商id不能为空") |
||||
|
private Long supplierId; |
||||
|
|
||||
|
/** 供应商名称 */ |
||||
|
@Length(max = 50,message = "供应商名称长度不能超过50字") |
||||
|
private String supplierName; |
||||
|
|
||||
|
/** 供应商编码 */ |
||||
|
@Length(max = 30,message = "供应商编码长度不能超过30字") |
||||
|
private String supplierCode; |
||||
|
|
||||
|
/** 类型:0=销售区域;1=行政区域;2-供应商负责人;9-无相关数据 */ |
||||
|
private Integer type; |
||||
|
|
||||
|
/** 区域id */ |
||||
|
@Length(max = 32,message = "区域id长度不能超过32字") |
||||
|
private String regionId; |
||||
|
|
||||
|
/** 销售区域1 */ |
||||
|
@Length(max = 32,message = "销售区域1长度不能超过32字") |
||||
|
private String saleRegionFirst; |
||||
|
|
||||
|
/** 销售区域2 */ |
||||
|
@Length(max = 32,message = "销售区域2长度不能超过32字") |
||||
|
private String saleRegionSecond; |
||||
|
|
||||
|
/** 销售区域3 */ |
||||
|
@Length(max = 32,message = "销售区域3长度不能超过32字") |
||||
|
private String saleRegionThird; |
||||
|
|
||||
|
/** 销售区域4 */ |
||||
|
@Length(max = 32,message = "销售区域4长度不能超过32字") |
||||
|
private String saleRegionFourthly; |
||||
|
|
||||
|
/** 主要负责人 */ |
||||
|
@NotNull(message = "主要负责人不能为空") |
||||
|
private Integer masterFlag; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@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; |
||||
|
|
||||
|
/** 行政区域1 */ |
||||
|
@Length(max = 32,message = "行政区域1长度不能超过32字") |
||||
|
private String bizRegionFirst; |
||||
|
|
||||
|
/** 行政区域2 */ |
||||
|
@Length(max = 32,message = "行政区域2长度不能超过32字") |
||||
|
private String bizRegionSecond; |
||||
|
|
||||
|
/** 行政区域3 */ |
||||
|
@Length(max = 32,message = "行政区域3长度不能超过32字") |
||||
|
private String bizRegionThird; |
||||
|
|
||||
|
/** 行政区域4 */ |
||||
|
@Length(max = 32,message = "行政区域4长度不能超过32字") |
||||
|
private String bizRegionFourthly; |
||||
|
|
||||
|
/** */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** */ |
||||
|
private Integer costFlag; |
||||
|
|
||||
|
|
||||
|
public static HisUserSupplierTemp toNewObject(HisUserSupplierTemp source){ |
||||
|
HisUserSupplierTemp userSupplierTemp = new HisUserSupplierTemp(); |
||||
|
userSupplierTemp.setId(source.getId()); |
||||
|
userSupplierTemp.setUserId(source.getUserId()); |
||||
|
userSupplierTemp.setSupplierId(source.getSupplierId()); |
||||
|
userSupplierTemp.setSupplierName(source.getSupplierName()); |
||||
|
userSupplierTemp.setSupplierCode(source.getSupplierCode()); |
||||
|
userSupplierTemp.setType(source.getType()); |
||||
|
userSupplierTemp.setRegionId(source.getRegionId()); |
||||
|
userSupplierTemp.setSaleRegionFirst(source.getSaleRegionFirst()); |
||||
|
userSupplierTemp.setSaleRegionSecond(source.getSaleRegionSecond()); |
||||
|
userSupplierTemp.setSaleRegionThird(source.getSaleRegionThird()); |
||||
|
userSupplierTemp.setSaleRegionFourthly(source.getSaleRegionFourthly()); |
||||
|
userSupplierTemp.setMasterFlag(source.getMasterFlag()); |
||||
|
userSupplierTemp.setCreateTime(source.getCreateTime()); |
||||
|
userSupplierTemp.setBizRegionFirst(source.getBizRegionFirst()); |
||||
|
userSupplierTemp.setBizRegionSecond(source.getBizRegionSecond()); |
||||
|
userSupplierTemp.setBizRegionThird(source.getBizRegionThird()); |
||||
|
userSupplierTemp.setBizRegionFourthly(source.getBizRegionFourthly()); |
||||
|
userSupplierTemp.setTenantId(source.getTenantId()); |
||||
|
userSupplierTemp.setCostFlag(source.getCostFlag()); |
||||
|
return userSupplierTemp; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
package com.qs.serve.modules.his.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.his.entity.HisUserSupplierTemp; |
||||
|
import org.apache.ibatis.annotations.Insert; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
/** |
||||
|
* 供应商负责人 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2023-05-31 |
||||
|
*/ |
||||
|
public interface HisUserSupplierTempMapper extends BaseMapper<HisUserSupplierTemp> { |
||||
|
|
||||
|
@InterceptorIgnore(tenantLine = "1") |
||||
|
//@Select("SELECT * INTO his_user_supplier FROM his_user_supplier_temp")
|
||||
|
@Insert("INSERT INTO his_user_supplier SELECT * FROM his_user_supplier_temp") |
||||
|
int selectIntoHis(); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,21 @@ |
|||||
|
package com.qs.serve.modules.his.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.his.entity.HisUserSupplierTemp; |
||||
|
|
||||
|
/** |
||||
|
* 供应商负责人 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2023-05-31 |
||||
|
*/ |
||||
|
public interface HisUserSupplierTempService extends IService<HisUserSupplierTemp> { |
||||
|
|
||||
|
/** |
||||
|
* 重新创建表数据 |
||||
|
*/ |
||||
|
void reloadHis(); |
||||
|
|
||||
|
void selectInfoHis(); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,143 @@ |
|||||
|
package com.qs.serve.modules.his.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.framework.redis.RedisService; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegionUser; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
||||
|
import com.qs.serve.modules.bms.service.BmsRegionUserService; |
||||
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
||||
|
import com.qs.serve.modules.his.entity.HisUserSupplier; |
||||
|
import com.qs.serve.modules.his.mapper.HisUserSupplierMapper; |
||||
|
import com.qs.serve.modules.sys.entity.SysUser; |
||||
|
import com.qs.serve.modules.sys.mapper.SysUserMapper; |
||||
|
import com.qs.serve.modules.sys.service.SysPostUserService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.his.entity.HisUserSupplierTemp; |
||||
|
import com.qs.serve.modules.his.service.HisUserSupplierTempService; |
||||
|
import com.qs.serve.modules.his.mapper.HisUserSupplierTempMapper; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 供应商负责人 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2023-05-31 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class HisUserSupplierTempServiceImpl extends ServiceImpl<HisUserSupplierTempMapper,HisUserSupplierTemp> implements HisUserSupplierTempService { |
||||
|
|
||||
|
private final SysUserMapper sysUserMapper; |
||||
|
private final SysPostUserService sysPostUserService; |
||||
|
private final BmsSupplierService bmsSupplierService; |
||||
|
private BmsRegionMapper saleRegionMapper; |
||||
|
private BmsRegion2Mapper bmsRegion2Mapper; |
||||
|
private BmsRegionUserService regionUserService; |
||||
|
private RedisService redisService; |
||||
|
private HisUserSupplierMapper hisUserSupplierMapper; |
||||
|
|
||||
|
@Override |
||||
|
public void selectInfoHis() { |
||||
|
hisUserSupplierMapper.delete(new QueryWrapper<>()); |
||||
|
baseMapper.selectIntoHis(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void reloadHis() { |
||||
|
//移除所有历史
|
||||
|
this.remove(new QueryWrapper<>()); |
||||
|
//加载所有用户
|
||||
|
List<SysUser> sysUser = sysUserMapper.selectList(new QueryWrapper<>()); |
||||
|
List<String> userIds = sysUser.stream().map(a->a.getId()).collect(Collectors.toList()); |
||||
|
//初始化
|
||||
|
for (String userId : userIds) { |
||||
|
this.initByUserId(userId,null); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void initByUserId(String userId,List<String> existUserIds){ |
||||
|
if(existUserIds==null){ |
||||
|
existUserIds = new ArrayList<>(); |
||||
|
} |
||||
|
if(existUserIds.contains(userId)){ |
||||
|
return; |
||||
|
}else { |
||||
|
existUserIds.add(userId); |
||||
|
} |
||||
|
List<String> childUserIds = sysPostUserService.listByChildIds(userId); |
||||
|
for (String childUserId : childUserIds) { |
||||
|
this.initByUserId(childUserId, existUserIds); |
||||
|
} |
||||
|
BmsSupplier param = new BmsSupplier(); |
||||
|
param.setCurrUserId(userId); |
||||
|
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param); |
||||
|
List<HisUserSupplierTemp> userSuppliers = new ArrayList<>(); |
||||
|
for (BmsSupplier supplier : list) { |
||||
|
HisUserSupplierTemp userSupplier = supplier.toHisUserSupplierTemp(userId,3); |
||||
|
userSuppliers.add(userSupplier); |
||||
|
} |
||||
|
LambdaQueryWrapper<BmsRegionUser> regionUserLqw = new LambdaQueryWrapper<>(); |
||||
|
regionUserLqw.eq(BmsRegionUser::getUserId,userId); |
||||
|
List<BmsRegionUser> regionUsers = regionUserService.list(regionUserLqw); |
||||
|
List<String> regionSaleIds = regionUsers.stream() |
||||
|
.filter(a->a.getType().equals(0)) |
||||
|
.map(BmsRegionUser::getRegionId) |
||||
|
.collect(Collectors.toList()); |
||||
|
if(regionSaleIds.size()>0){ |
||||
|
List<BmsRegion> saleRegions = saleRegionMapper.selectBatchIds(regionSaleIds); |
||||
|
Map<Integer,List<BmsRegion>> saleRegionsMap = saleRegions.stream().collect(Collectors.groupingBy(BmsRegion::getLevel)); |
||||
|
for (Integer level : saleRegionsMap.keySet()) { |
||||
|
List<BmsRegion> saleRegionListByLevel = saleRegionsMap.get(level); |
||||
|
List<String> regionIds = saleRegionListByLevel.stream().map(BmsRegion::getId).collect(Collectors.toList()); |
||||
|
toHisUserSupplier(userSuppliers,0,regionIds,level,userId); |
||||
|
} |
||||
|
} |
||||
|
List<String> regionBizIds = regionUsers.stream() |
||||
|
.filter(a->a.getType().equals(1)) |
||||
|
.map(BmsRegionUser::getRegionId) |
||||
|
.collect(Collectors.toList()); |
||||
|
if(regionBizIds.size()>0){ |
||||
|
List<BmsRegion2> bizRegions = bmsRegion2Mapper.selectBatchIds(regionBizIds); |
||||
|
Map<Integer,List<BmsRegion2>> saleRegionsMap = bizRegions.stream().collect(Collectors.groupingBy(BmsRegion2::getLevel)); |
||||
|
for (Integer level : saleRegionsMap.keySet()) { |
||||
|
List<BmsRegion2> region2List = saleRegionsMap.get(level); |
||||
|
List<String> region2Ids = region2List.stream().map(BmsRegion2::getId).collect(Collectors.toList()); |
||||
|
toHisUserSupplier(userSuppliers,1,region2Ids,level,userId); |
||||
|
} |
||||
|
} |
||||
|
if(userSuppliers.size()>0){ |
||||
|
this.saveBatch(userSuppliers); |
||||
|
}else { |
||||
|
HisUserSupplierTemp userSupplier = new HisUserSupplierTemp(); |
||||
|
userSupplier.setUserId(userId); |
||||
|
userSupplier.setSupplierId(0L); |
||||
|
userSupplier.setType(9); |
||||
|
this.save(userSupplier); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private void toHisUserSupplier(List<HisUserSupplierTemp> userSuppliers,Integer type,List<String> regionIds,Integer level,String userId){ |
||||
|
if(regionIds.size()>0){ |
||||
|
List<BmsSupplier> supplierList = bmsSupplierService.listByRegionIds(regionIds,level); |
||||
|
for (BmsSupplier supplier : supplierList) { |
||||
|
HisUserSupplierTemp userSupplier = supplier.toHisUserSupplierTemp(userId,type); |
||||
|
userSuppliers.add(userSupplier); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,58 @@ |
|||||
|
package com.qs.serve.task; |
||||
|
|
||||
|
import com.qs.serve.common.framework.redis.RedisService; |
||||
|
import com.qs.serve.common.model.consts.RedisCacheKeys; |
||||
|
import com.qs.serve.common.util.AuthContextUtils; |
||||
|
import com.qs.serve.modules.his.service.HisUserSupplierTempService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.time.Duration; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/5/31 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
@AllArgsConstructor |
||||
|
public class HisTask { |
||||
|
|
||||
|
RedisService redisService; |
||||
|
HisUserSupplierTempService tempService; |
||||
|
|
||||
|
/** |
||||
|
* 每隔半小时执行一次,串行 |
||||
|
*/ |
||||
|
@Scheduled(cron="0 0/30 * * * ?") |
||||
|
public void buildTempTable(){ |
||||
|
AuthContextUtils.setTenant("001"); |
||||
|
Integer opt = redisService.getInteger(RedisCacheKeys.HIS_UPDATE); |
||||
|
//设置默认值
|
||||
|
if (opt==null){ |
||||
|
redisService.set(RedisCacheKeys.HIS_UPDATE,0); |
||||
|
return; |
||||
|
} |
||||
|
//忽略状态
|
||||
|
if (opt==1){ |
||||
|
//执行同步
|
||||
|
log.warn("======================执行同步======================"); |
||||
|
LocalDateTime s1 = LocalDateTime.now(); |
||||
|
//防卡死,加入超时
|
||||
|
redisService.set(RedisCacheKeys.HIS_UPDATE,2,1, TimeUnit.HOURS); |
||||
|
tempService.reloadHis(); |
||||
|
LocalDateTime s2 = LocalDateTime.now(); |
||||
|
long diff = Duration.between(s1, s2).getSeconds(); |
||||
|
tempService.selectInfoHis(); |
||||
|
redisService.set(RedisCacheKeys.HIS_UPDATE,0); |
||||
|
log.warn("======================执行同步完成,耗时[ {} 秒]======================",diff); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue