java110
2022-01-17 d937205d5824dc44ab1567cf6f84fbfa817baa92
service-job/src/main/java/com/java110/job/adapt/roomRenovation/MachineSaveRoomRenovation.java
@@ -21,18 +21,23 @@
import com.java110.intf.order.IPrivilegeInnerServiceSMO;
import com.java110.intf.store.ISmallWeChatInnerServiceSMO;
import com.java110.intf.store.ISmallWechatAttrInnerServiceSMO;
import com.java110.intf.store.IStoreInnerServiceSMO;
import com.java110.intf.user.*;
import com.java110.job.adapt.DatabusAdaptImpl;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.util.Assert;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
@@ -80,12 +85,28 @@
    private static String sendMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
    @Override
    public void execute(Business business, List<Business> businesses) {
    public void execute(Business business, List<Business> businesses) throws ParseException {
        JSONObject data = business.getData();
        //获取开始时间
        String beginTime = data.getString("startTime") + " 00:00:00";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date timeOne = format.parse(beginTime);
        Calendar now = Calendar.getInstance();
        String newTime = now.get(Calendar.YEAR) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DAY_OF_MONTH) + " 00:00:00";
        Date timeTwo = format.parse(newTime);
        if (timeOne.getTime() < timeTwo.getTime()) {
            logger.info("装修时间不能小于当前时间!");
            return;
        }
        //查询小区信息
        CommunityDto communityDto = new CommunityDto();
        communityDto.setCommunityId(data.getString("communityId"));
        List<CommunityDto> communityDtos = communityInnerServiceSMO.queryCommunitys(communityDto);
        //查询房屋业主信息
        OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
        ownerRoomRelDto.setRoomId(data.getString("roomId"));
        List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelInnerServiceSMO.queryOwnerRoomRels(ownerRoomRelDto);
        Assert.listOnlyOne(ownerRoomRelDtos, "查询房屋业主错误!");
        //申请人姓名
        String personName = data.getString("personName");
        //申请联系电话
@@ -100,8 +121,6 @@
        String endTime = data.getString("endTime");
        //备注
        String remark = data.getString("remark");
        //获取当前用户id
        String userId = data.getString("userId");
        JSONObject paramIn = new JSONObject();
        paramIn.put("personName", personName);
        paramIn.put("personTel", personTel);
@@ -110,7 +129,7 @@
        paramIn.put("startTime", startTime);
        paramIn.put("endTime", endTime);
        paramIn.put("remark", remark);
        paramIn.put("userId", userId);
        paramIn.put("userId", ownerRoomRelDtos.get(0).getOwnerId());
        //给员工推送消息
        publishMsg(paramIn, communityDtos.get(0));
        //给业主推送信息
@@ -163,24 +182,29 @@
                staffAppAuthDto.setStaffId(userDto.getUserId());
                staffAppAuthDto.setAppType("WECHAT");
                List<StaffAppAuthDto> staffAppAuthDtos = staffAppAuthInnerServiceSMO.queryStaffAppAuths(staffAppAuthDto);
                String openId = staffAppAuthDtos.get(0).getOpenId();
                Data data = new Data();
                PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
                templateMessage.setTemplate_id(templateId);
                templateMessage.setTouser(openId);
                data.setFirst(new Content("尊敬的管理员,您好!有新的装修申请需要您处理,申请信息如下:"));
                data.setKeyword1(new Content(paramIn.getString("personName") + "-" + paramIn.getString("personTel")));
                data.setKeyword2(new Content(communityDto.getName() + roomName[0] + "栋" + roomName[1] + "单元" + roomName[2] + "室"));
                data.setKeyword3(new Content(paramIn.getString("startTime") + "至" + paramIn.getString("endTime")));
                data.setKeyword4(new Content(paramIn.getString("remark")));
                data.setKeyword5(new Content("待审核"));
                data.setRemark(new Content("感谢您的使用。"));
                templateMessage.setData(data);
                String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL");
                templateMessage.setUrl(wechatUrl);
                logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
                ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
                logger.info("微信模板返回内容:{}", responseEntity);
                if (staffAppAuthDtos != null && staffAppAuthDtos.size() > 0) {
                    String openId = staffAppAuthDtos.get(0).getOpenId();
                    Data data = new Data();
                    PropertyFeeTemplateMessage templateMessage = new PropertyFeeTemplateMessage();
                    templateMessage.setTemplate_id(templateId);
                    templateMessage.setTouser(openId);
                    data.setFirst(new Content("尊敬的管理员,您好!有新的装修申请需要您处理,申请信息如下:"));
                    data.setKeyword1(new Content(paramIn.getString("personName") + "-" + paramIn.getString("personTel")));
                    data.setKeyword2(new Content(communityDto.getName() + roomName[0] + "栋" + roomName[1] + "单元" + roomName[2] + "室"));
                    data.setKeyword3(new Content(paramIn.getString("startTime") + "至" + paramIn.getString("endTime")));
                    data.setKeyword4(new Content(paramIn.getString("remark")));
                    data.setKeyword5(new Content("待审核"));
                    data.setRemark(new Content("感谢您的使用。"));
                    templateMessage.setData(data);
                    //获取员工公众号地址
                    String wechatUrl = MappingCache.getValue("STAFF_WECHAT_URL");
                    templateMessage.setUrl(wechatUrl);
                    logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));
                    ResponseEntity<String> responseEntity = outRestTemplate.postForEntity(url, JSON.toJSONString(templateMessage), String.class);
                    logger.info("微信模板返回内容:{}", responseEntity);
                } else {
                    continue;
                }
            }
        }
    }
@@ -270,6 +294,7 @@
            data.setKeyword4(new Content(paramIn.getString("startTime") + "至" + paramIn.getString("endTime")));
            data.setRemark(new Content("物业联系电话:" + tel + ",请到物业管理处或通过手机缴纳装修押金!"));
            templateMessage.setData(data);
            //获取业主公众号地址
            String wechatUrl = MappingCache.getValue("OWNER_WECHAT_URL");
            templateMessage.setUrl(wechatUrl);
            logger.info("发送模板消息内容:{}", JSON.toJSONString(templateMessage));