Commit 95526117 authored by suhuiguang's avatar suhuiguang

1.区域建筑关系建立

parent 52af9353
...@@ -10,6 +10,7 @@ import javax.persistence.GenerationType; ...@@ -10,6 +10,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
...@@ -38,7 +39,8 @@ public class BasicEntity /*extends Resource*/ implements Serializable{ ...@@ -38,7 +39,8 @@ public class BasicEntity /*extends Resource*/ implements Serializable{
private Date createDate = new Date(); private Date createDate = new Date();
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.AUTO,generator = "myid")
@GenericGenerator(name = "myid", strategy = "com.yeejoin.amos.fas.config.ManulInsertGenerator")
@Column(name = "ID",nullable=false,unique=true) @Column(name = "ID",nullable=false,unique=true)
public long getId() { public long getId() {
return id; return id;
......
...@@ -79,6 +79,19 @@ public class RiskSource extends BasicEntity { ...@@ -79,6 +79,19 @@ public class RiskSource extends BasicEntity {
private String routePath; private String routePath;
/** /**
* 同步源id
*/
private Long sourceId;
public Long getSourceId() {
return sourceId;
}
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}
/**
* 闪烁频率 * 闪烁频率
*/ */
@Column(name = "flicker_frequency") @Column(name = "flicker_frequency")
......
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo; import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo; import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
...@@ -36,10 +14,22 @@ import com.yeejoin.amos.fas.core.common.request.CommonPageable; ...@@ -36,10 +14,22 @@ import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse; import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.RiskSource;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/api/risksource") @RequestMapping("/api/risksource")
...@@ -47,8 +37,6 @@ import io.swagger.annotations.ApiParam; ...@@ -47,8 +37,6 @@ import io.swagger.annotations.ApiParam;
public class RiskSourceController extends BaseController { public class RiskSourceController extends BaseController {
private final Logger log = LoggerFactory.getLogger(RiskSourceController.class); private final Logger log = LoggerFactory.getLogger(RiskSourceController.class);
private final static String IS_RISK_AREA = "TRUE";
@Autowired @Autowired
IRiskFactorService iRiskFactorService; IRiskFactorService iRiskFactorService;
...@@ -734,4 +722,20 @@ public class RiskSourceController extends BaseController { ...@@ -734,4 +722,20 @@ public class RiskSourceController extends BaseController {
public CommonResponse queryFmeaByPointId(@PathVariable Long pointId) { public CommonResponse queryFmeaByPointId(@PathVariable Long pointId) {
return CommonResponseUtil.success(riskSourceService.queryFmeaByPointId(pointId)); return CommonResponseUtil.success(riskSourceService.queryFmeaByPointId(pointId));
} }
@Permission
@ApiOperation(value = "同步风险区域",notes = "创建或者更新,对站调用")
@PostMapping("/syn/region")
public CommonResponse synRegion(@RequestBody List<RiskSource> list){
ReginParams reginParams = getSelectedOrgInfo();
String compCode = getOrgCode(reginParams);
return CommonResponseUtil.success(riskSourceService.synRegion(getUserId(),compCode,list));
}
@Permission
@ApiOperation(value = "删除建筑与风险区域关系",notes = "对站调用")
@PutMapping("/remove/bind")
public CommonResponse removeBind(@RequestParam Long instanceId){
return CommonResponseUtil.success(riskSourceService.removeBind(instanceId));
}
} }
...@@ -35,10 +35,11 @@ public interface IRiskSourceDao extends BaseDao<RiskSource, Long> { ...@@ -35,10 +35,11 @@ public interface IRiskSourceDao extends BaseDao<RiskSource, Long> {
@Query(value="select *from f_risk_source where is_region = 'TRUE' and parent_id > 0", nativeQuery = true) @Query(value="select *from f_risk_source where is_region = 'TRUE' and parent_id > 0", nativeQuery = true)
List<RiskSource> queryRiskAreaRpn(); List<RiskSource> queryRiskAreaRpn();
Optional<RiskSource> findByOrgCodeAndParentId(String orgCode, Long parentId); Optional<RiskSource> findByOrgCodeAndParentId(String orgCode, Long parentId);
List<RiskSource> findByParentIdAndIsRegion(long id, String string); List<RiskSource> findByParentIdAndIsRegion(long id, String string);
Optional<RiskSource> findByCode(String riskSourceCode); Optional<RiskSource> findByCode(String riskSourceCode);
List<RiskSource> findBySourceId(Long instanceId);
} }
...@@ -194,4 +194,20 @@ public interface IRiskSourceService { ...@@ -194,4 +194,20 @@ public interface IRiskSourceService {
* @date 2020-9-9 11:53:36 * @date 2020-9-9 11:53:36
*/ */
void deleteById(Long id); void deleteById(Long id);
/**
* 同步创建/更新区域
* @param code userId
* @param compCode 公司编号
* @param list 同步数据支持多个
* @return List<RiskSource>
*/
List<RiskSource> synRegion(String code, String compCode, List<RiskSource> list);
/**
* 解除绑定关系
* @param instanceId 解除者id
* @return Boolean
*/
Boolean removeBind(Long instanceId);
} }
package com.yeejoin.amos.fas.config;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentityGenerator;
import java.io.Serializable;
/**
* 自定义的主键生成策略,如果填写了主键id,如果数据库中没有这条记录,则新增指定id的记录;否则更新记录
*
* 如果不填写主键id,则利用数据库本身的自增策略指定id
*/
public class ManulInsertGenerator extends IdentityGenerator {
@Override
public Serializable generate(SharedSessionContractImplementor s, Object obj) throws HibernateException {
Serializable id = s.getEntityPersister(null, obj).getClassMetadata().getIdentifier(obj, s);
if (id != null && Long.parseLong(id.toString()) > 0) {
return id;
} else {
return super.generate(s, obj);
}
}
}
...@@ -587,4 +587,15 @@ ...@@ -587,4 +587,15 @@
ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_user_id` varchar(20) NULL COMMENT '驻站消防队队长'; ALTER TABLE `f_station_info` ADD COLUMN `fire_captain_user_id` varchar(20) NULL COMMENT '驻站消防队队长';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="shg" id="1609226808866-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_risk_source" columnName="source_id"/>
</not>
</preConditions>
<comment>f_risk_source add column source_id</comment>
<sql>
alter table `f_risk_source` add column `source_id` bigint(20) DEFAULT NULL AFTER `status`;
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -183,7 +183,7 @@ ...@@ -183,7 +183,7 @@
left join wl_equipment_index as ein on ind.equipment_index_id = ein.id left join wl_equipment_index as ein on ind.equipment_index_id = ein.id
left join wl_stock_detail as sto on sto.qr_code = spe.qr_code left join wl_stock_detail as sto on sto.qr_code = spe.qr_code
left join wl_warehouse_structure as str on sto.warehouse_structure_id = str.source_id left join wl_warehouse_structure as str on sto.warehouse_structure_id = str.source_id
left join f_risk_source as sce on str.source_id = sce.id left join f_risk_source as sce on str.source_id = sce.source_id
) d ) d
WHERE WHERE
1 = 1 1 = 1
...@@ -298,8 +298,9 @@ ...@@ -298,8 +298,9 @@
LEFT JOIN wl_equipment we ON we.id = wed.equipment_id LEFT JOIN wl_equipment we ON we.id = wed.equipment_id
LEFT JOIN wl_unit u ON u.id = we.unit_id LEFT JOIN wl_unit u ON u.id = we.unit_id
LEFT JOIN wl_warehouse_structure ws ON ws.source_id = wsd.warehouse_structure_id LEFT JOIN wl_warehouse_structure ws ON ws.source_id = wsd.warehouse_structure_id
left join f_risk_source as sce on sce.source_id = ws.source_id
WHERE WHERE
ws.source_id = #{riskSourceId} sce.id = #{riskSourceId}
GROUP BY GROUP BY
wsd.equipment_detail_id, wsd.equipment_detail_id,
wed.`name` wed.`name`
......
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