diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java index cb7c47a..70a6a1f 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java @@ -124,6 +124,7 @@ public class YearReviewController { try{ log.info("into getWorkflowTop success params ==> "+param); User loginUser = HrmUserVarify.getUser(request, response); + loginUser.setLoginid("9"); param.put("workflowIds",workflowIds); if(!param.containsKey("limit")){ param.put("limit",3); diff --git a/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java b/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java index c616cbb..6f4f5e5 100644 --- a/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java +++ b/src/main/java/weaver/bokang/xiao/dz_invoice/schedule/InvoiceQuerySchedule.java @@ -8,7 +8,6 @@ import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import com.alibaba.fastjson.JSON; import com.api.bokang.xiao.dz_invoice.mapper.DzInvoiceMapper; -import lombok.Data; import org.apache.log4j.Logger; import weaver.interfaces.schedule.BaseCronJob; import weaver.xiao.commons.config.entity.RequestMappingConfig; @@ -27,7 +26,6 @@ import java.util.Objects; **/ @ActionDesc(value = "定时查询发票勾选状态", author = "bokang.xiao") -@Data public class InvoiceQuerySchedule extends BaseCronJob { @RequiredMark("发票查询接口唯一标识") diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/CompanyEntity.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/CompanyEntity.java new file mode 100644 index 0000000..ba8c0ba --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/CompanyEntity.java @@ -0,0 +1,38 @@ +package weaver.bokang.xiao.xhny_report.entity; + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import lombok.Data; + +/** + * @ClassName CompanyEntity + * @Author 肖博亢 + * @Date 2023/3/17 18:10 + * @Description

+ **/ + +@Data +public class CompanyEntity { + + private Integer id; + + /** 起订要求 */ + @SqlDbFieldAnn("fs") + private String orderRequire; + + /** 退换货条件 */ + @SqlDbFieldAnn("thtk") + private Integer returnAndExchange; + + /** 配送周期 */ + @SqlDbFieldAnn("csshsx") + private Integer deliveryCycle; + + /** 账期 */ + @SqlDbFieldAnn("zqxlk") + private Integer accountPeriod; + + /** 装卸(分拣)服务 */ + @SqlDbFieldAnn("sftgfjfw") + private Integer sortingService; + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/ConfigEntity.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/ConfigEntity.java new file mode 100644 index 0000000..5338e82 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/ConfigEntity.java @@ -0,0 +1,39 @@ +package weaver.bokang.xiao.xhny_report.entity; + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import lombok.Data; + +/** + * @ClassName ConfigEntity + * @Author 肖博亢 + * @Date 2023/3/16 10:50 + * @Description

评分明细配置

+ **/ + +@Data +public class ConfigEntity { + + /** 数据id */ + private Integer id; + + /** 分数 */ + @SqlDbFieldAnn("fs") + private Double score; + + /** 子项目 */ + @SqlDbFieldAnn("zxm") + private Integer childItem; + + /** 明细 */ + @SqlDbFieldAnn("mx") + private String detail; + + /** 权重 */ + @SqlDbFieldAnn("qz") + private String weight; + + /** 明细项 */ + @SqlDbFieldAnn("fs") + private Integer detailItem; + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/SourceTrackingData.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/SourceTrackingData.java new file mode 100644 index 0000000..b9a3d23 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/SourceTrackingData.java @@ -0,0 +1,18 @@ +package weaver.bokang.xiao.xhny_report.entity; + +import lombok.Data; + +import java.util.List; + +/** + * @ClassName SourceTrackingData + * @Author 肖博亢 + * @Date 2023/3/17 15:19 + * @Description

询价数据

+ **/ + +@Data +public class SourceTrackingData { + + private List vendorList; +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReport.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReport.java new file mode 100644 index 0000000..c4eb8e6 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReport.java @@ -0,0 +1,44 @@ +package weaver.bokang.xiao.xhny_report.entity; + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import lombok.Data; + +import java.util.List; + +/** + * @ClassName VendorMarkReport + * @Author 肖博亢 + * @Date 2023/3/16 13:47 + * @Description

+ **/ + +@Data +public class VendorMarkReport { + + /** 数据id */ + private Integer id; + + /** 评估开始时间 */ + @SqlDbFieldAnn("pgksrq") + private String evaluationStartDate; + + /** 评估结束时间 */ + @SqlDbFieldAnn("pgjsrq") + private String evaluationEndDate; + + /** 供应商 */ + @SqlDbFieldAnn("gys") + private Integer supplier; + + /** 品类 */ + @SqlDbFieldAnn("pl") + private String category; + + /** 本期总分 */ + @SqlDbFieldAnn("bqzf") + private double totalScore; + + /** 分数明细信息 */ + private List vendorMarkReportDtList; + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReportDt.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReportDt.java new file mode 100644 index 0000000..760cf09 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReportDt.java @@ -0,0 +1,44 @@ +package weaver.bokang.xiao.xhny_report.entity; + +import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import lombok.Builder; +import lombok.Data; + +/** + * @ClassName VendorMarkReportDt + * @Author 肖博亢 + * @Date 2023/3/16 13:56 + * @Description

+ **/ + +@Data +@Builder +public class VendorMarkReportDt { + + /** 数据id */ + private Integer id; + + /** 主数据id */ + private Integer mainId; + + /** 项目 */ + @SqlDbFieldAnn("xm") + private Integer project; + + /** 描述 */ + @SqlDbFieldAnn("ms") + private String desc; + + /** 权重 */ + @SqlDbFieldAnn("qz") + private String weight; + + + /** 预估得分 */ + @SqlDbFieldAnn("ygdf") + private String anticipateScore; + + /** 实际得分 */ + @SqlDbFieldAnn("sjdf") + private Double score; +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorMapper.java b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorMapper.java new file mode 100644 index 0000000..b8e57c4 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorMapper.java @@ -0,0 +1,33 @@ +package weaver.bokang.xiao.xhny_report.mapper; + +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import weaver.bokang.xiao.xhny_report.entity.CompanyEntity; +import weaver.bokang.xiao.xhny_report.entity.ConfigEntity; + +import java.util.List; + +/** + * @ClassName VendorMapper + * @Author 肖博亢 + * @Date 2023/3/16 14:13 + * @Description

+ **/ + +@SqlMapper +public interface VendorMapper { + + /** + *

查询配置信息

+ * @return 配置列表 + */ + @Select("select * from uf_vendorMark") + List queryVendorConfig(); + + /** + * 查询供应商信息 + * @return 供应商列表信息 + */ + @Select("select * from uf_company_info") + List queryCompanyList(); +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java new file mode 100644 index 0000000..415f3c0 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java @@ -0,0 +1,56 @@ +package weaver.bokang.xiao.xhny_report.schedule; + +import aiyh.utils.Util; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import lombok.Data; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; +import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern; +import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain; +import weaver.bokang.xiao.xhny_report.service.store.VendorStore; +import weaver.interfaces.schedule.BaseCronJob; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName GenerateReportSchedule + * @Author 肖博亢 + * @Date 2023/3/17 19:58 + * @Description

生成报表定时任务

+ **/ +@Data +@ActionDesc(value = "生成报表信息", author = "bokang.xiao") +public class GenerateReportSchedule extends BaseCronJob { + + private final Logger log = Util.getLogger(); + + @RequiredMark("报表模块id") + @PrintParamMark + private String reportModelId; + + @Override + public void execute() { + try { + //必填参数校验 + Util.verifyRequiredField(this); + //公共参数初始化 + VendorStore instance = VendorStore.getInstance(); + instance.init(); + //获取评分处理链 + AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain(); + //处理数据初始化 + List vendorMarkReportList = new ArrayList<>(); + SourceTrackingData sourceTrackingData = new SourceTrackingData(); + //进行供应商评分 + scoreChain.handle(vendorMarkReportList, sourceTrackingData); + //批量插入供应商报表数据 + //todo 批量插入供应商报表数据 + }catch (Exception e){ + log.error("定时任务执行异常 ==>"+Util.getErrString(e)); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java new file mode 100644 index 0000000..0bcfd51 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java @@ -0,0 +1,74 @@ +package weaver.bokang.xiao.xhny_report.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSON; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.xhny_report.entity.ConfigEntity; +import weaver.bokang.xiao.xhny_report.mapper.VendorMapper; +import weaver.bokang.xiao.xhny_report.service.chain.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @ClassName ScoreChainPattern + * @Author 肖博亢 + * @Date 2023/3/17 16:13 + * @Description

评分链路初始化

+ **/ +public class ScoreChainPattern { + + private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class); + + private static final Logger logger = Util.getLogger(); + + private static final Map SCORE_CHAIN_MAP = new HashMap<>(); + + static { + SCORE_CHAIN_MAP.put(0,new OrderRequirementChain()); + SCORE_CHAIN_MAP.put(1,new ReturnAndExchangeChain()); + SCORE_CHAIN_MAP.put(2,new DeliveryCycleChain()); + SCORE_CHAIN_MAP.put(3,new AccountPeriodChain()); + SCORE_CHAIN_MAP.put(4,new QuotationNumberChain()); + SCORE_CHAIN_MAP.put(5,new MoneyAmountChain()); + SCORE_CHAIN_MAP.put(6,new TopThirtyChain()); + SCORE_CHAIN_MAP.put(7,new QuotationCompleteChain()); + SCORE_CHAIN_MAP.put(8,new QuotationTimeChain()); + SCORE_CHAIN_MAP.put(9,new ArrivalRateChain()); + SCORE_CHAIN_MAP.put(10,new BadCountChain()); + SCORE_CHAIN_MAP.put(11,new SortingServiceChain()); + } + + public static AbstractScoreChain getScoreChain(){ + List configEntities = VENDOR_MAPPER.queryVendorConfig(); + if(configEntities.isEmpty()){ + throw new CustomerException("评分配置信息不能为空"); + } + logger.info(String.format("评分配置信息: < %s >", JSON.toJSONString(configEntities))); + Map> configMap = configEntities.stream().collect(Collectors.groupingBy(ConfigEntity::getChildItem)); + AbstractScoreChain abstractScoreChain = null; + for (Map.Entry> entry : configMap.entrySet()) { + AbstractScoreChain tempChain = SCORE_CHAIN_MAP.get(entry.getKey()); + if(Objects.isNull(tempChain)){ + logger.error(String.format("无法找到与之 %d 对应的链路处理对象",entry.getKey())); + continue; + } + if(Objects.isNull(abstractScoreChain)){ + abstractScoreChain = SCORE_CHAIN_MAP.get(entry.getKey()); + abstractScoreChain.setScoreConfigList(entry.getValue()); + }else { + AbstractScoreChain nexChain = SCORE_CHAIN_MAP.get(entry.getKey()); + nexChain.setScoreConfigList(entry.getValue()); + abstractScoreChain.nextScoreChain(nexChain); + } + } + if(Objects.isNull(abstractScoreChain)){ + throw new CustomerException("链路调用对象初始化为空,请检查"); + } + return abstractScoreChain; + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java new file mode 100644 index 0000000..0114371 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java @@ -0,0 +1,61 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import aiyh.utils.Util; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.xhny_report.entity.ConfigEntity; +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; +import weaver.bokang.xiao.xhny_report.service.store.VendorStore; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @ClassName AbstractScoreChain + * @Author 肖博亢 + * @Date 2023/3/17 14:59 + * @Description

评分处理抽象类

+ **/ +public abstract class AbstractScoreChain { + + /** 日志对象 */ + protected Logger logger = Util.getLogger(); + + /** 评分配置列表 */ + protected List scoreConfigList; + + /** 评分配置信息集合 */ + protected Map configEntityMap; + + /** 公共数据信息 */ + protected VendorStore vendorStore = VendorStore.getInstance(); + + /** 责任链中的下一个元素 */ + protected AbstractScoreChain nextAbstractScoreChain; + + /** + *

传入下一责任链元素

+ * @param abstractScoreChain 责任链元素 + */ + public void nextScoreChain(AbstractScoreChain abstractScoreChain){ + this.nextAbstractScoreChain = abstractScoreChain; + } + + /** + *

设置评分配置列表

+ * @param scoreConfigList 评分配置列表 + */ + public void setScoreConfigList(List scoreConfigList){ + this.scoreConfigList = scoreConfigList; + this.configEntityMap = scoreConfigList.stream().collect(Collectors.toMap(ConfigEntity::getDetailItem, item -> item)); + } + + /** + *

具体评分逻辑

+ * @param vendorMarkReportList 报表数据 + * @param sourceTrackingData 询价数据 + */ + abstract public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData); + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AccountPeriodChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AccountPeriodChain.java new file mode 100644 index 0000000..7a4c259 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AccountPeriodChain.java @@ -0,0 +1,54 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.*; + +import java.util.*; + +/** + * @ClassName AccountPeriodChain + * @Author 肖博亢 + * @Date 2023/3/17 15:33 + * @Description

账期评分

+ **/ +public class AccountPeriodChain extends AbstractScoreChain{ + + /** 评分对应关系 */ + private final Map mappingConfig = new HashMap<>(); + + { + mappingConfig.put(0,14); + mappingConfig.put(1,15); + mappingConfig.put(2,16); + mappingConfig.put(3,17); + } + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //具体评分逻辑 + logger.info(" AccountPeriodChain deal 账期评分处理 "); + Map companyMap = vendorStore.getCompanyMap(); + for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { + Integer supplier = vendorMarkReport.getSupplier(); + CompanyEntity companyEntity = companyMap.get(supplier); + ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getAccountPeriod())); + double score = 0.00; + if(Objects.nonNull(configEntity)){ + score = configEntity.getScore(); + } + List vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); + vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; + vendorMarkReportDtList.add( + VendorMarkReportDt.builder() + .score(score) + .project(configEntity.getChildItem()) + .weight(configEntity.getWeight()) + .desc("账期评分").build()); + double totalScore = vendorMarkReport.getTotalScore(); + vendorMarkReport.setTotalScore(totalScore + score); + } + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java new file mode 100644 index 0000000..364dff3 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName ArrivalRateChain + * @Author 肖博亢 + * @Date 2023/3/17 15:43 + * @Description

到货率评分

+ **/ +public class ArrivalRateChain extends AbstractScoreChain{ + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java new file mode 100644 index 0000000..fb96dfc --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java @@ -0,0 +1,25 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName BadCountChain + * @Author 肖博亢 + * @Date 2023/3/17 15:45 + * @Description

不良品数评分

+ **/ +public class BadCountChain extends AbstractScoreChain{ + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/DeliveryCycleChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/DeliveryCycleChain.java new file mode 100644 index 0000000..f46cad8 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/DeliveryCycleChain.java @@ -0,0 +1,59 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.*; + +import java.util.*; + +/** + * @ClassName DeliveryCycleChain + * @Author 肖博亢 + * @Date 2023/3/17 15:32 + * @Description

配送周期评分

+ **/ +public class DeliveryCycleChain extends AbstractScoreChain{ + + /** 评分对应关系 */ + private final Map mappingConfig = new HashMap<>(); + + { + mappingConfig.put(0,5); + mappingConfig.put(1,6); + mappingConfig.put(2,7); + mappingConfig.put(3,8); + mappingConfig.put(4,9); + mappingConfig.put(5,10); + mappingConfig.put(6,11); + mappingConfig.put(7,12); + mappingConfig.put(8,13); + } + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //具体评分逻辑 + logger.info(" DeliveryCycleChain deal 配送周期评分处理 "); + Map companyMap = vendorStore.getCompanyMap(); + for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { + Integer supplier = vendorMarkReport.getSupplier(); + CompanyEntity companyEntity = companyMap.get(supplier); + ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getDeliveryCycle())); + double score = 0.00; + if(Objects.nonNull(configEntity)){ + score = configEntity.getScore(); + } + List vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); + vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; + vendorMarkReportDtList.add( + VendorMarkReportDt.builder() + .score(score) + .project(configEntity.getChildItem()) + .weight(configEntity.getWeight()) + .desc("配送周期评分").build()); + double totalScore = vendorMarkReport.getTotalScore(); + vendorMarkReport.setTotalScore(totalScore + score); + } + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java new file mode 100644 index 0000000..2bec078 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java @@ -0,0 +1,25 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName MoneyAmountChain + * @Author 肖博亢 + * @Date 2023/3/17 15:38 + * @Description

金额数评分

+ **/ +public class MoneyAmountChain extends AbstractScoreChain{ + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/OrderRequirementChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/OrderRequirementChain.java new file mode 100644 index 0000000..92ad802 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/OrderRequirementChain.java @@ -0,0 +1,55 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import org.apache.commons.lang3.StringUtils; +import weaver.bokang.xiao.xhny_report.entity.*; + + +import java.util.*; + +/** + * @ClassName OrderRequirementChain + * @Author 肖博亢 + * @Date 2023/3/17 15:27 + * @Description

起订要求评分

+ **/ +public class OrderRequirementChain extends AbstractScoreChain{ + + /** 评分对应关系 */ + private final Map mappingConfig = new HashMap<>(); + + { + mappingConfig.put(0,0); + mappingConfig.put(1,0); + } + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + logger.info(" OrderRequirementChain deal 起订要求评分处理 "); + Map companyMap = vendorStore.getCompanyMap(); + for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { + Integer supplier = vendorMarkReport.getSupplier(); + CompanyEntity companyEntity = companyMap.get(supplier); + int configEntityId = StringUtils.isNotBlank(companyEntity.getOrderRequire()) ? 0 : 1; + ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(configEntityId)); + double score = 0.00; + if(Objects.nonNull(configEntity)){ + score = configEntity.getScore(); + } + List vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); + vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; + vendorMarkReportDtList.add( + VendorMarkReportDt.builder() + .score(score) + .project(configEntity.getChildItem()) + .weight(configEntity.getWeight()) + .desc("起订要求评分").build()); + double totalScore = vendorMarkReport.getTotalScore(); + vendorMarkReport.setTotalScore(totalScore + score); + } + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationCompleteChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationCompleteChain.java new file mode 100644 index 0000000..31cfa6e --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationCompleteChain.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName QuotationCompleteChain + * @Author 肖博亢 + * @Date 2023/3/17 15:41 + * @Description

报价完整信评分

+ **/ +public class QuotationCompleteChain extends AbstractScoreChain { + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java new file mode 100644 index 0000000..a05486f --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName QuotationNumberChain + * @Author 肖博亢 + * @Date 2023/3/17 15:35 + * @Description

报价数评分

+ **/ +public class QuotationNumberChain extends AbstractScoreChain{ + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationTimeChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationTimeChain.java new file mode 100644 index 0000000..7ad4470 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationTimeChain.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName QuotationTimeChain + * @Author 肖博亢 + * @Date 2023/3/17 15:42 + * @Description

报价及时率评分

+ **/ +public class QuotationTimeChain extends AbstractScoreChain{ + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ReturnAndExchangeChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ReturnAndExchangeChain.java new file mode 100644 index 0000000..340f453 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ReturnAndExchangeChain.java @@ -0,0 +1,53 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.*; + +import java.util.*; + +/** + * @ClassName ReturnAndExchangeChain + * @Author 肖博亢 + * @Date 2023/3/17 15:31 + * @Description

退换货评分

+ **/ +public class ReturnAndExchangeChain extends AbstractScoreChain{ + + /** 评分对应关系 */ + private final Map mappingConfig = new HashMap<>(); + + { + mappingConfig.put(0,2); + mappingConfig.put(1,3); + mappingConfig.put(2,4); + } + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //具体评分逻辑 + logger.info(" ReturnAndExchangeChain deal 退换货评分处理 "); + Map companyMap = vendorStore.getCompanyMap(); + for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { + Integer supplier = vendorMarkReport.getSupplier(); + CompanyEntity companyEntity = companyMap.get(supplier); + ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getReturnAndExchange())); + double score = 0.00; + if(Objects.nonNull(configEntity)){ + score = configEntity.getScore(); + } + List vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); + vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; + vendorMarkReportDtList.add( + VendorMarkReportDt.builder() + .score(score) + .project(configEntity.getChildItem()) + .weight(configEntity.getWeight()) + .desc("退换货评分").build()); + double totalScore = vendorMarkReport.getTotalScore(); + vendorMarkReport.setTotalScore(totalScore + score); + } + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/SortingServiceChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/SortingServiceChain.java new file mode 100644 index 0000000..cc754d8 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/SortingServiceChain.java @@ -0,0 +1,52 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.*; + +import java.util.*; + +/** + * @ClassName SortingServiceChain + * @Author 肖博亢 + * @Date 2023/3/17 15:46 + * @Description

分拣服务评分

+ **/ +public class SortingServiceChain extends AbstractScoreChain{ + + /** 评分对应关系 */ + private final Map mappingConfig = new HashMap<>(); + + { + mappingConfig.put(0,38); + mappingConfig.put(1,39); + } + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //具体评分逻辑 + logger.info(" SortingServiceChain deal 分拣服务评分处理 "); + Map companyMap = vendorStore.getCompanyMap(); + for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { + Integer supplier = vendorMarkReport.getSupplier(); + CompanyEntity companyEntity = companyMap.get(supplier); + ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getSortingService())); + double score = 0.00; + if(Objects.nonNull(configEntity)){ + score = configEntity.getScore(); + } + List vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); + vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; + vendorMarkReportDtList.add( + VendorMarkReportDt.builder() + .score(score) + .project(configEntity.getChildItem()) + .weight(configEntity.getWeight()) + .desc("分拣服务评分").build()); + double totalScore = vendorMarkReport.getTotalScore(); + vendorMarkReport.setTotalScore(totalScore + score); + } + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java new file mode 100644 index 0000000..44b57f0 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.xhny_report.service.chain; + +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport; + +import java.util.List; +import java.util.Objects; + +/** + * @ClassName TopThirtyChain + * @Author 肖博亢 + * @Date 2023/3/17 15:39 + * @Description

top30评分

+ **/ +public class TopThirtyChain extends AbstractScoreChain{ + + @Override + public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { + //TODO 具体评分逻辑 + + //让下一个链对象评分 + if(Objects.nonNull(this.nextAbstractScoreChain)) { + this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java new file mode 100644 index 0000000..e3e8a9c --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java @@ -0,0 +1,59 @@ +package weaver.bokang.xiao.xhny_report.service.store; + +import aiyh.utils.Util; +import lombok.Getter; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.xhny_report.entity.CompanyEntity; +import weaver.bokang.xiao.xhny_report.mapper.VendorMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @ClassName VendorStore + * @Author 肖博亢 + * @Date 2023/3/17 18:31 + * @Description

+ **/ + +@Getter +public class VendorStore { + + /** 公司信息 */ + private List companyEntityList; + + private Map companyMap = new HashMap<>(); + + private static final Logger logger = Util.getLogger(); + + private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class); + + private VendorStore(){ + //this.init(); + } + + public void init(){ + try{ + this.companyEntityList = VENDOR_MAPPER.queryCompanyList(); + if(Objects.nonNull(companyEntityList) && !companyEntityList.isEmpty()){ + companyMap = companyEntityList.stream().collect(Collectors.toMap(CompanyEntity::getId, item -> item)); + } + }catch (Exception exception){ + logger.error("VendorStore 初始化异常 ==>"+Util.getErrString(exception)); + } + } + + public static VendorStore getInstance(){ + return VendorStoreHolder.VENDOR_STORE; + } + + private static class VendorStoreHolder{ + private VendorStoreHolder(){ + + } + private static final VendorStore VENDOR_STORE = new VendorStore(); + } +} diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 5224d02..f895e02 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -1,7 +1,6 @@ package bokang.xiao; import aiyh.utils.GenerateFileUtil; -import aiyh.utils.ThreadPoolConfig; import aiyh.utils.Util; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; @@ -9,46 +8,33 @@ import basetest.BaseTest; import bokang.xiao.entity.CourseEntity; import bokang.xiao.entity.StudentEntity; import bokang.xiao.entity.TeacherEntity; -import bokang.xiao.mapper.TestMapper; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; -import com.api.bokang.xiao.porsche_review.service.ReviewService; import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl; -import com.api.bokang.xiao.wx_report.entity.ReportEntityVO; import com.api.bokang.xiao.wx_report.mapper.ReportMapper; import com.api.bokang.xiao.wx_report.service.ReportService; import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl; -import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.apache.poi.POIXMLDocument; -import org.apache.poi.hwpf.HWPFDocument; -import org.apache.poi.hwpf.usermodel.Range; import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFParagraph; -import org.apache.poi.xwpf.usermodel.XWPFRun; import org.junit.Test; -import weaver.bokang.xiao.dz_invoice.action.InvoiceDeductionAction; -import weaver.bokang.xiao.dz_invoice.schedule.InvoiceQuerySchedule; +import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; +import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain; +import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern; import weaver.general.StaticObj; import weaver.hrm.User; import weaver.interfaces.datasource.DataSource; import weaver.workflow.workflow.WorkflowVersion; -import weaver.xiao.commons.config.entity.ResponseMapping; import weaver.xiao.commons.utils.DocImageFileUtil; import java.io.*; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.nio.charset.StandardCharsets; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.stream.Collectors; /** * @ClassName NormalTest @@ -125,7 +111,10 @@ public class NormalTest extends BaseTest { @Test public void testgg() throws IOException { - System.out.println(null instanceof Collections); + //System.out.println(null instanceof Collections); + AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain(); + scoreChain.handle(new ArrayList<>(),new SourceTrackingData()); + System.out.println(scoreChain); } @Test