Parcourir la source

Merge remote-tracking branch 'origin/master'

丁治程 il y a 1 an
Parent
commit
dab01a1d9a

+ 23 - 6
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckItem/controller/CmmsSpotcheckItemController.java

@@ -20,6 +20,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
+import org.jeecg.modules.util.AutoCodeUtil;
+import org.jeecg.modules.util.UserConstants;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -49,7 +51,18 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckItem, ICmmsSpotcheckItemService> {
 	@Autowired
 	private ICmmsSpotcheckItemService cmmsSpotcheckItemService;
-	
+	@Autowired
+	private AutoCodeUtil autoCodeUtil;
+
+	 /**
+	  * 依据设备ID获取点检项信息
+	  */
+	 @ApiOperation("依据设备ID获取点检项信息")
+	 @GetMapping(value = "/listbyequipmentid/{equipmentid}")
+	 public Result<List<CmmsSpotcheckItem>> listByEquipmentid(@PathVariable("equipmentid") String equipmentid) {
+		 return Result.OK(cmmsSpotcheckItemService.selectCmmsSpotcheckItemByEquipmentid(equipmentid));
+	 }
+
 	/**
 	 * 分页列表查询
 	 *
@@ -71,7 +84,7 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
 		IPage<CmmsSpotcheckItem> pageList = cmmsSpotcheckItemService.page(page, queryWrapper);
 		return Result.OK(pageList);
 	}
-	
+
 	/**
 	 *   添加
 	 *
@@ -83,10 +96,14 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
 	//@RequiresPermissions("org.jeecg.modules:ems_cmms_spotcheck_item:add")
 	@PostMapping(value = "/add")
 	public Result<String> add(@RequestBody CmmsSpotcheckItem cmmsSpotcheckItem) {
+		//生成点检项编号
+		if (cmmsSpotcheckItem.getItemcode() == null || "".equals(cmmsSpotcheckItem.getItemcode())) {
+			cmmsSpotcheckItem.setItemcode(autoCodeUtil.genSerialCode(UserConstants.CMMSSPOTCHECKITEM_CODE, null));
+		}
 		cmmsSpotcheckItemService.save(cmmsSpotcheckItem);
 		return Result.OK("添加成功!");
 	}
-	
+
 	/**
 	 *  编辑
 	 *
@@ -101,7 +118,7 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
 		cmmsSpotcheckItemService.updateById(cmmsSpotcheckItem);
 		return Result.OK("编辑成功!");
 	}
-	
+
 	/**
 	 *   通过id删除
 	 *
@@ -116,7 +133,7 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
 		cmmsSpotcheckItemService.removeById(id);
 		return Result.OK("删除成功!");
 	}
-	
+
 	/**
 	 *  批量删除
 	 *
@@ -131,7 +148,7 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
 		this.cmmsSpotcheckItemService.removeByIds(Arrays.asList(ids.split(",")));
 		return Result.OK("批量删除成功!");
 	}
-	
+
 	/**
 	 * 通过id查询
 	 *

+ 3 - 0
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckItem/entity/CmmsSpotcheckItem.java

@@ -81,4 +81,7 @@ public class CmmsSpotcheckItem implements Serializable {
 	/**所属部门*/
     @ApiModelProperty(value = "所属部门")
     private java.lang.String sysOrgCode;
+    /**备注*/
+    @ApiModelProperty(value = "备注")
+    private java.lang.String remark;
 }

+ 8 - 0
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckItem/mapper/CmmsSpotcheckItemMapper.java

@@ -14,4 +14,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface CmmsSpotcheckItemMapper extends BaseMapper<CmmsSpotcheckItem> {
 
+    /**
+     * 查询点检项列表
+     *
+     * @param cmmsSpotcheckItem 点检项
+     * @return 点检项集合
+     */
+    public List<CmmsSpotcheckItem> selectCmmsSpotcheckItemList(CmmsSpotcheckItem cmmsSpotcheckItem);
+
 }

+ 29 - 1
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckItem/mapper/xml/CmmsSpotcheckItemMapper.xml

@@ -2,4 +2,32 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.cmmsSpotcheckItem.mapper.CmmsSpotcheckItemMapper">
 
-</mapper>
+    <resultMap type="org.jeecg.modules.cmmsSpotcheckItem.entity.CmmsSpotcheckItem" id="CmmsSpotcheckItemResult">
+        <result property="id"    column="id"    />
+        <result property="itemcode"    column="itemcode"    />
+        <result property="itemname"    column="itemname"    />
+        <result property="equipmenttreeid"    column="equipmenttreeid"    />
+        <result property="conditions"    column="conditions"    />
+        <result property="itemtype"    column="itemtype"    />
+        <result property="tag"    column="tag"    />
+<!--        <result property="equipmenttreename"    column="equipmenttreename"    />-->
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <select id="selectCmmsSpotcheckItemList" parameterType="org.jeecg.modules.cmmsSpotcheckItem.entity.CmmsSpotcheckItem" resultMap="CmmsSpotcheckItemResult">
+        select i.id, i.itemcode, i.itemname,
+        i.equipmenttreeid, i.conditions, i.itemtype, i.tag,
+        i.create_by, i.create_time, i.update_by, i.update_time, i.remark
+        from ems_cmms_spotcheck_item as i
+--         left join ems_tpm_equipment_tree as t on i.equipmenttreeid = t.id  t.name as equipmenttreename,
+        <where>
+            <if test="itemname != null  and itemname != ''"> and (i.itemcode like concat('%', #{itemname}, '%') or i.itemname like concat('%', #{itemname}, '%'))</if>
+            <if test="equipmenttreeid != null "> and i.equipmenttreeid = #{equipmenttreeid}</if>
+        </where>
+    </select>
+
+</mapper>

+ 10 - 0
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckItem/service/ICmmsSpotcheckItemService.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.cmmsSpotcheckItem.service;
 import org.jeecg.modules.cmmsSpotcheckItem.entity.CmmsSpotcheckItem;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 点检项
  * @Author: jeecg-boot
@@ -11,4 +13,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ICmmsSpotcheckItemService extends IService<CmmsSpotcheckItem> {
 
+    /**
+     * 查询点检项列表
+     *
+     * @param equipmentid 设备ID
+     * @return 点检项集合
+     */
+    public List<CmmsSpotcheckItem> selectCmmsSpotcheckItemByEquipmentid(String equipmentid);
+
 }

+ 29 - 0
jeecg_module_ems/src/main/java/org/jeecg/modules/cmmsSpotcheckItem/service/impl/CmmsSpotcheckItemServiceImpl.java

@@ -3,10 +3,16 @@ package org.jeecg.modules.cmmsSpotcheckItem.service.impl;
 import org.jeecg.modules.cmmsSpotcheckItem.entity.CmmsSpotcheckItem;
 import org.jeecg.modules.cmmsSpotcheckItem.mapper.CmmsSpotcheckItemMapper;
 import org.jeecg.modules.cmmsSpotcheckItem.service.ICmmsSpotcheckItemService;
+import org.jeecg.modules.tpmEquipment.entity.TpmEquipment;
+import org.jeecg.modules.tpmEquipment.mapper.TpmEquipmentMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @Description: 点检项
  * @Author: jeecg-boot
@@ -16,4 +22,27 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class CmmsSpotcheckItemServiceImpl extends ServiceImpl<CmmsSpotcheckItemMapper, CmmsSpotcheckItem> implements ICmmsSpotcheckItemService {
 
+    @Autowired
+    private TpmEquipmentMapper tpmEquipmentMapper;
+    @Autowired
+    private CmmsSpotcheckItemMapper spotcheckItemMapper;
+
+    /**
+     * 查询点检项列表
+     *
+     * @param equipmentid 设备ID
+     * @return 点检项集合
+     */
+    public List<CmmsSpotcheckItem> selectCmmsSpotcheckItemByEquipmentid(String equipmentid) {
+        // 获取设备信息
+        TpmEquipment tpmEquipment = tpmEquipmentMapper.selectById(equipmentid);
+
+        if(tpmEquipment!=null){
+            CmmsSpotcheckItem cmmsSpotcheckItem = new CmmsSpotcheckItem();
+            cmmsSpotcheckItem.setEquipmenttreeid(tpmEquipment.getEquipmenttreeid());
+            return spotcheckItemMapper.selectCmmsSpotcheckItemList(cmmsSpotcheckItem);
+        }else return new ArrayList<>();
+
+    }
+
 }