Jelajahi Sumber

派位,审批等功能

xiao547607 4 tahun lalu
induk
melakukan
2fe08722d7

+ 1 - 0
common/src/main/java/com/jpsoft/campus/modules/base/dao/ApprovalInfoDAO.java

@@ -17,4 +17,5 @@ public interface ApprovalInfoDAO {
 	List<ApprovalInfo> list();
 	List<ApprovalInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
 	List<ApprovalInfo> findByApplicationId(String applicationId);
+	List<ApprovalInfo> findByApplicationIdAndOperation(String applicationId,String operation);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/campus/modules/base/entity/ApplicationMiddle.java

@@ -126,4 +126,7 @@ public class ApplicationMiddle {
 
 	@ApiModelProperty(value = "入学通知书")
 	private String offerImg;
+
+	@ApiModelProperty(value = "新类型")
+	private String newType;
 }

+ 3 - 0
common/src/main/java/com/jpsoft/campus/modules/base/entity/ApplicationPrimary.java

@@ -122,4 +122,7 @@ public class ApplicationPrimary {
 
     @ApiModelProperty(value = "入学通知书")
     private String offerImg;
+
+    @ApiModelProperty(value = "新类型")
+    private String newType;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/campus/modules/base/entity/ApportionDetail.java

@@ -86,4 +86,6 @@ public class ApportionDetail {
 	private String schoolName;
 	@ApiModelProperty(value = "学生名称")
 	private String studentName;
+	@ApiModelProperty(value = "学生证件号")
+	private String studentCard;
 }

+ 1 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/ApprovalInfoService.java

@@ -15,4 +15,5 @@ public interface ApprovalInfoService {
 	List<ApprovalInfo> list();
 	Page<ApprovalInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 	List<ApprovalInfo> findByApplicationId(String applicationId);
+	List<ApprovalInfo> findByApplicationIdAndOperation(String applicationId,String operation);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/impl/ApprovalInfoServiceImpl.java

@@ -74,4 +74,9 @@ public class ApprovalInfoServiceImpl implements ApprovalInfoService {
 		// TODO Auto-generated method stub
 		return approvalInfoDAO.findByApplicationId(applicationId);
 	}
+
+	@Override
+	public List<ApprovalInfo> findByApplicationIdAndOperation(String applicationId,String operation){
+		return approvalInfoDAO.findByApplicationIdAndOperation(applicationId,operation);
+	}
 }

+ 9 - 1
common/src/main/resources/mapper/base/ApplicationMiddle.xml

@@ -27,6 +27,7 @@
         <result property="isSend" column="is_send"/>
         <result property="sendTime" column="send_time"/>
         <result property="offerImg" column="offer_img"/>
+        <result property="newType" column="new_type"/>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.campus.modules.base.entity.ApplicationMiddle">
         <!--
@@ -37,7 +38,7 @@
         <![CDATA[
 		insert into base_application_middle
 	    (id_,create_by,create_time,update_by,update_time,del_flag,type_,status_,category_id,now_address,person_id,school_id,student_id,street_id,community_id,choose_reason,hit_,offer_id,
-	    is_send,send_time,offer_code,offer_img
+	    is_send,send_time,offer_code,offer_img,new_type
 	    )
 		values
 		(
@@ -63,6 +64,7 @@
 			,#{sendTime,jdbcType=TIMESTAMP}
 			,#{offerCode,jdbcType=VARCHAR}
 			,#{offerImg,jdbcType=VARCHAR}
+			,#{newType,jdbcType=VARCHAR}
 		)
 	]]>
     </insert>
@@ -135,6 +137,9 @@
             <if test="offerImg!=null">
                 offer_img=#{offerImg,jdbcType=VARCHAR},
             </if>
+            <if test="newType!=null">
+                new_type=#{newType,jdbcType=VARCHAR},
+            </if>
         </set>
         where id_=#{id}
     </update>
@@ -164,6 +169,9 @@
 			select * from base_application_middle
 		]]>
         <where>
+            <if test="searchParams.delFlag != null">
+                and del_flag like #{searchParams.delFlag}
+            </if>
             <if test="searchParams.type != null">
                 and type_ like #{searchParams.type}
             </if>

+ 6 - 1
common/src/main/resources/mapper/base/ApplicationPrimary.xml

@@ -26,6 +26,7 @@
         <result property="isSend" column="is_send"/>
         <result property="sendTime" column="send_time"/>
         <result property="offerImg" column="offer_img"/>
+        <result property="newType" column="new_type"/>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.campus.modules.base.entity.ApplicationPrimary">
         <!--
@@ -37,7 +38,7 @@
 		insert into base_application_primary
 	    (id_,create_by,create_time,update_by,update_time,del_flag,type_,
 	    status_,category_id,now_address,person_id,student_id,street_id,community_id,school_id,hit_,offer_id,
-	    is_send,send_time,offer_code,offer_img
+	    is_send,send_time,offer_code,offer_img,new_type
 	    )
 		values
 		(
@@ -62,6 +63,7 @@
 			,#{sendTime,jdbcType=TIMESTAMP}
 			,#{offerCode,jdbcType=VARCHAR}
 			,#{offerImg,jdbcType=VARCHAR}
+			,#{newType,jdbcType=VARCHAR}
 		)
 	]]>
     </insert>
@@ -131,6 +133,9 @@
             <if test="offerImg!=null">
                 offer_img=#{offerImg,jdbcType=VARCHAR},
             </if>
+            <if test="newType!=null">
+                new_type=#{newType,jdbcType=VARCHAR},
+            </if>
         </set>
         where id_=#{id}
     </update>

+ 9 - 1
common/src/main/resources/mapper/base/ApportionDetail.xml

@@ -17,6 +17,7 @@
 			<result property="updateBy" column="update_by" />
 			<result property="updateTime" column="update_time" />
 			<result property="studentName" column="student_name" />
+			<result property="studentCard" column="student_card" />
 			<result property="schoolName" column="school_name" />
 			</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.campus.modules.base.entity.ApportionDetail">
@@ -101,7 +102,8 @@
 				SELECT
 					t1.*,
 					t2.name_ AS student_name,
-					t3.name_ AS school_name
+					t3.name_ AS school_name,
+					t2.id_card as student_card
 				FROM
 				base_apportion_detail t1
 				LEFT JOIN base_student_info t2 ON t1.student_id = t2.id_
@@ -114,6 +116,12 @@
 			<if test="searchParams.winner != null">
 				and t1.winner_ = #{searchParams.winner}
 			</if>
+			<if test="searchParams.delFlag != null">
+				and t1.del_flag = #{searchParams.delFlag}
+			</if>
+			<if test="searchParams.createBy != null">
+				and t1.create_by = #{searchParams.createBy}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 9 - 0
common/src/main/resources/mapper/base/ApprovalInfo.xml

@@ -118,4 +118,13 @@
 			order by create_time asc
 		]]>
     </select>
+    <select id="findByApplicationIdAndOperation" parameterType="string" resultMap="ApprovalInfoMap">
+        <![CDATA[
+			select * from base_approval_info
+			where application_id=#{applicationId}
+			and remark_ like #{operation}
+			and del_flag=0
+			order by create_time desc
+		]]>
+    </select>
 </mapper>

+ 50 - 6
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationMiddleController.java

@@ -1380,7 +1380,7 @@ public class ApplicationMiddleController {
                     }
                 }else if("90".equals(status)){
                     //获取最大编号
-                    int serialNum = offerInfoService.findMaxSerialNum(applicationMiddle.getSchoolId(),"1");
+                    int serialNum = offerInfoService.findMaxSerialNum(applicationMiddle.getSchoolId(),"2");
                     serialNum = serialNum+1;//最大编号加一
                     Calendar date = Calendar.getInstance();
                     String year = String.valueOf(date.get(Calendar.YEAR));
@@ -1394,13 +1394,13 @@ public class ApplicationMiddleController {
                     off.setApplicationId(applicationMiddle.getId());
                     off.setStudentId(applicationMiddle.getStudentId());
                     off.setEnrollmentType("2");//中学
-                    off.setSchoolId(applicationMiddle.getSchoolId());
+                    off.setSchoolId(applicationMiddle.getOfferId());
                     off.setSerialNum(serialNum);
                     off.setCode(code);
 
                     applicationMiddle.setOfferCode(code);
 
-                    SchoolInfo schoolInfo = schoolInfoService.get(applicationMiddle.getSchoolId());
+                    SchoolInfo schoolInfo = schoolInfoService.get(applicationMiddle.getOfferId());
                     PersonInfo personInfo = personInfoService.get(applicationMiddle.getPersonId());
                     StudentInfo studentInfo = studentInfoService.get(applicationMiddle.getStudentId());
                     String bdUrl = toPressText(code,personInfo.getName(),studentInfo.getName(), schoolInfo.getName());
@@ -1572,7 +1572,7 @@ public class ApplicationMiddleController {
                 //微信消息推送 发送完成录取通知
                 applicationMiddle.setStatus(nextStatus);
 
-                int serialNum = offerInfoService.findMaxSerialNum(applicationMiddle.getSchoolId(),"1");
+                int serialNum = offerInfoService.findMaxSerialNum(applicationMiddle.getSchoolId(),"2");
                 serialNum = serialNum+1;//最大编号加一
                 Calendar date = Calendar.getInstance();
                 String year = String.valueOf(date.get(Calendar.YEAR));
@@ -1586,12 +1586,12 @@ public class ApplicationMiddleController {
                 off.setApplicationId(applicationMiddle.getId());
                 off.setStudentId(applicationMiddle.getStudentId());
                 off.setEnrollmentType("2");//小学
-                off.setSchoolId(applicationMiddle.getSchoolId());
+                off.setSchoolId(applicationMiddle.getOfferId());
                 off.setSerialNum(serialNum);
                 off.setCode(code);
                 applicationMiddle.setOfferCode(code);
 
-                SchoolInfo schoolInfo = schoolInfoService.get(applicationMiddle.getSchoolId());
+                SchoolInfo schoolInfo = schoolInfoService.get(applicationMiddle.getOfferId());
                 PersonInfo personInfo = personInfoService.get(applicationMiddle.getPersonId());
                 StudentInfo studentInfo = studentInfoService.get(applicationMiddle.getStudentId());
                 String bdUrl = toPressText(code, personInfo.getName(), studentInfo.getName(), schoolInfo.getName());
@@ -1775,4 +1775,48 @@ public class ApplicationMiddleController {
             }
         }
     }
+
+
+    @ApiOperation(value="修改新类型")
+    @PostMapping("changeNewType")
+    public MessageResult<Integer> changeNewType(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("type", "C");
+            searchParams.put("delFlag", false);
+            Page<ApplicationMiddle> page = applicationMiddleService.pageSearch(searchParams,0,100000,false,sortList);
+
+            for (ApplicationMiddle am : page.getResult()) {
+                List<ApprovalInfo> aiList = approvalInfoService.findByApplicationIdAndOperation(am.getId(),"%C%");
+                if(aiList.size() > 0){
+                    ApprovalInfo ai = aiList.get(0);
+                    am.setNewType(ai.getRemark());
+                    applicationMiddleService.update(am);
+                }
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("操作失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 48 - 5
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationPrimaryController.java

@@ -1538,21 +1538,20 @@ public class ApplicationPrimaryController {
                     serialNum = serialNum+1;//最大编号加一
                     Calendar date = Calendar.getInstance();
                     String year = String.valueOf(date.get(Calendar.YEAR));
-                    SchoolInfo si = schoolInfoService.get(applicationPrimary.getSchoolId());
+                    SchoolInfo si = schoolInfoService.get(applicationPrimary.getOfferId());
                     //开发区+年份+学校编号2位+序号4位
                     String code = "KFQ" + year + si.getSchoolCode() + String.format("%04d", serialNum);
                     //保存录取信息表
                     OfferInfo off = new OfferInfo();
                     off.setId(UUID.randomUUID().toString());
-
                     off.setApplicationId(applicationPrimary.getId());
                     off.setStudentId(applicationPrimary.getStudentId());
                     off.setEnrollmentType("1");//小学
-                    off.setSchoolId(applicationPrimary.getSchoolId());
+                    off.setSchoolId(applicationPrimary.getOfferId());
                     off.setSerialNum(serialNum);
 
                     applicationPrimary.setOfferCode(code);
-                    SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
+                    SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getOfferId());
                     PersonInfo personInfo = personInfoService.get(applicationPrimary.getPersonId());
                     StudentInfo studentInfo = studentInfoService.get(applicationPrimary.getStudentId());
                     String bdUrl = toPressText(code,personInfo.getName(),studentInfo.getName(), schoolInfo.getName());
@@ -1756,7 +1755,7 @@ public class ApplicationPrimaryController {
                     off.setCreateTime(new Date());
 
                     applicationPrimary.setOfferCode(code);
-                    SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getSchoolId());
+                    SchoolInfo schoolInfo = schoolInfoService.get(applicationPrimary.getOfferId());
                     PersonInfo personInfo = personInfoService.get(applicationPrimary.getPersonId());
                     StudentInfo studentInfo = studentInfoService.get(applicationPrimary.getStudentId());
                     String bdUrl = toPressText(code, personInfo.getName(), studentInfo.getName(), schoolInfo.getName());
@@ -1993,4 +1992,48 @@ public class ApplicationPrimaryController {
             }
         }
     }
+
+
+    @ApiOperation(value="修改新类型")
+    @PostMapping("changeNewType")
+    public MessageResult<Integer> changeNewType(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("type", "C");
+            searchParams.put("delFlag", false);
+            Page<ApplicationPrimary> page = applicationPrimaryService.pageSearch(searchParams,0,100000,false,sortList);
+
+            for (ApplicationPrimary ap : page.getResult()) {
+                List<ApprovalInfo> aiList = approvalInfoService.findByApplicationIdAndOperation(ap.getId(),"%C%");
+                if(aiList.size() > 0){
+                    ApprovalInfo ai = aiList.get(0);
+                    ap.setNewType(ai.getRemark());
+                    applicationPrimaryService.update(ap);
+                }
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("操作失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 185 - 0
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApportionController.java

@@ -323,6 +323,13 @@ public class ApportionController {
             apportion.setUpdateTime(new Date());
             apportionService.insert(apportion);
 
+            if(amount < 1){
+                map.put("apportionId",apportion.getId());
+                msgResult.setResult(true);
+                msgResult.setData(map);
+                return msgResult;
+            }
+
             //写入派位列表
             for(int i=0;i<applicationPrimaryPage.size();i++){
                 ApplicationPrimary applicationPrimary = applicationPrimaryPage.get(i);
@@ -365,6 +372,92 @@ public class ApportionController {
         return msgResult;
     }
 
+    @ApiOperation(value="开始派位-小学-测试")
+    @PostMapping("startApportionPrimaryTest")
+    public MessageResult<Map> startApportionPrimaryTest(String schoolId,String type,Integer amount,@RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+        Map<String,Object> map = new HashMap<>();
+
+        try {
+            //读取等待派位人员信息列表
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("status","60");
+            if (StringUtils.isNotEmpty(schoolId)) {
+                searchParams.put("schoolId",schoolId);
+            }
+            if (StringUtils.isNotEmpty(type)) {
+                DataDictionary dataDictionary = dataDictionaryService.findByCatalogNameAndValue("C类生证明",type);
+                searchParams.put("categoryId",dataDictionary.getId());
+            }
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+            Page<ApplicationPrimary> applicationPrimaryPage = applicationPrimaryService.pageSearch(searchParams,1,100000,false,sortList);
+
+            //随机抽取
+            if(amount > applicationPrimaryPage.size()){
+                amount = applicationPrimaryPage.size();
+            }
+            List<Integer> integerList = new ArrayList<>();
+            Random random = new Random();
+            for(int i=0;i<amount;i++){
+                for(int j=0;j>-1;j++) {
+                    Integer ran = random.nextInt(applicationPrimaryPage.size());
+                    if (!integerList.contains(ran)) {
+                        integerList.add(ran);
+                        break;
+                    }
+                }
+            }
+
+            //写入派位信息
+            Apportion apportion = new Apportion();
+            apportion.setId(UUID.randomUUID().toString());
+            apportion.setSchoolId(schoolId);
+            apportion.setType(type);
+            apportion.setDelFlag(false);
+            apportion.setCreateBy("测试派位系统");
+            apportion.setCreateTime(new Date());
+            apportionService.insert(apportion);
+
+            if(amount < 1){
+                map.put("apportionId",apportion.getId());
+                msgResult.setResult(true);
+                msgResult.setData(map);
+                return msgResult;
+            }
+
+            //写入派位列表
+            for(int i=0;i<applicationPrimaryPage.size();i++){
+                ApplicationPrimary applicationPrimary = applicationPrimaryPage.get(i);
+                ApportionDetail apportionDetail = new ApportionDetail();
+                apportionDetail.setId(UUID.randomUUID().toString());
+                apportionDetail.setApportionId(apportion.getId());
+                apportionDetail.setApplicationId(applicationPrimary.getId());
+                apportionDetail.setStudentId(applicationPrimary.getStudentId());
+                apportionDetail.setPersonId(applicationPrimary.getPersonId());
+                apportionDetail.setSchoolId(schoolId);
+                Boolean bl = integerList.contains(i) == true ? true : false;
+                apportionDetail.setWinner(bl);
+                apportionDetail.setDelFlag(true);
+                apportionDetail.setCreateBy("测试派位系统");
+                apportionDetail.setCreateTime(new Date());
+                apportionDetailService.insert(apportionDetail);
+            }
+
+            map.put("apportionId",apportion.getId());
+            msgResult.setResult(true);
+            msgResult.setData(map);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageListPrimary",method = RequestMethod.POST)
     public MessageResult<Map> pageListPrimary(
@@ -512,6 +605,13 @@ public class ApportionController {
             apportion.setUpdateTime(new Date());
             apportionService.insert(apportion);
 
+            if(amount < 1){
+                map.put("apportionId",apportion.getId());
+                msgResult.setResult(true);
+                msgResult.setData(map);
+                return msgResult;
+            }
+
             //写入派位列表
             for(int i=0;i<ApplicationMiddlePage.size();i++){
                 ApplicationMiddle applicationMiddle = ApplicationMiddlePage.get(i);
@@ -554,6 +654,91 @@ public class ApportionController {
         return msgResult;
     }
 
+    @ApiOperation(value="开始派位-中学-测试")
+    @PostMapping("startApportionMiddleTest")
+    public MessageResult<Map> startApportionMiddleTest(String schoolId,String type,Integer amount,@RequestAttribute String subject){
+        MessageResult<Map> msgResult = new MessageResult<>();
+        Map<String,Object> map = new HashMap<>();
+
+        try {
+            //读取等待派位人员信息列表
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("status","60");
+            if (StringUtils.isNotEmpty(schoolId)) {
+                searchParams.put("schoolId",schoolId);
+            }
+            if (StringUtils.isNotEmpty(type)) {
+                searchParams.put("type",type);
+            }
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time","desc"));
+            Page<ApplicationMiddle> ApplicationMiddlePage = applicationMiddleService.pageSearch(searchParams,1,100000,false,sortList);
+
+            //随机抽取
+            if(amount > ApplicationMiddlePage.size()){
+                amount = ApplicationMiddlePage.size();
+            }
+            List<Integer> integerList = new ArrayList<>();
+            Random random = new Random();
+            for(int i=0;i<amount;i++){
+                for(int j=0;j>-1;j++) {
+                    Integer ran = random.nextInt(ApplicationMiddlePage.size());
+                    if (!integerList.contains(ran)) {
+                        integerList.add(ran);
+                        break;
+                    }
+                }
+            }
+
+            //写入派位信息
+            Apportion apportion = new Apportion();
+            apportion.setId(UUID.randomUUID().toString());
+            apportion.setSchoolId(schoolId);
+            apportion.setType(type);
+            apportion.setDelFlag(false);
+            apportion.setCreateBy("测试派位系统");
+            apportion.setCreateTime(new Date());
+            apportionService.insert(apportion);
+
+            if(amount < 1){
+                map.put("apportionId",apportion.getId());
+                msgResult.setResult(true);
+                msgResult.setData(map);
+                return msgResult;
+            }
+
+            //写入派位列表
+            for(int i=0;i<ApplicationMiddlePage.size();i++){
+                ApplicationMiddle applicationMiddle = ApplicationMiddlePage.get(i);
+                ApportionDetail apportionDetail = new ApportionDetail();
+                apportionDetail.setId(UUID.randomUUID().toString());
+                apportionDetail.setApportionId(apportion.getId());
+                apportionDetail.setApplicationId(applicationMiddle.getId());
+                apportionDetail.setStudentId(applicationMiddle.getStudentId());
+                apportionDetail.setPersonId(applicationMiddle.getPersonId());
+                apportionDetail.setSchoolId(schoolId);
+                Boolean bl = integerList.contains(i) == true ? true : false;
+                apportionDetail.setWinner(bl);
+                apportionDetail.setDelFlag(true);
+                apportionDetail.setCreateBy("测试派位系统");
+                apportionDetail.setCreateTime(new Date());
+                apportionDetailService.insert(apportionDetail);
+            }
+
+            map.put("apportionId",apportion.getId());
+            msgResult.setResult(true);
+            msgResult.setData(map);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value="中学列表")
     @RequestMapping(value = "pageListMiddle",method = RequestMethod.POST)
     public MessageResult<Map> pageListMiddle(

+ 179 - 4
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApportionDetailController.java

@@ -1,23 +1,35 @@
 package com.jpsoft.campus.modules.base.controller;
 
+import com.alipay.api.domain.Person;
 import com.github.pagehelper.Page;
+import com.jpsoft.campus.config.OSSConfig;
+import com.jpsoft.campus.modules.base.dto.ApplicationMiddleDTO;
 import com.jpsoft.campus.modules.base.dto.ApportionDetailDTO;
-import com.jpsoft.campus.modules.base.entity.ApplicationPrimary;
-import com.jpsoft.campus.modules.base.entity.ApportionDetail;
-import com.jpsoft.campus.modules.base.service.ApplicationPrimaryService;
-import com.jpsoft.campus.modules.base.service.ApportionDetailService;
+import com.jpsoft.campus.modules.base.entity.*;
+import com.jpsoft.campus.modules.base.service.*;
 import com.jpsoft.campus.modules.common.dto.Sort;
 import com.jpsoft.campus.modules.common.dto.MessageResult;
+import com.jpsoft.campus.modules.common.utils.OSSUtil;
 import com.jpsoft.campus.modules.common.utils.PojoUtils;
+import com.jpsoft.campus.modules.sys.entity.DataDictionary;
+import com.jpsoft.campus.modules.sys.entity.User;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -31,6 +43,14 @@ public class ApportionDetailController {
     private ApportionDetailService apportionDetailService;
     @Autowired
     private ApplicationPrimaryService applicationPrimaryService;
+    @Autowired
+    private SchoolInfoService schoolInfoService;
+    @Autowired
+    private StudentInfoService studentInfoService;
+    @Autowired
+    private PersonInfoService personInfoService;
+    @Autowired
+    private OSSConfig ossConfig;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -231,6 +251,42 @@ public class ApportionDetailController {
         return msgResult;
     }
 
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageListTest",method = RequestMethod.POST)
+    public MessageResult<Map> pageListTest(
+            String id,
+            @RequestParam(value="apportionId",defaultValue="") String apportionId,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestParam(value="winner",defaultValue="true") boolean winner,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("t1.create_time","asc"));
+
+        if (StringUtils.isNotEmpty(apportionId)) {
+            searchParams.put("apportionId",apportionId);
+        }
+
+        searchParams.put("winner",winner);
+        searchParams.put("delFlag",true);
+        searchParams.put("createBy","测试派位系统");
+
+        Page<ApportionDetail> page = apportionDetailService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
     @ApiOperation(value="派位详情列表")
     @RequestMapping(value = "pageListDTO",method = RequestMethod.POST)
     public MessageResult<Map> pageListDTO(
@@ -301,4 +357,123 @@ public class ApportionDetailController {
 
         return msgResult;
     }
+
+
+    @ApiOperation(value = "导出派位结果")
+    @PostMapping("exportXlsPwjg")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "apportionId", value = "派位ID", required = false, paramType = "form", dataType = "String"),
+            @ApiImplicitParam(name = "winner", value = "派位结果", required = false, paramType = "form", dataType = "boolean"),
+    })
+    public MessageResult<String> exportXlsPwjg(
+            @RequestParam(value="apportionId",defaultValue="") String apportionId,
+            @RequestParam(value="winner",defaultValue="true") boolean winner,
+            @RequestAttribute String subject) {
+        MessageResult<String> msgResult = new MessageResult<>();
+        try {
+            HSSFWorkbook workbook = new HSSFWorkbook();
+            HSSFSheet sheet = workbook.createSheet();
+            //表头
+            HSSFRow rowTitle = sheet.createRow(0);
+            HSSFCell cellTitle1 = rowTitle.createCell(0);
+            cellTitle1.setCellValue("序号");
+            HSSFCell cellTitle2 = rowTitle.createCell(1);
+            cellTitle2.setCellValue("预录取学校");
+            HSSFCell cellTitle3 = rowTitle.createCell(2);
+            cellTitle3.setCellValue("学生姓名");
+            HSSFCell cellTitle4 = rowTitle.createCell(3);
+            cellTitle4.setCellValue("学生证件号");
+            HSSFCell cellTitle5 = rowTitle.createCell(4);
+            cellTitle5.setCellValue("登记人姓名");
+            HSSFCell cellTitle6 = rowTitle.createCell(5);
+            cellTitle6.setCellValue("登记人手机号码");
+            HSSFCell cellTitle7 = rowTitle.createCell(6);
+            cellTitle7.setCellValue("结果");
+
+            //预录取学校
+            sheet.setColumnWidth(1, 20 * 256);
+            //姓名
+            sheet.setColumnWidth(2, 20 * 256);
+            //证件号
+            sheet.setColumnWidth(3, 24 * 256);
+            //姓名
+            sheet.setColumnWidth(4, 20 * 256);
+            //手机号
+            sheet.setColumnWidth(5, 24 * 256);
+            //结果
+            sheet.setColumnWidth(6, 10 * 256);
+
+            Map<String,Object> searchParams = new HashMap<>();
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("t1.create_time","asc"));
+
+            if (StringUtils.isNotEmpty(apportionId)) {
+                searchParams.put("apportionId",apportionId);
+            }
+
+            searchParams.put("winner",winner);
+            Page<ApportionDetail> page = apportionDetailService.pageSearch(searchParams,0,1000000,false,sortList);
+
+            for (int i = 0; i < page.size(); i++) {
+                ApportionDetail ad = page.get(i);
+                StudentInfo studentInfo = studentInfoService.get(ad.getStudentId());
+
+
+                HSSFRow rowContent = sheet.createRow(i + 1);
+                //"序号"
+                HSSFCell cellContent1 = rowContent.createCell(0);
+                cellContent1.setCellValue(i + 1);
+//                "预录取学校"
+                HSSFCell cellContent2 = rowContent.createCell(1);
+                cellContent2.setCellValue(ad.getSchoolName());
+//                "学生姓名"
+                HSSFCell cellContent3 = rowContent.createCell(2);
+                cellContent3.setCellValue(ad.getStudentName());
+//                "证件号码"
+                HSSFCell cellContent4 = rowContent.createCell(3);
+                cellContent4.setCellValue(studentInfo.getIdCard());
+                if(StringUtils.isNotEmpty(ad.getPersonId())){
+                    //"登记人姓名"
+                    HSSFCell cellContent5 = rowContent.createCell(4);
+                    PersonInfo personInfo = personInfoService.get(ad.getPersonId());
+                    cellContent5.setCellValue(personInfo.getName());
+
+                    //"登记人手机号码"
+                    HSSFCell cellContent6 = rowContent.createCell(5);
+                    cellContent6.setCellValue(personInfo.getPhone());
+                }
+                //"结果"
+                HSSFCell cellContent7 = rowContent.createCell(6);
+                String winnerStr = "成功";
+                if(ad.getWinner()){
+                    winnerStr = "成功";
+                }else{
+                    winnerStr = "失败";
+                }
+                cellContent7.setCellValue(winnerStr);
+            }
+
+            //todo 将wb保存到oss
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            workbook.write(output);
+
+            byte[] buffer = output.toByteArray();
+            ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+            String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
+
+            //todo 返回导入失败报表下载链接
+
+            msgResult.setData(downloadUrl);
+            msgResult.setResult(true);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }