Procházet zdrojové kódy

【NEW】增加查询实验室接口,优化代码

ZhaoMn před 3 roky
rodič
revize
400122fa88

+ 13 - 1
railway-admin/src/main/java/com/railway/web/controller/system/SysDeptController.java

@@ -51,6 +51,17 @@ public class SysDeptController extends BaseController {
     return AjaxResult.success(depts);
   }
 
+  /**
+   * 获取实验室部门列表
+   */
+  @ApiOperation(value = "获取实验室部门列表")
+  @PreAuthorize("@ss.hasPermi('system:dept:list')")
+  @GetMapping("/listLab")
+  public AjaxResult listLab() {
+    List<SysDept> depts = deptService.selectLabDeptList();
+    return AjaxResult.success(depts);
+  }
+
   /**
    * 查询部门列表(排除节点)
    */
@@ -135,7 +146,8 @@ public class SysDeptController extends BaseController {
   public AjaxResult edit(@Validated @RequestBody SysDept dept) {
     if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
       return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
-    } else if (dept.getParentId().equals(dept.getDeptId())) {
+    } else if (StringUtils.isNotEmpty(dept.getParentId())
+        && dept.getParentId().equals(dept.getDeptId())) {
       return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
     } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
         && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) {

+ 10 - 6
railway-business/src/main/java/com/railway/business/safetool/domain/SecExperiment.java

@@ -3,12 +3,10 @@ package com.railway.business.safetool.domain;
 import com.railway.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import java.util.Date;
-
 import org.hibernate.validator.constraints.Length;
-import javax.validation.constraints.NotNull;
 /**
  * 送检记录表
  * @author lijie 2021-12-25
@@ -21,18 +19,24 @@ public class SecExperiment extends BaseEntity{
     @ApiModelProperty(value = "主键", hidden = true)
     private String id;
 
+    @ApiModelProperty(value = "车间")
+    private Long deptId;
+
+    @ApiModelProperty(value = "车间名称")
+    private String deptName;
+
     @ApiModelProperty(value = "实验室id 部门表类型为实验室")
     private Long labId;
 
+    @ApiModelProperty(value = "实验室Name 部门表类型为实验室")
+    private Long labName;
+
     @ApiModelProperty(value = "送检计划id")
     private Long schedledId;
 
     @ApiModelProperty(value = "截止时间")
     private Date endTime;
 
-    @ApiModelProperty(value = "车间")
-    private Long deptName;
-
     @ApiModelProperty(value = "送检日期")
     private Date scheduledTime;
 

+ 7 - 5
railway-business/src/main/java/com/railway/business/safetool/domain/SecScheduled.java

@@ -3,13 +3,9 @@ package com.railway.business.safetool.domain;
 import com.railway.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import java.util.Date;
-import java.util.List;
-
-import org.hibernate.validator.constraints.Length;
-import javax.validation.constraints.NotNull;
 /**
  * 安全工具计划表
  * @author lijie 2021-12-04
@@ -25,9 +21,15 @@ public class SecScheduled extends BaseEntity{
     @ApiModelProperty(value = "车间id")
     protected Long deptId;
 
+    @ApiModelProperty(value = "车间名称")
+    private String deptName;
+
     @ApiModelProperty(value = "实验室id 部门表类型为实验室")
     protected Long labId;
 
+    @ApiModelProperty(value = "实验室Name 部门表类型为实验室")
+    private Long labName;
+
     @ApiModelProperty(value = "计划送检日期")
     protected Date scheduledTime;
 

+ 1 - 5
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecExpListVo.java

@@ -1,13 +1,9 @@
 package com.railway.business.safetool.domain.vo;
 
-import com.railway.business.safetool.domain.SecScheduled;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
 import java.io.Serializable;
-import java.util.Date;
+import lombok.Data;
 
 /**
  * 送检记录列表

+ 1 - 6
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListParmVo.java

@@ -1,14 +1,9 @@
 package com.railway.business.safetool.domain.vo;
 
-import com.railway.business.safetool.domain.SecScheduled;
-import com.railway.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
 import java.io.Serializable;
-import java.util.List;
+import lombok.Data;
 
 /**
  * 安全工具计划表

+ 4 - 7
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListVo.java

@@ -1,16 +1,11 @@
 package com.railway.business.safetool.domain.vo;
 
-import com.railway.business.safetool.domain.BaseSafetyTool;
 import com.railway.business.safetool.domain.SecScheduled;
-import com.railway.common.core.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import org.hibernate.validator.constraints.Length;
-
-import java.util.Date;
-import java.util.List;
 
 /**
  * 安全工具计划表
@@ -21,7 +16,9 @@ import java.util.List;
 @EqualsAndHashCode(callSuper = true)
 public class SecScheduledListVo extends SecScheduled {
 
-    //计划包含的安全工具集合
+    /**
+     * 计划包含的安全工具集合
+     */
     @ApiModelProperty(value = "baseSafetyTools")
     private List<SecScheduledToolsVo> baseSafetyTools;
 

+ 0 - 2
railway-business/src/main/java/com/railway/business/safetool/domain/vo/SecScheduledListVo2.java

@@ -6,8 +6,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
-import java.util.List;
-
 /**
  * 安全工具计划表
  * @author lijie 2021-12-04

+ 1 - 3
railway-business/src/main/java/com/railway/business/safetool/mapper/SecScheduledMapper.java

@@ -4,14 +4,12 @@ import com.github.pagehelper.Page;
 import com.railway.business.safetool.domain.SecScheduled;
 import com.railway.business.safetool.domain.vo.SecScheduledDetailVo;
 import com.railway.business.safetool.domain.vo.SecScheduledListParmVo;
-import com.railway.business.safetool.domain.vo.SecScheduledListVo;
 import com.railway.business.safetool.domain.vo.SecScheduledListVo2;
+import java.util.List;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
-import java.util.List;
-
 /**
 * 安全工具计划表
 * @author lijie

+ 5 - 4
railway-business/src/main/java/com/railway/business/safetool/service/ISecScheduledService.java

@@ -1,10 +1,11 @@
 package com.railway.business.safetool.service;
 
 import com.railway.business.safetool.domain.SecScheduled;
-import com.railway.business.safetool.domain.SecScheduledTool;
-import com.railway.business.safetool.domain.vo.*;
-import org.springframework.transaction.annotation.Transactional;
-
+import com.railway.business.safetool.domain.vo.SecScheduledDetailVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListParmVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListVo2;
+import com.railway.business.safetool.domain.vo.SecScheduledToolsAddVo;
 import java.util.List;
 /**
 * 安全工具计划表

+ 140 - 138
railway-business/src/main/java/com/railway/business/safetool/service/impl/SecScheduledServiceImpl.java

@@ -1,153 +1,155 @@
 package com.railway.business.safetool.service.impl;
 
+import com.railway.business.safetool.domain.SecScheduled;
 import com.railway.business.safetool.domain.SecScheduledTool;
-import com.railway.business.safetool.domain.vo.*;
+import com.railway.business.safetool.domain.vo.SecScheduledDetailVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListParmVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListVo;
+import com.railway.business.safetool.domain.vo.SecScheduledListVo2;
+import com.railway.business.safetool.domain.vo.SecScheduledToolsAddVo;
+import com.railway.business.safetool.domain.vo.SecScheduledToolsVo;
 import com.railway.business.safetool.mapper.SecScheduledMapper;
-import com.railway.business.safetool.domain.SecScheduled;
 import com.railway.business.safetool.mapper.SecScheduledToolMapper;
 import com.railway.business.safetool.service.ISecScheduledService;
+import com.railway.common.utils.SecurityUtils;
 import com.railway.common.utils.bean.BeanUtils;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 import org.springframework.stereotype.Service;
-import com.railway.common.utils.SecurityUtils;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Date;
 /**
-* 安全工具计划表
-* @author lijie
-* @date 2021/12/04
-*/
+ * 安全工具计划表
+ *
+ * @author lijie
+ * @date 2021/12/04
+ */
 @Service
 @Transactional(readOnly = true)
-public class SecScheduledServiceImpl implements ISecScheduledService{
-
-	private final SecScheduledMapper secScheduledMapper;
-	private final SecScheduledToolMapper secScheduledToolMapper;
-
-	public SecScheduledServiceImpl(SecScheduledMapper secScheduledMapper,
-			SecScheduledToolMapper secScheduledToolMapper) {
-		this.secScheduledMapper = secScheduledMapper;
-		this.secScheduledToolMapper = secScheduledToolMapper;
-	}
-
-	/**
-	* 新增
-	*/
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int create(SecScheduledListVo secScheduled) throws Exception {
-	    secScheduled.setCreateTime(new Date());
-        secScheduled.setCreateBy(SecurityUtils.getUsername());
-		List<SecScheduledToolsVo> baseSafetyTools = secScheduled.getBaseSafetyTools() ;
-
-		if (CollectionUtils.isEmpty(baseSafetyTools))
-		{
-			throw new Exception("安全工具不能为空");
-		}
-		SecScheduled s = new SecScheduled();
-		BeanUtils.copyBeanProp(s,secScheduled);
-		s.setState("0");
-		s.setDelFlag("0");
-		int r = secScheduledMapper.insert(s);
-		if (r<1){
-			throw new Exception("计划插入失败");
-		}
-		for (SecScheduledToolsVo t:baseSafetyTools) {
-			SecScheduledTool secScheduledTool = new SecScheduledTool();
-			secScheduledTool.setScheduledId(s.getId());
-			secScheduledTool.setToolId(t.getToolId());
-			r = secScheduledToolMapper.insert(secScheduledTool);
-			if (r<1){
-				throw new Exception("计划关系插入失败");
-			}
-		}
-		return  1;
-	}
-
-	/**
-	* 删除
-	*/
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int delete(String[] ids) {
-		int r =0;
-		for (String id : ids) {
-			int j= secScheduledMapper.delete(id);
-			r = r + j;
-		}
-		return	r;
-	}
-
-	/**
-	* 更新
-	*/
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int update(SecScheduled secScheduled) {
-		secScheduled.setUpdateTime(new Date());
-    	secScheduled.setUpdateBy(SecurityUtils.getUsername());
-		return secScheduledMapper.update(secScheduled);
-	}
-
-	/**
-	* 获取单个
-	*/
-	@Override
-	public List<SecScheduledDetailVo> getInfo(String id) {
-		List<SecScheduledDetailVo> r = secScheduledMapper.getInfo(id);
-		r.forEach( vo->
-				vo.setC(vo.getBaseSafetyTools().size()+"")
-				);
-		return r;
-	}
-
-	/**
-	* 查询列表
-	*/
-	@Override
-	public List<SecScheduledListVo2> getList(SecScheduledListParmVo secScheduled) {
-		secScheduled.setDeptId(SecurityUtils.getLoginUser().getDeptId());
-		List<SecScheduledListVo2> r = secScheduledMapper.getList(secScheduled);
-		if (!CollectionUtils.isEmpty(r)&&r.size()==1){
-				if ("0件".equals(r.get(0).getC())) {
-					return new ArrayList<>();
-				}
-			}
-		return r;
-	}
-
-
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int delTools(SecScheduledToolsAddVo secScheduled) {
-
-		if (secScheduledToolMapper.checkdel(secScheduled)!=1){
-			return secScheduledToolMapper.delete(secScheduled);
-		}else {
-			return 0;
-		}
-
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public int addTools(SecScheduledToolsAddVo toolsVo) {
-
-
-		SecScheduledTool secScheduledTool = new SecScheduledTool();
-		secScheduledTool.setScheduledId(toolsVo.getScheduledId());
-		secScheduledTool.setToolId(toolsVo.getToolId());
-
-
-		if (secScheduledToolMapper.check(secScheduledTool)==0){
-			return secScheduledToolMapper.insert(secScheduledTool);
-		}else {
-			return 0;
-		}
-
-	}
+public class SecScheduledServiceImpl implements ISecScheduledService {
+
+  private final SecScheduledMapper secScheduledMapper;
+  private final SecScheduledToolMapper secScheduledToolMapper;
+
+  public SecScheduledServiceImpl(SecScheduledMapper secScheduledMapper,
+      SecScheduledToolMapper secScheduledToolMapper) {
+    this.secScheduledMapper = secScheduledMapper;
+    this.secScheduledToolMapper = secScheduledToolMapper;
+  }
+
+  /**
+   * 新增
+   */
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int create(SecScheduledListVo secScheduled) throws Exception {
+    secScheduled.setCreateTime(new Date());
+    secScheduled.setCreateBy(SecurityUtils.getUsername());
+    List<SecScheduledToolsVo> baseSafetyTools = secScheduled.getBaseSafetyTools();
+
+    if (CollectionUtils.isEmpty(baseSafetyTools)) {
+      throw new Exception("安全工具不能为空");
+    }
+    SecScheduled s = new SecScheduled();
+    BeanUtils.copyBeanProp(s, secScheduled);
+    s.setState("0");
+    s.setDelFlag("0");
+    int r = secScheduledMapper.insert(s);
+    if (r < 1) {
+      throw new Exception("计划插入失败");
+    }
+    for (SecScheduledToolsVo t : baseSafetyTools) {
+      SecScheduledTool secScheduledTool = new SecScheduledTool();
+      secScheduledTool.setScheduledId(s.getId());
+      secScheduledTool.setToolId(t.getToolId());
+      r = secScheduledToolMapper.insert(secScheduledTool);
+      if (r < 1) {
+        throw new Exception("计划关系插入失败");
+      }
+    }
+    return 1;
+  }
+
+  /**
+   * 删除
+   */
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int delete(String[] ids) {
+    int r = 0;
+    for (String id : ids) {
+      int j = secScheduledMapper.delete(id);
+      r = r + j;
+    }
+    return r;
+  }
+
+  /**
+   * 更新
+   */
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int update(SecScheduled secScheduled) {
+    secScheduled.setUpdateTime(new Date());
+    secScheduled.setUpdateBy(SecurityUtils.getUsername());
+    return secScheduledMapper.update(secScheduled);
+  }
+
+  /**
+   * 获取单个
+   */
+  @Override
+  public List<SecScheduledDetailVo> getInfo(String id) {
+    List<SecScheduledDetailVo> r = secScheduledMapper.getInfo(id);
+    r.forEach(vo ->
+        vo.setC(vo.getBaseSafetyTools().size() + "")
+    );
+    return r;
+  }
+
+  /**
+   * 查询列表
+   */
+  @Override
+  public List<SecScheduledListVo2> getList(SecScheduledListParmVo secScheduled) {
+    secScheduled.setDeptId(SecurityUtils.getLoginUser().getDeptId());
+    List<SecScheduledListVo2> r = secScheduledMapper.getList(secScheduled);
+    if (!CollectionUtils.isEmpty(r) && r.size() == 1) {
+      if ("0件".equals(r.get(0).getC())) {
+        return new ArrayList<>();
+      }
+    }
+    return r;
+  }
+
+
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int delTools(SecScheduledToolsAddVo secScheduled) {
+
+    if (secScheduledToolMapper.checkdel(secScheduled) != 1) {
+      return secScheduledToolMapper.delete(secScheduled);
+    } else {
+      return 0;
+    }
+
+  }
+
+  @Override
+  @Transactional(rollbackFor = Exception.class)
+  public int addTools(SecScheduledToolsAddVo toolsVo) {
+
+    SecScheduledTool secScheduledTool = new SecScheduledTool();
+    secScheduledTool.setScheduledId(toolsVo.getScheduledId());
+    secScheduledTool.setToolId(toolsVo.getToolId());
+
+    if (secScheduledToolMapper.check(secScheduledTool) == 0) {
+      return secScheduledToolMapper.insert(secScheduledTool);
+    } else {
+      return 0;
+    }
+
+  }
 }

+ 111 - 108
railway-business/src/main/resources/mapper/safetool/SecExperimentMapper.xml

@@ -1,114 +1,117 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.railway.business.safetool.mapper.SecExperimentMapper">
 
-    <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.vo.SecExpDetailVo">
-        <result column="toolName" property="toolName"/>
-        <result column="unit" property="unit"/>
-        <collection property="baseSafetyTools" ofType="com.railway.business.safetool.domain.vo.SecExpToolsVo">
-            <result column="tool_id" property="toolId"/>
-            <result column="tool_code" property="toolCode"/>
-            <result column="id" property="id"/>
-            <result column="isok" property="isok"/>
-        </collection>
-
-    </resultMap>
-
-
-
-    <resultMap id="listResultMap" type="com.railway.business.safetool.domain.vo.SecExpListVo">
-        <result column="id" property="id"/>
-        <result column="state" property="state"/>
-        <result column="scheduled_time" property="scheduledTime"/>
-        <result column="end_time" property="endTime"/>
-        <result column="exp_date" property="expDate"/>
-        <result column="dept_name" property="deptName"/>
-        <result column="lab_name" property="labName"/>
-        <result column="real_name" property="realName"/>
-
-    </resultMap>
-
-
-    <insert id="insertExp" keyProperty="id" parameterType="com.railway.business.safetool.domain.vo.SecExpAddParmVo">
-        INSERT INTO sec_experiment (lab_id,lab_name,schedled_id,end_time,dept_id,dept_name,
-        scheduled_time,state,del_flag,create_time,create_by)
-        select lab_id,d2.dept_name lab_name,s.id schedled_id,
-        ADDDATE(now(),3) end_time ,s.dept_id,d.dept_name,
-        now() scheduled_time,
-        '0' state ,'0' del_flag, now() create_time , #{createby} create_by
-        from sec_scheduled s
-        left join sys_dept d on s.dept_id = d.dept_id
-        left join sys_dept d2 on lab_id = d2.dept_id
-        where  s.id = #{secid}
-    </insert>
-
-
-    <insert id="insertTool" >
-        INSERT INTO sec_experiment_tool (tool_id,isok,exp_id,del_flag,create_time,create_by)
-        select tool_id,'0' isok ,#{expid} exp_id ,'0' del_flag, now() create_time , #{createby} create_by
-        from sec_scheduled_tool
-        where scheduled_id = #{secid}
-    </insert>
-
-
-    <update id="update" parameterType="com.railway.business.safetool.domain.SecExperiment">
-        UPDATE sec_experiment
-        <set>
-                    <if test ='null != labId'>lab_id = #{labId},</if>
-                    <if test ='null != schedledId'>schedled_id = #{schedledId},</if>
-                    <if test ='null != endTime'>end_time = #{endTime},</if>
-                    <if test ='null != deptName'>dept_name = #{deptName},</if>
-                    <if test ='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
-                    <if test ='null != expDate'>exp_date = #{expDate},</if>
-                    <if test ='null != state'>state = #{state},</if>
-                    <if test ='null != delFlag'>del_flag = #{delFlag},</if>
-                    <if test ='null != createBy'>create_by = #{createBy},</if>
-                    <if test ='null != createTime'>create_time = #{createTime},</if>
-                    <if test ='null != updateBy'>update_by = #{updateBy},</if>
-                    <if test ='null != updateTime'>update_time = #{updateTime}</if>
-        </set>
-        WHERE id = #{id}
-    </update>
-    <update id="updateScheduled" >
-	             update sec_scheduled
-					set 	state = #{state}
-					where id = (
-				 select schedled_id from sec_experiment where id = #{id}
-				 )
-    </update>
-    <select id="getInfo" resultMap="BaseResultMap">
- select  d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code,r.id,r.isok
- FROM sec_experiment s
- LEFT JOIN sec_experiment_tool r
- ON r.exp_id = s.id
- INNER JOIN base_safety_tool t
- ON t.tool_id = r.tool_id
- left join sys_dept d1 on s.dept_id = d1.dept_id
- left join sys_dept d2 on s.lab_id =  d2.dept_id
- left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
- WHERE s.del_flag = '0' and t.del_flag = '0' and t.state = '1'
-   and s.id=#{id}
-    </select>
-
-    <select id="getList" resultMap="listResultMap">
-
-        select e.id,e.state,e.scheduled_time,e.end_time,e.exp_date,e.dept_name,e.lab_name,u.real_name from sec_experiment e
-        left join sys_user u on e.create_by = u.user_name
-        where e.lab_id =#{labId}
-
-        <if test="deptId!=null and deptId!=''">
-            and  e.deptId =#{deptId}
-        </if>
-
-        <if test="scheduledTime!=null and scheduledTime!=''">
-            and  e.scheduled_time =#{scheduledTime}
-        </if>
-
-        <if test="orderby!=null and orderby!=''">
-            order by end_time ${orderby}
-        </if>
-
-    </select>
+  <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.vo.SecExpDetailVo">
+    <result column="toolName" property="toolName"/>
+    <result column="unit" property="unit"/>
+    <collection property="baseSafetyTools"
+      ofType="com.railway.business.safetool.domain.vo.SecExpToolsVo">
+      <result column="tool_id" property="toolId"/>
+      <result column="tool_code" property="toolCode"/>
+      <result column="id" property="id"/>
+      <result column="isok" property="isok"/>
+    </collection>
+
+  </resultMap>
+
+
+  <resultMap id="listResultMap" type="com.railway.business.safetool.domain.vo.SecExpListVo">
+    <result column="id" property="id"/>
+    <result column="state" property="state"/>
+    <result column="scheduled_time" property="scheduledTime"/>
+    <result column="end_time" property="endTime"/>
+    <result column="exp_date" property="expDate"/>
+    <result column="dept_name" property="deptName"/>
+    <result column="lab_name" property="labName"/>
+    <result column="real_name" property="realName"/>
+
+  </resultMap>
+
+
+  <insert id="insertExp" keyProperty="id"
+    parameterType="com.railway.business.safetool.domain.vo.SecExpAddParmVo">
+    INSERT INTO sec_experiment (lab_id,lab_name,schedled_id,end_time,dept_id,dept_name,
+    scheduled_time,state,del_flag,create_time,create_by)
+    select lab_id,d2.dept_name lab_name,s.id schedled_id,
+    ADDDATE(now(),3) end_time ,s.dept_id,d.dept_name,
+    now() scheduled_time,
+    '0' state ,'0' del_flag, now() create_time , #{createby} create_by
+    from sec_scheduled s
+    left join sys_dept d on s.dept_id = d.dept_id
+    left join sys_dept d2 on lab_id = d2.dept_id
+    where s.id = #{secid}
+  </insert>
+
+
+  <insert id="insertTool">
+    INSERT INTO sec_experiment_tool (tool_id,isok,exp_id,del_flag,create_time,create_by)
+    select tool_id,'0' isok ,#{expid} exp_id ,'0' del_flag, now() create_time , #{createby}
+    create_by
+    from sec_scheduled_tool
+    where scheduled_id = #{secid}
+  </insert>
+
+
+  <update id="update" parameterType="com.railway.business.safetool.domain.SecExperiment">
+    UPDATE sec_experiment
+    <set>
+      <if test='null != labId'>lab_id = #{labId},</if>
+      <if test='null != schedledId'>schedled_id = #{schedledId},</if>
+      <if test='null != endTime'>end_time = #{endTime},</if>
+      <if test='null != deptName'>dept_name = #{deptName},</if>
+      <if test='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
+      <if test='null != expDate'>exp_date = #{expDate},</if>
+      <if test='null != state'>state = #{state},</if>
+      <if test='null != delFlag'>del_flag = #{delFlag},</if>
+      <if test='null != createBy'>create_by = #{createBy},</if>
+      <if test='null != createTime'>create_time = #{createTime},</if>
+      <if test='null != updateBy'>update_by = #{updateBy},</if>
+      <if test='null != updateTime'>update_time = #{updateTime}</if>
+    </set>
+    WHERE id = #{id}
+  </update>
+  <update id="updateScheduled">
+    update sec_scheduled
+    set state = #{state}
+    where id = (
+    select schedled_id from sec_experiment where id = #{id}
+    )
+  </update>
+  <select id="getInfo" resultMap="BaseResultMap">
+    select d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code,r.id,r.isok
+    FROM sec_experiment s
+    LEFT JOIN sec_experiment_tool r
+    ON r.exp_id = s.id
+    INNER JOIN base_safety_tool t
+    ON t.tool_id = r.tool_id
+    left join sys_dept d1 on s.dept_id = d1.dept_id
+    left join sys_dept d2 on s.lab_id = d2.dept_id
+    left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
+    WHERE s.del_flag = '0' and t.del_flag = '0' and t.state = '1'
+    and s.id=#{id}
+  </select>
+
+  <select id="getList" resultMap="listResultMap">
+
+    select e.id,e.state,e.scheduled_time,e.end_time,e.exp_date,e.dept_name,e.lab_name,u.real_name
+    from sec_experiment e
+    left join sys_user u on e.create_by = u.user_name
+    where e.lab_id =#{labId}
+
+    <if test="deptId!=null and deptId!=''">
+      and e.deptId =#{deptId}
+    </if>
+
+    <if test="scheduledTime!=null and scheduledTime!=''">
+      and e.scheduled_time =#{scheduledTime}
+    </if>
+
+    <if test="orderby!=null and orderby!=''">
+      order by end_time ${orderby}
+    </if>
+
+  </select>
 
 </mapper>

+ 170 - 168
railway-business/src/main/resources/mapper/safetool/SecScheduledMapper.xml

@@ -1,174 +1,176 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.railway.business.safetool.mapper.SecScheduledMapper">
 
-    <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.vo.SecScheduledDetailVo">
-                <result column="toolName" property="toolName"/>
-                <result column="unit" property="unit"/>
-        <collection property="baseSafetyTools" ofType="com.railway.business.safetool.domain.vo.SecScheduledToolsVo">
-            <result column="tool_id" property="toolId"/>
-            <result column="tool_code" property="toolCode"/>
-            <result column="id" property="id"/>
-        </collection>
-
-    </resultMap>
-    <resultMap id="BaseResultMap2" type="com.railway.business.safetool.domain.vo.SecScheduledListVo2">
-        <result column="id" property="id"/>
-        <result column="dept_id" property="deptId"/>
-
-        <result column="lab_id" property="labId"/>
-        <result column="scheduled_time" property="scheduledTime"/>
-        <result column="deptName" property="deptName"/>
-        <result column="labName" property="labName"/>
-        <result column="c" property="c"/>
-    </resultMap>
-
-    <sql id="Base_Column_List">
-                id,
-                dept_id,
-                store_place,
-                lab_id,
-                scheduled_time,
-                state,
-                del_flag,
-                create_by,
-                create_time,
-                update_by,
-                update_time
-    </sql>
-
-    <insert id="insert" parameterType="com.railway.business.safetool.domain.SecScheduled">
-
-            <selectKey keyProperty="id" order="AFTER" resultType="Long">
-                select @@IDENTITY as id
-            </selectKey>
-
-        INSERT INTO sec_scheduled
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test ='null != deptId'>
-                    dept_id,
-                    </if>
-
-                    <if test ='null != labId'>
-                    lab_id,
-                    </if>
-                    <if test ='null != scheduledTime'>
-                    scheduled_time,
-                    </if>
-                    <if test ='null != state'>
-                    state,
-                    </if>
-                    <if test ='null != delFlag'>
-                    del_flag,
-                    </if>
-                    <if test ='null != createBy'>
-                    create_by,
-                    </if>
-                    <if test ='null != createTime'>
-                    create_time,
-                    </if>
-                    <if test ='null != updateBy'>
-                    update_by,
-                    </if>
-                    <if test ='null != updateTime'>
-                    update_time
-                    </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-                    <if test ='null != deptId'>
-                    #{deptId},
-                    </if>
-
-                    <if test ='null != labId'>
-                    #{labId},
-                    </if>
-                    <if test ='null != scheduledTime'>
-                    #{scheduledTime},
-                    </if>
-                    <if test ='null != state'>
-                    #{state},
-                    </if>
-                    <if test ='null != delFlag'>
-                    #{delFlag},
-                    </if>
-                    <if test ='null != createBy'>
-                    #{createBy},
-                    </if>
-                    <if test ='null != createTime'>
-                    #{createTime},
-                    </if>
-                    <if test ='null != updateBy'>
-                    #{updateBy},
-                    </if>
-                    <if test ='null != updateTime'>
-                    #{updateTime}
-                    </if>
-        </trim>
-    </insert>
-
-    <delete id="delete">
-        UPDATE sec_scheduled
-        set del_flag='1'
-        WHERE id = #{id}
-    </delete>
-
-    <update id="update" parameterType="com.railway.business.safetool.domain.SecScheduled">
-        UPDATE sec_scheduled
-        <set>
-                    <if test ='null != deptId'>dept_id = #{deptId},</if>
-
-                    <if test ='null != labId'>lab_id = #{labId},</if>
-                    <if test ='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
-                    <if test ='null != state'>state = #{state},</if>
-                    <if test ='null != delFlag'>del_flag = #{delFlag},</if>
-                    <if test ='null != createBy'>create_by = #{createBy},</if>
-                    <if test ='null != createTime'>create_time = #{createTime},</if>
-                    <if test ='null != updateBy'>update_by = #{updateBy},</if>
-                    <if test ='null != updateTime'>update_time = #{updateTime}</if>
-        </set>
-        WHERE id = #{id}
-    </update>
-
-
-    <select id="getInfo" resultMap="BaseResultMap">
-select  d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code,r.id
- FROM sec_scheduled s
- LEFT JOIN sec_scheduled_tool r
- ON r.scheduled_id = s.id
- INNER JOIN base_safety_tool t
- ON t.tool_id = r.tool_id
- left join sys_dept d1 on s.dept_id = d1.dept_id
- left join sys_dept d2 on s.lab_id =  d2.dept_id
- left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
- WHERE s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
-        and s.id=#{id}
-
-    </select>
-
-    <select id="getList" resultMap="BaseResultMap2">
-
-        select s.id,s.dept_id,s.lab_id,s.scheduled_time ,d1.dept_name deptName,d2.dept_name labName,concat(count(1),'件') c
-         from
-        sec_scheduled s
-        left join  sec_scheduled_tool r
-        on r.scheduled_id = s.id
-        inner join  base_safety_tool t
-        on t.tool_id = r.tool_id
-        left join sys_dept d1 on s.dept_id = d1.dept_id
-        left join sys_dept d2 on s.lab_id =  d2.dept_id
-        where s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
-
-            and s.dept_id=#{deptId}
-
-
-        <if test="labId!=null and labId!=''">
-            and s.lab_id=#{labId}
-        </if>
-        <if test="orderby!=null and orderby!=''">
-            order by scheduled_time ${orderby}
-        </if>
-
-    </select>
+  <resultMap id="BaseResultMap" type="com.railway.business.safetool.domain.vo.SecScheduledDetailVo">
+    <result column="toolName" property="toolName"/>
+    <result column="unit" property="unit"/>
+    <collection property="baseSafetyTools"
+      ofType="com.railway.business.safetool.domain.vo.SecScheduledToolsVo">
+      <result column="tool_id" property="toolId"/>
+      <result column="tool_code" property="toolCode"/>
+      <result column="id" property="id"/>
+    </collection>
+
+  </resultMap>
+  <resultMap id="BaseResultMap2" type="com.railway.business.safetool.domain.vo.SecScheduledListVo2">
+    <result column="id" property="id"/>
+    <result column="dept_id" property="deptId"/>
+
+    <result column="lab_id" property="labId"/>
+    <result column="scheduled_time" property="scheduledTime"/>
+    <result column="deptName" property="deptName"/>
+    <result column="labName" property="labName"/>
+    <result column="c" property="c"/>
+  </resultMap>
+
+  <sql id="Base_Column_List">
+    id,
+    dept_id,
+    store_place,
+    lab_id,
+    scheduled_time,
+    state,
+    del_flag,
+    create_by,
+    create_time,
+    update_by,
+    update_time
+  </sql>
+
+  <insert id="insert" parameterType="com.railway.business.safetool.domain.SecScheduled">
+
+    <selectKey keyProperty="id" order="AFTER" resultType="Long">
+      select @@IDENTITY as id
+    </selectKey>
+
+    INSERT INTO sec_scheduled
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test='null != deptId'>
+        dept_id,
+      </if>
+
+      <if test='null != labId'>
+        lab_id,
+      </if>
+      <if test='null != scheduledTime'>
+        scheduled_time,
+      </if>
+      <if test='null != state'>
+        state,
+      </if>
+      <if test='null != delFlag'>
+        del_flag,
+      </if>
+      <if test='null != createBy'>
+        create_by,
+      </if>
+      <if test='null != createTime'>
+        create_time,
+      </if>
+      <if test='null != updateBy'>
+        update_by,
+      </if>
+      <if test='null != updateTime'>
+        update_time
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test='null != deptId'>
+        #{deptId},
+      </if>
+
+      <if test='null != labId'>
+        #{labId},
+      </if>
+      <if test='null != scheduledTime'>
+        #{scheduledTime},
+      </if>
+      <if test='null != state'>
+        #{state},
+      </if>
+      <if test='null != delFlag'>
+        #{delFlag},
+      </if>
+      <if test='null != createBy'>
+        #{createBy},
+      </if>
+      <if test='null != createTime'>
+        #{createTime},
+      </if>
+      <if test='null != updateBy'>
+        #{updateBy},
+      </if>
+      <if test='null != updateTime'>
+        #{updateTime}
+      </if>
+    </trim>
+  </insert>
+
+  <delete id="delete">
+    UPDATE sec_scheduled
+    set del_flag='1'
+    WHERE id = #{id}
+  </delete>
+
+  <update id="update" parameterType="com.railway.business.safetool.domain.SecScheduled">
+    UPDATE sec_scheduled
+    <set>
+      <if test='null != deptId'>dept_id = #{deptId},</if>
+
+      <if test='null != labId'>lab_id = #{labId},</if>
+      <if test='null != scheduledTime'>scheduled_time = #{scheduledTime},</if>
+      <if test='null != state'>state = #{state},</if>
+      <if test='null != delFlag'>del_flag = #{delFlag},</if>
+      <if test='null != createBy'>create_by = #{createBy},</if>
+      <if test='null != createTime'>create_time = #{createTime},</if>
+      <if test='null != updateBy'>update_by = #{updateBy},</if>
+      <if test='null != updateTime'>update_time = #{updateTime}</if>
+    </set>
+    WHERE id = #{id}
+  </update>
+
+
+  <select id="getInfo" resultMap="BaseResultMap">
+    select d3.dict_label toolName ,t.unit,t.tool_id,t.tool_code,r.id
+    FROM sec_scheduled s
+    LEFT JOIN sec_scheduled_tool r
+    ON r.scheduled_id = s.id
+    INNER JOIN base_safety_tool t
+    ON t.tool_id = r.tool_id
+    left join sys_dept d1 on s.dept_id = d1.dept_id
+    left join sys_dept d2 on s.lab_id = d2.dept_id
+    left join sys_dict_data d3 on d3.dict_type = 'tool_type' and d3.dict_value = t.tool_type
+    WHERE s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
+    and s.id=#{id}
+
+  </select>
+
+  <select id="getList" resultMap="BaseResultMap2">
+
+    select s.id,s.dept_id,s.lab_id,s.scheduled_time ,d1.dept_name deptName,d2.dept_name
+    labName,concat(count(1),'件') c
+    from
+    sec_scheduled s
+    left join sec_scheduled_tool r
+    on r.scheduled_id = s.id
+    inner join base_safety_tool t
+    on t.tool_id = r.tool_id
+    left join sys_dept d1 on s.dept_id = d1.dept_id
+    left join sys_dept d2 on s.lab_id = d2.dept_id
+    where s.del_flag = '0' and s.state = 0 and t.del_flag = '0' and t.state = '1'
+
+    and s.dept_id=#{deptId}
+
+
+    <if test="labId!=null and labId!=''">
+      and s.lab_id=#{labId}
+    </if>
+    <if test="orderby!=null and orderby!=''">
+      order by scheduled_time ${orderby}
+    </if>
+
+  </select>
 
 </mapper>

+ 7 - 0
railway-system/src/main/java/com/railway/system/service/ISysDeptService.java

@@ -18,6 +18,13 @@ public interface ISysDeptService {
    */
   List<SysDept> selectDeptList();
 
+  /**
+   * 查询部门管理数据
+   *
+   * @return 部门信息集合
+   */
+  List<SysDept> selectLabDeptList();
+
   /**
    * 查询部门管理数据
    *

+ 14 - 0
railway-system/src/main/java/com/railway/system/service/impl/SysDeptServiceImpl.java

@@ -53,6 +53,20 @@ public class SysDeptServiceImpl implements ISysDeptService {
     return selectDeptList(dept);
   }
 
+  /**
+   * 查询部门管理数据
+   *
+   * @return 部门信息集合
+   */
+  @Override
+  public List<SysDept> selectLabDeptList() {
+    SysDept dept = new SysDept();
+    dept.setStatus(UserConstants.DEPT_NORMAL);
+    String deptType = "lab";
+    dept.setDeptType(deptType);
+    return deptMapper.selectDeptList(dept);
+  }
+
   /**
    * 查询部门管理数据
    *