重写mybatis plus updateById 方法以及嵌套循环

 /**
     * 重写mybatis plus updateById 方法
     * 2021-06-09
     *
     * @param entity
     * @return
     */
    @Override
    @Transactional
    public boolean updateById(EvnConsultationArrange entity) {
        super.updateById(entity);
        if (entity.getArrangeState().equals("2"))//草稿1,进行中2,完成3,进行发送短信操作
        {
            Collection collectionSms = new ArrayList<>();
            String receiverNames = entity.getArrangeReceivernames();//得到短信接收人姓名
            String receiverPhoness = entity.getArrangeReceiverphones();//得到短信接收人手机
            String[] phonesArray = receiverPhoness.split(",");
            String[] namesArray = receiverNames.split(",");
            for (int i = 0; i < namesArray.length; i++) {
                String phone = null;
                for (int j = i; j < phonesArray.length; j++) {
                    phone=phonesArray[j];
                    break;
                }
                String testphone= phonesArray[i];
                String name = namesArray[i];
                SysSms sysSms = new SysSms();
                sysSms.setBusinessId(entity.getId());//业务主键
                sysSms.setMessageContent(entity.getArrangeSmscontent());//短信内容
                sysSms.setMessageReceiver(phone);//接收人电话
                sysSms.setMessageTitle(name);//接收人
                sysSms.setMessageType("0");//未发送
                sysSms.setMessageSender(entity.getCreateName());//发送人
                sysSms.setMessageSendtime(new Date());
                collectionSms.add(sysSms);
            }

        }
        return true;
    }

 

posted @ 2021-06-09 19:12  DarJeely  阅读(888)  评论(0编辑  收藏  举报