|
|
@ -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; |
|
|
@ -69,7 +69,7 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
|
|
|
|
private int totalCells = 0;// 总条数
|
|
|
|
|
|
|
|
public static int Guid=100;//id自增值
|
|
|
|
public static int Guid = 100;//id自增值
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EvaluateOfficerRedis evaluateOfficerRedis; |
|
|
@ -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()); |
|
|
@ -110,13 +113,14 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
} |
|
|
|
CompleteDeptDTO completeDeptDTO = completeDept.getData(); |
|
|
|
Map<String, Object> params = new HashMap<String, Object>(); |
|
|
|
params.put("deptId",completeDeptDTO.getStreetId()); |
|
|
|
params.put("deptId", completeDeptDTO.getStreetId()); |
|
|
|
List<EvaluateOfficerAppResultDTO> list = baseDao.getDeptOfficer(params); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 条件查询 |
|
|
|
* |
|
|
|
* @param params |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -133,8 +137,8 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
return ConvertUtils.sourceToTarget(entityList, EvaluateOfficerDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<EvaluateOfficerEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<EvaluateOfficerEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<EvaluateOfficerEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -165,10 +169,11 @@ 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) { |
|
|
|
baseDao.updateCount(id,type); |
|
|
|
baseDao.updateCount(id, type); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -192,9 +197,9 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result insertPartyList(MultipartFile file,String deptId) { |
|
|
|
public Result insertPartyList(MultipartFile file, String deptId) { |
|
|
|
// 清空当前街道数据
|
|
|
|
if(deptId != null && !"".equals(deptId)){ |
|
|
|
if (deptId != null && !"".equals(deptId)) { |
|
|
|
baseDao.deleteByDeptId(deptId); |
|
|
|
} |
|
|
|
// 清空该人员相关评价数据
|
|
|
@ -202,17 +207,17 @@ 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>(); |
|
|
|
try{ |
|
|
|
try { |
|
|
|
Workbook wb = null; |
|
|
|
InputStream is = file.getInputStream(); |
|
|
|
if ("true".equals(isExcel2003)) { |
|
|
|
// 当excel是2003时,创建excel2003
|
|
|
|
wb = new HSSFWorkbook(is); |
|
|
|
}else if("false".equals(isExcel2003)){ |
|
|
|
} else if ("false".equals(isExcel2003)) { |
|
|
|
// 当excel是2007时,创建excel2007
|
|
|
|
wb = new XSSFWorkbook(is); |
|
|
|
} else { |
|
|
@ -242,37 +247,37 @@ 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) { |
|
|
|
} else if (c == 1) { |
|
|
|
// 性别
|
|
|
|
String value = getCellContent(cell); |
|
|
|
if("女".equals(value)){ |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
if ("女".equals(value)) { |
|
|
|
value = "0"; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
value = "1"; |
|
|
|
} |
|
|
|
evaluateOfficerEntity.setSex(value); |
|
|
|
|
|
|
|
}else if (c == 2) { |
|
|
|
} else if (c == 2) { |
|
|
|
// 单位职务
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setPosition(value); |
|
|
|
|
|
|
|
}else if (c == 3) { |
|
|
|
} 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) { |
|
|
|
} else if (c == 5) { |
|
|
|
// 排序
|
|
|
|
String value = getCellContent(cell); |
|
|
|
String value = ExcelUtils.getCellContent(cell); |
|
|
|
evaluateOfficerEntity.setSort(Integer.parseInt(value)); |
|
|
|
|
|
|
|
} |
|
|
@ -292,9 +297,9 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
evaluateOfficerEntity.setUpdatedTime(new Date()); |
|
|
|
list.add(evaluateOfficerEntity); |
|
|
|
} |
|
|
|
if(list.size() > 0){ |
|
|
|
if (list.size() > 0) { |
|
|
|
EvaluateOfficerEntity[] evaluateOfficerEntities = new EvaluateOfficerEntity[list.size()]; |
|
|
|
for(int k = 0 ; k < list.size() ; k++){ |
|
|
|
for (int k = 0; k < list.size(); k++) { |
|
|
|
evaluateOfficerEntities[k] = list.get(k); |
|
|
|
} |
|
|
|
baseDao.insertList(evaluateOfficerEntities); |
|
|
@ -310,7 +315,7 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
result.setCode(0); |
|
|
|
result.setData("数据导入成功!"); |
|
|
|
return result; |
|
|
|
}catch(Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
} |
|
|
|
result.setMsg("defeat"); |
|
|
@ -321,83 +326,23 @@ public class EvaluateOfficerServiceImpl extends BaseServiceImpl<EvaluateOfficerD |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取19位随机数 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getLongRandom(){ |
|
|
|
Guid+=1; |
|
|
|
public String getLongRandom() { |
|
|
|
Guid += 1; |
|
|
|
long now = System.currentTimeMillis(); |
|
|
|
SimpleDateFormat dateFormat=new SimpleDateFormat("MMdd"); |
|
|
|
String time=dateFormat.format(now); |
|
|
|
String currentTimeMillis=now+""; |
|
|
|
int ran=0; |
|
|
|
if(Guid>999){ |
|
|
|
Guid=100; |
|
|
|
} |
|
|
|
ran=Guid; |
|
|
|
String str = time+currentTimeMillis.substring(1, currentTimeMillis.length())+ran; |
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("MMdd"); |
|
|
|
String time = dateFormat.format(now); |
|
|
|
String currentTimeMillis = now + ""; |
|
|
|
int ran = 0; |
|
|
|
if (Guid > 999) { |
|
|
|
Guid = 100; |
|
|
|
} |
|
|
|
ran = Guid; |
|
|
|
String str = time + currentTimeMillis.substring(1, currentTimeMillis.length()) + ran; |
|
|
|
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)$"); |
|
|
|
} |
|
|
|
|
|
|
|
} |