Browse Source

/*修改武汉站现场发现设备类型管理:增加设备类型出现的bug。*/

master
htjcAdmin 9 months ago
parent
commit
3b25a90042
4 changed files with 48 additions and 101 deletions
  1. +8
    -7
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/controller/BasedataDeviceTypeController.java
  2. +24
    -86
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/ProDeviceTypeTreeSelectVO.java
  3. +14
    -6
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceTypeServiceImpl.java
  4. +2
    -2
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/util/ProDeviceTypeTreeSelectUtil.java

+ 8
- 7
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/controller/BasedataDeviceTypeController.java View File

@ -90,9 +90,9 @@ public class BasedataDeviceTypeController extends BaseController {
)
@PostMapping({"/add"})
public AjaxResult add(@RequestBody BasedataDeviceType basedataDevicetype) {
if ("1".equals(this.basedataDeviceTypeService.checkDeviceTypeNameUnique(basedataDevicetype))) {
if ("1".equals(basedataDeviceTypeService.checkDeviceTypeNameUnique(basedataDevicetype))) {
return AjaxResult.error("设备类别'" + basedataDevicetype.getDeviceTypeName() + "'类别名称已存在");
} else if ("1".equals(this.basedataDeviceTypeService.checkDeviceTypeCodeUnique(basedataDevicetype))) {
} else if ("1".equals(basedataDeviceTypeService.checkDeviceTypeCodeUnique(basedataDevicetype))) {
return AjaxResult.error("设备类别'" + basedataDevicetype.getDeviceTypeCode() + "'类别编码已存在");
} else {
basedataDevicetype.setCreateBy(SecurityUtils.getUsername());
@ -102,8 +102,9 @@ public class BasedataDeviceTypeController extends BaseController {
}
try {
return this.toAjax(this.basedataDeviceTypeService.insertBasedataDeviceType(basedataDevicetype));
} catch (Exception var3) {
return toAjax(basedataDeviceTypeService.insertBasedataDeviceType(basedataDevicetype));
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error("添加失败,设备类型编码重复!");
}
}
@ -116,16 +117,16 @@ public class BasedataDeviceTypeController extends BaseController {
)
@PostMapping({"/update"})
public AjaxResult edit(@RequestBody BasedataDeviceType basedataDevicetype) {
if ("1".equals(this.basedataDeviceTypeService.checkDeviceTypeNameUnique(basedataDevicetype))) {
if ("1".equals(basedataDeviceTypeService.checkDeviceTypeNameUnique(basedataDevicetype))) {
return AjaxResult.error("设备类别'" + basedataDevicetype.getDeviceTypeName() + "'修改失败,设备类别名称已存在");
} else if ("1".equals(this.basedataDeviceTypeService.checkDeviceTypeCodeUnique(basedataDevicetype))) {
} else if ("1".equals(basedataDeviceTypeService.checkDeviceTypeCodeUnique(basedataDevicetype))) {
return AjaxResult.error("设备类别'" + basedataDevicetype.getDeviceTypeCode() + "'修改失败,设备类别编码已存在");
} else {
if ("无相别".equals(basedataDevicetype.getPhaseNum())) {
basedataDevicetype.setPhase("O");
}
return this.toAjax(this.basedataDeviceTypeService.updateBasedataDeviceType(basedataDevicetype));
return toAjax(basedataDeviceTypeService.updateBasedataDeviceType(basedataDevicetype));
}
}


+ 24
- 86
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/ProDeviceTypeTreeSelectVO.java View File

@ -1,16 +1,20 @@
package com.inspect.metadata.prodevmnt.domain.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.inspect.base.core.annotation.Excel;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ProDeviceTypeTreeSelectVO {
private static final long serialVersionUID = 1L;
private Long parentId;
private Long devicetypeId;
private Long deviceTypeId;
@Excel(
name = "电力主设备标识-Yes:是;No:否"
)
@ -18,11 +22,13 @@ public class ProDeviceTypeTreeSelectVO {
@Excel(
name = "设备类型名称"
)
private String devicetypeName;
@JsonProperty("devicetypeName")
private String deviceTypeName;
@Excel(
name = "设备编码"
)
private String devicetypeCode;
@JsonProperty("devicetypeCode")
private String deviceTypeCode;
@Excel(
name = "相数,0:无相;1:单项;3:三项"
)
@ -39,89 +45,21 @@ public class ProDeviceTypeTreeSelectVO {
name = "专业类型"
)
private int level;
private List<ProDeviceTypeTreeSelectVO> children = new ArrayList();
public int getLevel() {
return this.level;
}
public void setLevel(int level) {
this.level = level;
}
public Long getParentId() {
return this.parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Long getDevicetypeId() {
return this.devicetypeId;
}
public void setDevicetypeId(Long devicetypeId) {
this.devicetypeId = devicetypeId;
}
public String getPowerMainEquFlag() {
return this.powerMainEquFlag;
}
public void setPowerMainEquFlag(String powerMainEquFlag) {
this.powerMainEquFlag = powerMainEquFlag;
}
public String getDevicetypeName() {
return this.devicetypeName;
}
public void setDevicetypeName(String devicetypeName) {
this.devicetypeName = devicetypeName;
}
public String getDevicetypeCode() {
return this.devicetypeCode;
}
public void setDevicetypeCode(String devicetypeCode) {
this.devicetypeCode = devicetypeCode;
}
public String getPhaseNum() {
return this.phaseNum;
}
public void setPhaseNum(String phaseNum) {
this.phaseNum = phaseNum;
}
public String getPhase() {
return this.phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public String getProfessionType() {
return this.professionType;
}
public void setProfessionType(String professionType) {
this.professionType = professionType;
}
public List<ProDeviceTypeTreeSelectVO> getChildren() {
return this.children;
}
public void setChildren(List<ProDeviceTypeTreeSelectVO> children) {
this.children = children;
}
private List<ProDeviceTypeTreeSelectVO> children = new ArrayList<>();
@Override
public String toString() {
return (new ToStringBuilder(this)).append("parentId", this.parentId).append("devicetypeId", this.devicetypeId).append("powerMainEquFlag", this.powerMainEquFlag).append("devicetypeName", this.devicetypeName).append("devicetypeCode", this.devicetypeCode).append("phaseNum", this.phaseNum).append("phase", this.phase).append("professionType", this.professionType).append("level", this.level).append("children", this.children).toString();
return "ProDeviceTypeTreeSelectVO{" +
"parentId=" + parentId +
", deviceTypeId=" + deviceTypeId +
", powerMainEquFlag='" + powerMainEquFlag + '\'' +
", deviceTypeName='" + deviceTypeName + '\'' +
", deviceTypeCode='" + deviceTypeCode + '\'' +
", phaseNum='" + phaseNum + '\'' +
", phase='" + phase + '\'' +
", professionType='" + professionType + '\'' +
", level=" + level +
", children=" + children +
'}';
}
}

+ 14
- 6
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceTypeServiceImpl.java View File

@ -1,5 +1,6 @@
package com.inspect.metadata.prodevmnt.service.impl;
import com.inspect.base.core.constant.Color;
import com.inspect.metadata.prodevmnt.domain.BasedataDeviceType;
import com.inspect.metadata.prodevmnt.domain.vo.ProDeviceTypeTreeSelectVO;
import com.inspect.metadata.prodevmnt.mapper.BasedataDeviceTypeMapper;
@ -15,10 +16,14 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@Service
public class BasedataDeviceTypeServiceImpl implements IBasedataDeviceTypeService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final BasedataDeviceTypeMapper basedataDevicetypeMapper;
public BasedataDeviceTypeServiceImpl(BasedataDeviceTypeMapper basedataDevicetypeMapper) {
@ -34,11 +39,11 @@ public class BasedataDeviceTypeServiceImpl implements IBasedataDeviceTypeService
}
public int insertBasedataDeviceType(BasedataDeviceType basedataDevicetype) {
BasedataDeviceType info = this.basedataDevicetypeMapper.selectBasedataDeviceTypeByDeviceTypeId(basedataDevicetype.getParentId());
BasedataDeviceType info = basedataDevicetypeMapper.selectBasedataDeviceTypeByDeviceTypeId(basedataDevicetype.getParentId());
basedataDevicetype.setLevel(info.getLevel() + 1);
basedataDevicetype.setAncestors(info.getAncestors() + "," + basedataDevicetype.getParentId());
basedataDevicetype.setCreateTime(DateUtils.getNowDate());
return this.basedataDevicetypeMapper.insertBasedataDeviceType(basedataDevicetype);
return basedataDevicetypeMapper.insertBasedataDeviceType(basedataDevicetype);
}
public int updateBasedataDeviceType(BasedataDeviceType basedataDevicetype) {
@ -62,11 +67,11 @@ public class BasedataDeviceTypeServiceImpl implements IBasedataDeviceTypeService
public String checkDeviceTypeNameUnique(BasedataDeviceType basedataDevicetype) {
long deviceTypeId = StringUtils.isNull(basedataDevicetype.getDeviceTypeId()) ? -1L : basedataDevicetype.getDeviceTypeId();
BasedataDeviceType info = this.basedataDevicetypeMapper.checkDeviceTypeNameUnique(basedataDevicetype.getDeviceTypeName(), basedataDevicetype.getParentId());
BasedataDeviceType info = basedataDevicetypeMapper.checkDeviceTypeNameUnique(basedataDevicetype.getDeviceTypeName(), basedataDevicetype.getParentId());
if (StringUtils.isNotNull(info) && info.getDeviceTypeId() != deviceTypeId) {
return "1";
} else {
BasedataDeviceType subInfo = this.basedataDevicetypeMapper.checkDeviceTypeNameUnique(basedataDevicetype.getDeviceTypeName(), basedataDevicetype.getDeviceTypeId());
BasedataDeviceType subInfo = basedataDevicetypeMapper.checkDeviceTypeNameUnique(basedataDevicetype.getDeviceTypeName(), basedataDevicetype.getDeviceTypeId());
return null != subInfo ? "1" : "0";
}
}
@ -116,7 +121,7 @@ public class BasedataDeviceTypeServiceImpl implements IBasedataDeviceTypeService
public List<ProDeviceTypeTreeSelectVO> getProDeviceTypeTreeSelect(BasedataDeviceType basedataDevicetype) {
List<ProDeviceTypeTreeSelectVO> mainDevVOS = new ArrayList<>();
List<BasedataDeviceType> list = this.basedataDevicetypeMapper.selectBasedataDeviceTypeList(basedataDevicetype);
List<BasedataDeviceType> list = basedataDevicetypeMapper.selectBasedataDeviceTypeList(basedataDevicetype);
if (!list.isEmpty()) {
for (BasedataDeviceType device : list) {
ProDeviceTypeTreeSelectVO proDeviceTreeSelect = new ProDeviceTypeTreeSelectVO();
@ -131,12 +136,15 @@ public class BasedataDeviceTypeServiceImpl implements IBasedataDeviceTypeService
public List<BasedataDeviceType> getCompTypeTreeSelectByMainDeviceTypeId(BasedataDeviceType basedataDevicetype) {
List<BasedataDeviceType> list = this.basedataDevicetypeMapper.selectBasedataDeviceTypeList(basedataDevicetype);
if (null != list && !list.isEmpty()) {
for (BasedataDeviceType deviceType : list) {
this.getDeviceTypeChildByRecursion(deviceType);
}
log.info(Color.GREEN + "[METADATA] basedataDeviceType: {}, res size: {}" + Color.END, basedataDevicetype, list.size());
} else {
log.info(Color.GREEN + "[METADATA] basedataDeviceType: {}, res size: 0" + Color.END, basedataDevicetype);
}
return list;
}


+ 2
- 2
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/util/ProDeviceTypeTreeSelectUtil.java View File

@ -16,7 +16,7 @@ public class ProDeviceTypeTreeSelectUtil {
ProDeviceTypeTreeSelectVO area;
while (iterator.hasNext()) {
area = iterator.next();
tempList.add(area.getDevicetypeId());
tempList.add(area.getDeviceTypeId());
}
iterator = areas.iterator();
@ -51,7 +51,7 @@ public class ProDeviceTypeTreeSelectUtil {
List<ProDeviceTypeTreeSelectVO> tlist = new ArrayList<>();
for (ProDeviceTypeTreeSelectVO n : list) {
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().equals(t.getDevicetypeId())) {
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().equals(t.getDeviceTypeId())) {
tlist.add(n);
}
}


Loading…
Cancel
Save