Commit 7c5de387 authored by xukaiqiang's avatar xukaiqiang

sql

parent 4f6fa381
......@@ -75,6 +75,18 @@ public class Fmea extends BasicEntity {
private RiskSource riskSource;
@Column(name = "company_leader")
private Integer companyLeader;
@Column(name = "department_leader")
private Integer departmentLeader;
@Column(name = "group_leader")
private Integer groupLeader;
@Column(name = "person_leader")
private Integer personLeader;
public Fmea() {
}
......@@ -244,4 +256,36 @@ public class Fmea extends BasicEntity {
public void setRpn(BigDecimal rpn) {
this.rpn = rpn;
}
public Integer getCompanyLeader() {
return companyLeader;
}
public void setCompanyLeader(Integer companyLeader) {
this.companyLeader = companyLeader;
}
public Integer getDepartmentLeader() {
return departmentLeader;
}
public void setDepartmentLeader(Integer departmentLeader) {
this.departmentLeader = departmentLeader;
}
public Integer getGroupLeader() {
return groupLeader;
}
public void setGroupLeader(Integer groupLeader) {
this.groupLeader = groupLeader;
}
public Integer getPersonLeader() {
return personLeader;
}
public void setPersonLeader(Integer personLeader) {
this.personLeader = personLeader;
}
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ public class FmeaServiceImpl implements IFmeaService {
RiskSource riskSource = iRiskSourceDao.findById(fmea.getRiskSourceId());
fmea.setRiskSource(riskSource);
iFmeaDao.save(fmea);
updateRpniInfo(fmea.getRiskSourceId());
//updateRpniInfo(fmea.getRiskSourceId());
});
}
......
......@@ -1509,7 +1509,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
/**
* fmea的更新导致rpn、rpni的值改变
*/
public void notifyRiskSource(Long riskSourceId) {
private void notifyRiskSource(Long riskSourceId) {
RiskSource riskSource = iRiskSourceDao.findById(riskSourceId);
if (riskSource == null) {
return;
......@@ -1537,6 +1537,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
count++;
}
}
if(count==0){
return;
}
BigDecimal averageOidValue = totalOidValue.divide(BigDecimal.valueOf(count));
BigDecimal averageNewOidValue = totalNewOidValue.divide(BigDecimal.valueOf(count));
BigDecimal rpn = maxDidValue.multiply(maxSidValue).multiply(averageNewOidValue);
......
......@@ -9,6 +9,7 @@
<!--初始化表结构
<include file="fas-init-table.xml" relativeToChangelogFile="true"/>-->
<include file="fas-1.0.1.xml" relativeToChangelogFile="true"/>
<include file="fas-1.0.2.xml" relativeToChangelogFile="true"/>
<!-- 系统函数脚本 -->
<include file="fas-sql-task.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<changeSet author="xukaiqiang" id="1557134646002-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_fmea" columnName="rpn"/>
</not>
</preConditions>
<comment>f_fmea add column rpn</comment>
<sql>
ALTER TABLE `f_fmea` ADD COLUMN `rpn` decimal(10,2) DEFAULT NULL COMMENT '实时rpn';
</sql>
</changeSet>
<changeSet author="xukaiqiang" id="1557134646002-2">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_fmea" columnName="new_evaluation_oid"/>
</not>
</preConditions>
<comment>f_fmea add column new_evaluation_oid</comment>
<sql>
ALTER TABLE `f_fmea` ADD COLUMN `new_evaluation_oid` bigint(20) DEFAULT NULL COMMENT '最新故障频数';
</sql>
</changeSet>
<changeSet author="xukaiqiang" id="1557134646002-3">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="f_fmea_equipment_point"/>
</not>
</preConditions>
<comment>create f_fmea_equipment_point</comment>
<sql>
CREATE TABLE `f_fmea_equipment_point` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
`fmea_id` bigint(20) NOT NULL COMMENT 'fmea编号',
`equipment_point_id` bigint(20) NOT NULL COMMENT '装备指标编号',
`state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '装备指标状态(0:正常;1:告警)',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8 COMMENT='fmea和装备指标的关系';
</sql>
</changeSet>
<changeSet author="xukaiqiang" id="1557134646002-4">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="f_fmea_point_inputitem"/>
</not>
</preConditions>
<comment>create f_fmea_point_inputitem</comment>
<sql>
CREATE TABLE `f_fmea_point_inputitem` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增',
`fmea_id` bigint(20) NOT NULL COMMENT 'fmea编号',
`point_inputitem_id` bigint(20) NOT NULL COMMENT '检查点和项关系编号',
`state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查项状态(0:正常;1:不合格)',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=116 DEFAULT CHARSET=utf8 COMMENT='fmea和检查项的关系';
</sql>
</changeSet>
<changeSet author="xukaiqiang" id="1557134646002-5">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_risk_level" columnName="top_limit"/>
</not>
</preConditions>
<comment>f_risk_level add column top_limit</comment>
<sql>
ALTER TABLE `f_risk_level` ADD COLUMN `top_limit` decimal(10,2) DEFAULT NULL COMMENT '上限';
</sql>
</changeSet>
<changeSet author="xukaiqiang" id="1557134646002-6">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_risk_level" columnName="down_limit"/>
</not>
</preConditions>
<comment>f_risk_level add column down_limit</comment>
<sql>
ALTER TABLE `f_risk_level` ADD COLUMN `down_limit` decimal(10,2) DEFAULT NULL COMMENT '下限';
</sql>
</changeSet>
<changeSet author="xukaiqiang" id="1557134646002-7">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_rpn_change_log" columnName="fmea_id"/>
</not>
</preConditions>
<comment>f_rpn_change_log add column fmea_id</comment>
<sql>
ALTER TABLE `f_rpn_change_log` ADD COLUMN `fmea_id` bigint(20) NOT NULL COMMENT 'fmeaId';
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -39,6 +39,10 @@
fm.protection,
fm.disposal,
fm.remark,
fm.company_leader as companyLeader,
fm.department_leader as departmentLeader,
fm.group_leader as groupLeader,
fm.person_leader as personLeader,
rf.`name` AS riskFactorName,
fat.`name` AS accidentTypeName,
fat.id AS accidentTypeId,
......@@ -79,42 +83,44 @@
<select id="getById" resultType="com.yeejoin.amos.fas.dao.entity.Fmea">
select
id,
risk_source_id as riskSourceId,
risk_factors_id as riskFactorsId,
evaluation_sid as evaluationSid,
evaluation_oid as evaluationOid,
evaluation_did as evaluationDid,
rpni,
rpn,
a.id,
a.risk_source_id as riskSourceId,
a.risk_factors_id as riskFactorsId,
a.evaluation_sid as evaluationSid,
a.evaluation_oid as evaluationOid,
a.evaluation_did as evaluationDid,
a.new_evaluation_oid as newEvaluationOid,
a.rpni,
a.rpn,
(select coefficient from f_evaluation_model where id = a.evaluation_sid) as sidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_oid) as oidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_did) as didValue,
(select coefficient from f_evaluation_model where id = a.new_evaluation_oid) as newOidValue
from
f_fmea
f_fmea as a
where
id = #{id}
a.id = #{id}
</select>
<select id="listByRiskSourceId" resultType="com.yeejoin.amos.fas.dao.entity.Fmea">
select
id,
risk_source_id as riskSourceId,
risk_factors_id as riskFactorsId,
evaluation_sid as evaluationSid,
evaluation_oid as evaluationOid,
evaluation_did as evaluationDid,
rpni,
rpn,
a.id,
a.risk_source_id as riskSourceId,
a.risk_factors_id as riskFactorsId,
a.evaluation_sid as evaluationSid,
a.evaluation_oid as evaluationOid,
a.evaluation_did as evaluationDid,
a.new_evaluation_oid as newEvaluationOid,
a.rpni,
a.rpn,
(select coefficient from f_evaluation_model where id = a.evaluation_sid) as sidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_oid) as oidValue,
(select coefficient from f_evaluation_model where id = a.evaluation_did) as didValue,
(select coefficient from f_evaluation_model where id = a.new_evaluation_oid) as newOidValue
from
f_fmea
f_fmea as a
where
risk_source_id = #{riskSourceId}
a.risk_source_id = #{riskSourceId}
</select>
......
......@@ -5,6 +5,7 @@ log4j.logger.org.hibernate=info
log4j.logger.com.mchange=info
log4j.logger.org.springframework=info
log4j.logger.com.mangofactory=info
log4j.logger.com.yeejoin.amos.fas.business.dao.mapper=debug
log4j.logger.org.apache=info
log4j.logger.com.zaxxer.hikari.pool=info
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment