Browse Source

待审批列表审批信息修正,修正下发没有微信ID

baihe 3 years ago
parent
commit
d74855964f

+ 11 - 12
application-facade/src/main/java/com/factory/wx/service/impl/WxServiceImpl.java

@@ -175,21 +175,20 @@ public class WxServiceImpl implements WxService {
         Set<String> openIdSet = new HashSet<>();
 		for(Long userId:list) {
 			try {
-				String openId = wxMapper
-						.selectOne(Wrappers.<UsUserWechat>lambdaQuery().eq(UsUserWechat::getUserId, userId))
-						.getOpenid();
-				if(!openIdSet.add(openId)) {
-					log.warn("下发微信消息,接收人userId:{}的openId重复",sendMsgReq.getToUserId());
+				UsUserWechat uUsUserWechat = wxMapper
+						.selectOne(Wrappers.<UsUserWechat>lambdaQuery().eq(UsUserWechat::getUserId, userId));
+				if(uUsUserWechat==null||uUsUserWechat.getOpenid()==null) {
+					log.warn("下发微信消息,接收人userId:{}的openId为空", sendMsgReq.getToUserId());
 					continue;
 				}
-				if (null != openId && !openId.isEmpty()) {
-					AppEntry appEntry = AppEntry.builder().appId(appid).secret(appsecret).build();
-					TemplateEntry tpl = TemplateEntry.builder().template_id(templateId).touser(openId).page(page)
-							.miniprogram_state(miniprogramState).data(dataMap).build();
-					PushWxMessage.sendMessage(appEntry, tpl);
-				} else {
-					log.error("下发微信消息,接收人userId:{}的openId为空", sendMsgReq.getToUserId());
+				if(!openIdSet.add(uUsUserWechat.getOpenid())) {
+					log.warn("下发微信消息,接收人userId:{}的openId重复",sendMsgReq.getToUserId());
+					continue;
 				}
+				AppEntry appEntry = AppEntry.builder().appId(appid).secret(appsecret).build();
+				TemplateEntry tpl = TemplateEntry.builder().template_id(templateId).touser(uUsUserWechat.getOpenid()).page(page)
+						.miniprogram_state(miniprogramState).data(dataMap).build();
+				PushWxMessage.sendMessage(appEntry, tpl);
 			} catch (Exception e) {
 				 log.error("下发微信消息异常",e);
 			}

+ 9 - 17
application-facade/src/main/resources/mapper/PreventMistakeMapper.xml

@@ -337,27 +337,19 @@
      -->
 
     <!--取得审批人 如果是待生产审核  则显示质量经理的审核信息-->
-    <select id="getLatestApprovalInfo" resultType="com.factory.web.entity.pm.OnsiteApprovalPlan"><![CDATA[
+    <select id="getLatestApprovalInfo" resultType="com.factory.web.entity.pm.OnsiteApprovalPlan">
+    <![CDATA[
         SELECT oap.benteler_plan_id bentelerPlanId,
                oap.approval_level approvalLevel,
                oap.`status`,
-               a.approval_user_id approvalUserId,
-               a.reason,
-               a.updated_time,
+               oap.approval_user_id approvalUserId,
+               oap.reason,
+               oap.updated_time updateTime,
                uu.username as approvalPerson
-        FROM onsite_approval_plan oap,
-             (
-                 SELECT oap.*
-                 FROM onsite_approval_plan oap
-                 WHERE oap.benteler_plan_id = #{req.bentelerPlanId}
-                 order by oap.status desc, oap.approval_level desc
-                 limit 1
-             ) a,
-             us_user uu
-        WHERE oap.benteler_plan_id = a.benteler_plan_id
-          and uu.id = a.approval_user_id
-          AND oap.benteler_plan_id = #{req.bentelerPlanId}
-        order by approval_level desc
+        FROM onsite_approval_plan oap
+             left join us_user uu on uu.id = oap.approval_user_id
+        WHERE oap.benteler_plan_id = #{req.bentelerPlanId}
+        order by oap.status desc, oap.approval_level desc
         limit 1
         ]]></select>