zoukankan      html  css  js  c++  java
  • 河北省重大技术需求征集系统(10)

    完善DemandMapper层

    package com.dao;
    
    import com.bean.DemandBean;
    import com.bean.Tongjibean;
    import com.mapper.DemandMapper;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    import java.util.List;
    
    public class DemandDao {
    
        private DemandMapper mapper;
    
        /*
         * 获取数据表中数据总量
         */
    
        public void setUp() throws Exception {
            ApplicationContext context = new ClassPathXmlApplicationContext(
                    "classpath:spring/applicationContext.xml", "classpath:spring/applicationContext-mybatis.xml");
            mapper = context.getBean(DemandMapper.class);
        }
    
        public int getCount() throws Exception {
            setUp();
            return mapper.getCount();
        }
    
        /**
         * 判断需求名称是否存在
         * 
         * @throws Exception
         */
        @SuppressWarnings("finally")
        public boolean checkName(String JSXQMC) throws Exception {
            setUp();
            DemandBean demandBean = new DemandBean();
    
            try {
                demandBean = mapper.getByName(JSXQMC);
                if (demandBean == null) {
                    return true;
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                return false;
            }
    
        }
    
        /*
         * 添加需求
         */
        public void saveDemand(DemandBean demandBean) throws Exception {
            setUp();
    
            int n = mapper.saveDemand(demandBean);
        }
    
        /*
         * 更新审核的状态
         */
        public boolean updateSFSH(String WJID, int SFSH, String V) throws Exception {
            setUp();
    
    
            DemandBean demandBean = new DemandBean();
            demandBean.setWJID(WJID);
            demandBean.setSFSH(SFSH);
            demandBean.setV(V);
    
            int n = mapper.updateSFSH(demandBean);
    
            if (n > 0)
                return true;
            return false;
        }
    
        // 获取每一个分页的数据
        public List<DemandBean> getListByPage(int start, int size) throws Exception {
            setUp();
            List<DemandBean> list = mapper.getListPage(start, size);
            return list;
        }
    
        /**
         * 根据需求状态 获取数目
         */
        public Tongjibean tongji() throws Exception {
            setUp();
            Tongjibean tongjibean = new Tongjibean();
            tongjibean.setWeishenhe(mapper.getWeishenhe());
            tongjibean.setShenhe(mapper.getShenhe());
            tongjibean.setTongguo(mapper.getTongguo());
            tongjibean.setTuihui(mapper.getTuihui());
            return tongjibean;
        }
    
        // 去掉分页
        public List<DemandBean> xdshPolicy(String num, String sType0, String q0, String logic1, String sType1,
                String q1, String logic2, String sType2, String q2) throws Exception {
            setUp();
    
            List<DemandBean> list = mapper.xdshPolicy(num, sType0, q0, logic1, sType1, q1, logic2, sType2, q2);
    
            return list;
        }
    
        /**
         * 显示基础研究,,,,集合
         * 
         * @throws Exception
         */
        public List<String> getTypeList() throws Exception {
            setUp();
    
            List<String> list = mapper.getTypeList();
            return list;
        }
    
        /* 显示学科分类第一级 */
        public List<String> getXKFLListA() throws Exception {
            setUp();
            List<String> list = mapper.getXKFLListA();
            return list;
        }
    
        /* 显示学科分类第二级 */
        public List<String> getXKFLListB(String type) throws Exception {
            setUp();
            List<String> list = mapper.getXKFLListB(type);
            return list;
        }
    
        /* 显示学科分类第三级 */
        public List<String> getXKFLListC(String type) throws Exception {
            setUp();
            List<String> list = mapper.getXKFLListC(type);
            return list;
        }
    
        /*
         * 检测字符串中第几个位置的字符 public String getSP(String str,int n){ String A="";
         * String[] split=str.split("\,"); A=split[n]; return A; String
         * address="上海:上海市:闵行区:吴中路"; String[] splitAddress=address.split("\:");
         * System.out.println(splitAddress[0]+splitAddress[1]+splitAddress[2]+
         * splitAddress[3]); }
         * 
         * 数组的个数 public int getStr(String a){ int num=0; String[]
         * split=a.split("\,"); num=split.length; return num; }
         */
    
        /* 显示国民经济行业第一级 */
        public List<String> getXQJSYYHYListA() throws Exception {
            setUp();
            List<String> list = mapper.getXQJSYYHYListA();
            return list;
        }
    
        /* 显示国民经济分类第二级 */
        public List<String> getXQJSYYHYListB(String type) throws Exception {
            setUp();
            List<String> list = mapper.getXQJSYYHYListB(type);
            return list;
        }
    
        /* 显示国民经济行业分类第三级 */
        public List<String> getXQJSYYHYListC(String type) throws Exception {
            setUp();
    
            List<String> list = mapper.getXQJSYYHYListC(type);
            return list;
        }
    
        public List<DemandBean> getListNext(String next) throws Exception {
            setUp();
    
            List<DemandBean> list = mapper.getListNext(next);
    
            return list;
        }
    
        public List<DemandBean> getListAX(String next) throws Exception {
            setUp();
            List<DemandBean> list = mapper.getListAX(next);
            return list;
        }
    
        public List<DemandBean> getListBX(String next, String parent) throws Exception {
            setUp();
            List<DemandBean> list = mapper.getListBX(next, parent);
            return list;
        }
    
        public List<DemandBean> getListCX(String next, String parent) throws Exception {
            setUp();
            List<DemandBean> list = mapper.getListCX(next, parent);
            return list;
        }
    
        public List<DemandBean> getListAH(String next) throws Exception {
            setUp();
    
            List<DemandBean> list = mapper.getListAH(next);
    
            return list;
        }
    
        public List<DemandBean> getListBH(String next, String parent) throws Exception {
            setUp();
            List<DemandBean> list = mapper.getListBH(next, parent);
            return list;
        }
    
        public List<DemandBean> getListCH(String next, String parent) throws Exception {
            setUp();
    
            List<DemandBean> list = mapper.getListCH(next, parent);
    
            return list;
        }
    
        /**
         * 以列表形式显示
         * 
         * @throws Exception
         */
        public List<DemandBean> getList() throws Exception {
            setUp();
    
            List<DemandBean> list = mapper.getList();
    
            return list;
        }
    
        /**
         * 以列表形式显示,用户已提交的问卷
         * 
         * @throws Exception
         */
        public List<DemandBean> getMyList(String username) throws Exception {
            setUp();
            List<DemandBean> list = mapper.getMyList(username);
    
            return list;
        }
    
        /**
         * 带条件的搜索,通过name
         */
        public List<DemandBean> getByName(String JSXQMC) {
            try {
                setUp();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
    
            List<DemandBean> list = mapper.getByLikeName(JSXQMC);
    
            return list;
        }
    
        /**
         * 根据id查看详细信息
         * 
         * @throws Exception
         */
        public DemandBean getById(String WJID) throws Exception {
            setUp();
    
            DemandBean demandBean = new DemandBean();
            demandBean = mapper.getById(WJID);
    
            return demandBean;
        }
    
        /**
         * 以列表形式显示未审核的需求信息
         * 
         * @throws Exception
         */
        public List<DemandBean> getListNo() throws Exception {
            setUp();
    
            List<DemandBean> list = mapper.getListNo();
    
            return list;
        }
    
        public boolean deleteDemand(String id) throws Exception {
            setUp();
            return mapper.deleteDemand(id);
    
        }
    }
    <?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.mapper.DemandMapper">
        <delete id="deleteDemand" parameterType="java.lang.String">
        delete  from T_DCWJXX where WJID=#{id}
        </delete>
    
        <!-- 获取数据库的总量 需求数目 -->
        <!--count-->
        <select id="getCount" resultType="int">
            select count(*) count from
            T_DCWJXX
        </select>
    
        <!-- 判断需求名称是否存在 -->
        <!--name exist-->
        <select id="getByName" parameterType="java.lang.String"
            resultType="com.bean.DemandBean">
            select * from T_DCWJXX where JSXQMC=#{JSXQMC}
        </select>
    
        <!-- 添加需求 -->
        <!--insert-->
        <insert id="saveDemand" parameterType="com.bean.DemandBean">
            insert into
            T_DCWJXX(WJID,username,SZDY,SFSH,JGMC,GLBM,TXDZ,DWWZ,DZYX,FRDB,YZBM,LXR,GDDH,YDDH,CZ,JGSX,JGJJ,JSXQMC,QSXQNF,JZXQNF,ZDKJXQGS,GJZ,YJLX,XKFL1,XKFL2,XKFL3,XQJSSSLY,QTJSMS,XQJSYYHY1,XQJSYYHY2,XQJSYYHY3,JSXQHZMS,HZYXDW,NTR,createDate)
            values(#{WJID},#{username},#{SZDY},#{SFSH},#{JGMC},#{GLBM},#{TXDZ},#{DWWZ},#{DZYX},#{FRDB},#{YZBM},#{LXR},#{GDDH},#{YDDH},#{CZ},#{JGSX},#{JGJJ},#{JSXQMC},#{QSXQNF},#{JZXQNF},#{ZDKJXQGS},#{GJZ},#{YJLX},#{XKFL1},#{XKFL2},#{XKFL3},#{XQJSSSLY},#{QTJSMS},#{XQJSYYHY1},#{XQJSYYHY2},#{XQJSYYHY3},#{JSXQHZMS},#{HZYXDW},#{NTR},#{createDate})
        </insert>
    
        <!-- 更新审核的状态 -->
        <!--refresh-->
        <update id="updateSFSH" parameterType="com.bean.DemandBean">
            update T_DCWJXX set
            SFSH=#{SFSH},V=#{V} where WJID=#{WJID}
        </update>
    
        <!-- 未审核的需求 -->
    <!--    not pass-->
        <select id="getListNo" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where
            SFSH=0
        </select>
    
        <!-- 根据id查看详细信息 -->
        <!--Information-->
        <select id="getById" parameterType="java.lang.String"
            resultType="com.bean.DemandBean">
            select * from T_DCWJXX where WJID= #{WJID}
        </select>
        
        <!-- 以列表形式显示,用户已提交的问卷 -->
        <select id="getMyList" parameterType="java.lang.String" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where username=#{username}
        </select>
        
        <!-- 带条件的搜索,通过name -->
    <!--    select by issue-->
        <select id="getByLikeName" parameterType="java.lang.String" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where JSXQMC like '%${value}%'
        </select>
        
        <!-- 获取所有需求 -->
        <!--get all-->
        <select id="getList" resultType="com.bean.DemandBean">
            select * from T_DCWJXX
        </select>
        
        <!-- 获取每一个分页数据 -->
        <!--get every page-->
        <select id="getListPage" resultType="com.bean.DemandBean">
        select  * from T_DCWJXX order by id limit  #{0},#{1}
            </select>
        
        <!-- 显示基础研究的集合 -->
    <!--    show jcyj list-->
        <select id="getTypeList" resultType="java.lang.String">
            select distinct YJLX from T_DCWJXX
        </select>
        
        <!-- 显示学科分类第一级 -->
        <!--xkfl first level-->
        <select id="getXKFLListA" resultType="java.lang.String">
            select distinct XKFL1 from T_DCWJXX
        </select>
        
        <!-- 显示学科分类第二级 -->
        <!--second level-->
        <select id="getXKFLListB" parameterType="java.lang.String" resultType="java.lang.String">
            select distinct XKFL2 from T_DCWJXX where XKFL1 = #{type}
        </select>
        
        <!-- 显示学科分类第三级 -->
        <!--third level-->
        <select id="getXKFLListC" parameterType="java.lang.String" resultType="java.lang.String">
            select distinct XKFL3 from T_DCWJXX where XKFL2 = #{type}
        </select>
        
        <!-- 显示国民经济行业第一级 -->
        <!--ecology first level-->
        <select id="getXQJSYYHYListA" resultType="java.lang.String">
            select distinct XQJSYYHY1 from T_DCWJXX
        </select>
        
        <!-- 显示国民经济分类第二级 -->
        <!--ecology second level-->
    
        <select id="getXQJSYYHYListB" parameterType="java.lang.String" resultType="java.lang.String">
            select distinct XQJSYYHY2 from T_DCWJXX where XQJSYYHY1 = #{type};
        </select>
        
        <!-- 显示国民经济行业第三级 -->
        <!--ecology third level-->
    
        <select id="getXQJSYYHYListC" parameterType="java.lang.String" resultType="java.lang.String">
            select distinct XQJSYYHY3 from T_DCWJXX where XQJSYYHY2 = #{type};    
        </select>
        
        <!-- 获取n页的数据 -->
        <!-- n  page  data-->
        <select id="getListNext" parameterType="java.lang.String" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where YJLX = #{next}
        </select>
        
        <select id="getListAX" parameterType="java.lang.String" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where XKFL1 = #{next}
        </select>
        
        <select id="getListBX" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where XKFL2 = #{0} and XKFL1 = #{1}
        </select>
        
        <select id="getListCX" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where XKFL3 = #{0} and XKFL2 = #{1}
        </select> 
        
        <select id="getListAH" parameterType="java.lang.String" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where XQJSYYHY1 = #{next}
        </select>
        
        <select id="getListBH" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where XQJSYYHY2 = #{0} and XQJSYYHY1 = #{1}
        </select>
        
        <select id="getListCH" resultType="com.bean.DemandBean">
            select * from T_DCWJXX where XQJSYYHY3 = #{0} and XQJSYYHY2 = #{1}
        </select>
        
        <select id="getWeishenhe" resultType="java.lang.Integer">
            select count(*) as s from T_DCWJXX where SFSH=0
        </select>
        
        <select id="getShenhe" resultType="java.lang.Integer">
            select count(*) as s from T_DCWJXX where SFSH!=0
        </select>
        
        <select id="getTongguo" resultType="java.lang.Integer">
            select count(*) as s from T_DCWJXX where SFSH=1
        </select>
        
        <select id="getTuihui" resultType="java.lang.Integer">
            select count(*) as s from T_DCWJXX where SFSH=2
        </select>
        
        <select id="xdshPolicy" resultType="com.bean.DemandBean">
            select * from T_DCWJXX
            <!--<where>
                <if test='param1 == 1'>
                    #{param2}  =='${param3}'
                </if>
                <if test="param1 == '2'">
                    <if test="param4 == 'AND'">
                        #{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%'
                    </if>
                    <if test="param4 == 'OR'">
                        (#{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%')
                    </if>
                    <if test="param4 == 'NOT'">
                        #{param2} like '%${param3}%' and #{param5} not like '%${param6}%'
                    </if>
                </if>
                <if test="param1 == '3'">
                    <if test="param7 == 'AND'">
                        <if test="param4 == 'AND'">
                            #{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%' #{param7} #{param8} like '%${param9}%'
                        </if>
                        <if test="param4 == 'OR'">
                            (#{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%' #{param7} #{param8} like '%${param9}%')
                        </if>
                        <if test="param4 == 'NOT'">
                            #{param2} like '%${param3}%' and #{param5} not like '%${param6}%' and #{param8} not like '%${param9}%'
                        </if>
                    </if>
                    
                    <if test="param7 == 'OR'">
                        <if test="param4 == 'AND'">
                            #{param2} like '%${param3}%' #{param4} (#{param5} like '%${param6}%' #{param7} #{param8} like '%${param9}%')
                        </if>
                        <if test="param4 == 'OR'">
                            (#{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%' #{param7} #{param8} like '%${param9}%')
                        </if>
                        <if test="param4 == 'NOT'">
                            (#{param2} like '%${param3}%' and #{param5} not like '%${param6}%') #{param7} #{param8} like '%${param9}%'
                        </if>            
                    </if>
                    <if test="param7 == 'NOT'">
                        <if test="param4 == 'AND'">
                            #{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%' and #{param8} not like '%${param9}%'
                        </if>
                        <if test="param4 == 'OR'">
                            (#{param2} like '%${param3}%' #{param4} #{param5} like '%${param6}%') and #{param8} not like '%${param9}%')
                        </if>
                        <if test="param4 == 'NOT'">
                            #{param2} like '%${param3}%' and #{param5} not like '%${param6}%' and #{param8} not like '%${param9}%'
                        </if>
                    </if>
                </if>
            </where>-->
        </select>
    
    
    </mapper>
  • 相关阅读:
    EF生成的SQL语句执行顺序问题。
    关于scope_identity()与 @@IDENTITY
    按条件设置gridcontrol 单元格属性
    DevExpress gridcontrol Master-Detail绑定到对象类型
    dev ChartControl 备忘
    gridcontrol 图片列异步加载
    关于EmitMapper,映射配置
    asp.net Hessian 服务的注册
    XtrasReport 标签打印
    Devexpress + wcf +ef 批量更新处理
  • 原文地址:https://www.cnblogs.com/ywqtro/p/13917206.html
Copyright © 2011-2022 走看看