|
|
@ -25,6 +25,7 @@ import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dto.CompleteDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.evaluate.EvaluateOfficerDTO; |
|
|
@ -40,7 +41,6 @@ import com.elink.esua.epdc.modules.evaluate.service.EvaluateOfficerService; |
|
|
|
import com.elink.esua.epdc.modules.evaluate.service.EvaluateRoleService; |
|
|
|
import com.elink.esua.epdc.modules.feign.SysFeignClient; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
@ -87,17 +87,20 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
); |
|
|
|
return getPageData(page, EvaluateOfficerDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<EvaluateOfficerCountResultDTO> getEvaluateOfficerCountPage(Map<String, Object> params) { |
|
|
|
IPage<EvaluateOfficerCountResultDTO> page = getPage(params); |
|
|
|
List<EvaluateOfficerCountResultDTO> list = baseDao.getEvaluateOfficerCount(params); |
|
|
|
return new PageData<>(list, page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<EvaluateOfficerCountResultDTO> countExport(Map<String, Object> params) { |
|
|
|
List<EvaluateOfficerCountResultDTO> list = baseDao.getEvaluateOfficerCount(params); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<EvaluateOfficerAppResultDTO> getDeptOfficer(EvaluateOfficerAppFormDTO formDto) { |
|
|
|
Result<CompleteDeptDTO> completeDept = sysFeignClient.getCompleteDept(formDto.getGridId()); |
|
|
@ -117,6 +120,7 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
|
|
|
|
/** |
|
|
|
* 条件查询 |
|
|
|
* |
|
|
|
* @param params |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -165,6 +169,7 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
EvaluateOfficerEntity entity = ConvertUtils.sourceToTarget(dto, EvaluateOfficerEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void updateCount(String id, String type) { |
|
|
@ -202,7 +207,7 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
baseDao.deleteEvaluateInfoByDeptId(deptId); |
|
|
|
|
|
|
|
//获取excle版本
|
|
|
|
String isExcel2003 = getExcelInfo(file); |
|
|
|
String isExcel2003 = ExcelUtils.getExcelInfo(file); |
|
|
|
Result result = new Result(); |
|
|
|
//需存储的实体
|
|
|
|
List<EvaluateOfficerEntity> list = new ArrayList<EvaluateOfficerEntity>(); |
|
|
@ -242,12 +247,12 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
if (null != cell) { |
|
|
|
if (c == 0) { |
|
|
|
// 干部姓名
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setFullName(value); |
|
|
|
|
|
|
|
} else if (c == 1) { |
|
|
|
// 性别
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
if ("女".equals(value)) { |
|
|
|
value = "0"; |
|
|
|
} else { |
|
|
@ -257,22 +262,22 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
|
|
|
|
} else if (c == 2) { |
|
|
|
// 单位职务
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setPosition(value); |
|
|
|
|
|
|
|
} else if (c == 3) { |
|
|
|
// 点赞次数
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setLikesCount(Integer.parseInt(value)); |
|
|
|
|
|
|
|
} else if (c == 4) { |
|
|
|
// 被踩次数
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setOpposeCount(Integer.parseInt(value)); |
|
|
|
|
|
|
|
} else if (c == 5) { |
|
|
|
// 排序
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setSort(Integer.parseInt(value)); |
|
|
|
|
|
|
|
} |
|
|
@ -321,6 +326,7 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取19位随机数 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getLongRandom() { |
|
|
@ -338,66 +344,5 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取单元格内容 |
|
|
|
* @param cell |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getCellContent(Cell cell){ |
|
|
|
String value = ""; |
|
|
|
if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { |
|
|
|
value = String.valueOf(cell.getNumericCellValue()); |
|
|
|
} else { |
|
|
|
value = cell.getStringCellValue(); |
|
|
|
} |
|
|
|
//内容超过25个字进行长度限制,否则数据库会超限
|
|
|
|
/*if(value.length() > 25){ |
|
|
|
value = value.substring(0,25) + "..."; |
|
|
|
}*/ |
|
|
|
return value; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取excle版本 |
|
|
|
* @param mFile |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getExcelInfo(MultipartFile mFile) { |
|
|
|
String fileName = mFile.getOriginalFilename();// 获取文件名
|
|
|
|
String isExcel2003 = "true";// 根据文件名判断文件是2003版本还是2007版本
|
|
|
|
try { |
|
|
|
if (!validateExcel(fileName)) {// 验证文件名是否合格
|
|
|
|
return ""; |
|
|
|
} |
|
|
|
if (isExcel2007(fileName)) { |
|
|
|
isExcel2003 = "false"; |
|
|
|
} |
|
|
|
return isExcel2003; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 验证EXCEL文件 |
|
|
|
* @param filePath |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public boolean validateExcel(String filePath) { |
|
|
|
if (filePath == null || !(isExcel2003(filePath) || isExcel2007(filePath))) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// @描述:是否是2003的excel,返回true是2003
|
|
|
|
public static boolean isExcel2003(String filePath) { |
|
|
|
return filePath.matches("^.+\\.(?i)(xls)$"); |
|
|
|
} |
|
|
|
// @描述:是否是2007的excel,返回true是2007
|
|
|
|
public static boolean isExcel2007(String filePath) { |
|
|
|
return filePath.matches("^.+\\.(?i)(xlsx)$"); |
|
|
|
} |
|
|
|
|
|
|
|
} |