Commit 7cb89f74ed92c42d48f334c60c905bfbb4f1a7a4

Authored by 陈杰
1 parent 473605c5
Exists in master

bug 修复

src/main/java/com/sincere/student/controller/AdminController.java
... ... @@ -97,21 +97,7 @@ public class AdminController {
97 97 submitFile.setFileUrl(null);
98 98 }else {
99 99 List<Point> list = ExcelUtils.analysisExcel(submitFile.getFileUrl());
100   - List<Point> points = new ArrayList<>();
101   - for(Point point : list){
102   - Integer universityId = universityService.selectByName(point.getUniversityName());
103   - if(universityId == null){
104   - throw new ResultException(902,point.getUniversityName()+"不存在");
105   - }
106   - point.setUniversityId(universityId);
107   - Integer majorId = universityService.selectIdByMajor(point.getMajor(),universityId);
108   - if(majorId == null){
109   - throw new ResultException(902,point.getUniversityName()+"-"+point.getMajor()+"关系不存在");
110   - }
111   - point.setMajorId(majorId);
112   - points.add(point);
113   - }
114   - submitFile.setList(points);
  100 + submitFile.setList(list);
115 101 }
116 102 submitService.update(submitFile);
117 103 }catch (ResultException e){
... ... @@ -133,21 +119,7 @@ public class AdminController {
133 119 }
134 120 try{
135 121 List<Point> list = ExcelUtils.analysisExcel(submitFile.getFileUrl());
136   - List<Point> points = new ArrayList<>();
137   - for(Point point : list){
138   - Integer universityId = universityService.selectByName(point.getUniversityName());
139   - if(universityId == null){
140   - throw new ResultException(902,point.getUniversityName()+"不存在");
141   - }
142   - point.setUniversityId(universityId);
143   - Integer majorId = universityService.selectIdByMajor(point.getMajor(),universityId);
144   - if(majorId == null){
145   - throw new ResultException(902,point.getUniversityName()+"-"+point.getMajor()+"关系不存在");
146   - }
147   - point.setMajorId(majorId);
148   - points.add(point);
149   - }
150   - submitFile.setList(points);
  122 + submitFile.setList(list);
151 123 submitService.create(submitFile);
152 124 }catch (ResultException e){
153 125 e.printStackTrace();
... ... @@ -268,9 +240,13 @@ public class AdminController {
268 240 result.setMessage("同一栏目下,已有该学校招生咨询");
269 241 }else {
270 242 int id = consultService.create(universityConsult);
271   - String name = universityService.getById(universityConsult.getUniversityId()).getName();
  243 + try{
  244 + String name = universityService.getById(universityConsult.getUniversityId()).getName();
  245 + dto.setName(name);
  246 + }catch (Exception e){
  247 +
  248 + }
272 249 dto.setId(id);
273   - dto.setName(name);
274 250 result.setData(dto);
275 251 }
276 252 return result ;
... ... @@ -315,8 +291,12 @@ public class AdminController {
315 291 BaseDto<ReturnDto> result = new BaseDto() ;
316 292 ReturnDto dto = new ReturnDto();
317 293 int id = videoService.create(video);
318   - String name = universityService.getById(video.getUniversityId()).getName();
319   - dto.setName(name);
  294 + try{
  295 + String name = universityService.getById(video.getUniversityId()).getName();
  296 + dto.setName(name);
  297 + }catch (Exception e){
  298 +
  299 + }
320 300 dto.setId(id);
321 301 result.setData(dto);
322 302 return result ;
... ...
src/main/java/com/sincere/student/mapper/UniversityPointMapper.java
... ... @@ -7,15 +7,5 @@ import java.util.List;
7 7 public interface UniversityPointMapper {
8 8 int deleteBySubmit(Integer id);
9 9  
10   - int insert(Point record);
11   -
12 10 int insertBatch(List<Point> list);
13   -
14   - int insertSelective(Point record);
15   -
16   - Point selectByPrimaryKey(Integer id);
17   -
18   - int updateByPrimaryKeySelective(Point record);
19   -
20   - int updateByPrimaryKey(Point record);
21 11 }
22 12 \ No newline at end of file
... ...
src/main/java/com/sincere/student/model/Point.java
... ... @@ -7,9 +7,7 @@ public class Point {
7 7  
8 8 private Integer submitId;
9 9 private String universityName;
10   - private Integer universityId;
11 10 private String major ;
12   - private Integer majorId;
13 11  
14 12 private Integer grade;
15 13  
... ... @@ -18,22 +16,8 @@ public class Point {
18 16 private Integer rank;
19 17  
20 18 private Date createTime;
21   -
22   - public String getUniversityName() {
23   - return universityName;
24   - }
25   -
26   - public void setUniversityName(String universityName) {
27   - this.universityName = universityName;
28   - }
29   -
30   - public String getMajor() {
31   - return major;
32   - }
33   -
34   - public void setMajor(String major) {
35   - this.major = major;
36   - }
  19 + private String province;
  20 + private String city ;
37 21  
38 22 public Integer getId() {
39 23 return id;
... ... @@ -51,20 +35,20 @@ public class Point {
51 35 this.submitId = submitId;
52 36 }
53 37  
54   - public Integer getUniversityId() {
55   - return universityId;
  38 + public String getUniversityName() {
  39 + return universityName;
56 40 }
57 41  
58   - public void setUniversityId(Integer universityId) {
59   - this.universityId = universityId;
  42 + public void setUniversityName(String universityName) {
  43 + this.universityName = universityName;
60 44 }
61 45  
62   - public Integer getMajorId() {
63   - return majorId;
  46 + public String getMajor() {
  47 + return major;
64 48 }
65 49  
66   - public void setMajorId(Integer majorId) {
67   - this.majorId = majorId;
  50 + public void setMajor(String major) {
  51 + this.major = major;
68 52 }
69 53  
70 54 public Integer getGrade() {
... ... @@ -98,4 +82,20 @@ public class Point {
98 82 public void setCreateTime(Date createTime) {
99 83 this.createTime = createTime;
100 84 }
  85 +
  86 + public String getProvince() {
  87 + return province;
  88 + }
  89 +
  90 + public void setProvince(String province) {
  91 + this.province = province;
  92 + }
  93 +
  94 + public String getCity() {
  95 + return city;
  96 + }
  97 +
  98 + public void setCity(String city) {
  99 + this.city = city;
  100 + }
101 101 }
102 102 \ No newline at end of file
... ...
src/main/java/com/sincere/student/utils/ExcelUtils.java
... ... @@ -85,11 +85,22 @@ public class ExcelUtils {
85 85 cell5.setCellType(CellType.STRING);
86 86 point.setRank(Integer.valueOf(cell5.getStringCellValue().trim()));
87 87 }
  88 + Cell cell6 = sheetRow.getCell(5);
  89 + if(cell6 != null){
  90 + cell6.setCellType(CellType.STRING);
  91 + point.setProvince(cell6.getStringCellValue().trim());
  92 + }
  93 + Cell cell7 = sheetRow.getCell(6);
  94 + if(cell7 != null){
  95 + cell7.setCellType(CellType.STRING);
  96 + point.setCity(cell7.getStringCellValue());
  97 + }
88 98 list.add(point);
89 99 }
90 100 }
91 101 return list ;
92 102 }catch (Exception e){
  103 + e.printStackTrace();
93 104 throw new ResultException(999,"系统错误");
94 105 }finally {
95 106 try{
... ...
src/main/resources/mapper/UniversityPointMapper.xml
... ... @@ -4,134 +4,27 @@
4 4 <resultMap id="BaseResultMap" type="com.sincere.student.model.Point">
5 5 <id column="id" jdbcType="INTEGER" property="id" />
6 6 <result column="submit_id" jdbcType="INTEGER" property="submitId" />
7   - <result column="university_id" jdbcType="INTEGER" property="universityId" />
8   - <result column="major_id" jdbcType="INTEGER" property="majorId" />
  7 + <result column="university" jdbcType="VARCHAR" property="universityName" />
  8 + <result column="major" jdbcType="VARCHAR" property="major" />
9 9 <result column="grade" jdbcType="VARCHAR" property="grade" />
10 10 <result column="enroll_number" jdbcType="INTEGER" property="enrollNumber" />
11 11 <result column="rank" jdbcType="INTEGER" property="rank" />
12 12 <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  13 + <result column="province" jdbcType="VARCHAR" property="province" />
  14 + <result column="city" jdbcType="VARCHAR" property="city" />
13 15 </resultMap>
14 16  
15 17 <insert id="insertBatch" parameterType="java.util.List">
16   - insert into university_point (submit_id, university_id , major_id ,grade ,enroll_number ,rank,create_time)
  18 + insert into university_point (submit_id, university , major ,grade ,enroll_number ,rank,create_time,province,city)
17 19 values
18 20 <foreach collection="list" item="emp" separator=",">
19   - (#{emp.submitId}, #{emp.universityId}, #{emp.majorId}, #{emp.grade}, #{emp.enrollNumber}, #{emp.rank},GETDATE())
  21 + (#{emp.submitId}, #{emp.universityName}, #{emp.major}, #{emp.grade}, #{emp.enrollNumber}, #{emp.rank},GETDATE(),#{emp.province},#{emp.city})
20 22 </foreach>
21 23 </insert>
22 24  
23   - <sql id="Base_Column_List">
24   - id, submit_id, university_id, major_id, grade, enroll_number, rank, create_time
25   - </sql>
26   - <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
27   - select
28   - <include refid="Base_Column_List" />
29   - from university_point
30   - where id = #{id,jdbcType=INTEGER}
31   - </select>
32 25 <delete id="deleteBySubmit" parameterType="java.lang.Integer">
33 26 delete from university_point
34 27 where submit_id = #{id,jdbcType=INTEGER}
35 28 </delete>
36   - <insert id="insert" parameterType="com.sincere.student.model.Point">
37   - insert into university_point (id, submit_id, university_id,
38   - major_id, grade, enroll_number,
39   - rank, create_time)
40   - values (#{id,jdbcType=INTEGER}, #{submitId,jdbcType=INTEGER}, #{universityId,jdbcType=INTEGER},
41   - #{majorId,jdbcType=INTEGER}, #{grade,jdbcType=VARCHAR}, #{enrollNumber,jdbcType=INTEGER},
42   - #{rank,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP})
43   - </insert>
44   - <insert id="insertSelective" parameterType="com.sincere.student.model.Point">
45   - insert into university_point
46   - <trim prefix="(" suffix=")" suffixOverrides=",">
47   - <if test="id != null">
48   - id,
49   - </if>
50   - <if test="submitId != null">
51   - submit_id,
52   - </if>
53   - <if test="universityId != null">
54   - university_id,
55   - </if>
56   - <if test="majorId != null">
57   - major_id,
58   - </if>
59   - <if test="grade != null">
60   - grade,
61   - </if>
62   - <if test="enrollNumber != null">
63   - enroll_number,
64   - </if>
65   - <if test="rank != null">
66   - rank,
67   - </if>
68   - <if test="createTime != null">
69   - create_time,
70   - </if>
71   - </trim>
72   - <trim prefix="values (" suffix=")" suffixOverrides=",">
73   - <if test="id != null">
74   - #{id,jdbcType=INTEGER},
75   - </if>
76   - <if test="submitId != null">
77   - #{submitId,jdbcType=INTEGER},
78   - </if>
79   - <if test="universityId != null">
80   - #{universityId,jdbcType=INTEGER},
81   - </if>
82   - <if test="majorId != null">
83   - #{majorId,jdbcType=INTEGER},
84   - </if>
85   - <if test="grade != null">
86   - #{grade,jdbcType=VARCHAR},
87   - </if>
88   - <if test="enrollNumber != null">
89   - #{enrollNumber,jdbcType=INTEGER},
90   - </if>
91   - <if test="rank != null">
92   - #{rank,jdbcType=INTEGER},
93   - </if>
94   - <if test="createTime != null">
95   - #{createTime,jdbcType=TIMESTAMP},
96   - </if>
97   - </trim>
98   - </insert>
99   - <update id="updateByPrimaryKeySelective" parameterType="com.sincere.student.model.Point">
100   - update university_point
101   - <set>
102   - <if test="submitId != null">
103   - submit_id = #{submitId,jdbcType=INTEGER},
104   - </if>
105   - <if test="universityId != null">
106   - university_id = #{universityId,jdbcType=INTEGER},
107   - </if>
108   - <if test="majorId != null">
109   - major_id = #{majorId,jdbcType=INTEGER},
110   - </if>
111   - <if test="grade != null">
112   - grade = #{grade,jdbcType=VARCHAR},
113   - </if>
114   - <if test="enrollNumber != null">
115   - enroll_number = #{enrollNumber,jdbcType=INTEGER},
116   - </if>
117   - <if test="rank != null">
118   - rank = #{rank,jdbcType=INTEGER},
119   - </if>
120   - <if test="createTime != null">
121   - create_time = #{createTime,jdbcType=TIMESTAMP},
122   - </if>
123   - </set>
124   - where id = #{id,jdbcType=INTEGER}
125   - </update>
126   - <update id="updateByPrimaryKey" parameterType="com.sincere.student.model.Point">
127   - update university_point
128   - set submit_id = #{submitId,jdbcType=INTEGER},
129   - university_id = #{universityId,jdbcType=INTEGER},
130   - major_id = #{majorId,jdbcType=INTEGER},
131   - grade = #{grade,jdbcType=VARCHAR},
132   - enroll_number = #{enrollNumber,jdbcType=INTEGER},
133   - rank = #{rank,jdbcType=INTEGER},
134   - create_time = #{createTime,jdbcType=TIMESTAMP}
135   - where id = #{id,jdbcType=INTEGER}
136   - </update>
  29 +
137 30 </mapper>
138 31 \ No newline at end of file
... ...
src/main/resources/mapper/UniversityReplyMapper.xml
... ... @@ -15,7 +15,7 @@
15 15 <include refid="Base_Column_List" />
16 16 from university_reply
17 17 where message_id = #{id,jdbcType=INTEGER}
18   - order by create_time
  18 + order by create_time desc
19 19 </select>
20 20 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
21 21 delete from university_reply
... ...
src/main/resources/mapper/UniversitySubmitFileMapper.xml
... ... @@ -18,23 +18,15 @@
18 18 <select id="getAppListCount" parameterType="com.sincere.student.dto.PointSearchDto" resultType="java.lang.Integer">
19 19 select count(DISTINCT(sf.id))
20 20 from university_submit_file sf join university_point p on sf.id = p.submit_id
21   - join university_info info on p.university_id = info.id
22   - join university_major m on p.major_id = m.id
23 21 <where>
24 22 <if test="submitId != 0">
25 23 and sf.id = #{submitId}
26 24 </if>
27   - <if test="universityName != null and universityName != '' ">
28   - and info.name like #{universityName}
29   - </if>
30   - <if test="province != null and province != '' ">
31   - and info.province = #{province}
32   - </if>
33   - <if test="city != null and city != '' ">
34   - and info.city = #{city}
35   - </if>
36 25 <if test="majorName != null and majorName != '' ">
37   - and m.major like #{majorName}
  26 + and p.major like #{majorName}
  27 + </if>
  28 + <if test="universityName != null and universityName != '' ">
  29 + and p.university like #{universityName}
38 30 </if>
39 31 <if test="point != 0 ">
40 32 <![CDATA[ and p.grade > #{point}-5 and p.grade < #{point} +5 ]]>
... ... @@ -46,32 +38,24 @@
46 38 </select>
47 39  
48 40 <select id="getAppList" parameterType="com.sincere.student.dto.PointSearchDto" resultMap="LineMap">
49   - select sf.id , sf.title ,info.id as universityId , info.name , m.major , p.enroll_number , p.rank , p.grade
  41 + select sf.id , sf.title , p.university as name , p.major , p.enroll_number , p.rank , p.grade
50 42 from university_submit_file sf join university_point p on sf.id = p.submit_id
51   - join university_info info on p.university_id = info.id
52   - join university_major m on p.major_id = m.id
53 43 <where>
54 44 <if test="submitId != 0">
55 45 and sf.id = #{submitId}
56 46 </if>
57   - <if test="universityName != null and universityName != '' ">
58   - and info.name like #{universityName}
59   - </if>
60   - <if test="province != null and province != '' ">
61   - and info.province = #{province}
62   - </if>
63   - <if test="city != null and city != '' ">
64   - and info.city = #{city}
65   - </if>
66 47 <if test="majorName != null and majorName != '' ">
67   - and m.major like #{majorName}
  48 + and p.major like #{majorName}
68 49 </if>
69   - <if test="point != 0 ">
70   - <![CDATA[ and p.grade >= #{point}-5 and p.grade <= #{point} +5 ]]>
71   - </if>
72   - <if test="rank != 0 ">
73   - <![CDATA[ and p.rank >= #{rank}-100 and p.rank <= #{rank} +100 ]]>
  50 + <if test="universityName != null and universityName != '' ">
  51 + and p.university like #{universityName}
74 52 </if>
  53 + <if test="point != 0 ">
  54 + <![CDATA[ and p.grade >= #{point}-5 and p.grade <= #{point} +5 ]]>
  55 + </if>
  56 + <if test="rank != 0 ">
  57 + <![CDATA[ and p.rank >= #{rank}-100 and p.rank <= #{rank} +100 ]]>
  58 + </if>
75 59 </where>
76 60 order by sf.id
77 61 </select>
... ...