优化模型新增。优化成本计算功能。
This commit is contained in:
+54
-8
@@ -5,12 +5,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.zzsmart.qomo.dao.entity.FlowDefinition;
|
import com.zzsmart.qomo.dao.entity.FlowDefinition;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostModel;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.enums.CostModelStatusEnum;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostModelMapper;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostModelService;
|
import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostModelService;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostModelDefinitionVO;
|
||||||
import com.zzsmart.qomo.service.IDataFlowDefinitionService;
|
import com.zzsmart.qomo.service.IDataFlowDefinitionService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
@@ -20,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: app_scene_cost_model
|
* @Description: app_scene_cost_model
|
||||||
@@ -36,7 +42,10 @@ public class AppSceneCostModelController {
|
|||||||
private IAppSceneCostModelService appSceneCostModelService;
|
private IAppSceneCostModelService appSceneCostModelService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDataFlowDefinitionService flowDefinitionService;
|
private IDataFlowDefinitionService flowDefinitionService;
|
||||||
|
@Autowired
|
||||||
|
private AppSceneCostCountMapper appSceneCostCountMapper;
|
||||||
|
@Autowired
|
||||||
|
private AppSceneCostModelMapper costModelMapper;
|
||||||
/**
|
/**
|
||||||
* 标准成本模型分页列表查询
|
* 标准成本模型分页列表查询
|
||||||
*
|
*
|
||||||
@@ -71,17 +80,41 @@ public class AppSceneCostModelController {
|
|||||||
/**
|
/**
|
||||||
* 添加标准成本模型
|
* 添加标准成本模型
|
||||||
*
|
*
|
||||||
* @param flowDefinition
|
* @param modelDefinitionVO
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@AutoLog(value = "app_scene_cost_model-添加")
|
@AutoLog(value = "app_scene_cost_model-添加")
|
||||||
@ApiOperation(value = "app_scene_cost_model-添加", notes = "app_scene_cost_model-添加")
|
@ApiOperation(value = "app_scene_cost_model-添加", notes = "app_scene_cost_model-添加")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public Result<FlowDefinition> add(@RequestBody FlowDefinition flowDefinition) {
|
public Result<FlowDefinition> add(@RequestBody CostModelDefinitionVO modelDefinitionVO) {
|
||||||
flowDefinition.setCreateTime(new Date());
|
try {
|
||||||
flowDefinition.setUpdateTime(new Date());
|
FlowDefinition flowDefinition = new FlowDefinition();
|
||||||
FlowDefinition definition = flowDefinitionService.add(flowDefinition);
|
//TODO 新增平台层模型定义记录
|
||||||
return Result.OK(definition);
|
String flowCode = "FLOW_" + System.currentTimeMillis() + new Random(10000).nextInt();
|
||||||
|
flowDefinition.setUpdateTime(new Date());
|
||||||
|
flowDefinition.setCreateTime(new Date());
|
||||||
|
flowDefinition.setCode(flowCode);
|
||||||
|
flowDefinition.setProjectId(modelDefinitionVO.getProjectId());
|
||||||
|
flowDefinition.setUserId("1744546658109349889");
|
||||||
|
flowDefinition.setUserName("系统管理员");
|
||||||
|
flowDefinition.setTenantId(-1);
|
||||||
|
flowDefinition.setEnvironmentId(1);
|
||||||
|
flowDefinition.setName(modelDefinitionVO.getModelName());
|
||||||
|
FlowDefinition definition = flowDefinitionService.add(flowDefinition);
|
||||||
|
AppSceneCostModel forecastModel = new AppSceneCostModel();
|
||||||
|
forecastModel.setModelType(modelDefinitionVO.getModelType());
|
||||||
|
forecastModel.setModelName(modelDefinitionVO.getModelName());
|
||||||
|
forecastModel.setStatus(CostModelStatusEnum.Draft.getCode());
|
||||||
|
//2.新模型记录
|
||||||
|
forecastModel.setFlowDefinitionId(definition.getId());
|
||||||
|
forecastModel.setUpdateTime(new Date());
|
||||||
|
forecastModel.setCreateTime(new Date());
|
||||||
|
costModelMapper.insert(forecastModel);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Result.error("新增失败");
|
||||||
|
}
|
||||||
|
return Result.OK("新增成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,6 +141,19 @@ public class AppSceneCostModelController {
|
|||||||
@ApiOperation(value = "app_scene_cost_model-通过id删除", notes = "app_scene_cost_model-通过id删除")
|
@ApiOperation(value = "app_scene_cost_model-通过id删除", notes = "app_scene_cost_model-通过id删除")
|
||||||
@DeleteMapping(value = "/delete")
|
@DeleteMapping(value = "/delete")
|
||||||
public Result<String> delete(@RequestParam(name = "id", required = true) Integer id) {
|
public Result<String> delete(@RequestParam(name = "id", required = true) Integer id) {
|
||||||
|
//检查模型是否被引用或挂载
|
||||||
|
if (id != null) {
|
||||||
|
FlowDefinition flowDefinition = flowDefinitionService.getById(id);
|
||||||
|
if (flowDefinition != null) {
|
||||||
|
Integer id1 = flowDefinition.getId();
|
||||||
|
QueryWrapper<AppSceneCostCount> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("flow_definition_id", id1);
|
||||||
|
Long aLong = appSceneCostCountMapper.selectCount(queryWrapper);
|
||||||
|
if (aLong > 0) {
|
||||||
|
return Result.error("该模型正在被引用,无法删除!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
flowDefinitionService.delete(id);
|
flowDefinitionService.delete(id);
|
||||||
return Result.OK("删除成功!");
|
return Result.OK("删除成功!");
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-45
@@ -1,75 +1,88 @@
|
|||||||
package com.zzsmart.qomo.kn.cost.manage.entity;
|
package com.zzsmart.qomo.kn.cost.manage.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import lombok.Data;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
|
||||||
import org.jeecg.common.aspect.annotation.Dict;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.*;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: app_scene_cost_model
|
* @Description: app_scene_cost_model
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2024-07-29
|
* @Date: 2024-09-09
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
@TableName("app_scene_cost_model")
|
@TableName("app_scene_cost_model")
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ApiModel(value="app_scene_cost_model对象", description="app_scene_cost_model")
|
@ApiModel(value = "app_scene_cost_model对象", description = "app_scene_cost_model")
|
||||||
public class AppSceneCostModel implements Serializable {
|
public class AppSceneCostModel implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**主键*/
|
/**
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
@ApiModelProperty(value = "主键")
|
@ApiModelProperty(value = "主键")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
/**物料编号*/
|
/**
|
||||||
@Excel(name = "物料编号", width = 15)
|
* 模型名称
|
||||||
@ApiModelProperty(value = "物料编号")
|
*/
|
||||||
private String materialNo;
|
@Excel(name = "模型名称", width = 15)
|
||||||
/**图号*/
|
@ApiModelProperty(value = "模型名称")
|
||||||
@Excel(name = "图号", width = 15)
|
private String modelName;
|
||||||
@ApiModelProperty(value = "图号")
|
/**
|
||||||
private String drawingNo;
|
* 模型类型(标准成本、成本挖掘)
|
||||||
/**标准成本计算流程id*/
|
*/
|
||||||
@Excel(name = "标准成本计算流程id", width = 15)
|
@Excel(name = "模型类型(标准成本、成本挖掘)", width = 15)
|
||||||
@ApiModelProperty(value = "标准成本计算流程id")
|
@ApiModelProperty(value = "模型类型(标准成本、成本挖掘)")
|
||||||
|
private String modelType;
|
||||||
|
/**
|
||||||
|
* 模型定义id
|
||||||
|
*/
|
||||||
|
@Excel(name = "模型定义id", width = 15)
|
||||||
|
@ApiModelProperty(value = "模型定义id")
|
||||||
private Integer flowDefinitionId;
|
private Integer flowDefinitionId;
|
||||||
/**状态*/
|
/**
|
||||||
@Excel(name = "状态", width = 15)
|
* 状态(草稿、已发布、已作废)
|
||||||
@ApiModelProperty(value = "状态")
|
*/
|
||||||
private Integer status;
|
@Excel(name = "状态(草稿、已发布、已作废)", width = 15)
|
||||||
/**模型版本*/
|
@ApiModelProperty(value = "状态(草稿、已发布、已作废)")
|
||||||
@Excel(name = "模型版本", width = 15)
|
private String status;
|
||||||
@ApiModelProperty(value = "模型版本")
|
/**
|
||||||
private String modelVersion;
|
* 创建时间
|
||||||
/**创建人*/
|
*/
|
||||||
@ApiModelProperty(value = "创建人")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Integer createBy;
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
/**创建时间*/
|
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
/**更新人*/
|
/**
|
||||||
@ApiModelProperty(value = "更新人")
|
* 创建人
|
||||||
private Integer updateBy;
|
*/
|
||||||
/**更新时间*/
|
@ApiModelProperty(value = "创建人")
|
||||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
private String createBy;
|
||||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@ApiModelProperty(value = "更新时间")
|
@ApiModelProperty(value = "更新时间")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
private String updateBy;
|
||||||
}
|
}
|
||||||
|
|||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package com.zzsmart.qomo.kn.cost.manage.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预测模型状态枚举
|
||||||
|
*/
|
||||||
|
public enum CostModelStatusEnum {
|
||||||
|
/**
|
||||||
|
* 草稿
|
||||||
|
*/
|
||||||
|
Draft("Draft", "草稿"),
|
||||||
|
/**
|
||||||
|
* 已删除
|
||||||
|
*/
|
||||||
|
Delete("Deleted", "已删除"),
|
||||||
|
/**
|
||||||
|
* 已发布
|
||||||
|
*/
|
||||||
|
Published("Published", "已发布");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
CostModelStatusEnum(String code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据code获取text
|
||||||
|
*
|
||||||
|
* @param codeNo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getTextByCode(String codeNo) {
|
||||||
|
for (CostModelStatusEnum value : CostModelStatusEnum.values()) {
|
||||||
|
if (value.getCode().equals(codeNo)) {
|
||||||
|
return value.name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return codeNo.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据text获取code
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getCodeByName(String name) {
|
||||||
|
for (CostModelStatusEnum value : CostModelStatusEnum.values()) {
|
||||||
|
if (value.name().equals(name)) {
|
||||||
|
return value.name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -478,7 +478,7 @@ public class StandardCostService {
|
|||||||
//获取最上层的物料号
|
//获取最上层的物料号
|
||||||
String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
|
String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
|
||||||
//获取任务类型
|
//获取任务类型
|
||||||
String taskType = parameters.getTaskType();
|
String taskType = parameters.getTaksType();
|
||||||
//获取任务代码
|
//获取任务代码
|
||||||
String taskCode = flowTaskInfoVO.getTaskCode();
|
String taskCode = flowTaskInfoVO.getTaskCode();
|
||||||
//获取流程id
|
//获取流程id
|
||||||
|
|||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package com.zzsmart.qomo.kn.cost.manage.vo;
|
||||||
|
|
||||||
|
import com.zzsmart.qomo.common.enums.ReleaseState;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型信息封装
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class CostModelDefinitionVO extends AppSceneCostModel {
|
||||||
|
@ApiModelProperty("encoding")
|
||||||
|
private String code;
|
||||||
|
@ApiModelProperty("flow definition name")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("flow definition version")
|
||||||
|
private Integer version;
|
||||||
|
@ApiModelProperty("flow definition release state: 0:offline,1:online")
|
||||||
|
private ReleaseState releaseState;
|
||||||
|
@ApiModelProperty("定时调度表达式")
|
||||||
|
private String scheduleCron;
|
||||||
|
@ApiModelProperty("任务调度模式(1任务队列领取模式(推荐) 2所有集群服务器均可同时运行 3只有主服务器可运行(主服务器失败时其他服务器接管) 4由调度服务器统一调度)")
|
||||||
|
private Integer scheduleMode;
|
||||||
|
@ApiModelProperty("依赖周期(分钟)")
|
||||||
|
private Integer dependencyCycle;
|
||||||
|
@ApiModelProperty("在任务队列模式下可以根据任务重要性来领取任务(10为最高)")
|
||||||
|
private Integer taskImportance;
|
||||||
|
@ApiModelProperty("运行方式(0 禁用 1手动触发 2定时自动调度 3依赖上级流程)")
|
||||||
|
private Integer runMode;
|
||||||
|
@ApiModelProperty("project id")
|
||||||
|
private Integer projectId;
|
||||||
|
@ApiModelProperty("project code")
|
||||||
|
private String projectCode;
|
||||||
|
@ApiModelProperty("环境配置ID")
|
||||||
|
private Integer environmentId;
|
||||||
|
@ApiModelProperty("租户ID")
|
||||||
|
private Integer tenantId;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user