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. 20
      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
@RequestMapping("/business/employees")
@Api(tags = {"人员信息(应急人员与值班人员)"})
public class DcEmployeesController extends BaseController
{
@Autowired
@ -41,7 +41,7 @@ public class DcEmployeesController extends BaseController
/**
* 查询值班人员信息列表
*/
@ApiOperation("获取人员信息列表")
//@ApiOperation("获取人员信息列表")
@PreAuthorize("@ss.hasPermi('business:employees:list')")
@GetMapping("/list")
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')")
@Log(title = "值班人员信息", businessType = BusinessType.INSERT)
@PostMapping
@ -89,7 +89,7 @@ public class DcEmployeesController extends BaseController
/**
* 修改值班人员信息
*/
@ApiOperation(value = "修改人员信息", notes = "修改人员信息")
//@ApiOperation(value = "修改人员信息", notes = "修改人员信息")
@PreAuthorize("@ss.hasPermi('business:employees:edit')")
@Log(title = "值班人员信息", businessType = BusinessType.UPDATE)
@PutMapping
@ -111,7 +111,7 @@ public class DcEmployeesController extends BaseController
}
//查询全部机构id与名称信息
@ApiOperation(value = "查询全部机构id与名称信息", notes = "查询全部机构id与名称信息")
//@ApiOperation(value = "查询全部机构id与名称信息", notes = "查询全部机构id与名称信息")
@PostMapping("/organization")
public AjaxResult selectOrganizationAll(){
return AjaxResult.success(dcEmployeesService.selectOrganizationAll());

20
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)
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());

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

Binary file not shown.
Loading…
Cancel
Save