Commit 907476e8 authored by tianyiming's avatar tianyiming

12819、12818

parent a9be3e64
......@@ -70,6 +70,8 @@ public class EquipmentDetailController extends AbstractBaseController {
IEquipmentDetailService iEquipmentDetailService;
@Autowired
IFireFightingSystemService fireFightingSystemService;
@Autowired
EquipmentDetailMapper equipmentDetailMapper;
@Autowired
private StockDetailMapper stockDetailMapper;
......@@ -233,7 +235,43 @@ public class EquipmentDetailController extends AbstractBaseController {
return equipmentDate;
}
@RequestMapping(value = "/selectequipmentDateByCode", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据code查询", notes = "根据code查询")
public EquipmentDate selectequipmentDateByCode(@RequestParam String code,
@RequestParam(required = false) Long stockDetailId) {
EquipmentDate equipmentDate = new EquipmentDate();
EquipmentSpecific equipmentSpecific = equipmentSpecificSerivce.getBaseMapper().selectOne(new QueryWrapper<EquipmentSpecific>().eq("code",code));
if(!ObjectUtils.isEmpty(equipmentSpecific.getSystemId())){
FireFightingSystemEntity fightingSystemEntity = fireFightingSystemService.getOneById(Long.valueOf(equipmentSpecific.getSystemId()));
equipmentSpecific.setSystemId(fightingSystemEntity.getName());
} else {
equipmentSpecific.setSystemId("");
}
FireFightingSystemEntity fightingSystemEntity = fireFightingSystemService.getOneById(Long.valueOf(equipmentSpecific.getSystemId()));
equipmentSpecific.setSystemId(fightingSystemEntity.getName());
equipmentSpecific.setFullqrCode("01#" + equipmentSpecific.getQrCode());
EquipmentDetail equipmentDetail = iEquipmentDetailService.getOneById(equipmentSpecific.getEquipmentDetailId());
StockDetail stockDetail = null;
if (stockDetailId != null) {
//解决灭火药剂,有多个货位状态问题
stockDetail = stockDetailMapper.selectById(stockDetailId);
equipmentSpecific.setStockDetail(stockDetail);
} else {
//消防装备默认分支
List<StockDetail> stockDetails = stockDetailMapper.selectList(new LambdaQueryWrapper<StockDetail>().eq(StockDetail::getEquipmentSpecificId, equipmentSpecific.getId()));
if (!stockDetails.isEmpty()) {
stockDetail = stockDetails.get(0);
equipmentSpecific.setStockDetail(stockDetail);
}
}
if (stockDetail != null) {
equipmentSpecific.setStock(iStockService.getById(stockDetail.getStockId()));
}
equipmentDate.setEquipmentDetail(equipmentDetail);
equipmentDate.setEquipmentSpecific(equipmentSpecific);
return equipmentDate;
}
/***
*
* 修改
......
......@@ -817,7 +817,22 @@ public class FireFightingSystemController extends AbstractBaseController {
public List<PointTreeVo> getPointTree(@RequestParam(required = false) String systemId, @RequestParam(required = false) String bizOrgCode) {
return fireFightingSystemService.getPointTree(systemId, bizOrgCode);
}
@RequestMapping(value = "/{systemCode}/system/detail", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation("通过系统code查询消防系统及部件信息")
public Map<String, Object> getSystemDetailByCode(@PathVariable String systemCode) {
return fireFightingSystemService.getSystemDetailByCode(systemCode);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "获取系统分类树", notes = "获取系统分类树")
@GetMapping(value = "/systemAndEquipmentTreeByBziOrgCode")
public List<OrgMenuDto> systemAndEquipmentTreeByBziOrgCode(@RequestParam(required = false) String bizOrgCode) {
return fireFightingSystemService.systemAndEquipmentTreeByBziOrgCode(bizOrgCode);
}
/**
* 获取装备类型和统计值
* @throws Exception
......
......@@ -526,4 +526,10 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
List<Map<String, Object>> selectDayEchart(@Param("systemId") String systemId,
@Param("date") String date,
@Param("indicator") List<String> indicator);
List<Map<String, Object>> systemAndEquipment(@Param("bizOrgCode")String bizOrgCode);
Long selectEquipCountBySystemId(Long id);
String selectEquipSystemType(String code);
}
......@@ -284,4 +284,8 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
Page<Map<String, Object>> getSystemInfo(Page page, String companyCode, String systemCode);
List<OrgMenuDto> systemAndEquipmentTreeByBziOrgCode(String bizOrgCode);
Map<String, Object> getSystemDetailByCode(String systemCode);
}
......@@ -1982,4 +1982,74 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
return fireFightingSystemMapper.getSystemInfo(page, bizOrgCode, null);
}
@Override
public List<OrgMenuDto> systemAndEquipmentTreeByBziOrgCode(String bizOrgCode) {
List<Map<String, Object>> list = fireFightingSystemMapper.systemAndEquipment(bizOrgCode);
return systemAndEquipmentTree(list);
}
@Override
public Map<String,Object> getSystemDetailByCode(String systemCode) {
Map<String,Object> map = new HashMap<>();
LambdaQueryWrapper<FireFightingSystemEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FireFightingSystemEntity::getCode, systemCode);
List<FireFightingSystemEntity> systemEntities = this.list(wrapper);
if (systemEntities.isEmpty()) {
throw new RuntimeException("code" + systemCode + "不存在");
}
if (systemEntities != null) {
FireFightingSystemVo fireFightingSystemVo = fireFightingSystemMapper.getFightingSysInfo(systemEntities.get(0).getCode(), systemEntities.get(0).getId());
map.put("systemStatus", "异常".equals(fireFightingSystemVo.getStatus()) ? false : true);
} else {
map.put("systemStatus", true);
}
map.put("name",systemEntities.get(0).getName());
map.put("code",systemEntities.get(0).getCode());
map.put("installDate",systemEntities.get(0).getInstallDate());
map.put("chargePersonPhone",systemEntities.get(0).getChargePersonPhone());
map.put("chargePersonName",systemEntities.get(0).getChargePersonName());
map.put("designOrg",systemEntities.get(0).getDesignOrg());
map.put("designOrgTelephone",systemEntities.get(0).getDesignOrgTelephone());
map.put("leadDesigner",systemEntities.get(0).getLeadDesigner());
Long num = this.baseMapper.selectEquipCountBySystemId(systemEntities.get(0).getId());
String systemType = this.baseMapper.selectEquipSystemType(systemCode);
map.put("systemType",systemType);
map.put("num",num);
return map;
}
public static List<OrgMenuDto> systemAndEquipmentTree(List<Map<String,Object>> list) {
List<OrgMenuDto> menuList = list.stream()
.map(o -> new OrgMenuDto(Long.parseLong(o.get("id").toString()), o.get("name").toString(),
ObjectUtils.isEmpty(o.get("parentId")) ? 0L : Long.parseLong(o.get("parentId").toString()),
ObjectUtils.isEmpty(o.get("code")) ? "": o.get("code").toString(),
false, o.get("bizOrgCode").toString()))
.collect(Collectors.toList());
List<OrgMenuDto> result = new ArrayList<>();
Map<Long, OrgMenuDto> map = new HashMap<>(menuList.size());
menuList.forEach(e -> map.put(e.getKey(), e));
Set<? extends Map.Entry<Long, ? extends OrgMenuDto>> entries = map.entrySet();
// 此处多线程,会value 出现null 的情况
// entries.parallelStream().forEach(entry -> {
entries.forEach(entry -> {
OrgMenuDto value = entry.getValue();
if (value != null) {
OrgMenuDto treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<OrgMenuDto> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
result.add(value);
}
}
});
return result;
}
}
......@@ -4356,4 +4356,76 @@
temp.notReturnd DESC
</select>
<select id="systemAndEquipment" resultType="java.util.Map">
SELECT
a.id,
a.`name`,
a.code,
a.sort,
substring_index(
substring_index(
a.parentId,
',',
b.help_topic_id + 1
),
',' ,- 1
) AS parentId,
a.bizOrgCode
FROM
(
(
SELECT
ffs.`id`,
ffs.`name`,
ffs.`code`,
sort,
'' parentId,
ffs.biz_org_code bizOrgCode
FROM
f_fire_fighting_system ffs
WHERE
ffs.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%' )
) UNION
(
SELECT
wes.id,
wes.`name`,
wes.`code`,
0,
wes.system_id parentId,
wes.biz_org_code bizOrgCode
FROM
f_fire_fighting_system ffs
LEFT JOIN wl_equipment_specific wes ON wes.system_id = ffs.id
WHERE
wes.biz_org_code LIKE CONCAT(#{bizOrgCode}, '%' )
)
)a
JOIN mysql.help_topic b ON b.help_topic_id &lt; (
length(a.parentId) - length(
REPLACE (a.parentId, ',', '')
) + 1
)
ORDER BY parentId, sort
</select>
<select id="selectEquipCountBySystemId" resultType="java.lang.Long">
SELECT
count(1) num
FROM
wl_equipment_specific AS spe
where
spe.system_id = #{systemId}
</select>
<select id="selectEquipSystemType" resultType="java.lang.String">
SELECT
group_name
FROM
f_fire_fighting_system ffs
LEFT JOIN wl_dynamic_form_group wdfg ON ffs.form_group_id = wdfg.id
WHERE
ffs.code = #{code}
</select>
</mapper>
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