diff --git a/op-modules/op-device/src/main/java/com/op/device/controller/EquCheckItemController.java b/op-modules/op-device/src/main/java/com/op/device/controller/EquCheckItemController.java index 31d8a3c3..9ff9a90a 100644 --- a/op-modules/op-device/src/main/java/com/op/device/controller/EquCheckItemController.java +++ b/op-modules/op-device/src/main/java/com/op/device/controller/EquCheckItemController.java @@ -35,6 +35,26 @@ public class EquCheckItemController extends BaseController { @Autowired private IEquCheckItemService equCheckItemService; + /** + * 通过检查项code查询关联设备code列表 + * @return + */ + @RequiresPermissions("device:item:list") + @GetMapping(value = "/getEquipmentCodeList/{itemCode}") + public AjaxResult getEquipmentCodeListByItemCode(@PathVariable("itemCode") String itemCode) { + return equCheckItemService.getEquipmentCodeListByItemCode(itemCode); + } + + /** + * 获取全部设备list信息 + * @return + */ + @RequiresPermissions("device:item:list") + @GetMapping("/getEquipmentList") + public AjaxResult getEquipmentList() { + return equCheckItemService.getEquipmentList(); + } + /** * 查询检查项维护列表 */ diff --git a/op-modules/op-device/src/main/java/com/op/device/domain/EquItemEquipment.java b/op-modules/op-device/src/main/java/com/op/device/domain/EquItemEquipment.java new file mode 100644 index 00000000..99f7d1f0 --- /dev/null +++ b/op-modules/op-device/src/main/java/com/op/device/domain/EquItemEquipment.java @@ -0,0 +1,181 @@ +package com.op.device.domain; + +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.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; + +/** + * 检查项/设备关联对象 equ_item_equipment + * + * @author wws + * @date 2023-10-12 + */ +public class EquItemEquipment extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 主键 */ + private String id; + + /** 关联code */ + @Excel(name = "关联code") + private String connCode; + + /** 检查项code */ + @Excel(name = "检查项code") + private String itemCode; + + /** 设备code */ + @Excel(name = "设备code") + private String equipmentCode; + + /** 工厂 */ + @Excel(name = "工厂") + private String factoryCode; + + /** 备用字段1 */ + @Excel(name = "备用字段1") + private String attr1; + + /** 备用字段2 */ + @Excel(name = "备用字段2") + private String attr2; + + /** 备用字段3 */ + @Excel(name = "备用字段3") + private String attr3; + + /** 删除标识 */ + private String delFlag; + + /** 创建人 */ + @Excel(name = "创建人") + private String createdBy; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdTime; + + /** 更新人 */ + @Excel(name = "更新人") + private String updatedBy; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date updatedTime; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + public void setConnCode(String connCode) { + this.connCode = connCode; + } + + public String getConnCode() { + return connCode; + } + public void setItemCode(String itemCode) { + this.itemCode = itemCode; + } + + public String getItemCode() { + return itemCode; + } + public void setEquipmentCode(String equipmentCode) { + this.equipmentCode = equipmentCode; + } + + public String getEquipmentCode() { + return equipmentCode; + } + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryCode() { + return factoryCode; + } + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + public void setAttr3(String attr3) { + this.attr3 = attr3; + } + + public String getAttr3() { + return attr3; + } + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getDelFlag() { + return delFlag; + } + 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("id", getId()) + .append("connCode", getConnCode()) + .append("itemCode", getItemCode()) + .append("equipmentCode", getEquipmentCode()) + .append("factoryCode", getFactoryCode()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("delFlag", getDelFlag()) + .append("createdBy", getCreatedBy()) + .append("createdTime", getCreatedTime()) + .append("updatedBy", getUpdatedBy()) + .append("updatedTime", getUpdatedTime()) + .toString(); + } +} diff --git a/op-modules/op-device/src/main/java/com/op/device/domain/dto/EquCheckItemDTO.java b/op-modules/op-device/src/main/java/com/op/device/domain/dto/EquCheckItemDTO.java index acae10b4..cdc9204f 100644 --- a/op-modules/op-device/src/main/java/com/op/device/domain/dto/EquCheckItemDTO.java +++ b/op-modules/op-device/src/main/java/com/op/device/domain/dto/EquCheckItemDTO.java @@ -59,6 +59,17 @@ public class EquCheckItemDTO { // 创建日期结束 private String createTimeEnd; + // 设备编码list + private List equipmentCodeList; + + public List getEquipmentCodeList() { + return equipmentCodeList; + } + + public void setEquipmentCodeList(List equipmentCodeList) { + this.equipmentCodeList = equipmentCodeList; + } + public List getCreatedTimeArray() { return createdTimeArray; } diff --git a/op-modules/op-device/src/main/java/com/op/device/domain/vo/EquCheckItemVO.java b/op-modules/op-device/src/main/java/com/op/device/domain/vo/EquCheckItemVO.java index 5f4eb3e3..4c98a617 100644 --- a/op-modules/op-device/src/main/java/com/op/device/domain/vo/EquCheckItemVO.java +++ b/op-modules/op-device/src/main/java/com/op/device/domain/vo/EquCheckItemVO.java @@ -41,6 +41,26 @@ public class EquCheckItemVO { private String updatedBy ; // 标准列表 private List formStandard; + // 设备名称 + private String equipmentName; + // 设备编码 + private String equipmentCode; + + public String getEquipmentName() { + return equipmentName; + } + + public void setEquipmentName(String equipmentName) { + this.equipmentName = equipmentName; + } + + public String getEquipmentCode() { + return equipmentCode; + } + + public void setEquipmentCode(String equipmentCode) { + this.equipmentCode = equipmentCode; + } public String getItemId() { return itemId; diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemDetailMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemDetailMapper.java index f741f429..31308191 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemDetailMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemDetailMapper.java @@ -78,4 +78,10 @@ public interface EquCheckItemDetailMapper { * @param itemId */ void deleteEquCheckItemDetailByItemId(String itemId); + + /** + * 逻辑删除-通过检查项id删除标准信息 + * @param itemId + */ + void delEquCheckItemDetailByItemId(String itemId); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemMapper.java index 27e64548..892c7133 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquCheckItemMapper.java @@ -3,6 +3,7 @@ package com.op.device.mapper; import java.util.List; import com.op.device.domain.EquCheckItem; +import com.op.device.domain.vo.EquCheckItemVO; /** * 检查项维护Mapper接口 @@ -71,4 +72,10 @@ public interface EquCheckItemMapper { * @return */ int selectSerialNumber(); + + /** + * 获取全部设备信息name、code + * @return + */ + List selectAllEquipmentList(); } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/EquItemEquipmentMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/EquItemEquipmentMapper.java new file mode 100644 index 00000000..def69bba --- /dev/null +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/EquItemEquipmentMapper.java @@ -0,0 +1,86 @@ +package com.op.device.mapper; + +import java.util.List; + +import com.op.device.domain.EquItemEquipment; + +/** + * 检查项/设备关联Mapper接口 + * + * @author wws + * @date 2023-10-12 + */ +public interface EquItemEquipmentMapper { + /** + * 查询检查项/设备关联 + * + * @param id 检查项/设备关联主键 + * @return 检查项/设备关联 + */ + public EquItemEquipment selectEquItemEquipmentById(String id); + + /** + * 查询检查项/设备关联列表 + * + * @param equItemEquipment 检查项/设备关联 + * @return 检查项/设备关联集合 + */ + public List selectEquItemEquipmentList(EquItemEquipment equItemEquipment); + + /** + * 新增检查项/设备关联 + * + * @param equItemEquipment 检查项/设备关联 + * @return 结果 + */ + public int insertEquItemEquipment(EquItemEquipment equItemEquipment); + + /** + * 修改检查项/设备关联 + * + * @param equItemEquipment 检查项/设备关联 + * @return 结果 + */ + public int updateEquItemEquipment(EquItemEquipment equItemEquipment); + + /** + * 删除检查项/设备关联 + * + * @param id 检查项/设备关联主键 + * @return 结果 + */ + public int deleteEquItemEquipmentById(String id); + + /** + * 批量删除检查项/设备关联 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEquItemEquipmentByIds(String[] ids); + + /** + * 获取流水号 + * @return + */ + int selectSerialNumber(); + + /** + * 通过检查项code查询关联设备code列表 + * @param itemCode + * @return + */ + List selectEquipmentCodeList(String itemCode); + + /** + * 通过检查项code删除关联信息 + * @param itemCode + */ + void deleteEquItemEquipmentByItemCode(String itemCode); + + /** + * 逻辑删除-通过itemId删除设备关联信息 + * @param itemId + */ + void delEquItemEquipmentByItemId(String itemId); +} diff --git a/op-modules/op-device/src/main/java/com/op/device/service/IEquCheckItemService.java b/op-modules/op-device/src/main/java/com/op/device/service/IEquCheckItemService.java index b093e800..d493ec69 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/IEquCheckItemService.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/IEquCheckItemService.java @@ -41,7 +41,7 @@ public interface IEquCheckItemService { /** * 修改检查项维护 * - * @param equCheckItem 检查项维护 + * @param equCheckItemDTO 检查项维护 * @return 结果 */ public AjaxResult updateEquCheckItem(EquCheckItemDTO equCheckItemDTO); @@ -61,4 +61,16 @@ public interface IEquCheckItemService { * @return 结果 */ public int deleteEquCheckItemByItemId(String itemId); + + /** + * 获取全部设备list信息 + * @return + */ + AjaxResult getEquipmentList(); + + /** + * 通过检查项code查询关联设备code列表 + * @return + */ + AjaxResult getEquipmentCodeListByItemCode(String itemCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java index 3838a68a..8f95d4cf 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquCheckItemServiceImpl.java @@ -12,9 +12,11 @@ import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; import com.op.common.log.annotation.Log; import com.op.device.domain.EquCheckItemDetail; +import com.op.device.domain.EquItemEquipment; import com.op.device.domain.dto.EquCheckItemDTO; import com.op.device.domain.vo.EquCheckItemVO; import com.op.device.mapper.EquCheckItemDetailMapper; +import com.op.device.mapper.EquItemEquipmentMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -42,6 +44,8 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { private EquCheckItemMapper equCheckItemMapper; @Autowired private EquCheckItemDetailMapper equCheckItemDetailMapper; + @Autowired + private EquItemEquipmentMapper equItemEquipmentMapper; /** * 查询检查项维护 @@ -96,7 +100,6 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { * * @param equCheckItemDTO 检查项维护 * @return 结果 - * TODO 加事务锁 */ @Override @DS("#header.poolName") @@ -160,6 +163,27 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { equCheckItemDetailMapper.insertEquCheckItemDetail(detail); } + // 处理关联设备信息 + for (String code : equCheckItemDTO.getEquipmentCodeList()) { + EquItemEquipment equItemEquipment = new EquItemEquipment(); + + // 获取流水号 + String cnnSerialNum = String.format("%03d", equItemEquipmentMapper.selectSerialNumber()); + + equItemEquipment.setId(IdUtils.fastSimpleUUID()); + equItemEquipment.setConnCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+cnnSerialNum); + equItemEquipment.setItemCode(equCheckItem.getItemCode()); + equItemEquipment.setEquipmentCode(code); + equItemEquipment.setFactoryCode(factory); + equItemEquipment.setCreatedBy(SecurityContextHolder.getUserName()); + equItemEquipment.setCreatedTime(DateUtils.getNowDate()); + equItemEquipment.setUpdatedBy(SecurityContextHolder.getUserName()); + equItemEquipment.setUpdatedTime(DateUtils.getNowDate()); + + // 插入数据库 + equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment); + } + return success("新增成功"); } @@ -191,9 +215,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { equCheckItemMapper.updateEquCheckItem(equCheckItem); - // 删除所有标准 + // 删除所有该检查项标准 equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(equCheckItem.getItemId()); + // 处理检查项详情信息 for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) { // 获取标准流水号 String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode())); @@ -210,6 +235,30 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { // 插入到数据库 equCheckItemDetailMapper.insertEquCheckItemDetail(detail); } + + // 删除所有该检查项关联设备 + equItemEquipmentMapper.deleteEquItemEquipmentByItemCode(equCheckItemDTO.getItemCode()); + + // 处理关联设备信息 + for (String code : equCheckItemDTO.getEquipmentCodeList()) { + EquItemEquipment equItemEquipment = new EquItemEquipment(); + + // 获取流水号 + String cnnSerialNum = String.format("%03d", equItemEquipmentMapper.selectSerialNumber()); + + equItemEquipment.setId(IdUtils.fastSimpleUUID()); + equItemEquipment.setConnCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+cnnSerialNum); + equItemEquipment.setItemCode(equCheckItem.getItemCode()); + equItemEquipment.setEquipmentCode(code); + equItemEquipment.setFactoryCode(equCheckItemDTO.getFactoryCode()); + equItemEquipment.setCreatedBy(SecurityContextHolder.getUserName()); + equItemEquipment.setCreatedTime(DateUtils.getNowDate()); + equItemEquipment.setUpdatedBy(SecurityContextHolder.getUserName()); + equItemEquipment.setUpdatedTime(DateUtils.getNowDate()); + + // 插入数据库 + equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment); + } return success("修改成功"); } @@ -223,7 +272,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { @DS("#header.poolName") public int deleteEquCheckItemByItemIds(String[] itemIds) { for (String data : itemIds) { - equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(data); + // 逻辑删除检查项详情信息 + equCheckItemDetailMapper.delEquCheckItemDetailByItemId(data); + // 逻辑删除设备关联 + equItemEquipmentMapper.delEquItemEquipmentByItemId(data); } return equCheckItemMapper.deleteEquCheckItemByItemIds(itemIds); } @@ -237,8 +289,32 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService { @Override @DS("#header.poolName") public int deleteEquCheckItemByItemId(String itemId) { - // 通过id删除标准信息 - equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(itemId); + // 逻辑删除标准 + equCheckItemDetailMapper.delEquCheckItemDetailByItemId(itemId); + // 逻辑删除设备关联 + equItemEquipmentMapper.delEquItemEquipmentByItemId(itemId); + return equCheckItemMapper.deleteEquCheckItemByItemId(itemId); } + + /** + * 获取全部设备信息 + * @return + */ + @Override + @DS("#header.poolName") + public AjaxResult getEquipmentList() { + List equipmentList = equCheckItemMapper.selectAllEquipmentList(); + return success(equipmentList); + } + + /** + * 通过检查项code查询关联设备code列表 + * @return + */ + @Override + public AjaxResult getEquipmentCodeListByItemCode(String itemCode) { + List equipmentCodeList = equItemEquipmentMapper.selectEquipmentCodeList(itemCode); + return success(equipmentCodeList); + } } diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemDetailMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemDetailMapper.xml index 41fc3985..0cb9d421 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemDetailMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemDetailMapper.xml @@ -132,18 +132,24 @@ where detail_id = #{detailId} and del_flag = '0' + + delete from equ_check_item_detail + where parent_code = ( + select item_code from equ_check_item where item_id = #{itemId} ) + + - update equ_check_item_detail set del_flag = '1' where detail_id = #{detailId} + delete from equ_check_item_detail where detail_id = #{detailId} - update equ_check_item_detail set del_flag = '1' where detail_id in + delete from equ_check_item_detail where detail_id in #{detailId} - + update equ_check_item_detail set del_flag = '1' where parent_code = ( diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemMapper.xml index 06687e34..5439d400 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/EquCheckItemMapper.xml @@ -12,7 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -68,7 +68,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE CONVERT(date, GETDATE()) = CONVERT(date,created_time) and del_flag = '0' - + + + insert into equ_check_item item_id, diff --git a/op-modules/op-device/src/main/resources/mapper/device/EquItemEquipmentMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/EquItemEquipmentMapper.xml new file mode 100644 index 00000000..10298b93 --- /dev/null +++ b/op-modules/op-device/src/main/resources/mapper/device/EquItemEquipmentMapper.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + select id, conn_code, item_code, equipment_code, factory_code, attr1, attr2, attr3, del_flag, created_by, created_time, updated_by, updated_time from equ_item_equipment + + + + + + + + + + + + insert into equ_item_equipment + + id, + conn_code, + item_code, + equipment_code, + factory_code, + attr1, + attr2, + attr3, + del_flag, + created_by, + created_time, + updated_by, + updated_time, + + + #{id}, + #{connCode}, + #{itemCode}, + #{equipmentCode}, + #{factoryCode}, + #{attr1}, + #{attr2}, + #{attr3}, + #{delFlag}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + + + + + update equ_item_equipment + + conn_code = #{connCode}, + item_code = #{itemCode}, + equipment_code = #{equipmentCode}, + factory_code = #{factoryCode}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + del_flag = #{delFlag}, + created_by = #{createdBy}, + created_time = #{createdTime}, + updated_by = #{updatedBy}, + updated_time = #{updatedTime}, + + where id = #{id} and del_flag = '0' + + + + delete from equ_item_equipment where id = #{id} + + + + delete from equ_item_equipment where id in + + #{id} + + + + + delete from equ_item_equipment where item_code = #{itemCode} + + + + update equ_item_equipment + set del_flag = '1' + where item_code = + (select item_code from equ_check_item where item_id = #{itemId}) + + \ No newline at end of file