Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 3 mesiacov pred
rodič
commit
982898e7e6

+ 6 - 2
src/main/java/com/xjrsoft/module/databoard/controller/DataboardController.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.databoard.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -469,6 +470,9 @@ public class DataboardController {
     @ApiOperation(value="个人考勤")
     @SaCheckPermission("databoard:detail")
     public RT<AttendanceStatisticsVo> attendanceStatistics(@Valid StatisticsDetailDto dto){
+        if(dto.getUserId() == null){
+            dto.setUserId(StpUtil.getLoginIdAsLong());
+        }
         LocalDateTime startTime = null;
         LocalDateTime endTime = null;
         if(dto.getStartDate() != null){
@@ -519,7 +523,7 @@ public class DataboardController {
             sql +=" AND t1.adjust_date between '" + startTime.format(formatter) + "' and '" + endTime.format(formatter) + "'";
         }
         if(dto.getUserId() != null){
-            sql += " and t1.user_id = " + dto.getUserId();
+            sql += " and (t1.user_id = " + dto.getUserId() + " or t1.exchange_teacher_id = '" + dto.getUserId() + "')";
         }
         list = SqlRunnerAdapter.db().selectList(sql);
         result.setAdjustCount(Integer.parseInt(list.get(0).get("a_count").toString()));
@@ -532,7 +536,7 @@ public class DataboardController {
             sql +=" AND t1.adjust_date between '" + startTime.format(formatter) + "' and '" + endTime.format(formatter) + "'";
         }
         if(dto.getUserId() != null){
-            sql += " t1.and user_id = " + dto.getUserId();
+            sql += " and t1.user_id = " + dto.getUserId();
         }
         list = SqlRunnerAdapter.db().selectList(sql);
         result.setExchangeCount(Integer.parseInt(list.get(0).get("a_count").toString()));

+ 1 - 1
src/main/java/com/xjrsoft/module/liteflow/node/WfRoomApplicantNode.java

@@ -108,7 +108,7 @@ public class WfRoomApplicantNode extends NodeComponent {
                         } catch (InterruptedException e) {
                             throw new RuntimeException(e);
                         }
-                        wfRoomApplicantService.noticeParents(formId);
+                        //wfRoomApplicantService.noticeParents(formId);
                     });
                 }
             });

+ 80 - 0
src/main/java/com/xjrsoft/module/liteflow/node/WfRoomStayOvernightNode.java

@@ -0,0 +1,80 @@
+package com.xjrsoft.module.liteflow.node;
+
+import cn.hutool.core.convert.Convert;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.xjrsoft.common.enums.WorkflowApproveType;
+import com.xjrsoft.module.room.service.IWfRoomStayOvernightService;
+import com.xjrsoft.module.workflow.entity.WorkflowRecord;
+import com.xjrsoft.module.workflow.mapper.WorkflowRecordMapper;
+import com.xjrsoft.module.workflow.service.IWorkflowExecuteService;
+import com.yomahub.liteflow.core.NodeComponent;
+import org.apache.commons.lang.StringUtils;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * 学生住宿申请后,修改学籍信息中的就读方式
+ */
+@Component("wf_room_stay_overnight_node")
+public class WfRoomStayOvernightNode extends NodeComponent {
+    @Autowired
+    private IWfRoomStayOvernightService wfRoomStayOvernightService;
+    @Autowired
+    private IWorkflowExecuteService workflowExecuteService;
+    @Autowired
+    private WorkflowRecordMapper workflowRecordMapper;
+
+    @Override
+    public void process() throws Exception {
+        // 获取表单中数据编号
+        Map<String, Object> params = this.getFirstContextBean();
+        Object value = util.getFormDatKey(params,"id");
+        Long formId = Convert.toLong(value);
+        Object processInstanceId = params.get("processInstanceId");
+        if (processInstanceId == null) {
+            return;
+        }
+        String processInstanceIdStr = Convert.toStr(processInstanceId);
+        if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
+            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+                @Override
+                public void afterCommit() {
+                    CompletableFuture.runAsync(() -> {
+                        Optional<HistoricProcessInstance> historicProcessInstanceOptional = workflowExecuteService.getHistoricProcessInstance(processInstanceId.toString());
+
+                        if (historicProcessInstanceOptional.isEmpty()) {
+                            return;
+                        }
+                        HistoricProcessInstance historicProcessInstance = historicProcessInstanceOptional.get();
+                        if (!historicProcessInstance.getState().equals(HistoricProcessInstance.STATE_ACTIVE)) {
+                            // 获取流程记录中的非正常结束
+                            LambdaQueryWrapper<WorkflowRecord> workflowRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                            workflowRecordLambdaQueryWrapper
+                                    .and(wq -> wq.eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.DISAGREE.getCode())
+                                            .or()
+                                            .eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.WITHDRAW.getCode())
+                                    )
+                                    .eq(WorkflowRecord::getProcessId, processInstanceId)
+                            ;
+                            List<WorkflowRecord> workflowRecordList = workflowRecordMapper.selectList(workflowRecordLambdaQueryWrapper);
+
+                            if (!workflowRecordList.isEmpty()) {
+                                return;
+                            }
+                        }
+                        //查询出数据
+                        wfRoomStayOvernightService.noticeParents(formId);
+                    });
+                }
+            });
+        }
+    }
+}

+ 15 - 11
src/main/java/com/xjrsoft/module/personnel/service/impl/BasePersonnelLabourCapitalServiceImpl.java

@@ -1,11 +1,11 @@
 package com.xjrsoft.module.personnel.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.personnel.dto.BasePersonnelLabourCapitalMonthPageDto;
@@ -23,9 +23,8 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
@@ -50,15 +49,15 @@ public class BasePersonnelLabourCapitalServiceImpl extends MPJBaseServiceImpl<Ba
         User user = userService.getById(userId);
         dto.setJobNumber(user.getUserName());
         Page<BasePersonnelLabourCapitalMonthPageVo> resultPage = labourCapitalMapper.getMonthPage(page, dto);
-
+        JsonParser parser = new JsonParser();
         for (BasePersonnelLabourCapitalMonthPageVo record : resultPage.getRecords()) {
-            JSONObject extendJsonObj = JSON.parseObject(record.getPendingJson());
-            Map<String, Object> newDict = new HashMap<>();
+            JsonObject extendJsonObj = parser.parse(record.getPendingJson()).getAsJsonObject();
+            LinkedHashMap<String, Object> newDict = new LinkedHashMap<>();
 
             for (String key : extendJsonObj.keySet()) {
-                String bpName = getBpName(key);
+                String bpName = getBpName(record.getLabourCapitalId(), key);
                 if (bpName != null) {
-                    newDict.put(bpName, extendJsonObj.getString(key));
+                    newDict.put(bpName, extendJsonObj.get(key).isJsonNull()?"-":extendJsonObj.get(key).getAsString());
                 }
             }
 
@@ -76,8 +75,13 @@ public class BasePersonnelLabourCapitalServiceImpl extends MPJBaseServiceImpl<Ba
         return labourCapitalMapper.getYearPage(page, dto);
     }
 
-    private String getBpName(String columnNumber) {
-        List<BasePersonnelLabourCapitalTitle> bpTitles = capitalTitleMapper.selectList(Wrappers.<BasePersonnelLabourCapitalTitle>lambdaQuery().eq(BasePersonnelLabourCapitalTitle::getColumnNumber, columnNumber));
+    private String getBpName(Long labourCapitalId, String columnNumber) {
+        List<BasePersonnelLabourCapitalTitle> bpTitles = capitalTitleMapper.selectList(
+                Wrappers.<BasePersonnelLabourCapitalTitle>lambdaQuery()
+                        .eq(BasePersonnelLabourCapitalTitle::getColumnNumber, columnNumber)
+                        .eq(BasePersonnelLabourCapitalTitle::getLabourCapitalId, labourCapitalId)
+                        .orderByDesc(BasePersonnelLabourCapitalTitle::getRowsNumber)
+        );
         if (bpTitles != null && !bpTitles.isEmpty()) {
             return bpTitles.get(0).getName();
         } else {

+ 5 - 1
src/main/java/com/xjrsoft/module/personnel/vo/BasePersonnelLabourCapitalMonthPageVo.java

@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ContentStyle;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -43,7 +44,7 @@ public class BasePersonnelLabourCapitalMonthPageVo {
     @ContentStyle(dataFormat = 49)
     @ExcelProperty("月工资明细")
     @ApiModelProperty("月工资明细")
-    private Map<String, Object> dict;
+    private LinkedHashMap<String, Object> dict;
 
     @ContentStyle(dataFormat = 49)
     @ExcelProperty("月份")
@@ -54,4 +55,7 @@ public class BasePersonnelLabourCapitalMonthPageVo {
     @ExcelProperty("年份")
     @ApiModelProperty("年份")
     private int year;
+
+    @ApiModelProperty("年份")
+    private Long labourCapitalId;
 }

+ 2 - 0
src/main/java/com/xjrsoft/module/room/service/IWfRoomStayOvernightService.java

@@ -11,4 +11,6 @@ import com.xjrsoft.module.room.entity.WfRoomStayOvernight;
 */
 
 public interface IWfRoomStayOvernightService extends MPJBaseService<WfRoomStayOvernight> {
+
+    Boolean noticeParents(Long id);
 }

+ 59 - 0
src/main/java/com/xjrsoft/module/room/service/impl/WfRoomStayOvernightServiceImpl.java

@@ -1,12 +1,26 @@
 package com.xjrsoft.module.room.service.impl;
 
+import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.service.IBaseClassService;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserStudent;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.organization.service.IWeChatService;
 import com.xjrsoft.module.room.entity.WfRoomStayOvernight;
 import com.xjrsoft.module.room.mapper.WfRoomStayOvernightMapper;
 import com.xjrsoft.module.room.service.IWfRoomStayOvernightService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.List;
+
 /**
 * @title: 留校住宿申请
 * @Author szs
@@ -16,4 +30,49 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class WfRoomStayOvernightServiceImpl extends MPJBaseServiceImpl<WfRoomStayOvernightMapper, WfRoomStayOvernight> implements IWfRoomStayOvernightService {
+    private final IUserService userService;
+
+    private final IBaseClassService classService;
+
+    private final IWeChatService weChatService;
+    @Override
+    public Boolean noticeParents(Long id) {
+        WfRoomStayOvernight applicant = this.getById(id);
+        List<User> list = userService.list(
+                new MPJLambdaWrapper<User>()
+                        .select(User::getId)
+                        .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
+                        .innerJoin(UserStudent.class, UserStudent::getUserId, User::getId)
+                        .eq(UserStudent::getStudentId, applicant.getApplicantUserId())
+                        .isNotNull(User::getOpenId)
+        );
+        SimpleDateFormat sdf = new SimpleDateFormat("yyy年MM月dd日");
+
+        User student = userService.getById(applicant.getApplicantUserId());
+        BaseClass aClass = classService.getById(applicant.getClassName());
+        String wechatTemplate = "pbggflZY985uimp9XQ0pe3-GftuPyF7fG5jCo97_jJU";
+        for (User user : list) {
+            WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+            weChatSendMessageDto.setUserId(user.getOpenId());
+            weChatSendMessageDto.setTemplateId(wechatTemplate);
+            weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
+
+            JSONObject data = new JSONObject();
+            // 姓名
+            data.put("thing1", new JSONObject() {{
+                put("value", student.getName());
+            }});
+            // 时间
+            data.put("time3", new JSONObject() {{
+                put("value", sdf.format(applicant.getStartTime()));
+            }});
+            //班级
+            data.put("thing2", new JSONObject() {{
+                put("value", aClass.getName());
+            }});
+            weChatSendMessageDto.setContent(data);
+            weChatService.sendTemplateMessage(weChatSendMessageDto);
+        }
+        return true;
+    }
 }

+ 2 - 1
src/main/resources/mapper/personnel/BasePersonnelLabourCapitalMapper.xml

@@ -11,7 +11,8 @@
             t1.name,
             d.name as dept,
             t1.amount_to as amount,
-            t1.extend_json as pendingJson
+            t1.extend_json as pendingJson,
+            t1.labour_capital_id
         FROM
             base_personnel_labour_capital t
                 LEFT JOIN base_personnel_labour_capital_data t1 ON t1.labour_capital_id = t.id