|
@@ -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;
|
|
|
+ }
|
|
|
}
|