Browse Source

导入模板修改,模板样式修改,优化部分代码

develop
zhao-meiyu 11 months ago
parent
commit
62557d6df3
  1. 10
      zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java
  2. 36
      zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java
  3. BIN
      zc-business/src/main/resources/excelTemplate/值班示例模板.xlsx

10
zc-business/src/main/java/com/zc/business/controller/DcEmployeesController.java

@ -32,7 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/business/employees") @RequestMapping("/business/employees")
@Api(tags = {"人员信息(应急人员与值班人员)"})
public class DcEmployeesController extends BaseController public class DcEmployeesController extends BaseController
{ {
@Autowired @Autowired
@ -41,7 +41,7 @@ public class DcEmployeesController extends BaseController
/** /**
* 查询值班人员信息列表 * 查询值班人员信息列表
*/ */
@ApiOperation("获取人员信息列表") //@ApiOperation("获取人员信息列表")
@PreAuthorize("@ss.hasPermi('business:employees:list')") @PreAuthorize("@ss.hasPermi('business:employees:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(DcEmployees dcEmployees) public TableDataInfo list(DcEmployees dcEmployees)
@ -77,7 +77,7 @@ public class DcEmployeesController extends BaseController
/** /**
* 新增值班人员信息 * 新增值班人员信息
*/ */
@ApiOperation(value = "新增人员信息", notes = "新增人员信息") //@ApiOperation(value = "新增人员信息", notes = "新增人员信息")
@PreAuthorize("@ss.hasPermi('business:employees:add')") @PreAuthorize("@ss.hasPermi('business:employees:add')")
@Log(title = "值班人员信息", businessType = BusinessType.INSERT) @Log(title = "值班人员信息", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@ -89,7 +89,7 @@ public class DcEmployeesController extends BaseController
/** /**
* 修改值班人员信息 * 修改值班人员信息
*/ */
@ApiOperation(value = "修改人员信息", notes = "修改人员信息") //@ApiOperation(value = "修改人员信息", notes = "修改人员信息")
@PreAuthorize("@ss.hasPermi('business:employees:edit')") @PreAuthorize("@ss.hasPermi('business:employees:edit')")
@Log(title = "值班人员信息", businessType = BusinessType.UPDATE) @Log(title = "值班人员信息", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
@ -111,7 +111,7 @@ public class DcEmployeesController extends BaseController
} }
//查询全部机构id与名称信息 //查询全部机构id与名称信息
@ApiOperation(value = "查询全部机构id与名称信息", notes = "查询全部机构id与名称信息") //@ApiOperation(value = "查询全部机构id与名称信息", notes = "查询全部机构id与名称信息")
@PostMapping("/organization") @PostMapping("/organization")
public AjaxResult selectOrganizationAll(){ public AjaxResult selectOrganizationAll(){
return AjaxResult.success(dcEmployeesService.selectOrganizationAll()); return AjaxResult.success(dcEmployeesService.selectOrganizationAll());

36
zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java

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

BIN
zc-business/src/main/resources/excelTemplate/值班示例模板.xlsx

Binary file not shown.
Loading…
Cancel
Save