|
|
@ -1,13 +1,19 @@ |
|
|
|
package com.zc.business.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.google.gson.JsonArray; |
|
|
|
import com.google.gson.JsonElement; |
|
|
|
import com.google.gson.JsonParser; |
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.exception.ServiceException; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.SecurityUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.common.utils.bean.BeanValidators; |
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
|
import com.zc.business.domain.DcEmployees; |
|
|
|
import com.zc.business.domain.DcShifts; |
|
|
|
import com.zc.business.domain.DcShiftsList; |
|
|
|
import com.zc.business.domain.DcShiftsRecord; |
|
|
|
import com.zc.business.mapper.DcEmployeesMapper; |
|
|
|
import com.zc.business.mapper.DcShiftsMapper; |
|
|
@ -19,13 +25,10 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.validation.Validator; |
|
|
|
import java.lang.reflect.Array; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 值班Service业务层处理 |
|
|
@ -62,23 +65,30 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
* @return 值班 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<HashMap> selectDcShiftsList(DcShifts dcShifts) |
|
|
|
public List<DcShifts> selectDcShiftsList(DcShifts dcShifts) |
|
|
|
{ |
|
|
|
List<HashMap> objects = new ArrayList<>(); |
|
|
|
// ArrayList<HashMap> objects = new ArrayList<>();
|
|
|
|
ArrayList<DcShifts> objects = new ArrayList<>(); |
|
|
|
List<DcShifts> list = dcShiftsMapper.selectDcShiftsList(dcShifts); |
|
|
|
for (DcShifts shifts:list){ |
|
|
|
HashMap<String, Object> map = new HashMap<String, Object>(); |
|
|
|
for (DcShifts shifts:list ){ |
|
|
|
Date date = shifts.getDate(); |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String formattedDate = formatter.format(date); |
|
|
|
String station = shifts.getStation(); |
|
|
|
List<HashMap<String, Object>> name = dcShiftsMapper.selectStation(station, date); |
|
|
|
map.put("date",formattedDate); |
|
|
|
map.put("organizationName",name); |
|
|
|
|
|
|
|
objects.add(map); |
|
|
|
Long station = shifts.getStation(); |
|
|
|
List<DcShiftsList> organizationName = dcShiftsMapper.selectStationDate(station, date); |
|
|
|
shifts.setShiftsList(organizationName); |
|
|
|
objects.add(shifts); |
|
|
|
} |
|
|
|
return objects; |
|
|
|
// for (DcShifts shifts:list){
|
|
|
|
// HashMap<String, Object> map = new HashMap<String, Object>();
|
|
|
|
// Date date = shifts.getDate();
|
|
|
|
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// String formattedDate = formatter.format(date);
|
|
|
|
// String station = shifts.getStation();
|
|
|
|
// List<HashMap<String, Object>> name = dcShiftsMapper.selectStation(station, date);
|
|
|
|
// map.put("date",formattedDate);
|
|
|
|
// map.put("organizationName",name);
|
|
|
|
// objects.add(map);
|
|
|
|
// }
|
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -95,27 +105,45 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = ServiceException.class) |
|
|
|
public int insertDcShifts(DcShifts dcShifts) throws Exception{ |
|
|
|
dcShifts.setCreateTime(DateUtils.getNowDate()); |
|
|
|
int shifts = dcShiftsMapper.insertDcShifts(dcShifts); |
|
|
|
String msg = ""; |
|
|
|
if (shifts==0){ |
|
|
|
msg="新增用户信息失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord(); |
|
|
|
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
|
|
|
|
dcShiftsRecord.setOperationType("Add");//操作类型
|
|
|
|
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
|
|
|
|
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
|
|
|
|
Long employeesId = dcShifts.getEmployeesId();//新增人员id
|
|
|
|
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesId); |
|
|
|
String name = dcEmployees.getName();//新增人员名称
|
|
|
|
dcShiftsRecord.setModifyContent("新增值班人员"+name); |
|
|
|
dcShifts.setCreateTime(DateUtils.getNowDate()); |
|
|
|
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); |
|
|
|
if (shiftsRecord==0){ |
|
|
|
msg="操作日志记录失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
JSON employeesJson = dcShifts.getEmployeesJson(); |
|
|
|
JsonElement jsonElement = new JsonParser().parse(String.valueOf(employeesJson)); |
|
|
|
JsonArray jsonArray = jsonElement.getAsJsonArray(); |
|
|
|
for (JsonElement element : jsonArray) { |
|
|
|
Long employeesId = element.getAsJsonObject().get("employeesId").getAsLong(); |
|
|
|
Long station = element.getAsJsonObject().get("station").getAsLong(); |
|
|
|
String scheduling = element.getAsJsonObject().get("scheduling").getAsString(); |
|
|
|
if (employeesId!=null&&station!=null&& StringUtils.isNotEmpty(scheduling)){ |
|
|
|
dcShifts.setEmployeesId(employeesId); |
|
|
|
dcShifts.setStation(station); |
|
|
|
dcShifts.setScheduling(scheduling); |
|
|
|
Long aLong = dcShiftsMapper.selectExist(dcShifts); |
|
|
|
if (aLong!=0){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
dcShifts.setCreateTime(DateUtils.getNowDate()); |
|
|
|
int shifts = dcShiftsMapper.insertDcShifts(dcShifts); |
|
|
|
if (shifts==0){ |
|
|
|
msg="新增用户信息失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord(); |
|
|
|
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
|
|
|
|
dcShiftsRecord.setOperationType("Add");//操作类型
|
|
|
|
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
|
|
|
|
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
|
|
|
|
Long employeesIdS = dcShifts.getEmployeesId();//新增人员id
|
|
|
|
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesIdS); |
|
|
|
String name = dcEmployees.getName();//新增人员名称
|
|
|
|
dcShiftsRecord.setModifyContent("新增值班人员"+name); |
|
|
|
dcShifts.setCreateTime(DateUtils.getNowDate()); |
|
|
|
dcShiftsRecord.setStation(station);//驻点
|
|
|
|
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); |
|
|
|
if (shiftsRecord==0){ |
|
|
|
msg="操作日志记录失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
@ -153,6 +181,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
|
|
|
|
dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期
|
|
|
|
dcShiftsRecord.setModifyContent("岗位" + postNameBefore + "姓名" + nameBefore + "修改为" + postName + name); |
|
|
|
dcShiftsRecord.setStation(dcShiftsById.getStation());//驻点
|
|
|
|
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); |
|
|
|
if (shiftsRecord == 0) { |
|
|
|
msg = "操作日志记录失败"; |
|
|
@ -186,6 +215,37 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
|
|
|
|
dcShiftsRecord.setModifyContent("删除值班人员"+name); |
|
|
|
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
|
|
|
|
dcShiftsRecord.setStation(dcShifts.getStation());//驻点
|
|
|
|
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); |
|
|
|
if (shiftsRecord==0){ |
|
|
|
msg="操作日志记录失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = ServiceException.class) |
|
|
|
public int deleteDcShiftsListId(DcShifts dcShifts) throws Exception { |
|
|
|
List<DcShifts> shiftsValue = dcShiftsMapper.selectDcShiftsDeleteList(dcShifts); |
|
|
|
for (DcShifts shifts:shiftsValue){ |
|
|
|
Long id = shifts.getId(); |
|
|
|
DcShifts dcShiftsById = dcShiftsMapper.selectDcShiftsById(id); |
|
|
|
String name = dcShiftsById.getName(); |
|
|
|
String msg = ""; |
|
|
|
int i = dcShiftsMapper.deleteDcShiftsById(id); |
|
|
|
if (i==0){ |
|
|
|
msg="删除用户信息失败"; |
|
|
|
throw new ServiceException(msg); |
|
|
|
} |
|
|
|
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord(); |
|
|
|
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
|
|
|
|
dcShiftsRecord.setOperationType("DELETE");//操作类型
|
|
|
|
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
|
|
|
|
dcShiftsRecord.setModifyContent("删除值班人员"+name); |
|
|
|
dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期
|
|
|
|
dcShiftsRecord.setStation(dcShiftsById.getStation());//驻点
|
|
|
|
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord); |
|
|
|
if (shiftsRecord==0){ |
|
|
|
msg="操作日志记录失败"; |
|
|
@ -195,6 +255,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 删除值班信息 |
|
|
|
* |
|
|
@ -243,7 +304,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService |
|
|
|
|
|
|
|
//查询操作记录表
|
|
|
|
@Override |
|
|
|
public List<DcShiftsRecord> selectDcShiftsRecord() { |
|
|
|
return dcShiftsMapper.selectDcShiftsRecord(); |
|
|
|
public List<DcShiftsRecord> selectDcShiftsRecord(DcShifts shifts) { |
|
|
|
return dcShiftsMapper.selectDcShiftsRecord(shifts); |
|
|
|
} |
|
|
|
} |
|
|
|