消息发送

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】消息发送的更多相关文章

  1. C#开发微信门户及应用(19)-微信企业号的消息发送(文本、图片、文件、语音、视频、图文消息等)

    我们知道,企业号主要是面向企业需求而生的,因此内部消息的交流显得非常重要,而且发送.回复消息数量应该很可观,对于大企业尤其如此,因此可以结合企业号实现内部消息的交流.企业号具有关注安全.消息无限制等特 ...

  2. [UWP]UWP中获取联系人/邮件发送/SMS消息发送操作

    这篇博客将介绍如何在UWP程序中获取联系人/邮件发送/SMS发送的基础操作. 1. 获取联系人 UWP中联系人获取需要引入Windows.ApplicationModel.Contacts名称空间. ...

  3. Kafka、RabbitMQ、RocketMQ消息中间件的对比 —— 消息发送性能-转自阿里中间件

    引言 分布式系统中,我们广泛运用消息中间件进行系统间的数据交换,便于异步解耦.现在开源的消息中间件有很多,前段时间我们自家的产品 RocketMQ (MetaQ的内核) 也顺利开源,得到大家的关注. ...

  4. iOS开发小技巧--即时通讯项目:消息发送框(UITextView)高度的变化; 以及UITextView光标复位的小技巧

    1.即时通讯项目中输入框(UITextView)跟随输入文字的增多,高度变化的实现 最主要的方法就是监听UITextView的文字变化的方法- (void)textViewDidChange:(UIT ...

  5. activemq安装与简单消息发送接收实例

    安装环境:Activemq5.11.1, jdk1.7(activemq5.11.1版本需要jdk升级到1.7),虚拟机: 192.168.147.131 [root@localhost softwa ...

  6. eBay 消息发送(2)

      1.简介 Call Index Doc: http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/index.html   消息发送主要 ...

  7. eBay 消息发送(1)

      1.简介 Call Index Doc: http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/index.html   消息发送主要 ...

  8. twitter storm源码走读之2 -- tuple消息发送场景分析

    欢迎转载,转载请注明出处源自徽沪一郎.本文尝试分析tuple发送时的具体细节,本博的另一篇文章<bolt消息传递路径之源码解读>主要从消息接收方面来阐述问题,两篇文章互为补充. worke ...

  9. ActiveMQ点对点的消息发送案例

    公司最近会用MQ对某些业务进行处理,所以,这次我下载了apache-activemq-5.12.0-bin把玩下. 基于练习方便需要,使用Windows的版本. 参考的优秀文章: activemq的几 ...

  10. 高效的TCP消息发送组件

    目前的.net 架构下缺乏高效的TCP消息发送组件,而这种组件是构建高性能分布式应用所必需的.为此我结合多年的底层开发经验开发了一个.net 下的高效TCP消息发送组件.这个组件在异步发送时可以达到每 ...

随机推荐

  1. .NET8 Blazor新特性 流式渲染

    什么是SSR Blazor中的流式渲染结合了SSR(服务端渲染),服务端将HTML拼好返回给前端,有点像我们熟知的Razor Pages 或 MVC . 当已经有了 Razor Pages 或 MVC ...

  2. Vite 5.0有哪些新变化?

    Rollup 4 Vite 现在使用 Rollup 4,它也带来了一些重大的变化,特别是: 导入断言(assertions 属性)已被重命名为导入属性(attributes 属性). 不再支持 Aco ...

  3. (数据科学学习手札155)基于martin为在线地图构建字体切片服务

    本文示例代码已上传至我的Github仓库https://github.com/CNFeffery/DataScienceStudyNotes 1 简介 大家好我是费老师,在之前的一篇文章(基于mart ...

  4. Calendar日历类型常见方法(必看!!)

    Hi i,m JinXiang 前言 本篇文章主要介绍Calendar日历类型的几种常见方法以及部分理论知识 欢迎点赞  收藏 留言评论 私信必回哟 博主收将持续更新学习记录获,友友们有任何问题可以在 ...

  5. jmeter测试计划中的“独立运行每个线程组”Demo演示

    一:jmeter的运行顺序 测试计划-->线程组 其次执行顺序为:配置元件.前置处理器.定时器.取样器.后置处理器.断言.监听器 当一个测试计划中有多个线程组,当多个线程组都是是执行状态时,就会 ...

  6. win32 API 文件夹操作函数整理

    常用操作文件目录的函数 1. CreateDirectory 创建文件夹 原型: BOOL CreateDirectory( LPCTSTR lpPathName, LPSECURITY_ATTRIB ...

  7. 文心一言 VS 讯飞星火 VS chatgpt (164)-- 算法导论13.1 4题

    四.用go语言,假设将一棵红黑树的每一个红结点"吸收"到它的黑色父结点中,使得红结点的子结点变成黑色父结点的子结点(忽略关键字的变化).当一个黑结点的所有红色子结点都被吸收后,它可 ...

  8. python异步编程之asyncio初识

    async await介绍 用asyncio提供的@asyncio.coroutine可以把一个生成器标记为协程类型,然后在协程内部用yield from 等待IO操作,让出cpu执行权. 然而异步的 ...

  9. Windows和Linux下通过go实现自删除

    自删除在攻防中都挺常见的,自写远控通常也有需要.可是在度娘里搜不到什么办法,于是就查查Windows api学习记录一回. linux 先获得当前程序的文件名,再使用syscall这个包中的Unlin ...

  10. 2023-07-07:给出两个字符串 str1 和 str2。 返回同时以 str1 和 str2 作为子序列的最短字符串。 如果答案不止一个,则可以返回满足条件的任意一个答案。 输入:str1 =

    2023-07-07:给出两个字符串 str1 和 str2. 返回同时以 str1 和 str2 作为子序列的最短字符串. 如果答案不止一个,则可以返回满足条件的任意一个答案. 输入:str1 = ...