111
parent
64f37126e2
commit
b4076353ae
|
@ -29,7 +29,6 @@ public interface RemoteUserService {
|
|||
*/
|
||||
@GetMapping("/user/info/{username}")
|
||||
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
|
@ -43,4 +42,13 @@ public interface RemoteUserService {
|
|||
|
||||
@PostMapping("/user")
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
|
||||
@GetMapping("/user/info/{username}")
|
||||
public Result<LoginUser> info (@PathVariable("username") String username);
|
||||
|
||||
@GetMapping("/user/authRole/{userId}")
|
||||
public Result authRole (@PathVariable("userId") Long userId);
|
||||
|
||||
@GetMapping("/user/selectByUserId/{userId}")
|
||||
public SysUser selectByUserId (@PathVariable("userId") Long userId);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BusinessController extends BaseController {
|
|||
/**
|
||||
* 获取企业详细信息
|
||||
*/
|
||||
// @RequiresPermissions("system:business:query")
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ public class BusinessController extends BaseController {
|
|||
/**
|
||||
* 新增企业
|
||||
*/
|
||||
// @RequiresPermissions("system:business:add")
|
||||
|
||||
@Log(title = "企业", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody Business business)
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Business extends BaseEntity {
|
|||
|
||||
/** 企业主键 */
|
||||
@Excel(name = "企业主键")
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 企业名称 */
|
||||
|
@ -77,4 +77,5 @@ public class Business extends BaseEntity {
|
|||
/** 认证等级0/1 */
|
||||
@Excel(name = "认证等级0/1")
|
||||
private String authentication;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
package com.xiaohuang.business.gaode;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* GaoDe
|
||||
*
|
||||
|
@ -7,4 +19,16 @@ package com.xiaohuang.business.gaode;
|
|||
* on 2024/6/1
|
||||
*/
|
||||
public class GaoDe {
|
||||
|
||||
private static String key = "d4178e403ddd206ad3c0a4cad4271ae8";
|
||||
|
||||
public static String getAdd(String log, String lat){
|
||||
|
||||
StringBuffer s = new StringBuffer();
|
||||
|
||||
s.append("key=").append(key).append("&location=").append(log).append(",").append(lat);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.xiaohuang.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.xiaohuang.business.domain.Business;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -60,4 +63,6 @@ public interface BusinessMapper extends BaseMapper<Business>
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteBusinessByIds(Long[] ids);
|
||||
|
||||
Result<LoginUser> info(@Param("userId") Long userId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.xiaohuang.business.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* RemoteUserLoginFactory
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/2
|
||||
*/
|
||||
|
||||
@FeignClient("muyu-system")
|
||||
public interface RemoteUserLoginFactory {
|
||||
|
||||
@Log(title = "用户管理",businessType = BusinessType.INSERT)
|
||||
@PostMapping("/user")
|
||||
public Result add(@Validated @RequestBody SysUser user);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
package com.xiaohuang.business.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
|
@ -13,6 +14,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +52,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
|||
@Override
|
||||
public Business selectBusinessById(Long id)
|
||||
{
|
||||
return this.baseMapper.selectBusinessById(id);
|
||||
return businessMapper.selectBusinessById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,9 +65,17 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
|||
public List<Business> selectBusinessList(Business business)
|
||||
{
|
||||
|
||||
return this.baseMapper.selectBusinessList(business);
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser user = remoteUserService.selectByUserId(loginUser.getUserid());
|
||||
if (user.getUserType().equals("00")) {
|
||||
return businessMapper.selectBusinessList(business);
|
||||
}
|
||||
business.setId(Long.valueOf(user.getUserType()));
|
||||
return businessMapper.selectBusinessList(business);
|
||||
}
|
||||
|
||||
|
||||
//新增企业
|
||||
@Override
|
||||
public int insertBusiness(Business business)
|
||||
{
|
||||
|
@ -75,11 +92,77 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
|||
.userType(String.valueOf(business.getId()))
|
||||
.build();
|
||||
Result add = remoteUserService.add(sysUser);
|
||||
System.out.println(sysUser);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public void httpConnectMysql(Business business){
|
||||
if (business.getBusinessStates().equals(2)){
|
||||
if (!redisTemplate.hasKey(business.getId()+business.getName())){
|
||||
redisTemplate.opsForValue().set(business.getId()+business.getName(), String.valueOf(3306+business.getId()));
|
||||
extracted(business);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void extracted(Business business){
|
||||
//建木
|
||||
String postUrl = "http://175.24.138.82:10006/webhook/%E6%9C%AA%E5%91%BD%E5%90%8D%E9%A1%B9%E7%9B%AE";
|
||||
HashMap<String, String> hashMap = new HashMap<>();
|
||||
hashMap.put("businessId",business.getId()+business.getName());
|
||||
hashMap.put("mysqlPort",String.valueOf(3306+ business.getId()));
|
||||
String json = JSON.toJSONString(hashMap);
|
||||
|
||||
//创建链接与设置连接参数
|
||||
URL urlObj = null;
|
||||
|
||||
try {
|
||||
urlObj = new URL(postUrl);
|
||||
|
||||
HttpURLConnection httpConn = (HttpURLConnection) urlObj.openConnection();
|
||||
|
||||
httpConn.setRequestMethod("POST");
|
||||
httpConn.setRequestProperty("Charset","UTF-8");
|
||||
|
||||
//post请求且JSON数据,必须要设置
|
||||
httpConn.setRequestProperty("Content-Type","application/json");
|
||||
|
||||
//打开输出流.默认是false
|
||||
httpConn.setDoOutput(false);
|
||||
|
||||
//打开输入流.默认是true,
|
||||
httpConn.setDoOutput(true);
|
||||
|
||||
//获取输出流和写数据
|
||||
OutputStream oStream = httpConn.getOutputStream();
|
||||
|
||||
oStream.write(json.getBytes());
|
||||
oStream.flush();
|
||||
|
||||
//调用
|
||||
if (httpConn.getResponseCode()!=200){
|
||||
throw new Exception("调用服务端异常");
|
||||
}
|
||||
|
||||
//获取输入流和读取数据
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(httpConn.getInputStream())
|
||||
);
|
||||
|
||||
String resultData = br.readLine();
|
||||
|
||||
System.out.println("服务端返回结果: "+ resultData);
|
||||
|
||||
//关闭链接
|
||||
httpConn.disconnect();
|
||||
|
||||
|
||||
//打开输出流.
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改企业
|
||||
*
|
||||
|
@ -90,7 +173,8 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
|||
public int updateBusiness(Business business)
|
||||
{
|
||||
business.setUpdateTime(DateUtils.getNowDate());
|
||||
return this.baseMapper.updateBusiness(business);
|
||||
httpConnectMysql(business);
|
||||
return businessMapper.updateBusiness(business);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +186,7 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
|||
@Override
|
||||
public int deleteBusinessByIds(Long[] ids)
|
||||
{
|
||||
return this.baseMapper.deleteBusinessByIds(ids);
|
||||
return businessMapper.deleteBusinessByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,6 +198,6 @@ public class BusinessServiceImpl extends ServiceImpl<BusinessMapper, Business> i
|
|||
@Override
|
||||
public int deleteBusinessById(Long id)
|
||||
{
|
||||
return this.baseMapper.deleteBusinessById(id);
|
||||
return businessMapper.deleteBusinessById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectBusinessList" parameterType="com.xiaohuang.business.domain.Business" resultMap="BusinessResult">
|
||||
<include refid="selectBusinessVo"/>
|
||||
<where>
|
||||
<if test="id != null and id != ''"> and id = #{id}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="businessPerson != null and businessPerson != ''"> and business_person = #{businessPerson}</if>
|
||||
<if test="businessLincenseNumber != null and businessLincenseNumber != ''"> and business_lincense_number = #{businessLincenseNumber}</if>
|
||||
|
@ -48,6 +49,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="info" resultType="com.muyu.common.system.domain.LoginUser">
|
||||
select * from sys_user where id=#{userId}
|
||||
</select>
|
||||
|
||||
<insert id="insertBusiness" parameterType="com.xiaohuang.business.domain.Business" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into business
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
@ -66,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="businessPerson != null">#{businessPerson},</if>
|
||||
|
@ -83,7 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateBusiness" parameterType="com.xiaohuang.business.domain.Business">
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package com.xiaohuang.vehicle.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.xiaohuang.vehicle.domain.vo.Path;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 围栏对象 Fence
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/2
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("fence")
|
||||
public class Fence extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 围栏主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 围栏名称
|
||||
*/
|
||||
@Excel(name = "围栏名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@Excel(name = "围栏组Id")
|
||||
private Long groupId;
|
||||
|
||||
|
||||
/**
|
||||
* 围栏经纬集合
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<Path> path;
|
||||
|
||||
/**
|
||||
* 围栏经纬
|
||||
*/
|
||||
@Excel(name = "围栏经纬")
|
||||
private String fenceLongitudeLatitude;
|
||||
|
||||
/**
|
||||
* 围栏备注
|
||||
*/
|
||||
@Excel(name = "围栏备注")
|
||||
private String fenceDescription;
|
||||
|
||||
|
||||
/**
|
||||
* 半径
|
||||
*/
|
||||
@Excel(name = "半径")
|
||||
private Double redius;
|
||||
|
||||
|
||||
/**
|
||||
* 驶入,驶出
|
||||
*/
|
||||
@Excel(name = "驶入,驶出")
|
||||
private String eventType;
|
||||
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@Excel(name = "是否删除 0否 1是")
|
||||
private String isDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 围栏状态
|
||||
*/
|
||||
@Excel(name = "围栏状态")
|
||||
private String fenceState;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.xiaohuang.vehicle.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 围栏组对象 Group
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/2
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("group")
|
||||
public class Group extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 围栏组id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 围栏组名称
|
||||
*/
|
||||
@Excel(name = "围栏组名称")
|
||||
private String groupName;
|
||||
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
}
|
|
@ -34,7 +34,7 @@ public class Vehicle extends BaseEntity
|
|||
|
||||
/** 车辆vin */
|
||||
@Excel(name = "车辆vin")
|
||||
private Long number;
|
||||
private String number;
|
||||
|
||||
/** 车辆类型 */
|
||||
@Excel(name = "车辆类型")
|
||||
|
@ -62,6 +62,9 @@ public class Vehicle extends BaseEntity
|
|||
|
||||
/** 企业ID */
|
||||
@Excel(name = "企业ID")
|
||||
private Long enterpriseId;
|
||||
private Long businessId;
|
||||
|
||||
@Excel(name="围栏组ID")
|
||||
private Long groupId;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.xiaohuang.vehicle.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Path
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/2
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Path {
|
||||
|
||||
private String Q;
|
||||
private String R;
|
||||
private String lng;
|
||||
private String lat;
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.xiaohuang.vehicle.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 车辆录入对象 VehicleReq
|
||||
*
|
||||
* @author xiaohuang
|
||||
* on 2024/6/2
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class VehicleReq {
|
||||
|
||||
|
||||
|
||||
/** 车辆主键 */
|
||||
private Long id;
|
||||
|
||||
/** 车辆vin */
|
||||
private String number;
|
||||
|
||||
/** 车辆类型 */
|
||||
private Long typeId;
|
||||
|
||||
/** 电子围栏ID */
|
||||
private Long electonicId;
|
||||
|
||||
/** 电机厂商 */
|
||||
private String motor;
|
||||
|
||||
/** 电池厂商 */
|
||||
private String battery;
|
||||
|
||||
/** 电机编号 */
|
||||
private Long motorNumber;
|
||||
|
||||
/** 电池编号 */
|
||||
private Long batteryNumber;
|
||||
|
||||
/** 企业ID */
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String businessNam;
|
||||
|
||||
}
|
Loading…
Reference in New Issue