Browse Source

微信推送,短信推送,人员类型,http工具类

develop
wangsixiang 8 months ago
parent
commit
56eba8e75b
  1. 12
      zc-business/pom.xml
  2. 24
      zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
  3. 38
      zc-business/src/main/java/com/zc/business/controller/MsmController.java
  4. 2
      zc-business/src/main/java/com/zc/business/domain/DcEmployees.java
  5. 12
      zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java
  6. 2
      zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
  7. 21
      zc-business/src/main/java/com/zc/business/service/IMsmService.java
  8. 38
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  9. 201
      zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java
  10. 83
      zc-business/src/main/java/com/zc/business/utils/HttpUtil.java
  11. 2
      zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml
  12. 18
      zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

12
zc-business/pom.xml

@ -71,6 +71,18 @@
<artifactId>poi-tl</artifactId> <artifactId>poi-tl</artifactId>
<version>1.9.1</version> <version>1.9.1</version>
</dependency> </dependency>
<!-- aliyun-java-sdk-core -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.6.3</version>
</dependency>
<!-- aliyun-java-sdk-dysmsapi -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies> </dependencies>
<groupId>com.zc</groupId> <groupId>com.zc</groupId>

24
zc-business/src/main/java/com/zc/business/controller/DcWarningController.java

@ -1,5 +1,6 @@
package com.zc.business.controller; package com.zc.business.controller;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcWarningBatchConvert; import com.zc.business.domain.DcWarningBatchConvert;
import com.zc.business.service.IDcWarningService; import com.zc.business.service.IDcWarningService;
@ -10,12 +11,16 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.DcWarning; import com.zc.business.domain.DcWarning;
import com.zc.business.service.IDeviceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -29,6 +34,7 @@ import java.util.List;
* @date 2024-01-26 * @date 2024-01-26
*/ */
@Api(tags = "感知事件") @Api(tags = "感知事件")
@Component
@RestController @RestController
@RequestMapping("/business/warning") @RequestMapping("/business/warning")
public class DcWarningController extends BaseController public class DcWarningController extends BaseController
@ -36,6 +42,11 @@ public class DcWarningController extends BaseController
@Autowired @Autowired
private IDcWarningService dcWarningService; private IDcWarningService dcWarningService;
//定时任务,定时结束部分事件
public void updateEndSection(){
IDcWarningService ben = SpringUtils.getBean(IDcWarningService.class);
ben.updateEndSection();
}
/** /**
* 查询预警信息列表 * 查询预警信息列表
*/ */
@ -136,9 +147,14 @@ public class DcWarningController extends BaseController
return dcWarningService.batchConvert(dcWarningBatchConvert); return dcWarningService.batchConvert(dcWarningBatchConvert);
} }
//定时任务,定时结束部分事件
@PostMapping("/endSection") //指挥调度
public AjaxResult updateEndSection(){ @PostMapping("/commandAndDispatch")
return toAjax(dcWarningService.updateEndSection()); public AjaxResult commandAndDispatch(@RequestBody DcWarning dcWarning){
if (StringUtils.isBlank(dcWarning.getStakeMark())){
return AjaxResult.error("参数错误");
}
return (dcWarningService.commandAndDispatch(dcWarning));
} }
} }

38
zc-business/src/main/java/com/zc/business/controller/MsmController.java

@ -0,0 +1,38 @@
package com.zc.business.controller;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcWarning;
import com.zc.business.service.IMsmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
/**
* 王思祥
* 推送业务
*/
@RestController
@RequestMapping("/business/sms")
public class MsmController extends BaseController {
@Autowired
private IMsmService msmService;
/**
* 短信推送业务,阿里云短信业务
*/
@PostMapping("/push")
public Boolean alibabaCloudSms()
{
return msmService.send("19806114248");
}
//调用微信推送
@PostMapping("/wenXinPush")
public AjaxResult commandAndDispatch(){
return AjaxResult.success(msmService.wenXinSend("wx9ee0e3babfd8d2af","de2ecb80b30d63135918ba3ae6ffb711"));
}
}

2
zc-business/src/main/java/com/zc/business/domain/DcEmployees.java

@ -50,7 +50,7 @@ public class DcEmployees extends BaseEntity
private Long parentId; private Long parentId;
//人员类型1为路管人员2为应急人员 //人员类型1为路管人员2为应急人员
@Excel(name = "人员类型 1-路管人员 2-应急人员") @Excel(name = "人员类型 1-路管人员 2-交警人员")
private Long employeesType; private Long employeesType;
//类型参数 //类型参数
private String type; private String type;

12
zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java

@ -5,9 +5,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import cn.hutool.core.lang.hash.Hash; import cn.hutool.core.lang.hash.Hash;
import com.zc.business.domain.DcRoadSection;
import com.zc.business.domain.DcWaringStrategy; import com.zc.business.domain.DcWaringStrategy;
import com.zc.business.domain.DcWarning; import com.zc.business.domain.DcWarning;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
/** /**
* 预警信息Mapper接口 * 预警信息Mapper接口
@ -90,4 +92,14 @@ public interface DcWarningMapper
public Integer updateEndSection(@Param("dcWarningList") List<DcWarning> dcWarningList); public Integer updateEndSection(@Param("dcWarningList") List<DcWarning> dcWarningList);
//查询当天全部可以结束的事件 //查询当天全部可以结束的事件
public List<DcWarning> selectEndSection(); public List<DcWarning> selectEndSection();
//依据桩号返回驻点id
public Long selectSectionId(@Param("stakeMark")String stakeMark,@Param("direction")String direction);
//依据桩号获取最近距离的驻点
public List<HashMap<String,Object>> selectRecentlySection();
//查询某个机构的全部应急人员信息
public List<HashMap<String,Object>> selectOrganizationEmployees(@Param("organizationId")Long organizationId);
//查询某个机构当天的值班信息
public List<HashMap<String,Object>> selectShifts(@Param("station") Long station);
//查询某个机构的车辆信息
public List<HashMap<String,Object>> selectVehicles(@Param("organizationId")Long organizationId);
} }

2
zc-business/src/main/java/com/zc/business/service/IDcWarningService.java

@ -84,4 +84,6 @@ public interface IDcWarningService
//定时结束部分事件 //定时结束部分事件
Integer updateEndSection(); Integer updateEndSection();
//指挥调度
AjaxResult commandAndDispatch(DcWarning dcWarning);
} }

21
zc-business/src/main/java/com/zc/business/service/IMsmService.java

@ -0,0 +1,21 @@
package com.zc.business.service;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.domain.AjaxResult;
public interface IMsmService {
/**
* 发送短信
*
* @param phone 手机号
* @return
*/
public boolean send(String phone);
/**
* 微信推送
*
* @return
*/
JSONArray wenXinSend(String appId, String appSecret);
}

38
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -1,7 +1,6 @@
package com.zc.business.service.impl; package com.zc.business.service.impl;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
@ -16,19 +15,22 @@ import com.zc.business.mapper.DcEventMapper;
import com.zc.business.mapper.DcWarningMapper; import com.zc.business.mapper.DcWarningMapper;
import com.zc.business.service.IDcEventService; import com.zc.business.service.IDcEventService;
import com.zc.business.service.IDcWarningService; import com.zc.business.service.IDcWarningService;
import com.zc.business.utils.StakeMarkUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.json.JSONObject; import java.util.stream.Collectors;
import org.json.JSONArray;
/** /**
* 预警信息Service业务层处理 * 预警信息Service业务层处理
* *
@ -543,4 +545,34 @@ public class DcWarningServiceImpl implements IDcWarningService
return dcWarningMapper.updateEndSection(dcWarnings); return dcWarningMapper.updateEndSection(dcWarnings);
} }
@Override
public AjaxResult commandAndDispatch(DcWarning dcWarning) {
//逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
for (HashMap<String,Object> map:mapList){
if (StringUtils.isBlank(map.get("stakeMark").toString())){
continue;
}
String stakeMark = map.get("stakeMark").toString();
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//桩号本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
map.put("difference",difference/1000.0);//米转公里加入到map
Long id = (Long) map.get("id");//机构的id,用户获取人员、值班、车辆等信息
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map
List<HashMap<String, Object>> shiftsMap = dcWarningMapper.selectShifts(id);//值班map
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map
map.put("employeesMap",employeesMap);
map.put("shiftsMap",shiftsMap);
map.put("vehiclesMap",vehiclesMap);
hashMaps.add(map);
}
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
return AjaxResult.success(sortedHashMaps);
}
} }

201
zc-business/src/main/java/com/zc/business/service/impl/MsmServiceImpl.java

@ -0,0 +1,201 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.zc.business.service.IMsmService;
import com.zc.business.utils.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 短信业务实现类
*/
@Service
public class MsmServiceImpl implements IMsmService {
private static final String WEIXINTUISONTOKEN = "weixintuisontoken";//redis策略缓存的key
/**
* 发送短信
*
* @param phone 手机号
* @return
*/
public boolean send(String phone) {
//地域节点、阿里云的id、秘钥
DefaultProfile profile = DefaultProfile.getProfile("cn-qingdao",
"LTAI5tENd3j1tP5t2fF4fxaX", "i86Yenj13XRd2aeZMtybpKxsqI1VRU");
IAcsClient client = new DefaultAcsClient(profile);
SendSmsRequest request = new SendSmsRequest();
request.setSysRegionId("cn-qingdao");//地域节点
request.putQueryParameter("PhoneNumbers", phone); //手机号,要填绑定测试的手机号码
request.putQueryParameter("SignName", "阿里云短信测试"); //阿里云签名名称
request.putQueryParameter("TemplateCode", "SMS_154950909"); //阿里云模板code
String code = String.format("%04d", new Random().nextInt(10000));//验证码
HashMap<Object, Object> map = new HashMap<>();
map.put("code", code); //参数加入到map
JSONObject json = new JSONObject(map); //map参数转为JSON传入到模板即可
request.putQueryParameter("TemplateParam", json);
try {
SendSmsResponse response = client.getAcsResponse(request);
if (response != null && response.getCode() != null && response.getCode().equals("OK")) {
return true;
}
return false;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
//测试短信推送
// public static void main(String[] args) {
// MsmServiceImpl msmService = new MsmServiceImpl();
// boolean send = msmService.send("19806114248");
// System.out.println(send);
// }
//微信推送
@Override
public JSONArray wenXinSend(String appId, String appSecret) {
MsmServiceImpl msmService = new MsmServiceImpl();
return msmService.sendTemp(appId, appSecret);
}
//获取微信token
public static com.alibaba.fastjson.JSONObject getAccessToken(String appId, String appSecret) {
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
String accessToken = null;
com.alibaba.fastjson.JSONObject jsonObj = null;
try {
URL urlGet = new URL(url);
HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
http.setRequestMethod("GET"); // 必须是get方式请求
http.setDoInput(true);
http.connect();
InputStream is = http.getInputStream();
int size = is.available();
byte[] jsonBytes = new byte[size];
is.read(jsonBytes);
accessToken = new String(jsonBytes, "UTF-8");
System.err.println(accessToken);
jsonObj = com.alibaba.fastjson.JSONObject.parseObject(accessToken);
is.close();
} catch (Exception e) {
e.printStackTrace();
}
return jsonObj;
}
//执行微信推送
public JSONArray sendTemp(String appId, String appSecret) {
JSONArray objects = new JSONArray();
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(100);
MsmServiceImpl msmService = new MsmServiceImpl();
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
String accessToken = redisCache.getCacheObject(WEIXINTUISONTOKEN);
if (StringUtils.isBlank(accessToken)) {
accessToken = msmService.getAccessToken(appId, appSecret).getString("access_token");//获取到了access_token
String expiresIn = msmService.getAccessToken(appId, appSecret).getString("expires_in");//token有效秒数
redisCache.setCacheObject(WEIXINTUISONTOKEN, accessToken, Integer.parseInt(expiresIn), TimeUnit.SECONDS);//把token存入到redis中,并设置过期时间(时间来自于微信接口返回)
}
JSONArray userListOpenid = msmService.getUserListOpenid(accessToken);
CountDownLatch latch = new CountDownLatch(userListOpenid.size());
for (Object openid : userListOpenid) {
String token = accessToken;
executor.execute(() -> {
// 封装要发送的json
Map<String, Object> map = new HashMap();
map.put("template_id", "D_yBiN7aDl2pw3bhSqU_Fbi0D8BHXL0qeBjhusWVO68");//模板消息id
map.put("touser", openid.toString());//这里的openid是全部关注公众号的openid
// 封装data
com.alibaba.fastjson.JSONObject data = new com.alibaba.fastjson.JSONObject();
com.alibaba.fastjson.JSONObject name = new com.alibaba.fastjson.JSONObject();
name.put("value", "做一个身体和心灵都勇敢的人,趁着身体未老,心灵还透明。晚安!");
data.put("name", name);
com.alibaba.fastjson.JSONObject weather = new com.alibaba.fastjson.JSONObject();
weather.put("value", "阴天 19°c");
data.put("weather", weather);
com.alibaba.fastjson.JSONObject birthday = new com.alibaba.fastjson.JSONObject();
birthday.put("value", "53 天");
data.put("birthday", birthday);
map.put("data", data);
String r = HttpUtil.getJsonData(com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(map)),
"https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token); //发送模板消息
System.out.println("-->" + r);
try {
JSONObject jsonObject = new JSONObject(r);
String errmsg = jsonObject.getString("errmsg");
Object errcode = jsonObject.get("errcode");
objects.add(errcode);
} catch (Exception e) {
e.printStackTrace();
} finally {
latch.countDown();
}
});
}
try {
latch.await(); // 等待所有线程执行完毕
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
executor.shutdown();
}
return objects;
//map.put("url","https://www.vipkes.cn");//用户点击模板消息,要跳转的地址
// 封装miniprogram 跳转小程序用,不跳不要填
// Map<String, String> mapA = new HashMap<>();
// mapA.put("appid", ""); //小程序appid
// mapA.put("pagepath", ""); //小程序页面pagepath
// map.put("miniprogram", mapA);
}
//获取微信公众号全部关注人的openid
public static JSONArray getUserListOpenid(String accessToken) {
String url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + accessToken;
;
com.alibaba.fastjson.JSONObject jsonObj = null;
try {
URL urlGet = new URL(url);
HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
http.setRequestMethod("GET"); // 必须是get方式请求
http.setDoInput(true);
http.connect();
InputStream is = http.getInputStream();
int size = is.available();
byte[] jsonBytes = new byte[size];
is.read(jsonBytes);
String userOpenid = new String(jsonBytes, "UTF-8");
jsonObj = com.alibaba.fastjson.JSONObject.parseObject(userOpenid);
is.close();
} catch (Exception e) {
e.printStackTrace();
}
com.alibaba.fastjson.JSONObject data = jsonObj.getJSONObject("data");
return data.getJSONArray("openid");
}
}

83
zc-business/src/main/java/com/zc/business/utils/HttpUtil.java

@ -0,0 +1,83 @@
package com.zc.business.utils;
import com.alibaba.fastjson.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpUtil {
public static String getJsonData(JSONObject jsonParam, String urls) {
StringBuffer sb = new StringBuffer();
try {
// 创建url资源
URL url = new URL(urls);
// 建立http连接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 设置允许输出
conn.setDoOutput(true);
// 设置允许输入
conn.setDoInput(true);
// 设置不用缓存
conn.setUseCaches(false);
// 设置传递方式
conn.setRequestMethod("POST");
// 设置维持长连接
conn.setRequestProperty("Connection", "Keep-Alive");
// 设置文件字符集:
conn.setRequestProperty("Charset", "UTF-8");
// 转换为字节数组
byte[] data = (jsonParam.toString()).getBytes();
// 设置文件长度
conn.setRequestProperty("Content-Length", String.valueOf(data.length));
// 设置文件类型:
conn.setRequestProperty("contentType", "application/json");
// 开始连接请求
conn.connect();
//OutputStream out = new DataOutputStream(conn.getOutputStream()) ;
//防止消息乱码
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "utf-8");
// 写入请求的字符串
out.write(jsonParam.toString());
out.flush();
out.close();
System.out.println(conn.getResponseCode());
// 请求返回的状态
if (HttpURLConnection.HTTP_OK == conn.getResponseCode()) {
System.out.println("连接成功");
// 请求返回的数据
InputStream in1 = conn.getInputStream();
try {
String readLine = new String();
BufferedReader responseReader = new BufferedReader(new InputStreamReader(in1, "UTF-8"));
while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine).append("\n");
}
responseReader.close();
System.out.println(sb.toString());
} catch (Exception e1) {
e1.printStackTrace();
}
} else {
System.out.println("error++");
}
} catch (Exception e) {
}
return sb.toString();
}
}

2
zc-business/src/main/resources/mapper/business/DcEmployeesMapper.xml

@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
employees.create_time, employees.update_time, employees.create_time, employees.update_time,
CASE CASE
WHEN employees.employees_type = 1 THEN '路管人员' WHEN employees.employees_type = 1 THEN '路管人员'
WHEN employees.employees_type = 2 THEN '应急人员' WHEN employees.employees_type = 2 THEN '交警人员'
END AS type END AS type
from dc_employees as employees from dc_employees as employees
left join dc_organization as organization on organization.id=employees.organization_id left join dc_organization as organization on organization.id=employees.organization_id

18
zc-business/src/main/resources/mapper/business/DcWarningMapper.xml

@ -245,5 +245,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectEndSection" resultType="com.zc.business.domain.DcWarning"> <select id="selectEndSection" resultType="com.zc.business.domain.DcWarning">
select id from dc_warning where YEAR(end_time) = YEAR(CURDATE()) and warning_state!=4 and now()>end_time select id from dc_warning where YEAR(end_time) = YEAR(CURDATE()) and warning_state!=4 and now()>end_time
</select> </select>
<select id="selectSectionId" resultType="java.lang.Long">
select section_id from dc_satke_mark where stake_mark=#{stakeMark} and direction=#{direction}
</select>
<select id="selectRecentlySection" resultType="hashmap">
select id,organization_name organizationName,stake_mark stakeMark from dc_organization
</select>
<select id="selectOrganizationEmployees" resultType="java.util.HashMap">
select name,contact_number contactNumber from dc_employees where organization_id=#{organizationId} and employees_type=2
</select>
<select id="selectShifts" resultType="java.util.HashMap">
select shifts.scheduling,employees.name shiftsName,employees.contact_number shiftsNumber from dc_shifts as shifts
left join dc_employees as employees on shifts.employees_id=employees.id
where shifts.station=#{station} and DATE(date) = CURDATE();
</select>
<select id="selectVehicles" resultType="java.util.HashMap">
select vehicle_type vehicleType,vehicle_plate vehiclePlate from dc_vehicles
where vehicle_status=1 and organization_id=#{organizationId}
</select>
</mapper> </mapper>

Loading…
Cancel
Save