From 8beb4adab090352b9e2d4b1bf7ee78d7f490a2c8 Mon Sep 17 00:00:00 2001 From: yinq Date: Thu, 9 May 2024 16:56:51 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20add=E7=BB=9F=E8=AE=A1=E5=8D=95?= =?UTF-8?q?=E5=85=83=E4=BF=A1=E6=81=AF=E3=80=81=E7=BB=9F=E8=AE=A1=E8=AE=A1?= =?UTF-8?q?=E9=87=8F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EmsBaseMonitorInfoController.java | 11 + .../EmsBaseMonitorWorkUnitController.java | 100 +++++++ .../controller/EmsBaseWorkUnitController.java | 115 ++++++++ .../ems/base/domain/EmsBaseMonitorInfo.java | 77 +++++- .../base/domain/EmsBaseMonitorWorkUnit.java | 236 ++++++++++++++++ .../os/ems/base/domain/EmsBaseWorkUnit.java | 251 ++++++++++++++++++ .../com/os/ems/base/domain/TreeSelects.java | 102 +++++++ .../mapper/EmsBaseMonitorWorkUnitMapper.java | 61 +++++ .../base/mapper/EmsBaseWorkUnitMapper.java | 61 +++++ .../service/IEmsBaseMonitorInfoService.java | 22 ++ .../IEmsBaseMonitorWorkUnitService.java | 61 +++++ .../base/service/IEmsBaseWorkUnitService.java | 69 +++++ .../impl/EmsBaseMonitorInfoServiceImpl.java | 97 +++++++ .../EmsBaseMonitorWorkUnitServiceImpl.java | 97 +++++++ .../impl/EmsBaseWorkUnitServiceImpl.java | 177 ++++++++++++ .../ems/base/EmsBaseMonitorInfoMapper.xml | 12 +- .../ems/base/EmsBaseMonitorWorkUnitMapper.xml | 133 ++++++++++ .../mapper/ems/base/EmsBaseWorkUnitMapper.xml | 116 ++++++++ 18 files changed, 1779 insertions(+), 19 deletions(-) create mode 100644 os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorWorkUnitController.java create mode 100644 os-ems/src/main/java/com/os/ems/base/controller/EmsBaseWorkUnitController.java create mode 100644 os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorWorkUnit.java create mode 100644 os-ems/src/main/java/com/os/ems/base/domain/EmsBaseWorkUnit.java create mode 100644 os-ems/src/main/java/com/os/ems/base/domain/TreeSelects.java create mode 100644 os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseMonitorWorkUnitMapper.java create mode 100644 os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseWorkUnitMapper.java create mode 100644 os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorWorkUnitService.java create mode 100644 os-ems/src/main/java/com/os/ems/base/service/IEmsBaseWorkUnitService.java create mode 100644 os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorWorkUnitServiceImpl.java create mode 100644 os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java create mode 100644 os-ems/src/main/resources/mapper/ems/base/EmsBaseMonitorWorkUnitMapper.xml create mode 100644 os-ems/src/main/resources/mapper/ems/base/EmsBaseWorkUnitMapper.xml diff --git a/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorInfoController.java b/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorInfoController.java index b2b9b68..7bba90f 100644 --- a/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorInfoController.java +++ b/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorInfoController.java @@ -2,6 +2,8 @@ package com.os.ems.base.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.os.ems.base.domain.TreeSelects; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -44,6 +46,15 @@ public class EmsBaseMonitorInfoController extends BaseController return success(list); } + /** + * 查询计量设备信息下拉树结构 + * */ + @PostMapping("/monitorInfoTree") + public AjaxResult getMonitorInfoTree(EmsBaseMonitorInfo baseMonitorInfo) { + List list = emsBaseMonitorInfoService.selectBaseMonitorInfoTreeList(baseMonitorInfo); + return success(list); + } + /** * 导出计量设备信息列表 */ diff --git a/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorWorkUnitController.java b/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorWorkUnitController.java new file mode 100644 index 0000000..171e99e --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseMonitorWorkUnitController.java @@ -0,0 +1,100 @@ +package com.os.ems.base.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.os.common.annotation.Log; +import com.os.common.core.controller.BaseController; +import com.os.common.core.domain.AjaxResult; +import com.os.common.enums.BusinessType; +import com.os.ems.base.domain.EmsBaseMonitorWorkUnit; +import com.os.ems.base.service.IEmsBaseMonitorWorkUnitService; +import com.os.common.utils.poi.ExcelUtil; +import com.os.common.core.page.TableDataInfo; + +/** + * 统计计量信息Controller + * + * @author Yinq + * @date 2024-05-09 + */ +@RestController +@RequestMapping("/ems/base/baseMonitorWorkUnit") +public class EmsBaseMonitorWorkUnitController extends BaseController { + @Autowired + private IEmsBaseMonitorWorkUnitService emsBaseMonitorWorkUnitService; + + /** + * 查询统计计量信息列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseMonitorWorkUnit:list')") + @GetMapping("/list") + public TableDataInfo list(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) { + startPage(); + List list = emsBaseMonitorWorkUnitService.selectEmsBaseMonitorWorkUnitList(emsBaseMonitorWorkUnit); + return getDataTable(list); + } + + /** + * 导出统计计量信息列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseMonitorWorkUnit:export')") + @Log(title = "统计计量信息" , businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) { + List list = emsBaseMonitorWorkUnitService.selectEmsBaseMonitorWorkUnitList(emsBaseMonitorWorkUnit); + ExcelUtil util = new ExcelUtil(EmsBaseMonitorWorkUnit.class); + util.exportExcel(response, list, "统计计量信息数据"); + } + + /** + * 获取统计计量信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseMonitorWorkUnit:query')") + @GetMapping(value = "/{objId}") + public AjaxResult getInfo(@PathVariable("objId") Long objId) { + return success(emsBaseMonitorWorkUnitService.selectEmsBaseMonitorWorkUnitByObjId(objId)); + } + + /** + * 新增统计计量信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseMonitorWorkUnit:add')") + @Log(title = "统计计量信息" , businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) { + emsBaseMonitorWorkUnit.setCreateBy(getUsername()); + return toAjax(emsBaseMonitorWorkUnitService.insertEmsBaseMonitorWorkUnit(emsBaseMonitorWorkUnit)); + } + + /** + * 修改统计计量信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseMonitorWorkUnit:edit')") + @Log(title = "统计计量信息" , businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) { + emsBaseMonitorWorkUnit.setUpdateBy(getUsername()); + return toAjax(emsBaseMonitorWorkUnitService.updateEmsBaseMonitorWorkUnit(emsBaseMonitorWorkUnit)); + } + + /** + * 删除统计计量信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseMonitorWorkUnit:remove')") + @Log(title = "统计计量信息" , businessType = BusinessType.DELETE) + @DeleteMapping("/{objIds}") + public AjaxResult remove(@PathVariable Long[] objIds) { + return toAjax(emsBaseMonitorWorkUnitService.deleteEmsBaseMonitorWorkUnitByObjIds(objIds)); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseWorkUnitController.java b/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseWorkUnitController.java new file mode 100644 index 0000000..c9254cd --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/controller/EmsBaseWorkUnitController.java @@ -0,0 +1,115 @@ +package com.os.ems.base.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.os.ems.base.domain.TreeSelects; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.os.common.annotation.Log; +import com.os.common.core.controller.BaseController; +import com.os.common.core.domain.AjaxResult; +import com.os.common.enums.BusinessType; +import com.os.ems.base.domain.EmsBaseWorkUnit; +import com.os.ems.base.service.IEmsBaseWorkUnitService; +import com.os.common.utils.poi.ExcelUtil; + +/** + * 统计单元信息Controller + * + * @author Yinq + * @date 2024-05-09 + */ +@RestController +@RequestMapping("/ems/base/baseWorkUnit") +public class EmsBaseWorkUnitController extends BaseController +{ + @Autowired + private IEmsBaseWorkUnitService emsBaseWorkUnitService; + + /** + * 查询统计单元信息列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseWorkUnit:list')") + @GetMapping("/list") + public AjaxResult list(EmsBaseWorkUnit emsBaseWorkUnit) + { + List list = emsBaseWorkUnitService.selectEmsBaseWorkUnitList(emsBaseWorkUnit); + return success(list); + } + + /** + * 查询计量设备信息下拉树结构 + */ + @PostMapping("/workUnitTree") + public AjaxResult getMonitorInfoTree(EmsBaseWorkUnit baseWorkUnit) { + List list = emsBaseWorkUnitService.selectBaseWorkUnitTreeList(baseWorkUnit); + return success(list); + } + + /** + * 导出统计单元信息列表 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseWorkUnit:export')") + @Log(title = "统计单元信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsBaseWorkUnit emsBaseWorkUnit) + { + List list = emsBaseWorkUnitService.selectEmsBaseWorkUnitList(emsBaseWorkUnit); + ExcelUtil util = new ExcelUtil(EmsBaseWorkUnit.class); + util.exportExcel(response, list, "统计单元信息数据"); + } + + /** + * 获取统计单元信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseWorkUnit:query')") + @GetMapping(value = "/{objId}") + public AjaxResult getInfo(@PathVariable("objId") Long objId) + { + return success(emsBaseWorkUnitService.selectEmsBaseWorkUnitByObjId(objId)); + } + + /** + * 新增统计单元信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseWorkUnit:add')") + @Log(title = "统计单元信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsBaseWorkUnit emsBaseWorkUnit) + { + emsBaseWorkUnit.setCreateBy(getUsername()); + return toAjax(emsBaseWorkUnitService.insertEmsBaseWorkUnit(emsBaseWorkUnit)); + } + + /** + * 修改统计单元信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseWorkUnit:edit')") + @Log(title = "统计单元信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsBaseWorkUnit emsBaseWorkUnit) + { + emsBaseWorkUnit.setUpdateBy(getUsername()); + return toAjax(emsBaseWorkUnitService.updateEmsBaseWorkUnit(emsBaseWorkUnit)); + } + + /** + * 删除统计单元信息 + */ + @PreAuthorize("@ss.hasPermi('ems/base:baseWorkUnit:remove')") + @Log(title = "统计单元信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{objIds}") + public AjaxResult remove(@PathVariable Long[] objIds) + { + return toAjax(emsBaseWorkUnitService.deleteEmsBaseWorkUnitByObjIds(objIds)); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorInfo.java b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorInfo.java index 5981c4c..331ca72 100644 --- a/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorInfo.java +++ b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorInfo.java @@ -1,17 +1,21 @@ package com.os.ems.base.domain; +import com.os.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.os.common.annotation.Excel; import com.os.common.core.domain.TreeEntity; +import java.util.ArrayList; +import java.util.List; + /** * 计量设备信息对象 ems_base_monitor_info * * @author Yinq * @date 2024-05-08 */ -public class EmsBaseMonitorInfo extends TreeEntity +public class EmsBaseMonitorInfo extends BaseEntity { private static final long serialVersionUID = 1L; @@ -20,7 +24,7 @@ public class EmsBaseMonitorInfo extends TreeEntity /** 计量设备编号 */ @Excel(name = "计量设备编号") - private String monitorId; + private String monitorCode; /** 计量设备名称 */ @Excel(name = "计量设备名称") @@ -82,7 +86,57 @@ public class EmsBaseMonitorInfo extends TreeEntity @Excel(name = "表具层级") private Long monitorHierarchy; - public void setObjId(Long objId) + private List children = new ArrayList(); + + private String parentName; + + private Long parentId; + + private Integer orderNum; + + private String ancestors; + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public String getParentName() { + return parentName; + } + + public void setParentName(String parentName) { + this.parentName = parentName; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + + public String getAncestors() { + return ancestors; + } + + public void setAncestors(String ancestors) { + this.ancestors = ancestors; + } + + public void setObjId(Long objId) { this.objId = objId; } @@ -91,16 +145,16 @@ public class EmsBaseMonitorInfo extends TreeEntity { return objId; } - public void setMonitorId(String monitorId) - { - this.monitorId = monitorId; + + public String getMonitorCode() { + return monitorCode; } - public String getMonitorId() - { - return monitorId; + public void setMonitorCode(String monitorCode) { + this.monitorCode = monitorCode; } - public void setMonitorName(String monitorName) + + public void setMonitorName(String monitorName) { this.monitorName = monitorName; } @@ -240,14 +294,11 @@ public class EmsBaseMonitorInfo extends TreeEntity public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("objId", getObjId()) - .append("parentId", getParentId()) - .append("monitorId", getMonitorId()) .append("monitorName", getMonitorName()) .append("monitorAddr", getMonitorAddr()) .append("monitorType", getMonitorType()) .append("monitorStatus", getMonitorStatus()) .append("collectDeviceId", getCollectDeviceId()) - .append("ancestors", getAncestors()) .append("grade", getGrade()) .append("meterTypeId", getMeterTypeId()) .append("correctValue", getCorrectValue()) diff --git a/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorWorkUnit.java b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorWorkUnit.java new file mode 100644 index 0000000..e9ea343 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseMonitorWorkUnit.java @@ -0,0 +1,236 @@ +package com.os.ems.base.domain; + +import java.math.BigDecimal; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.os.common.annotation.Excel; +import com.os.common.core.domain.BaseEntity; + +/** + * 统计计量信息对象 ems_base_monitor_work_unit + * + * @author Yinq + * @date 2024-05-09 + */ +public class EmsBaseMonitorWorkUnit extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键标识 + */ + private Long objId; + + /** + * 计量设备编号 + */ + @Excel(name = "计量设备编号") + private String monitorCode; + + /** + * 计量设备名称 + */ + @Excel(name = "计量设备名称") + private String monitorName; + + /** + * 统计单元编号 + */ + @Excel(name = "统计单元编号") + private String workUnitCode; + + /** + * 统计单元名称 + */ + @Excel(name = "统计单元名称") + private String workUnitName; + + /** + * 计量设备状态(0启用 1停用) + */ + @Excel(name = "计量设备状态" , readConverterExp = "0=启用,1=停用") + private Long monitorStatus; + + /** + * 计量设备类型 + */ + @Excel(name = "计量设备类型") + private Long monitorType; + + /** + * 计算方式(0加 1减) + */ + @Excel(name = "计算方式" , readConverterExp = "0=加,1=减") + private Long formulaMode; + + /** + * 比率 + */ + @Excel(name = "比率") + private BigDecimal proportion; + + /** + * 启用标识(0启用 1停用) + */ + @Excel(name = "启用标识" , readConverterExp = "0=启用,1=停用") + private String isFlag; + + /** + * 创建人 + */ + @Excel(name = "创建人") + private String createdBy; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date createdTime; + + /** + * 修改人 + */ + @Excel(name = "修改人") + private String updatedBy; + + /** + * 修改时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "修改时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date updatedTime; + + public String getMonitorName() { + return monitorName; + } + + public void setMonitorName(String monitorName) { + this.monitorName = monitorName; + } + + public String getWorkUnitName() { + return workUnitName; + } + + public void setWorkUnitName(String workUnitName) { + this.workUnitName = workUnitName; + } + + public void setObjId(Long objId) { + this.objId = objId; + } + + public Long getObjId() { + return objId; + } + + public void setMonitorCode(String monitorCode) { + this.monitorCode = monitorCode; + } + + public String getMonitorCode() { + return monitorCode; + } + + public void setWorkUnitCode(String workUnitCode) { + this.workUnitCode = workUnitCode; + } + + public String getWorkUnitCode() { + return workUnitCode; + } + + public void setMonitorStatus(Long monitorStatus) { + this.monitorStatus = monitorStatus; + } + + public Long getMonitorStatus() { + return monitorStatus; + } + + public void setMonitorType(Long monitorType) { + this.monitorType = monitorType; + } + + public Long getMonitorType() { + return monitorType; + } + + public void setFormulaMode(Long formulaMode) { + this.formulaMode = formulaMode; + } + + public Long getFormulaMode() { + return formulaMode; + } + + public void setProportion(BigDecimal proportion) { + this.proportion = proportion; + } + + public BigDecimal getProportion() { + return proportion; + } + + public void setIsFlag(String isFlag) { + this.isFlag = isFlag; + } + + public String getIsFlag() { + return isFlag; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedTime(Date createdTime) { + this.createdTime = createdTime; + } + + public Date getCreatedTime() { + return createdTime; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedTime(Date updatedTime) { + this.updatedTime = updatedTime; + } + + public Date getUpdatedTime() { + return updatedTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("objId" , getObjId()) + .append("monitorCode" , getMonitorCode()) + .append("workUnitCode" , getWorkUnitCode()) + .append("monitorStatus" , getMonitorStatus()) + .append("monitorType" , getMonitorType()) + .append("formulaMode" , getFormulaMode()) + .append("proportion" , getProportion()) + .append("remark" , getRemark()) + .append("isFlag" , getIsFlag()) + .append("createdBy" , getCreatedBy()) + .append("createdTime" , getCreatedTime()) + .append("updatedBy" , getUpdatedBy()) + .append("updatedTime" , getUpdatedTime()) + .toString(); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseWorkUnit.java b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseWorkUnit.java new file mode 100644 index 0000000..fe6365d --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseWorkUnit.java @@ -0,0 +1,251 @@ +package com.os.ems.base.domain; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.os.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.os.common.annotation.Excel; +import com.os.common.core.domain.TreeEntity; + +/** + * 统计单元信息对象 ems_base_work_unit + * + * @author Yinq + * @date 2024-05-09 + */ +public class EmsBaseWorkUnit extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键标识 */ + private Long objId; + + /** 统计单元编号 */ + @Excel(name = "统计单元编号") + private String workUnitCode; + + /** 统计单元名称 */ + @Excel(name = "统计单元名称") + private String workUnitName; + + /** 统计区域 */ + @Excel(name = "统计区域") + private String workUnitAddress; + + /** 排序 */ + @Excel(name = "排序") + private Long workUnitSort; + + /** 产线/工位 */ + @Excel(name = "产线/工位") + private String productLineCode; + + /** 统计单元类型(1建筑) */ + @Excel(name = "统计单元类型", readConverterExp = "1=建筑") + private Long workUnitType; + + /** 启用标识(0启用 1停用) */ + @Excel(name = "启用标识(0启用 1停用)") + private String isFlag; + + /** 创建人 */ + @Excel(name = "创建人") + private String createdBy; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date createdTime; + + /** 更新人 */ + @Excel(name = "更新人") + private String updatedBy; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date updatedTime; + + private List children = new ArrayList(); + + private String parentName; + + private Long parentId; + + private Integer orderNum; + + private String ancestors; + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public String getParentName() { + return parentName; + } + + public void setParentName(String parentName) { + this.parentName = parentName; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public Integer getOrderNum() { + return orderNum; + } + + public void setOrderNum(Integer orderNum) { + this.orderNum = orderNum; + } + + public String getAncestors() { + return ancestors; + } + + public void setAncestors(String ancestors) { + this.ancestors = ancestors; + } + + public void setObjId(Long objId) + { + this.objId = objId; + } + + public Long getObjId() + { + return objId; + } + public void setWorkUnitCode(String workUnitCode) + { + this.workUnitCode = workUnitCode; + } + + public String getWorkUnitCode() + { + return workUnitCode; + } + public void setWorkUnitName(String workUnitName) + { + this.workUnitName = workUnitName; + } + + public String getWorkUnitName() + { + return workUnitName; + } + public void setWorkUnitAddress(String workUnitAddress) + { + this.workUnitAddress = workUnitAddress; + } + + public String getWorkUnitAddress() + { + return workUnitAddress; + } + public void setWorkUnitSort(Long workUnitSort) + { + this.workUnitSort = workUnitSort; + } + + public Long getWorkUnitSort() + { + return workUnitSort; + } + public void setProductLineCode(String productLineCode) + { + this.productLineCode = productLineCode; + } + + public String getProductLineCode() + { + return productLineCode; + } + public void setWorkUnitType(Long workUnitType) + { + this.workUnitType = workUnitType; + } + + public Long getWorkUnitType() + { + return workUnitType; + } + public void setIsFlag(String isFlag) + { + this.isFlag = isFlag; + } + + public String getIsFlag() + { + return isFlag; + } + public void setCreatedBy(String createdBy) + { + this.createdBy = createdBy; + } + + public String getCreatedBy() + { + return createdBy; + } + public void setCreatedTime(Date createdTime) + { + this.createdTime = createdTime; + } + + public Date getCreatedTime() + { + return createdTime; + } + public void setUpdatedBy(String updatedBy) + { + this.updatedBy = updatedBy; + } + + public String getUpdatedBy() + { + return updatedBy; + } + public void setUpdatedTime(Date updatedTime) + { + this.updatedTime = updatedTime; + } + + public Date getUpdatedTime() + { + return updatedTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("objId", getObjId()) + .append("workUnitCode", getWorkUnitCode()) + .append("parentId", getParentId()) + .append("workUnitName", getWorkUnitName()) + .append("workUnitAddress", getWorkUnitAddress()) + .append("ancestors", getAncestors()) + .append("workUnitSort", getWorkUnitSort()) + .append("productLineCode", getProductLineCode()) + .append("workUnitType", getWorkUnitType()) + .append("isFlag", getIsFlag()) + .append("createdBy", getCreatedBy()) + .append("createdTime", getCreatedTime()) + .append("updatedBy", getUpdatedBy()) + .append("updatedTime", getUpdatedTime()) + .toString(); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/domain/TreeSelects.java b/os-ems/src/main/java/com/os/ems/base/domain/TreeSelects.java new file mode 100644 index 0000000..fd2aa4b --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/domain/TreeSelects.java @@ -0,0 +1,102 @@ +package com.os.ems.base.domain; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.os.common.core.domain.entity.SysDept; +import com.os.common.core.domain.entity.SysMenu; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Treeselect树结构实体类 + * + * @author ruoyi + */ +public class TreeSelects implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private Long id; + + /** 节点名称 */ + private String label; + + private String code; + + /** 子节点 */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public TreeSelects() + { + + } + + public TreeSelects(SysDept dept) + { + this.id = dept.getDeptId(); + this.label = dept.getDeptName(); + this.children = dept.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList()); + } + + public TreeSelects(EmsBaseMonitorInfo baseMonitorInfo){ + this.id = baseMonitorInfo.getObjId(); + this.label = baseMonitorInfo.getMonitorName(); + this.code = baseMonitorInfo.getMonitorCode(); + this.children = baseMonitorInfo.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList()); + } + + public TreeSelects(EmsBaseWorkUnit baseWorkUnit){ + this.id = baseWorkUnit.getObjId(); + this.label = baseWorkUnit.getWorkUnitName(); + this.code = baseWorkUnit.getWorkUnitCode(); + this.children = baseWorkUnit.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList()); + } + + public TreeSelects(SysMenu menu) + { + this.id = menu.getMenuId(); + this.label = menu.getMenuName(); + this.children = menu.getChildren().stream().map(TreeSelects::new).collect(Collectors.toList()); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Long getId() + { + return id; + } + + public void setId(Long id) + { + this.id = id; + } + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseMonitorWorkUnitMapper.java b/os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseMonitorWorkUnitMapper.java new file mode 100644 index 0000000..7cdf416 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseMonitorWorkUnitMapper.java @@ -0,0 +1,61 @@ +package com.os.ems.base.mapper; + +import java.util.List; +import com.os.ems.base.domain.EmsBaseMonitorWorkUnit; + +/** + * 统计计量信息Mapper接口 + * + * @author Yinq + * @date 2024-05-09 + */ +public interface EmsBaseMonitorWorkUnitMapper +{ + /** + * 查询统计计量信息 + * + * @param objId 统计计量信息主键 + * @return 统计计量信息 + */ + public EmsBaseMonitorWorkUnit selectEmsBaseMonitorWorkUnitByObjId(Long objId); + + /** + * 查询统计计量信息列表 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 统计计量信息集合 + */ + public List selectEmsBaseMonitorWorkUnitList(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit); + + /** + * 新增统计计量信息 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 结果 + */ + public int insertEmsBaseMonitorWorkUnit(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit); + + /** + * 修改统计计量信息 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 结果 + */ + public int updateEmsBaseMonitorWorkUnit(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit); + + /** + * 删除统计计量信息 + * + * @param objId 统计计量信息主键 + * @return 结果 + */ + public int deleteEmsBaseMonitorWorkUnitByObjId(Long objId); + + /** + * 批量删除统计计量信息 + * + * @param objIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBaseMonitorWorkUnitByObjIds(Long[] objIds); +} diff --git a/os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseWorkUnitMapper.java b/os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseWorkUnitMapper.java new file mode 100644 index 0000000..a8a7aea --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/mapper/EmsBaseWorkUnitMapper.java @@ -0,0 +1,61 @@ +package com.os.ems.base.mapper; + +import java.util.List; +import com.os.ems.base.domain.EmsBaseWorkUnit; + +/** + * 统计单元信息Mapper接口 + * + * @author Yinq + * @date 2024-05-09 + */ +public interface EmsBaseWorkUnitMapper +{ + /** + * 查询统计单元信息 + * + * @param objId 统计单元信息主键 + * @return 统计单元信息 + */ + public EmsBaseWorkUnit selectEmsBaseWorkUnitByObjId(Long objId); + + /** + * 查询统计单元信息列表 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 统计单元信息集合 + */ + public List selectEmsBaseWorkUnitList(EmsBaseWorkUnit emsBaseWorkUnit); + + /** + * 新增统计单元信息 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 结果 + */ + public int insertEmsBaseWorkUnit(EmsBaseWorkUnit emsBaseWorkUnit); + + /** + * 修改统计单元信息 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 结果 + */ + public int updateEmsBaseWorkUnit(EmsBaseWorkUnit emsBaseWorkUnit); + + /** + * 删除统计单元信息 + * + * @param objId 统计单元信息主键 + * @return 结果 + */ + public int deleteEmsBaseWorkUnitByObjId(Long objId); + + /** + * 批量删除统计单元信息 + * + * @param objIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBaseWorkUnitByObjIds(Long[] objIds); +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorInfoService.java b/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorInfoService.java index 5767f61..de4d90d 100644 --- a/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorInfoService.java +++ b/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorInfoService.java @@ -2,6 +2,7 @@ package com.os.ems.base.service; import java.util.List; import com.os.ems.base.domain.EmsBaseMonitorInfo; +import com.os.ems.base.domain.TreeSelects; /** * 计量设备信息Service接口 @@ -58,4 +59,25 @@ public interface IEmsBaseMonitorInfoService * @return 结果 */ public int deleteEmsBaseMonitorInfoByObjId(Long objId); + + /** + * 查询计量设备信息下拉树结构 + * */ + List selectBaseMonitorInfoTreeList(EmsBaseMonitorInfo baseMonitorInfo); + + /** + * 构建前端所需要下拉树结构 + * + * @param + * @return 下拉树结构列表 + */ + public List buildMonitorInfoTreeSelect(List baseMonitorInfos); + + /** + * 构建前端所需要树结构 + * + * @param + * @return 树结构列表 + */ + public List buildMonitorInfoTree(List baseMonitorInfos); } diff --git a/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorWorkUnitService.java b/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorWorkUnitService.java new file mode 100644 index 0000000..b02c952 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseMonitorWorkUnitService.java @@ -0,0 +1,61 @@ +package com.os.ems.base.service; + +import java.util.List; +import com.os.ems.base.domain.EmsBaseMonitorWorkUnit; + +/** + * 统计计量信息Service接口 + * + * @author Yinq + * @date 2024-05-09 + */ +public interface IEmsBaseMonitorWorkUnitService +{ + /** + * 查询统计计量信息 + * + * @param objId 统计计量信息主键 + * @return 统计计量信息 + */ + public EmsBaseMonitorWorkUnit selectEmsBaseMonitorWorkUnitByObjId(Long objId); + + /** + * 查询统计计量信息列表 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 统计计量信息集合 + */ + public List selectEmsBaseMonitorWorkUnitList(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit); + + /** + * 新增统计计量信息 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 结果 + */ + public int insertEmsBaseMonitorWorkUnit(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit); + + /** + * 修改统计计量信息 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 结果 + */ + public int updateEmsBaseMonitorWorkUnit(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit); + + /** + * 批量删除统计计量信息 + * + * @param objIds 需要删除的统计计量信息主键集合 + * @return 结果 + */ + public int deleteEmsBaseMonitorWorkUnitByObjIds(Long[] objIds); + + /** + * 删除统计计量信息信息 + * + * @param objId 统计计量信息主键 + * @return 结果 + */ + public int deleteEmsBaseMonitorWorkUnitByObjId(Long objId); +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseWorkUnitService.java b/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseWorkUnitService.java new file mode 100644 index 0000000..6a7f38c --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/IEmsBaseWorkUnitService.java @@ -0,0 +1,69 @@ +package com.os.ems.base.service; + +import java.util.List; +import com.os.ems.base.domain.EmsBaseWorkUnit; +import com.os.ems.base.domain.TreeSelects; + +/** + * 统计单元信息Service接口 + * + * @author Yinq + * @date 2024-05-09 + */ +public interface IEmsBaseWorkUnitService +{ + /** + * 查询统计单元信息 + * + * @param objId 统计单元信息主键 + * @return 统计单元信息 + */ + public EmsBaseWorkUnit selectEmsBaseWorkUnitByObjId(Long objId); + + /** + * 查询统计单元信息列表 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 统计单元信息集合 + */ + public List selectEmsBaseWorkUnitList(EmsBaseWorkUnit emsBaseWorkUnit); + + /** + * 新增统计单元信息 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 结果 + */ + public int insertEmsBaseWorkUnit(EmsBaseWorkUnit emsBaseWorkUnit); + + /** + * 修改统计单元信息 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 结果 + */ + public int updateEmsBaseWorkUnit(EmsBaseWorkUnit emsBaseWorkUnit); + + /** + * 批量删除统计单元信息 + * + * @param objIds 需要删除的统计单元信息主键集合 + * @return 结果 + */ + public int deleteEmsBaseWorkUnitByObjIds(Long[] objIds); + + /** + * 删除统计单元信息信息 + * + * @param objId 统计单元信息主键 + * @return 结果 + */ + public int deleteEmsBaseWorkUnitByObjId(Long objId); + + List selectBaseWorkUnitTreeList(EmsBaseWorkUnit baseWorkUnit); + + public List buildWorkUnitTreeSelect(List baseWorkUnits); + + public List buildWorkUnitTree(List baseWorkUnits); + +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorInfoServiceImpl.java b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorInfoServiceImpl.java index 51f740d..250af2f 100644 --- a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorInfoServiceImpl.java +++ b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorInfoServiceImpl.java @@ -1,7 +1,13 @@ package com.os.ems.base.service.impl; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; + import com.os.common.utils.DateUtils; +import com.os.common.utils.StringUtils; +import com.os.ems.base.domain.TreeSelects; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.os.ems.base.mapper.EmsBaseMonitorInfoMapper; @@ -93,4 +99,95 @@ public class EmsBaseMonitorInfoServiceImpl implements IEmsBaseMonitorInfoService { return emsBaseMonitorInfoMapper.deleteEmsBaseMonitorInfoByObjId(objId); } + + /** + * 查询计量设备信息下拉树结构 + * */ + @Override + public List selectBaseMonitorInfoTreeList(EmsBaseMonitorInfo baseMonitorInfo) { + List baseMonitorInfos = selectEmsBaseMonitorInfoList(baseMonitorInfo); + return buildMonitorInfoTreeSelect(baseMonitorInfos); + } + + /** + * 构建前端所需要下拉树结构 + * + * @param + * @return 下拉树结构列表 + */ + @Override + public List buildMonitorInfoTreeSelect(List baseMonitorInfos) + { + List deptTrees = buildMonitorInfoTree(baseMonitorInfos); + return deptTrees.stream().map(TreeSelects::new).collect(Collectors.toList()); + } + + /** + * 构建前端所需要树结构 + * + * @param + * @return 树结构列表 + */ + @Override + public List buildMonitorInfoTree(List baseMonitorInfos) + { + List returnList = new ArrayList(); + List tempList = baseMonitorInfos.stream().map(EmsBaseMonitorInfo::getObjId).collect(Collectors.toList()); + for (EmsBaseMonitorInfo baseMonitorInfo : baseMonitorInfos) + { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(baseMonitorInfo.getParentId())) + { + recursionFn(baseMonitorInfos, baseMonitorInfo); + returnList.add(baseMonitorInfo); + } + } + if (returnList.isEmpty()) + { + returnList = baseMonitorInfos; + } + return returnList; + } + /** + * 递归列表 + */ + private void recursionFn(List list, EmsBaseMonitorInfo t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (EmsBaseMonitorInfo tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + /** + * 得到子节点列表 + */ + private List getChildList(List list, EmsBaseMonitorInfo t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + EmsBaseMonitorInfo n = (EmsBaseMonitorInfo) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getObjId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, EmsBaseMonitorInfo t) + { + return getChildList(list, t).size() > 0; + } + } diff --git a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorWorkUnitServiceImpl.java b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorWorkUnitServiceImpl.java new file mode 100644 index 0000000..ad804a0 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseMonitorWorkUnitServiceImpl.java @@ -0,0 +1,97 @@ +package com.os.ems.base.service.impl; + +import java.util.List; + +import com.os.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.os.ems.base.mapper.EmsBaseMonitorWorkUnitMapper; +import com.os.ems.base.domain.EmsBaseMonitorWorkUnit; +import com.os.ems.base.service.IEmsBaseMonitorWorkUnitService; + +/** + * 统计计量信息Service业务层处理 + * + * @author Yinq + * @date 2024-05-09 + */ +@Service +public class EmsBaseMonitorWorkUnitServiceImpl implements IEmsBaseMonitorWorkUnitService +{ + @Autowired + private EmsBaseMonitorWorkUnitMapper emsBaseMonitorWorkUnitMapper; + + /** + * 查询统计计量信息 + * + * @param objId 统计计量信息主键 + * @return 统计计量信息 + */ + @Override + public EmsBaseMonitorWorkUnit selectEmsBaseMonitorWorkUnitByObjId(Long objId) + { + return emsBaseMonitorWorkUnitMapper.selectEmsBaseMonitorWorkUnitByObjId(objId); + } + + /** + * 查询统计计量信息列表 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 统计计量信息 + */ + @Override + public List selectEmsBaseMonitorWorkUnitList(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) + { + emsBaseMonitorWorkUnit.setCreateTime(DateUtils.getNowDate()); + return emsBaseMonitorWorkUnitMapper.selectEmsBaseMonitorWorkUnitList(emsBaseMonitorWorkUnit); + } + + /** + * 新增统计计量信息 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 结果 + */ + @Override + public int insertEmsBaseMonitorWorkUnit(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) + { + emsBaseMonitorWorkUnit.setUpdateTime(DateUtils.getNowDate()); + return emsBaseMonitorWorkUnitMapper.insertEmsBaseMonitorWorkUnit(emsBaseMonitorWorkUnit); + } + + /** + * 修改统计计量信息 + * + * @param emsBaseMonitorWorkUnit 统计计量信息 + * @return 结果 + */ + @Override + public int updateEmsBaseMonitorWorkUnit(EmsBaseMonitorWorkUnit emsBaseMonitorWorkUnit) + { + return emsBaseMonitorWorkUnitMapper.updateEmsBaseMonitorWorkUnit(emsBaseMonitorWorkUnit); + } + + /** + * 批量删除统计计量信息 + * + * @param objIds 需要删除的统计计量信息主键 + * @return 结果 + */ + @Override + public int deleteEmsBaseMonitorWorkUnitByObjIds(Long[] objIds) + { + return emsBaseMonitorWorkUnitMapper.deleteEmsBaseMonitorWorkUnitByObjIds(objIds); + } + + /** + * 删除统计计量信息信息 + * + * @param objId 统计计量信息主键 + * @return 结果 + */ + @Override + public int deleteEmsBaseMonitorWorkUnitByObjId(Long objId) + { + return emsBaseMonitorWorkUnitMapper.deleteEmsBaseMonitorWorkUnitByObjId(objId); + } +} diff --git a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java new file mode 100644 index 0000000..18144c2 --- /dev/null +++ b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java @@ -0,0 +1,177 @@ +package com.os.ems.base.service.impl; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +import com.os.common.utils.DateUtils; +import com.os.common.utils.StringUtils; +import com.os.ems.base.domain.TreeSelects; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.os.ems.base.mapper.EmsBaseWorkUnitMapper; +import com.os.ems.base.domain.EmsBaseWorkUnit; +import com.os.ems.base.service.IEmsBaseWorkUnitService; + +/** + * 统计单元信息Service业务层处理 + * + * @author Yinq + * @date 2024-05-09 + */ +@Service +public class EmsBaseWorkUnitServiceImpl implements IEmsBaseWorkUnitService +{ + @Autowired + private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper; + + /** + * 查询统计单元信息 + * + * @param objId 统计单元信息主键 + * @return 统计单元信息 + */ + @Override + public EmsBaseWorkUnit selectEmsBaseWorkUnitByObjId(Long objId) + { + return emsBaseWorkUnitMapper.selectEmsBaseWorkUnitByObjId(objId); + } + + /** + * 查询统计单元信息列表 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 统计单元信息 + */ + @Override + public List selectEmsBaseWorkUnitList(EmsBaseWorkUnit emsBaseWorkUnit) + { + return emsBaseWorkUnitMapper.selectEmsBaseWorkUnitList(emsBaseWorkUnit); + } + + /** + * 新增统计单元信息 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 结果 + */ + @Override + public int insertEmsBaseWorkUnit(EmsBaseWorkUnit emsBaseWorkUnit) + { + emsBaseWorkUnit.setCreateTime(DateUtils.getNowDate()); + return emsBaseWorkUnitMapper.insertEmsBaseWorkUnit(emsBaseWorkUnit); + } + + /** + * 修改统计单元信息 + * + * @param emsBaseWorkUnit 统计单元信息 + * @return 结果 + */ + @Override + public int updateEmsBaseWorkUnit(EmsBaseWorkUnit emsBaseWorkUnit) + { + emsBaseWorkUnit.setUpdateTime(DateUtils.getNowDate()); + return emsBaseWorkUnitMapper.updateEmsBaseWorkUnit(emsBaseWorkUnit); + } + + /** + * 批量删除统计单元信息 + * + * @param objIds 需要删除的统计单元信息主键 + * @return 结果 + */ + @Override + public int deleteEmsBaseWorkUnitByObjIds(Long[] objIds) + { + return emsBaseWorkUnitMapper.deleteEmsBaseWorkUnitByObjIds(objIds); + } + + /** + * 删除统计单元信息信息 + * + * @param objId 统计单元信息主键 + * @return 结果 + */ + @Override + public int deleteEmsBaseWorkUnitByObjId(Long objId) + { + return emsBaseWorkUnitMapper.deleteEmsBaseWorkUnitByObjId(objId); + } + + @Override + public List selectBaseWorkUnitTreeList(EmsBaseWorkUnit baseWorkUnit) { + List baseWorkUnits = selectEmsBaseWorkUnitList(baseWorkUnit); + return buildWorkUnitTreeSelect(baseWorkUnits); + } + + @Override + public List buildWorkUnitTreeSelect(List baseWorkUnits) { + List baseWorkUnitsTrees = buildWorkUnitTree(baseWorkUnits); + return baseWorkUnitsTrees.stream().map(TreeSelects::new).collect(Collectors.toList()); + } + + @Override + public List buildWorkUnitTree(List baseWorkUnits) { + List returnList = new ArrayList(); + List tempList = baseWorkUnits.stream().map(EmsBaseWorkUnit::getObjId).collect(Collectors.toList()); + for (EmsBaseWorkUnit baseWorkUnit : baseWorkUnits) + { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(baseWorkUnit.getParentId())) + { + recursionFn(baseWorkUnits, baseWorkUnit); + returnList.add(baseWorkUnit); + } + } + if (returnList.isEmpty()) + { + returnList = baseWorkUnits; + } + return returnList; + } + + /** + * 递归列表 + */ + private void recursionFn(List list, EmsBaseWorkUnit t) + { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (EmsBaseWorkUnit tChild : childList) + { + if (hasChild(list, tChild)) + { + recursionFn(list, tChild); + } + } + } + + /** + * 得到子节点列表 + */ + private List getChildList(List list, EmsBaseWorkUnit t) + { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) + { + EmsBaseWorkUnit n = (EmsBaseWorkUnit) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getObjId().longValue()) + { + tlist.add(n); + } + } + return tlist; + } + + /** + * 判断是否有子节点 + */ + private boolean hasChild(List list, EmsBaseWorkUnit t) + { + return getChildList(list, t).size() > 0; + } +} diff --git a/os-ems/src/main/resources/mapper/ems/base/EmsBaseMonitorInfoMapper.xml b/os-ems/src/main/resources/mapper/ems/base/EmsBaseMonitorInfoMapper.xml index d04b27a..988c4b9 100644 --- a/os-ems/src/main/resources/mapper/ems/base/EmsBaseMonitorInfoMapper.xml +++ b/os-ems/src/main/resources/mapper/ems/base/EmsBaseMonitorInfoMapper.xml @@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -31,14 +31,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select obj_id, parent_id, monitor_id, monitor_name, monitor_addr, monitor_type, monitor_status, collect_device_id, ancestors, grade, meter_type_id, correct_value, pt, ct, is_ammeter, is_key_monitor, is_circuit, create_by, create_time, update_by, update_time, public_share_type, monitor_hierarchy from ems_base_monitor_info + select obj_id, parent_id, monitor_code, monitor_name, monitor_addr, monitor_type, monitor_status, collect_device_id, ancestors, grade, meter_type_id, correct_value, pt, ct, is_ammeter, is_key_monitor, is_circuit, create_by, create_time, update_by, update_time, public_share_type, monitor_hierarchy from ems_base_monitor_info + + + and ebmwu.monitor_code = #{monitorCode} + and ebmwu.work_unit_code = #{workUnitCode} + and ebmwu.monitor_status = #{monitorStatus} + and ebmwu.monitor_type = #{monitorType} + and ebmwu.formula_mode = #{formulaMode} + and ebmwu.proportion = #{proportion} + and ebmwu.is_flag = #{isFlag} + and ebmwu.created_by = #{createdBy} + and ebmwu.created_time = #{createdTime} + and ebmwu.updated_by = #{updatedBy} + and ebmwu.updated_time = #{updatedTime} + + + + + + + insert into ems_base_monitor_work_unit + + monitor_code, + work_unit_code, + monitor_status, + monitor_type, + formula_mode, + proportion, + remark, + is_flag, + created_by, + created_time, + updated_by, + updated_time, + + + #{monitorCode}, + #{workUnitCode}, + #{monitorStatus}, + #{monitorType}, + #{formulaMode}, + #{proportion}, + #{remark}, + #{isFlag}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + + + + + update ems_base_monitor_work_unit + + monitor_code = #{monitorCode}, + work_unit_code = #{workUnitCode}, + monitor_status = #{monitorStatus}, + monitor_type = #{monitorType}, + formula_mode = #{formulaMode}, + proportion = #{proportion}, + remark = #{remark}, + is_flag = #{isFlag}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, + + where obj_id = #{objId} + + + + delete + from ems_base_monitor_work_unit + where obj_id = #{objId} + + + + delete from ems_base_monitor_work_unit where obj_id in + + #{objId} + + + \ No newline at end of file diff --git a/os-ems/src/main/resources/mapper/ems/base/EmsBaseWorkUnitMapper.xml b/os-ems/src/main/resources/mapper/ems/base/EmsBaseWorkUnitMapper.xml new file mode 100644 index 0000000..e1a746e --- /dev/null +++ b/os-ems/src/main/resources/mapper/ems/base/EmsBaseWorkUnitMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + select obj_id, work_unit_code, parent_id, work_unit_name, work_unit_address, ancestors, work_unit_sort, product_line_code, work_unit_type, is_flag, created_by, created_time, updated_by, updated_time from ems_base_work_unit + + + + + + + + insert into ems_base_work_unit + + work_unit_code, + parent_id, + work_unit_name, + work_unit_address, + ancestors, + work_unit_sort, + product_line_code, + work_unit_type, + is_flag, + created_by, + created_time, + updated_by, + updated_time, + + + #{workUnitCode}, + #{parentId}, + #{workUnitName}, + #{workUnitAddress}, + #{ancestors}, + #{workUnitSort}, + #{productLineCode}, + #{workUnitType}, + #{isFlag}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + + + + + update ems_base_work_unit + + work_unit_code = #{workUnitCode}, + parent_id = #{parentId}, + work_unit_name = #{workUnitName}, + work_unit_address = #{workUnitAddress}, + ancestors = #{ancestors}, + work_unit_sort = #{workUnitSort}, + product_line_code = #{productLineCode}, + work_unit_type = #{workUnitType}, + is_flag = #{isFlag}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, + + where obj_id = #{objId} + + + + delete from ems_base_work_unit where obj_id = #{objId} + + + + delete from ems_base_work_unit where obj_id in + + #{objId} + + + \ No newline at end of file