|
@@ -0,0 +1,93 @@
|
|
|
+package com.metro.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.metro.baseRe.BaseResponse;
|
|
|
+import com.metro.entity.dto.DeviceDTO;
|
|
|
+import com.metro.entity.po.Company;
|
|
|
+import com.metro.entity.po.JDevices;
|
|
|
+import com.metro.entity.po.OrgCode;
|
|
|
+import com.metro.entity.po.SelfDatabase;
|
|
|
+import com.metro.mapper.CompanysMapper;
|
|
|
+import com.metro.mapper.JDevicesMapper;
|
|
|
+import com.metro.mapper.OrgCodeMapper;
|
|
|
+import com.metro.mapper.SelfDatabaseMapper;
|
|
|
+import com.metro.service.OpenAPIService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description:
|
|
|
+ * @ClassName OpenAPIServiceImpl
|
|
|
+ * @Author WXG
|
|
|
+ * @Date 2022/6/15 15:43
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class OpenAPIServiceImpl implements OpenAPIService {
|
|
|
+ @Resource
|
|
|
+ private SelfDatabaseMapper selfDatabaseMapper;
|
|
|
+ @Resource
|
|
|
+ private JDevicesMapper jDevicesMapper;
|
|
|
+ @Resource
|
|
|
+ private CompanysMapper companysMapper;
|
|
|
+ @Resource
|
|
|
+ private OrgCodeMapper orgCodeMapper;
|
|
|
+ @Override
|
|
|
+ public BaseResponse<Boolean> selectByIdNum(String idNum) {
|
|
|
+ if(StringUtils.isEmpty(idNum)){
|
|
|
+ throw new NullPointerException();
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<SelfDatabase> databaseLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ databaseLambdaQueryWrapper.eq(SelfDatabase::getIdNum, idNum);
|
|
|
+ List<SelfDatabase> selfDatabases = selfDatabaseMapper.selectList(databaseLambdaQueryWrapper);
|
|
|
+ if(selfDatabases !=null && selfDatabases.size() > 0){
|
|
|
+ return BaseResponse.fail("管控人员");
|
|
|
+ }
|
|
|
+ return BaseResponse.ok(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> selectByDeviceId(DeviceDTO deviceDTO) {
|
|
|
+ if(deviceDTO == null){
|
|
|
+ return getMapInfo(1001,"数据为空",null);
|
|
|
+ }
|
|
|
+ if(deviceDTO.getDevice_id() == null || StringUtils.isEmpty(deviceDTO.getDevice_id())){
|
|
|
+ return getMapInfo(1001,"设备号为空",null);
|
|
|
+ }
|
|
|
+ JDevices jDevices = jDevicesMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<JDevices>().eq(JDevices::getDeviceId, deviceDTO.getDevice_id())
|
|
|
+ );
|
|
|
+ if(jDevices == null){
|
|
|
+ return getMapInfo(1001,"设备号不存在",null);
|
|
|
+ }
|
|
|
+ Company company = companysMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<Company>()
|
|
|
+ .eq(Company::getCompanyId, jDevices.getCompanyId())
|
|
|
+ .eq(Company::getBranchId, jDevices.getBranchId())
|
|
|
+ );
|
|
|
+ if(company == null){
|
|
|
+ return getMapInfo(1001,"单位站点数据不存在",null);
|
|
|
+ }
|
|
|
+ OrgCode orgCode = orgCodeMapper.selectById(company.getCompanyId());
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("company_id",company.getCompanyId());
|
|
|
+ dataMap.put("company_name",company.getCompanyName());
|
|
|
+ dataMap.put("branch_id",company.getBranchId());
|
|
|
+ dataMap.put("branch_name",company.getBranchName());
|
|
|
+ dataMap.put("org_code",orgCode == null?null:orgCode.getOrgCode());
|
|
|
+ return getMapInfo(1,"",dataMap);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> getMapInfo(int errCode, String errMsg ,Map<String,Object> dataMap) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("errCode",errCode);
|
|
|
+ map.put("errMsg",errMsg);
|
|
|
+ map.put("data",dataMap);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+}
|