Merge remote-tracking branch 'upstream/test' into test

yun-zuoyi
castle.zang 3 years ago
commit 8fc894b413

@ -69,6 +69,7 @@ public class CommonEnumUtil {
APS_3(38, 18400, 26, 190000000L, "i3aps-3", "高级计划与排产-3"),
APS_4(48, 8400, 27, 200000000L, "i3aps-4", "高级计划与排产-4"),
SURFACE(98, 0, 0, 0, "i3surface", "对外服务"),
EAM(108, 8500, 28, 210000000L, "eam", "设备信息管理服务"),
/**
*

@ -2070,7 +2070,7 @@ public class MesEnumUtil {
MES_REPAIR(320, "repairExcelService", "质量数据处理措施,支持编辑"),
MES_EQU_TASK_PLAN(330, "equTaskPlanExcelService", "设备作业周期计划,支持编辑"),
MES_PART_OJBECT(340, "partObjectExcelService", "物料对象"),
MES_PART_EXT_OJBECT(341, "PartObjectExtExcelService", "物料对象Ext"),
MES_PART_EXT_OJBECT(341, "partObjectExtExcelService", "物料对象Ext"),
MES_ROUTE_PROCESS_WORK_CELL(350, "routeProcessWorkCellExcelService", "工序工作单元"),
MES_DATASOURCE(360, "datasourceExcelService", "DB地址清单"),
MES_EQU_TASK_NOTIFY_CFG(370, "equTaskNotifyCfgExcelService", "设备通知配置"),

@ -7,6 +7,7 @@ import io.swagger.annotations.ApiParam;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
/**
@ -51,6 +52,17 @@ public class BsSuitCaseModel implements Serializable {
@ApiParam(value = "分页数据")
private Pager pager;
// 请求ID
@ApiParam(value = "请求ID")
private String requestId;
/**
* id
*/
@ApiParam(value = "业务id列表")
private List<String> busiIdList;
public BsSuitCaseModel() {
}

@ -12,6 +12,7 @@ import io.swagger.annotations.ApiParam;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description :
@ -116,6 +117,19 @@ public class SuitClientModel implements Serializable {
@XStreamCDATA
private Object suitResultMessage;
// 请求ID
private String requestId;
/**
* id
*/
private List<String> busiIdList;
/**
*
*/
private Boolean duplicate;
private boolean isNeedRetry = false;
public SuitClientModel() {
@ -135,6 +149,10 @@ public class SuitClientModel implements Serializable {
this.suitSslKeyResult = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
// 设置默认
this.suitResult = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
this.requestId = suitCaseModel.getRequestId();
this.busiIdList = suitCaseModel.getBusiIdList();
this.duplicate = Boolean.FALSE;
}
public SuitClientModel(Integer requestSource, Integer suitMethodId, BsSuitCaseModel suitCaseModel) {
@ -152,6 +170,11 @@ public class SuitClientModel implements Serializable {
this.suitSslKeyResult = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
// 设置默认
this.suitResult = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
this.requestId = suitCaseModel.getRequestId();
this.busiIdList = suitCaseModel.getBusiIdList();
this.duplicate = Boolean.FALSE;
}
public SuitClientModel(SuitModel suitModel, BsSuitCaseModel suitCaseModel) {
@ -170,6 +193,10 @@ public class SuitClientModel implements Serializable {
this.suitSslKeyResult = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
// 设置默认
this.suitResult = CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
this.requestId = suitModel.getRequestId();
this.busiIdList = suitModel.getBusiIdList();
this.duplicate = Boolean.FALSE;
}
}
}

@ -0,0 +1,29 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import java.util.Date;
/**
*
*/
public interface IWmsHealthIndexCron {
/**
* CRON
* @param expectDifference ()
* 60 1
* -60 1
*/
boolean verify(int expectDifference);
/**
*
* @return
*/
Date getPreviousDate();
/**
*
*/
Date getNextDate();
}

@ -0,0 +1,26 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
/**
*
* @author link
*/
public enum WmsHealthIndexCalcWay {
/**
*
*/
DATABSE("10"),
/**
*
*/
LOCALMETHOD("20"),
/**
*
*/
SCRIPT("30");
private String value;
private WmsHealthIndexCalcWay(String value){
this.value = value;
}
}

@ -0,0 +1,86 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import cn.estsh.i3plus.pojo.wms.bean.WmsHealthVariableResult;
import lombok.Getter;
import lombok.Setter;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import java.util.Set;
/**
*
*/
@Getter
@Setter
public class WmsHealthIndexEntity {
/**
* (+)
*/
private final WmsHealthIndexId id;
/**
*
*/
private String name;
/**
*
*/
private String module;
/**
*
*/
private final WmsHealthIndexFormula formula;
/**
*
*/
private WmsHealthIndexValue value;
/**
*
*/
private Boolean refresh;
public WmsHealthIndexEntity(final WmsHealthIndexId id,
final WmsHealthIndexFormula formula){
this.id = id;
this.formula = formula;
};
public static WmsHealthIndexEntity of(final String organizeCode,
final String indicatorCode,
final String calcFormula){
return new WmsHealthIndexEntity(WmsHealthIndexId.of(organizeCode,indicatorCode),
WmsHealthIndexFormula.of(organizeCode,indicatorCode));
}
public boolean isRefresh(){
return Boolean.TRUE.equals(refresh);
}
public void refresh(){
WmsHealthIndexValue value = generateWmsHealthIndexValue();
if(null != value) {
this.setValue(value);
this.setRefresh(true);
}
}
private WmsHealthIndexValue generateWmsHealthIndexValue(){
if(!formula.isEmpty()){
String result = null;
int size = formula.getResults().size();
if(size==1){
WmsHealthIndexVariableValue varValue = formula.getSingleValue();
result = String.valueOf(varValue.getDetail());
}else{
result = String.valueOf(formula.getSpelResult());
}
return new WmsHealthIndexValue(result);
}
return null;
}
}

@ -0,0 +1,131 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Getter;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import java.util.*;
/**
*
*/
@Getter
public class WmsHealthIndexFormula {
/**
*
*/
private final String organizeCode;
/**
* (#VAR202201070002/#VAR456)/(#VAR123/#VAR456)*100%
*/
private final String calcFormula;
/**
*
*/
private Set<WmsHealthIndexVariable> vars = new HashSet<>();
/**
*
*/
private Map<WmsHealthIndexVariable, WmsHealthIndexVariableValue> results =
new HashMap<>();
public WmsHealthIndexFormula(final String organizeCode,final String calcFormula){
this.calcFormula = calcFormula;
this.organizeCode = organizeCode;
checkCode();
initVars();
}
/**
*
*/
private void checkCode(){
}
/**
*
* @return
*/
private void initVars(){
Set<WmsHealthIndexVariable> vars = new HashSet<>();
final String [] varTemp = this.calcFormula.split("#");
for(String varStrItem : varTemp) {
if (!varStrItem.startsWith("VAR")||varStrItem.length()<15) {
continue;
}
String variableCode = varStrItem.substring(0, 15);
vars.add(new WmsHealthIndexVariable(organizeCode,variableCode));
}
this.vars = vars;
}
public void addResult(WmsHealthIndexVariable key, WmsHealthIndexVariableValue result){
if(null!=result) {
this.results.put(key, result);
}
}
public boolean isEmpty(){
return results.isEmpty();
}
/**
*
* @return
*/
public boolean isResultSizeSameWithVarsSize(){
return results.size() == vars.size();
}
/**
*
*/
public WmsHealthIndexVariableValue getSingleValue(){
if(!isEmpty()) {
WmsHealthIndexVariableValue variableValue = com.google.common.collect.Lists
.newArrayList(results.values()).get(0);
return variableValue;
}
return null;
}
/**
* calcFormulaSPEL
* @return
*/
public Integer getSpelResult(){
if(results.isEmpty()) {
return -1;
}
Integer calcResult = 0;
int resultSize = results.size();
StandardEvaluationContext ctx = new StandardEvaluationContext();
ExpressionParser parser = new SpelExpressionParser();
//单个变量,特殊情况特殊处理
if(resultSize == 1){
calcResult = getSingleValue().getValue();
}else{
Set<WmsHealthIndexVariable> varKeys = results.keySet();
for (WmsHealthIndexVariable varKey : varKeys) {
// 取出该变量名称对应的计算结果
WmsHealthIndexVariableValue variableValue = results.get(varKey);
Integer value = variableValue.getValue();
ctx.setVariable(varKey.getId().getVariable(), value);
}
// 存在多个变量则按照SPEL进行运算最后取值
try {
calcResult = (Integer) parser.parseExpression(calcFormula)
.getValue(ctx);
} catch (Exception e) {
calcResult = -1;
}
}
return calcResult;
}
public static WmsHealthIndexFormula of(String organizeCode,String calcFormula){
return new WmsHealthIndexFormula(organizeCode,calcFormula);
}
}

@ -0,0 +1,34 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Getter;
/**
*
*/
@Getter
public class WmsHealthIndexId{
/**
*
*/
private final String organizeCode;
/**
*
*/
private final String indicatorCode;
public WmsHealthIndexId(final String organizeCode,final String indicatorCode){
if(null==indicatorCode){
throw new IllegalArgumentException("indicatorCode can't be null");
}
if(null==organizeCode){
throw new IllegalArgumentException("organizeCode can't be null");
}
this.indicatorCode = indicatorCode;
this.organizeCode = indicatorCode;
}
public static WmsHealthIndexId of(String organizeCode,String indicatorCode){
return new WmsHealthIndexId(organizeCode,indicatorCode);
}
}

@ -0,0 +1,19 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
/**
*
* @author link
*/
@Builder
@Getter
@Setter
public class WmsHealthIndexQuery{
private Long beginTime;
private Long endTime;
private Integer pageIndex;
private Integer pageSize;
}

@ -0,0 +1,26 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Getter;
import lombok.Setter;
/**
*
* @author link
*/
@Getter
public class WmsHealthIndexValue{
/**
*
*/
private final String result;
@Setter
private Long time;
public WmsHealthIndexValue(final String result){
if(null==result){
throw new IllegalArgumentException("result can't be null");
}
this.result = result;
this.time = System.currentTimeMillis();
}
}

@ -0,0 +1,108 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Getter;
import lombok.Setter;
/**
*
*/
@Getter
public class WmsHealthIndexVariable {
/**
*
*/
private final WmsHealthIndexVariableId id;
/**
*
*/
@Setter
private String name;
/**
*
*/
@Setter
private IWmsHealthIndexCron cycleRange;
/**
*
*/
@Setter
private IWmsHealthIndexCron calcFrequency;
/**
*
*/
@Setter
private WmsHealthIndexCalcWay calcWay;
/**
*
*/
@Setter
private String applyArea;
/**
*
*/
@Setter
private String applyPartGroup;
@Setter
private String sqlStatement;
@Setter
private String className;
@Setter
private String functionName;
@Setter
private String scriptNo;
/**
*
*/
@Setter
private Object value;
/**
* CRON
*/
@Setter
private boolean refresh;
public WmsHealthIndexVariable(String organizeCode,String variable){
this(new WmsHealthIndexVariableId(organizeCode,variable));
}
public WmsHealthIndexVariable(WmsHealthIndexVariableId id){
this.id = id;
}
/**
* CRON
* @param expectDifference
* @return
*/
public boolean isNeedCalc(int expectDifference){
boolean flag = calcFrequency.verify(expectDifference);
flag |= calcFrequency.verify(-expectDifference);
return flag;
}
public boolean checked(){
return null!=value;
}
public void changeCalcFrequency(IWmsHealthIndexCron cron){
setCalcFrequency(cron);
setRefresh(true);
}
public void changeCycleRange(IWmsHealthIndexCron cron){
setCycleRange(cron);
setRefresh(true);
}
}

@ -0,0 +1,23 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Getter;
import lombok.Value;
/**
*
*/
@Getter
@Value
public class WmsHealthIndexVariableId {
/**
*
*/
private final String organizeCode;
/**
*
*/
private final String variable;
}

@ -0,0 +1,27 @@
package cn.estsh.i3plus.pojo.wms.bean.health;
import lombok.Getter;
import lombok.Value;
/**
*
*/
@Getter
@Value
public class WmsHealthIndexVariableValue {
/**
*
*/
private final Integer value;
/**
*
*/
private final Object detail;
public static WmsHealthIndexVariableValue empty(){
return new WmsHealthIndexVariableValue(-1,"");
}
}

@ -0,0 +1,45 @@
package cn.estsh.i3plus.pojo.wms.repository;
import cn.estsh.i3plus.pojo.wms.bean.health.WmsHealthIndexEntity;
import cn.estsh.i3plus.pojo.wms.bean.health.WmsHealthIndexId;
import cn.estsh.i3plus.pojo.wms.bean.health.WmsHealthIndexQuery;
import java.util.List;
import java.util.Optional;
/**
*
*/
public interface IWmsHealthIndexRepository {
/**
*
* @param id
* @return
*/
WmsHealthIndexEntity findAndInit(WmsHealthIndexId id);
/**
*
* @param id
* @return
*/
Optional<WmsHealthIndexEntity> getLastRecord(final WmsHealthIndexId id);
/**
*
* @param wmsHealthIndexEntity
* @param source
*/
void save(final WmsHealthIndexEntity wmsHealthIndexEntity,String source);
/**
*
* @param id
* @param param
* @return
*/
List<WmsHealthIndexEntity> query(final WmsHealthIndexId id,
final WmsHealthIndexQuery param);
}

@ -17,8 +17,7 @@ public interface WmsHealthQueryRecordRepository extends BaseRepository<WmsHealth
int countByOrganizeCodeAndIndicatorCodeAndQueryTimeBetween(String organizeCode,String indicatorCode, Long startTime,
Long endTime);
Optional<WmsHealthQueryRecord> findByOrganizeCodeAndIndicatorCodeOrderByQueryTimeDesc(String organizeCode,String indicatorCode);
Optional<WmsHealthQueryRecord> findFirstByOrganizeCodeAndIndicatorCodeOrderByQueryTimeDesc(String organizeCode,String indicatorCode);
}

Loading…
Cancel
Save