手环领用接口开发 、通用模块接口开发

This commit is contained in:
haozq 2024-08-07 20:06:45 +08:00
parent 88c5bd9fd3
commit e0853e088c
12 changed files with 1006 additions and 50 deletions

View File

@ -0,0 +1,117 @@
package com.bonus.common.core.utils;
/**
* 经纬度工具类
*/
public class HaversineUtil {
/**
*精度低
* @param lat1
* @param lon1
* @param lat2
* @param lon2
* @return
*/
public static double haversineDistance(double lat1, double lon1, double lat2, double lon2) {
double earthRadius = 6371; // 地球半径单位千米
// 将经纬度转换为弧度
double latRad1 = Math.toRadians(lat1);
double lonRad1 = Math.toRadians(lon1);
double latRad2 = Math.toRadians(lat2);
double lonRad2 = Math.toRadians(lon2);
// 计算经纬度差值
double deltaLat = latRad2 - latRad1;
double deltaLon = lonRad2 - lonRad1;
// 应用Haversine公式计算距离
double a = Math.pow(Math.sin(deltaLat / 2), 2)
+ Math.cos(latRad1) * Math.cos(latRad2)
* Math.pow(Math.sin(deltaLon / 2), 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
// 计算距离
double distance = earthRadius * c;
return distance;
}
/**
* 计算两个经纬度的距离
* @param lat1
* @param lon1
* @param lat2
* @param lon2
* @return
*/
public static double vincentyDistance(double lat1, double lon1, double lat2, double lon2) {
double a = 6378137; // 赤道半径单位
double b = 6356752.3142; // 极半径单位
double f = 1 / 298.257223563; // 椭球扁率
// 将经纬度转换为弧度
double latRad1 = Math.toRadians(lat1);
double lonRad1 = Math.toRadians(lon1);
double latRad2 = Math.toRadians(lat2);
double lonRad2 = Math.toRadians(lon2);
// 计算经纬度差值
double L = lonRad2 - lonRad1;
// 计算U1和U2
double tanU1 = (1 - f) * Math.tan(latRad1);
double cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1);
double sinU1 = tanU1 * cosU1;
double tanU2 = (1 - f) * Math.tan(latRad2);
double cosU2 = 1 / Math.sqrt(1 + tanU2 * tanU2);
double sinU2 = tanU2 * cosU2;
// 初始化λ和λ'
double lambda = L;
double lambdaPrime;
int iterationLimit = 100; // 迭代次数限制
double cosSigma, sinSigma, sigma, sinAlpha, cosSqAlpha, cos2SigmaM;
do {
double sinLambda = Math.sin(lambda);
double cosLambda = Math.cos(lambda);
sinSigma = Math.sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda)
+ (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
* (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
if (sinSigma == 0) {
// 两点重合距离为0
return 0;
}
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
sigma = Math.atan2(sinSigma, cosSigma);
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
cosSqAlpha = 1 - sinAlpha * sinAlpha;
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
if (Double.isNaN(cos2SigmaM)) {
cos2SigmaM = 0;
}
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
lambdaPrime = lambda;
lambda = L + (1 - C) * f * sinAlpha
* (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma
* (-1 + 2 * cos2SigmaM * cos2SigmaM)));
iterationLimit--;
} while (Math.abs(lambda - lambdaPrime) > 1e-12 && iterationLimit > 0);
if (iterationLimit == 0) {
// 未能收敛返回NaN
return Double.NaN;
}
// 计算椭球面之间的距离
double uSq = cosSqAlpha * (a * a - b * b) / (b * b);
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
double deltaSigma = B
* sinSigma
* (cos2SigmaM + B
/ 4
* (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B
/ 6
* cos2SigmaM
* (-3 + 4 * sinSigma * sinSigma)
* (-3 + 4 * cos2SigmaM * cos2SigmaM)));
double distance = b * A * (sigma - deltaSigma);
return distance;
}
}

View File

@ -78,6 +78,10 @@ public class AesCbcUtils {
public static void main(String[] args) {
// String json="";
String param="curryDay=2024-08-07";
String data2=encrypt(param);
System.err.println(data2);
String json="{\"username\":\"guest\",\"password\":\"admin@123\"}";
String data=encrypt(json);
System.err.println(data);

View File

@ -26,8 +26,39 @@ public class BoxEntity {
*/
private String roleCode;
/**
* 班组id
*/
private long teamId;
/**
* 日期
*/
private String curryDay;
/**
* 发放的手环数量
*/
private Integer boxNum;
/**
* 班组名称
*/
private String teamName;
/**
* 手环编码
*/
private String shCode;
/**
* 用户名称
*/
private String userName;
/**
* 设备id
*/
private String devIds;
/**
* 手环数量
*/
private Integer shNum;
}

View File

@ -11,6 +11,10 @@ public class BraceletEntity {
* 设备id
*/
private String id;
/**
* 绑定人id
*/
private String peopleId;
/**
* 手环发放的数量
@ -26,6 +30,19 @@ public class BraceletEntity {
* 用户id
*/
private String userId;
/**
* 用户名称
*/
private String userName;
private String teamName;
/**
* 身份证
*/
private String idCard;
/**
* 设备id
*/
@ -34,10 +51,6 @@ public class BraceletEntity {
* 手机号码
*/
private String phone;
/**
* 身份证号码
*/
private String idCard;
/**
* 人员类型
*/
@ -47,5 +60,62 @@ public class BraceletEntity {
*/
private String shCode;
/**
* 电量
*/
private String dl;
/**
* 心率
*/
private String xl;
/**
* 施工杆塔经度
*/
private String sgLat;
/**
* 施工杆塔 维度
*/
private String sgLon;
/**
* 经度
*/
private String lat;
/**
* 维度
*/
private String lon;
/**
* 血压
*/
private String xy;
/**
* 告警内容
*/
private String warn;
/**
* 温度
*/
private String wd;
/**
* 告警内容
*/
private String localWarn;
/**
* 告警内容
*/
private String sgFw;
private DevDetailEntity entity;
/**
* 绑定信息内容
*/
private String bidMsg;
}

View File

@ -0,0 +1,41 @@
package com.bonus.app.entity;
import lombok.Data;
/**
* 设备属性信息实体类
*/
@Data
public class BraceletInfoEntity {
private String id;
/**
*
*/
private String dataVal;
/**
* 编码
*/
private String dataCode;
/**
* 单位
*/
private String dataUnit;
/**
* 设备id
*/
private String devId;
/**
* 数据更新时间
*/
private String dataTime;
/**
* logo图标
*/
private String logoUrl;
private String dataName;
}

View File

@ -0,0 +1,11 @@
package com.bonus.app.entity;
/**
* 数据信息详情
*/
public class DevDetailEntity {
}

View File

@ -1,4 +1,48 @@
package com.bonus.app.config;
import org.omg.CORBA.PUBLIC_MEMBER;
public class SystemConfig {
/**
* 施工配置范围
*/
public final static String dict_code="sys_sg_distance";
/**
* 施工配置范围
*/
public final static Integer max_len=50;
/**
* 电量编码
*/
public final static String dl_code="电量";
/**
* 经度编码
*/
public final static String lat_code="经度";
/**
* 维度编码
*/
public final static String lon_code="维度";
/**
* 施工配置范围
*/
public final static String xl_code="心率";
/**
* 血压
*/
public final static String xy_code="血压";
/**
* 温度 编码
*/
public final static String wd_code="温度";
}

View File

@ -11,9 +11,8 @@ import com.bonus.common.log.enums.OperaType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -54,10 +53,63 @@ public class BraceletController extends BaseController{
@SysLog(title = "手环管理", businessType = OperaType.QUERY, module = "基础管理->手环管理", details = "查询手环列表")
public AjaxResult getBoxInfo(BoxEntity entity) {
return service.getBoxInfo(entity);
}
/**
* 发放手环查询接口
* 分配信息
* @param entity
* @return
*/
@GetMapping("getBoxToUser")
@SysLog(title = "app->手环管理", businessType = OperaType.QUERY, module = "app->手环管理->手环管理", details = "查看手环发放信息")
public AjaxResult getBoxToUser(BoxEntity entity) {
return service.getBoxToUser(entity);
}
/**
* 发放手环查询接口
* 分配信息
* @param entity
* @return
*/
@PostMapping("sendBoxBracelet")
@SysLog(title = "app->手环管理", businessType = OperaType.QUERY, module = "app->手环管理->发放手环", details = "查看手环发放信息")
public AjaxResult sendBoxBracelet(@RequestBody BoxEntity entity) {
return service.sendBoxBracelet(entity);
}
/**
* 归还手环箱查询
* @param entity
* @return
*/
@GetMapping("getBoxBraceletUsed")
@SysLog(title = "app->手环管理", businessType = OperaType.QUERY, module = "app->手环管理->归还手环", details = "手环使用详情")
public AjaxResult getBoxBraceletUsed(BoxEntity entity) {
return service.getBoxBraceletUsed(entity);
}
/**
* 归还手环箱查询
* @param entity
* @return
*/
@PostMapping("returnBoxBracelet")
@SysLog(title = "app->手环管理", businessType = OperaType.QUERY, module = "app->手环管理->归还手环", details = "归还手环")
public AjaxResult returnBoxBracelet(@RequestBody BoxEntity entity) {
return service.returnBoxBracelet(entity);
}
/**
* 归还手环箱查询
* @param entity
* @return
*/
@PostMapping("addLsUser")
@SysLog(title = "app->手环管理", businessType = OperaType.QUERY, module = "app->手环管理->新增临时人员", details = "新增临时人员")
public AjaxResult addLsUser(@RequestParam(value = "file", required = false) MultipartFile file, String params) {
return service.addLsUser(file,params);
}
}

View File

@ -2,7 +2,10 @@ package com.bonus.app.mapper;
import com.bonus.app.entity.BoxEntity;
import com.bonus.app.entity.BraceletEntity;
import com.bonus.app.entity.BraceletInfoEntity;
import com.bonus.app.entity.LsUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@ -19,11 +22,84 @@ public interface BraceletMapper {
*/
List<BoxEntity> getBoxListById(BoxEntity entity);
/**
* 查询手环箱中手环信息
* @param entity
* @return
*/
List<BraceletEntity> getBoxInfo(BoxEntity entity);
/**
* 查询手环箱中使用的手环信息
* @param entity
* @return
*/
List<BraceletEntity> getBoxInfoBid(BoxEntity entity);
/**
* 查询手环信息
* @param vo
*/
List<Map<String,String>> getBoxInfoDetails(BraceletEntity vo);
List<BraceletInfoEntity> getBoxInfoDetails(BraceletEntity vo);
/**
* 人员高空 作业证数量
* @param vo
* @return
*/
int getCertificate(BraceletEntity vo);
/**
* 查询手环发放的数量
* @param entity
* @return
*/
Integer getBoxFfNum(BoxEntity entity);
/**
*
* @param entity
* @return
*/
Integer getBoxShNum(BoxEntity entity);
/**
*
* @param entity
* @return
*/
Integer getShUsed(BoxEntity entity);
int updateBoxNum(BoxEntity entity);
/**
* 依据 手环id 查询对应的手环箱 的手环数量
* @param list
* @return
*/
List<BoxEntity> getBoxBraceletNum(@Param("list") List<String> list);
/**
* 归还手环
* @param vo
*/
int updateBoxBraceletInfo(@Param("devId") String devId);
void insertLsUser(LsUserEntity user);
/**
* 依据身份证号码查询人员
* @param user
* @return
*/
Integer getPeopleNum(LsUserEntity user);
Integer getLsUserNum(LsUserEntity user);
/**
* 依据班组id 查询施工工地id
* @param teamId
* @return
*/
String getProIdByTeamId(@Param("teamId") Long teamId);
}

View File

@ -4,6 +4,7 @@ import com.bonus.app.entity.BoxEntity;
import com.bonus.app.entity.BraceletEntity;
import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@ -21,9 +22,46 @@ public interface BraceletService {
AjaxResult getBoxListById(BoxEntity entity);
/**
* 查询当前手环箱 设备信息
* 查询当前手环箱
* 设备信息
* @param entity
* @return
*/
AjaxResult getBoxInfo(BoxEntity entity);
/**
* 查询手环 使用信息
* @param entity
* @return
*/
AjaxResult getBoxToUser(BoxEntity entity);
/**
* 发放手环
* @param entity
* @return
*/
AjaxResult sendBoxBracelet(BoxEntity entity);
/**
* 手环使用情况
* @param entity
* @return
*/
AjaxResult getBoxBraceletUsed(BoxEntity entity);
/**
*归还手环箱
* @param entity
* @return
*/
AjaxResult returnBoxBracelet(BoxEntity entity);
/**
* 新增临时人员
* @param file
* @param params
* @return
*/
AjaxResult addLsUser(MultipartFile file, String params);
}

View File

@ -1,24 +1,45 @@
package com.bonus.app.service;
import com.bonus.app.config.RoleConfig;
import cn.afterturn.easypoi.cache.manager.IFileLoader;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.bonus.app.config.SystemConfig;
import com.bonus.app.entity.BoxEntity;
import com.bonus.app.entity.BraceletEntity;
import com.bonus.app.entity.BraceletInfoEntity;
import com.bonus.app.entity.LsUserEntity;
import com.bonus.app.mapper.BraceletMapper;
import com.bonus.common.core.utils.DateTimeHelper;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.constant.HttpStatus;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.domain.R;
import com.bonus.common.core.utils.*;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.utils.uuid.IdUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.entity.bracelet.vo.PersonVo;
import com.bonus.common.entity.file.ResourceFileVo;
import com.bonus.common.security.utils.DictUtils;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.RemoteFileService;
import com.bonus.system.api.RemoteSourceService;
import com.bonus.system.api.domain.SysDictData;
import com.bonus.system.api.domain.SysFileSource;
import com.bonus.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
/**
* app 接口实现层
@ -29,20 +50,18 @@ public class BraceletServiceImpl implements BraceletService{
@Autowired
private BraceletMapper mapper;
@Autowired
private RemoteFileService fileService;
@Autowired
private RemoteSourceService sourceService;
@Override
public AjaxResult getBoxListById(BoxEntity entity) {
try{
if (!DateTimeHelper.getNowDay().equals(entity.getCurryDay())) {
return AjaxResult.error("请求参数不正确");
}
LoginUser loginUser= SecurityUtils.getLoginUser();
String teamCode=loginUser.getSysUser().getRoleCode();
entity.setRoleCode(teamCode);
if(ObjectUtils.isEmpty((loginUser.getSysUser().getTeamId()))){
entity.setTeamId(-99999L);
}else{
entity.setTeamId(loginUser.getSysUser().getTeamId());
}
setDefaultVal(entity);
List<BoxEntity> list=mapper.getBoxListById(entity);
return AjaxResult.success(list);
}catch (Exception e){
@ -59,34 +78,354 @@ public class BraceletServiceImpl implements BraceletService{
@Override
public AjaxResult getBoxInfo(BoxEntity entity) {
try{
if (StringUtils.isEmpty(entity.getBoxId())){
return AjaxResult.error("请求参数不正确");
}
Map<String,Object> map= Maps.newHashMap();
// if (StringUtils.isEmpty(entity.getBoxId())){
// return AjaxResult.error("请求参数不正确");
// }
setDefaultVal(entity);
Integer ffNum=mapper.getBoxFfNum(entity);
Integer shUsedNum=mapper.getShUsed(entity);
//查询手环数据信息
List<BraceletEntity> list=mapper.getBoxInfo(entity);
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
List<CompletableFuture<?>> futures = new ArrayList<>();
for (BraceletEntity vo:list){
CompletableFuture<?> future = CompletableFuture.runAsync(() -> {
mapper.getBoxInfoDetails(vo);
}, executor);
futures.add(future);
}
//数据处理->查询属性值高空作业信息
// 等待所有任务完成
List<CompletableFuture<?>> futures = new ArrayList<>();
for(BraceletEntity vo:list){
CompletableFuture<?> future = CompletableFuture.runAsync(() -> {
List<BraceletInfoEntity> infoList=mapper.getBoxInfoDetails(vo);
//数据处理->高空作业证数据信息
SetDevInfo(infoList,vo);
vo.setIdCard(Sm4Utils.decode(vo.getIdCard()));
vo.setPhone(Sm4Utils.decode(vo.getPhone()));
}, executor);
futures.add(future);
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
//进行数据处理
for(BraceletEntity vo:list){
CompletableFuture<?> future = CompletableFuture.runAsync(() -> {
setSgFw(vo);
}, executor);
futures.add(future);
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
// 关闭ExecutorService
executor.shutdown();
if(ffNum<=shUsedNum){
map.put("msg","所发放的手环全部完成绑定");
}else{
map.put("msg",ffNum-shUsedNum+"个手环未在规定时间内通过验证,请现场排查");
}
map.put("data",list);
return AjaxResult.success(map);
}catch (Exception e){
log.error(e.toString());
log.error(e.toString(),e);
}
return AjaxResult.error("系统异常");
}
@Override
public AjaxResult getBoxToUser(BoxEntity entity) {
try{
Map<String,Object> map=Maps.newHashMap();
//发放的数量
Integer ffNum=mapper.getBoxFfNum(entity);
//手环箱中手环的数量
Integer shNum=mapper.getBoxShNum(entity);
//手环被使用的数量
Integer shUsedNum=mapper.getShUsed(entity);
map.put("ffNum",ffNum);
map.put("shNum",shNum);
map.put("shUsedNum",shUsedNum);
return AjaxResult.success(map);
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error("系统异常");
}
/**
* 发放手环
* @param entity
* @return
*/
@Override
public AjaxResult sendBoxBracelet(BoxEntity entity) {
try{
if(ObjectUtils.isEmpty(entity.getBoxNum())){
return AjaxResult.error("发放的数量不能为空");
}
if(entity.getBoxNum()==0){
return AjaxResult.error("发放的数量不能为0");
}
//手环箱中手环的数量
Integer shNum=mapper.getBoxShNum(entity);
if(entity.getBoxNum()>shNum){
return AjaxResult.error("发放的数量不能超过手环箱手环的数量");
}
int num= mapper.updateBoxNum(entity);
if(num>0){
return AjaxResult.success("发放成功");
}
return AjaxResult.success("发放失败");
}catch (Exception e){
log.error(e.toString());
}
return AjaxResult.error("系统异常");
}
@Override
public AjaxResult getBoxBraceletUsed(BoxEntity entity) {
try{
setDefaultVal(entity);
//查询 已使用的手环数据信息
List<BraceletEntity> list=mapper.getBoxInfoBid(entity);
List<CompletableFuture<?>> futures = new ArrayList<>();
ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
for(BraceletEntity vo:list){
CompletableFuture<?> future = CompletableFuture.runAsync(() -> {
List<BraceletInfoEntity> infoList=mapper.getBoxInfoDetails(vo);
//数据处理->高空作业证数据信息
vo.setIdCard(Sm4Utils.decode(vo.getIdCard()));
vo.setPhone(Sm4Utils.decode(vo.getPhone()));
SetDevInfo(infoList,vo);
}, executor);
futures.add(future);
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
executor.shutdown();
return AjaxResult.success(list);
}catch (Exception e){
log.error(e.toString());
}
return AjaxResult.error("系统异常");
}
@Override
public AjaxResult returnBoxBracelet(BoxEntity entity) {
try{
if(StringUtils.isEmpty(entity.getDevIds())){
return AjaxResult.error("请选择归还的设备");
}
List<String> list= Arrays.asList(entity.getDevIds().split("@"));
List<BoxEntity> boxList=mapper.getBoxBraceletNum(list);
boxList.forEach(vo->{
if(vo.getShNum()>vo.getBoxNum()){
vo.setBoxNum(0);
}else {
int num= vo.getBoxNum()-vo.getShNum();
vo.setBoxNum(num);
}
mapper.updateBoxNum(vo);
});
AtomicInteger allNum= new AtomicInteger();
list.forEach(devId->{
int num= mapper.updateBoxBraceletInfo(devId);
allNum.addAndGet(num);
});
if(list.size()==allNum.get()){
return AjaxResult.success("归还成功");
}
return AjaxResult.error("归还失败");
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error("系统异常");
}
@Override
public AjaxResult addLsUser(MultipartFile file, String params) {
try {
if(ObjectUtils.isEmpty(file)){
return AjaxResult.error("请上传人员图片");
}
LsUserEntity user= JSON.parseObject(params,LsUserEntity.class);
if(StringUtils.isEmpty(user.getUserName())){
return AjaxResult.error("用户名不能为空");
}
if(StringUtils.isEmpty(user.getIdCard())){
return AjaxResult.error("身份证号码不能为空");
}
if(!IdCardUtil.isValidChineseID(user.getIdCard())){
return AjaxResult.error("请填写正确的身份证号码");
}
if(StringUtils.isEmpty(user.getPhone())){
return AjaxResult.error("手机号码不能为空");
}
if (!IdCardUtil.isValidChinaMobileNumber(user.getPhone())){
return AjaxResult.error("请输入正确的手机号码");
}
String sex=IdCardUtil.getGenderByIdCard(user.getIdCard());
user.setSex(sex);
user.setPhone(Sm4Utils.encode(user.getPhone()));
user.setIdCard(Sm4Utils.encode(user.getIdCard()));
Integer num=mapper.getLsUserNum(user);
if(num>0){
return AjaxResult.error("临时人员已存在");
}
Integer num2=mapper.getPeopleNum(user);
if(num2>0){
return AjaxResult.error("该员工为正式员工");
}
LoginUser loginUser= SecurityUtils.getLoginUser();
String teamCode=loginUser.getSysUser().getRoleCode();
if(ObjectUtils.isEmpty((loginUser.getSysUser().getTeamId()))){
return AjaxResult.error("未选择班组");
}
user.setTeamId(loginUser.getSysUser().getTeamId());
String proId=mapper.getProIdByTeamId(loginUser.getSysUser().getTeamId());
user.setProId(proId);
mapper.insertLsUser(user);
if(StringUtils.isNotEmpty(user.getId())){
R result=fileService.singleUploadFile(file,SecurityConstants.INNER);
if (result != null && result.getCode() == HttpStatus.ERROR) {
return AjaxResult.error("人员图片上传失败");
} else if (result != null && result.getCode() == HttpStatus.SUCCESS && result.getData() != null) {
String jsonString = JSON.toJSONString(result.getData());
JSONObject item = JSON.parseObject(jsonString);
if (item != null) {
SysFileSource fileVo = setResourceFileData(item, user);
R<Boolean> r= sourceService.addFileSource(fileVo, SecurityConstants.INNER);
if(r.getData()){
return AjaxResult.success("添加成功");
}
}
}
}
return AjaxResult.error("添加失败");
}catch (Exception e){
log.error(e.toString(),e);
}
return AjaxResult.error("系统异常");
}
/**
* 资源文件赋值
*
* @param item
* @return ResourceFileVo
* @author cwchen
* @date 2024/7/16 13:49
*/
public SysFileSource setResourceFileData(JSONObject item, LsUserEntity vo) {
SysFileSource fileVo = new SysFileSource();
fileVo.setFileType(1);
fileVo.setFilePath(item.getString("fileId"));
fileVo.setFileSuffix(item.getString("suffix"));
fileVo.setFileName(item.getString("fileName"));
fileVo.setSourceId(vo.getId());
fileVo.setSourceType("6");
return fileVo;
}
/**
* 赋值默认值
* @param entity
*/
public void setDefaultVal(BoxEntity entity){
LoginUser loginUser= SecurityUtils.getLoginUser();
String teamCode=loginUser.getSysUser().getRoleCode();
entity.setRoleCode(teamCode);
if(ObjectUtils.isEmpty((loginUser.getSysUser().getTeamId()))){
entity.setTeamId(-99999L);
}else{
entity.setTeamId(loginUser.getSysUser().getTeamId());
}
}
/**
* 比较距离
* @param list
* @param vo
*/
public void SetDevInfo( List<BraceletInfoEntity> list ,BraceletEntity vo){
if(StringUtils.isNotEmpty(list)){
list.forEach(entity->{
if(StringHelper.isNotEmpty(entity.getDataVal())){
StringBuffer stringBuffer=new StringBuffer();
stringBuffer.append(entity.getDataVal());
if(StringUtils.isNotEmpty(entity.getDataUnit())){
// stringBuffer.append("(");
stringBuffer.append(entity.getDataUnit());
// stringBuffer.append(")");
}
switch (entity.getDataCode()){
case SystemConfig.dl_code:
vo.setDl(stringBuffer.toString()); break;
case SystemConfig.lat_code:
vo.setLat(stringBuffer.toString());
break;
case SystemConfig.lon_code:
vo.setLon(stringBuffer.toString());
break;
case SystemConfig.xl_code:
vo.setXl(stringBuffer.toString());
break;
case SystemConfig.xy_code:
vo.setXy(stringBuffer.toString());
break;
case SystemConfig.wd_code:
vo.setWd(stringBuffer.toString());
break;
}
}
//查询人员高空作业证数量
int gkNum=mapper.getCertificate(vo);
if(gkNum<1){
vo.setWarn("无高空作业证");
}
});
}
}
/**
* 查询施工范围
* @param vo
*/
public void setSgFw(BraceletEntity vo){
int maxLne=getMaxLen();
if(StringHelper.isNotEmpty(vo.getLat()) && StringHelper.isNotEmpty(vo.getLon())){
if(StringHelper.isNotEmpty(vo.getSgLat()) && StringHelper.isNotEmpty(vo.getSgLon())){
Double lat=Double.parseDouble(vo.getLat());
Double lon=Double.parseDouble(vo.getLon());
Double sgLat=Double.parseDouble(vo.getSgLat());
Double sgLon=Double.parseDouble(vo.getSgLon());
double len=HaversineUtil.vincentyDistance(sgLat,sgLon,lat,lon);
if(len>maxLne){
vo.setSgFw("异常(超出作业范围)");
}else{
vo.setSgFw("正常");
}
}
}else{
vo.setSgFw("无数据");
}
}
/**
* 获取施工范围默认值
* @return
*/
public int getMaxLen(){
List<SysDictData> dictDatas = DictUtils.getDictCache(SystemConfig.dict_code);
int max_len=SystemConfig.max_len;
try{
if(StringUtils.isNotEmpty(dictDatas)){
max_len=Integer.parseInt(dictDatas.get(0).getDictValue());
}
}catch (Exception e){
log.error(e.toString(),e);
}
return max_len;
}
}

View File

@ -3,21 +3,43 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.app.mapper.BraceletMapper">
<insert id="insertLsUser" useGeneratedKeys="true" keyProperty="id">
insert into tb_ls_user (
name,
id_card,
phone,
sex,
create_time,
team_id,
pro_id
)values (#{userName},#{idCard},#{phone},#{sex},now(),#{teamId},#{proId})
</insert>
<update id="updateBoxNum">
UPDATE tb_sh_box
SET box_num=#{boxNum}
where id=#{boxId}
</update>
<update id="updateBoxBraceletInfo">
UPDATE tb_bracelet
SET face_status=0,peopel_type=NULL,bid_id=NULL,bid_time=NULL,sh_status=0
WHERE id=#{devId}
</update>
<select id="getBoxListById" resultType="com.bonus.app.entity.BoxEntity" >
select id boxId,box_name boxName
FROM tb_sh_box
WHERE team_id is not null
WHERE team_id is not null and del_flag=0
<if test="roleCode!=null and roleCode!='' and roleCode=='team'">
and team_id=#{teamId}
</if>
</select>
<select id="getBoxInfo" resultType="com.bonus.app.entity.BraceletEntity">
select blt.sh_code shCode,blt.id devId,peopel_type userType,
select blt.sh_code shCode,blt.id devId,peopel_type userType, blt.bid_id userId,
tpp.lat sgLat ,tpp.lon sgLon,team.team_name teamName,
case
WHEN peopel_type=0 then tpe.name
WHEN peopel_type=1 then tlu.name
ELSE ''
END AS user_name ,
END AS userName ,
case
WHEN peopel_type=0 then tpe.phone
WHEN peopel_type=1 then tlu.phone
@ -27,14 +49,125 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHEN peopel_type=0 then tpe.id_card
WHEN peopel_type=1 then tlu.id_card
ELSE ''
END AS id_card
END AS idCard
FROM tb_bracelet blt
left join tb_people tpe on blt.bid_id=blt.id and peopel_type=0
left join tb_ls_user tlu on blt.bid_id=tlu.id and peopel_type=1
where blt.box_id=#{boxId}
left join tb_sh_box sbx on blt.box_id=sbx.id
left join t_work_team team on team.team_id=sbx.team_id
left join tb_project_power tpp on tpp.id=sbx.gt_id
left join tb_people tpe on blt.bid_id=tpe.id and peopel_type=0
left join tb_ls_user tlu on blt.bid_id=tlu.id and peopel_type=1
where blt.del_flag=0
<if test="boxId!=null and boxId!=''">
and blt.box_id=#{boxId}
</if>
<if test="teamName!=null and teamName!=''">
and team.team_name like concat('%',#{teamName},'%')
</if>
<if test="shCode!=null and shCode!=''">
and blt.sh_code like concat('%',#{shCode},'%')
</if>
<if test="userName!=null and userName!=''">
and (
tpe.name like concat('%',#{userName},'%') or
tlu.name like concat('%',#{userName},'%')
)
</if>
<if test="roleCode!=null and roleCode!='' and roleCode=='team'">
and team_id=#{teamId}
</if>
</select>
<select id="getBoxInfoBid" resultType="com.bonus.app.entity.BraceletEntity">
select blt.sh_code shCode,blt.id devId,peopel_type userType, blt.bid_id userId,
tpp.lat sgLat ,tpp.lon sgLon,
case
WHEN peopel_type=0 then tpe.name
WHEN peopel_type=1 then tlu.name
ELSE ''
END AS userName ,
case
WHEN peopel_type=0 then tpe.phone
WHEN peopel_type=1 then tlu.phone
ELSE ''
END AS phone ,
case
WHEN peopel_type=0 then tpe.id_card
WHEN peopel_type=1 then tlu.id_card
ELSE ''
END AS idCard
FROM tb_bracelet blt
left join tb_sh_box sbx on blt.box_id=sbx.id
left join tb_project_power tpp on tpp.id=sbx.gt_id
left join tb_people tpe on blt.bid_id=tpe.id and peopel_type=0
left join tb_ls_user tlu on blt.bid_id=tlu.id and peopel_type=1
where blt.del_flag=0 AND blt.bid_id is not null and blt.bid_id!=''
<if test="boxId!=null and boxId!=''">
and blt.box_id=#{boxId}
</if>
<if test="roleCode!=null and roleCode!='' and roleCode=='team'">
and team_id=#{teamId}
</if>
<if test="userName!=null and userName!=''">
and (
tpe.name like concat('%',#{userName},'%') or
tlu.name like concat('%',#{userName},'%')
)
</if>
</select>
<select id="getBoxInfoDetails" resultType="java.util.Map">
<select id="getBoxInfoDetails" resultType="com.bonus.app.entity.BraceletInfoEntity">
select id ,data_name dataName,data_val dataVal,data_unit dataUnit,data_code dataCode,data_time dataTime
from tb_dev_details
where dev_id=#{devId}
</select>
<!--高空作业证-->
<select id="getCertificate" resultType="java.lang.Integer">
select count(1)
from tb_people_certificate
where certificate_type=1 and
people_id=#{userId}
</select>
<!--手环发放的数量-->
<select id="getBoxFfNum" resultType="java.lang.Integer">
select box_num
from tb_sh_box
where id=#{boxId}
</select>
<select id="getShUsed" resultType="java.lang.Integer">
SELECT count(1)
FROM tb_bracelet blt
where blt.box_id=#{boxId} and blt.bid_id is not null and blt.bid_id!='' and blt.del_flag=0
</select>
<select id="getBoxShNum" resultType="java.lang.Integer">
SELECT count(1)
FROM tb_bracelet blt
where blt.box_id=#{boxId} and blt.del_flag=0
</select>
<select id="getBoxBraceletNum" resultType="com.bonus.app.entity.BoxEntity">
select box.id boxId,count(1) shNum,box.box_num boxNum
from tb_sh_box box
left join tb_bracelet bt on bt.box_id=box.id
where bt.id in(
<foreach collection="list" item="devId" separator=",">
#{devId}
</foreach>
)
GROUP BY box.id,box.box_num
</select>
<select id="getLsUserNum" resultType="java.lang.Integer">
select count(1)
from tb_ls_user
where id_card=#{idCard}
</select>
<select id="getPeopleNum" resultType="java.lang.Integer">
select count(1)
from tb_people
where id_card=#{idCard} and del_flag=0
</select>
<select id="getProIdByTeamId" resultType="java.lang.String">
select pro_id
from t_work_team
where team_id=#{teamId}
</select>
</mapper>