Browse Source

报表完成

xiao547607 4 years ago
parent
commit
cc103c312d

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

@@ -22,4 +22,5 @@ public interface ApplicationPrimaryDAO {
     long existByIdCard(String idCard, String applicationId);
 
 	List<ApplicationPrimary> findByStudentId(String id);
+	ApplicationPrimary findByStudentNameAndIdCard(String studentName, String idCard,String schoolId);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/campus/modules/base/dto/ApplicationMiddleDTO.java

@@ -160,4 +160,9 @@ public class ApplicationMiddleDTO implements Serializable {
 
     @ApiModelProperty(value = "入学通知书")
     private String offerImg;
+
+    @ApiModelProperty(value = "登记人名称")
+    private String personName;
+    @ApiModelProperty(value = "登记人电话")
+    private String personPhone;
 }

+ 5 - 0
common/src/main/java/com/jpsoft/campus/modules/base/dto/ApplicationPrimaryDTO.java

@@ -156,4 +156,9 @@ public class ApplicationPrimaryDTO implements Serializable {
     private String offerCode;
     @ApiModelProperty(value = "入学通知书")
     private String offerImg;
+
+    @ApiModelProperty(value = "登记人名称")
+    private String personName;
+    @ApiModelProperty(value = "登记人电话")
+    private String personPhone;
 }

+ 2 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/ApplicationPrimaryService.java

@@ -5,6 +5,7 @@ import java.util.Map;
 import com.github.pagehelper.Page;
 import com.jpsoft.campus.modules.base.dto.ApplicationPrimaryDTO;
 import com.jpsoft.campus.modules.base.entity.ApplicationPrimary;
+import com.jpsoft.campus.modules.base.entity.ApprovalInfo;
 import com.jpsoft.campus.modules.common.dto.Sort;
 
 public interface ApplicationPrimaryService {
@@ -20,4 +21,5 @@ public interface ApplicationPrimaryService {
     boolean existByIdCard(String idCard, String applicationId);
 
 	List<ApplicationPrimary> findByStudentId(String id);
+	ApplicationPrimary findByStudentNameAndIdCard(String studentName, String idCard,String schoolId);
 }

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

@@ -95,4 +95,9 @@ public class ApplicationPrimaryServiceImpl implements ApplicationPrimaryService
 	public List<ApplicationPrimary> findByStudentId(String id) {
 		return applicationPrimaryDAO.findByStudentId(id);
 	}
+
+	@Override
+	public ApplicationPrimary findByStudentNameAndIdCard(String studentName, String idCard,String schoolId){
+		return applicationPrimaryDAO.findByStudentNameAndIdCard(studentName,idCard,schoolId);
+	}
 }

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

@@ -220,6 +220,8 @@
         <result property="offerName" column="offer_name"/>
         <result property="offerCode" column="offer_code"/>
         <result property="offerImg" column="offer_img"/>
+        <result property="personName" column="person_name"/>
+        <result property="personPhone" column="person_phone"/>
     </resultMap>
     <select id="searchDTO" parameterType="hashmap" resultMap="ApplicationMiddleDTOMap">
         <![CDATA[
@@ -235,12 +237,15 @@
 			a.offer_id,
 			e.name_ as offer_name,
 			a.offer_code,
-			a.offer_img
+			a.offer_img,
+			f.name_ as person_name,
+			f.phone_ as person_phone
 			FROM base_application_middle a
 			LEFT JOIN base_student_info b ON a.student_id = b.id_
 			LEFT JOIN base_person_student c ON (a.person_id = c.person_id AND a.student_id = c.student_id)
 			LEFT JOIN base_school_info d ON a.school_id = d.id_
 			LEFT JOIN base_school_info e ON a.offer_id = e.id_
+			LEFT JOIN base_person_info f ON a.person_id = f.id_
 		]]>
         <where>
             <if test="searchParams.delFlag != null">

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

@@ -214,6 +214,9 @@
         <result property="offerName" column="offer_name"/>
         <result property="offerCode" column="offer_code"/>
         <result property="offerImg" column="offer_img"/>
+        <result property="personName" column="person_name"/>
+        <result property="personPhone" column="person_phone"/>
+
     </resultMap>
     <select id="searchDTO" parameterType="hashmap" resultMap="ApplicationPrimaryDTOMap">
         <![CDATA[
@@ -229,12 +232,15 @@
 			a.offer_id,
 			e.name_ as offer_name,
 			a.offer_code,
-			a.offer_img
+			a.offer_img,
+			f.name_ as person_name,
+			f.phone_ as person_phone
 			FROM base_application_primary a
 			LEFT JOIN base_student_info b ON a.student_id = b.id_
 			LEFT JOIN base_person_student c ON (a.person_id = c.person_id AND a.student_id = c.student_id)
 			LEFT JOIN base_school_info d ON a.school_id = d.id_
 			LEFT JOIN base_school_info e ON a.offer_id = e.id_
+			LEFT JOIN base_person_info f ON a.person_id = f.id_
 		]]>
         <where>
             <if test="searchParams.delFlag != null">
@@ -307,4 +313,13 @@
         where student_id=#{0} and del_flag=0
         order by create_time asc
     </select>
+    <select id="findByStudentNameAndIdCard" resultMap="ApplicationPrimaryMap">
+        SELECT * FROM base_application_primary t1
+        LEFT JOIN base_student_info t2 ON t1.student_id = t2.id_
+        WHERE
+        t1.del_flag = 0
+        AND t2.name_ LIKE #{studentName}
+        AND t2.id_card = #{idCard}
+        AND t1.school_id = #{schoolId}
+    </select>
 </mapper>

+ 3 - 0
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationMiddleController.java

@@ -1471,6 +1471,9 @@ public class ApplicationMiddleController {
         Map<String,Object> searchParams = new HashMap<>();
         User user = userService.get(subject);
         List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("a.school_id","asc"));
+        sortList.add(new Sort("a.type_","asc"));
+        sortList.add(new Sort("a.offer_code","asc"));
         sortList.add(new Sort("a.create_time","desc"));
 
         if (StringUtils.isNotEmpty(tabStatus)) {

+ 118 - 11
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationPrimaryController.java

@@ -12,10 +12,7 @@ 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.common.utils.WechatMessageUtil;
-import com.jpsoft.campus.modules.common.utils.WeixinUtil;
+import com.jpsoft.campus.modules.common.utils.*;
 import com.jpsoft.campus.modules.sys.entity.DataDictionary;
 import com.jpsoft.campus.modules.sys.entity.User;
 import com.jpsoft.campus.modules.sys.service.DataDictionaryService;
@@ -32,12 +29,15 @@ 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.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.imageio.ImageIO;
 import javax.servlet.ServletContext;
@@ -49,6 +49,7 @@ import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/base/applicationPrimary")
@@ -288,13 +289,22 @@ public class ApplicationPrimaryController {
         Map<String,Object> searchParams = new HashMap<>();
 
         List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("a.school_id","asc"));
+        sortList.add(new Sort("a.type_","asc"));
+        sortList.add(new Sort("a.category_id","desc"));
+        sortList.add(new Sort("a.offer_code","asc"));
         sortList.add(new Sort("a.create_time","desc"));
 
         if (StringUtils.isNotEmpty(tabStatus)) {
             searchParams.put("tabStatus",tabStatus);
         }
         if (StringUtils.isNotEmpty(type)) {
-            searchParams.put("type",type);
+            if("A".equals(type) || "B".equals(type) ||"C".equals(type)) {
+                searchParams.put("type", type);
+            }else{
+                searchParams.put("type", "C");
+                searchParams.put("categoryId", type);
+            }
         }
         if (StringUtils.isNotEmpty(status)) {
             searchParams.put("status",status);
@@ -374,7 +384,7 @@ public class ApplicationPrimaryController {
             applicationPrimaryDTO.setTypeName(dataDictionaryService.findNameByCatalogNameAndValue("报名类型",applicationPrimaryDTO.getType()));
             applicationPrimaryDTO.setStatusName(dataDictionaryService.findNameByCatalogNameAndValue("小学招生审核流程",applicationPrimaryDTO.getStatus()));
             applicationPrimaryDTO.setCardType(dataDictionaryService.findNameByCatalogNameAndValue("证件类型",applicationPrimaryDTO.getCardType()));
-            applicationPrimaryDTO.setCategoryName(dataDictionaryService.getName(applicationPrimaryDTO.getCategoryId()));
+            applicationPrimaryDTO.setCategoryName(dataDictionaryService.getValue(applicationPrimaryDTO.getCategoryId()));
         }
 
         msgResult.setResult(true);
@@ -412,7 +422,12 @@ public class ApplicationPrimaryController {
             sortList.add(new Sort("id_","asc"));
 
             if (StringUtils.isNotEmpty(type)) {
-                searchParams.put("type",type);
+                if("A".equals(type) || "B".equals(type) ||"C".equals(type)) {
+                    searchParams.put("type", type);
+                }else{
+                    searchParams.put("type", "C");
+                    searchParams.put("categoryId", type);
+                }
             }
             if (StringUtils.isNotEmpty(status)) {
                 searchParams.put("status",status);
@@ -518,7 +533,12 @@ public class ApplicationPrimaryController {
             sortList.add(new Sort("id_","asc"));
 
             if (StringUtils.isNotEmpty(type)) {
-                searchParams.put("type",type);
+                if("A".equals(type) || "B".equals(type) ||"C".equals(type)) {
+                    searchParams.put("type", type);
+                }else{
+                    searchParams.put("type", "C");
+                    searchParams.put("categoryId", type);
+                }
             }
             if (StringUtils.isNotEmpty(status)) {
                 searchParams.put("status",status);
@@ -616,7 +636,12 @@ public class ApplicationPrimaryController {
             sortList.add(new Sort("id_","asc"));
 
             if (StringUtils.isNotEmpty(type)) {
-                searchParams.put("type",type);
+                if("A".equals(type) || "B".equals(type) ||"C".equals(type)) {
+                    searchParams.put("type", type);
+                }else{
+                    searchParams.put("type", "C");
+                    searchParams.put("categoryId", type);
+                }
             }
             if (StringUtils.isNotEmpty(status)) {
                 searchParams.put("status",status);
@@ -1737,7 +1762,7 @@ 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);
                     //保存录取信息表
@@ -1862,7 +1887,7 @@ public class ApplicationPrimaryController {
             int mothh = DateUtil.thisMonth() +1;
             Graphics g = im.getGraphics();
             g.setColor(new Color(0,0,0));
-            Font font = new Font("宋体",Font.PLAIN,40);  //设置字体
+            Font font = new Font("宋体",Font.BOLD,40);  //设置字体
             g.setFont(font);
             Random ran = new Random();  // 随机位置
             g.drawString(offerCode,1000,400);
@@ -2036,4 +2061,86 @@ public class ApplicationPrimaryController {
 
         return msgResult;
     }
+
+    @ApiOperation(value = "导入其他职工")
+    @PostMapping("importCheckXls")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "uploadFile", value = "上传文件", required = true, paramType = "form", dataType = "__file")
+    })
+    public MessageResult<String> importOtherXls(
+            @RequestParam(value = "schoolId", defaultValue = "2a161029-324a-4ef5-8062-4cf63339bcdc") String schoolId,
+                                    MultipartFile uploadFile,@RequestAttribute String subject) {
+        User user = userService.get(subject);
+
+        MessageResult<String> msgResult = new MessageResult<>();
+        try {
+            POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
+            int sheetIndex = 0;
+            Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
+
+            int affectCount = 0;
+            int failCount = 0;
+            int validateColIndex = 5;
+
+            for (int rowIndex = 1; rowIndex <= sheet1.getLastRowNum(); rowIndex++) {
+                try {
+                    String name = (String) poiUtils.getCellValue(sheetIndex, rowIndex, 1).toString().replace(" ", "");
+                    String idCard = (String) poiUtils.getCellValue(sheetIndex, rowIndex, 2).toString().replace(" ", "");
+                    String newCate = (String) poiUtils.getCellValue(sheetIndex, rowIndex, 3).toString().replace(" ", "");
+
+                    ApplicationPrimary applicationPrimary = applicationPrimaryService.findByStudentNameAndIdCard(name,idCard,schoolId);
+
+                    if(applicationPrimary == null){
+                        applicationPrimary = new ApplicationPrimary();
+                        applicationPrimary.setId(idCard);
+                        applicationPrimary.setCreateBy(name);
+                        applicationPrimary.setOfferId(idCard);
+                        applicationPrimary.setNewType(newCate);
+                        applicationPrimaryService.insert(applicationPrimary);
+                    }else {
+                        applicationPrimary.setNewType(newCate);
+                        applicationPrimary.setUpdateBy(subject);
+                        applicationPrimary.setUpdateTime(new Date());
+                        applicationPrimaryService.update(applicationPrimary);
+                    }
+
+                } catch (Exception innerEx) {
+                    failCount++;
+                    sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue(innerEx.getMessage());
+                    logger.error(innerEx.getMessage(), innerEx);
+                }
+            }
+
+            if (failCount > 0) {
+                //有导入失败的记录
+                msgResult.setResult(false);
+                msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
+
+                //todo 只保留错误数据的sheet
+                Workbook wb = poiUtils.exportErrorXls(sheetIndex, validateColIndex, 10000);
+
+                //todo 将wb保存到oss
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                wb.write(output);
+
+                byte[] buffer = output.toByteArray();
+                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+
+                String downloadUrl = OSSUtil.upload(ossConfig, "import", "error.xls", input);
+
+                //todo 返回导入失败报表下载链接
+                msgResult.setData(downloadUrl);
+            } else {
+                msgResult.setResult(true);
+                msgResult.setMessage("数据成功导入" + affectCount + "条");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }