Explorar o código

fix 推送学时

he2802 %!s(int64=3) %!d(string=hai) anos
pai
achega
281eca04fa

+ 9 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/grade/ClassStudentController.java

@@ -198,4 +198,13 @@ public class ClassStudentController extends BaseController {
         return toAjax(iClassGradeUserService.updateUserPeriodStatus(bo));
     }
 
+    /**
+     * 学时信息推送
+     */
+    @ApiOperation("学时信息推送")
+    @PreAuthorize("@ss.hasPermi('app:user:edit')")
+    @PostMapping("/pushPeriod")
+    public AjaxResult<Void> pushPeriod(@RequestBody List<ClassGradeUserQueryBo>  list) {
+        return toAjax(Validator.isEmpty(iClassGradeUserService.pushOfficialPeriodMore(list)) ? 1 : 0);
+    }
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/domain/ClassGradeUser.java

@@ -66,5 +66,9 @@ private static final long serialVersionUID=1L;
     private Long officialStatusTime;
     /** 学时推送时间 */
     private Long periodPlushTime;
+    /** 官方信息推送次数 */
+    private Long officialStatusNum;
+    /** 是否学时推送 0未推送 1推送 */
+    private Integer periodPlush;
 }
 

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IClassGradeUserService.java

@@ -49,6 +49,8 @@ public interface IClassGradeUserService extends IService<ClassGradeUser> {
 
 	String pushOfficialPeriod(ClassGradeUserQueryBo bo);
 
+	String pushOfficialPeriodMore(List<ClassGradeUserQueryBo> list);
+
 	List<ClassPeriodStudentExportVo> exportPo(ClassGradeUserQueryBo bo);
 
 	/**

+ 104 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -376,6 +376,11 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         return gradePeriodStatus;
     }
 
+    /**
+     * 信息推送
+     * @param bo
+     * @return
+     */
     @Override
     public String pushOfficialInfo(ClassGradeUserQueryBo bo){
         ClassGradeUserVo userVo = this.baseMapper.selectUser(bo);
@@ -432,6 +437,7 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
              objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusMsg, respone);
              objectLambdaUpdateWrapper.set(ClassGradeUser::getUpdateTime,DateUtils.getNowTime());
              objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusTime,DateUtils.getNowTime());
+             objectLambdaUpdateWrapper.set(ClassGradeUser::getOfficialStatusNum,userVo.getOfficialStatusNum()+1);
              this.update(null, objectLambdaUpdateWrapper);
              return null;
          }else {
@@ -449,6 +455,11 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         }
     }
 
+    /**
+     * 批量信息推送
+     * @param list
+     * @return
+     */
     @Override
     public String pushOfficialInfoMore(List<ClassGradeUserQueryBo> list) {
         int index = 1;
@@ -463,9 +474,101 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         return errorMsg;
     }
 
+    /**
+     * 学时推送
+     * @param bo
+     * @return
+     */
     @Override
     public String pushOfficialPeriod(ClassGradeUserQueryBo bo) {
-        return null;
+        ClassGradeUserVo userVo = this.baseMapper.selectUser(bo);
+        if(Validator.isEmpty(userVo)){
+            return "用户不存在";
+        }
+        if(Validator.isEmpty(userVo.getInterfacePushId())||!userVo.getInterfacePushId().equals(1L)){
+            return "没开通信息推送";
+        }
+        if(Validator.isEmpty(userVo.getOfficialName())){
+            return "没配置班号";
+        }
+        if(Validator.isEmpty(userVo.getClassStatus())||userVo.getClassStatus()!=1){
+            return "未开班";
+        }
+        if(Validator.isNotEmpty(userVo.getClassStartTime())){
+            long nowTime = System.currentTimeMillis()/1000;
+            if(userVo.getClassStartTime().longValue()>nowTime){
+                return "班级有效期未开始";
+            }
+            if(nowTime>userVo.getClassStartTime().longValue()){
+                return "班级有效期已结束";
+            }
+        }
+        OrderGoodsQueryBo goodsQueryBo = new OrderGoodsQueryBo();
+        goodsQueryBo.setUserId(bo.getUserId());
+        goodsQueryBo.setGradeId(userVo.getGradeId());
+        OrderGoodsVo orderGoods = iOrderGoodsService.gradeGoods(goodsQueryBo);
+        if(Validator.isEmpty(orderGoods)){
+            return "班级商品不存在";
+        }
+        Map<String, String> params =  new HashMap<>();
+        params.put("zh",OFFICIALPUSH_INFOACCOUNT);
+        params.put("bh",userVo.getOfficialName());
+        params.put("xm",userVo.getRealName());
+        params.put("sfz",userVo.getIdCard());
+        params.put("ksrq",DateUtils.timestampToDate(orderGoods.getCreateTime()));
+        params.put("jsrq",DateUtils.timestampToDate(userVo.getPeriodTime()));
+        String  dataTxt = params.get("zh")+params.get("bh")+params.get("xm")+params.get("sfz")+params.get("ksrq")+params.get("jsrq");
+        String encrypted = dataSign(dataTxt,OFFICIALPUSH_TOKEN);
+        params.put("SignMsg",encrypted);
+        String respone = "";
+        try{
+            respone = HttpUtils.postFormBody(OFFICIALPUSH_PERIODPATH,params);
+            String[] split = respone.split("\\|");
+            if (split.length < 2) {
+                return "推送接口返回数据错误";
+            }
+            if(split[0].equals("OK")){
+                //推送成功
+                LambdaUpdateWrapper<ClassGradeUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+                objectLambdaUpdateWrapper.eq(ClassGradeUser::getId, userVo.getId());
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodPlush, 1);
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodPlushMsg, respone);
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getUpdateTime,DateUtils.getNowTime());
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodPlushTime,DateUtils.getNowTime());
+                this.update(null, objectLambdaUpdateWrapper);
+                return null;
+            }else {
+                //推送失败
+                LambdaUpdateWrapper<ClassGradeUser> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+                objectLambdaUpdateWrapper.eq(ClassGradeUser::getId, userVo.getId());
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodPlushMsg, respone);
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getUpdateTime,DateUtils.getNowTime());
+                objectLambdaUpdateWrapper.set(ClassGradeUser::getPeriodPlushTime,DateUtils.getNowTime());
+                this.update(null, objectLambdaUpdateWrapper);
+                return respone;
+            }
+        }catch (IOException e){
+            throw new CustomException("请求错误");
+        }
+    }
+
+    /**
+     * 批量学时推送
+     * @param list
+     * @return
+     */
+    @Override
+    public String pushOfficialPeriodMore(List<ClassGradeUserQueryBo> list) {
+        int index = 1;
+        String errorMsg = "";
+        for(ClassGradeUserQueryBo bo : list){
+            String msg = pushOfficialPeriod(bo);
+            if(Validator.isNotEmpty(msg)){
+                errorMsg += "第"+index+"条错误:"+ msg;
+            }
+            index++;
+        }
+        return errorMsg;
     }
 
 

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/vo/ClassGradeUserVo.java

@@ -103,4 +103,14 @@ public class ClassGradeUserVo {
 	@Excel(name = "班级有效期结束时间")
 	@ApiModelProperty("班级有效期结束时间")
 	private Long classEndTime;
+	/** 官方信息推送次数 */
+	@Excel(name = "官方信息推送次数")
+	@ApiModelProperty("官方信息推送次数")
+	private Long officialStatusNum;
+	@ApiModelProperty("学时通过时间")
+	private Long periodTime;
+	/** 是否学时推送 0未推送 1推送 */
+	@Excel(name = "是否学时推送 0未推送 1推送")
+	@ApiModelProperty("是否学时推送 0未推送 1推送")
+	private Integer periodPlush;
 }

+ 6 - 1
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml

@@ -20,6 +20,7 @@
         <result property="periodPlushMsg" column="period_plush_msg"/>
         <result property="officialStatusTime" column="official_status_time"/>
         <result property="periodPlushTime" column="period_plush_time"/>
+        <result property="officialStatusNum" column="official_status_num"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserVo" id="ClassGradeUserVoResult">
@@ -39,6 +40,8 @@
         <result property="officialName" column="official_name"/>
         <result property="classStartTime" column="class_start_time"/>
         <result property="classEndTime" column="class_end_time"/>
+        <result property="officialStatusNum" column="official_status_num"/>
+        <result property="periodTime" column="period_time"/>
     </resultMap>
 
 
@@ -182,7 +185,9 @@
         cg.class_status,
         cg.interface_push_id,
         cg.class_start_time,
-        cg.class_end_time
+        cg.class_end_time,
+        g.official_status_num,
+        g.period_time
         FROM
         class_grade_user g
         LEFT JOIN `user` u ON g.user_id = u.user_id