新弘农业报表需求

main
ic_excellent 2023-03-23 13:23:58 +08:00
parent d776524824
commit a7b324ce6c
30 changed files with 1022 additions and 149 deletions

View File

@ -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 <h1></h1>
**/
@Path("/xbk/xhny_report")
public class ReportController {
private final Logger log = Util.getLogger();
/**
* <h2></h2>
* @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 "查看日志信息";
}
}

View File

@ -1,6 +1,10 @@
package weaver.bokang.xiao.xhny_report.entity; package weaver.bokang.xiao.xhny_report.entity;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Data; 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; import java.util.List;
@ -14,5 +18,28 @@ import java.util.List;
@Data @Data
public class SourceTrackingData { public class SourceTrackingData {
private List<String> vendorList; private Integer id;
/** 寻源单号 */
@SqlDbFieldAnn("xydh")
private String sourceTrackingCode;
/** 报价开始时间 */
@SqlDbFieldAnn("bjkssj")
private String quotaBeginDate;
/** 报价截止时间 */
@SqlDbFieldAnn("bjjzsj")
private String quotaEndDate;
/** 供应商列表 */
private List<VendorEntity> sourceVendorList;
/** 物料列表 */
private List<MaterialEntity> sourceMaterialList;
/** 最终报价数据 */
private List<QuotaData> quotaDataList;
} }

View File

@ -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 aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Data; import lombok.Data;

View File

@ -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 aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Data; import lombok.Data;
@ -17,7 +17,7 @@ public class ConfigEntity {
private Integer id; private Integer id;
/** 分数 */ /** 分数 */
@SqlDbFieldAnn("fs") @SqlDbFieldAnn("fsz")
private Double score; private Double score;
/** 子项目 */ /** 子项目 */
@ -30,10 +30,10 @@ public class ConfigEntity {
/** 权重 */ /** 权重 */
@SqlDbFieldAnn("qz") @SqlDbFieldAnn("qz")
private String weight; private Double weight;
/** 明细项 */ /** 明细项 */
@SqlDbFieldAnn("fs") @SqlDbFieldAnn("mxx")
private Integer detailItem; private Integer detailItem;
} }

View File

@ -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 <h1></h1>
**/
@Data
public class MaterialEntity {
/** 物料id */
@SqlDbFieldAnn("wlid")
private Integer materialId;
/** 物料编码 */
@SqlDbFieldAnn("wlbm")
private String materialCode;
/** 物料名称(产品名称) */
@SqlDbFieldAnn("wlmc")
private String materialName;
}

View File

@ -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 <h1></h1>
**/
@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);
}
}

View File

@ -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 <h1></h1>
**/
@Data
public class VendorEntity {
/** 供应商id */
@SqlDbFieldAnn("gysid")
private Integer vendorId;
/** 供应商id */
@SqlDbFieldAnn("gsbm")
private String vendorCode;
/** 供应商名称 */
@SqlDbFieldAnn("gysmc")
private String vendorName;
}

View File

@ -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 aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List; import java.util.List;
@ -13,6 +16,9 @@ import java.util.List;
**/ **/
@Data @Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class VendorMarkReport { public class VendorMarkReport {
/** 数据id */ /** 数据id */
@ -30,6 +36,9 @@ public class VendorMarkReport {
@SqlDbFieldAnn("gys") @SqlDbFieldAnn("gys")
private Integer supplier; private Integer supplier;
/** 供应商编码 */
private String supplierCode;
/** 品类 */ /** 品类 */
@SqlDbFieldAnn("pl") @SqlDbFieldAnn("pl")
private String category; private String category;
@ -38,6 +47,10 @@ public class VendorMarkReport {
@SqlDbFieldAnn("bqzf") @SqlDbFieldAnn("bqzf")
private double totalScore; private double totalScore;
/** 寻源单号 */
@SqlDbFieldAnn("xydh")
private String sourceTrackingCode;
/** 分数明细信息 */ /** 分数明细信息 */
private List<VendorMarkReportDt> vendorMarkReportDtList; private List<VendorMarkReportDt> vendorMarkReportDtList;

View File

@ -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 aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @ClassName VendorMarkReportDt * @ClassName VendorMarkReportDt
@ -13,6 +15,8 @@ import lombok.Data;
@Data @Data
@Builder @Builder
@NoArgsConstructor
@AllArgsConstructor
public class VendorMarkReportDt { public class VendorMarkReportDt {
/** 数据id */ /** 数据id */
@ -31,8 +35,7 @@ public class VendorMarkReportDt {
/** 权重 */ /** 权重 */
@SqlDbFieldAnn("qz") @SqlDbFieldAnn("qz")
private String weight; private Double weight;
/** 预估得分 */ /** 预估得分 */
@SqlDbFieldAnn("ygdf") @SqlDbFieldAnn("ygdf")

View File

@ -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 <h1></h1>
**/
@SqlMapper
public interface SourceTrackingMapper {
/**
* <h2></h2>
* @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<SourceTrackingData> querySourceTrackingList(@ParamMapper("param")Map<String,Object> param);
/**
* <h2></h2>
* @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<VendorEntity> queryVendorList(@ParamMapper("mainId")int mainId);
/**
* <h2></h2>
* @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<MaterialEntity> queryMaterialList(@ParamMapper("mainId")int mainId);
/**
* <h2></h2>
* @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<QuotaData> queryQuotaList(@ParamMapper("sourceTackingCode")String sourceTackingCode);
/**
* <h2></h2>
* @param sourceTrackingCode
* @return
*/
@Update("update uf_src_rfq set sfypf = 0 where xydh = #{sourceTrackingCode}")
boolean updateSourceTrackingStatus(String sourceTrackingCode);
}

View File

@ -2,10 +2,11 @@ package weaver.bokang.xiao.xhny_report.mapper;
import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper; import aiyh.utils.annotation.recordset.SqlMapper;
import weaver.bokang.xiao.xhny_report.entity.CompanyEntity; import weaver.bokang.xiao.xhny_report.entity.pojo.CompanyEntity;
import weaver.bokang.xiao.xhny_report.entity.ConfigEntity; import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName VendorMapper * @ClassName VendorMapper
@ -30,4 +31,15 @@ public interface VendorMapper {
*/ */
@Select("select * from uf_company_info") @Select("select * from uf_company_info")
List<CompanyEntity> queryCompanyList(); List<CompanyEntity> queryCompanyList();
/**
* <h2></h2>
* @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<String,Object> param);
} }

View File

@ -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 <h1></h1>
**/
@SqlMapper
public interface VendorReportMapper {
/**
* <h2></h2>
* @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);
/**
* <h2></h2>
* @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<VendorMarkReportDt> vendorMarkReportDtList,@ParamMapper("mainId") int mainId);
/**
* <h2></h2>
* @param ids id
* @return
*/
@Delete("delete from uf_vendorMarkReport where id in ($t{ids})")
boolean deleteReport(@ParamMapper("ids")String ids);
/**
* <h2></h2>
* @param mainIds id
* @return
*/
@Delete("delete from uf_vendorMarkReport_dt1 where mainid in ($t{mainIds})")
boolean deleteReportDt(@ParamMapper("mainIds")String mainIds);
}

View File

@ -5,15 +5,20 @@ import aiyh.utils.action.CusBaseCronJob;
import aiyh.utils.annotation.ActionDesc; import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.PrintParamMark; import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark; import aiyh.utils.annotation.RequiredMark;
import com.alibaba.fastjson.JSON;
import lombok.Data; import lombok.Data;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.ScoreChainPattern;
import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain; import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain;
import weaver.bokang.xiao.xhny_report.service.store.VendorStore; import weaver.bokang.xiao.xhny_report.service.store.VendorStore;
import weaver.general.TimeUtil;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
/** /**
* @ClassName GenerateReportSchedule * @ClassName GenerateReportSchedule
@ -29,26 +34,63 @@ public class GenerateReportSchedule extends CusBaseCronJob {
@RequiredMark("报表模块id") @RequiredMark("报表模块id")
@PrintParamMark @PrintParamMark
private String reportModelId; private String reportModelId;
@RequiredMark("数据源名称")
@PrintParamMark
private String dataSource;
private SourceTrackingMapper sourceTrackingMapper = Util.getMapper(SourceTrackingMapper.class);
private VendorReportMapper vendorReportMapper = Util.getTransMapper(VendorReportMapper.class);
@Override @Override
public void runCode() { public void runCode() {
try { //公共参数初始化
// 必填参数校验 VendorStore instance = VendorStore.getInstance();
Util.verifyRequiredField(this); instance.init(dataSource);
// 公共参数初始化 // 获取评分处理链
VendorStore instance = VendorStore.getInstance(); AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain();
instance.init(); log.info(scoreChain);
// 获取评分处理链 //处理数据初始化
AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain(); Map<String,Object> queryParam = new HashMap<>(8);
// 处理数据初始化 queryParam.put("endDate", TimeUtil.getCurrentTimeString());
List<VendorMarkReport> vendorMarkReportList = new ArrayList<>(); List<SourceTrackingData> sourceTrackingDataList = sourceTrackingMapper.querySourceTrackingList(queryParam);
SourceTrackingData sourceTrackingData = new SourceTrackingData(); if(Objects.isNull(sourceTrackingDataList) || sourceTrackingDataList.isEmpty()){
// 进行供应商评分 log.info("当天没有需要统计的供应商评分数据");
return;
}
log.info("询价单信息 sourceTrackingDataList ==>"+ JSON.toJSONString(sourceTrackingDataList));
for (SourceTrackingData sourceTrackingData : sourceTrackingDataList) {
List<VendorEntity> sourceVendorList = sourceTrackingData.getSourceVendorList();
List<VendorMarkReport> 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); scoreChain.handle(vendorMarkReportList, sourceTrackingData);
// 批量插入供应商报表数据 //批量插入供应商报表数据
// todo 批量插入供应商报表数据 List<Integer> reportIdList = new ArrayList<>();
} catch (Exception e) { try {
log.error("定时任务执行异常 ==>" + Util.getErrString(e)); 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);
}
}
} }
} }
} }

View File

@ -4,7 +4,7 @@ import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger; 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.mapper.VendorMapper;
import weaver.bokang.xiao.xhny_report.service.chain.*; import weaver.bokang.xiao.xhny_report.service.chain.*;
@ -51,6 +51,7 @@ public class ScoreChainPattern {
logger.info(String.format("评分配置信息: < %s >", JSON.toJSONString(configEntities))); logger.info(String.format("评分配置信息: < %s >", JSON.toJSONString(configEntities)));
Map<Integer, List<ConfigEntity>> configMap = configEntities.stream().collect(Collectors.groupingBy(ConfigEntity::getChildItem)); Map<Integer, List<ConfigEntity>> configMap = configEntities.stream().collect(Collectors.groupingBy(ConfigEntity::getChildItem));
AbstractScoreChain abstractScoreChain = null; AbstractScoreChain abstractScoreChain = null;
AbstractScoreChain pointerChain = null;
for (Map.Entry<Integer, List<ConfigEntity>> entry : configMap.entrySet()) { for (Map.Entry<Integer, List<ConfigEntity>> entry : configMap.entrySet()) {
AbstractScoreChain tempChain = SCORE_CHAIN_MAP.get(entry.getKey()); AbstractScoreChain tempChain = SCORE_CHAIN_MAP.get(entry.getKey());
if(Objects.isNull(tempChain)){ if(Objects.isNull(tempChain)){
@ -60,10 +61,12 @@ public class ScoreChainPattern {
if(Objects.isNull(abstractScoreChain)){ if(Objects.isNull(abstractScoreChain)){
abstractScoreChain = SCORE_CHAIN_MAP.get(entry.getKey()); abstractScoreChain = SCORE_CHAIN_MAP.get(entry.getKey());
abstractScoreChain.setScoreConfigList(entry.getValue()); abstractScoreChain.setScoreConfigList(entry.getValue());
pointerChain = abstractScoreChain;
}else { }else {
AbstractScoreChain nexChain = SCORE_CHAIN_MAP.get(entry.getKey()); AbstractScoreChain nexChain = SCORE_CHAIN_MAP.get(entry.getKey());
nexChain.setScoreConfigList(entry.getValue()); nexChain.setScoreConfigList(entry.getValue());
abstractScoreChain.nextScoreChain(nexChain); pointerChain.nextScoreChain(nexChain);
pointerChain = nexChain;
} }
} }
if(Objects.isNull(abstractScoreChain)){ if(Objects.isNull(abstractScoreChain)){

View File

@ -2,13 +2,14 @@ package weaver.bokang.xiao.xhny_report.service.chain;
import aiyh.utils.Util; import aiyh.utils.Util;
import org.apache.log4j.Logger; 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.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 weaver.bokang.xiao.xhny_report.service.store.VendorStore;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**

View File

@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain; 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.*; import java.util.*;
@ -31,20 +33,14 @@ public class AccountPeriodChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier(); Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier); CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getAccountPeriod())); ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getAccountPeriod()));
double score = 0.00; double score = 0.0;
if(Objects.nonNull(configEntity)){ if(Objects.nonNull(configEntity)){
score = configEntity.getScore(); score = VendorUtil.getScoreByConfig(configEntity);
}else {
configEntity = this.configEntityMap.get(mappingConfig.get(0));
} }
List<VendorMarkReportDt> vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); logger.info(String.format("账期评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"账期评分");
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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {

View File

@ -1,9 +1,21 @@
package weaver.bokang.xiao.xhny_report.service.chain; 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.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.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
@ -16,11 +28,61 @@ public class ArrivalRateChain extends AbstractScoreChain{
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 //具体评分逻辑
Map<Integer, ConfigEntity> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);
} }
} }
/**
* <h2></h2>
* @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;
}
} }

View File

@ -1,10 +1,14 @@
package weaver.bokang.xiao.xhny_report.service.chain; 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.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.*;
import java.util.Objects;
/** /**
* @ClassName BadCountChain * @ClassName BadCountChain
@ -13,10 +17,40 @@ import java.util.Objects;
* @Description <h1></h1> * @Description <h1></h1>
**/ **/
public class BadCountChain extends AbstractScoreChain{ public class BadCountChain extends AbstractScoreChain{
private final VendorMapper vendorMapper = Util.getMapper(VendorMapper.class);
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 //具体评分逻辑
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
Map<String,Object> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);

View File

@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain; 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.*; import java.util.*;
@ -36,20 +38,14 @@ public class DeliveryCycleChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier(); Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier); CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getDeliveryCycle())); ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getDeliveryCycle()));
double score = 0.00; double score = 0.0;
if(Objects.nonNull(configEntity)){ if(Objects.nonNull(configEntity)){
score = configEntity.getScore(); score = VendorUtil.getScoreByConfig(configEntity);
}else {
configEntity = this.configEntityMap.get(mappingConfig.get(0));
} }
List<VendorMarkReportDt> vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); logger.info(String.format("配送周期评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"配送周期评分");
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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {

View File

@ -1,10 +1,12 @@
package weaver.bokang.xiao.xhny_report.service.chain; package weaver.bokang.xiao.xhny_report.service.chain;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.math.BigDecimal;
import java.util.Objects; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @ClassName MoneyAmountChain * @ClassName MoneyAmountChain
@ -15,11 +17,73 @@ import java.util.Objects;
public class MoneyAmountChain extends AbstractScoreChain{ public class MoneyAmountChain extends AbstractScoreChain{
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 logger.info(" MoneyAmountChain deal 金额数评分 ");
//具体评分逻辑
List<QuotaData> quotaDataList = sourceTrackingData.getQuotaDataList();
//按供应商将报价信息分组
Map<Integer, List<QuotaData>> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
//初始化供应商评分map集合
Map<Integer, Integer> vendorScoreMap = vendorMarkReportList.stream().collect(Collectors.toMap(
VendorMarkReport::getSupplier,
v -> -1
));
//供应商都进行了报价取出每个供应商的物料报价组成新的list
List<List<QuotaData>> sourceList = new ArrayList<>();
if(vendorQuotaMap.size() == vendorMarkReportList.size()){
Set<Map.Entry<Integer, List<QuotaData>>> entries = vendorQuotaMap.entrySet();
for (Map.Entry<Integer, List<QuotaData>> entry : entries) {
sourceList.add(entry.getValue());
}
}
//求出每个供应商都报价的物料(求交集)
List<QuotaData> retainQuotaList = VendorUtil.retainElementList(sourceList);
if(!retainQuotaList.isEmpty()){
//统计报价总和
Map<Integer, Double> quotaScoreMap = vendorQuotaMap.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
v -> v.getValue().stream().filter(retainQuotaList::contains).mapToDouble(QuotaData::getQuotaValue).sum())
);
//统计报价最小值
Optional<Map.Entry<Integer, Double>> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);
} }
} }
} }

View File

@ -1,7 +1,9 @@
package weaver.bokang.xiao.xhny_report.service.chain; package weaver.bokang.xiao.xhny_report.service.chain;
import org.apache.commons.lang3.StringUtils; 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.*; import java.util.*;
@ -18,13 +20,13 @@ public class OrderRequirementChain extends AbstractScoreChain{
private final Map<Integer,Integer> mappingConfig = new HashMap<>(); private final Map<Integer,Integer> mappingConfig = new HashMap<>();
{ {
mappingConfig.put(0,0); mappingConfig.put(0,38);
mappingConfig.put(1,0); mappingConfig.put(1,33);
} }
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 //具体评分逻辑
logger.info(" OrderRequirementChain deal 起订要求评分处理 "); logger.info(" OrderRequirementChain deal 起订要求评分处理 ");
Map<Integer, CompanyEntity> companyMap = vendorStore.getCompanyMap(); Map<Integer, CompanyEntity> companyMap = vendorStore.getCompanyMap();
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
@ -32,20 +34,12 @@ public class OrderRequirementChain extends AbstractScoreChain{
CompanyEntity companyEntity = companyMap.get(supplier); CompanyEntity companyEntity = companyMap.get(supplier);
int configEntityId = StringUtils.isNotBlank(companyEntity.getOrderRequire()) ? 0 : 1; int configEntityId = StringUtils.isNotBlank(companyEntity.getOrderRequire()) ? 0 : 1;
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(configEntityId)); ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(configEntityId));
double score = 0.00; if(Objects.isNull(configEntity)){
if(Objects.nonNull(configEntity)){ logger.error("OrderRequirementChain 起订要求评分配置为设置 "+companyEntity);
score = configEntity.getScore();
} }
List<VendorMarkReportDt> vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); double score = VendorUtil.getScoreByConfig(configEntity);
vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; logger.info(String.format("起订要求评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
vendorMarkReportDtList.add( VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"起订要求评分");
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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {

View File

@ -1,23 +1,55 @@
package weaver.bokang.xiao.xhny_report.service.chain; package weaver.bokang.xiao.xhny_report.service.chain;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* @ClassName QuotationCompleteChain * @ClassName QuotationCompleteChain
* @Author * @Author
* @Date 2023/3/17 15:41 * @Date 2023/3/17 15:41
* @Description <h1></h1> * @Description <h1></h1>
**/ **/
public class QuotationCompleteChain extends AbstractScoreChain { public class QuotationCompleteChain extends AbstractScoreChain {
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 logger.info(" QuotationCompleteChain deal 报价完整性评分 ");
//具体评分逻辑
List<QuotaData> quotaDataList = sourceTrackingData.getQuotaDataList();
//按供应商将报价信息分组
Map<Integer, List<QuotaData>> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);

View File

@ -1,10 +1,15 @@
package weaver.bokang.xiao.xhny_report.service.chain; package weaver.bokang.xiao.xhny_report.service.chain;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.math.BigDecimal;
import java.util.Objects; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @ClassName QuotationNumberChain * @ClassName QuotationNumberChain
@ -16,8 +21,72 @@ public class QuotationNumberChain extends AbstractScoreChain{
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 logger.info(" QuotationNumberChain deal 报价数评分 ");
//具体评分逻辑
List<QuotaData> quotaDataList = sourceTrackingData.getQuotaDataList();
//按供应商将报价信息分组
Map<Integer, List<QuotaData>> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
//初始化供应商评分map集合
Map<Integer, Integer> vendorScoreMap = vendorMarkReportList.stream().collect(Collectors.toMap(
VendorMarkReport::getSupplier,
v -> -1
));
//供应商都进行了报价取出每个供应商的物料报价组成新的list
List<List<QuotaData>> sourceList = new ArrayList<>();
if(vendorQuotaMap.size() == vendorMarkReportList.size()){
Set<Map.Entry<Integer, List<QuotaData>>> entries = vendorQuotaMap.entrySet();
for (Map.Entry<Integer, List<QuotaData>> entry : entries) {
sourceList.add(entry.getValue());
}
}
//求出每个供应商都报价的物料(求交集)
List<QuotaData> retainQuotaList = VendorUtil.retainElementList(sourceList);
if(!retainQuotaList.isEmpty()) {
//过滤出交集部分的物料报价
Map<Integer, List<QuotaData>> materialQuotaMap = quotaDataList.stream()
.filter(retainQuotaList::contains)
.collect(Collectors.groupingBy(QuotaData::getMaterialId));
//统计每个物料报价的最低值
Map<Integer, Double> materialMinMap = materialQuotaMap.entrySet().stream().collect(Collectors.toMap(
Map.Entry::getKey,
v -> v.getValue().stream()
.min(Comparator.comparing(QuotaData::getQuotaValue))
.get().getQuotaValue()
));
//统计每个供应商报价最低物料数量
Map<Integer, Integer> 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<Integer, Integer> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);

View File

@ -1,10 +1,15 @@
package weaver.bokang.xiao.xhny_report.service.chain; package weaver.bokang.xiao.xhny_report.service.chain;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* @ClassName QuotationTimeChain * @ClassName QuotationTimeChain
@ -16,8 +21,20 @@ public class QuotationTimeChain extends AbstractScoreChain{
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 logger.info(" QuotationTimeChain deal 报价及时率评分 ");
//具体评分逻辑
List<QuotaData> quotaDataList = sourceTrackingData.getQuotaDataList();
//按供应商将报价信息分组
Map<Integer, List<QuotaData>> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);

View File

@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain; 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.*; import java.util.*;
@ -30,20 +32,14 @@ public class ReturnAndExchangeChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier(); Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier); CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getReturnAndExchange())); ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getReturnAndExchange()));
double score = 0.00; double score = 0.0;
if(Objects.nonNull(configEntity)){ if(Objects.nonNull(configEntity)){
score = configEntity.getScore(); score = VendorUtil.getScoreByConfig(configEntity);
}else {
configEntity = this.configEntityMap.get(mappingConfig.get(0));
} }
List<VendorMarkReportDt> vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); logger.info(String.format("退换货评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"退换货评分");
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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {

View File

@ -1,6 +1,8 @@
package weaver.bokang.xiao.xhny_report.service.chain; 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.*; import java.util.*;
@ -29,20 +31,14 @@ public class SortingServiceChain extends AbstractScoreChain{
Integer supplier = vendorMarkReport.getSupplier(); Integer supplier = vendorMarkReport.getSupplier();
CompanyEntity companyEntity = companyMap.get(supplier); CompanyEntity companyEntity = companyMap.get(supplier);
ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getSortingService())); ConfigEntity configEntity = this.configEntityMap.get(mappingConfig.get(companyEntity.getSortingService()));
double score = 0.00; double score = 0.0;
if(Objects.nonNull(configEntity)){ if(Objects.nonNull(configEntity)){
score = configEntity.getScore(); score = VendorUtil.getScoreByConfig(configEntity);
}else {
configEntity = this.configEntityMap.get(mappingConfig.get(0));
} }
List<VendorMarkReportDt> vendorMarkReportDtList = vendorMarkReport.getVendorMarkReportDtList(); logger.info(String.format("分拣服务评分: 供应商==>[%s],评分==>[%s]",vendorMarkReport.getSupplierCode(),score));
vendorMarkReportDtList = Objects.isNull(vendorMarkReportDtList) ? new ArrayList<>() : vendorMarkReportDtList; VendorUtil.makeReportData(vendorMarkReport,configEntity,score,"分拣服务评分");
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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {

View File

@ -1,10 +1,15 @@
package weaver.bokang.xiao.xhny_report.service.chain; package weaver.bokang.xiao.xhny_report.service.chain;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.math.BigDecimal;
import java.util.Objects; import java.util.*;
import java.util.stream.Collectors;
/** /**
* @ClassName TopThirtyChain * @ClassName TopThirtyChain
@ -16,8 +21,77 @@ public class TopThirtyChain extends AbstractScoreChain{
@Override @Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) { public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//TODO 具体评分逻辑 logger.info(" TopThirtyChain deal top30评分 ");
//具体评分逻辑
List<QuotaData> quotaDataList = sourceTrackingData.getQuotaDataList();
//按供应商将报价信息分组
Map<Integer, List<QuotaData>> vendorQuotaMap = quotaDataList.stream().collect(Collectors.groupingBy(QuotaData::getVendorId));
//初始化供应商评分map集合
Map<Integer, Integer> vendorScoreMap = vendorMarkReportList.stream().collect(Collectors.toMap(
VendorMarkReport::getSupplier,
v -> -1
));
//供应商都进行了报价取出每个供应商的物料报价组成新的list
List<List<QuotaData>> sourceList = new ArrayList<>();
if(vendorQuotaMap.size() == vendorMarkReportList.size()){
Set<Map.Entry<Integer, List<QuotaData>>> entries = vendorQuotaMap.entrySet();
for (Map.Entry<Integer, List<QuotaData>> entry : entries) {
sourceList.add(entry.getValue());
}
}
//求出每个供应商都报价的物料(求交集)
List<QuotaData> retainQuotaList = VendorUtil.retainElementList(sourceList);
if(!retainQuotaList.isEmpty()){
//过滤top30的物料信息
Map<String, Double> topThirtyMaterial = this.vendorStore.getTopThirtyMaterial();
Map<Integer, String> mappingMaterial = sourceTrackingData.getSourceMaterialList().stream().collect(Collectors.toMap(MaterialEntity::getMaterialId, MaterialEntity::getMaterialCode));
List<QuotaData> 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<Integer, Double> quotaScoreMap = vendorQuotaMap.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
v -> v.getValue().stream().filter(collect::contains).mapToDouble(QuotaData::getQuotaValue).sum())
);
//统计报价最小值
Optional<Map.Entry<Integer, Double>> 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)) { if(Objects.nonNull(this.nextAbstractScoreChain)) {
this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData); this.nextAbstractScoreChain.handle(vendorMarkReportList, sourceTrackingData);

View File

@ -1,11 +1,17 @@
package weaver.bokang.xiao.xhny_report.service.store; package weaver.bokang.xiao.xhny_report.service.store;
import aiyh.utils.Util; import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import lombok.Getter; import lombok.Getter;
import org.apache.log4j.Logger; 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.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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -27,25 +33,63 @@ public class VendorStore {
private Map<Integer,CompanyEntity> companyMap = new HashMap<>(); private Map<Integer,CompanyEntity> companyMap = new HashMap<>();
/** 数据源名称 */
private String dataSource;
private static final Logger logger = Util.getLogger(); private static final Logger logger = Util.getLogger();
private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class); private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class);
private final Map<String,Double> topThirtyMaterial = new HashMap<>();
private VendorStore(){ private VendorStore(){
//this.init(); //this.init();
} }
public void init(){ public void init(String dataSource){
try{ try{
this.dataSource = dataSource;
this.companyEntityList = VENDOR_MAPPER.queryCompanyList(); this.companyEntityList = VENDOR_MAPPER.queryCompanyList();
if(Objects.nonNull(companyEntityList) && !companyEntityList.isEmpty()){ if(Objects.nonNull(companyEntityList) && !companyEntityList.isEmpty()){
companyMap = companyEntityList.stream().collect(Collectors.toMap(CompanyEntity::getId, item -> item)); 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){ }catch (Exception exception){
logger.error("VendorStore 初始化异常 ==>"+Util.getErrString(exception)); logger.error("VendorStore 初始化异常 ==>"+Util.getErrString(exception));
} }
} }
/**
* <h2>top30</h2>
*/
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(){ public static VendorStore getInstance(){
return VendorStoreHolder.VENDOR_STORE; return VendorStoreHolder.VENDOR_STORE;
} }

View File

@ -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 <h1></h1>
**/
public class VendorUtil {
/**
* <h2></h2>
* @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;
}
/**
* <h2></h2>
* @param vendorMarkReport
* @param configEntity
* @param score
* @param desc
*/
public static void makeReportData(VendorMarkReport vendorMarkReport, ConfigEntity configEntity, double score,String desc){
List<VendorMarkReportDt> 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);
}
/**
* <h2></h2>
* @param elementLists
* @return
*/
public static <T> List<T> retainElementList(List<List<T>> elementLists) {
Optional<List<T>> result = elementLists.parallelStream()
.filter(elementList -> elementList != null && elementList.size() != 0)
.reduce((a, b) -> {
a.retainAll(b);
return a;
});
return result.orElse(new ArrayList<>());
}
}

View File

@ -19,8 +19,11 @@ import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test; import org.junit.Test;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; 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.chain.AbstractScoreChain;
import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern; import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetDataSource;
import weaver.general.StaticObj; import weaver.general.StaticObj;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.interfaces.datasource.DataSource; import weaver.interfaces.datasource.DataSource;
@ -30,11 +33,9 @@ import weaver.xiao.commons.utils.DocImageFileUtil;
import java.io.*; import java.io.*;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.sql.CallableStatement; import java.sql.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*; import java.util.*;
import java.util.Date;
/** /**
* @ClassName NormalTest * @ClassName NormalTest
@ -46,10 +47,15 @@ public class NormalTest extends BaseTest {
@Test @Test
public void testWord(){ public void testWord(){
String s = "{uf_jxshttz:jxsqszt=1&qsfs=0:cjrq},{uf_htzzzs:dqjd=24&htlb is not null&yylx=0:sqrq}"; GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class);
ReviewServiceImpl reviewService = new ReviewServiceImpl(); }
Map<String, Map<String, String>> modelTableSql = reviewService.getModelTableSql(s);
System.out.println(modelTableSql); @Test
public void testChain(){
GenerateReportSchedule generateReportSchedule = new GenerateReportSchedule();
generateReportSchedule.setReportModelId("-2915");
generateReportSchedule.setDataSource("NCC");
generateReportSchedule.runCode();
} }
@Test @Test
@ -69,19 +75,31 @@ public class NormalTest extends BaseTest {
@Test @Test
public void testDataSource(){ public void testDataSource(){
DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.a"),DataSource.class); DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class);
Connection conn = null ; Connection conn = null ;
CallableStatement callableStatement = null; // CallableStatement对象 CallableStatement callableStatement = null; // CallableStatement对象
ResultSet resultSet = null; // 结果集对象 ResultSet resultSet = null; // 结果集对象
try{ try{
conn = ds.getConnection(); 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(); resultSet = callableStatement.executeQuery();
if(resultSet.next()){ if(resultSet.next()){
System.out.println(resultSet.getString("nassistnum"));
} }
} catch (SQLException e) { } catch (Exception e) {
throw new RuntimeException(e); log.error("远程调用存储过程失败 ==>"+Util.getErrString(e));
} }
} }
@ -94,7 +112,7 @@ public class NormalTest extends BaseTest {
param.put("workflowIds","0"); param.put("workflowIds","0");
//String s1 = reviewMapper.queryCreateTopDate(param, 1); //String s1 = reviewMapper.queryCreateTopDate(param, 1);
//System.out.println(s1); //System.out.println(s1);
RecordSet recordSet = new RecordSet();
} }
@Test @Test
@ -115,6 +133,8 @@ public class NormalTest extends BaseTest {
AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain(); AbstractScoreChain scoreChain = ScoreChainPattern.getScoreChain();
scoreChain.handle(new ArrayList<>(),new SourceTrackingData()); scoreChain.handle(new ArrayList<>(),new SourceTrackingData());
System.out.println(scoreChain); System.out.println(scoreChain);
Logger logger = Util.getLogger();
//logger.info("message sendData ==>"+);
} }
@Test @Test