Commit 748332ed authored by tianyiming's avatar tianyiming

生成监管码和96333电梯码

parent 54232d71
package com.yeejoin.amos.boot.module.tzs.api.dto;
import lombok.Data;
@Data
public class EquInfoDto {
/**
* 城市编码
*/
private String city;
/**
* 区县编码
*/
private String county;
/**
* 设备类别
*/
private String equipCategory;
/**
* 设备种类
*/
private String equipList;
/**
* record
*/
private String record;
}
package com.yeejoin.amos.boot.module.tzs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo;
import org.apache.ibatis.annotations.Param;
......@@ -17,4 +18,6 @@ public interface CategoryOtherInfoMapper extends BaseMapper<CategoryOtherInfo> {
CategoryOtherInfo selectSupervisorCode(@Param("supervisorCode") String supervisorCode);
CategoryOtherInfo selectElevatorCode(@Param("elevatorCode") String elevatorCode);
EquInfoDto selectEquipInfo(String record);
}
......@@ -19,7 +19,9 @@ public interface IEquipmentCategoryService {
Page equipClaimOverview();
int createSupervisorCode(Map<String,Object> map);
int createSupervisorCode(Map<String,Object> map,String record);
List<LinkedHashMap> creatTree();
List<LinkedHashMap> getRegion(String level, String parentId);
}
......@@ -2,15 +2,30 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.feign;
import com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
@FeignClient(value = "AMOS-API-PRIVILEGE", path = "privilege")
@FeignClient(value = "AMOS-API-PRIVILEGE",configuration = {FeignConfiguration.class})
public interface PrivilegeFeginService {
@RequestMapping(value = "/v1/agencyuser/me", method = RequestMethod.GET)
@RequestMapping(value = "/privilege/v1/agencyuser/me", method = RequestMethod.GET)
ResponseModel<AgencyUserModel> getMe();
//获取单位树
@RequestMapping(value = "/privilege/v1/company/tree", method = RequestMethod.GET)
FeignClientResult tree();
//获取省级行政区划
@RequestMapping(value = "systemctl/v1/region/level", method = RequestMethod.GET)
FeignClientResult getProvince(@RequestParam String level);
//获取行政区划树
@RequestMapping(value = "systemctl/v1/region/tree", method = RequestMethod.GET)
FeignClientResult getTree();
}
......@@ -27,7 +27,7 @@
<select id="selectElevatorCode" resultType="com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo">
SELECT
CODE96333
CODE96333 code
FROM
idx_biz_jg_other_info oi
WHERE
......@@ -36,4 +36,18 @@
RIGHT ( CODE96333, 2 ) DESC
LIMIT 1
</select>
<select id="selectEquipInfo" resultType="com.yeejoin.amos.boot.module.tzs.api.dto.EquInfoDto">
SELECT
"CITY",
"COUNTY",
"EQU_LIST" equipList,
"EQU_CATEGORY" equipCategory,
ibjoi."RECORD"
FROM
idx_biz_jg_other_info ibjoi
LEFT JOIN idx_biz_jg_register_info ibjri ON ibjoi.RECORD = ibjri.RECORD
LEFT JOIN idx_biz_jg_use_info ibjui ON ibjoi.RECORD = ibjui.RECORD
WHERE ibjoi."RECORD" = #{record}
</select>
</mapper>
package com.yeejoin.amos;
import com.yeejoin.amos.boot.biz.common.utils.oConvertUtils;
import com.yeejoin.amos.boot.module.tzs.biz.listener.BaseEnterpriseMqTtlListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.CarcylUnitInspectMqTtlListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.FillingRecordSyncListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.PrivilegeCompanyDeleteListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.PrivilegeCompanyUpdateAddListener;
import com.yeejoin.amos.boot.module.tzs.biz.listener.*;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
import org.eclipse.paho.client.mqttv3.MqttException;
......@@ -76,6 +72,9 @@ public class AmosTzsApplication {
private FillingRecordSyncListener fillingRecordSyncListener;
@Autowired
private AmosMqttListener amosMqTtlListener;
@Autowired
ICylinderInfoService cylinderInfoServiceImpl;
public static void main(String[] args) throws UnknownHostException {
......@@ -102,6 +101,7 @@ public class AmosTzsApplication {
emqKeeper.getMqttClient().subscribe("/tz/privilege_company_add_update", 1, privilegeCompanyUpdateAddListener);
emqKeeper.getMqttClient().subscribe("/tz/privilege_company_delete", 1, privilegeCompanyDeleteListener);
emqKeeper.getMqttClient().subscribe("/tzs/sync/fillingRecord", 1, fillingRecordSyncListener);
emqKeeper.getMqttClient().subscribe("tzs/oneCodePass/deviceSave", 0, amosMqTtlListener);
// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam", 1, examMqTtlListener);
// emqKeeper.getMqttClient().subscribe("topic_mqtt_exam_record", 1, examMqTtRecordListener);
}
......
......@@ -8,7 +8,6 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.biz.common.utils.TreeParser;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.JgAllDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
......@@ -190,7 +189,7 @@ public class EquipmentCategoryController extends BaseController {
@PostMapping(value = "/createSupervisorCode")
@ApiOperation(httpMethod = "POST", value = "生成监管码和96333码", notes = "生成监管码和96333码")
public ResponseModel<Object> createSupervisorCode(@RequestBody Map<String,Object> map) {
return ResponseHelper.buildResponse(equipmentCategoryService.createSupervisorCode(map));
return ResponseHelper.buildResponse(equipmentCategoryService.createSupervisorCode(map,null));
}
......@@ -233,4 +232,17 @@ public class EquipmentCategoryController extends BaseController {
}
/**
* 生成管辖分局树
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "getRegion")
@ApiOperation(httpMethod = "GET", value = "生成管辖分局树", notes = "生成管辖分局树")
public ResponseModel<Object> getRegion(@RequestParam(value = "level", required = false) String level,
@RequestParam(value = "parentId", required = false) String parentId) {
return ResponseHelper.buildResponse(equipmentCategoryService.getRegion(level,parentId));
}
}
package com.yeejoin.amos.boot.module.tzs.biz.fegin;
import com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(name = "${privilege.fegin.name}", configuration = {FeignConfiguration.class})
public interface PrivilegeFeign {
//获取单位树
@RequestMapping(value = "/privilege/v1/company/tree", method = RequestMethod.GET)
FeignClientResult tree();
}
package com.yeejoin.amos.boot.module.tzs.biz.listener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqxListener;
/**
* @author Administrator
*/
@Component
public class AmosMqttListener extends EmqxListener {
@Autowired
IEquipmentCategoryService equipmentCategoryService;
@Override
public void processMessage(String topic, MqttMessage mqttMessage){
byte[] payload = mqttMessage.getPayload();
String str = new String(payload);
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String id = jsonObject.get("id").toString();
equipmentCategoryService.createSupervisorCode(null, id);
}
}
......@@ -4,17 +4,16 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquInfoDto;
import com.yeejoin.amos.boot.module.tzs.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.tzs.api.entity.RescueStation;
import com.yeejoin.amos.boot.module.tzs.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.tzs.api.enums.EquipmentCategoryEnum;
import com.yeejoin.amos.boot.module.tzs.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.tzs.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.tzs.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.tzs.api.service.IEquipmentCategoryService;
import com.yeejoin.amos.boot.module.tzs.biz.fegin.PrivilegeFeign;
import com.yeejoin.amos.boot.module.tzs.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.tzs.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.tzs.flc.api.feign.PrivilegeFeginService;
......@@ -51,9 +50,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private Resource equipStatus;
@Autowired
PrivilegeFeign privilegeFeign;
@Autowired
CategoryOtherInfoMapper categoryOtherInfoMapper;
@Autowired
......@@ -141,24 +137,30 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
* 生成监管码和电梯96333识别码
*/
@Override
public int createSupervisorCode(Map<String, Object> map) {
LinkedHashMap value = (LinkedHashMap) map.get("value");
//获取对应城市、区县值
LinkedHashMap o = (LinkedHashMap) value.get("1627903393253056514");
String city = o.get("CITY").toString();
String county = o.get("COUNTY").toString();
//获取对应种类、类别值
LinkedHashMap o1 = (LinkedHashMap) value.get("1630483430028369922");
String equipCategory = o1.get("EQU_CATEGORY").toString();
String equipList = o1.get("EQU_LIST").toString();
//测试数据 暂时保留
// String city = "610400";
// String county = "610401";
// String equipCategory = "3200";
// String equipList = "3000";
public int createSupervisorCode(Map<String, Object> map, String record) {
String city = null;
String county = null;
String equipCategory = null;
String equipList = null;
if (ObjectUtils.isEmpty(record)) {
//获取对应城市、区县值
city = map.get("CITY").toString();
county = map.get("COUNTY").toString();
//获取对应种类、类别值
equipCategory = map.get("EQU_CATEGORY").toString();
equipList = map.get("EQU_LIST").toString();
} else {
EquInfoDto equInfoDto = categoryOtherInfoMapper.selectEquipInfo(record);
city = equInfoDto.getCity();
county = equInfoDto.getCounty();
equipCategory = equInfoDto.getEquipCategory();
equipList = equInfoDto.getEquipList();
}
//生成码
Map<String, String> codeMap = creatCode(city, county, equipCategory, equipList);
Map<String, String> codeMap = new HashMap<>();
synchronized (EquipmentCategoryServiceImpl.class) {
codeMap = creatCode(city, county, equipCategory, equipList);
}
//查询最后一条数据并进行修改
CategoryOtherInfo otherInfo = categoryOtherInfoMapper.selectOne(new QueryWrapper<CategoryOtherInfo>().orderByDesc("REC_DATE").last("limit 1"));
return categoryOtherInfoMapper.updateSupervisorCode(codeMap.get("supervisorCode"), codeMap.get("elevatorCode"), otherInfo.getSequenceNbr());
......@@ -166,27 +168,61 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Override
public List<LinkedHashMap> creatTree() {
FeignClientResult tree = privilegeFeign.tree();
FeignClientResult tree = privilegeFeginService.tree();
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
List<LinkedHashMap> treeData = deleteTreeData(result);
List<LinkedHashMap> treeData = deleteTreeData(result, null);
List<LinkedHashMap> resultTree = new ArrayList<>();
resultTree.add(treeData.get(5));
return resultTree;
}
private List<LinkedHashMap> deleteTreeData(List<LinkedHashMap> result) {
@Override
public List<LinkedHashMap> getRegion(String level, String parentId) {
List<LinkedHashMap> list = new ArrayList<>();
if (ObjectUtils.isEmpty(parentId)) {
FeignClientResult result = privilegeFeginService.getProvince(level);
list = (List<LinkedHashMap>) result.getResult();
list.get(0).put("sequenceNbr", list.get(0).get("regionCode"));
} else {
FeignClientResult tree = privilegeFeginService.getTree();
List<LinkedHashMap> result = (List<LinkedHashMap>) tree.getResult();
list = deleteTreeData(result, parentId);
}
return list;
}
private List<LinkedHashMap> deleteTreeData(List<LinkedHashMap> result, String type) {
Iterator it = result.iterator();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//删除使用单位
if ("company".equals(e.get("level"))) {
it.remove();
if (ObjectUtils.isEmpty(type)) {
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//删除使用单位
if ("company".equals(e.get("level"))) {
it.remove();
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
deleteTreeData((List<LinkedHashMap>) e.get("children"), null);
}
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
deleteTreeData((List<LinkedHashMap>) e.get("children"));
return result;
} else {
List<LinkedHashMap> list = new ArrayList<>();
while (it.hasNext()) {
LinkedHashMap e = (LinkedHashMap) it.next();
//修改数据
if (type.equals(e.get("parentRegionCode").toString())) {
e.put("children",null);
e.put("sequenceNbr",e.get("regionCode"));
list.add(e);
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
List<LinkedHashMap> children = deleteTreeData((List<LinkedHashMap>) e.get("children"), type);
list.addAll(children);
}
}
return list;
}
return result;
}
/**
......@@ -356,5 +392,4 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<EquipmentCategory> equipmentCategories = baseMapper.selectList(wrapper2);
return equipmentCategories;
}
}
}
\ No newline at end of file
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