|
|
@ -106,13 +106,20 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
@Transactional(rollbackFor = ServiceException.class) |
|
|
|
public int updateDcShifts(DcShifts dcShifts) throws Exception{ |
|
|
|
String msg = ""; |
|
|
|
Long id = dcShifts.getId(); |
|
|
|
dcShifts.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
int updateDcShifts = dcShiftsMapper.updateDcShifts(dcShifts); |
|
|
|
if (updateDcShifts == 0) { |
|
|
|
msg = "修改用户信息失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
Long idBefore = dcShifts.getIdBefore(); |
|
|
|
DcEmployees dcShiftsBefore = dcEmployeesMapper.selectDcEmployeesById(idBefore);//拿到修改前的数据
|
|
|
|
String nameBefore = dcShiftsBefore.getName();//修改前名称
|
|
|
|
String postNameBefore = dcShiftsBefore.getPostName();//修改前职位
|
|
|
|
Long employeesId = dcShifts.getEmployeesId();//修改后人员id
|
|
|
|
if (!idBefore.equals(employeesId)) { |
|
|
|
Long id = dcShifts.getId(); |
|
|
|
DcShifts dcShiftsById = dcShiftsMapper.selectDcShiftsById(id);//查询值班信息
|
|
|
|
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesId);//查询修改后的人员信息
|
|
|
|
String name = dcEmployees.getName();//修改后的人名
|
|
|
|
String postName = dcEmployees.getPostName();//修改后的岗位
|
|
|
@ -120,7 +127,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
|
|
|
|
dcShiftsRecord.setOperationType("EDIT");//操作类型
|
|
|
|
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
|
|
|
|
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
|
|
|
|
dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期
|
|
|
|
dcShiftsRecord.setModifyContent("岗位" + postNameBefore + "姓名" + nameBefore + "修改为" + postName + name); |
|
|
|
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); |
|
|
|
if (shiftsRecord == 0) { |
|
|
@ -128,8 +135,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
dcShifts.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
return dcShiftsMapper.updateDcShifts(dcShifts); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -186,17 +192,19 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
//List<DcShifts> equipmentList = util.importExcel("值班人员数据",file.getInputStream(),0);
|
|
|
|
|
|
|
|
BeanValidators.validateWithException(validator, equipmentList);//对象属性验证
|
|
|
|
|
|
|
|
for (int i = 0; i < equipmentList.size(); i++) { |
|
|
|
DcShifts dcShifts = equipmentList.get(i);//获取第i条全部的数据,转换给实体类
|
|
|
|
String name = dcShifts.getName(); |
|
|
|
String contactNumber = dcShifts.getContactNumber();//手机号
|
|
|
|
if (contactNumber == null || contactNumber.equals("")) { |
|
|
|
msg = "没有获取到相关手机号信息,请输入手机号"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
HashMap<String, Object> map = dcShiftsMapper.contactNumber(contactNumber);//手机号获取人员id
|
|
|
|
if (map == null) { |
|
|
|
msg = "没有查询到" + name + "的手机号绑定的信息,请查看手机号是否正确"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
|
|
|
|
Long id = (Long) map.get("id"); |
|
|
|
dcShifts.setEmployeesId(id); |
|
|
|
dcShifts.setCreateTime(DateUtils.getNowDate()); |
|
|
|