|
@@ -4,6 +4,7 @@ import com.ghsc.partybuild.mapper.PxTrainingRecordCQuery;
|
|
|
import com.ghsc.partybuild.mapper.PxTrainingRecordMapper;
|
|
|
import com.ghsc.partybuild.model.*;
|
|
|
import com.ghsc.partybuild.service.DictionaryService;
|
|
|
+import com.ghsc.partybuild.service.PartyUserService;
|
|
|
import com.ghsc.partybuild.service.PxTrainingRecordService;
|
|
|
import com.ghsc.partybuild.util.DateUtils;
|
|
|
import com.ghsc.partybuild.util.StringUtils;
|
|
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service("PxTrainingRecordService")
|
|
|
public class PxTrainingRecordServiceImpl implements PxTrainingRecordService {
|
|
@@ -25,6 +27,8 @@ public class PxTrainingRecordServiceImpl implements PxTrainingRecordService {
|
|
|
@Autowired
|
|
|
private DictionaryService dictionaryService;
|
|
|
@Autowired
|
|
|
+ private PartyUserService partyUserService;
|
|
|
+ @Autowired
|
|
|
private StringUtils stringUtils;
|
|
|
@Autowired
|
|
|
private DateUtils dateUtils;
|
|
@@ -125,127 +129,100 @@ public class PxTrainingRecordServiceImpl implements PxTrainingRecordService {
|
|
|
return pxTrainingRecordMapper.deleteByExample(exp);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<PxTrainingRecordVo> importPxTrainingRecord(List<PxTrainingRecordVo> dataList, String userId) {
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
-//
|
|
|
-// public List<LeaderTeamVo> importLeaderTeam(int leaderTeamType, List<LeaderTeamVo> dataList, String userID) throws Exception {
|
|
|
-// if (dataList.size() <= 0) {
|
|
|
-// throw new Exception("请添加导入数据");
|
|
|
-// }
|
|
|
-// List<LeaderTeamVo> errorList = new ArrayList<>();
|
|
|
-// List<LwLeaderteam> resultList = new ArrayList<>();
|
|
|
-//
|
|
|
-// List<String> nameList = dataList.stream().filter(it -> !stringUtils.IsNullOrEmpty(it.getName())).map(it -> it.getName().trim()).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// List<CfDictionary> qualificationTypeList = dictionaryService.getDictionaryListByDicTypeKey("QualificationType");
|
|
|
-// List<CfDictionary> professionalTypeList = dictionaryService.getDictionaryListByDicTypeKey("ProfessionalType");
|
|
|
-// List<CfDictionary> educationTypeList = dictionaryService.getDictionaryListByDicTypeKey("EducationType");
|
|
|
-// List<CfDictionary> dicSexList = dictionaryService.getDictionaryListByDicTypeKey("dic_sex");
|
|
|
-// List<HashMap<String, Object>> nationList = partyDicService.getNationList();
|
|
|
-//
|
|
|
-// List<LwLeaderteam> dbLwLeaderteamList = getLeaderteamList(nameList, leaderTeamType);
|
|
|
-//
|
|
|
-// if (nameList.stream().distinct().count() != nameList.size()) {
|
|
|
-// throw new Exception("导入数据存在相同姓名,请修改后重新导入!");
|
|
|
-// }
|
|
|
-//
|
|
|
-// for (int i = 0; i < dataList.size(); i++) {
|
|
|
-// LeaderTeamVo item = dataList.get(i);
|
|
|
-//
|
|
|
-// LwLeaderteam lwLeaderteam = dbLwLeaderteamList.stream().filter(it -> it.getName().equals(item.getName())).findFirst().orElse(new LwLeaderteam());
|
|
|
-//
|
|
|
-// String errorInfo = "";
|
|
|
-// Date birthDate = dateUtils.strToDateExt(item.getBirthdatestr());
|
|
|
-// Date joinDate = dateUtils.strToDateExt(item.getJoindatestr());
|
|
|
-// Date workDate = dateUtils.strToDateExt(item.getWorkdatestr());
|
|
|
-// Date engageDate = dateUtils.strToDateExt(item.getEngagedatestr());
|
|
|
-// Date nowPositionDate = dateUtils.strToDateExt(item.getNowpositiondatestr());
|
|
|
-// Date samePositionDate = dateUtils.strToDateExt(item.getSamepositiondatestr());
|
|
|
-//
|
|
|
-// item.setSex(dictionaryService.getDickeyByName(item.getSexname(), dicSexList));
|
|
|
-// item.setEducationtype(dictionaryService.getDickeyByName(item.getEducationname(), educationTypeList));
|
|
|
-// item.setQualificationtype(dictionaryService.getDickeyByName(item.getQualificationname(), qualificationTypeList));
|
|
|
-// item.setProfessionaltype(dictionaryService.getDickeyByName(item.getProfessionalname(), professionalTypeList));
|
|
|
-// if(!stringUtils.IsNullOrEmpty(item.getBirthplacename())){
|
|
|
-// HashMap<String, Object> nationMap = nationList.stream().filter(x->stringUtils.valueOf(x.get("HZMC")).equals(item.getBirthplacename())).findFirst().orElse(null);
|
|
|
-// item.setBirthplace(nationMap != null ? stringUtils.valueOf(nationMap.get("BM")) : "");
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (stringUtils.IsNullOrEmpty(item.getName()))
|
|
|
-// errorInfo += "请填写姓名!";
|
|
|
-// if (stringUtils.IsNullOrEmpty(item.getDepartmentname()))
|
|
|
-// errorInfo += "请填写机构!";
|
|
|
-// if (stringUtils.IsNullOrEmpty(item.getPosition()))
|
|
|
-// errorInfo += "请填写部门职务!";
|
|
|
-// if(item.getSex() == null)
|
|
|
-// errorInfo += "请根据单元格下拉选项选择性别!";
|
|
|
-// if(item.getBirthplace() == null)
|
|
|
-// errorInfo += "请根据单元格下拉选项选择民族!";
|
|
|
-// if (stringUtils.IsNullOrEmpty(item.getNativeplace()))
|
|
|
-// errorInfo += "请填写籍贯!";
|
|
|
-// if (!stringUtils.IsNullOrEmpty(item.getBirthdatestr()) && birthDate == null)
|
|
|
-// errorInfo += "出生年月格式错误!";
|
|
|
-// if (!stringUtils.IsNullOrEmpty(item.getWorkdatestr()) && workDate == null)
|
|
|
-// errorInfo += "参加工作时间格式错误!";
|
|
|
-// if(item.getEducationtype() == null)
|
|
|
-// errorInfo += "请根据单元格下拉选项选择学历!";
|
|
|
-// if (stringUtils.IsNullOrEmpty(item.getParty()))
|
|
|
-// errorInfo += "请填写党派!";
|
|
|
-// if (!stringUtils.IsNullOrEmpty(item.getJoindatestr()) && joinDate == null)
|
|
|
-// errorInfo += "加入时间格式错误!";
|
|
|
-// if(item.getQualificationtype() == null)
|
|
|
-// errorInfo += "请根据单元格下拉选项选择学位!";
|
|
|
-// if (stringUtils.IsNullOrEmpty(item.getGraduationschoolmajor()))
|
|
|
-// errorInfo += "请填写专业!";
|
|
|
-// if (!stringUtils.IsNullOrEmpty(item.getNowpositiondatestr()) && nowPositionDate == null)
|
|
|
-// errorInfo += "任行政现职时间格式错误!";
|
|
|
-//
|
|
|
-// if (stringUtils.IsNullOrEmpty(errorInfo)) {
|
|
|
-// lwLeaderteam.setName(item.getName());
|
|
|
-// lwLeaderteam.setDepartmentname(item.getDepartmentname());
|
|
|
-// lwLeaderteam.setPosition(item.getPosition());
|
|
|
-// lwLeaderteam.setSex(item.getSex());
|
|
|
-// lwLeaderteam.setBirthplace(item.getBirthplace());
|
|
|
-// lwLeaderteam.setNativeplace(item.getNativeplace());
|
|
|
-// lwLeaderteam.setBirthdate(birthDate);
|
|
|
-// lwLeaderteam.setWorkdate(workDate);
|
|
|
-// lwLeaderteam.setEducationtype(item.getEducationtype());
|
|
|
-// lwLeaderteam.setParty(item.getParty());
|
|
|
-// lwLeaderteam.setJoindate(joinDate);
|
|
|
-// lwLeaderteam.setQualificationtype(item.getQualificationtype());
|
|
|
-// lwLeaderteam.setGraduationschoolmajor(item.getGraduationschoolmajor());
|
|
|
-// lwLeaderteam.setProfessionaltype(item.getProfessionaltype());
|
|
|
-// lwLeaderteam.setEngagedate(engageDate);
|
|
|
-// lwLeaderteam.setNowpositiondate(nowPositionDate);
|
|
|
-// lwLeaderteam.setSamepositiondate(samePositionDate);
|
|
|
-// lwLeaderteam.setWorkexperience(item.getWorkexperience());
|
|
|
-// resultList.add(lwLeaderteam);
|
|
|
-// } else {
|
|
|
-// item.setErrorInfo("第" + (i + 1) + "行," + errorInfo);
|
|
|
-// errorList.add(item);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (errorList.size() <= 0) {
|
|
|
-// resultList.forEach(item -> {
|
|
|
-// if (dbLwLeaderteamList.stream().filter(it -> it.getName().equals(item.getName())).count() == 0) {
|
|
|
-// item.setLeaderteamid(UUID.randomUUID().toString());
|
|
|
-// item.setLeaderteamtype(leaderTeamType);
|
|
|
-// item.setCreateuserid(userID);
|
|
|
-// item.setCreatetime(new Date());
|
|
|
-// leaderteamMapper.insert(item);
|
|
|
-// } else {
|
|
|
-// item.setUpdateuserid(userID);
|
|
|
-// item.setUpdatetime(new Date());
|
|
|
-// leaderteamMapper.updateByPrimaryKeyWithBLOBs(item);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
-//
|
|
|
-// return errorList;
|
|
|
-// }
|
|
|
+ public List<PxTrainingRecordVo> importPxTrainingRecord(List<PxTrainingRecordVo> dataList, String userID) throws Exception {
|
|
|
+
|
|
|
+ if (dataList.size() <= 0) {
|
|
|
+ throw new Exception("请添加导入数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> nameList = dataList.stream().filter(it -> !stringUtils.IsNullOrEmpty(it.getName())).map(it -> it.getName().trim()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<PxTrainingRecord> resultList = new ArrayList<>();
|
|
|
+ List<PxTrainingRecordVo> errorList = new ArrayList<>();
|
|
|
+ List<CfDictionary> pxdxlxTypeList = dictionaryService.getDictionaryListByDicTypeKey("pxdxlxType");
|
|
|
+ List<CfDictionary> pxxsTypeList = dictionaryService.getDictionaryListByDicTypeKey("pxxsType");
|
|
|
+ List<CfDictionary> dicSexList = dictionaryService.getDictionaryListByDicTypeKey("dic_sex");
|
|
|
+
|
|
|
+ if (nameList.stream().distinct().count() != nameList.size()) {
|
|
|
+ throw new Exception("导入数据存在相同姓名,请修改后重新导入!");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < dataList.size(); i++) {
|
|
|
+ PxTrainingRecordVo item = dataList.get(i);
|
|
|
+ PxTrainingRecord model = new PxTrainingRecord();
|
|
|
+
|
|
|
+ String errorInfo = "";
|
|
|
+ item.setXxkssj(dateUtils.strToDateExt(item.getXxkssjstr()));
|
|
|
+ item.setXxjssj(dateUtils.strToDateExt(item.getXxjssjstr()));
|
|
|
+ item.setGender(dictionaryService.getDickeyByName(item.getGendername(), dicSexList));
|
|
|
+ item.setPxdxlx(dictionaryService.getDickeyByName(item.getPxdxlxtypename(), pxdxlxTypeList));
|
|
|
+ item.setPxxs(dictionaryService.getDickeyByName(item.getPxxstypename(), pxxsTypeList));
|
|
|
+
|
|
|
+ if (item.getPxdxlx() == null)
|
|
|
+ errorInfo += "请根据单元格下拉选项选择培训对象类型!";
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getName()))
|
|
|
+ errorInfo += "请填写姓名!";
|
|
|
+ if (item.getGender() == null)
|
|
|
+ errorInfo += "请根据单元格下拉选项选择性别!";
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getSfzh()))
|
|
|
+ errorInfo += "请填身份证号!";
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getGzbm()))
|
|
|
+ errorInfo += "请填写工作部门!";
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getZw()))
|
|
|
+ errorInfo += "请填写职务!";
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getPxxmmc()))
|
|
|
+ errorInfo += "请填写培训项目名称!";
|
|
|
+ if(item.getPxxs() == null)
|
|
|
+ errorInfo += "请根据单元格下拉选项选择培训形式!";
|
|
|
+ if(item.getXss() == null)
|
|
|
+ errorInfo += "请填写学时数!";
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getXxkssjstr()) && item.getXxkssj() == null)
|
|
|
+ errorInfo += "学习开始时间格式错误!";
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getXxjssjstr()) && item.getXxjssj() == null)
|
|
|
+ errorInfo += "学习结束时间格式错误!";
|
|
|
+
|
|
|
+ if (stringUtils.IsNullOrEmpty(errorInfo)) {
|
|
|
+ HashMap<String, Object> userInfo = partyUserService.getPartyUserInfoByNameAndSfzh(item.getName(), item.getSfzh());
|
|
|
+ if(userInfo.size()>0){
|
|
|
+ item.setRybm(stringUtils.valueOf(userInfo.get("RYBM")));
|
|
|
+// item.setZw(stringUtils.valueOf(userInfo.get("ZWMC")));
|
|
|
+// String genderStr = stringUtils.valueOf(userInfo.get("XB"));
|
|
|
+// item.setGender(genderStr.length() > 0 ? Integer.parseInt(genderStr) : 0);
|
|
|
+ }
|
|
|
+ model.setPxdxlx(item.getPxdxlx());
|
|
|
+ model.setName(item.getName());
|
|
|
+ model.setGender(item.getGender());
|
|
|
+ model.setSfzh(item.getSfzh());
|
|
|
+ model.setGzbm(item.getGzbm());
|
|
|
+ model.setZw(item.getZw());
|
|
|
+ model.setPxxmmc(item.getPxxmmc());
|
|
|
+ model.setPxxs(item.getPxxs());
|
|
|
+ model.setXss(item.getXss());
|
|
|
+ model.setXxkssj(item.getXxkssj());
|
|
|
+ model.setXxjssj(item.getXxjssj());
|
|
|
+ model.setKhqk(item.getKhqk());
|
|
|
+ model.setSsjgmc(item.getSsjgmc());
|
|
|
+ model.setXxdd(item.getXxdd());
|
|
|
+ model.setXxnr(item.getXxnr());
|
|
|
+ model.setRemark(item.getRemark());
|
|
|
+ resultList.add(model);
|
|
|
+ } else {
|
|
|
+ item.setErrorInfo("第" + (i + 1) + "行," + errorInfo);
|
|
|
+ errorList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errorList.size() <= 0) {
|
|
|
+ resultList.forEach(item -> {
|
|
|
+ item.setId(UUID.randomUUID().toString());
|
|
|
+ item.setCreateUserid(userID);
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ pxTrainingRecordMapper.insert(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return errorList;
|
|
|
+ }
|
|
|
|
|
|
}
|