【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消息发送组件.这个组件在异步发送时可以达到每 ...
随机推荐
- L2-040 哲哲打游戏
这题读懂题目之后就发现它很呆 #include <bits/stdc++.h> using namespace std; const int N = 100010, M = 110; ve ...
- python列表之索引及len()函数
我们在刚开始使用列表的时候,经常会遇到这种错误 list_1 = ['one', 'two', 'three', 'four', 'five'] print(list_1[5]) 这段代码看上去是没有 ...
- vertx的学习总结7之用kotlin 与vertx搞一个简单的http
这里我就简单的聊几句,如何用vertx web来搞一个web项目的 1.首先先引入几个依赖,这里我就用maven了,这个是kotlin+vertx web <?xml version=" ...
- Linux笔记03: Linux常用命令_3.2目录操作命令
3.2 目录操作命令 3.2.1 ls命令 ●命令名称:ls. ●英文原意:list directory contents. ●所在路径:/usr/bin/ls. ●执行权限:所有用户. ●功能描述: ...
- 为啥不建议用BeanUtils.copyProperties拷贝数据
在实际的业务开发中,我们经常会碰到VO.BO.PO.DTO等对象属性之间的赋值,当属性较多的时候我们使用get,set的方式进行赋值的工作量相对较大,因此很多人会选择使用spring提供的拷贝工具Be ...
- MySQL 数据目录
MySQL 的数据目录 1. MySQL 的主要目录结构 方式1:通过命令搜索 find / -name mysql 方式2(推荐):通过查看配置文件获取目录结构 vim /etc/my.cnf (重 ...
- Java反射,看完就会用
什么是反射 在说反射概念之前,我们先说另外2个概念:编译期和运行期. 编译期: 编译期是源代码从文本形式转换为字节码的过程,这发生在Java代码被JVM执行之前. 在编译期,编译器对源代码进行语法检查 ...
- Codeforce Round 916(div3)
Codeforces Round 916(div3) [Problem - A - Codeforces]:Problemsolving Log A.题 直接看样例进行分析,发现每一次出现的字符代表着 ...
- Python——第二章:字典(dictionary)以及 添、删、改、查
首先, 字典是以键值对的形式进行存储数据的,必须有键[key],有值[value] 字典的表示方式: {key:value, key2:value, key3:value} 举例: dic = {&q ...
- Harbor私有镜像仓库搭建
为什么选择Harbor 你可能会问既然我们已经有了 Docker 镜像仓库为什么还需要 Harbor 呢?嗯,Harbor 是 Docker 镜像仓库的企业级扩展,用途更广泛.这些新的企业级功能包括: ...