Explorar el Código

优化模型新增。优化成本计算功能。

bgy hace 1 año
padre
commit
734414f3ba

+ 54
- 8
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/controller/AppSceneCostModelController.java Ver fichero

5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.zzsmart.qomo.dao.entity.FlowDefinition;
7
 import com.zzsmart.qomo.dao.entity.FlowDefinition;
8
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostCount;
9
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostModel;
10
+import com.zzsmart.qomo.kn.cost.manage.enums.CostModelStatusEnum;
11
+import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostCountMapper;
12
+import com.zzsmart.qomo.kn.cost.manage.mapper.AppSceneCostModelMapper;
8
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostModelService;
13
 import com.zzsmart.qomo.kn.cost.manage.service.IAppSceneCostModelService;
14
+import com.zzsmart.qomo.kn.cost.manage.vo.CostModelDefinitionVO;
9
 import com.zzsmart.qomo.service.IDataFlowDefinitionService;
15
 import com.zzsmart.qomo.service.IDataFlowDefinitionService;
10
 import io.swagger.annotations.Api;
16
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.ApiOperation;
17
 import io.swagger.annotations.ApiOperation;
12
 import lombok.extern.slf4j.Slf4j;
18
 import lombok.extern.slf4j.Slf4j;
13
-import org.apache.shiro.authz.annotation.RequiresPermissions;
14
 import org.jeecg.common.api.vo.Result;
19
 import org.jeecg.common.api.vo.Result;
15
 import org.jeecg.common.aspect.annotation.AutoLog;
20
 import org.jeecg.common.aspect.annotation.AutoLog;
16
 import org.jeecg.common.system.query.QueryGenerator;
21
 import org.jeecg.common.system.query.QueryGenerator;
20
 import javax.servlet.http.HttpServletRequest;
25
 import javax.servlet.http.HttpServletRequest;
21
 import java.util.Date;
26
 import java.util.Date;
22
 import java.util.List;
27
 import java.util.List;
28
+import java.util.Random;
23
 
29
 
24
 /**
30
 /**
25
  * @Description: app_scene_cost_model
31
  * @Description: app_scene_cost_model
36
     private IAppSceneCostModelService appSceneCostModelService;
42
     private IAppSceneCostModelService appSceneCostModelService;
37
     @Autowired
43
     @Autowired
38
     private IDataFlowDefinitionService flowDefinitionService;
44
     private IDataFlowDefinitionService flowDefinitionService;
39
-
45
+    @Autowired
46
+    private AppSceneCostCountMapper appSceneCostCountMapper;
47
+    @Autowired
48
+    private AppSceneCostModelMapper costModelMapper;
40
     /**
49
     /**
41
      * 标准成本模型分页列表查询
50
      * 标准成本模型分页列表查询
42
      *
51
      *
71
     /**
80
     /**
72
      * 添加标准成本模型
81
      * 添加标准成本模型
73
      *
82
      *
74
-     * @param flowDefinition
83
+     * @param modelDefinitionVO
75
      * @return
84
      * @return
76
      */
85
      */
77
     @AutoLog(value = "app_scene_cost_model-添加")
86
     @AutoLog(value = "app_scene_cost_model-添加")
78
     @ApiOperation(value = "app_scene_cost_model-添加", notes = "app_scene_cost_model-添加")
87
     @ApiOperation(value = "app_scene_cost_model-添加", notes = "app_scene_cost_model-添加")
79
     @PostMapping(value = "/add")
88
     @PostMapping(value = "/add")
80
-    public Result<FlowDefinition> add(@RequestBody FlowDefinition flowDefinition) {
81
-        flowDefinition.setCreateTime(new Date());
82
-        flowDefinition.setUpdateTime(new Date());
83
-        FlowDefinition definition = flowDefinitionService.add(flowDefinition);
84
-        return Result.OK(definition);
89
+    public Result<FlowDefinition> add(@RequestBody CostModelDefinitionVO modelDefinitionVO) {
90
+        try {
91
+            FlowDefinition flowDefinition = new FlowDefinition();
92
+            //TODO 新增平台层模型定义记录
93
+            String flowCode = "FLOW_" + System.currentTimeMillis() + new Random(10000).nextInt();
94
+            flowDefinition.setUpdateTime(new Date());
95
+            flowDefinition.setCreateTime(new Date());
96
+            flowDefinition.setCode(flowCode);
97
+            flowDefinition.setProjectId(modelDefinitionVO.getProjectId());
98
+            flowDefinition.setUserId("1744546658109349889");
99
+            flowDefinition.setUserName("系统管理员");
100
+            flowDefinition.setTenantId(-1);
101
+            flowDefinition.setEnvironmentId(1);
102
+            flowDefinition.setName(modelDefinitionVO.getModelName());
103
+            FlowDefinition definition = flowDefinitionService.add(flowDefinition);
104
+            AppSceneCostModel forecastModel = new AppSceneCostModel();
105
+            forecastModel.setModelType(modelDefinitionVO.getModelType());
106
+            forecastModel.setModelName(modelDefinitionVO.getModelName());
107
+            forecastModel.setStatus(CostModelStatusEnum.Draft.getCode());
108
+            //2.新模型记录
109
+            forecastModel.setFlowDefinitionId(definition.getId());
110
+            forecastModel.setUpdateTime(new Date());
111
+            forecastModel.setCreateTime(new Date());
112
+            costModelMapper.insert(forecastModel);
113
+
114
+        } catch (Exception e) {
115
+            return Result.error("新增失败");
116
+        }
117
+        return Result.OK("新增成功");
85
     }
118
     }
86
 
119
 
87
     /**
120
     /**
108
     @ApiOperation(value = "app_scene_cost_model-通过id删除", notes = "app_scene_cost_model-通过id删除")
141
     @ApiOperation(value = "app_scene_cost_model-通过id删除", notes = "app_scene_cost_model-通过id删除")
109
     @DeleteMapping(value = "/delete")
142
     @DeleteMapping(value = "/delete")
110
     public Result<String> delete(@RequestParam(name = "id", required = true) Integer id) {
143
     public Result<String> delete(@RequestParam(name = "id", required = true) Integer id) {
144
+        //检查模型是否被引用或挂载
145
+        if (id != null) {
146
+            FlowDefinition flowDefinition = flowDefinitionService.getById(id);
147
+            if (flowDefinition != null) {
148
+                Integer id1 = flowDefinition.getId();
149
+                QueryWrapper<AppSceneCostCount> queryWrapper = new QueryWrapper<>();
150
+                queryWrapper.eq("flow_definition_id", id1);
151
+                Long aLong = appSceneCostCountMapper.selectCount(queryWrapper);
152
+                if (aLong > 0) {
153
+                    return Result.error("该模型正在被引用,无法删除!");
154
+                }
155
+            }
156
+        }
111
         flowDefinitionService.delete(id);
157
         flowDefinitionService.delete(id);
112
         return Result.OK("删除成功!");
158
         return Result.OK("删除成功!");
113
     }
159
     }

+ 58
- 45
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/entity/AppSceneCostModel.java Ver fichero

1
 package com.zzsmart.qomo.kn.cost.manage.entity;
1
 package com.zzsmart.qomo.kn.cost.manage.entity;
2
 
2
 
3
-import java.io.Serializable;
4
-import java.io.UnsupportedEncodingException;
5
-import java.util.Date;
6
-import java.math.BigDecimal;
7
 import com.baomidou.mybatisplus.annotation.IdType;
3
 import com.baomidou.mybatisplus.annotation.IdType;
8
 import com.baomidou.mybatisplus.annotation.TableId;
4
 import com.baomidou.mybatisplus.annotation.TableId;
9
 import com.baomidou.mybatisplus.annotation.TableName;
5
 import com.baomidou.mybatisplus.annotation.TableName;
10
-import com.baomidou.mybatisplus.annotation.TableLogic;
11
-import lombok.Data;
12
 import com.fasterxml.jackson.annotation.JsonFormat;
6
 import com.fasterxml.jackson.annotation.JsonFormat;
13
-import org.springframework.format.annotation.DateTimeFormat;
14
-import org.jeecgframework.poi.excel.annotation.Excel;
15
-import org.jeecg.common.aspect.annotation.Dict;
16
 import io.swagger.annotations.ApiModel;
7
 import io.swagger.annotations.ApiModel;
17
 import io.swagger.annotations.ApiModelProperty;
8
 import io.swagger.annotations.ApiModelProperty;
18
-import lombok.EqualsAndHashCode;
9
+import lombok.*;
19
 import lombok.experimental.Accessors;
10
 import lombok.experimental.Accessors;
11
+import org.jeecgframework.poi.excel.annotation.Excel;
12
+import org.springframework.format.annotation.DateTimeFormat;
13
+
14
+import java.io.Serializable;
15
+import java.util.Date;
20
 
16
 
21
 /**
17
 /**
22
  * @Description: app_scene_cost_model
18
  * @Description: app_scene_cost_model
23
  * @Author: jeecg-boot
19
  * @Author: jeecg-boot
24
- * @Date:   2024-07-29
20
+ * @Date: 2024-09-09
25
  * @Version: V1.0
21
  * @Version: V1.0
26
  */
22
  */
27
 @Data
23
 @Data
24
+@Builder
25
+@AllArgsConstructor
26
+@NoArgsConstructor
28
 @TableName("app_scene_cost_model")
27
 @TableName("app_scene_cost_model")
29
 @Accessors(chain = true)
28
 @Accessors(chain = true)
30
 @EqualsAndHashCode(callSuper = false)
29
 @EqualsAndHashCode(callSuper = false)
31
-@ApiModel(value="app_scene_cost_model对象", description="app_scene_cost_model")
30
+@ApiModel(value = "app_scene_cost_model对象", description = "app_scene_cost_model")
32
 public class AppSceneCostModel implements Serializable {
31
 public class AppSceneCostModel implements Serializable {
33
     private static final long serialVersionUID = 1L;
32
     private static final long serialVersionUID = 1L;
34
 
33
 
35
-	/**主键*/
36
-	@TableId(type = IdType.ASSIGN_ID)
34
+    /**
35
+     * 主键
36
+     */
37
+    @TableId(type = IdType.ASSIGN_ID)
37
     @ApiModelProperty(value = "主键")
38
     @ApiModelProperty(value = "主键")
38
     private Integer id;
39
     private Integer id;
39
-	/**物料编号*/
40
-	@Excel(name = "物料编号", width = 15)
41
-    @ApiModelProperty(value = "物料编号")
42
-    private String materialNo;
43
-	/**图号*/
44
-	@Excel(name = "图号", width = 15)
45
-    @ApiModelProperty(value = "图号")
46
-    private String drawingNo;
47
-	/**标准成本计算流程id*/
48
-	@Excel(name = "标准成本计算流程id", width = 15)
49
-    @ApiModelProperty(value = "标准成本计算流程id")
40
+    /**
41
+     * 模型名称
42
+     */
43
+    @Excel(name = "模型名称", width = 15)
44
+    @ApiModelProperty(value = "模型名称")
45
+    private String modelName;
46
+    /**
47
+     * 模型类型(标准成本、成本挖掘)
48
+     */
49
+    @Excel(name = "模型类型(标准成本、成本挖掘)", width = 15)
50
+    @ApiModelProperty(value = "模型类型(标准成本、成本挖掘)")
51
+    private String modelType;
52
+    /**
53
+     * 模型定义id
54
+     */
55
+    @Excel(name = "模型定义id", width = 15)
56
+    @ApiModelProperty(value = "模型定义id")
50
     private Integer flowDefinitionId;
57
     private Integer flowDefinitionId;
51
-	/**状态*/
52
-	@Excel(name = "状态", width = 15)
53
-    @ApiModelProperty(value = "状态")
54
-    private Integer status;
55
-	/**模型版本*/
56
-	@Excel(name = "模型版本", width = 15)
57
-    @ApiModelProperty(value = "模型版本")
58
-    private String modelVersion;
59
-	/**创建人*/
60
-    @ApiModelProperty(value = "创建人")
61
-    private Integer createBy;
62
-	/**创建时间*/
63
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
64
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
58
+    /**
59
+     * 状态(草稿、已发布、已作废)
60
+     */
61
+    @Excel(name = "状态(草稿、已发布、已作废)", width = 15)
62
+    @ApiModelProperty(value = "状态(草稿、已发布、已作废)")
63
+    private String status;
64
+    /**
65
+     * 创建时间
66
+     */
67
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
68
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
65
     @ApiModelProperty(value = "创建时间")
69
     @ApiModelProperty(value = "创建时间")
66
     private Date createTime;
70
     private Date createTime;
67
-	/**更新人*/
68
-    @ApiModelProperty(value = "更新人")
69
-    private Integer updateBy;
70
-	/**更新时间*/
71
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
72
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
71
+    /**
72
+     * 创建人
73
+     */
74
+    @ApiModelProperty(value = "创建人")
75
+    private String createBy;
76
+    /**
77
+     * 更新时间
78
+     */
79
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
80
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
73
     @ApiModelProperty(value = "更新时间")
81
     @ApiModelProperty(value = "更新时间")
74
     private Date updateTime;
82
     private Date updateTime;
83
+    /**
84
+     * 更新人
85
+     */
86
+    @ApiModelProperty(value = "更新人")
87
+    private String updateBy;
75
 }
88
 }

+ 65
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/enums/CostModelStatusEnum.java Ver fichero

1
+package com.zzsmart.qomo.kn.cost.manage.enums;
2
+
3
+/**
4
+ * 预测模型状态枚举
5
+ */
6
+public enum CostModelStatusEnum {
7
+    /**
8
+     * 草稿
9
+     */
10
+    Draft("Draft", "草稿"),
11
+    /**
12
+     * 已删除
13
+     */
14
+    Delete("Deleted", "已删除"),
15
+    /**
16
+     * 已发布
17
+     */
18
+    Published("Published", "已发布");
19
+
20
+    private final String code;
21
+    private final String name;
22
+
23
+    CostModelStatusEnum(String code, String name) {
24
+        this.code = code;
25
+        this.name = name;
26
+    }
27
+
28
+    public String getCode() {
29
+        return code;
30
+    }
31
+
32
+    public String getName() {
33
+        return name;
34
+    }
35
+
36
+    /**
37
+     * 根据code获取text
38
+     *
39
+     * @param codeNo
40
+     * @return
41
+     */
42
+    public static String getTextByCode(String codeNo) {
43
+        for (CostModelStatusEnum value : CostModelStatusEnum.values()) {
44
+            if (value.getCode().equals(codeNo)) {
45
+                return value.name();
46
+            }
47
+        }
48
+        return codeNo.toString();
49
+    }
50
+
51
+    /**
52
+     * 根据text获取code
53
+     *
54
+     * @param name
55
+     * @return
56
+     */
57
+    public static String getCodeByName(String name) {
58
+        for (CostModelStatusEnum value : CostModelStatusEnum.values()) {
59
+            if (value.name().equals(name)) {
60
+                return value.name();
61
+            }
62
+        }
63
+        return name;
64
+    }
65
+}

+ 1
- 1
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/plugin/StandardCostService.java Ver fichero

478
             //获取最上层的物料号
478
             //获取最上层的物料号
479
             String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
479
             String topMaterialCode = flowTaskInfoVO.getTopMaterialCode();
480
             //获取任务类型
480
             //获取任务类型
481
-            String taskType = parameters.getTaskType();
481
+            String taskType = parameters.getTaksType();
482
             //获取任务代码
482
             //获取任务代码
483
             String taskCode = flowTaskInfoVO.getTaskCode();
483
             String taskCode = flowTaskInfoVO.getTaskCode();
484
             //获取流程id
484
             //获取流程id

+ 45
- 0
qomo-kn-cost-manage/src/main/java/com/zzsmart/qomo/kn/cost/manage/vo/CostModelDefinitionVO.java Ver fichero

1
+package com.zzsmart.qomo.kn.cost.manage.vo;
2
+
3
+import com.zzsmart.qomo.common.enums.ReleaseState;
4
+import com.zzsmart.qomo.kn.cost.manage.entity.AppSceneCostModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.AllArgsConstructor;
7
+import lombok.Builder;
8
+import lombok.Data;
9
+import lombok.NoArgsConstructor;
10
+
11
+/**
12
+ * 模型信息封装
13
+ */
14
+@Data
15
+@Builder
16
+@AllArgsConstructor
17
+@NoArgsConstructor
18
+public class CostModelDefinitionVO extends AppSceneCostModel {
19
+    @ApiModelProperty("encoding")
20
+    private String code;
21
+    @ApiModelProperty("flow definition name")
22
+    private String name;
23
+    @ApiModelProperty("flow definition version")
24
+    private Integer version;
25
+    @ApiModelProperty("flow definition release state: 0:offline,1:online")
26
+    private ReleaseState releaseState;
27
+    @ApiModelProperty("定时调度表达式")
28
+    private String scheduleCron;
29
+    @ApiModelProperty("任务调度模式(1任务队列领取模式(推荐) 2所有集群服务器均可同时运行 3只有主服务器可运行(主服务器失败时其他服务器接管) 4由调度服务器统一调度)")
30
+    private Integer scheduleMode;
31
+    @ApiModelProperty("依赖周期(分钟)")
32
+    private Integer dependencyCycle;
33
+    @ApiModelProperty("在任务队列模式下可以根据任务重要性来领取任务(10为最高)")
34
+    private Integer taskImportance;
35
+    @ApiModelProperty("运行方式(0 禁用 1手动触发 2定时自动调度 3依赖上级流程)")
36
+    private Integer runMode;
37
+    @ApiModelProperty("project id")
38
+    private Integer projectId;
39
+    @ApiModelProperty("project code")
40
+    private String projectCode;
41
+    @ApiModelProperty("环境配置ID")
42
+    private Integer environmentId;
43
+    @ApiModelProperty("租户ID")
44
+    private Integer tenantId;
45
+}