提交相关代码

This commit is contained in:
zfhai 2023-12-09 11:30:27 +08:00
parent 83dffa593f
commit 04f0676e73
6 changed files with 93 additions and 2 deletions

View File

@ -2,15 +2,34 @@ package com.bonus.zlpt.equip.api;
import com.bonus.zlpt.common.core.constant.ServiceNameConstants; import com.bonus.zlpt.common.core.constant.ServiceNameConstants;
import com.bonus.zlpt.common.core.web.domain.AjaxResult; import com.bonus.zlpt.common.core.web.domain.AjaxResult;
import com.bonus.zlpt.equip.api.domain.TypeInfo;
import com.bonus.zlpt.equip.api.factory.DevInfoServiceApiFallbackFactory; import com.bonus.zlpt.equip.api.factory.DevInfoServiceApiFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletResponse;
@FeignClient(contextId = "remoteDevInfoService", value = ServiceNameConstants.EQUIP_SERVICE, fallbackFactory = DevInfoServiceApiFallbackFactory.class) @FeignClient(contextId = "remoteDevInfoService", value = ServiceNameConstants.EQUIP_SERVICE, fallbackFactory = DevInfoServiceApiFallbackFactory.class)
public interface RemoteDevInfoService public interface RemoteDevInfoService
{ {
/**
* 设备查询
* @param maId
* @return
*/
@GetMapping(value = "/dev/{maId}") @GetMapping(value = "/dev/{maId}")
public AjaxResult getInfo(@PathVariable("maId") Long maId); public AjaxResult getInfo(@PathVariable("maId") Long maId);
/**
* 添加设备
* @param typeInfo
* @param typeInfo
*/
@PostMapping("/dev")
void add(@RequestBody TypeInfo typeInfo);
} }

View File

@ -141,4 +141,6 @@ public class DevInfo extends BaseEntity
private String isActive; private String isActive;
/**文件附件*/ /**文件附件*/
private List<SysFileInfo> fileList; private List<SysFileInfo> fileList;
/**城市*/
private String city;
} }

View File

@ -0,0 +1,66 @@
package com.bonus.zlpt.equip.api.enums;
public enum MaStatusEnum {
/** 待上架审批 */
PENDING_APPROVAL(15, "待上架审批"),
/** 待租 */
ON_HIRE(16, "待租"),
/** 在租 */
UNDER_RENT(17, "在租"),
/** 下架 */
DELIST(18,"下架"),
/** 自有 */
SELF_OWNED(43,"自有");
private final Integer code;
private final String name;
MaStatusEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
/**
* 根据code获取name
* @param code
* @return
*/
public static String getNameByCode(int code) {
MaStatusEnum[] maStatusEnums = values();
for (MaStatusEnum maStatusEnum : maStatusEnums) {
if (maStatusEnum.getCode() == code) {
return maStatusEnum.getName();
}
}
return null;
}
/**
*
* @param msg
* @return
*/
public static Integer getCodeByName(String msg) {
MaStatusEnum[] maStatusEnums = values();
for (MaStatusEnum maStatusEnum : maStatusEnums) {
if (maStatusEnum.getName() == msg) {
return maStatusEnum.getCode();
}
}
return null;
}
}

View File

@ -11,6 +11,7 @@ import com.bonus.zlpt.equip.api.domain.vo.DevInfoVo;
import com.bonus.zlpt.common.core.domain.system.SysFile; import com.bonus.zlpt.common.core.domain.system.SysFile;
import com.bonus.zlpt.common.core.utils.DateUtils; import com.bonus.zlpt.common.core.utils.DateUtils;
import com.bonus.zlpt.equip.api.enums.MaStatusEnum;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import com.bonus.zlpt.equip.mapper.SysFileInfoMapper; import com.bonus.zlpt.equip.mapper.SysFileInfoMapper;
@ -183,7 +184,8 @@ public class DevInfoServiceImpl implements IDevInfoService
//根据key计算每种状态的数量 //根据key计算每种状态的数量
for (String key : keys) { for (String key : keys) {
List<DevInfo> DevInfoList = groupedByMaStatus.get(key); List<DevInfo> DevInfoList = groupedByMaStatus.get(key);
sumTypeMap.put(key,DevInfoList.size()); //根据key来获取状态名称
sumTypeMap.put(MaStatusEnum.getNameByCode(Integer.parseInt(key)),DevInfoList.size());
} }
return sumTypeMap; return sumTypeMap;
} }

View File

@ -45,12 +45,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectDevInfoList" parameterType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo" resultType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo"> <select id="selectDevInfoList" parameterType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo" resultType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo">
select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name,u.type as type
from ma_dev_info d from ma_dev_info d
left join (select t.*, p.type_name as parent_name left join (select t.*, p.type_name as parent_name
from ma_type_info t from ma_type_info t
left join ma_type_info p on t.parent_id=p.type_id) t on d.type_id = t.type_id left join ma_type_info p on t.parent_id=p.type_id) t on d.type_id = t.type_id
left join bm_company_info c on d.own_co = c.company_id left join bm_company_info c on d.own_co = c.company_id
left join ma_up_off u on d.ma_id = u.ma_id
-- select d.*,t.type_name,c.company_name ,u.type, u.id as up_id -- select d.*,t.type_name,c.company_name ,u.type, u.id as up_id
-- from ma_dev_info d -- from ma_dev_info d
-- left join ma_type_info t on d.type_id = t.type_id -- left join ma_type_info t on d.type_id = t.type_id

View File

@ -43,6 +43,7 @@ public class FileUploadTencentServiceImpl implements FileUploadTencentService {
ClientConfig clientConfig = new ClientConfig(); ClientConfig clientConfig = new ClientConfig();
// 这里建议设置使用 https 协议 // 这里建议设置使用 https 协议
clientConfig.setHttpProtocol(HttpProtocol.https); clientConfig.setHttpProtocol(HttpProtocol.https);
clientConfig.setRegion(region);
// 3 生成 cos 客户端 // 3 生成 cos 客户端
COSClient cosClient = new COSClient(cred, clientConfig); COSClient cosClient = new COSClient(cred, clientConfig);