手环管理

This commit is contained in:
jjLv 2024-08-02 18:49:17 +08:00
parent d136050374
commit 8d8197fb36
8 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package com.bonus.common.entity.bracelet.exportVo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @className:ShExportVo
* @version:1.0
* @description:手环导出-vo
*/
@Data
public class ShExportVo {
@Excel(name = "序号", width = 10.0,height = 20.0, orderNum = "0")
private String id;
@Excel(name = "手环编码", width = 20.0,height = 15.0,orderNum = "1")
private String shCode;
@Excel(name = "所属手环箱", width = 20.0,height = 15.0,orderNum = "2")
private String shboxName;
@Excel(name = "手环状态", width = 20.0,height = 15.0,orderNum = "3")
private String shStatus;
@Excel(name = "使用人", width = 20.0,height = 15.0,orderNum = "4")
private String shPersonName;
}

View File

@ -49,5 +49,8 @@ public class BraceletVo
@Excel(name = "使用人名称")
private String shPersonName;
/** 手环数组id */
@Excel(name = "手环数组id")
private int[] shIds;
}

View File

@ -56,6 +56,19 @@ public class BraceletController extends BaseController {
return getDataTable(list);
}
/**
* 展示未绑定手环列表
* @param data
* @return
*/
@GetMapping("listShNoBind")
@SysLog(title = "手环管理", businessType = OperaType.QUERY, module = "基础管理->手环管理", details = "查询未绑定手环列表")
public TableDataInfo listShNoBind(BraceletVo data) {
startPage();
List<BraceletVo> list = braceletservice.getShBindNoLists(data);
return getDataTable(list);
}
/**
* 展示手环箱列表
@ -106,6 +119,14 @@ public class BraceletController extends BaseController {
return braceletservice.selectBoxById(shboxId);
}
/**
* 根据手环箱id获取刷新详细信息
*/
// @RequiresPermissions("bracelet:shbox:query")
@GetMapping(value = "/new/{shboxId}")
public AjaxResult getNewInfo(@PathVariable Integer shboxId) {
return braceletservice.selectBoxNewById(shboxId);
}
/**
@ -198,4 +219,14 @@ public class BraceletController extends BaseController {
return braceletservice.delSh(vo);
}
/**
* 绑定手环
*/
@PostMapping("bindSh")
@SysLog(title = "手环管理", businessType = OperaType.UPDATE,module = "基础管理->手环管理")
public AjaxResult bindSh(@RequestBody BraceletVo vo) {
int shboxId = vo.getShboxId();
return braceletservice.bindSh(shboxId,vo.getShIds());
}
}

View File

@ -3,7 +3,9 @@ package com.bonus.bracelet.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.bonus.bracelet.mapper.BraceletMapper;
import com.bonus.bracelet.mapper.DeviceMapper;
import com.bonus.bracelet.service.IBraceletService;
import com.bonus.bracelet.service.IDeviceService;
import com.bonus.bracelet.service.IPersonMgeService;
import com.bonus.bracelet.service.ITeamMgeService;
@ -12,7 +14,9 @@ import com.bonus.common.core.utils.ExcelStyleUtil;
import com.bonus.common.entity.bracelet.BraceletParamsDto;
import com.bonus.common.entity.bracelet.exportVo.DeviceExportVo;
import com.bonus.common.entity.bracelet.exportVo.PersonExportVo;
import com.bonus.common.entity.bracelet.exportVo.ShExportVo;
import com.bonus.common.entity.bracelet.exportVo.TeamExportVo;
import com.bonus.common.entity.bracelet.vo.BraceletVo;
import com.bonus.common.entity.bracelet.vo.DeviceVo;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.bracelet.vo.TeamVo;
@ -55,9 +59,14 @@ public class ExportFileController {
@Resource(name = "IDeviceService")
private IDeviceService iDeviceService;
@Resource(name = "IBraceletService")
private IBraceletService iBraceletService;
@Resource(name = "DeviceMapper")
private DeviceMapper deviceMapper;
@Resource(name = "BraceletMapper")
private BraceletMapper braceletMapper;
/**
* 导出人员
*
@ -175,4 +184,31 @@ public class ExportFileController {
log.error(e.toString(), e);
}
}
@GetMapping("exportSh")
public void exportSh(HttpServletRequest request, HttpServletResponse response, BraceletVo dto) {
try {
List<ShExportVo> shExportVoList = new ArrayList<>();
List<BraceletVo> shLists = iBraceletService.getBraceletLists(dto);
for (int i = 0; i < shLists.size(); i++) {
ShExportVo exportVo = new ShExportVo();
BraceletVo vo = shLists.get(i);
BeanUtils.copyProperties(vo, exportVo);
exportVo.setId((i + 1) + "");
exportVo.setShStatus(vo.getShStatus() == BusinessConstants.TYPE3 ? "在用" : vo.getShStatus() == BusinessConstants.TYPE ? "未用" : "其他");
shExportVoList.add(exportVo);
}
ExportParams exportParams = new ExportParams("手环", "手环", ExcelType.XSSF);
exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ShExportVo.class, shExportVoList);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("手环" + ".xlsx", "UTF-8"));
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.close();
workbook.close();
} catch (Exception e) {
log.error(e.toString(), e);
}
}
}

View File

@ -4,6 +4,7 @@ import com.bonus.common.entity.bracelet.vo.BraceletVo;
import com.bonus.common.entity.bracelet.vo.DeviceVo;
import com.bonus.common.entity.bracelet.vo.ShboxVo;
import com.bonus.common.entity.bracelet.vo.SidebandDeviceVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -28,6 +29,13 @@ public interface BraceletMapper {
*/
List<BraceletVo> getShBindLists(BraceletVo data);
/**
* 未绑定手环列表
* @param data
* @return
*/
List<BraceletVo> getShBindNoLists(BraceletVo data);
/**
* 手环箱管理页面手环箱列表
* @param data
@ -70,6 +78,13 @@ public interface BraceletMapper {
*/
public ShboxVo selectBoxById(Integer shboxId);
/**
* 根据手环箱id获得刷新详细信息
* @param shboxId
* @return
*/
public ShboxVo selectBoxNewById(Integer shboxId);
//
// /**
// * 判断设备名称是否存在
@ -174,4 +189,11 @@ public interface BraceletMapper {
* @return
*/
int delShboxById(int shboxId);
/**
* 绑定
* @param shboxId
* @param shId
*/
void bindSh(@Param("shboxId") int shboxId, @Param("shId") int shId);
}

View File

@ -27,6 +27,13 @@ public interface IBraceletService {
*/
List<BraceletVo> getShBindLists(BraceletVo data);
/**
* 未绑定手环列表
* @param data
* @return
*/
List<BraceletVo> getShBindNoLists(BraceletVo data);
/**
* 手环箱管理页面手环箱列表
* @param data
@ -54,6 +61,13 @@ public interface IBraceletService {
*/
public AjaxResult selectBoxById(Integer shboxId);
/**
* 根据手环箱id获得刷新详细信息
* @param shboxId
* @return
*/
public AjaxResult selectBoxNewById(Integer shboxId);
/**
* 新增手环信息
* @param vo
@ -110,4 +124,13 @@ public interface IBraceletService {
* @return
*/
AjaxResult delShboxById(int shboxId);
/**
* 绑定
* @param shboxId
* @param shIds
* @return
*/
AjaxResult bindSh(int shboxId,int[] shIds);
}

View File

@ -1,9 +1,11 @@
package com.bonus.bracelet.service.impl;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.bonus.bracelet.mapper.BraceletMapper;
import com.bonus.bracelet.mapper.DeviceMapper;
import com.bonus.bracelet.service.IBraceletService;
import com.bonus.bracelet.service.IDeviceService;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.bracelet.vo.BraceletVo;
import com.bonus.common.entity.bracelet.vo.DeviceVo;
@ -17,6 +19,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -86,6 +90,16 @@ public class BraceletServiceImpl implements IBraceletService {
return listFilter;
}
@Override
public List<BraceletVo> getShBindNoLists(BraceletVo data) {
List<BraceletVo> list = new ArrayList<>();
try {
list = braceletMapper.getShBindNoLists(data);
} catch (Exception e) {
log.error(e.toString(), e);
}
return list;
}
@Override
public List<ShboxVo> getShboxLists(ShboxVo data) {
@ -328,4 +342,49 @@ public class BraceletServiceImpl implements IBraceletService {
return AjaxResult.error();
}
}
/**
* 根据手环箱id获得刷新详细信息
* @param shboxId
* @return
*/
@Override
public AjaxResult selectBoxNewById(Integer shboxId) {
Map<String,Integer> map= Maps.newHashMap();
try {
ShboxVo vo = braceletMapper.selectBoxNewById(shboxId);
if(!Objects.isNull(vo)){
Integer num=vo.getShboxCapacity()-vo.getShboxBindNum();
map.put("boxNum",num);
}else{
map.put("boxNum",0);
return AjaxResult.error();
}
return AjaxResult.success(map);
} catch (Exception e) {
map.put("boxNum",0);
log.error(e.toString(), e);
return AjaxResult.error();
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult bindSh(int shboxId,int[] shIds) {
if(shIds.length==0){
return AjaxResult.error("请至少选择一个要绑定的手环");
}
try {
for (int i = 0; i < shIds.length; i++) {
int shId = shIds[i];
braceletMapper.bindSh(shboxId,shId);
}
} catch (Exception e) {
log.error(e.toString(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error("绑定失败");
}
return AjaxResult.success("绑定成功");
}
}

View File

@ -40,6 +40,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by id ASC
</select>
<!--未绑定手环列表-->
<select id="getShBindNoLists" resultType="com.bonus.common.entity.bracelet.vo.BraceletVo">
select id as shId,sh_code as shCode
from tb_bracelet
where box_ix is NULL and del_flag = 0
order by id ASC
</select>
<!--获取人员管理表中领用人名称-->
<select id="getBraceletPersonName" parameterType="int" resultType="java.lang.String">
@ -215,4 +223,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from tb_sh_box tsb
where id = #{shboxId} and del_flag = 0
</select>
<!--根据手环箱id获得刷新详细信息-->
<select id="selectBoxNewById" parameterType="int" resultType="com.bonus.common.entity.bracelet.vo.ShboxVo">
select tsb.id as shboxId, tsb.box_name as shboxName,tsb.box_code as shboxCode,tsb.box_capacity as shboxCapacity,count(tb.id) as shboxBindNum
from tb_sh_box tsb
left join tb_bracelet tb on tsb.id = tb.box_ix and tb.del_flag = 0
where tsb.del_flag = 0 and tsb.id = #{shboxId}
group by tsb.id
order by tsb.id ASC
</select>
<!--绑定-->
<update id="bindSh">
UPDATE tb_bracelet
SET box_ix = #{shboxId},sh_status = 0
where id = #{shId}
</update>
</mapper>