New file |
| | |
| | | package com.zt.life.modules.mainPart.baseReliability.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.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.baseReliability.service.ParamDataBasicService; |
| | | import com.zt.life.modules.mainPart.basicInfo.model.ParamData; |
| | | 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 java.util.List; |
| | | |
| | | |
| | | /** |
| | | * param_data_basic |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-07-11 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/baseReliability/ParamDataBasic/") |
| | | @Api(tags="param_data_basic") |
| | | public class ParamDataBasicController { |
| | | @Autowired |
| | | private ParamDataBasicService paramDataBasicService; |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("分页") |
| | | @ApiImplicitParams({ |
| | | @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 = "shipId", value = "船ID", dataType = Constant.QT.LONG), |
| | | @ApiImplicitParam(name = "isRecal", value = "是否重新计算", dataType = Constant.QT.INT), |
| | | }) |
| | | public Result<List<ParamData>> page(@ApiIgnore @QueryParam QueryFilter queryFilter){ |
| | | if ((Integer) queryFilter.getParams().get("isRecal")==1){ |
| | | Long shipId =(Long) queryFilter.getParams().get("shipId"); |
| | | paramDataBasicService.compute(shipId); |
| | | } |
| | | return Result.ok(paramDataBasicService.page(queryFilter)); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @ApiOperation("信息") |
| | | public Result<ParamData> get(@PathVariable("id") Long id){ |
| | | ParamData data = paramDataBasicService.get(id); |
| | | |
| | | return Result.ok(data); |
| | | } |
| | | |
| | | @PostMapping |
| | | @ApiOperation("新增") |
| | | @LogOperation("新增") |
| | | public Result insert(@RequestBody ParamData paramDataBasic){ |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(paramDataBasic, AddGroup.class, DefaultGroup.class); |
| | | paramDataBasicService.insert(paramDataBasic); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation("修改") |
| | | @LogOperation("修改") |
| | | public Result update(@RequestBody ParamData paramDataBasic){ |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(paramDataBasic, UpdateGroup.class, DefaultGroup.class); |
| | | paramDataBasicService.update(paramDataBasic); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @ApiOperation("删除") |
| | | @LogOperation("删除") |
| | | public Result delete(@RequestBody Long[] ids){ |
| | | //效验数据 |
| | | AssertUtils.isArrayEmpty(ids, "id"); |
| | | paramDataBasicService.delete(ids); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zt.life.modules.mainPart.baseReliability.dao; |
| | | |
| | | import com.zt.common.dao.BaseDao; |
| | | import com.zt.life.modules.mainPart.basicInfo.model.ParamData; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | | * param_data_basic |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-07-11 |
| | | */ |
| | | @Mapper |
| | | public interface ParamDataBasicDao extends BaseDao<ParamData> { |
| | | |
| | | List<ParamData> getAI(Map<String, Object> params); |
| | | |
| | | void compute(Long shipId,Integer productType); |
| | | |
| | | void compute2(Long shipId); |
| | | } |
New file |
| | |
| | | package com.zt.life.modules.mainPart.baseReliability.service; |
| | | |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.common.utils.TreeUtils; |
| | | import com.zt.common.utils.TreeUtils2; |
| | | import com.zt.life.modules.mainPart.baseReliability.dao.ParamDataBasicDao; |
| | | import com.zt.life.modules.mainPart.basicInfo.model.ParamData; |
| | | import org.springframework.stereotype.Service; |
| | | import com.zt.common.db.query.QueryFilter; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * param_data_basic |
| | | * |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-07-11 |
| | | */ |
| | | @Service |
| | | public class ParamDataBasicService extends BaseService<ParamDataBasicDao, ParamData> { |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param queryFilter |
| | | * @return |
| | | */ |
| | | public List<ParamData> page(QueryFilter queryFilter) { |
| | | List<ParamData> list = baseDao.getAI(queryFilter.getQueryParams()); |
| | | return TreeUtils.build(list); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param ids |
| | | */ |
| | | public void delete(Long[] ids) { |
| | | super.deleteLogic(ids); |
| | | } |
| | | |
| | | public void compute(Long shipId) { |
| | | baseDao.compute(shipId,4); |
| | | baseDao.compute(shipId,3); |
| | | baseDao.compute(shipId,2); |
| | | baseDao.compute2(shipId); |
| | | } |
| | | } |
| | |
| | | List<ParamData> getByShipId(Long shipId); |
| | | |
| | | void deleteByShipId(Long shipId); |
| | | |
| | | void recalculate(Long shipId); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.zt.common.entity.BusiEntity; |
| | | import com.zt.common.entity.TreeNode; |
| | | import com.zt.common.entity.TreeNode2; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @TableName("param_data") |
| | | public class ParamData extends BusiEntity { |
| | | public class ParamData extends BusiEntity implements TreeNode<ParamData> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "源ID") |
| | |
| | | @ApiModelProperty(value = "运行时间") |
| | | private Double runTime; |
| | | |
| | | private Double ai; |
| | | |
| | | @TableField(exist = false) |
| | | private Long productIdInit; |
| | | |
| | |
| | | @TableField(exist = false) |
| | | private List<ParamData> dataThreeList; |
| | | |
| | | @TableField(exist = false) |
| | | private Long pid; |
| | | |
| | | @ApiModelProperty(value = "子节点") |
| | | @TableField(exist = false) |
| | | private List<ParamData> children = new ArrayList<>(); |
| | | } |
| | |
| | | com.zt.life.util.ImportUtil.updateErrMap(errMap, "没有填写是否参加计算", sheetName, row1); |
| | | continue; |
| | | } |
| | | if (StringUtils.isEmpty(basicMtbfRegulate)) { |
| | | com.zt.life.util.ImportUtil.updateErrMap(errMap, "没有填写mtbf", sheetName, row1); |
| | | continue; |
| | | } |
| | | if (StringUtils.isEmpty(taskMtbcfRegulate)) { |
| | | com.zt.life.util.ImportUtil.updateErrMap(errMap, "没有填写mtbcf", sheetName, row1); |
| | | continue; |
| | | } |
| | | if (StringUtils.isEmpty(repairable)) { |
| | | com.zt.life.util.ImportUtil.updateErrMap(errMap, "没有填写是否可维修", sheetName, row1); |
| | | continue; |
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.baseReliability.dao.ParamDataBasicDao"> |
| | | <update id="compute"> |
| | | update param_data f, |
| | | ( |
| | | SELECT |
| | | c.*, |
| | | CASE |
| | | WHEN WeightedFailure IS NOT NULL |
| | | AND WeightedFailure > 0 THEN |
| | | 1 / WeightedFailure ELSE 0 |
| | | END AS basic_mtbf_regulate, |
| | | CASE |
| | | WHEN WeightedFailure IS NOT NULL |
| | | AND WeightedFailure > 0 THEN |
| | | WeightedMTTR / WeightedFailure ELSE 0 |
| | | END AS repair_mttcr |
| | | FROM |
| | | ( |
| | | SELECT |
| | | c.id, |
| | | c.name, |
| | | sum( |
| | | CASE |
| | | WHEN b.product_type < 5 THEN |
| | | 1 * 1 / basic_mtbf_regulate |
| | | WHEN a.reliab_distrib_type = 1 THEN |
| | | 1 * a.basic_mtbf_operating_ratio / a.basic_mtbf_regulate |
| | | WHEN a.reliab_distrib_type = 2 THEN |
| | | 1 * a.basic_mtbf_operating_ratio / a.basic_mtbf_regul_succ_rate |
| | | ELSE 0 END |
| | | ) AS WeightedFailure, |
| | | sum( |
| | | CASE |
| | | WHEN b.product_type < 5 THEN |
| | | 1 * 1 * a.repair_mttcr / a.basic_mtbf_regulate |
| | | WHEN a.repairable = 1 and a.reliab_distrib_type = 1 THEN |
| | | 1 * a.basic_mtbf_operating_ratio * a.repair_mttcr / a.basic_mtbf_regulate |
| | | WHEN a.repairable = 1 and a.reliab_distrib_type = 2 THEN |
| | | 1 * a.basic_mtbf_operating_ratio * a.repair_mttcr / a.basic_mtbf_regul_succ_rate |
| | | ELSE 0 |
| | | END |
| | | ) AS WeightedMttr |
| | | FROM |
| | | param_data a, |
| | | product_model b, |
| | | product_model c |
| | | WHERE 1 = 1 |
| | | and c.ship_id = ${shipId} and c.product_type = ${productType} and c.is_delete = 0 |
| | | and b.ship_id = ${shipId} and b.pid = c.id and b.is_delete = 0 |
| | | and a.IS_DELETE = 0 and a.product_id = b.id |
| | | AND (b.product_type =5 AND a.basic_join_compute = 1 || b.product_type < 5) |
| | | AND ((a.reliab_distrib_type =1 |
| | | AND a.basic_mtbf_regulate > 0 |
| | | ) |
| | | OR ( a.reliab_distrib_type = 2 |
| | | AND a.basic_mtbf_regul_succ_rate > 0 |
| | | )) |
| | | |
| | | GROUP BY c.id,c.name |
| | | ) c |
| | | )d set f.basic_mtbf_regulate = d.basic_mtbf_regulate, |
| | | f.repair_mttcr = d.repair_mttcr |
| | | where f.product_id = d.id; |
| | | </update> |
| | | |
| | | <update id="compute2"> |
| | | UPDATE param_data a, product_model b |
| | | SET ai = basic_mtbf_regulate / (basic_mtbf_regulate + repair_mttcr) |
| | | where b.ship_id = ${shipId} |
| | | </update> |
| | | |
| | | <select id="getAI" resultType="com.zt.life.modules.mainPart.basicInfo.model.ParamData"> |
| | | SELECT a.NAME, |
| | | a.id, |
| | | a.pid, |
| | | b.ai, |
| | | b.basic_mtbf_regulate, |
| | | b.repair_mttcr, |
| | | b.basic_mtbf_operating_ratio |
| | | FROM product_model a |
| | | LEFT JOIN param_data b ON b.product_id = a.id and b.is_delete = 0 |
| | | where a.is_delete = 0 |
| | | and a.ship_id = ${shipId} |
| | | or a.id =${shipId} |
| | | ORDER BY a.product_type, a.sort |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <!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.basicInfo.dao.ParamDataDao"> |
| | | |
| | | <delete id="deleteByShipId"> |
| | | delete from param_data where ship_id =${shipId} |
| | | delete |
| | | from param_data |
| | | where ship_id = ${shipId} |
| | | </delete> |
| | | |
| | | <select id="getList" resultType="com.zt.life.modules.mainPart.basicInfo.model.ParamData"> |
New file |
| | |
| | | <template> |
| | | <div> |
| | | <el-row :gutter="5"> |
| | | <el-col :span="5"> |
| | | <div class="fa-card-a" style="margin-right: 5px;height: calc(100vh - 123px)"> |
| | | <product-model-tree ref="modelTree" @on-selected="onProductSelected" @on-default="onDefault" showXdy="false" |
| | | basic="3"/> |
| | | </div> |
| | | </el-col> |
| | | <el-col :span="19"> |
| | | <div class="mod-baseReliability-paramDataBasic fa-card-a" style="margin-left: 5px;"> |
| | | <zt-table-wraper :defaultNotQuery='true' ref="tableObj" query-url="/baseReliability/ParamDataBasic/page" |
| | | delete-url="/baseReliability/ParamDataBasic" |
| | | v-slot="{ table }" :paging='false'> |
| | | <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="baseReliability:add" @click="table.editHandle()"/> |
| | | <zt-button type="delete" perm="baseReliability:delete" @click="table.deleteHandle()"/>--> |
| | | <zt-button type="primary" @click="recalculate()">重新计算</zt-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:70}" |
| | | row-key="id" |
| | | :expand-row-keys="defultKey" |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | border @selection-change="table.selectionChangeHandle"> |
| | | <!--<el-table-column type="selection" width="40"/>--> |
| | | <el-table-column prop="name" label="名称"/> |
| | | <el-table-column prop="basicMtbfRegulate" label="MTBF" align="right"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ scope.row.basicMtbfRegulate | keepNumber }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="repairMttcr" label="MTTR" align="right"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ scope.row.repairMttcr | keepNumber }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="basicMtbfOperatingRatio" label="运行比" align="right"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ scope.row.basicMtbfOperatingRatio | keepNumber }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="ai" label="可用度" align="right"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ scope.row.ai | keepNumber }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </zt-table-wraper> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import ProductModelTree from "../basicInfo/ProductModelTree"; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | dataForm: { |
| | | shipId: '', |
| | | isRecal: 0, |
| | | basicMtbfRegulate: '', |
| | | repairMttcr: '', |
| | | basicMtbfOperatingRatio: '', |
| | | ai: '' |
| | | }, |
| | | defultKey: [] |
| | | } |
| | | }, |
| | | components: { |
| | | ProductModelTree, |
| | | }, |
| | | filters: { |
| | | keepNumber(value) { //过滤器保留4为小数 |
| | | const numM = Number(value).toFixed(5); |
| | | if (numM === "NaN") { |
| | | return "0.0000"; |
| | | } |
| | | if (numM === '0.0000' && value > 0) { |
| | | |
| | | } |
| | | const realVal = numM.substring(0, numM.length - 1); |
| | | return realVal; |
| | | }, |
| | | }, |
| | | methods: { |
| | | onProductSelected(data) { |
| | | this.defultKey = [] |
| | | this.dataForm.shipId = data.id |
| | | this.dataForm.productType = data.productType |
| | | console.log(data, 'onProductSelected(data)') |
| | | this.$nextTick(() => { |
| | | this.$refs.tableObj.query() |
| | | this.setDefultKey() |
| | | }) |
| | | }, |
| | | setDefultKey() { |
| | | console.log(this.$refs.tableObj.dataList[0].id,'this.$refs.tableObj.dataList[0].id') |
| | | this.defultKey.push(this.dataForm.shipId + "") |
| | | }, |
| | | onDefault(defaultId) { |
| | | this.dataForm.shipId = defaultId |
| | | this.$nextTick(() => { |
| | | this.$refs.tableObj.query() |
| | | this.setDefultKey() |
| | | }) |
| | | }, |
| | | async recalculate() { |
| | | this.dataForm.isRecal = 1 |
| | | this.$nextTick(() => { |
| | | this.$refs.tableObj.query() |
| | | }) |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <template> |
| | | <div> |
| | | <el-row :gutter="5"> |
| | | <el-col :span="4"> |
| | | <el-col :span="5"> |
| | | <div class="fa-card-a" style="margin-right: 5px;height: calc(100vh - 123px)"> |
| | | <product-model-tree @on-selected="onProductSelected" showXdy="false"/> |
| | | </div> |
| | | </el-col> |
| | | <el-col :span="20"> |
| | | <el-col :span="19"> |
| | | <div class="mod-basicInfo-paramData fa-card-a" style="margin-left: 5px;"> |
| | | <zt-table-wraper ref="tableObj" defaultNotQuery="true" query-url="/basicInfo/ParamData/page" |
| | | delete-url="/basicInfo/ParamData/" |
| | |
| | | methods: { |
| | | add() { |
| | | this.dataForm.type = this.productType |
| | | alert(this.dataForm.type ) |
| | | if (this.dataForm.type !== '1') { |
| | | if (this.dataForm.type !== '3') { |
| | | this.dataForm.type = this.dataForm.type - 1 |