diff --git a/src/main/java/com/api/bokang/xiao/xhny_report/ReportController.java b/src/main/java/com/api/bokang/xiao/xhny_report/ReportController.java
new file mode 100644
index 0000000..8d49250
--- /dev/null
+++ b/src/main/java/com/api/bokang/xiao/xhny_report/ReportController.java
@@ -0,0 +1,64 @@
+package com.api.bokang.xiao.xhny_report;
+
+import aiyh.utils.Util;
+import org.apache.log4j.Logger;
+import weaver.general.StaticObj;
+import weaver.interfaces.datasource.DataSource;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.ResultSet;
+
+
+/**
+ * @ClassName ReportController
+ * @Author 肖博亢
+ * @Date 2023/3/20 15:49
+ * @Description
+ **/
+@Path("/xbk/xhny_report")
+public class ReportController {
+
+ private final Logger log = Util.getLogger();
+
+ /**
+ * 获取搜索组件信息
+ * @param request 请求体
+ * @param response 响应体
+ * @return 请求结果
+ */
+ @Path("/testDataSource")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String testDataSource(@Context HttpServletRequest request, @Context HttpServletResponse response){
+ DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class);
+ Connection conn = null ;
+ // CallableStatement对象
+ CallableStatement callableStatement = null;
+ // 结果集对象
+ ResultSet resultSet = null;
+ try{
+ conn = ds.getConnection();
+ callableStatement = conn.prepareCall("{CALL kd_po_nastnumAndnassistnum(?,?,?)}");
+
+ callableStatement.setString(1,"GC736");
+ callableStatement.setString(2,"2023-01-01");
+ callableStatement.setString(3,"2023-04-01");
+
+ resultSet = callableStatement.executeQuery();
+ if(resultSet.next()){
+ log.info("数据源请求结果 ==>"+resultSet.getString("nrate"));
+ }
+ } catch (Exception e) {
+ log.error("远程调用存储过程失败 ==>"+Util.getErrString(e));
+ }
+ return "查看日志信息";
+ }
+}
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
index b9a3d23..5d10bf2 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/SourceTrackingData.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/SourceTrackingData.java
@@ -1,6 +1,10 @@
package weaver.bokang.xiao.xhny_report.entity;
+import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Data;
+import weaver.bokang.xiao.xhny_report.entity.pojo.MaterialEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorEntity;
import java.util.List;
@@ -14,5 +18,28 @@ import java.util.List;
@Data
public class SourceTrackingData {
- private List vendorList;
+ private Integer id;
+
+ /** 寻源单号 */
+ @SqlDbFieldAnn("xydh")
+ private String sourceTrackingCode;
+
+ /** 报价开始时间 */
+ @SqlDbFieldAnn("bjkssj")
+ private String quotaBeginDate;
+
+ /** 报价截止时间 */
+ @SqlDbFieldAnn("bjjzsj")
+ private String quotaEndDate;
+
+ /** 供应商列表 */
+ private List sourceVendorList;
+
+ /** 物料列表 */
+ private List sourceMaterialList;
+
+ /** 最终报价数据 */
+ private List quotaDataList;
+
+
}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/CompanyEntity.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/CompanyEntity.java
similarity index 93%
rename from src/main/java/weaver/bokang/xiao/xhny_report/entity/CompanyEntity.java
rename to src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/CompanyEntity.java
index ba8c0ba..8ed0996 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/CompanyEntity.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/CompanyEntity.java
@@ -1,4 +1,4 @@
-package weaver.bokang.xiao.xhny_report.entity;
+package weaver.bokang.xiao.xhny_report.entity.pojo;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Data;
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/ConfigEntity.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/ConfigEntity.java
similarity index 81%
rename from src/main/java/weaver/bokang/xiao/xhny_report/entity/ConfigEntity.java
rename to src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/ConfigEntity.java
index 5338e82..634784a 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/ConfigEntity.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/ConfigEntity.java
@@ -1,4 +1,4 @@
-package weaver.bokang.xiao.xhny_report.entity;
+package weaver.bokang.xiao.xhny_report.entity.pojo;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Data;
@@ -17,7 +17,7 @@ public class ConfigEntity {
private Integer id;
/** 分数 */
- @SqlDbFieldAnn("fs")
+ @SqlDbFieldAnn("fsz")
private Double score;
/** 子项目 */
@@ -30,10 +30,10 @@ public class ConfigEntity {
/** 权重 */
@SqlDbFieldAnn("qz")
- private String weight;
+ private Double weight;
/** 明细项 */
- @SqlDbFieldAnn("fs")
+ @SqlDbFieldAnn("mxx")
private Integer detailItem;
}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/MaterialEntity.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/MaterialEntity.java
new file mode 100644
index 0000000..a4f838a
--- /dev/null
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/MaterialEntity.java
@@ -0,0 +1,27 @@
+package weaver.bokang.xiao.xhny_report.entity.pojo;
+
+import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
+import lombok.Data;
+
+/**
+ * @ClassName MaterialEntity
+ * @Author 肖博亢
+ * @Date 2023/3/20 11:48
+ * @Description
+ **/
+@Data
+public class MaterialEntity {
+
+ /** 物料id */
+ @SqlDbFieldAnn("wlid")
+ private Integer materialId;
+
+ /** 物料编码 */
+ @SqlDbFieldAnn("wlbm")
+ private String materialCode;
+
+ /** 物料名称(产品名称) */
+ @SqlDbFieldAnn("wlmc")
+ private String materialName;
+
+}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java
new file mode 100644
index 0000000..1cab43c
--- /dev/null
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java
@@ -0,0 +1,53 @@
+package weaver.bokang.xiao.xhny_report.entity.pojo;
+
+import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.Objects;
+
+/**
+ * @ClassName QuotaData
+ * @Author 肖博亢
+ * @Date 2023/3/20 12:00
+ * @Description 最终报价数据
+ **/
+@Getter
+@Setter
+@NoArgsConstructor
+public class QuotaData {
+
+ /** 供应商编码 */
+ @SqlDbFieldAnn("gysgsid")
+ private Integer vendorId;
+
+ /** 物料编码 */
+ @SqlDbFieldAnn("wlbm")
+ private Integer materialId;
+
+ /** 含税报价 */
+ @SqlDbFieldAnn("djbhs")
+ private Double quotaValue;
+
+ /** 寻源单号 */
+ @SqlDbFieldAnn("xjdh")
+ private String sourceTrackingCode;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ QuotaData quotaData = (QuotaData) o;
+ return materialId.equals(quotaData.materialId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(vendorId, materialId);
+ }
+}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorEntity.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorEntity.java
new file mode 100644
index 0000000..4c1ff79
--- /dev/null
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorEntity.java
@@ -0,0 +1,26 @@
+package weaver.bokang.xiao.xhny_report.entity.pojo;
+
+import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
+import lombok.Data;
+
+/**
+ * @ClassName VendorEntity
+ * @Author 肖博亢
+ * @Date 2023/3/20 11:47
+ * @Description
+ **/
+@Data
+public class VendorEntity {
+
+ /** 供应商id */
+ @SqlDbFieldAnn("gysid")
+ private Integer vendorId;
+
+ /** 供应商id */
+ @SqlDbFieldAnn("gsbm")
+ private String vendorCode;
+
+ /** 供应商名称 */
+ @SqlDbFieldAnn("gysmc")
+ private String vendorName;
+}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReport.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReport.java
similarity index 70%
rename from src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReport.java
rename to src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReport.java
index c4eb8e6..2eb686d 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReport.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReport.java
@@ -1,7 +1,10 @@
-package weaver.bokang.xiao.xhny_report.entity;
+package weaver.bokang.xiao.xhny_report.entity.pojo;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
import lombok.Data;
+import lombok.NoArgsConstructor;
import java.util.List;
@@ -13,6 +16,9 @@ import java.util.List;
**/
@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
public class VendorMarkReport {
/** 数据id */
@@ -30,6 +36,9 @@ public class VendorMarkReport {
@SqlDbFieldAnn("gys")
private Integer supplier;
+ /** 供应商编码 */
+ private String supplierCode;
+
/** 品类 */
@SqlDbFieldAnn("pl")
private String category;
@@ -38,6 +47,10 @@ public class VendorMarkReport {
@SqlDbFieldAnn("bqzf")
private double totalScore;
+ /** 寻源单号 */
+ @SqlDbFieldAnn("xydh")
+ private String sourceTrackingCode;
+
/** 分数明细信息 */
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/pojo/VendorMarkReportDt.java
similarity index 79%
rename from src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReportDt.java
rename to src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReportDt.java
index 760cf09..4cd72da 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/VendorMarkReportDt.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReportDt.java
@@ -1,8 +1,10 @@
-package weaver.bokang.xiao.xhny_report.entity;
+package weaver.bokang.xiao.xhny_report.entity.pojo;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
+import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* @ClassName VendorMarkReportDt
@@ -13,6 +15,8 @@ import lombok.Data;
@Data
@Builder
+@NoArgsConstructor
+@AllArgsConstructor
public class VendorMarkReportDt {
/** 数据id */
@@ -31,8 +35,7 @@ public class VendorMarkReportDt {
/** 权重 */
@SqlDbFieldAnn("qz")
- private String weight;
-
+ private Double weight;
/** 预估得分 */
@SqlDbFieldAnn("ygdf")
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/mapper/SourceTrackingMapper.java b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/SourceTrackingMapper.java
new file mode 100644
index 0000000..e90f3ef
--- /dev/null
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/SourceTrackingMapper.java
@@ -0,0 +1,78 @@
+package weaver.bokang.xiao.xhny_report.mapper;
+
+import aiyh.utils.annotation.recordset.*;
+import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.MaterialEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName SourceTrackingMapper
+ * @Author 肖博亢
+ * @Date 2023/3/20 13:31
+ * @Description
+ **/
+@SqlMapper
+public interface SourceTrackingMapper {
+
+ /**
+ * 查询询价数据列表
+ * @param param 条件参数
+ * @return 询价信息列表
+ */
+ @Select("select id,xydh,bjkssj,bjjzsj from uf_src_rfq where bjjzsj < #{endDate} and (sfypf = 1 or sfypf is null)")
+ @CollectionMappings({
+ @CollectionMapping(property = "sourceVendorList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
+ @CollectionMapping(property = "sourceMaterialList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
+ @CollectionMapping(property = "quotaDataList", column = "xydh", id = @Id(value = String.class, methodId = 3)),
+ })
+ List querySourceTrackingList(@ParamMapper("param")Map param);
+
+ /**
+ * 查询询价单供应商数据
+ * @param mainId 主数据id
+ * @return 供应商列表
+ */
+ @Select("select dt.gysbm gysid,dt.gysmc,company.gsbm " +
+ " from uf_src_rfq_dt2 dt " +
+ " inner join uf_company_info company on dt.gysbm = company.id " +
+ " where dt.mainid = #{mainId}")
+ @CollectionMethod(1)
+ List queryVendorList(@ParamMapper("mainId")int mainId);
+
+ /**
+ * 查询询价单物料数据
+ * @param mainId 主数据id
+ * @return 物料列表
+ */
+ @Select("select dt.wlbm wlid,dt.wlmc,mdm.wlbm " +
+ " from uf_src_rfq_dt1 dt " +
+ " inner join uf_mdm_item mdm on dt.wlbm = mdm.id " +
+ " where dt.mainid = #{mainId}")
+ @CollectionMethod(2)
+ List queryMaterialList(@ParamMapper("mainId")int mainId);
+
+ /**
+ * 查询最终报价数据数据
+ * @param sourceTackingCode 寻源单号
+ * @return 最终报价列表
+ */
+ @Select("select main.gys,dt.wlbm,dt.djbhs,main.gysgsid,main.xjdh " +
+ " from uf_src_rfq_supplier main " +
+ " inner join uf_src_rfq_supplier_dt1 dt on main.id = dt.mainid " +
+ "where main.xjdh = #{sourceTackingCode} and dt.djbhs is not null ")
+ @CollectionMethod(3)
+ List queryQuotaList(@ParamMapper("sourceTackingCode")String sourceTackingCode);
+
+ /**
+ * 更新询价表是否已评分字段
+ * @param sourceTrackingCode 寻原单号
+ * @return 更新结果
+ */
+ @Update("update uf_src_rfq set sfypf = 0 where xydh = #{sourceTrackingCode}")
+ boolean updateSourceTrackingStatus(String sourceTrackingCode);
+
+}
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
index b8e57c4..a3a0344 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorMapper.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorMapper.java
@@ -2,10 +2,11 @@ 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 weaver.bokang.xiao.xhny_report.entity.pojo.CompanyEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
import java.util.List;
+import java.util.Map;
/**
* @ClassName VendorMapper
@@ -30,4 +31,15 @@ public interface VendorMapper {
*/
@Select("select * from uf_company_info")
List queryCompanyList();
+
+ /**
+ * 查询供应商被投诉的次数
+ * @param param 条件参数
+ * @return 被投诉的次数
+ */
+ @Select("select count(1) from uf_kscltz main " +
+ " inner join uf_kscltz_dt1 dt on main.id = dt.mainid " +
+ " where ',' + CAST (dt.gys AS VARCHAR ) + ',' like #{vendorStr} and (main.tsrq between #{beginDate} and #{endDate})")
+ int getBadCount(Map param);
+
}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java
new file mode 100644
index 0000000..7b08df1
--- /dev/null
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java
@@ -0,0 +1,58 @@
+package weaver.bokang.xiao.xhny_report.mapper;
+
+import aiyh.utils.annotation.recordset.*;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt;
+
+import java.util.List;
+
+/**
+ * @ClassName VendorReportMapper
+ * @Author 肖博亢
+ * @Date 2023/3/20 14:20
+ * @Description 报表数据
+ **/
+@SqlMapper
+public interface VendorReportMapper {
+
+ /**
+ * 更新报表数据
+ * @param vendorMarkReport 供应商评分报表
+ * @return 更新结果
+ */
+ @Update("update uf_vendorMarkReport set " +
+ "pgksrq = #{evaluationStartDate}," +
+ "pgjsrq = #{evaluationEndDate}," +
+ "gys = #{supplier}," +
+ "pl = #{category}," +
+ "bqzf = #{totalScore}," +
+ "xydh = #{sourceTrackingCode} " +
+ "where id = #{id}")
+ boolean updateReport(VendorMarkReport vendorMarkReport);
+
+ /**
+ * 批量插入报表明细数据
+ * @param vendorMarkReportDtList 报表明细数据
+ * @return 插入结果
+ */
+ @BatchInsert("insert into uf_vendorMarkReport_dt1 (xm,ms,qz,sjdf,mainid) " +
+ "values(#{item.project},#{item.desc},#{item.weight},#{item.score},#{mainId})")
+ boolean insertReportDt(@BatchSqlArgs List vendorMarkReportDtList,@ParamMapper("mainId") int mainId);
+
+ /**
+ * 删除报表数据
+ * @param ids 主键id数组
+ * @return 操作结果
+ */
+ @Delete("delete from uf_vendorMarkReport where id in ($t{ids})")
+ boolean deleteReport(@ParamMapper("ids")String ids);
+
+ /**
+ * 删除报表明细数据
+ * @param mainIds 主键数据id数组
+ * @return 操作结果
+ */
+ @Delete("delete from uf_vendorMarkReport_dt1 where mainid in ($t{mainIds})")
+ boolean deleteReportDt(@ParamMapper("mainIds")String mainIds);
+
+}
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
index cac6dbd..e1c4ba3 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java
@@ -5,15 +5,20 @@ import aiyh.utils.action.CusBaseCronJob;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
+import com.alibaba.fastjson.JSON;
import lombok.Data;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
-import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.mapper.SourceTrackingMapper;
+import weaver.bokang.xiao.xhny_report.mapper.VendorReportMapper;
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.general.TimeUtil;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @ClassName GenerateReportSchedule
@@ -29,26 +34,63 @@ public class GenerateReportSchedule extends CusBaseCronJob {
@RequiredMark("报表模块id")
@PrintParamMark
private String reportModelId;
-
+
+ @RequiredMark("数据源名称")
+ @PrintParamMark
+ private String dataSource;
+
+ private SourceTrackingMapper sourceTrackingMapper = Util.getMapper(SourceTrackingMapper.class);
+
+ private VendorReportMapper vendorReportMapper = Util.getTransMapper(VendorReportMapper.class);
+
@Override
public void runCode() {
- try {
- // 必填参数校验
- Util.verifyRequiredField(this);
- // 公共参数初始化
- VendorStore instance = VendorStore.getInstance();
- instance.init();
- // 获取评分处理链
- AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain();
- // 处理数据初始化
- List vendorMarkReportList = new ArrayList<>();
- SourceTrackingData sourceTrackingData = new SourceTrackingData();
- // 进行供应商评分
+ //公共参数初始化
+ VendorStore instance = VendorStore.getInstance();
+ instance.init(dataSource);
+ // 获取评分处理链
+ AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain();
+ log.info(scoreChain);
+ //处理数据初始化
+ Map queryParam = new HashMap<>(8);
+ queryParam.put("endDate", TimeUtil.getCurrentTimeString());
+ List sourceTrackingDataList = sourceTrackingMapper.querySourceTrackingList(queryParam);
+ if(Objects.isNull(sourceTrackingDataList) || sourceTrackingDataList.isEmpty()){
+ log.info("当天没有需要统计的供应商评分数据");
+ return;
+ }
+ log.info("询价单信息 sourceTrackingDataList ==>"+ JSON.toJSONString(sourceTrackingDataList));
+ for (SourceTrackingData sourceTrackingData : sourceTrackingDataList) {
+ List sourceVendorList = sourceTrackingData.getSourceVendorList();
+ List vendorMarkReportList = sourceVendorList.stream().map(item -> VendorMarkReport.builder()
+ .supplier(item.getVendorId())
+ .evaluationStartDate(sourceTrackingData.getQuotaBeginDate())
+ .evaluationEndDate(sourceTrackingData.getQuotaEndDate())
+ .sourceTrackingCode(sourceTrackingData.getSourceTrackingCode())
+ .build()).collect(Collectors.toList());
+ //进行供应商评分
scoreChain.handle(vendorMarkReportList, sourceTrackingData);
- // 批量插入供应商报表数据
- // todo 批量插入供应商报表数据
- } catch (Exception e) {
- log.error("定时任务执行异常 ==>" + Util.getErrString(e));
+ //批量插入供应商报表数据
+ List reportIdList = new ArrayList<>();
+ try {
+ log.info(String.format("单次寻源[%s] 供应商评分信息 ==>[%s]",sourceTrackingData.getSourceTrackingCode(),JSON.toJSONString(vendorMarkReportList)));
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ int dataId = Util.getModeDataId("uf_vendorMarkReport", Util.getIntValue(reportModelId), 1);
+ vendorMarkReport.setId(dataId);
+ reportIdList.add(dataId);
+ vendorReportMapper.updateReport(vendorMarkReport);
+ vendorReportMapper.insertReportDt(vendorMarkReport.getVendorMarkReportDtList(),dataId);
+ }
+ sourceTrackingMapper.updateSourceTrackingStatus(sourceTrackingData.getSourceTrackingCode());
+ Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(reportModelId),reportIdList);
+ Util.commitTransMapper(VendorReportMapper.class);
+ }catch (Exception e){
+ Util.rollbackTransMapper(VendorReportMapper.class);
+ if(!reportIdList.isEmpty()) {
+ String ids = reportIdList.stream().map(Util::null2String).collect(Collectors.joining(","));
+ vendorReportMapper.deleteReport(ids);
+ }
+ }
}
}
}
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
index 0bcfd51..0f9f7d6 100644
--- a/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java
@@ -4,7 +4,7 @@ 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.entity.pojo.ConfigEntity;
import weaver.bokang.xiao.xhny_report.mapper.VendorMapper;
import weaver.bokang.xiao.xhny_report.service.chain.*;
@@ -51,6 +51,7 @@ public class ScoreChainPattern {
logger.info(String.format("评分配置信息: < %s >", JSON.toJSONString(configEntities)));
Map> configMap = configEntities.stream().collect(Collectors.groupingBy(ConfigEntity::getChildItem));
AbstractScoreChain abstractScoreChain = null;
+ AbstractScoreChain pointerChain = null;
for (Map.Entry> entry : configMap.entrySet()) {
AbstractScoreChain tempChain = SCORE_CHAIN_MAP.get(entry.getKey());
if(Objects.isNull(tempChain)){
@@ -60,10 +61,12 @@ public class ScoreChainPattern {
if(Objects.isNull(abstractScoreChain)){
abstractScoreChain = SCORE_CHAIN_MAP.get(entry.getKey());
abstractScoreChain.setScoreConfigList(entry.getValue());
+ pointerChain = abstractScoreChain;
}else {
AbstractScoreChain nexChain = SCORE_CHAIN_MAP.get(entry.getKey());
nexChain.setScoreConfigList(entry.getValue());
- abstractScoreChain.nextScoreChain(nexChain);
+ pointerChain.nextScoreChain(nexChain);
+ pointerChain = nexChain;
}
}
if(Objects.isNull(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
index 0114371..9560057 100644
--- 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
@@ -2,13 +2,14 @@ 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.pojo.ConfigEntity;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
-import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
import weaver.bokang.xiao.xhny_report.service.store.VendorStore;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.stream.Collectors;
/**
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
index 7a4c259..e1a87c3 100644
--- 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
@@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain;
-import weaver.bokang.xiao.xhny_report.entity.*;
+import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import java.util.*;
@@ -31,20 +33,14 @@ public class AccountPeriodChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getAccountPeriod()));
- double score = 0.00;
+ double score = 0.0;
if(Objects.nonNull(configEntity)){
- score = configEntity.getScore();
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }else {
+ configEntity = this.configEntityMap.get(mappingConfig.get(0));
}
- 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);
+ logger.info(String.format("账期评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"账期评分");
}
//让下一个链对象评分
if(Objects.nonNull(this.nextAbstractScoreChain)) {
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
index 364dff3..8c10821 100644
--- 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
@@ -1,9 +1,21 @@
package weaver.bokang.xiao.xhny_report.service.chain;
+import aiyh.utils.Util;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
-import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
+import weaver.general.StaticObj;
+import weaver.interfaces.datasource.DataSource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Context;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
/**
@@ -16,11 +28,61 @@ public class ArrivalRateChain extends AbstractScoreChain{
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
-
+ //具体评分逻辑
+ Map configEntityMap = this.configEntityMap;
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ double arrivalRate = this.getArrivalRateByCall(vendorMarkReport.getSupplierCode(), sourceTrackingData.getQuotaBeginDate(), sourceTrackingData.getQuotaEndDate());
+ int scoreId = 0;
+ if(arrivalRate >= 1){
+ //到货率100%
+ scoreId = 30;
+ } else if(arrivalRate >= 0.8){
+ //到货率 80% - 100%
+ scoreId = 31;
+ } else {
+ //到货率 80% 以下
+ scoreId = 32;
+ }
+ ConfigEntity configEntity = configEntityMap.get(scoreId);
+ double score = VendorUtil.getScoreByConfig(configEntity);
+ logger.info(String.format("到货率评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"到货率评分");
+ }
//让下一个链对象评分
if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);
}
}
+
+ /**
+ * 通过存储过程获取到货率
+ * @param vendorCode 供应商编码
+ * @return 到货率
+ */
+ private double getArrivalRateByCall(String vendorCode,String beginDate,String endDate){
+ double arrivalRate = 0.00;
+ DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource."+this.vendorStore.getDataSource()),DataSource.class);
+ Connection conn = null ;
+ // CallableStatement对象
+ CallableStatement callableStatement = null;
+ // 结果集对象
+ ResultSet resultSet = null;
+ try{
+ conn = ds.getConnection();
+ callableStatement = conn.prepareCall("{CALL kd_po_nastnumAndnassistnum(?,?,?)}");
+
+ callableStatement.setString(1,vendorCode);
+ callableStatement.setString(2,beginDate);
+ callableStatement.setString(3,endDate);
+
+ resultSet = callableStatement.executeQuery();
+ if(resultSet.next()){
+ logger.info("数据源请求结果 ==>"+resultSet.getString("nrate"));
+ arrivalRate = Util.getDoubleValue(resultSet.getString("nrate"));
+ }
+ } catch (Exception e) {
+ logger.error("远程调用存储过程失败 ==>"+ Util.getErrString(e));
+ }
+ return arrivalRate;
+ }
}
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
index fb96dfc..852820e 100644
--- 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
@@ -1,10 +1,14 @@
package weaver.bokang.xiao.xhny_report.service.chain;
+import aiyh.utils.Util;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
-import weaver.bokang.xiao.xhny_report.entity.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt;
+import weaver.bokang.xiao.xhny_report.mapper.VendorMapper;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
/**
* @ClassName BadCountChain
@@ -13,10 +17,40 @@ import java.util.Objects;
* @Description 不良品数评分
**/
public class BadCountChain extends AbstractScoreChain{
+
+ private final VendorMapper vendorMapper = Util.getMapper(VendorMapper.class);
+
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
-
+ //具体评分逻辑
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Map queryParam = new HashMap<>();
+ queryParam.put("beginDate",sourceTrackingData.getQuotaBeginDate());
+ queryParam.put("endDate",sourceTrackingData.getQuotaEndDate());
+ queryParam.put("vendorStr",',' + vendorMarkReport.getSupplier() + ',');
+ int badCount = vendorMapper.getBadCount(queryParam);
+ int scoreId = 0;
+ if(badCount > 10){
+ //11次以上客诉
+ scoreId = 37;
+ } else if(badCount >= 6){
+ //6-10客诉
+ scoreId = 36;
+ } else if(badCount >= 3){
+ //3-5次客诉
+ scoreId = 35;
+ }else if(badCount >= 1){
+ //1-2次客诉
+ scoreId = 34;
+ }else {
+ //无客诉
+ scoreId = 33;
+ }
+ ConfigEntity configEntity = configEntityMap.get(scoreId);
+ double score = VendorUtil.getScoreByConfig(configEntity);
+ logger.info(String.format("不良品数评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"不良品数评分");
+ }
//让下一个链对象评分
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
index f46cad8..ead44ec 100644
--- 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
@@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain;
-import weaver.bokang.xiao.xhny_report.entity.*;
+import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import java.util.*;
@@ -36,20 +38,14 @@ public class DeliveryCycleChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getDeliveryCycle()));
- double score = 0.00;
+ double score = 0.0;
if(Objects.nonNull(configEntity)){
- score = configEntity.getScore();
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }else {
+ configEntity = this.configEntityMap.get(mappingConfig.get(0));
}
- 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);
+ logger.info(String.format("配送周期评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"配送周期评分");
}
//让下一个链对象评分
if(Objects.nonNull(this.nextAbstractScoreChain)) {
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
index 2bec078..bf3c5ed 100644
--- 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
@@ -1,10 +1,12 @@
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 weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
-import java.util.List;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @ClassName MoneyAmountChain
@@ -15,11 +17,73 @@ import java.util.Objects;
public class MoneyAmountChain extends AbstractScoreChain{
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
+ logger.info(" MoneyAmountChain deal 金额数评分 ");
+ //具体评分逻辑
+ List quotaDataList = sourceTrackingData.getQuotaDataList();
+ //按供应商将报价信息分组
+ Map> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
+ //初始化供应商评分map集合
+ Map vendorScoreMap = vendorMarkReportList.stream().collect(Collectors.toMap(
+ VendorMarkReport::getSupplier,
+ v -> -1
+ ));
+ //供应商都进行了报价,取出每个供应商的物料报价组成新的list
+ List> sourceList = new ArrayList<>();
+ if(vendorQuotaMap.size() == vendorMarkReportList.size()){
+ Set>> entries = vendorQuotaMap.entrySet();
+ for (Map.Entry> entry : entries) {
+ sourceList.add(entry.getValue());
+ }
+ }
+ //求出每个供应商都报价的物料(求交集)
+ List retainQuotaList = VendorUtil.retainElementList(sourceList);
+ if(!retainQuotaList.isEmpty()){
+ //统计报价总和
+ Map quotaScoreMap = vendorQuotaMap.entrySet().stream()
+ .collect(Collectors.toMap(
+ Map.Entry::getKey,
+ v -> v.getValue().stream().filter(retainQuotaList::contains).mapToDouble(QuotaData::getQuotaValue).sum())
+ );
+ //统计报价最小值
+ Optional> min = quotaScoreMap.entrySet().stream().min(Map.Entry.comparingByValue());
+ if(min.isPresent()){
+ double minValue = min.get().getValue();
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ double quotaStore = quotaScoreMap.get(supplier);
+ int scoreId;
+ if(new BigDecimal(quotaStore).compareTo(new BigDecimal(minValue)) == 0){
+ //最小值
+ scoreId = 20;
+ }else {
+ //其他
+ scoreId = 21;
+ }
+
+ vendorScoreMap.put(supplier,scoreId);
+ }
+ }
+ }
+ //整理评分数据
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ double score = 0.0;
+ ConfigEntity configEntity = this.configEntityMap.get(21);
+ int scoreId = vendorScoreMap.get(supplier);
+ if(scoreId > -1){
+ configEntity = this.configEntityMap.get(scoreId);
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }
+ logger.info(String.format("金额数评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"金额数评分");
+ }
//让下一个链对象评分
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
index 92ad802..f720e0d 100644
--- 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
@@ -1,7 +1,9 @@
package weaver.bokang.xiao.xhny_report.service.chain;
import org.apache.commons.lang3.StringUtils;
-import weaver.bokang.xiao.xhny_report.entity.*;
+import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import java.util.*;
@@ -18,13 +20,13 @@ public class OrderRequirementChain extends AbstractScoreChain{
private final Map mappingConfig = new HashMap<>();
{
- mappingConfig.put(0,0);
- mappingConfig.put(1,0);
+ mappingConfig.put(0,38);
+ mappingConfig.put(1,33);
}
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
+ //具体评分逻辑
logger.info(" OrderRequirementChain deal 起订要求评分处理 ");
Map companyMap = vendorStore.getCompanyMap();
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
@@ -32,20 +34,12 @@ public class OrderRequirementChain extends AbstractScoreChain{
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();
+ if(Objects.isNull(configEntity)){
+ logger.error("OrderRequirementChain 起订要求评分配置为设置 "+companyEntity);
}
- 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);
+ double score = VendorUtil.getScoreByConfig(configEntity);
+ logger.info(String.format("起订要求评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"起订要求评分");
}
//让下一个链对象评分
if(Objects.nonNull(this.nextAbstractScoreChain)) {
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
index 31cfa6e..1494341 100644
--- 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
@@ -1,23 +1,55 @@
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 weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* @ClassName QuotationCompleteChain
* @Author 肖博亢
* @Date 2023/3/17 15:41
- * @Description 报价完整信评分
+ * @Description 报价完整性评分
**/
public class QuotationCompleteChain extends AbstractScoreChain {
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
-
+ logger.info(" QuotationCompleteChain deal 报价完整性评分 ");
+ //具体评分逻辑
+ List quotaDataList = sourceTrackingData.getQuotaDataList();
+ //按供应商将报价信息分组
+ Map> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
+ //整理评分数据
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ //默认报价回复率<70%
+ int scoreId = 26;
+ if(vendorQuotaMap.containsKey(supplier)){
+ int quotaCount = vendorQuotaMap.get(supplier).size();
+ int sourceMaterialCount = sourceTrackingData.getSourceMaterialList().size();
+ double proportion = quotaCount * 1.0 / sourceMaterialCount;
+ if(proportion >= 0.95){
+ //报价回复率>=95%
+ scoreId = 24;
+ }else if(proportion >= 0.7){
+ //70%=<报价回复率<95%
+ scoreId = 25;
+ }
+ }
+ ConfigEntity configEntity = this.configEntityMap.get(scoreId);
+ double score = VendorUtil.getScoreByConfig(configEntity);
+ logger.info(String.format("报价完整性评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"报价完整性评分");
+ }
//让下一个链对象评分
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
index a05486f..17b27c9 100644
--- 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
@@ -1,10 +1,15 @@
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 weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
-import java.util.List;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @ClassName QuotationNumberChain
@@ -16,8 +21,72 @@ public class QuotationNumberChain extends AbstractScoreChain{
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
-
+ logger.info(" QuotationNumberChain deal 报价数评分 ");
+ //具体评分逻辑
+ List quotaDataList = sourceTrackingData.getQuotaDataList();
+ //按供应商将报价信息分组
+ Map> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
+ //初始化供应商评分map集合
+ Map vendorScoreMap = vendorMarkReportList.stream().collect(Collectors.toMap(
+ VendorMarkReport::getSupplier,
+ v -> -1
+ ));
+ //供应商都进行了报价,取出每个供应商的物料报价组成新的list
+ List> sourceList = new ArrayList<>();
+ if(vendorQuotaMap.size() == vendorMarkReportList.size()){
+ Set>> entries = vendorQuotaMap.entrySet();
+ for (Map.Entry> entry : entries) {
+ sourceList.add(entry.getValue());
+ }
+ }
+ //求出每个供应商都报价的物料(求交集)
+ List retainQuotaList = VendorUtil.retainElementList(sourceList);
+ if(!retainQuotaList.isEmpty()) {
+ //过滤出交集部分的物料报价
+ Map> materialQuotaMap = quotaDataList.stream()
+ .filter(retainQuotaList::contains)
+ .collect(Collectors.groupingBy(QuotaData::getMaterialId));
+ //统计每个物料报价的最低值
+ Map materialMinMap = materialQuotaMap.entrySet().stream().collect(Collectors.toMap(
+ Map.Entry::getKey,
+ v -> v.getValue().stream()
+ .min(Comparator.comparing(QuotaData::getQuotaValue))
+ .get().getQuotaValue()
+ ));
+ //统计每个供应商报价最低物料数量
+ Map minQuotaCount = vendorQuotaMap.entrySet().stream().collect(Collectors.toMap(
+ Map.Entry::getKey,
+ v -> (int) v.getValue().stream().filter(item -> {
+ Integer materialId = item.getMaterialId();
+ Double quotaValue = item.getQuotaValue();
+ return materialMinMap.containsKey(materialId) && new BigDecimal(quotaValue).compareTo(BigDecimal.valueOf(materialMinMap.get(materialId))) == 0;
+ }).count()
+ ));
+ //统计出报价最低 最多的次数
+ Integer maxCount = minQuotaCount.entrySet().stream().max(Map.Entry.comparingByValue()).get().getValue();
+ for (Map.Entry entry : minQuotaCount.entrySet()) {
+ if(entry.getValue().equals(maxCount)){
+ //报价数最低的最多
+ vendorScoreMap.put(entry.getKey(),18);
+ }else {
+ //其他
+ vendorScoreMap.put(entry.getKey(),19);
+ }
+ }
+ }
+ //整理评分数据
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ double score = 0.0;
+ ConfigEntity configEntity = this.configEntityMap.get(18);
+ int scoreId = vendorScoreMap.get(supplier);
+ if(scoreId > -1){
+ configEntity = this.configEntityMap.get(scoreId);
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }
+ logger.info(String.format("报价数评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"报价数评分");
+ }
//让下一个链对象评分
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
index 7ad4470..b5d6e6b 100644
--- 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
@@ -1,10 +1,15 @@
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 weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
+import java.util.stream.Collectors;
/**
* @ClassName QuotationTimeChain
@@ -16,8 +21,20 @@ public class QuotationTimeChain extends AbstractScoreChain{
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
-
+ logger.info(" QuotationTimeChain deal 报价及时率评分 ");
+ //具体评分逻辑
+ List quotaDataList = sourceTrackingData.getQuotaDataList();
+ //按供应商将报价信息分组
+ Map> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ //供应商报过价(及时回复)为27;未报价(未及时回复)则为28
+ int configId = vendorQuotaMap.containsKey(supplier) ? 27 : 28;
+ ConfigEntity configEntity = this.configEntityMap.get(configId);
+ double score = VendorUtil.getScoreByConfig(configEntity);
+ logger.info(String.format("报价及时率评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"报价及时率评分");
+ }
//让下一个链对象评分
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
index 340f453..c786c4d 100644
--- 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
@@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain;
-import weaver.bokang.xiao.xhny_report.entity.*;
+import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import java.util.*;
@@ -30,20 +32,14 @@ public class ReturnAndExchangeChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getReturnAndExchange()));
- double score = 0.00;
+ double score = 0.0;
if(Objects.nonNull(configEntity)){
- score = configEntity.getScore();
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }else {
+ configEntity = this.configEntityMap.get(mappingConfig.get(0));
}
- 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);
+ logger.info(String.format("退换货评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"退换货评分");
}
//让下一个链对象评分
if(Objects.nonNull(this.nextAbstractScoreChain)) {
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
index cc754d8..03ab02b 100644
--- 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
@@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain;
-import weaver.bokang.xiao.xhny_report.entity.*;
+import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.*;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import java.util.*;
@@ -29,20 +31,14 @@ public class SortingServiceChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getSortingService()));
- double score = 0.00;
+ double score = 0.0;
if(Objects.nonNull(configEntity)){
- score = configEntity.getScore();
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }else {
+ configEntity = this.configEntityMap.get(mappingConfig.get(0));
}
- 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);
+ logger.info(String.format("分拣服务评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"分拣服务评分");
}
//让下一个链对象评分
if(Objects.nonNull(this.nextAbstractScoreChain)) {
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
index 44b57f0..da5b11c 100644
--- 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
@@ -1,10 +1,15 @@
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 weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.MaterialEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
-import java.util.List;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @ClassName TopThirtyChain
@@ -16,8 +21,77 @@ public class TopThirtyChain extends AbstractScoreChain{
@Override
public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) {
- //TODO 具体评分逻辑
+ logger.info(" TopThirtyChain deal top30评分 ");
+ //具体评分逻辑
+ List quotaDataList = sourceTrackingData.getQuotaDataList();
+ //按供应商将报价信息分组
+ Map> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
+ //初始化供应商评分map集合
+ Map vendorScoreMap = vendorMarkReportList.stream().collect(Collectors.toMap(
+ VendorMarkReport::getSupplier,
+ v -> -1
+ ));
+ //供应商都进行了报价,取出每个供应商的物料报价组成新的list
+ List> sourceList = new ArrayList<>();
+ if(vendorQuotaMap.size() == vendorMarkReportList.size()){
+ Set>> entries = vendorQuotaMap.entrySet();
+ for (Map.Entry> entry : entries) {
+ sourceList.add(entry.getValue());
+ }
+ }
+ //求出每个供应商都报价的物料(求交集)
+ List retainQuotaList = VendorUtil.retainElementList(sourceList);
+ if(!retainQuotaList.isEmpty()){
+ //过滤top30的物料信息
+ Map topThirtyMaterial = this.vendorStore.getTopThirtyMaterial();
+ Map mappingMaterial = sourceTrackingData.getSourceMaterialList().stream().collect(Collectors.toMap(MaterialEntity::getMaterialId, MaterialEntity::getMaterialCode));
+ List collect = retainQuotaList.stream().filter(item -> {
+ Integer materialId = item.getMaterialId();
+ String materialCode = mappingMaterial.get(materialId);
+ return topThirtyMaterial.containsKey(materialCode);
+ }).collect(Collectors.toList());
+ if(!collect.isEmpty()) {
+ //统计报价总和
+ Map quotaScoreMap = vendorQuotaMap.entrySet().stream()
+ .collect(Collectors.toMap(
+ Map.Entry::getKey,
+ v -> v.getValue().stream().filter(collect::contains).mapToDouble(QuotaData::getQuotaValue).sum())
+ );
+ //统计报价最小值
+ Optional> min = quotaScoreMap.entrySet().stream().min(Map.Entry.comparingByValue());
+ if (min.isPresent()) {
+ double minValue = min.get().getValue();
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ double quotaStore = quotaScoreMap.get(supplier);
+ int scoreId;
+ if (new BigDecimal(quotaStore).compareTo(new BigDecimal(minValue)) == 0) {
+ //最小值
+ scoreId = 22;
+ } else {
+ //其他
+ scoreId = 23;
+ }
+
+ vendorScoreMap.put(supplier, scoreId);
+ }
+ }
+ }
+ }
+ //整理评分数据
+ for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
+ Integer supplier = vendorMarkReport.getSupplier();
+ double score = 0.0;
+ ConfigEntity configEntity = this.configEntityMap.get(23);
+ int scoreId = vendorScoreMap.get(supplier);
+ if(scoreId > -1){
+ configEntity = this.configEntityMap.get(scoreId);
+ score = VendorUtil.getScoreByConfig(configEntity);
+ }
+ logger.info(String.format("top30评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
+ VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"top30评分");
+ }
//让下一个链对象评分
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
index e3e8a9c..279711d 100644
--- 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
@@ -1,11 +1,17 @@
package weaver.bokang.xiao.xhny_report.service.store;
import aiyh.utils.Util;
+import com.alibaba.fastjson.JSON;
import lombok.Getter;
import org.apache.log4j.Logger;
-import weaver.bokang.xiao.xhny_report.entity.CompanyEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.CompanyEntity;
import weaver.bokang.xiao.xhny_report.mapper.VendorMapper;
+import weaver.general.StaticObj;
+import weaver.interfaces.datasource.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -27,25 +33,63 @@ public class VendorStore {
private Map companyMap = new HashMap<>();
+ /** 数据源名称 */
+ private String dataSource;
+
private static final Logger logger = Util.getLogger();
private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class);
+ private final Map topThirtyMaterial = new HashMap<>();
+
private VendorStore(){
//this.init();
}
- public void init(){
+ public void init(String dataSource){
try{
+ this.dataSource = dataSource;
this.companyEntityList = VENDOR_MAPPER.queryCompanyList();
if(Objects.nonNull(companyEntityList) && !companyEntityList.isEmpty()){
companyMap = companyEntityList.stream().collect(Collectors.toMap(CompanyEntity::getId, item -> item));
}
+ this.queryTopThirtyMaterial();
+ logger.info(String.format("公共数据初始化成功 VendorStore init success !! [VENDOR_MAPPER:%s \n topThirtyMaterial:%s]", JSON.toJSONString(VENDOR_MAPPER), JSON.toJSONString(topThirtyMaterial)));
}catch (Exception exception){
logger.error("VendorStore 初始化异常 ==>"+Util.getErrString(exception));
}
}
+ /**
+ * 从数据源查询出top30的物料信息
+ */
+ private void queryTopThirtyMaterial(){
+ DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource."+this.dataSource),DataSource.class);
+ Connection conn = null ;
+ Statement statement = null;
+ try {
+ conn = ds.getConnection();
+ statement = conn.createStatement();
+ String querySql = "select top 30 * from kd_po_orderout_b";
+ ResultSet rs = statement.executeQuery(querySql);
+ while (rs.next()) {
+ String materialCode = Util.null2String(rs.getString("materialcode"));
+ double nastorigtaxPrice = Util.getDoubleValue(rs.getString("nastorigtaxprice"));
+ this.topThirtyMaterial.put(materialCode,nastorigtaxPrice);
+ }
+ logger.info("top30 物料信息 topThirtyMaterial ==>"+topThirtyMaterial);
+ }catch (Exception e){
+ logger.error("数据源查询异常 ==>"+Util.getErrString(e));
+ }finally {
+ try{
+ assert conn != null;
+ conn.close();
+ }catch (Exception e){
+ logger.error("关闭连接异常 ==>"+Util.getErrString(e));
+ }
+ }
+ }
+
public static VendorStore getInstance(){
return VendorStoreHolder.VENDOR_STORE;
}
diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java
new file mode 100644
index 0000000..324071b
--- /dev/null
+++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java
@@ -0,0 +1,72 @@
+package weaver.bokang.xiao.xhny_report.service.util;
+
+import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
+import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
+import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * @ClassName VendorUtil
+ * @Author 肖博亢
+ * @Date 2023/3/20 18:37
+ * @Description
+ **/
+public class VendorUtil {
+
+ /**
+ * 通过配置信息获取分数
+ * @param configEntity 配置信息
+ * @return 分数
+ */
+ public static double getScoreByConfig(ConfigEntity configEntity){
+ double score = 0.00;
+ if(Objects.nonNull(configEntity)){
+ double weight = configEntity.getWeight();
+ double tempScore = configEntity.getScore();
+ score = tempScore * weight;
+ }
+ return score;
+ }
+
+ /**
+ * 报表参数组装
+ * @param vendorMarkReport 报表信息
+ * @param configEntity 配置信息
+ * @param score 分数
+ * @param desc 描述信息
+ */
+ public static void makeReportData(VendorMarkReport vendorMarkReport, ConfigEntity configEntity, double score,String desc){
+ List vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList();
+ vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList;
+ vendorMarkReport.setVendorMarkReportDtList(vendorMarkReportDtList);
+ vendorMarkReportDtList.add(
+ VendorMarkReportDt.builder()
+ .score(score)
+ .project(configEntity.getChildItem())
+ .weight(configEntity.getWeight())
+ .desc(desc).build());
+ double totalScore = vendorMarkReport.getTotalScore();
+ vendorMarkReport.setTotalScore(totalScore + score);
+ }
+
+ /**
+ * 多数组取交集
+ * @param elementLists 数据集合
+ * @return 交集数据
+ */
+ public static List retainElementList(List> elementLists) {
+ Optional> result = elementLists.parallelStream()
+ .filter(elementList -> elementList != null && elementList.size() != 0)
+ .reduce((a, b) -> {
+ a.retainAll(b);
+ return a;
+ });
+ return result.orElse(new ArrayList<>());
+ }
+
+}
diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java
index f895e02..54e5a24 100644
--- a/src/test/java/bokang/xiao/NormalTest.java
+++ b/src/test/java/bokang/xiao/NormalTest.java
@@ -19,8 +19,11 @@ import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
+import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule;
import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain;
import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern;
+import weaver.conn.RecordSet;
+import weaver.conn.RecordSetDataSource;
import weaver.general.StaticObj;
import weaver.hrm.User;
import weaver.interfaces.datasource.DataSource;
@@ -30,11 +33,9 @@ import weaver.xiao.commons.utils.DocImageFileUtil;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
import java.util.*;
+import java.util.Date;
/**
* @ClassName NormalTest
@@ -46,10 +47,15 @@ public class NormalTest extends BaseTest {
@Test
public void testWord(){
- String s = "{uf_jxshttz:jxsqszt=1&qsfs=0:cjrq},{uf_htzzzs:dqjd=24&htlb is not null&yylx=0:sqrq}";
- ReviewServiceImpl reviewService = new ReviewServiceImpl();
- Map> modelTableSql = reviewService.getModelTableSql(s);
- System.out.println(modelTableSql);
+ GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class);
+ }
+
+ @Test
+ public void testChain(){
+ GenerateReportSchedule generateReportSchedule = new GenerateReportSchedule();
+ generateReportSchedule.setReportModelId("-2915");
+ generateReportSchedule.setDataSource("NCC");
+ generateReportSchedule.runCode();
}
@Test
@@ -69,19 +75,31 @@ public class NormalTest extends BaseTest {
@Test
public void testDataSource(){
- DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.a"),DataSource.class);
+ DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class);
Connection conn = null ;
CallableStatement callableStatement = null; // CallableStatement对象
ResultSet resultSet = null; // 结果集对象
try{
conn = ds.getConnection();
- callableStatement = conn.prepareCall("{CALL proc_search_user(?,?,?,?)}");
+ callableStatement = conn.prepareCall("{CALL kd_po_nastnumAndnassistnum(?,?,?,?,?,?,?,?,?)}");
+
+ callableStatement.setString(1,"GC736");
+ callableStatement.setString(2,"2023-01-01");
+ callableStatement.setString(3,"2023-04-01");
+
+ callableStatement.registerOutParameter(4, Types.INTEGER);
+ callableStatement.registerOutParameter(5, Types.INTEGER);
+ callableStatement.registerOutParameter(6, Types.INTEGER);
+ callableStatement.registerOutParameter(7, Types.VARBINARY);
+ callableStatement.registerOutParameter(8, Types.VARBINARY);
+ callableStatement.registerOutParameter(9, Types.DOUBLE);
+
resultSet = callableStatement.executeQuery();
if(resultSet.next()){
-
+ System.out.println(resultSet.getString("nassistnum"));
}
- } catch (SQLException e) {
- throw new RuntimeException(e);
+ } catch (Exception e) {
+ log.error("远程调用存储过程失败 ==>"+Util.getErrString(e));
}
}
@@ -94,7 +112,7 @@ public class NormalTest extends BaseTest {
param.put("workflowIds","0");
//String s1 = reviewMapper.queryCreateTopDate(param, 1);
//System.out.println(s1);
-
+ RecordSet recordSet = new RecordSet();
}
@Test
@@ -115,6 +133,8 @@ public class NormalTest extends BaseTest {
AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain();
scoreChain.handle(new ArrayList<>(),new SourceTrackingData());
System.out.println(scoreChain);
+ Logger logger = Util.getLogger();
+ //logger.info("message sendData ==>"+);
}
@Test