| | |
| | | @TableField(exist = false) |
| | | private String nodeTypeExt; |
| | | |
| | | @TableField(exist = false) |
| | | /* @TableField(exist = false) |
| | | private int imgWidth; |
| | | |
| | | @TableField(exist = false) |
| | | private int imgHeight; |
| | | private int imgHeight;*/ |
| | | @TableField(exist = false) |
| | | private String dataId; |
| | | @TableField(exist = false) |
| | |
| | | } else { |
| | | sysPictureBaseService.insert(sysPictureBase); |
| | | } |
| | | if (sysPictureBase.getIsDefault() == 1) { |
| | | if (sysPictureBase.getIsDefault() == 1 && sysPictureBase.getProductType()!=20) { |
| | | sysPictureBaseService.updateByDefault(sysPictureBase.getId(), sysPictureBase.getProductType()); |
| | | sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(), sysPictureBase.getProductType(), null); |
| | | } |
| | |
| | | @ApiModelProperty(value = "图片名称") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "图片宽度") |
| | | private Integer width; |
| | | |
| | | @ApiModelProperty(value = "图片高度") |
| | | private Integer height; |
| | | |
| | | @ApiModelProperty(value = "svg图片") |
| | | private String svgContent; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | public class SysPictureBaseService extends BaseService<SysPictureBaseDao, SysPictureBase> { |
| | | |
| | | @Autowired |
| | | private SysOssService sysOssService; |
| | | /** |
| | | * 分页查询 |
| | | * |
New file |
| | |
| | | package com.zt.life.modules.mainPart.taskReliability.controller; |
| | | |
| | | |
| | | import com.zt.common.annotation.LogOperation; |
| | | import com.zt.common.constant.Constant; |
| | | import com.zt.common.annotation.QueryParam; |
| | | import com.zt.common.db.query.QueryFilter; |
| | | import com.zt.common.servlet.Result; |
| | | import com.zt.common.servlet.PageResult; |
| | | import com.zt.common.validator.AssertUtils; |
| | | import com.zt.common.validator.ValidatorUtils; |
| | | import com.zt.common.validator.group.AddGroup; |
| | | import com.zt.common.validator.group.DefaultGroup; |
| | | import com.zt.common.validator.group.UpdateGroup; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.TaskBinoParam; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.TaskPhaseModel; |
| | | import com.zt.life.modules.mainPart.taskReliability.service.TaskBinoParamService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * task_bino_param |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-06-19 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/taskReliability/TaskBinoParam/") |
| | | @Api(tags="task_bino_param") |
| | | public class TaskBinoParamController { |
| | | @Autowired |
| | | private TaskBinoParamService taskBinoParamService; |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("分页") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = Constant.Q.PAGE, value = Constant.QV.PAGE, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.LIMIT, value = Constant.QV.LIMIT, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = "taskId", value = "任务Id", dataType = Constant.QT.STRING), |
| | | }) |
| | | public PageResult<TaskBinoParam> page(@ApiIgnore @QueryParam QueryFilter queryFilter){ |
| | | |
| | | return PageResult.ok(taskBinoParamService.page(queryFilter)); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @ApiOperation("信息") |
| | | public Result<TaskBinoParam> get(@PathVariable("id") Long id){ |
| | | TaskBinoParam data = taskBinoParamService.get(id); |
| | | |
| | | return Result.ok(data); |
| | | } |
| | | |
| | | @PostMapping("save") |
| | | public Result save(@RequestBody TaskBinoParam taskBinoParam) { |
| | | //效验数据 |
| | | for (TaskBinoParam param : taskBinoParam.getDataThreeList()) { |
| | | if (param.getId()!=null){ |
| | | taskBinoParamService.update(param); |
| | | }else{ |
| | | taskBinoParamService.insert(param); |
| | | } |
| | | } |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @PostMapping |
| | | @ApiOperation("新增") |
| | | @LogOperation("新增") |
| | | public Result insert(@RequestBody TaskBinoParam taskBinoParam){ |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(taskBinoParam, AddGroup.class, DefaultGroup.class); |
| | | taskBinoParamService.insert(taskBinoParam); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation("修改") |
| | | @LogOperation("修改") |
| | | public Result update(@RequestBody TaskBinoParam taskBinoParam){ |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(taskBinoParam, UpdateGroup.class, DefaultGroup.class); |
| | | taskBinoParamService.update(taskBinoParam); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @ApiOperation("删除") |
| | | @LogOperation("删除") |
| | | public Result delete(@RequestBody Long[] ids){ |
| | | //效验数据 |
| | | AssertUtils.isArrayEmpty(ids, "id"); |
| | | taskBinoParamService.delete(ids); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | @Mapper |
| | | public interface ModelRbdNodeDao extends BaseDao<ModelRbdNode> { |
| | | |
| | | void deteleModelRbdNode(Long modelId); |
| | | } |
New file |
| | |
| | | package com.zt.life.modules.mainPart.taskReliability.dao; |
| | | |
| | | import com.zt.common.dao.BaseDao; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.TaskBinoParam; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * task_bino_param |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-06-19 |
| | | */ |
| | | @Mapper |
| | | public interface TaskBinoParamDao extends BaseDao<TaskBinoParam> { |
| | | |
| | | List<TaskBinoParam> getList(Map<String, Object> params); |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "") |
| | | private Integer status; |
| | | |
| | | } |
| | |
| | | import com.zt.common.constant.Constant; |
| | | import com.zt.common.entity.BusiEntity; |
| | | import com.zt.common.entity.TreeNode; |
| | | import com.zt.common.entity.TreeNode2; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=false) |
| | | @TableName("operat_condit_model") |
| | | public class OperatConditModel extends BusiEntity implements TreeNode<OperatConditModel> { |
| | | public class OperatConditModel extends BusiEntity implements TreeNode2<OperatConditModel> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "工况ID") |
| | |
| | | @ApiModelProperty(value = "模型ID") |
| | | private Long modelId; |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @TableField(exist = false) |
| | | private String product; |
| | | private String productName; |
| | | |
| | | @TableField(exist = false) |
| | | private String modelName; |
| | |
| | | @TableField(exist = false) |
| | | private Long pid; |
| | | |
| | | @TableField(exist = false) |
| | | private Long iid; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "任务名称") |
| | | private String taskName; |
| | | |
| | | @ApiModelProperty(value = "任务顺序") |
| | | private Integer taskSort; |
| | | /* @ApiModelProperty(value = "任务顺序") |
| | | private Integer taskSort;*/ |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
New file |
| | |
| | | package com.zt.life.modules.mainPart.taskReliability.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zt.common.entity.BusiEntity; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * task_bino_param |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-06-19 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper=false) |
| | | @TableName("task_bino_param") |
| | | public class TaskBinoParam extends BusiEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "任务ID") |
| | | private Long taskId; |
| | | |
| | | |
| | | @ApiModelProperty(value = "阶段id") |
| | | private Long phaseId; |
| | | |
| | | @TableField(exist = false) |
| | | private String phaseName; |
| | | |
| | | @ApiModelProperty(value = "工况ID") |
| | | private Long operatConditId; |
| | | |
| | | @TableField(exist = false) |
| | | private String operatConditName; |
| | | |
| | | @TableField(exist = false) |
| | | private String productName; |
| | | |
| | | @ApiModelProperty(value = "模型Id") |
| | | private Long modelId; |
| | | |
| | | @ApiModelProperty(value = "产品节点ID") |
| | | private Long productId; |
| | | |
| | | @ApiModelProperty(value = "成功率") |
| | | private Double successRate; |
| | | |
| | | @ApiModelProperty(value = "仿真次数") |
| | | private Integer simulatTimes; |
| | | |
| | | @ApiModelProperty(value = "成功次数") |
| | | private Integer successTimes; |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @TableField(exist = false) |
| | | private List<TaskBinoParam> dataThreeList; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "阶段时长比") |
| | | private Double phaseDurationRate; |
| | | |
| | | /* |
| | | @ApiModelProperty(value = "阶段时速") |
| | | private Double phaseSpeed; |
| | | |
| | | @ApiModelProperty(value = "阶段顺序") |
| | | private Integer phaseSort; |
| | | */ |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "") |
| | | private Integer status; |
| | | |
| | | @TableField(exist = false) |
| | | private Long productId; |
| | |
| | | private String operatConditName; |
| | | |
| | | @ApiModelProperty(value = "工况运行比") |
| | | private Double operatConditDurationRate; |
| | | private String operatConditDurationRate; |
| | | |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | |
| | | |
| | | @TableField(exist = false) |
| | | private String isCheck; |
| | | |
| | | |
| | | } |
| | |
| | | public class ModelRbdNodeService extends BaseService<ModelRbdNodeDao, ModelRbdNode> { |
| | | public void saveNodeArr(ModelRbd modelRbd) { |
| | | // |
| | | baseDao.deteleModelRbdNode(modelRbd.getId()); |
| | | ModelRbdNode node = new ModelRbdNode(); |
| | | node.setProductId(modelRbd.getProductId()); |
| | | node.setModelId(modelRbd.getId()); |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.common.utils.TreeUtils; |
| | | import com.zt.common.utils.TreeUtils2; |
| | | import com.zt.life.modules.mainPart.taskReliability.dao.OperatConditModelDao; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.ModelNodes; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.ModelRbd; |
| | |
| | | public List<OperatConditModel> page(QueryFilter queryFilter) { |
| | | List<OperatConditModel> list = baseDao.getList(queryFilter.getQueryParams()); |
| | | for (OperatConditModel conditModel : list) { |
| | | List<ModelRbd> modelList = baseDao.getModelList(conditModel.getId()); |
| | | List<ModelRbd> modelList = baseDao.getModelList(conditModel.getProductId()); |
| | | conditModel.setModelList(modelList); |
| | | } |
| | | return TreeUtils.build(list); |
| | | return TreeUtils2.build(list); |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.zt.life.modules.mainPart.taskReliability.service; |
| | | |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.life.modules.mainPart.taskReliability.dao.TaskBinoParamDao; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.TaskBinoParam; |
| | | import org.springframework.stereotype.Service; |
| | | import com.zt.common.db.query.QueryFilter; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * task_bino_param |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-06-19 |
| | | */ |
| | | @Service |
| | | public class TaskBinoParamService extends BaseService<TaskBinoParamDao, TaskBinoParam> { |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param queryFilter |
| | | * @return |
| | | */ |
| | | public List<TaskBinoParam> page(QueryFilter queryFilter) { |
| | | return baseDao.getList(queryFilter.getQueryParams()); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids |
| | | */ |
| | | public void delete(Long[] ids) { |
| | | super.deleteLogic(ids); |
| | | } |
| | | |
| | | } |
| | |
| | | select a.*, |
| | | CASE |
| | | WHEN b.end =1 THEN '已完成' |
| | | WHEN c.num >0 THEN '正在编辑' |
| | | WHEN a.content is not null THEN '正在编辑' |
| | | ELSE '未编辑' END AS modelState, |
| | | d.num as quoteNum |
| | | from model_rbd a |
| | | left join (select model_id,1 as end from algorithm where model_type = 'end' and is_delete=0 ) b on b.model_id = |
| | | a.id |
| | | left join (select id, count(1) as num from model_rbd where is_delete=0 group by id ) c on c.id |
| | | = a.id |
| | | left join (select model_id,count(1) as num from operat_condit_model where is_delete=0 group by model_id ) d on |
| | | d.model_id = a.id |
| | | <where> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.zt.life.modules.mainPart.taskReliability.dao.ModelRbdNodeDao"> |
| | | <delete id="deteleModelRbdNode"> |
| | | delete |
| | | from model_rbd_node |
| | | where model_id = ${modelId} |
| | | </delete> |
| | | </mapper> |
| | |
| | | </delete> |
| | | |
| | | <select id="getList" resultType="com.zt.life.modules.mainPart.taskReliability.model.OperatConditModel"> |
| | | SELECT a.id, |
| | | a.pid, |
| | | a.`NAME` as product, |
| | | c.model_name, |
| | | SELECT b.id, |
| | | a.id as iid, |
| | | a.id as product_id, |
| | | a.pid, |
| | | a.`NAME` as productName, |
| | | c.model_name, |
| | | b.model_id, |
| | | case when b.is_disabled is null or b.is_disabled = 1 then 1 else 0 end as is_disabled, |
| | | ${operatConditId} as operatConditId |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.zt.life.modules.mainPart.taskReliability.dao.TaskBinoParamDao"> |
| | | |
| | | <select id="getList" resultType="com.zt.life.modules.mainPart.taskReliability.model.TaskBinoParam"> |
| | | select a.task_id |
| | | , a.phase_id |
| | | , a.phase_name |
| | | , a.phase_sort |
| | | , a.operat_condit_id |
| | | , a.operat_condit_name |
| | | , a.model_id |
| | | , a.product_name |
| | | , a.product_id |
| | | , case |
| | | when b.success_rate is not null then b.success_rate |
| | | else a.task_mtbcf_regul_succ_rate end as success_rate |
| | | , b.id |
| | | , b.simulat_times |
| | | , b.success_times |
| | | from ( |
| | | SELECT a.task_id |
| | | , a.id as phase_id |
| | | , a.phase_name |
| | | , a.phase_sort |
| | | , b.operat_condit_id |
| | | , c.name as operat_condit_name |
| | | , d.model_id |
| | | , f.name as product_name |
| | | , f.id as product_id |
| | | , g.task_mtbcf_regul_succ_rate |
| | | FROM `task_phase` a |
| | | , task_phase_model b |
| | | , operat_condit c |
| | | , operat_condit_model d |
| | | , model_rbd_node e |
| | | , product_model f |
| | | , param_data g |
| | | where a.task_id = ${taskId} |
| | | and a.is_delete = 0 |
| | | and b.phase_id = a.id |
| | | and b.is_delete = 0 |
| | | and c.id = b.operat_condit_id |
| | | and c.is_delete = 0 |
| | | and d.operat_condit_id = c.id |
| | | and d.is_delete = 0 |
| | | and e.model_id = d.model_id |
| | | and e.is_delete = 0 |
| | | and f.id = e.node_id |
| | | and f.is_delete = 0 |
| | | and g.product_id = f.id |
| | | and g.is_delete = 0 |
| | | and g.reliab_distrib_type = 2 |
| | | ) a |
| | | left join task_bino_param b on |
| | | b.task_id = ${taskId} |
| | | and b.phase_id = a.phase_id |
| | | and b.operat_condit_id = a.operat_condit_id |
| | | and b.model_id = a.model_id |
| | | and b.product_id = a.product_id |
| | | order by a.phase_id, a.operat_condit_id, a.product_id |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | , a.NAME as operatConditName |
| | | , a.id as operatConditId |
| | | , case |
| | | when b.id is null then 0 |
| | | else 1 end as isCheck |
| | | when b.operat_condit_duration_rate >'0' then 1 |
| | | else 0 end as isCheck |
| | | FROM operat_condit a |
| | | left join task_phase_model b |
| | | on a.id = b.operat_condit_id and b.is_delete = 0 and b.phase_id = ${phaseId} |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <!-- <zt-table-column-dict prop="repairDistribType" :keys="24" label="维修分布类型" width="140" dict="RepairDistribType"/>--> |
| | | <el-table-column prop="repairDistribType" label="维修分布类型" :key="24" width="140"> |
| | | <el-table-column prop="repairDistribType" label="维修分布类型" :key="24" width="100"> |
| | | <template v-slot="{ row }"> |
| | | <el-select v-if="row.isEdit" v-model="row.repairDistribType" |
| | | placeholder="请选择"> |
| | |
| | | <span v-else v-text="scope.row.repairMttcr"></span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="repairMttcrOtherParams" :key="26" label="MTTCR其他参数" width="180"> |
| | | <el-table-column prop="repairMttcrOtherParams" :key="26" label="MTTCR其他参数" width="120"> |
| | | <template slot-scope="scope"> |
| | | <el-input v-if="scope.row.isEdit" v-model="scope.row.repairMttcrOtherParams"></el-input> |
| | | <span v-else v-text="scope.row.repairMttcrOtherParams"></span> |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" |
| | | :highlight-current-row="isSelect" |
| | | :row-class-name="tableRowClassName" |
| | | v-adaptive="{bottomOffset:70}" |
| | | border @row-click="selectOperatCondit" @selection-change="table.selectionChangeHandle"> |
| | | <el-table-column type="selection" width="40" align="center"/> |
| | | <el-table-column prop="name" label="工况名称"/> |
| | | <el-table-column prop="remark" label="备注" |
| | | / |
| | | /> |
| | | <zt-table-column-handle :table="table" |
| | | delete-perm="taskReliability::delete"/> |
| | | </el-table> |
| | |
| | | productId: '', |
| | | }, |
| | | isSelect: false, |
| | | currentId: '' |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | console.log(this.productList, ' async getTaskProductList()') |
| | | }, |
| | | selectOperatCondit(row) { |
| | | if (this.$refs.model.isChange) { |
| | | this.$alert("有未保存的工况模型") |
| | | return; |
| | | } |
| | | this.currentId = row.id |
| | | this.$emit('selectOperatCondit', row) |
| | | let param = { |
| | | row: row, |
| | |
| | | } |
| | | this.$refs.model.init(param) |
| | | }, |
| | | tableRowClassName( |
| | | { |
| | | row, |
| | | rowIndex |
| | | }) { |
| | | if (row.id == this.currentId) { |
| | | return 'select-row'; |
| | | } else { |
| | | return 'not-select-row'; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style> |
| | | .el-table .select-row { |
| | | background: rgba(23, 179, 163, 0.2) !important; |
| | | } |
| | | </style> |
| | |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" |
| | | v-adaptive="{bottomOffset:70}" border @selection-change="table.selectionChangeHandle" |
| | | row-key="id" |
| | | row-key="iid" |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | :default-expand-all="true"> |
| | | <el-table-column prop="product" label="产品节点"/> |
| | | <el-table-column prop="productName" label="产品节点"/> |
| | | <el-table-column prop="modelId" label="产品模型"> |
| | | <template slot-scope="scope"> |
| | | <el-select v-model="scope.row.modelId" :disabled="scope.row.isDisabled == 1" placeholder="请选择" |
| | |
| | | |
| | | <script> |
| | | import RBDEditImg from './RBD-edit-img' |
| | | import cloneDeep from 'lodash/cloneDeep' |
| | | |
| | | export default { |
| | | name: 'OperaConditModel', |
| | | data() { |
| | | return { |
| | | dataForm: { |
| | | id: '', |
| | | operatConditId: '', |
| | | productId: '', |
| | | }, |
| | | mapModelNodes: {}, |
| | | modelList: [], |
| | | dialogVisible2: false, |
| | | isChange: false, |
| | | } |
| | |
| | | |
| | | } |
| | | }, |
| | | modelChanged(row){ |
| | | modelChanged(row) { |
| | | this.isChange = true |
| | | this.modelChangedProess(row) |
| | | }, |
| | |
| | | <zt-form-item label="总体任务" prop="task"> |
| | | <zt-select v-model="dataForm.task" :datas="taskList" @change="onTaskSelected"/> |
| | | </zt-form-item> |
| | | <zt-form-item label="任务时长" prop="simulatTime"> |
| | | <!-- <zt-form-item label="任务时长" prop="simulatTime"> |
| | | <el-input type="number" :min="1" v-model="dataForm.simulatTime"> |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </zt-form-item> |
| | | </zt-form-item>--> |
| | | <zt-form-item label="数据类型" prop="dataType"> |
| | | <zt-dict v-model="dataForm.dataType" dict="dataType"></zt-dict> |
| | | </zt-form-item> |
| | |
| | | } |
| | | |
| | | .mod-taskReliability-simulatAssess .el-form-item__label { |
| | | line-height: calc((100vh - 175px) / 8); |
| | | line-height: calc((100vh - 175px) / 7); |
| | | } |
| | | |
| | | .mod-taskReliability-simulatAssess .el-form-item__content { |
| | | line-height: calc((100vh - 175px) / 8); |
| | | line-height: calc((100vh - 175px) / 7); |
| | | } |
| | | |
| | | .mod-taskReliability-simulatAssess .el-form-item__content > .el-input-group--append { |
| | |
| | | <div style="margin: 10px 0"> |
| | | <zt-select v-model="dataForm.productId" placeholder="请选择产品节点" :datas="productList" @change="onProductSelected"/> |
| | | </div> |
| | | <zt-table-wraper ref="tableObj" query-url="/taskReliability/Task/page" defaultNotQuery="true" :paging='false' delete-url="/taskReliability/Task/" |
| | | <zt-table-wraper ref="tableObj" query-url="/taskReliability/Task/page" defaultNotQuery="true" :paging='false' |
| | | delete-url="/taskReliability/Task/" |
| | | v-slot="{ table }"> |
| | | <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()"> |
| | | <el-form-item> |
| | | <zt-button v-if="dataForm.productId" type="add" @click="add()" /> |
| | | <zt-button v-if="dataForm.productId" type="add" @click="add()"/> |
| | | <zt-button v-if="dataForm.productId" type="delete" @click="table.deleteHandle()"/> |
| | | <el-button v-if="dataForm.productId" type="primary" @click="openDialog()">二项分布参数</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:30}" |
| | | border |
| | | :row-class-name="tableRowClassName" |
| | | @row-click="selectTask" |
| | | @selection-change="table.selectionChangeHandle"> |
| | | <el-table-column type="selection" width="40" align="center"/> |
| | | <el-table-column prop="taskName" label="任务名称"/> |
| | | <el-table-column prop="taskName" label="任务名称" align="center"/> |
| | | <!--<el-table-column prop="taskSort" label="任务顺序" align="center"/>--> |
| | | <el-table-column prop="taskDuration" label="任务总时长" align="right"/> |
| | | <el-table-column prop="taskDuration" label="任务总时长" align="right" width="120"/> |
| | | <zt-table-column-handle :table="table" |
| | | delete-perm="taskReliability::delete"/> |
| | | </el-table> |
| | | <!-- 弹窗, 新增 / 修改 --> |
| | | <add-or-update @refreshDataList="table.query" ref="AddOrUpdate"/> |
| | | <task-bino-param ref="taskBinoParam"></task-bino-param> |
| | | </zt-table-wraper> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import AddOrUpdate from './Task-AddOrUpdate' |
| | | import TaskBinoParam from "./TaskBinoParam"; |
| | | |
| | | export default { |
| | | name: 'Task', |
| | |
| | | return { |
| | | productList: [], |
| | | dataForm: { |
| | | id:'', |
| | | id: '', |
| | | productId: '' |
| | | } |
| | | }, |
| | | currentId: '', |
| | | isChange: '' |
| | | } |
| | | }, |
| | | components: { |
| | | TaskBinoParam, |
| | | AddOrUpdate |
| | | }, |
| | | mounted() { |
| | | this.getTaskProductList() |
| | | }, |
| | | methods: { |
| | | init() { |
| | | |
| | | init(isChange) { |
| | | this.isChange = isChange |
| | | }, |
| | | add() { |
| | | this.$refs.AddOrUpdate.$refs.dialog.init(null,{productId: this.dataForm.productId}) |
| | | this.$refs.AddOrUpdate.$refs.dialog.init(null, {productId: this.dataForm.productId}) |
| | | }, |
| | | selectTask(row){ |
| | | this.$emit('onTaskSelected',row) |
| | | openDialog() { |
| | | if (this.dataForm.id) { |
| | | this.$refs.taskBinoParam.$refs.dialog.init(null, {taskId: this.dataForm.id}) |
| | | } else { |
| | | this.$alert("请选择具体任务") |
| | | } |
| | | }, |
| | | selectTask(row) { |
| | | this.dataForm.id = row.id |
| | | this.$emit('onTaskSelected', row) |
| | | console.log(this.isChange, 'isChange') |
| | | if (this.isChange) { |
| | | } else { |
| | | this.currentId = row.id |
| | | } |
| | | }, |
| | | async getTaskProductList() { |
| | | let res = await this.$http.get('/basicInfo/XhProductModel/getTaskProductList') |
| | | this.productList = res.data |
| | | console.log(this.productList, ' async getTaskProductList()') |
| | | }, |
| | | onProductSelected(data){ |
| | | onProductSelected(data) { |
| | | console.log(data, ' onProductSelected(data)') |
| | | this.dataForm.productId = data.id |
| | | this.$refs.tableObj.query() |
| | | }, |
| | | tableRowClassName( |
| | | { |
| | | row, |
| | | rowIndex |
| | | }) { |
| | | if (row.id == this.currentId) { |
| | | return 'select-row'; |
| | | } else { |
| | | return 'not-select-row'; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style> |
| | | .el-table .select-row { |
| | | background: rgba(23, 179, 163, 0.2) !important; |
| | | } |
| | | </style> |
New file |
| | |
| | | <template> |
| | | <zt-dialog ref="dialog" column="1" title="二项参数" append-to-body :editAble="false" :hasConfirm="false"> |
| | | <zt-table-wraper ref="tableObj" query-url="/taskReliability/TaskBinoParam/page" delete-url="/taskReliability/TaskBinoParam" |
| | | v-slot="{ table }"> |
| | | <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()"> |
| | | <el-form-item> |
| | | <!-- <zt-button type="query" @click="table.query()"/> |
| | | <zt-button type="add" perm="taskReliability:add" @click="table.editHandle()"/> |
| | | <zt-button type="delete" perm="taskReliability:delete" @click="table.deleteHandle()"/>--> |
| | | <zt-button type="primary" @click="handleSaveRows">保存</zt-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="300" |
| | | border @selection-change="table.selectionChangeHandle" @cell-click="handleCellClick"> |
| | | <!-- <el-table-column type="selection" width="40"/>--> |
| | | <el-table-column prop="phaseName" label="阶段" align="center"/> |
| | | <el-table-column prop="operatConditName" label="工况" align="center"/> |
| | | <el-table-column prop="productName" label="二项分布设备" align="center"/> |
| | | <el-table-column prop="successRate" label="成功率" align="right"> |
| | | <template slot-scope="scope"> |
| | | <span |
| | | v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property"> |
| | | <el-input ref="editInput" |
| | | autosize v-model="scope.row.successRate" |
| | | placeholder="成功率"></el-input> |
| | | </span> |
| | | <span v-else>{{scope.row.successRate}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="simulatTimes" label="仿真次数" align="center"> |
| | | <template slot-scope="scope"> |
| | | <span |
| | | v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property"> |
| | | <el-input ref="editInput" |
| | | autosize v-model="scope.row.simulatTimes" |
| | | placeholder="仿真次数"></el-input> |
| | | </span> |
| | | <span v-else>{{scope.row.simulatTimes}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="successTimes" label="成功次数" align="center"> |
| | | <template slot-scope="scope"> |
| | | <span |
| | | v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property"> |
| | | <el-input ref="editInput" |
| | | autosize v-model="scope.row.successTimes" |
| | | placeholder="成功次数"></el-input> |
| | | </span> |
| | | <span v-else>{{scope.row.successTimes}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </zt-table-wraper> |
| | | </zt-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | import cloneDeep from "lodash/cloneDeep"; |
| | | |
| | | export default { |
| | | name: 'taskBinoParam', |
| | | data() { |
| | | return { |
| | | dataForm: { |
| | | id: '', |
| | | taskId: '', |
| | | successRate: '', |
| | | simulatTimes: '', |
| | | successTimes: '', |
| | | dataThreeList:[] |
| | | }, |
| | | editingCell: null, |
| | | dataList: [], |
| | | originalTableData: [], |
| | | originalData: null, |
| | | } |
| | | }, |
| | | components: {}, |
| | | methods: { |
| | | init(id, row) { |
| | | this.dataForm.taskId = row.taskId |
| | | }, |
| | | async handleSaveRows() { |
| | | this.dataForm.dataThreeList = this.$refs.tableObj.dataList |
| | | console.log(this.dataForm, 'this.dataForm this.dataForm') |
| | | let res = await this.$http.post('/taskReliability/TaskBinoParam/save', this.dataForm) |
| | | if (res.success) { |
| | | console.log(res.data) |
| | | await this.$tip.success() |
| | | this.originalData = null |
| | | this.dataForm.dataThreeList = null |
| | | this.$refs.tableObj.query() |
| | | this.originalTableData = JSON.parse(JSON.stringify(this.dataList)); // 更新初始数据为当前数据 |
| | | console.log(this.originalTableData, 'this.originalTableData 当前表格json数据') |
| | | } |
| | | }, |
| | | handleCellClick(row, column) { |
| | | this.editingCell = {row, column} |
| | | this.$nextTick(() => { |
| | | if (this.$refs.editInput) { |
| | | this.$refs.editInput.focus() |
| | | } |
| | | }) |
| | | console.log(this.editingCell, 'this.editingCell') |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <zt-button v-if="dataForm.taskId" type="delete" @click="table.deleteHandle()"/> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:30}" |
| | | |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:30}" border |
| | | :row-class-name="tableRowClassName" |
| | | @row-click="selectPhase" @selection-change="table.selectionChangeHandle"> |
| | | <el-table-column type="selection" width="40" align="center"/> |
| | | <el-table-column prop="phaseName" label="阶段名称" align="center"/> |
| | | <el-table-column prop="phaseDurationRate" label="阶段时长比" align="right"/> |
| | | <!-- <el-table-column prop="phaseSpeed" label="阶段时速" align="right"/>--> |
| | | <el-table-column prop="phaseDurationRate" label="阶段时长比" align="right" width="120"/> |
| | | <el-table-column prop="remark" label="备注" align="right" width="200"/> |
| | | <!-- <el-table-column prop="phaseSpeed" label="阶段时速" align="right"/>--> |
| | | <!--<el-table-column prop="phaseSort" label="阶段顺序" align="center"/>--> |
| | | <!--<el-table-column prop="operatConditDuration" label="工况时长分配" align="center"/>--> |
| | | <zt-table-column-handle :table="table" edit-perm="testReviewComment:update" |
| | | delete-perm="taskReliability::delete"> |
| | | <template v-slot="{row}"> |
| | | <zt-table-button type="primary" @click="openEditWin(row)">修改</zt-table-button> |
| | | <zt-table-button type="primary" @click="openEditWin(row)">修改</zt-table-button> |
| | | </template> |
| | | </zt-table-column-handle> |
| | | </el-table> |
| | |
| | | data() { |
| | | return { |
| | | dataForm: { |
| | | id:'', |
| | | id: '', |
| | | taskId: '', |
| | | productId: '' |
| | | }, |
| | | dataList: [], |
| | | time: null |
| | | time: null, |
| | | currentId: '', |
| | | isChange: '' |
| | | } |
| | | }, |
| | | components: { |
| | |
| | | AddOrUpdate |
| | | }, |
| | | methods: { |
| | | refreshData(){ |
| | | refreshData() { |
| | | this.$refs.tableObj.query() |
| | | this.$refs.task.$refs.tableObj.query() |
| | | }, |
| | |
| | | time: this.time |
| | | }) |
| | | }, |
| | | openEditWin(row){ |
| | | openEditWin(row) { |
| | | console.log(row) |
| | | this.$refs.AddOrUpdate.$refs.dialog.init(row.id, { |
| | | taskId: this.dataForm.taskId, |
| | |
| | | }) |
| | | }, |
| | | onTaskSelected(row) { |
| | | this.isChange = this.$refs.model.isChange |
| | | this.$refs.task.init(this.isChange) |
| | | if (this.isChange) { |
| | | this.$alert("有未保存的工况模型") |
| | | return; |
| | | } |
| | | this.dataForm.taskId = row.id |
| | | this.dataForm.productId = row.productId |
| | | this.$refs.tableObj.query() |
| | | let param = { |
| | | row: {id: 0}, |
| | | productId: 0 |
| | | } |
| | | this.$refs.model.init(param) |
| | | }, |
| | | selectPhase(row) { |
| | | if (this.$refs.model.isChange) { |
| | | this.$alert("有未保存的工况模型") |
| | | return; |
| | | } |
| | | this.currentId = row.id |
| | | this.$emit('selectPhase', row) |
| | | let param = { |
| | | row: row, |
| | |
| | | } |
| | | this.$refs.model.init(param) |
| | | }, |
| | | tableRowClassName( |
| | | { |
| | | row, |
| | | rowIndex |
| | | }) { |
| | | if (row.id == this.currentId) { |
| | | return 'select-row'; |
| | | } else { |
| | | return 'not-select-row'; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style> |
| | | .el-table .select-row { |
| | | background: rgba(23, 179, 163, 0.2) !important; |
| | | } |
| | | </style> |
| | |
| | | v-adaptive="{bottomOffset:30}" border |
| | | @cell-click="handleCellClick" |
| | | @selection-change="table.selectionChangeHandle"> |
| | | <el-table-column prop="operatConditName" label="工况名称" width="100"/> |
| | | <el-table-column prop="operatConditDurationRate" label="工况时长比" align="right" width="160"> |
| | | <el-table-column prop="operatConditName" label="工况名称" width="140" align="center"/> |
| | | <el-table-column prop="operatConditDurationRate" label="工况时长比" align="right" width="120"> |
| | | <template slot-scope="scope"> |
| | | <span |
| | | v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property"> |
| | | <el-input ref="editInput" |
| | | autosize v-model="scope.row.operatConditDurationRate" |
| | | placeholder="工况时长比"></el-input> |
| | | placeholder="工况时长比" @input="change()"></el-input> |
| | | </span> |
| | | <span v-else>{{scope.row.operatConditDurationRate}}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column align="center" label="选用"> |
| | | <template v-slot="{ row }"> |
| | | <el-checkbox true-label="1" false-label="0" v-model="row.isCheck"></el-checkbox> |
| | | <el-checkbox true-label="1" false-label="0" v-model="row.isCheck" @change="change"></el-checkbox> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import cloneDeep from 'lodash/cloneDeep' |
| | | |
| | | export default { |
| | | name: 'TaskPhaseModel', |
| | |
| | | operatConditId: '', |
| | | operatConditDurationRate: '', |
| | | dataList: [], |
| | | isCheck: '' |
| | | isCheck: '', |
| | | dataThreeList:[] |
| | | }, |
| | | lastSaveData: [], |
| | | isChange: false, |
| | | editingCell: null, |
| | | dataList: [], |
| | | originalTableData: [], |
| | |
| | | }, |
| | | //批量保存 |
| | | async handleSaveRows() { |
| | | let time = null |
| | | let operatConditDurationRate = null |
| | | let flag = true |
| | | let list = [] |
| | |
| | | for (let i = 0; i < this.dataForm.dataThreeList.length; i++) { |
| | | operatConditDurationRate = this.dataForm.dataThreeList[i].operatConditDurationRate |
| | | console.log(operatConditDurationRate) |
| | | if (this.dataForm.dataThreeList[i].operatConditDurationRate == null) |
| | | this.dataForm.dataThreeList[i].operatConditDurationRate = '0' |
| | | if (this.dataForm.dataThreeList[i].isCheck === '0') |
| | | this.dataForm.dataThreeList[i].operatConditDurationRate = '0' |
| | | if (String(operatConditDurationRate).match(reg) == null && operatConditDurationRate !== null) { |
| | | this.$alert("输入的数据格式有误") |
| | | flag = false |
| | | } |
| | | time = time + Number(this.dataForm.dataThreeList[i].operatConditDurationRate) |
| | | if (this.dataForm.dataThreeList[i].isCheck === '0' && this.dataForm.dataThreeList[i].operatConditDurationRate != null) { |
| | | this.$alert("有未勾选的工况") |
| | | flag = false |
| | | } else if (this.dataForm.dataThreeList[i].isCheck === '1' && this.dataForm.dataThreeList[i].operatConditDurationRate == null) { |
| | | // time = time + Number(this.dataForm.dataThreeList[i].operatConditDurationRate) |
| | | if (this.dataForm.dataThreeList[i].isCheck === '1' && (this.dataForm.dataThreeList[i].operatConditDurationRate == null || this.dataForm.dataThreeList[i].operatConditDurationRate == 0)) { |
| | | this.$alert("有未填写的工况时长") |
| | | flag = false |
| | | } |
| | | if (this.dataForm.dataThreeList[i].isCheck === '1') { |
| | | list.push(this.dataForm.dataThreeList[i]) |
| | | } |
| | | list.push(this.dataForm.dataThreeList[i]) |
| | | } |
| | | this.dataForm.dataThreeList = list |
| | | /*console.log(time, 'async handleSaveRows') |
| | |
| | | } |
| | | let res = await this.$http.post('/taskReliability/TaskPhaseModel/save', this.dataForm) |
| | | if (res.success) { |
| | | this.isChange = false; |
| | | this.lastSaveData = cloneDeep(list) |
| | | console.log(res.data) |
| | | await this.$tip.success() |
| | | this.originalData = null |
| | |
| | | this.dataList[i].productId = this.dataForm.productId |
| | | this.dataList[i].phaseId = this.dataForm.phaseId |
| | | } |
| | | this.lastSaveData = cloneDeep(this.$refs.tableObj.dataList) |
| | | console.log(this.lastSaveData) |
| | | }, |
| | | handleCellClick(row, column) { |
| | | this.editingCell = {row, column} |
| | |
| | | } |
| | | }) |
| | | console.log(this.editingCell, 'this.editingCell') |
| | | } |
| | | , |
| | | }, |
| | | change() { |
| | | console.log(this.$refs.tableObj.dataList, "this.$refs.tableObj.dataList") |
| | | console.log(this.lastSaveData, "this.lastSaveData") |
| | | |
| | | let r = JSON.stringify(this.$refs.tableObj.dataList); |
| | | let l = JSON.stringify(this.lastSaveData); |
| | | console.log(r,'this.$refs.tableObj.dataList[i]') |
| | | console.log(l,'this.lastSaveData[i]') |
| | | if (r!==l){ |
| | | this.isChange = true |
| | | return |
| | | } |
| | | /* for (let i = 0; i < this.$refs.tableObj.dataList.length; i++) { |
| | | if (this.$refs.tableObj.dataList[i] != this.lastSaveData[i]) { |
| | | console.log(i,'no') |
| | | console.log(this.$refs.tableObj.dataList[i],'this.$refs.tableObj.dataList[i]') |
| | | console.log(this.lastSaveData[i],'this.lastSaveData[i]') |
| | | this.isChange = true |
| | | return |
| | | } |
| | | }*/ |
| | | this.isChange = false |
| | | }, |
| | | |
| | | } |
| | | } |
| | |
| | | */ |
| | | public interface TreeNode2<T> extends Serializable { |
| | | |
| | | String getId(); |
| | | Long getIid(); |
| | | |
| | | void setId(String id); |
| | | void setIid(Long iid); |
| | | |
| | | String getPid(); |
| | | Long getPid(); |
| | | |
| | | void setPid(String pid); |
| | | void setPid(Long pid); |
| | | |
| | | List<T> getChildren(); |
| | | |
| | |
| | | import com.zt.common.exception.ErrorCode; |
| | | import com.zt.common.exception.RenException; |
| | | import com.zt.common.validator.AssertUtils; |
| | | import com.zt.core.sys.model.SysDept; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | |
| | | */ |
| | | private static <T extends TreeNode2> T findChildren(List<T> treeNodes, T rootNode) { |
| | | for (T treeNode : treeNodes) { |
| | | if (rootNode.getId().equals(treeNode.getPid())) { |
| | | if (rootNode.getIid().equals(treeNode.getPid())) { |
| | | rootNode.getChildren().add(findChildren(treeNodes, treeNode)); |
| | | } |
| | | } |
| | |
| | | List<T> result = new ArrayList<>(); |
| | | |
| | | // list转map |
| | | Map<String, T> nodeMap = new LinkedHashMap<>(treeNodes.size()); |
| | | Map<Long, T> nodeMap = new LinkedHashMap<>(treeNodes.size()); |
| | | for (T treeNode : treeNodes) { |
| | | nodeMap.put(treeNode.getId(), treeNode); |
| | | nodeMap.put(treeNode.getIid(), treeNode); |
| | | } |
| | | |
| | | for (T node : nodeMap.values()) { |
| | | T parent = nodeMap.get(node.getPid()); |
| | | if (parent != null && !(node.getId().equals(parent.getId()))) { |
| | | if (parent != null && !(node.getIid().equals(parent.getIid()))) { |
| | | parent.getChildren().add(node); |
| | | continue; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | public static <T extends TreeNode2> List<T> getAncestor(List<T> allNodes, Long id) { |
| | | Map<String, T> map = allNodes.stream().collect(Collectors.toMap(dept -> dept.getId(), dept -> dept)); |
| | | Map<Long, T> map = allNodes.stream().collect(Collectors.toMap(item -> item.getIid(), item -> item)); |
| | | List<T> list = new ArrayList<>(); |
| | | TreeNode2 node = map.get(id); |
| | | if (node != null) { |
| | |
| | | } |
| | | |
| | | public static <T extends TreeNode2> T getTreeRoot(List<T> allNodes, Long id, Long rootParentId) { |
| | | Map<String, T> map = allNodes.stream().collect(Collectors.toMap(type -> type.getId(), type -> type)); |
| | | Map<Long, T> map = allNodes.stream().collect(Collectors.toMap(type -> type.getIid(), type -> type)); |
| | | T parent = map.get(id); |
| | | while (parent != null) { |
| | | if (rootParentId.equals(parent.getPid())) { |
| | |
| | | if (id == 0) { |
| | | list.addAll(allNodes); |
| | | } else { |
| | | if (allNodes.stream().filter(n -> n.getId().equals(id)).count() > 0) { |
| | | T node = allNodes.stream().filter(n -> n.getId().equals(id)).findFirst().get(); |
| | | if (allNodes.stream().filter(n -> n.getIid().equals(id)).count() > 0) { |
| | | T node = allNodes.stream().filter(n -> n.getIid().equals(id)).findFirst().get(); |
| | | list.add(node); |
| | | queryChildrenDepartmentRecursion((List<TreeNode2>) list, (List<TreeNode2>) allNodes, node.getId()); |
| | | queryChildrenDepartmentRecursion((List<TreeNode2>) list, (List<TreeNode2>) allNodes, node.getIid()); |
| | | } |
| | | } |
| | | return list; |
| | |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public static <T extends TreeNode2> List<T> getDescendant(List<T> allNodes, String id) { |
| | | public static <T extends TreeNode2> List<T> getDescendant(List<T> allNodes, Long id) { |
| | | List<T> list = new ArrayList<>(); |
| | | queryChildrenDepartmentRecursion((List<TreeNode2>) list, (List<TreeNode2>) allNodes, id); |
| | | return list; |
| | |
| | | /** |
| | | * 递归查询子节点 |
| | | */ |
| | | private static void queryChildrenDepartmentRecursion(List<TreeNode2> list, List<TreeNode2> allNodes, String id) { |
| | | private static void queryChildrenDepartmentRecursion(List<TreeNode2> list, List<TreeNode2> allNodes, Long id) { |
| | | for (TreeNode2 node : allNodes.stream().filter(n -> n.getPid().equals(id)).collect(Collectors.toList())) { |
| | | list.add(node); |
| | | queryChildrenDepartmentRecursion(list, allNodes, node.getId()); |
| | | queryChildrenDepartmentRecursion(list, allNodes, node.getIid()); |
| | | } |
| | | } |
| | | |
| | |
| | | throw new RenException("查询信息失败"); |
| | | } |
| | | // 上级菜单不能为自身 |
| | | if (node.getId().equals(node.getPid())) { |
| | | if (node.getIid().equals(node.getPid())) { |
| | | throw new RenException(ErrorCode.SUPERIOR_MENU_ERROR); |
| | | } |
| | | // 上级不能为下级 |
| | | if (!dbNode.getPid().equals(node.getPid())) {// 层级改变了 |
| | | if (node.getId().equals(node.getPid())) { |
| | | if (node.getIid().equals(node.getPid())) { |
| | | throw new RenException("上级不能设置为其本身!"); |
| | | } |
| | | |
| | | List<T> list = TreeUtils2.getDescendant(allNodes, node.getId()); |
| | | List<T> list = TreeUtils2.getDescendant(allNodes, node.getIid()); |
| | | for (T d : list) { |
| | | if (d.getId().equals(node.getPid())) { |
| | | if (d.getIid().equals(node.getPid())) { |
| | | throw new RenException("上级不能设置为其下级!"); |
| | | } |
| | | } |