设备信息,字典domain
This commit is contained in:
parent
0079778d3a
commit
f83de238b6
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.bonus.common.biz.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class BaseAddress extends BaseEntity {
|
||||||
|
|
||||||
|
@Excel(name = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Excel(name = "平台id")
|
||||||
|
private Long platformId;
|
||||||
|
|
||||||
|
@Excel(name = "编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Excel(name = "父级编码")
|
||||||
|
private String parentCode;
|
||||||
|
|
||||||
|
@Excel(name = "地区名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Excel(name = "纬度")
|
||||||
|
private Double latitude;
|
||||||
|
|
||||||
|
@Excel(name = "经度")
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
@Excel(name = "等级")
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
@Excel(name = "区域划分")
|
||||||
|
private Integer region;
|
||||||
|
|
||||||
|
@Excel(name = "状态")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Excel(name = "创建时间")
|
||||||
|
private LocalDateTime created;
|
||||||
|
|
||||||
|
@Excel(name = "修改时间")
|
||||||
|
private LocalDateTime modified;
|
||||||
|
|
||||||
|
@Excel(name = "状态")
|
||||||
|
private Integer yn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.bonus.common.biz.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 我的收藏
|
||||||
|
对象 ma_user_collect
|
||||||
|
*
|
||||||
|
* @author xsheng
|
||||||
|
* @date 2023-12-02
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@ApiModel("我的收藏")
|
||||||
|
public class UserCollect extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 用户id */
|
||||||
|
@Excel(name = "用户id")
|
||||||
|
@ApiModelProperty(value = "用户id", required = true)
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 设备id */
|
||||||
|
@Excel(name = "设备id")
|
||||||
|
@ApiModelProperty(value = "设备id", required = true)
|
||||||
|
private Long maId;
|
||||||
|
|
||||||
|
/** 收藏时间 */
|
||||||
|
@Excel(name = "收藏时间")
|
||||||
|
@ApiModelProperty(value = "收藏时间", required = true)
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
private Boolean isCollect;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.bonus.common.biz.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum MaStatusEnum {
|
||||||
|
|
||||||
|
/** 待上架 */
|
||||||
|
TO_BE_LISTED (15, "待上架"),
|
||||||
|
/** 待租 */
|
||||||
|
ON_HIRE(16, "待租"),
|
||||||
|
/** 在租 */
|
||||||
|
UNDER_RENT(17, "在租"),
|
||||||
|
/** 下架 */
|
||||||
|
DELIST(18,"下架"),
|
||||||
|
/** 自有 */
|
||||||
|
SELF_OWNED(43,"自有"),
|
||||||
|
/** 待审批 */
|
||||||
|
PENDING_APPROVAL(331,"待审批"),
|
||||||
|
/** 上架驳回 */
|
||||||
|
LISTING_REJECTED(332,"上架驳回");
|
||||||
|
|
||||||
|
private final Integer code;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
MaStatusEnum(Integer code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getCodeByName(String msg) {
|
||||||
|
MaStatusEnum[] maStatusEnums = values();
|
||||||
|
for (MaStatusEnum maStatusEnum : maStatusEnums) {
|
||||||
|
if (maStatusEnum.getName() == msg) {
|
||||||
|
return maStatusEnum.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -156,8 +156,9 @@ public class DevInfo extends BaseEntity {
|
||||||
private String isActive;
|
private String isActive;
|
||||||
|
|
||||||
/**文件附件*/
|
/**文件附件*/
|
||||||
|
@ApiModelProperty(value = "文件附件")
|
||||||
private List<SysFileInfo> fileList;
|
private List<SysFileInfo> fileList;
|
||||||
|
|
||||||
/**城市*/
|
@ApiModelProperty(value = "城市")
|
||||||
private String city;
|
private String city;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.bonus.material.device.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备类型对象 ma_type_info
|
||||||
|
*
|
||||||
|
* @author syruan
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@ApiModel("设备类型对象")
|
||||||
|
public class TypeInfo extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 类型id */
|
||||||
|
@Excel(name = "类型id")
|
||||||
|
@ApiModelProperty(value = "类型id", required = true)
|
||||||
|
private Long typeId;
|
||||||
|
|
||||||
|
/** 父级id */
|
||||||
|
@Excel(name = "父级id")
|
||||||
|
@ApiModelProperty(value = "父级id", required = true)
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/** 类型名称 */
|
||||||
|
@Excel(name = "类型名称")
|
||||||
|
@ApiModelProperty(value = "类型名称", required = true)
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
/** 计量单位 */
|
||||||
|
@Excel(name = "计量单位")
|
||||||
|
@ApiModelProperty(value = "计量单位", required = true)
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
/** 层级 */
|
||||||
|
@Excel(name = "层级")
|
||||||
|
@ApiModelProperty(value = "层级", required = true)
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
/** 排序 */
|
||||||
|
@Excel(name = "排序")
|
||||||
|
@ApiModelProperty(value = "排序", required = true)
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
/** 是否删除 */
|
||||||
|
@Excel(name = "是否删除")
|
||||||
|
@ApiModelProperty(value = "是否删除", required = true)
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
/** 父部门名称 */
|
||||||
|
@ApiModelProperty(value = "父部门名称", required = true)
|
||||||
|
private String parentName;
|
||||||
|
|
||||||
|
/** 子部门 */
|
||||||
|
@ApiModelProperty(value = "子部门", required = true)
|
||||||
|
private List<TypeInfo> children = new ArrayList<TypeInfo>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.bonus.material.device.mapper;
|
package com.bonus.material.device.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.BaseAddress;
|
||||||
import com.bonus.common.biz.domain.SysDic;
|
import com.bonus.common.biz.domain.SysDic;
|
||||||
import com.bonus.common.biz.domain.SysFile;
|
import com.bonus.common.biz.domain.SysFile;
|
||||||
|
import com.bonus.common.biz.domain.UserCollect;
|
||||||
import com.bonus.material.device.domain.DevInfo;
|
import com.bonus.material.device.domain.DevInfo;
|
||||||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||||
|
|
||||||
|
|
@ -46,7 +48,7 @@ public interface DevInfoMapper {
|
||||||
*/
|
*/
|
||||||
List<DevInfoVo> selectDevInfoList(DevInfo devInfo);
|
List<DevInfoVo> selectDevInfoList(DevInfo devInfo);
|
||||||
|
|
||||||
List<Object> selectUserCollectByUserId(Long userId);
|
List<UserCollect> selectUserCollectByUserId(Long userId);
|
||||||
|
|
||||||
List<DevInfoVo> selectDevInfoHotList(DevInfo devInfo);
|
List<DevInfoVo> selectDevInfoHotList(DevInfo devInfo);
|
||||||
|
|
||||||
|
|
@ -91,7 +93,7 @@ public interface DevInfoMapper {
|
||||||
|
|
||||||
SysDic getSysDicById(Integer id);
|
SysDic getSysDicById(Integer id);
|
||||||
|
|
||||||
// public List<BaseAddress> getBaseAddress();
|
List<BaseAddress> getBaseAddress();
|
||||||
|
|
||||||
String getBaseAddressById(Integer id);
|
String getBaseAddressById(Integer id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.bonus.material.device.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.SysFileInfo;
|
||||||
|
import com.bonus.material.device.domain.TypeInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author syruan
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysFileInfoMapper {
|
||||||
|
|
||||||
|
//根据设备id查询
|
||||||
|
List<SysFileInfo> selectByMaId(Long maId);
|
||||||
|
|
||||||
|
void insertFileInfo(SysFileInfo fileInfo);
|
||||||
|
|
||||||
|
// BmCompanyInfo getBmCompanyInfo(@Param("companyName") String companyName);
|
||||||
|
|
||||||
|
TypeInfo getTypeInfo(@Param("deviceName") String deviceName);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.bonus.material.device.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.material.device.domain.DevInfo;
|
||||||
|
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息Service接口
|
||||||
|
*
|
||||||
|
* @author syruan
|
||||||
|
*/
|
||||||
|
public interface DevInfoService {
|
||||||
|
/**
|
||||||
|
* 查询设备信息
|
||||||
|
*
|
||||||
|
* @param maId 设备信息主键
|
||||||
|
* @return 设备信息
|
||||||
|
*/
|
||||||
|
public DevInfoVo selectDevInfoByMaId(Long maId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备信息列表
|
||||||
|
*
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
* @return 设备信息集合
|
||||||
|
*/
|
||||||
|
public List<DevInfoVo> selectDevInfoList(DevInfoVo devInfo);
|
||||||
|
|
||||||
|
List<DevInfoVo> selectUserCollectList(DevInfoVo devInfo);
|
||||||
|
|
||||||
|
public List<DevInfoVo> selectDevInfoHotList(DevInfoVo devInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备信息
|
||||||
|
*
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertDevInfo(DevInfo devInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备信息
|
||||||
|
*
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateDevInfo(DevInfo devInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除设备信息
|
||||||
|
*
|
||||||
|
* @param maIds 需要删除的设备信息主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteDevInfoByMaIds(Long[] maIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备信息信息
|
||||||
|
*
|
||||||
|
* @param maId 设备信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteDevInfoByMaId(Long maId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息录入
|
||||||
|
* @param inforMationDto
|
||||||
|
* @return
|
||||||
|
|
||||||
|
int insertInforMationDto(InforMationDto inforMationDto);*/
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, Integer> sumType();
|
||||||
|
|
||||||
|
List<DevInfoVo> selectDevInfoLists(DevInfoVo devInfo);
|
||||||
|
|
||||||
|
void insertOutType(String devInfo);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,336 @@
|
||||||
|
package com.bonus.material.device.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.bonus.common.biz.domain.*;
|
||||||
|
import com.bonus.common.biz.enums.MaStatusEnum;
|
||||||
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
|
import com.bonus.material.device.domain.DevInfo;
|
||||||
|
import com.bonus.material.device.domain.TypeInfo;
|
||||||
|
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||||
|
import com.bonus.material.device.mapper.DevInfoMapper;
|
||||||
|
import com.bonus.material.device.mapper.SysFileInfoMapper;
|
||||||
|
import com.bonus.material.device.service.DevInfoService;
|
||||||
|
import com.bonus.system.api.model.LoginUser;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author syruan
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class DevInfoServiceImpl implements DevInfoService {
|
||||||
|
private final Integer ASPECT_PICTURE = 20;
|
||||||
|
private final Integer EXAMINATION_PDF = 28;
|
||||||
|
private final Integer INSURANCE_PDF = 29;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DevInfoMapper devInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysFileInfoMapper sysFileInfoMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备信息
|
||||||
|
*
|
||||||
|
* @param maId 设备信息主键
|
||||||
|
* @return 设备信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DevInfoVo selectDevInfoByMaId(Long maId) {
|
||||||
|
DevInfoVo devInfoVo = devInfoMapper.selectDevInfoByMaId(maId);
|
||||||
|
//更新搜索量
|
||||||
|
updateHotSearch(maId);
|
||||||
|
try {
|
||||||
|
List<SysFile> files = devInfoMapper.getFilesByMaId(maId);
|
||||||
|
if (!CollectionUtils.isEmpty(files) && files.get(0) != null) {
|
||||||
|
List<String> picList = new ArrayList<>();
|
||||||
|
for (SysFile file : files) {
|
||||||
|
if (file.getDicId().equals(ASPECT_PICTURE)) {
|
||||||
|
picList.add(file.getUrl());
|
||||||
|
}
|
||||||
|
if (file.getDicId().equals(EXAMINATION_PDF)) {
|
||||||
|
devInfoVo.setExaminationPdf(file.getUrl());
|
||||||
|
}
|
||||||
|
if (file.getDicId().equals(INSURANCE_PDF)) {
|
||||||
|
devInfoVo.setInsurancePdf(file.getUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] pictureArray = null;
|
||||||
|
if (!CollectionUtils.isEmpty(picList)) {
|
||||||
|
pictureArray = picList.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
devInfoVo.setPictures(pictureArray);
|
||||||
|
}
|
||||||
|
Long companyUpNum = devInfoMapper.getCompanyUpNum(devInfoVo.getOwnCo());
|
||||||
|
devInfoVo.setCompanyUpNum(companyUpNum);
|
||||||
|
|
||||||
|
SysDic sysDic = devInfoMapper.getSysDicById(Integer.parseInt(devInfoVo.getMaStatus()));
|
||||||
|
devInfoVo.setMaStatusStr(sysDic.getName());
|
||||||
|
|
||||||
|
List<BaseAddress> addressList = devInfoMapper.getBaseAddress();
|
||||||
|
for (BaseAddress address : addressList) {
|
||||||
|
if (devInfoVo.getProvinceId().equals(Integer.valueOf(address.getCode()))) {
|
||||||
|
devInfoVo.setProvinceStr(address.getName());
|
||||||
|
}
|
||||||
|
if (devInfoVo.getCityId().equals(Integer.valueOf(address.getCode()))) {
|
||||||
|
devInfoVo.setCityStr(address.getName());
|
||||||
|
}
|
||||||
|
if (devInfoVo.getAreaId().equals(Integer.valueOf(address.getCode()))) {
|
||||||
|
devInfoVo.setAreaStr(address.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("fail to get devInfo for files or companyUpNum or maStatusStr" + maId);
|
||||||
|
}
|
||||||
|
return devInfoVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateHotSearch(Long maId) {
|
||||||
|
int count = devInfoMapper.getHotSearchCountByMaId(maId);
|
||||||
|
if (count == 0) {
|
||||||
|
devInfoMapper.insertHotSearch(maId);
|
||||||
|
} else {
|
||||||
|
devInfoMapper.updateHotSearchByMaId(maId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备信息列表
|
||||||
|
*
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
* @return 设备信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DevInfoVo> selectDevInfoList(DevInfoVo devInfo) {
|
||||||
|
List<DevInfoVo> list = devInfoMapper.selectDevInfoList(devInfo);
|
||||||
|
fillInMaStatusStr(list);
|
||||||
|
fillInCityStr(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备收藏列表
|
||||||
|
*
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
* @return 设备信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DevInfoVo> selectUserCollectList(DevInfoVo devInfo) {
|
||||||
|
List<DevInfoVo> result = devInfoMapper.selectDevInfoList(devInfo);
|
||||||
|
LoginUser user = SecurityUtils.getLoginUser();
|
||||||
|
if (Objects.nonNull(user)) {
|
||||||
|
List<UserCollect> userCollectList = devInfoMapper.selectUserCollectByUserId(user.getUserid());
|
||||||
|
result = filterUserCollect(result, userCollectList);
|
||||||
|
}
|
||||||
|
fillInMaStatusStr(result);
|
||||||
|
fillInCityStr(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DevInfoVo> filterUserCollect(List<DevInfoVo> list, List<UserCollect> userCollectList) {
|
||||||
|
List<DevInfoVo> result = new ArrayList<>();
|
||||||
|
for (DevInfoVo devInfoVo : list) {
|
||||||
|
for (UserCollect userCollect : userCollectList) {
|
||||||
|
if (devInfoVo.getMaId().longValue() == userCollect.getMaId().longValue()) {
|
||||||
|
result.add(devInfoVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DevInfoVo> selectDevInfoHotList(DevInfoVo devInfo) {
|
||||||
|
List<DevInfoVo> hotList = devInfoMapper.selectDevInfoHotList(devInfo);
|
||||||
|
fillInMaStatusStr(hotList);
|
||||||
|
fillInCityStr(hotList);
|
||||||
|
return hotList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillInMaStatusStr(List<DevInfoVo> list) {
|
||||||
|
List<SysDic> sysDicList = devInfoMapper.getSysDic();
|
||||||
|
for (DevInfoVo devInfoVo : list) {
|
||||||
|
for (SysDic sysDic : sysDicList) {
|
||||||
|
if (devInfoVo.getMaStatus().equals(String.valueOf(sysDic.getId()))) {
|
||||||
|
devInfoVo.setMaStatusStr(sysDic.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillInCityStr(List<DevInfoVo> list) {
|
||||||
|
List<BaseAddress> addressList = devInfoMapper.getBaseAddress();
|
||||||
|
for (DevInfoVo devInfoVo : list) {
|
||||||
|
for (BaseAddress address : addressList) {
|
||||||
|
if (devInfoVo.getCityId().equals(Integer.valueOf(address.getCode()))) {
|
||||||
|
devInfoVo.setCityStr(address.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增设备信息
|
||||||
|
*
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int insertDevInfo(DevInfo devInfo) {
|
||||||
|
devInfo.setCreateTime(new Date());
|
||||||
|
//获取用户信息
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
//保存用户信息
|
||||||
|
devInfo.setCreator(userId);
|
||||||
|
devInfo.setCode(String.valueOf(UUID.randomUUID()));
|
||||||
|
devInfoMapper.insertDevInfo(devInfo);
|
||||||
|
|
||||||
|
//把文件保存到附件中
|
||||||
|
List<SysFileInfo> fileInfoList = devInfo.getFileList();
|
||||||
|
if (CollectionUtil.isNotEmpty(fileInfoList)){
|
||||||
|
for (SysFileInfo sysFileInfo: fileInfoList) {
|
||||||
|
sysFileInfo.setModelId(Math.toIntExact(devInfo.getMaId()));
|
||||||
|
sysFileInfo.setCreator(String.valueOf(userId));
|
||||||
|
sysFileInfoMapper.insertFileInfo(sysFileInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备信息
|
||||||
|
* @param devInfo 设备信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateDevInfo(DevInfo devInfo) {
|
||||||
|
devInfo.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return devInfoMapper.updateDevInfo(devInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除设备信息
|
||||||
|
*
|
||||||
|
* @param maIds 需要删除的设备信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteDevInfoByMaIds(Long[] maIds)
|
||||||
|
{
|
||||||
|
return devInfoMapper.deleteDevInfoByMaIds(maIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备信息信息
|
||||||
|
*
|
||||||
|
* @param maId 设备信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteDevInfoByMaId(Long maId)
|
||||||
|
{
|
||||||
|
return devInfoMapper.deleteDevInfoByMaId(maId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
* 信息录入
|
||||||
|
* @param inforMationDto
|
||||||
|
* @return
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertInforMationDto(InforMationDto inforMationDto) {
|
||||||
|
DevInfo devInfo = new DevInfo();
|
||||||
|
BeanUtils.copyProperties(inforMationDto, devInfo);
|
||||||
|
devInfoMapper.insertDevInfo(devInfo);
|
||||||
|
return devInfoMapper.insertLon(inforMationDto);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计装备
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Integer> sumType() {
|
||||||
|
DevInfoVo devInfoVo = new DevInfoVo();
|
||||||
|
Map<String, Integer> sumTypeMap = new IdentityHashMap<>();
|
||||||
|
//获取所有的装备信息
|
||||||
|
List<DevInfoVo> devInfoList = devInfoMapper.selectDevInfoList(devInfoVo);
|
||||||
|
//获取每种状态列表
|
||||||
|
Map<String, List<DevInfo>> groupedByMaStatus = devInfoList.stream()
|
||||||
|
.collect(Collectors.groupingBy(DevInfo::getMaStatus));
|
||||||
|
//获取所有的key
|
||||||
|
Set<String> keys = groupedByMaStatus.keySet();
|
||||||
|
//根据key计算每种状态的数量
|
||||||
|
for (String key : keys) {
|
||||||
|
List<DevInfo> deviceList = groupedByMaStatus.get(key);
|
||||||
|
sumTypeMap.put(MaStatusEnum.getNameByCode(Integer.parseInt(key)),deviceList.size());
|
||||||
|
}
|
||||||
|
return sumTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DevInfoVo> selectDevInfoLists(DevInfoVo devInfo) {
|
||||||
|
List<DevInfoVo> list = devInfoMapper.selectDevInfoLists(devInfo);
|
||||||
|
//获取设备的附件
|
||||||
|
for (DevInfoVo devInfoVo: list) {
|
||||||
|
List<SysFileInfo> fileInfoList = sysFileInfoMapper.selectByMaId(devInfoVo.getMaId());
|
||||||
|
devInfoVo.setFileList(fileInfoList);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertOutType(String devInfo) {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
Map<String, Object> map = objectMapper.readValue(devInfo, new TypeReference<Map<String, Object>>() {});
|
||||||
|
//获取公司名称
|
||||||
|
String companyName = (String) map.get("companyName");
|
||||||
|
// TODO 根据公司名称获取公司ID
|
||||||
|
// BmCompanyInfo bmCompanyInfo = sysFileInfoMapper.getBmCompanyInfo(companyName);
|
||||||
|
//获取设备类型名称
|
||||||
|
String deviceName = (String) map.get("deviceName");
|
||||||
|
//根据设备类型名称获取设备类型ID
|
||||||
|
TypeInfo typeInfo = sysFileInfoMapper.getTypeInfo(deviceName);
|
||||||
|
//获取日租金
|
||||||
|
Long leasePrice = (Long) map.get("leasePrice");
|
||||||
|
//设备型号
|
||||||
|
String modelName = (String) map.get("modelName");
|
||||||
|
//出厂日期
|
||||||
|
String outFacTime = (String) map.get("outFacTime");
|
||||||
|
DevInfo devInfo1 = new DevInfo();
|
||||||
|
devInfo1.setCreateTime(new Date());
|
||||||
|
//获取用户信息
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
//保存用户信息
|
||||||
|
devInfo1.setCreator(userId);
|
||||||
|
devInfo1.setCode(String.valueOf(UUID.randomUUID()));
|
||||||
|
// TODO
|
||||||
|
// devInfo1.setOwnCo(Long.valueOf(bmCompanyInfo.getCompanyId()));
|
||||||
|
devInfo1.setTypeId(typeInfo.getTypeId());
|
||||||
|
devInfo1.setJsDayPrice(Float.valueOf(leasePrice));
|
||||||
|
devInfo1.setModelName(modelName);
|
||||||
|
devInfo1.setProductionDate(outFacTime);
|
||||||
|
devInfoMapper.insertDevInfo(devInfo1);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -307,17 +307,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{maId}
|
#{maId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
<select id="productList" parameterType="com.bonus.material.device.domain.DevInfo" resultType="com.bonus.zlpt.equip.api.domain.vo.MaDevInfoVo">
|
|
||||||
select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name
|
|
||||||
from ma_dev_info d
|
|
||||||
left join (select t.*, p.type_name as parent_name
|
|
||||||
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 bm_company_info c on d.own_co = c.company_id
|
|
||||||
|
|
||||||
</select>
|
<select id="selectUserCollectByUserId" parameterType="Long" resultType="com.bonus.common.biz.domain.UserCollect">
|
||||||
|
|
||||||
<select id="selectUserCollectByUserId" parameterType="Long" resultType="java.lang.Object">
|
|
||||||
select id, user_id, ma_id, time from ma_user_collect
|
select id, user_id, ma_id, time from ma_user_collect
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -351,9 +342,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- <select id="getBaseAddress" resultType="com.bonus.zlpt.system.api.domain.BaseAddress">-->
|
<select id="getBaseAddress" resultType="com.bonus.common.biz.domain.BaseAddress">
|
||||||
<!-- select id,name,code from base_address where status = 1-->
|
select id,name,code from base_address where status = 1
|
||||||
<!-- </select>-->
|
</select>
|
||||||
|
|
||||||
<select id="getBaseAddressById" resultType="String">
|
<select id="getBaseAddressById" resultType="String">
|
||||||
select name from base_address where status = 1 and id = #{id}
|
select name from base_address where status = 1 and id = #{id}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue