|
@@ -1,5 +1,6 @@
|
|
package com.ruoyi.project.training.spec.service.impl;
|
|
package com.ruoyi.project.training.spec.service.impl;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import com.ruoyi.common.exception.CustomException;
|
|
import com.ruoyi.common.exception.CustomException;
|
|
@@ -7,8 +8,13 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.framework.security.LoginUser;
|
|
import com.ruoyi.framework.security.LoginUser;
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
|
+import com.ruoyi.project.system.service.impl.SysUserServiceImpl;
|
|
import com.ruoyi.project.training.spec.domain.TStFeedback;
|
|
import com.ruoyi.project.training.spec.domain.TStFeedback;
|
|
|
|
+import com.ruoyi.project.training.spec.domain.TStYearplan;
|
|
import com.ruoyi.project.training.spec.domain.vo.TStPlanImportVO;
|
|
import com.ruoyi.project.training.spec.domain.vo.TStPlanImportVO;
|
|
|
|
+import com.ruoyi.project.training.spec.mapper.TStYearplanMapper;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.ruoyi.project.training.spec.mapper.TStPlanMapper;
|
|
import com.ruoyi.project.training.spec.mapper.TStPlanMapper;
|
|
@@ -24,9 +30,14 @@ import com.ruoyi.project.training.spec.service.ITStPlanService;
|
|
@Service
|
|
@Service
|
|
public class TStPlanServiceImpl implements ITStPlanService
|
|
public class TStPlanServiceImpl implements ITStPlanService
|
|
{
|
|
{
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private TStPlanMapper tStPlanMapper;
|
|
private TStPlanMapper tStPlanMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TStYearplanMapper tStYearplanMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<TStPlan> selectSeasonalTStPlanList(TStFeedback tStFeedback) {
|
|
public List<TStPlan> selectSeasonalTStPlanList(TStFeedback tStFeedback) {
|
|
return tStPlanMapper.selectSeasonalTStPlanList(tStFeedback);
|
|
return tStPlanMapper.selectSeasonalTStPlanList(tStFeedback);
|
|
@@ -119,61 +130,63 @@ public class TStPlanServiceImpl implements ITStPlanService
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public String importData(List<TStPlanImportVO> planList, boolean isUpdateSupport, LoginUser loginUser, Long yearPlanId) {
|
|
|
|
-// if (StringUtils.isNull(userList) || userList.size() == 0)
|
|
|
|
-// {
|
|
|
|
-// throw new CustomException("导入用户数据不能为空!");
|
|
|
|
-// }
|
|
|
|
-// int successNum = 0;
|
|
|
|
-// int failureNum = 0;
|
|
|
|
-// StringBuilder successMsg = new StringBuilder();
|
|
|
|
-// StringBuilder failureMsg = new StringBuilder();
|
|
|
|
-// String password = configService.selectConfigByKey("sys.user.initPassword");
|
|
|
|
-// for (SysUser user : userList)
|
|
|
|
-// {
|
|
|
|
-// try
|
|
|
|
-// {
|
|
|
|
-// // 验证是否存在这个用户
|
|
|
|
-// SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
|
|
|
-// if (StringUtils.isNull(u))
|
|
|
|
-// {
|
|
|
|
-// user.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
|
-// user.setCreateBy(operName);
|
|
|
|
-// this.insertUser(user);
|
|
|
|
-// successNum++;
|
|
|
|
-// successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
|
|
|
-// }
|
|
|
|
-// else if (isUpdateSupport)
|
|
|
|
-// {
|
|
|
|
-// user.setUpdateBy(operName);
|
|
|
|
-// this.updateUser(user);
|
|
|
|
-// successNum++;
|
|
|
|
-// successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
|
|
|
-// }
|
|
|
|
-// else
|
|
|
|
-// {
|
|
|
|
-// failureNum++;
|
|
|
|
-// failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// catch (Exception e)
|
|
|
|
-// {
|
|
|
|
-// failureNum++;
|
|
|
|
-// String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
|
|
|
-// failureMsg.append(msg + e.getMessage());
|
|
|
|
-// log.error(msg, e);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// if (failureNum > 0)
|
|
|
|
-// {
|
|
|
|
-// failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
-// throw new CustomException(failureMsg.toString());
|
|
|
|
-// }
|
|
|
|
-// else
|
|
|
|
-// {
|
|
|
|
-// successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
-// }
|
|
|
|
-// return successMsg.toString();
|
|
|
|
- return null;
|
|
|
|
|
|
+ public String importData(List<TStPlanImportVO> planList, boolean isUpdateSupport, SysUser loginUser, Long yearPlanId) {
|
|
|
|
+ if (StringUtils.isNull(planList) || planList.size() == 0)
|
|
|
|
+ {
|
|
|
|
+ throw new CustomException("导入培养计划数据不能为空!");
|
|
|
|
+ }
|
|
|
|
+ int successNum = 0;
|
|
|
|
+ int failureNum = 0;
|
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
|
+ TStYearplan yearplan =tStYearplanMapper.selectTStYearplanById(yearPlanId);
|
|
|
|
+ for (TStPlanImportVO planImportVO : planList) {
|
|
|
|
+ try {
|
|
|
|
+ TStPlan plan = new TStPlan();
|
|
|
|
+ plan.setYearPlanId(yearPlanId);
|
|
|
|
+ plan.setPlantName(planImportVO.getPlantName());
|
|
|
|
+ TStPlan result = tStPlanMapper.selectTStPlan(plan);
|
|
|
|
+ if (StringUtils.isNull(result))
|
|
|
|
+ {
|
|
|
|
+ successNum++;
|
|
|
|
+ plan.setStaffId(yearplan.getStaffId());
|
|
|
|
+ plan.setStartDate(planImportVO.getStartDate());
|
|
|
|
+ plan.setEndDate(planImportVO.getEndDate());
|
|
|
|
+ plan.setClassContent(planImportVO.getClassContent());
|
|
|
|
+ plan.setCreaterCode(loginUser.getUserId().toString());
|
|
|
|
+ plan.setCreatedate(new Date());
|
|
|
|
+ this.insertTStPlan(plan);
|
|
|
|
+ successMsg.append("<br/>" + successNum + "、培养计划 " + planImportVO.getPlantName() + " 导入成功");
|
|
|
|
+ } else if (isUpdateSupport) {
|
|
|
|
+ successNum++;
|
|
|
|
+ result.setStaffId(yearplan.getStaffId());
|
|
|
|
+ result.setStartDate(planImportVO.getStartDate());
|
|
|
|
+ result.setEndDate(planImportVO.getEndDate());
|
|
|
|
+ result.setClassContent(planImportVO.getClassContent());
|
|
|
|
+ result.setUpdaterCode(loginUser.getUserId().toString());
|
|
|
|
+ result.setUpdatedate(new Date());
|
|
|
|
+ this.updateTStPlan(result);
|
|
|
|
+ successMsg.append("<br/>" + successNum + "、培养计划 " + planImportVO.getPlantName() + " 更新成功");
|
|
|
|
+ } else {
|
|
|
|
+ failureNum++;
|
|
|
|
+ failureMsg.append("<br/>" + failureNum + "、培养计划 " + planImportVO.getPlantName() + " 已存在");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ failureNum++;
|
|
|
|
+ String msg = "<br/>" + failureNum + "、培养计划 " + planImportVO.getPlantName() + " 导入失败:";
|
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
|
+ log.error(msg, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (failureNum > 0)
|
|
|
|
+ {
|
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
+ throw new CustomException(failureMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
+ }
|
|
|
|
+ return successMsg.toString();
|
|
}
|
|
}
|
|
}
|
|
}
|