【HZERO】消息发送
消息发送
https://open.hand-china.com/community/detail/625843016338378752
新建模板
@Override
public String shipmentRelay(ShipmentRelayDTO dto) {
IfpShipment ifpShipment = ifpShipmentService.selectByPrimaryKey(dto.getShipmentGidOld());
//插入接力运单信息
IfpShipment newIfpShipment = new IfpShipment();
BeanUtils.copyProperties(ifpShipment, newIfpShipment, "id", "xid", "objectVersionNumber", "createdBy", "creationDate", "lastUpdatedBy", "lastUpdateDate", "vehicleGid", "driverGid", "loadDate", "loadWeight", "loadVolume", "loadItemCount", "unloadDate", "unloadWeight", "unloadVolume", "unloadItemCount", "loadAttachmentFile", "unloadAttachmentFile");
newIfpShipment.setDriverGid(dto.getDriverIdNew());
newIfpShipment.setVehicleGid(dto.getVehicleIdNew());
String newXid = ifpShipment.getXid() + "-1";
newIfpShipment.setXid(newXid);
newIfpShipment.setShipmentGidOld(dto.getShipmentGidOld());
newIfpShipment.setShipmentStatus("TO_CONFIRM_RELAY");
newIfpShipment.setSettleDriverGid(dto.getDriverIdNew());
if (null != dto.getTrailGid()) {
newIfpShipment.setTrailGid(dto.getTrailGid());
}
try {
newIfpShipment.setLoadAttachmentFile(JSONObject.parseObject(fileRemoteService.getAttachUUID(0L).getBody()).getString("content"));
newIfpShipment.setUnloadAttachmentFile(JSONObject.parseObject(fileRemoteService.getAttachUUID(0L).getBody()).getString("content"));
newIfpShipment.setSignAttachmentFile(JSONObject.parseObject(fileRemoteService.getAttachUUID(0L).getBody()).getString("content"));
newIfpShipment.setCostExplanationFile(JSONObject.parseObject(fileRemoteService.getAttachUUID(0L).getBody()).getString("content"));
}catch (Exception ignore){}
ifpShipmentService.insertSelective(newIfpShipment);
//生成新运单后要生成新的单次托运合同的承运合同的逻辑,单次托运合同是自动落章的,单次承运合同司机还要签章
//生成待装货运单,生成单次承运合同和单次托运合同
this.contractService.createFreightSignContract(ifpShipment.getTenantId(), dto.getDriverIdNew(), newIfpShipment.getId());
this.contractService.createShipperSingleContract(ifpShipment.getTenantId(), ifpShipment.getShipperCompanyId(), dto.getDriverIdNew(), newIfpShipment.getId());
//更新原运单接力运单id信息
ifpShipment.setShipmentGidNew(newIfpShipment.getId());
ifpShipment.setShipmentStatus("ALL_RELAY");
ifpShipmentService.updateByPrimaryKeySelective(ifpShipment);
//更新异常表相应的运单、司机、车辆信息
IfpExpection tempIfpExpection = new IfpExpection();
tempIfpExpection.setShipmentGidOld(dto.getShipmentGidOld());
IfpExpection ifpExpection = ifpExpectionService.selectOne(tempIfpExpection);
ifpExpection.setShipmentXidOld(ifpShipment.getXid());
ifpExpection.setShipmentGidNew(newIfpShipment.getId());
ifpExpection.setShipmentXidNew(newIfpShipment.getXid());
IfpDriver ifpDriver = ifpDriverService.selectByPrimaryKey(dto.getDriverIdNew());
ifpExpection.setDriverGidNew(dto.getDriverIdNew());
ifpExpection.setDriverNameNew(ifpDriver.getName());
ifpExpection.setDriverPhoneNew(ifpDriver.getPhone());
IfpVehicle ifpVehicle = iIfpVehicleService.selectByPrimaryKey(dto.getVehicleIdNew());
ifpExpection.setVehicleIdNew(dto.getVehicleIdNew());
ifpExpection.setIpnNew(ifpVehicle.getLpn());
ifpExpectionService.updateByPrimaryKey(ifpExpection);
return null;
}
根据角色发送消息
@PostMapping({"/bindVehicleAndDriverRelation"})
public ResponseEntity<?> bindVehicleAndDriverRelation(@PathVariable Long organizationId, @RequestBody IfpVehicle ifpVehicle,Long driverId) {
try {
//绑定重复性校验
IfpDriverVehicleRelation relation = new IfpDriverVehicleRelation();
relation.setDriverGid(driverId);
relation.setVehicleLpn(ifpVehicle.getLpn());
List<IfpDriverVehicleRelation> relations = this.ifpDriverVehicleRelationService.selectOptional(relation,null);
if (relations != null && relations.size()>0) {
return Results.success(new HtmsResult(false, "车辆不允许重复提交"));
}
IfpVehicle vehicle = new IfpVehicle();
vehicle.setLpn(ifpVehicle.getLpn());
List<IfpVehicle> ifpVehicleList = this.ifpVehicleService.select(vehicle);
if (ifpVehicleList == null || ifpVehicleList.size() == 0) {
ifpVehicle.setTenantId(organizationId);
//道路运输证号(为空时不校验)不能与车辆表的其他数据重复
if (null != ifpVehicle.getTransportLicenseNo()){
IfpVehicle TransportCheck = new IfpVehicle();
TransportCheck.setTransportLicenseNo(ifpVehicle.getTransportLicenseNo());
TransportCheck.setVehicleStatus("APPROVED");
List<IfpVehicle> TransportCheckList = this.ifpVehicleService.selectOptional(TransportCheck,new Criteria(TransportCheck));
if (null == ifpVehicle.getId()){
if (TransportCheckList.size() > 0){
return Results.success(new HtmsResult(false, "该道路运输证号已被使用"));
}
} else {
if (TransportCheckList.size() > 1 ){
return Results.success(new HtmsResult(false, "该道路运输证号已被使用"));
}
if (TransportCheckList.size() ==1 && !TransportCheckList.get(0).getId().equals(ifpVehicle.getId()) ) {
return Results.success(new HtmsResult(false, "该道路运输证号已被使用"));
}
}
}
// 默认'PENDING'
ifpVehicle.setVehicleStatus("PENDING");
ifpVehicle.setSubmitDate(new Date(System.currentTimeMillis()));
this.ifpVehicleService.insert(ifpVehicle);
List<IfpVehicle> vehicleList = new ArrayList<>();
vehicleList.add(ifpVehicle);
sinoiovService.pushVehicle(vehicleList);
insertDriverVerhicleRelation(organizationId, ifpVehicle, driverId);
this.commonService.sendWebMessageByRole("IFP.VEHICLE_AUDIT_TODO","injayunw", ifpVehicle.getLpn());
return Results.success(new HtmsResult(true, "提交成功,请耐心等待审核!"));
}
if (ifpVehicleList.size()>1) {
return Results.error(new HtmsResult(false, "车辆"+ifpVehicle.getLpn()+"存在重复数据!"));
}
if (ifpVehicleList.size()==1) {
IfpVehicle ifpVehicle1 = ifpVehicleList.get(0);
insertDriverVerhicleRelation(organizationId, ifpVehicle1, driverId);
if ("NEW,REJECTED,LAPSE".indexOf(ifpVehicle1.getVehicleStatus())>-1){
ifpVehicle.setSubmitDate(new Date(System.currentTimeMillis()));
ifpVehicle.setAuditPersonId(null);
ifpVehicle.setAuditDate(null);
ifpVehicle.setRejectReason(null);
ifpVehicle1.setVehicleStatus("PENDING");
this.ifpVehicleService.updateOptional(ifpVehicle1);
this.commonService.sendWebMessageByRole("IFP.VEHICLE_AUDIT_TODO","injayunw", ifpVehicle1.getLpn());
return Results.success(new HtmsResult(true, "提交成功,请耐心等待审核!"));
}else{
return Results.success(new HtmsResult(true, "添加成功"));
}
}
OperationRecord operationRecord = OperationRecord.newInstance(organizationId, ifpVehicle.getId(), ifpVehicle.getXid(), "IfpDriver", null, "移动端-司机-新建车辆与司机关系:" + ifpVehicle.getName());
this.operationRecordService.insertUseExecutor(operationRecord);
} catch (Exception var4) {
var4.printStackTrace();
return Results.success(new HtmsResult(false, var4.getMessage()));
}
return Results.success(new HtmsResult(true, "添加成功"));
}
/**
* 根据角色代码及消息模版发送站内消息
* @param roleCode 角色代码
* @return 用户列表
*/
void sendWebMessageByRole(String templateCode, String roleCode, String content);
public void sendWebMessageByRole(String templateCode, String roleCode, String content) {
try {
Map<String, String> args = new HashMap<>();
args.put("content", content);
List<User> userList = this.getRoleUserList(roleCode);
List<Receiver> receiverList = new ArrayList<>();
for(User user : userList){
receiverList.add(new Receiver().setUserId(user.getId()).setTargetUserTenantId(1L));
}
this.messageClient.async().sendWebMessage(1L, templateCode, receiverList, args);
}catch (Exception e){
e.printStackTrace();
}
}
public List<User> getRoleUserList(String roleCode) {
try {
User queryUser = new User();
Criteria criteria = new Criteria(queryUser);
criteria.select("id", "organizationId");
criteria.setWhereSql("EXISTS (SELECT 1 FROM HZERO_PLATFORM.IAM_ROLE RL, HZERO_PLATFORM.IAM_MEMBER_ROLE MRL WHERE RL.CODE = '" + roleCode + "' AND RL.ID = MRL.ROLE_ID AND MRL.MEMBER_ID = A.ID)");
return userMapper.selectOptional(queryUser, criteria);
}catch (Exception e){
e.printStackTrace();
return new ArrayList<>();
}
}
/*
* 发送站内信通知
*/
Map<String, String> args = new HashMap<>();
args.put("name", companyApplication.getName());
args.put("rejectReason", rejectReason);
String lang = "zh_CN";
messageClient.async().sendWebMessage(DetailsHelper.getUserDetails().getTenantId(), "NF.OWNER_AUTH_FAILED", lang, Collections.singletonList(new Receiver().setUserId(DetailsHelper.getUserDetails().getUserId()).setTargetUserTenantId(DetailsHelper.getUserDetails().getTenantId())), args);
messageClient.async().sendSms(DetailsHelper.getUserDetails().getTenantId(), "HZERO", "NF.OWNER_AUTH_FAILED", lang, Collections.singletonList(new Receiver().setPhone(companyApplication.getPhone())), args);
【HZERO】消息发送的更多相关文章
- C#开发微信门户及应用(19)-微信企业号的消息发送(文本、图片、文件、语音、视频、图文消息等)
我们知道,企业号主要是面向企业需求而生的,因此内部消息的交流显得非常重要,而且发送.回复消息数量应该很可观,对于大企业尤其如此,因此可以结合企业号实现内部消息的交流.企业号具有关注安全.消息无限制等特 ...
- [UWP]UWP中获取联系人/邮件发送/SMS消息发送操作
这篇博客将介绍如何在UWP程序中获取联系人/邮件发送/SMS发送的基础操作. 1. 获取联系人 UWP中联系人获取需要引入Windows.ApplicationModel.Contacts名称空间. ...
- Kafka、RabbitMQ、RocketMQ消息中间件的对比 —— 消息发送性能-转自阿里中间件
引言 分布式系统中,我们广泛运用消息中间件进行系统间的数据交换,便于异步解耦.现在开源的消息中间件有很多,前段时间我们自家的产品 RocketMQ (MetaQ的内核) 也顺利开源,得到大家的关注. ...
- iOS开发小技巧--即时通讯项目:消息发送框(UITextView)高度的变化; 以及UITextView光标复位的小技巧
1.即时通讯项目中输入框(UITextView)跟随输入文字的增多,高度变化的实现 最主要的方法就是监听UITextView的文字变化的方法- (void)textViewDidChange:(UIT ...
- activemq安装与简单消息发送接收实例
安装环境:Activemq5.11.1, jdk1.7(activemq5.11.1版本需要jdk升级到1.7),虚拟机: 192.168.147.131 [root@localhost softwa ...
- eBay 消息发送(2)
1.简介 Call Index Doc: http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/index.html 消息发送主要 ...
- eBay 消息发送(1)
1.简介 Call Index Doc: http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/index.html 消息发送主要 ...
- twitter storm源码走读之2 -- tuple消息发送场景分析
欢迎转载,转载请注明出处源自徽沪一郎.本文尝试分析tuple发送时的具体细节,本博的另一篇文章<bolt消息传递路径之源码解读>主要从消息接收方面来阐述问题,两篇文章互为补充. worke ...
- ActiveMQ点对点的消息发送案例
公司最近会用MQ对某些业务进行处理,所以,这次我下载了apache-activemq-5.12.0-bin把玩下. 基于练习方便需要,使用Windows的版本. 参考的优秀文章: activemq的几 ...
- 高效的TCP消息发送组件
目前的.net 架构下缺乏高效的TCP消息发送组件,而这种组件是构建高性能分布式应用所必需的.为此我结合多年的底层开发经验开发了一个.net 下的高效TCP消息发送组件.这个组件在异步发送时可以达到每 ...
随机推荐
- 确定性有限状态自动机 DFA
前言 在计算理论中,确定有限状态自动机或确定有限自动机(英语:deterministic finite automaton, DFA)是一个能实现状态转移的自动机.对于一个给定的属于该自动机的状态和一 ...
- Windows Terminal 简单美化
需要用到的软件/插件 oh-my-posh posh-git PSReadLine 安装 oh-my-posh oh-my-posh 是 shell 主题引擎,使用 winget 来安装 oh-my- ...
- Android 输入系统介绍
目录 一.目的 二.环境 三.相关概念 3.1 输入设备 3.2 UEVENT机制 3.3 JNI 3.4 EPOLL机制 3.5 INotify 四.详细设计 4.1 结构图 4.2 代码结构 4. ...
- 有一种浪漫,叫接触Linux
大家好,我是五月. 嵌入式开发 嵌入式开发产品必须依赖硬件和软件. 硬件一般使用51单片机,STM32.ARM,做成的产品以平板,手机,智能机器人,智能小车居多. 软件用的当然是以linux系统为蓝 ...
- 洛谷P2757 [国家集训队]等差子序列 (hash+线段树)
题目连接 这题只要令 $len=3$看是否符合即可.因为是一个 $1$到 $n$的排列,考虑数列中项,那么对于一个数 $x$,令 $k=\max(n-x, x-1)$,只要存在 $d\in(1,k)$ ...
- python中的post请求
用python来验证接口正确性,主要流程有4步: 1 设置url 2 设置消息头 3 设置消息体 4 获取响应 5 解析相应 6 验证数据 Content-Type的格式有四种:分别是applicat ...
- STM32外设:通用输入输出 GPIO、EXIT
主要外设: GPIO:General Purpose I/O 一般用途IO EXIT:External Interrupt/Event Controller 外部中断/事件控制器(STM32) 辅助外 ...
- 虚拟机运行Hadoop | 各种问题解决的心路历程
ps:完成大数据技术实验报告的过程,出项各种稀奇古怪的问题.(知道这叫什么吗?经济基础决定上层建筑,我当时配置可能留下了一堆隐患,总之如果有同样的问题,希望可以帮到你) 一.虚拟机网络连接不通的各种情 ...
- vue-test4 -------组件之间的数据传递
<template> <h3>CompA</h3> <component-b :onfun="dateFun"></compo ...
- Educational Codeforces Round 26 Problem C
C. Two Seals time limit per test 1 second memory limit per test 256 megabytes input standard input o ...