Browse Source

创新-设备子系统-设备bom,复制子项目接口

sucheng 1 year ago
parent
commit
d8d8bc994e

+ 8 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/dao/AspCheckItemsDao.java

@@ -0,0 +1,8 @@
+package com.rongwei.bscommon.sys.dao;
+
+
+import com.rongwei.bsentity.domain.AspCheckItems;
+import com.rongwei.rwcommon.base.BaseDao;
+
+public interface AspCheckItemsDao extends BaseDao<AspCheckItems> {
+}

+ 16 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/dao/EquBomMapperDao.java

@@ -0,0 +1,16 @@
+package com.rongwei.bscommon.sys.dao;
+
+import com.rongwei.bsentity.domain.EquBomDo;
+import com.rongwei.rwcommon.base.BaseDao;
+
+/**
+ * <p>
+ * 设备子系统——设备Bom Mapper 接口
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+public interface EquBomMapperDao extends BaseDao<EquBomDo> {
+
+}

+ 17 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/AspCheckItemsService.java

@@ -0,0 +1,17 @@
+package com.rongwei.bscommon.sys.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.domain.AspCheckItems;
+import com.rongwei.bsentity.dto.EquBomCopyDto;
+
+/**
+ * <p>
+ * 设备子系统——设备 服务类
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+public interface AspCheckItemsService extends IService<AspCheckItems> {
+}

+ 20 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/EquBomService.java

@@ -0,0 +1,20 @@
+package com.rongwei.bscommon.sys.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.domain.EquBomDo;
+import com.rongwei.bsentity.domain.EquOverhaulInventoryDo;
+import com.rongwei.bsentity.dto.EquBomCopyDto;
+
+/**
+ * <p>
+ * 设备子系统——设备Bom 服务类
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+public interface EquBomService extends IService<EquBomDo> {
+
+    void copyChilds(EquBomCopyDto request);
+}

+ 25 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/AspCheckItemsServiceImpl.java

@@ -0,0 +1,25 @@
+package com.rongwei.bscommon.sys.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bscommon.sys.dao.AspCheckItemsDao;
+import com.rongwei.bscommon.sys.service.AspCheckItemsService;
+import com.rongwei.bsentity.domain.AspCheckItems;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 设备子系统——设备 服务实现类
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+@Service
+public class AspCheckItemsServiceImpl extends ServiceImpl<AspCheckItemsDao, AspCheckItems> implements AspCheckItemsService {
+
+    private static final Logger logger = LoggerFactory.getLogger(AspCheckItemsServiceImpl.class);
+
+
+}

+ 94 - 0
cx-equipment/cx-equipment-common/src/main/java/com/rongwei/bscommon/sys/service/impl/EquBomServiceImpl.java

@@ -0,0 +1,94 @@
+package com.rongwei.bscommon.sys.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bscommon.sys.dao.EquBomMapperDao;
+import com.rongwei.bscommon.sys.dao.EquOverhaulInventoryMapperDao;
+import com.rongwei.bscommon.sys.service.AspCheckItemsService;
+import com.rongwei.bscommon.sys.service.EquBomService;
+import com.rongwei.bscommon.sys.service.EquOverhaulInventoryService;
+import com.rongwei.bsentity.domain.AspCheckItems;
+import com.rongwei.bsentity.domain.EquBomDo;
+import com.rongwei.bsentity.domain.EquOverhaulInventoryDo;
+import com.rongwei.bsentity.dto.EquBomCopyDto;
+import com.rongwei.rwcommon.base.exception.CustomException;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 设备子系统——设备Bom 服务实现类
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+@Service
+public class EquBomServiceImpl extends ServiceImpl<EquBomMapperDao, EquBomDo> implements EquBomService {
+
+    private static final Logger logger = LoggerFactory.getLogger(EquBomServiceImpl.class);
+
+    @Autowired
+    private AspCheckItemsService aspCheckItemsService;
+
+
+    @Override
+    @Transactional
+    public void copyChilds(EquBomCopyDto request) {
+        if (ObjectUtil.isEmpty(request.getFromEquId())){
+            throw new CustomException("当前物料ID不可为空");
+        }
+        if (ObjectUtil.isEmpty(request.getToEquId())){
+            throw new CustomException("复制到物料ID不可为空");
+        }
+        //查询目标设备的设备信息
+        AspCheckItems toEqu = aspCheckItemsService.getById(request.getToEquId());
+
+        //迭代复制
+        copyChildsByParentId(request.getFromEquId(), request.getToEquId(), toEqu.getCheckitemareaid(), toEqu.getChargeorgcid());
+
+    }
+
+    private void copyChildsByParentId(String fromEquId, String toEquId, String checkItemAreaId, String chargeOrgcId) {
+        //根据父,查询子集(来源)
+        List<EquBomDo> equFromBomDos = this.baseMapper.selectList(new QueryWrapper<EquBomDo>().lambda().eq(EquBomDo::getPid, fromEquId));
+        //根据父,查询子集(目标)
+        List<EquBomDo> equToBomDos = this.baseMapper.selectList(new QueryWrapper<EquBomDo>().lambda().eq(EquBomDo::getPid, toEquId));
+        //获取目标的子集编号
+        List<String> toBomMaterialNumList = equToBomDos.stream().map(item -> {
+            return item.getMaterialNum();
+        }).collect(Collectors.toList());
+
+        //遍历子集
+        for (EquBomDo equBomDo : equFromBomDos) {
+            //判断子集的编号是否重复
+            //如果不重复,则复制
+            if (!toBomMaterialNumList.contains(equBomDo.getMaterialNum())){
+                EquBomDo newEquBomDo = BeanUtil.copyProperties(equBomDo, EquBomDo.class);
+                newEquBomDo.setPid(toEquId);
+                //防止主键冲突
+                newEquBomDo.setId(SecurityUtil.getUUID());
+//                newEquBomDo.setFullPid();
+                //增加设备的树字段
+                newEquBomDo.setCheckItemAreaId(checkItemAreaId);
+                newEquBomDo.setChargeOrgId(chargeOrgcId);
+                //复制
+                this.save(newEquBomDo);
+
+                //开始迭代
+                copyChildsByParentId(equBomDo.getId(), newEquBomDo.getId(), checkItemAreaId, chargeOrgcId);
+
+            }
+
+        }
+    }
+}

+ 355 - 0
cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/domain/AspCheckItems.java

@@ -0,0 +1,355 @@
+package com.rongwei.bsentity.domain;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * asp_check_items
+ * @author 
+ */
+@Data
+public class AspCheckItems implements Serializable {
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 检查项名称
+     */
+    private String checkitemname;
+
+    /**
+     * 检查项编号
+     */
+    private String checkitemcode;
+
+    /**
+     * 检查项类型
+     */
+    private String checkitemtype;
+
+    /**
+     * 检查项所属区域ID
+     */
+    private String checkitemareaid;
+
+    /**
+     * 年检日期
+     */
+    private Date yearlyinspectiondate;
+
+    /**
+     * 提前预警天数
+     */
+    private Integer earlywarndays;
+
+    /**
+     * 设备用途
+     */
+    private String equipmentusage;
+
+    /**
+     * 检查对象负责人IDS
+     */
+    private String chargeuserid;
+
+    /**
+     * 检查对象负责人名称
+     */
+    private String chargeusername;
+
+    /**
+     * 检查对象负责组织二级机构ID
+     */
+    private String chargeorgpid;
+
+    /**
+     * 检查对象负责组织二级机构名称
+     */
+    private String chargeorgpname;
+
+    /**
+     * 检查对象负责组织一级机构ID
+     */
+    private String chargeorgcid;
+
+    /**
+     * 检查对象负责组织一级机构名称
+     */
+    private String chargeorgcname;
+
+    /**
+     * 检查对象负责组织机构ID
+     */
+    private String chargeorgid;
+
+    /**
+     * 检查对象负责组织机构名称
+     */
+    private String chargeorgname;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 启用/禁用
+     */
+    private String enabled;
+
+    /**
+     * 租户ID
+     */
+    private String tenantid;
+
+    /**
+     * 扩展json格式配置
+     */
+    private String roption;
+
+    /**
+     * 是否删除Y/N
+     */
+    private String deleted;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 创建时间
+     */
+    private Date createdate;
+
+    /**
+     * 创建用户ID
+     */
+    private String createuserid;
+
+    /**
+     * 修改日期
+     */
+    private Date modifydate;
+
+    /**
+     * 修改用户ID
+     */
+    private String modifyuserid;
+
+    /**
+     * 创建人名称
+     */
+    private String createusername;
+
+    /**
+     * 修改人名称
+     */
+    private String modifyusername;
+
+    /**
+     * 是否备用
+     */
+    private String standby;
+
+    /**
+     * 规格型号
+     */
+    private String devicemodel;
+
+    /**
+     * 出厂编号
+     */
+    private String deviceoutcode;
+
+    /**
+     * 安装地点
+     */
+    private String deviceaddress;
+
+    /**
+     * 制造单位名称
+     */
+    private String devicenakedname;
+
+    /**
+     * 设备代码
+     */
+    private String devicecode;
+
+    /**
+     * 注册代码
+     */
+    private String signupcode;
+
+    /**
+     * 设备制造日期
+     */
+    private Date devicecreatedate;
+
+    /**
+     * 检验日期
+     */
+    private Date devicecheckdate;
+
+    /**
+     * 下次检验日期
+     */
+    private Date nextcheckdate;
+
+    /**
+     * 环保号
+     */
+    private String environmentalprotectionno;
+
+    /**
+     * 备案号
+     */
+    private String filingno;
+
+    /**
+     * 使用登记证编号
+     */
+    private String registrationno;
+
+    /**
+     * 设备状态
+     */
+    private String devicestatus;
+
+    /**
+     * 设备分类
+     */
+    private String devicesort;
+
+    /**
+     * 类别
+     */
+    private String category;
+
+    /**
+     * 年限
+     */
+    private Integer life;
+
+    /**
+     * 预计提醒日期
+     */
+    private Date warndate;
+
+    /**
+     * 公称直径(mm)
+     */
+    private String nominaldiameter;
+
+    /**
+     * 公称壁厚(mm)
+     */
+    private String nominalwallthickness;
+
+    /**
+     * 管道长度(m)
+     */
+    private String pipelinelength;
+
+    /**
+     * 管道总长度(m)
+     */
+    private String pipelinelengthsum;
+
+    /**
+     * 压力(Mpa)
+     */
+    private String pressure;
+
+    /**
+     * 温度(°C)
+     */
+    private String temperature;
+
+    /**
+     * 介质
+     */
+    private String medium;
+
+    /**
+     * 备注
+     */
+    private String deviceremark;
+
+    /**
+     * 设备图
+     */
+    private String devicephoto;
+
+    /**
+     * 设备其他资料
+     */
+    private String deviceotherinformation;
+
+    /**
+     * 设备安装日期
+     */
+    private Date deviceinstalldate;
+
+    /**
+     * 设备开始使用日期
+     */
+    private Date devicestartdate;
+
+    /**
+     * 检验结论
+     */
+    private String inspectresult;
+
+    /**
+     * 检验机构名称
+     */
+    private String inspectby;
+
+    /**
+     * 数据来源(0-普通设备 1-特种设备)
+     */
+    private String source;
+
+    /**
+     * 移交设备ID
+     */
+    private String transferid;
+
+    /**
+     * 使用部门车间id
+     */
+    private String usedeptid;
+
+    /**
+     * 使用部门车间名称
+     */
+    private String usedeptname;
+
+    /**
+     * 所属部分
+     */
+    private String belongpart;
+
+    /**
+     * 设备原价值(万元)
+     */
+    private BigDecimal rawvalue;
+
+    /**
+     * 设备性能
+     */
+    private String property;
+
+    /**
+     * 所属工厂
+     */
+    private String ownedfactory;
+
+    private static final long serialVersionUID = 1L;
+}

+ 171 - 0
cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/domain/EquBomDo.java

@@ -0,0 +1,171 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 设备子系统——设备BOM
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("equ_bom")
+public class EquBomDo extends BaseDo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId("ID")
+    private String id;
+
+    /**
+     * 租户ID
+     */
+    @TableField("TENANTID")
+    private String tenantid;
+
+    /**
+     * 扩展json格式配置
+     */
+    @TableField("ROPTION")
+    private String roption;
+
+    /**
+     * 父级ID
+     */
+    @TableField("PID")
+    private String pid;
+
+    /**
+     * 父级全路径
+     */
+    @TableField("FULLPID")
+    private String fullPid;
+
+    /**
+     * 数表结构编号
+     */
+    @TableField("TREECODE")
+    private String treeCode;
+
+    /**
+     * 等级
+     */
+    @TableField("LEVEL")
+    private Integer level;
+
+    /**
+     * 排序
+     */
+    @TableField("SORT")
+    private Integer sort;
+
+    /**
+     * 是否叶子节点
+     */
+    @TableField("ISLEAF")
+    private String isLeaf;
+
+    /**
+     * 检查项所属区域ID
+     */
+    @TableField("CHECKITEMAREAID")
+    private String checkItemAreaId;
+
+    /**
+     * 检查对象负责组织机构ID
+     */
+    @TableField("CHARGEORGID")
+    private String chargeOrgId;
+
+    /**
+     * 检查对象负责组织机构名称
+     */
+    @TableField("CHARGEORGNAME")
+    private String chargeOrgName;
+
+    /**
+     * 物料名称
+     */
+    @TableField("MATERIALNAME")
+    private String materialName;
+
+    /**
+     * 物料编号
+     */
+    @TableField("MATERIALNUM")
+    private String materialNum;
+
+    /**
+     * 规格型号
+     */
+    @TableField("SPEC")
+    private String spec;
+
+    /**
+     * 类别编号
+     */
+    @TableField("TYPENUM")
+    private String typeNum;
+
+    /**
+     * 类别名称
+     */
+    @TableField("TYPENAME")
+    private String typeName;
+
+    /**
+     * 分类
+     */
+    @TableField("CATEGORY")
+    private String category;
+
+    /**
+     * 单位
+     */
+    @TableField("UNIT")
+    private String unit;
+
+    /**
+     * 更换周期
+     */
+    @TableField("CHANGECYCLE")
+    private String changeCycle;
+
+    /**
+     * 需求数量
+     */
+    @TableField("NEEDNUM")
+    private String needNum;
+
+    /**
+     * 标记
+     */
+    @TableField("FLAG")
+    private String flag;
+
+    /**
+     * 设备ID
+     */
+    @TableField("EQUID")
+    private String equId;
+
+
+
+}

+ 17 - 0
cx-equipment/cx-equipment-entity/src/main/java/com/rongwei/bsentity/dto/EquBomCopyDto.java

@@ -0,0 +1,17 @@
+package com.rongwei.bsentity.dto;
+
+import lombok.Data;
+
+/**
+ * @author :sc
+ * @since :2023/11/24
+ */
+@Data
+public class EquBomCopyDto {
+    //被复制设备ID
+    private String fromEquId;
+
+    //被粘贴设备ID
+    private String toEquId;
+
+}

+ 51 - 0
cx-equipment/cx-equipment-server/src/main/java/com/rongwei/bsserver/sys/controller/EquBomController.java

@@ -0,0 +1,51 @@
+package com.rongwei.bsserver.sys.controller;
+
+
+import com.rongwei.bscommon.sys.service.EquBomService;
+import com.rongwei.bscommon.sys.utils.ExceptionUtils;
+import com.rongwei.bsentity.dto.EquBomCopyDto;
+import com.rongwei.rwcommon.base.R;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+
+/**
+ * <p>
+ * 设备子系统——设备bom 前端控制器
+ * </p>
+ *
+ * @author sc
+ * @since 2023-11-24
+ */
+@Controller
+@RequestMapping("/equBom")
+public class EquBomController {
+
+    private static final Logger logger = LoggerFactory.getLogger(EquBomController.class);
+
+    @Autowired
+    private EquBomService equBomService;
+
+
+    /**
+     * 复制设备BOM子项
+     * @param request
+     * @return
+     */
+    @RequestMapping("/copyChilds")
+    public R copyChilds(@RequestBody EquBomCopyDto request){
+        try {
+            logger.info("复制设备BOM子项");
+            equBomService.copyChilds(request);
+        } catch (Exception e) {
+            ExceptionUtils.printExceptionDetail(e,"复制设备BOM子项异常:");
+        }
+        return R.ok("复制设备BOM子项成功");
+    }
+
+}
+