소스 검색

点检内容——获取点检内容详细信息

LLL 1 년 전
부모
커밋
34128247e6

+ 32 - 2
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckContent/controller/CmmsSpotcheckContentController.java

@@ -14,6 +14,7 @@ import org.jeecg.modules.cmmsSpotcheckContent.convert.CmmsSpotcheckContentConver
 import org.jeecg.modules.cmmsSpotcheckContent.dto.CmmsSpotcheckContentAddDTO;
 import org.jeecg.modules.cmmsSpotcheckContent.entity.CmmsSpotcheckContent;
 import org.jeecg.modules.cmmsSpotcheckContent.service.ICmmsSpotcheckContentService;
+import org.jeecg.modules.cmmsSpotcheckContent.vo.CmmsSpotcheckContentQueryVO;
 import org.jeecg.modules.cmmsSpotcheckContentItem.entity.CmmsSpotcheckContentItem;
 import org.jeecg.modules.cmmsSpotcheckContentItem.service.ICmmsSpotcheckContentItemService;
 import org.jeecg.modules.util.AutoCodeUtil;
@@ -48,6 +49,23 @@ public class CmmsSpotcheckContentController extends JeecgController<CmmsSpotchec
 	@Autowired
 	private ICmmsSpotcheckContentItemService spotcheckContentItemService;
 
+	/**
+	 * 通过id查询
+	 */
+	@ApiOperation("获取点检内容详细信息——包括该点检内容对应的点检项")
+	@GetMapping(value = "/queryContentAndItemById")
+	public Result<CmmsSpotcheckContentQueryVO> queryContentAndItemById(@RequestParam(name="id",required=true) String id) {
+		CmmsSpotcheckContent cmmsSpotcheckContent = cmmsSpotcheckContentService.getById(id);
+		if(cmmsSpotcheckContent==null) {
+			return Result.error("未找到对应数据");
+		}
+		Map<String, Object> columnMap = new HashMap<>();
+		columnMap.put("spotcheckcontid",cmmsSpotcheckContent.getId());
+		List<CmmsSpotcheckContentItem> spotcheckContentItemList = spotcheckContentItemService.listByMap(columnMap);
+		CmmsSpotcheckContentQueryVO vo = CmmsSpotcheckContentConvert.INSTANCE.convertVo(cmmsSpotcheckContent,spotcheckContentItemList);
+		return Result.OK(vo);
+	}
+
 	 /**
 	  * 如果要修改该点检内容状态为“启用”,那该设备的其他点检项都停掉
 	  * 启用:0
@@ -126,14 +144,26 @@ public class CmmsSpotcheckContentController extends JeecgController<CmmsSpotchec
 	/**
 	 *  编辑
 	 *
-	 * @param cmmsSpotcheckContent
+	 * @param dto
 	 * @return
 	 */
 	@AutoLog(value = "点检内容-编辑")
 	@ApiOperation(value="点检内容-编辑", notes="点检内容-编辑")
 	//@RequiresPermissions("org.jeecg.modules:ems_cmms_spotcheck_content:edit")
 	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody CmmsSpotcheckContent cmmsSpotcheckContent) {
+	public Result<String> edit(@RequestBody CmmsSpotcheckContentAddDTO dto) {
+		CmmsSpotcheckContent cmmsSpotcheckContent = CmmsSpotcheckContentConvert.INSTANCE.convert(dto);
+
+		Map<String, Object> columnMap = new HashMap<>();
+		columnMap.put("spotcheckcontid",dto.getId());
+		spotcheckContentItemService.removeByMap(columnMap);
+
+		List<CmmsSpotcheckContentItem> contentItemList = dto.getSpotcheckContentItemList();
+		if (contentItemList != null && contentItemList.size() > 0) {
+			contentItemList.stream().map(i->i.setSpotcheckcontid(cmmsSpotcheckContent.getId())).collect(Collectors.toList());
+			spotcheckContentItemService.saveBatch(contentItemList);
+		}
+
 		cmmsSpotcheckContentService.updateById(cmmsSpotcheckContent);
 		return Result.OK("编辑成功!");
 	}

+ 5 - 0
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckContent/convert/CmmsSpotcheckContentConvert.java

@@ -3,11 +3,14 @@ package org.jeecg.modules.cmmsSpotcheckContent.convert;
 
 import org.jeecg.modules.cmmsSpotcheckContent.dto.CmmsSpotcheckContentAddDTO;
 import org.jeecg.modules.cmmsSpotcheckContent.entity.CmmsSpotcheckContent;
+import org.jeecg.modules.cmmsSpotcheckContent.vo.CmmsSpotcheckContentQueryVO;
+import org.jeecg.modules.cmmsSpotcheckContentItem.entity.CmmsSpotcheckContentItem;
 import org.mapstruct.Mapper;
 import org.mapstruct.ReportingPolicy;
 import org.mapstruct.factory.Mappers;
 import org.springframework.util.CollectionUtils;
 
+import java.util.List;
 import java.util.stream.Collectors;
 
 @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE,imports ={ CollectionUtils.class, Collectors.class})
@@ -17,4 +20,6 @@ public interface CmmsSpotcheckContentConvert {
 
     CmmsSpotcheckContent convert(CmmsSpotcheckContentAddDTO dto);
 
+    CmmsSpotcheckContentQueryVO convertVo(CmmsSpotcheckContent cmmsSpotcheckContent, List<CmmsSpotcheckContentItem> spotcheckContentItemList);
+
 }

+ 64 - 0
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckContent/vo/CmmsSpotcheckContentQueryVO.java

@@ -0,0 +1,64 @@
+package org.jeecg.modules.cmmsSpotcheckContent.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecg.modules.cmmsSpotcheckContentItem.entity.CmmsSpotcheckContentItem;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class CmmsSpotcheckContentQueryVO  implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**主键*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private java.lang.String id;
+    /**点检内容编号*/
+    @Excel(name = "点检内容编号", width = 15)
+    @ApiModelProperty(value = "点检内容编号")
+    private java.lang.String contentcode;
+    /**点检内容名称*/
+    @Excel(name = "点检内容名称", width = 15)
+    @ApiModelProperty(value = "点检内容名称")
+    private java.lang.String contentname;
+    /**设备id*/
+    @Excel(name = "设备id", width = 15, dictTable = "ems_tpm_equipment", dicText = "equipmentname", dicCode = "id")
+    @Dict(dictTable = "ems_tpm_equipment", dicText = "equipmentname", dicCode = "id")
+    @ApiModelProperty(value = "设备id")
+    private java.lang.String equipmentid;
+    /**状态:启用:0、禁用:1*/
+    @Excel(name = "状态:启用:0、禁用:1", width = 15, dicCode = "spotcheck_content_status")
+    @Dict(dicCode = "spotcheck_content_status")
+    @ApiModelProperty(value = "状态:启用:0、禁用:1")
+    private java.lang.String status;
+    /**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private java.lang.String createBy;
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private java.util.Date createTime;
+    /**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private java.lang.String updateBy;
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private java.util.Date updateTime;
+    /**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private java.lang.String sysOrgCode;
+
+    /**点检内容-点检项集合*/
+    private List<CmmsSpotcheckContentItem> spotcheckContentItemList ;
+}