Kaynağa Gözat

添加考核项管理模块

minitiger 9 yıl önce
ebeveyn
işleme
c42ad73e96

+ 9 - 6
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/CheckItem.java

@@ -1,7 +1,6 @@
 package com.xintong.visualinspection.bean;
 
 import lombok.Data;
-import org.omg.CORBA.INTERNAL;
 
 /**
  * 文件名:AssessmentItem
@@ -10,15 +9,19 @@ import org.omg.CORBA.INTERNAL;
 @Data
 public class CheckItem {
     //编号
-    private Integer id;
-    //考核办法id
-    private Integer assessment_method_id;
+    private Long id;
+    //父节点id
+    private Long parent_id;
     //名称
     private String name;
     //内容
     private String content;
     //分数
     private Integer score;
-    //状态(奖励--0  or惩罚--1 )
-    private Integer status;
+    //分数类型(奖励--1  or惩罚--2 )
+    private Integer score_type;
+    //考核类型或考核项,1:考核类型;2:考核项
+    private Integer type;
+    //办法id
+    private Long rule_id;
 }

+ 50 - 16
VisualInspection_server/src/main/java/com/xintong/visualinspection/controller/CheckItemController.java

@@ -1,15 +1,17 @@
 package com.xintong.visualinspection.controller;
 
+import java.util.List;
+
 import javax.validation.Valid;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.xintong.visualinspection.bean.Constant;
-import com.xintong.visualinspection.service.ConstantService;
+import com.xintong.visualinspection.bean.CheckItem;
+import com.xintong.visualinspection.err.BusinessException;
+import com.xintong.visualinspection.service.CheckItemService;
 
 /**
  * 文件名:TestController
@@ -20,45 +22,77 @@ import com.xintong.visualinspection.service.ConstantService;
 public class CheckItemController extends BaseController {
 
     @Autowired
-    private ConstantService constantService;
+    private CheckItemService checkItemService;
 
    
     /**
-     * 添加常量
+     * 添加考核项
      * @return
      * String
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/addConstant")
-    public String addConstant(@Valid @RequestBody Constant constant, BindingResult result){
-    	constantService.insert(constant);
+    @RequestMapping(value = "/add")
+    public String add(@Valid @RequestBody CheckItem checkItem){
+    	checkItemService.insert(checkItem);
     	return super.returnSuccessResult("添加成功");
     }
     
     /**
-     * 修改常量
+     * 修改考核项
      * @return
      * String
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/updateConstant")
-    public String updateConstant(@RequestBody Constant constant){
-    	constantService.update(constant);
+    @RequestMapping(value = "/update")
+    public String update(@Valid @RequestBody CheckItem checkItem){
+    	checkItemService.update(checkItem);
     	return super.returnSuccessResult("修改成功");
     }
     
     /**
-     * 删除常量
+     * 删除考核项
      * @return
      * String
      * @exception
      * @since  1.0.0
      */
-    @RequestMapping(value = "/deleteConstant")
-    public String deleteConstant(@RequestBody String id){
-    	constantService.delete(Long.parseLong(id));
+    @RequestMapping(value = "/delete")
+    public String delete(@RequestBody CheckItem checkItem){
+    	checkItemService.delete(checkItem.getId());
     	return super.returnSuccessResult("删除成功");
     }
+    
+    /**
+     * 通过父亲id获取考核项
+     * @return
+     * String
+     * @exception
+     * @since  1.0.0
+     */
+    @RequestMapping(value = "/getByParentId")
+    public String getByParentId(@RequestBody CheckItem checkItem){
+    	if(checkItem.getParent_id()==null){
+    		throw new BusinessException(20101);
+    	}
+    	List<CheckItem> checkItemList = checkItemService.getByParentId(checkItem.getParent_id());
+    	return super.returnSuccessResult(checkItemList);
+    }
+    
+    /**
+     * 通过方法id获取考核项
+     * @return
+     * String
+     * @exception
+     * @since  1.0.0
+     */
+    @RequestMapping(value = "/getByRuleId")
+    public String getByRuleId(@RequestBody CheckItem checkItem){
+    	if(checkItem.getRule_id()==null){
+    		throw new BusinessException(20101);
+    	}
+    	List<CheckItem> checkItemList = checkItemService.getByRuleId(checkItem.getRule_id());
+    	return super.returnSuccessResult(checkItemList);
+    }
 }

+ 8 - 8
VisualInspection_server/src/main/java/com/xintong/visualinspection/dao/master/CheckItemDao.java

@@ -1,10 +1,10 @@
 package com.xintong.visualinspection.dao.master;
 
-import com.xintong.visualinspection.bean.User;
+import java.util.List;
+
 import org.apache.ibatis.annotations.Mapper;
-import org.springframework.stereotype.Repository;
 
-import java.util.List;
+import com.xintong.visualinspection.bean.CheckItem;
 
 /**
  * 文件名:UserInfoDao
@@ -12,10 +12,10 @@ import java.util.List;
  */
 @Mapper
 public interface CheckItemDao  {
-    public List<User> getAll();
-    public User getOne(Long id);
-    public void insert(User user);
-    public void update(User user);
+    public List<CheckItem> getAll();
+    public List<CheckItem> getByParentId(Long id);
+    public CheckItem getOne(Long id);
+    public void insert(CheckItem checkItem);
+    public void update(CheckItem checkItem);
     public void delete(Long id);
-    public User findByUserName(String username);
 }

+ 31 - 40
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/CheckItemMapper.xml

@@ -1,68 +1,59 @@
 <?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">
 <mapper namespace="com.xintong.visualinspection.dao.master.CheckItemDao" >
-    <resultMap id="BaseResultMap" type="com.xintong.visualinspection.bean.User" >
+    <resultMap id="BaseResultMap" type="com.xintong.visualinspection.bean.CheckItem" >
         <id column="id" property="id" jdbcType="INTEGER" />
-        <result column="username" property="username" jdbcType="VARCHAR" />
-        <result column="age" property="age" jdbcType="INTEGER" />
-        <result column="password" property="password" jdbcType="VARCHAR" />
-    </resultMap>
-    <resultMap id="userMap" type="com.xintong.visualinspection.bean.User">
-        <id property="id" column="ID"/>
-        <result property="username" column="username"/>
-        <result property="password" column="PASSWORD"/>
-        <collection property="roles" ofType="com.xintong.visualinspection.bean.Role">
-            <result column="name" property="name"/>
-        </collection>
+        <result column="parent_id" property="parent_id" jdbcType="INTEGER" />
+        <result column="name" property="name" jdbcType="VARCHAR" />
+        <result column="content" property="content" jdbcType="VARCHAR" />
+        <result column="score" property="score" jdbcType="INTEGER" />
+        <result column="score_type" property="score_type" jdbcType="INTEGER" />
+        <result column="type" property="type" jdbcType="INTEGER" />
     </resultMap>
 
     <select id="getAll" resultMap="BaseResultMap"  >
-        SELECT
-        id,username,age,password
-        FROM sys_user
+        SELECT *
+        FROM check_item
     </select>
 
     <select id="getOne" parameterType="java.lang.Long" resultMap="BaseResultMap" >
-        SELECT
-        id,username,age,password
-        FROM sys_user
+        SELECT *
+        FROM check_item
         WHERE id = #{id}
     </select>
-
-    <insert id="insert" parameterType="com.xintong.visualinspection.bean.User" >
+    
+	<select id="getByParentId" parameterType="java.lang.Long" resultMap="BaseResultMap" >
+        SELECT *
+        FROM check_item
+        WHERE parent_id = #{parent_id}
+    </select>
+    
+    <insert id="insert" parameterType="com.xintong.visualinspection.dao.master.CheckItemDao" >
         INSERT INTO
-        sys_user
-        (username,age,password,TRUENAME,ORGANID,BIRTH,AGE,MOBILE,POSITIONID,SEX,WORKNO,IDNO)
+        check_item
+        (name,parent_id,content,score,score_type,type)
         VALUES
-        (#{username}, #{age},#{password},#{truename},#{deptId},#{birth},#{age},#{mobile},#{positionId},#{sex},#{workno},#{idno})
+        (#{name}, #{parent_id},#{content},#{score},#{score_type},#{type})
     </insert>
 
-    <update id="update" parameterType="com.xintong.visualinspection.bean.User" >
+    <update id="update" parameterType="com.xintong.visualinspection.dao.master.CheckItemDao" >
         UPDATE
-        sys_user
+        check_item
         SET
-        <if test="username != null">userName = #{username},</if>
-        <if test="age != null">age = #{age},</if>
-        <if test="password != null">password = #{password},</if>
-        id = #{id}
+        <if test="name != null">name = #{name},</if>
+        <if test="parent_id != null">parent_id = #{parent_id},</if>
+        <if test="content != null">content = #{content},</if>
+        <if test="score != null">score = #{score},</if>
+        <if test="score_type != null">score_type = #{score_type},</if>
+        <if test="type != null">type = #{type}</if>
         WHERE
         id = #{id}
     </update>
 
     <delete id="delete" parameterType="java.lang.Long" >
         DELETE FROM
-        sys_user
+        check_item
         WHERE
         id =#{id}
     </delete>
-
-
-    <select id="findByUserName" parameterType="String" resultMap="userMap">
-        select u.*
-        ,r.name
-        from sys_user u
-        LEFT JOIN sys_role_user sru on u.id= sru.Sys_User_id
-        LEFT JOIN sys_role r on sru.sys_role_id=r.id
-        where username= #{username}
-    </select>
 </mapper>

+ 3 - 4
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/CheckItemService.java

@@ -3,7 +3,6 @@ package com.xintong.visualinspection.service;
 import java.util.List;
 
 import com.xintong.visualinspection.bean.CheckItem;
-import com.xintong.visualinspection.bean.Constant;
 
 /**
  * 
@@ -19,9 +18,9 @@ import com.xintong.visualinspection.bean.Constant;
  */
 public interface CheckItemService {
     public List<CheckItem> getAll();
-    public Constant getById(Long id);
-    public List<CheckItem> getByFlag();
-    public Constant getByFlagAndValue(String flag, int value);
+    public CheckItem getById(Long id);
+    public List<CheckItem> getByParentId(Long id);
+    public List<CheckItem> getByRuleId(Long id);
     public void insert(CheckItem checkItem);
     public void update(CheckItem checkItem);
     public void delete(Long id);

+ 21 - 16
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/CheckItemServiceImpl.java

@@ -26,46 +26,51 @@ public class CheckItemServiceImpl extends BaseService implements CheckItemServic
     private CheckItemDao checkItemDao;
 
 
-	public List getAll() {
+	@Override
+	public List<CheckItem> getAll() {
 		// TODO Auto-generated method stub
-		return null;
-	}
-
-
-	public Constant getById(Long id) {
-		// TODO Auto-generated method stub
-		return null;
+		return checkItemDao.getAll();
 	}
 
 
-	public List getByFlag() {
+	@Override
+	public CheckItem getById(Long id) {
 		// TODO Auto-generated method stub
-		return null;
+		return checkItemDao.getOne(id);
 	}
 
 
-	public Constant getByFlagAndValue(String flag, int value) {
+	@Override
+	public List<CheckItem> getByParentId(Long id) {
 		// TODO Auto-generated method stub
-		return null;
+		return checkItemDao.getByParentId(id);
 	}
 
 
+	@Override
 	public void insert(CheckItem checkItem) {
 		// TODO Auto-generated method stub
-		
+		checkItemDao.insert(checkItem);
 	}
 
 
+	@Override
 	public void update(CheckItem checkItem) {
 		// TODO Auto-generated method stub
-		
+		checkItemDao.update(checkItem);
 	}
 
 
+	@Override
 	public void delete(Long id) {
 		// TODO Auto-generated method stub
-		
+		checkItemDao.delete(id);
 	}
 
-    
+
+	@Override
+	public List<CheckItem> getByRuleId(Long id) {
+		// TODO Auto-generated method stub
+		return null;
+	}
 }