杜洪波
2024-08-19 1d1d34b48e6e80bea350d805d8ff2564ca226f25
Merge branch 'master' of http://nonxin.cn:8090/r/product/product-server-administration/V2.0.0
已修改16个文件
1504 ■■■■ 文件已修改
src/main/java/com/product/administration/config/SystemCode.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/controller/ConferenceManagerController.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/controller/EarlyWarningManagerController.java 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/controller/LeaveRequestController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/controller/WorkAttendanceKanbanController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/controller/WorkAttendanceLocationController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/ConferenceManagerService.java 115 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/CooperatesService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/CustomerInfoService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/EarlyWarningManagerService.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/EarlyWarningServer.java 423 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/LeaveRequestService.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/PunchRecordService.java 275 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/WorkAttendanceKanbanService.java 455 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/ide/IConferenceManagerService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/service/ide/IEarlyWarningManager.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/administration/config/SystemCode.java
@@ -247,17 +247,17 @@
    TEAM_MANAGER_DELETE_FAIL_HAS_SUB_TEAM("团队删除失败,包含子团队", ModuleEnum.ADMINISTRAT.getValue() + "176"),
    TEAM_MANAGER_DELETE_FAIL_HAS_STAFF_REFERED("团队删除失败,员工已经关联", ModuleEnum.ADMINISTRAT.getValue() + "177"),
    TEAM_SAVE_FAIL_DUPLICATE_NAME("保存失败,团队名称重复", ModuleEnum.ADMINISTRAT.getValue() + "178"),
    COMPANY_NOT_CONFIG_PUNCH_TIME("公司未配置打卡时间", ModuleEnum.ADMINISTRAT.getValue() + "179"),
    LIST_COOPERATES_MODEL_FAIL("协同模板列表获取失败", ModuleEnum.ADMINISTRAT.getValue() + "180"),
    FIND_COOPERATES_MODEL_FAIL("协同模板获取失败", ModuleEnum.ADMINISTRAT.getValue() + "181"),
    ATTENDANCE_LOCATION_SAVE_FAIL("考勤点保存失败", ModuleEnum.ADMINISTRAT.getValue() + "182"),
    ATTENDANCE_LOCATION_LIST_FAIL("考勤点查询失败", ModuleEnum.ADMINISTRAT.getValue() + "183"),
    WARN_NO_NORMAL_STATUS_RECORD("为获取到启用的预警记录", ModuleEnum.ADMINISTRAT.getValue() + "184"),
    COMPANY_PUNCH_TIME_NOT_CONFIG("公司打卡时间未配置", ModuleEnum.ADMINISTRAT.getValue()+"185"),
    KNOWLEDGE_SHARING_LIST_FAIL("获取知识共享列表失败", ModuleEnum.ADMINISTRAT.getValue() + "186"),
@@ -271,13 +271,16 @@
    CONFERENCE_ROOM_SAVE_FIAL_DUPLICATE_NAME("会议室保存失败,已存在同名称会议室", ModuleEnum.ADMINISTRAT.getValue() + "193"),
    WORK_ATTENDANCE_REPORT_FAIL("考勤报表获取失败!", ModuleEnum.ADMINISTRAT.getValue() + "194"),
    ANNOUNCEMENT_FAIL("公告详情", ModuleEnum.ADMINISTRAT.getValue() + "195"),
    ANNOUNCEMENT_ADD("公告新增", ModuleEnum.ADMINISTRAT.getValue() + "196"),
    ANNOUNCEMENT_UPDATE("公告修改", ModuleEnum.ADMINISTRAT.getValue() + "197"),
    ANNOUNCEMENT_DELECT("公告删除", ModuleEnum.ADMINISTRAT.getValue() + "198"),
    ANNOUNCEMENT_REMIND("已读提醒失败", ModuleEnum.ADMINISTRAT.getValue() + "199"),
    ANNOUNCEMENT_REMIND("已读提醒失败", ModuleEnum.ADMINISTRAT.getValue() + "199"),
    WARN_TRANSMIT_USER_IS_NULL("预警转发人员为空", ModuleEnum.ADMINISTRAT.getValue() + "200"),
    WARN_TRANSMIT_USER_REPEAT("预警转发人员重复", ModuleEnum.ADMINISTRAT.getValue() + "201"),
    EXPORT_FILE_FAIL("导出文件失败", ModuleEnum.ADMINISTRAT.getValue() + "998"),
    IMPORT_FILE_FAIL("导入文件失败", ModuleEnum.ADMINISTRAT.getValue() + "999"),
src/main/java/com/product/administration/controller/ConferenceManagerController.java
@@ -8,6 +8,7 @@
import com.product.administration.service.ide.IConferenceManagerService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
@@ -21,6 +22,7 @@
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @Author cheng
@@ -419,4 +421,45 @@
        }
    }
    @PostMapping("/get_kb_Data/{version}")
    @ApiVersion(1)
   public String getkbData(HttpServletRequest request){
        //获取参数
        FieldSetEntity fse = null;
        Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
        if (bean != null) {
            RequestParameterEntity reqp = (RequestParameterEntity) bean;
            fse = reqp.getFormData();
        }
        //判断参数是否为空
        if (bean == null || fse == null) {
            return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText());
        }
        List kbData = conferenceManagerService.getKbData(fse);
        return OK(kbData);
    }
    @PostMapping("/get_Meeting_Details/{version}")
    @ApiVersion(1)
    public String getMeetingDetails(HttpServletRequest request){
        //获取参数
        FieldSetEntity fse = null;
        /*Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
        if (bean != null) {
            RequestParameterEntity reqp = (RequestParameterEntity) bean;
            fse = reqp.getFormData();
        }
        //判断参数是否为空
        if (bean == null || fse == null) {
            return this.error(com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getValue(), com.product.admin.config.SystemCode.SYSTEM_FORM_NODATA.getText());
        }*/
        DataTableEntity meetingDetails = conferenceManagerService.getMeetingDetails(fse);
        return  OK(meetingDetails);
    }
}
src/main/java/com/product/administration/controller/EarlyWarningManagerController.java
@@ -1,17 +1,7 @@
package com.product.administration.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.product.admin.service.PublicService;
import com.product.admin.service.idel.IPublicService;
import com.product.core.spring.context.SpringMVCContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.product.administration.config.CmnConst;
import com.product.administration.config.SystemCode;
import com.product.administration.service.EarlyWarningManagerService;
@@ -25,7 +15,16 @@
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.module.sys.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
@@ -589,4 +588,45 @@
            return this.error(SystemCode.SYSTEM_EARLY_WARNING_UPDATE_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_UPDATE_FAIL.getText() + e.getMessage());
        }
    }
    /**
     * 批量修改预警时间
     *
     * @param request
     * @return
     */
    @PostMapping("/transmit/{version}")
    @ApiVersion(1)
    public String transmit(HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            //判断参数是否为空
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            if (fse.getTableName() == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            IEarlyWarningManager service = (IEarlyWarningManager) getProxyInstance(earlyWarningManagerService);
            service.transmit(fse);
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_EARLY_WARNING_UPDATE_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_UPDATE_FAIL.getText() + e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(SystemCode.SYSTEM_EARLY_WARNING_UPDATE_FAIL.getValue(), SystemCode.SYSTEM_EARLY_WARNING_UPDATE_FAIL.getText() + e.getMessage());
        }
    }
}
src/main/java/com/product/administration/controller/LeaveRequestController.java
@@ -140,6 +140,9 @@
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            String uuid = leaveRequestService.saveLeaveRequest(fse);
            if (uuid.equals("1")){
                return error("该时间段已经有请假记录无法保存");
            }
            if (!StringUtils.isEmpty(uuid)) {
                return OK_Add(uuid);
            }
src/main/java/com/product/administration/controller/WorkAttendanceKanbanController.java
@@ -98,7 +98,7 @@
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),SystemCode.SYSTEM_TABLE_NODATA.getText());
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            DataTableEntity dt = workAttendanceKanbanService.listMonthKanBan(fse);
            DataTableEntity dt = workAttendanceKanbanService.listMonthKanBanNew(fse);
            return OK_List(dt);
        } catch (BaseException e) {
            e.printStackTrace();
src/main/java/com/product/administration/controller/WorkAttendanceLocationController.java
@@ -48,10 +48,6 @@
            if (bean == null || fse == null) {
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            //判断表名是否正常
            if (!CmnConst.PRODUCT_OA_PUNCH_SITE.equals(fse.getTableName())) {
                return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
            }
            FieldSetEntity fseData=new FieldSetEntity();
            fseData.setTableName(CmnConst.PRODUCT_OA_PUNCH_SITE);
            DataTableEntity dt = workAttendanceLocationService.listAttendanceLocationInfoByUser();
src/main/java/com/product/administration/service/ConferenceManagerService.java
@@ -122,10 +122,10 @@
        if (nameVerification!=null) {
            throw new BaseException(SystemCode.CONFERENCE_ROOM_SAVE_FIAL_DUPLICATE_NAME.getValue(), SystemCode.CONFERENCE_ROOM_SAVE_FIAL_DUPLICATE_NAME.getText());
        }
        BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fse);
        //重名验证
        return baseDao.saveFieldSetEntity(fse);
    }
@@ -200,6 +200,117 @@
        return baseDao.delete(fse.getTableName(), fse.getUUID().split(","));
    }
    @Override
    public List getKbData(FieldSetEntity fse) throws BaseException {
        List<Object>param=new ArrayList<>();
       String meeting_date= fse.getString("meeting_date");
        String meeting_resource = fse.getString("meeting_resource");
        param.add(meeting_date);
        if(!StringUtils.isEmpty(meeting_resource)){
            String replace_meeting_resource = meeting_resource.replace(",", "%");
            meeting_resource="%"+replace_meeting_resource+"%";
            param.add(meeting_resource);
        }
        StringBuilder bs=new StringBuilder();
        bs.append(" SELECT DISTINCT y.*, g.room_name,g.uuid as meet_room_uuid ");
        bs.append(" FROM product_oa_conference_apply y");
        bs.append(" left JOIN product_oa_conference_room_config g ");
        bs.append(" on y.meeting_room=g.uuid ");
        bs.append(" where DATE_FORMAT(y.start_time,\"%Y-%m-%d\")=?");
        if(!StringUtils.isEmpty(meeting_resource)){
            bs.append(" and  y.meeting_resource like ? ");
        }
        bs.append(" ORDER BY y.start_time");
        DataTableEntity dataTableEntity = baseDao.listTable(bs.toString(), param.toArray());
        List<String> list=new ArrayList();
        List<HashMap> listDate=new ArrayList<>();
        //构造所需要的格式
        for(int i=0;i<dataTableEntity.getRows();i++){
            FieldSetEntity fieldSetEntity = dataTableEntity.getData().get(i);
            if(!list.contains(fieldSetEntity.getValue("room_name").toString())){
                HashMap<String,Object> hashMap=new HashMap<>();
                hashMap.put("room_name",fieldSetEntity.getValue("room_name").toString());
                hashMap.put("uuid",fieldSetEntity.getValue("meet_room_uuid").toString());
                Object getStartTime = dataTableEntity.getData().get(0).getValue("start_time");
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String time = dateFormat.format(getStartTime);
                hashMap.put("start_time",time);
                list.add(fieldSetEntity.getValue("room_name").toString());
                listDate.add(hashMap);
            }
            fieldSetEntity.setValue("parent",fieldSetEntity.getValue("meet_room_uuid").toString());
            HashMap<String,Object> hashMap=new HashMap<>();
            for (int j = 0; j < fieldSetEntity.getValues().keySet().size(); j++) {
                if(fieldSetEntity.getValues().keySet().toArray()[j].toString().equals("start_time") || fieldSetEntity.getValues().keySet().toArray()[j].toString().equals("end_time")){
                    Object meeting_time = fieldSetEntity.getValue(fieldSetEntity.getValues().keySet().toArray()[j].toString());
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    String time = dateFormat.format(meeting_time);
                    hashMap.put(fieldSetEntity.getValues().keySet().toArray()[j].toString(),time);
                }else {
                    hashMap.put(fieldSetEntity.getValues().keySet().toArray()[j].toString(),fieldSetEntity.getValue(fieldSetEntity.getValues().keySet().toArray()[j].toString()));
                }
            }
            listDate.add(hashMap);
        }
        return  listDate;
    }
    @Override
    public DataTableEntity getMeetingDetails(FieldSetEntity fse) throws BaseException {
        //String uuid = fse.getString("uuid");
        String uuid="96f161b4-6360-40ba-8dc1-72bb39d56be4";
        /*if(!StringUtils.isEmpty(uuid)){*/
            List<Object>param=new ArrayList<>();
            param.add(uuid);
            StringBuilder sb=new StringBuilder();
            sb.append(" SELECT b.uuid,b.start_time,b.end_time,b.record_man,b.record_master,b.status, ");
            sb.append(" CONCAT(DATE_FORMAT(b.start_time,\"%H-%i-%S\"),'~',DATE_FORMAT(b.end_time,\"%H-%i-%S\"))  as time_quantum,");
            sb.append(" DATE_FORMAT(b.start_time,\"%Y-%m-%d\") as meeting_date,");
            sb.append(" GROUP_CONCAT(b.dict_label   SEPARATOR ',') AS meeting_resouces ");
            sb.append(" FROM (");
            sb.append(" SELECT DISTINCT a.uuid,a.start_time,a.end_time,a.record_man,a.record_master,a.status,t.dict_label ");
            sb.append(" FROM (");
            sb.append("  SELECT T1.*, ");
            sb.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( T1.meeting_resource, ',', T2.digit + 1 ), ',',- 1 ) AS type ");
            sb.append(" FROM product_oa_conference_apply T1 ");
            sb.append(" JOIN ( SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 ) T2");
            sb.append(" ON T2.digit < ( length( T1.meeting_resource )- length( REPLACE ( T1.meeting_resource, ',', '' ))+ 1 )");
            sb.append(" WHERE t1.uuid = ? ");
            sb.append(" ) a");
            sb.append(" LEFT JOIN product_sys_dict t ON a.type = t.dict_value ");
            sb.append(" AND t.dict_name = '会议室资源'");
            sb.append(" )b ");
            sb.append(" group by b.uuid,b.start_time,b.end_time,b.record_man,b.record_master,b.status ");
            DataTableEntity dataTableEntity = baseDao.listTable(sb.toString(), param.toArray());
            for (int i = 0; i < dataTableEntity.getRows(); i++) {
                Date date = new Date();
                String uuid1 = dataTableEntity.getData().get(0).getString("uuid");
                String filter="uuid = '"+uuid1+"'";
                DataTableEntity product_oa_conference_apply = baseDao.listTable("product_oa_conference_apply", filter, new Object[]{});
                if(date.before(dataTableEntity.getData().get(0).getDate("start_time"))){
                    product_oa_conference_apply.getData().get(0).setValue("status","未开始");
                }else if(date.after(dataTableEntity.getData().get(0).getDate("end_time"))){
                    product_oa_conference_apply.getData().get(0).setValue("status","已取消");
                }else {
                    product_oa_conference_apply.getData().get(0).setValue("status","会议中");
                }
                baseDao.update(product_oa_conference_apply);
            }
            return  dataTableEntity;
       /* }else {
            return null;
        }*/
    }
    /**
     * 会议室使用情况
src/main/java/com/product/administration/service/CooperatesService.java
@@ -79,7 +79,13 @@
        FieldSetEntity fse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_COOPERATES, fs.getString(CmnConst.UUID), true);
        DataTableEntity copsub = fse.getSubDataTable(CmnConst.PRODUCT_OA_COOPERATE_SUB);
        baseDao.loadPromptData(copsub);
        for (int i = 0; i <copsub.getRows() ; i++) {
            String userId = copsub.getString(i, "created_by_save_value");
            String userAvatar = userService.getUserAvatar(userId);
            if (!StringUtils.isEmpty(userAvatar)) {
                    copsub.setFieldValue(i, "avatar", userAvatar);
            }
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(" select ifnull(concat(tricode,'-',receiver) ,receiver) code,uuid,title,cooperate_uuid,grade,receiver as id,receiver,sender, ");
        stringBuilder.append(" receiver_name,(select user_name FROM product_sys_users where user_id=receiver) label,sender_name,status, ");
src/main/java/com/product/administration/service/CustomerInfoService.java
@@ -8,7 +8,6 @@
import com.product.administration.config.CmnConst;
import com.product.administration.service.ide.ICustomerInfoService;
import com.product.common.lang.StringUtils;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
@@ -49,7 +48,10 @@
        sbSql.append("    CONCAT(B.linkman, '-', B.mobile) AS customer_contact \n");
        sbSql.append("FROM product_project_customer A \n");
        sbSql.append("LEFT JOIN product_project_customer_sub B ON B.customer_uuid = A.uuid \n");
        sbSql.append(searchFilter);
        if (!BaseUtil.strIsNull(searchFilter)) {
            sbSql.append("WHERE ").append(searchFilter);
        }
//        if(!StringUtils.isEmpty(dataFilter)) {
//            if (!StringUtils.isEmpty(searchFilter)) {
//                dataFilter+=" AND "+ searchFilter;
src/main/java/com/product/administration/service/EarlyWarningManagerService.java
@@ -27,6 +27,7 @@
import com.product.org.admin.service.StaffManagerService;
import com.product.quartz.service.impl.SysJobService;
import com.product.util.BaseUtil;
import com.product.util.SystemParamReplace;
import org.apache.commons.codec.binary.Base64;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -304,13 +305,15 @@
        Map<String, String> fieldReference = new HashMap<>();    //组合相关字段的参照,tableName1fieldName-->referenceName
        StringBuilder concatField = new StringBuilder();        //组合相关字段,tableName1.fieldName tableName1fieldName
        earlyWarningServer.parseWarningContent(warnCondition, concatField, tableNameAndAlias, fieldAndAlias, fieldReference);
        // 替换系统参数
        warnCondition = SystemParamReplace.systemParamsReplace(warnCondition);
        //生成主子表关联SQL
        String relationSQL = earlyWarningServer.createTableRelation(tableNameAndAlias, mainTableName);
        StringBuilder serviceSQL = new StringBuilder();
        serviceSQL.append(" SELECT ");
        serviceSQL.append(concatField.subSequence(1, concatField.length()));
        serviceSQL.append(StringUtils.isEmpty(concatField) ? "*" : concatField.subSequence(1, concatField.length()));
        serviceSQL.append(" FROM ");
        serviceSQL.append(relationSQL);
        serviceSQL.append(" WHERE ");
@@ -492,4 +495,39 @@
        }
        return dte;
    }
    /**
     * 转发
     * @param fse
     */
    @Override
    public void transmit(FieldSetEntity fse) {
        String uuid = fse.getUUID();
        String messageAccepter = fse.getString("user");
        FieldSetEntity warnMsgFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, uuid, false);
        String preReceiver = warnMsgFse.getString(CmnConst.RECEIVER);
        Set<String> preReceiverSet = Sets.newHashSet(preReceiver.split(","));
        if (StringUtils.isEmpty(messageAccepter)) {
            throw new BaseException(SystemCode.WARN_TRANSMIT_USER_IS_NULL);
        }
        Set<String> transmitUserSet = Sets.newHashSet(messageAccepter.split(","));
        transmitUserSet.forEach(transmitUser -> {
            if (preReceiverSet.contains(transmitUser)) {
                FieldSetEntity transmitUserFse = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_USERS, "user_id=?", new Object[]{transmitUser}, false);
                throw new BaseException(SystemCode.WARN_TRANSMIT_USER_REPEAT.getValue(), String.format("%s:%s", SystemCode.WARN_TRANSMIT_USER_REPEAT.getText(), transmitUserFse.getString(CmnConst.USER_NAME)));
            }
        });
        // 更新预警信息表
        warnMsgFse.setValue(CmnConst.RECEIVER, preReceiver + "," + messageAccepter);
        baseDao.saveFieldSetEntity(warnMsgFse);
        // 发送消息给转发人
        SystemUser curUser = SpringMVCContextHolder.getCurrentUser();
        FieldSetEntity msgFse = baseDao.getFieldSetByFilter(CmnConst.PRODUCT_SYS_MESSAGE, "source_table=? and source_uuid=?", new Object[]{CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, uuid}, false);
        String title = String.format("%s向您转发了预警消息《%s》", curUser.getUser_name(), msgFse.getString(CmnConst.TITLE));
        String content = msgFse.getString("content");
        WebsocketMesssageServiceThread.getInstance().appendMessage(messageAccepter, content, title, curUser.getUser_id(),
                "31", CmnConst.BUTTON_URL_WARN_MESSAGE_INFO + "?uuid=" + fse.getUUID(),
                CmnConst.PRODUCT_SYS_EARLY_WARNING_INFO, fse.getUUID(), curUser.getUser_id(), 0, 0, null);
    }
}
src/main/java/com/product/administration/service/EarlyWarningServer.java
@@ -3,10 +3,14 @@
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.cron.CronUtil;
import com.google.common.collect.Sets;
import com.product.administration.config.SystemCode;
import com.product.common.collect.SetUtils;
import com.product.quartz.util.CronUtils;
import com.product.util.SystemParamReplace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -30,10 +34,10 @@
    @Autowired
    BaseDao baseDao;
    @Autowired
    FlowService flowService;
    public BaseDao getBaseDao() {
        return baseDao;
@@ -60,6 +64,7 @@
    /**
     * 预警-给定uuid单个预警,通常为定时任务触发
     *
     * @param uuid
     */
    public void triggerSingleWarningTask(String uuid) {
@@ -76,6 +81,7 @@
    /**
     * 单个预警
     *
     * @param fseWarningConfig
     */
    private void singleWarningTask(FieldSetEntity fseWarningConfig) {
@@ -95,6 +101,22 @@
        String flowCode = fseWarningConfig.getString(CmnConst.FLOW_CODE);                        //流程type_code
        String flowParam = fseWarningConfig.getString(CmnConst.FLOW_PARAM);                        //流程参数转换
        //获取发送消息频率
        Double cronExpression = fseWarningConfig.getDouble("reminder_frequency");
        //发送消息的频率 1.23 小数点前面代表天 小数点后面代表小时
        double seconds = 0;
        if (cronExpression != null && cronExpression > 0) {
            //将发送消息频率转换为小时
            double hours = cronExpression * 24;
            //将发送消息频率转换为分钟
            double minutes = hours * 60;
            //将发送消息频率转换为秒
            seconds = minutes * 60;
        }
        Map<String, String> tableNameAndAlias = new HashMap<>();    //相关表名-->表别名,tableName-->tableName1
        Map<String, String> fieldAndAlias = new HashMap<>();        //相关字段-->字段别名,tableName.fieldName-->tableName1fieldName
@@ -140,13 +162,53 @@
        //查询符合预警的数据
        DataTableEntity dtService = baseDao.listTable(serviceSQL.toString(), new Object[]{});
        if (!BaseUtil.dataTableIsEmpty(dtService)) {
            List<String> collect = dtService.getData().stream().map(item -> item.getString(mainTableAlias + "uuid")).collect(Collectors.toList());
            //预警uuid
            String warnUUID = fseWarningConfig.getUUID();
            //将预警uuid放到collect 的第一个
            collect.add(0, warnUUID);
            StringBuilder sql = new StringBuilder();
            //查询是否已经存在预警如有相同data_uuid的数据查询出最近的一条根据预警时间字段 early_warning_datetime
//            SELECT e.*
//            FROM product_sys_early_warning_info e
//            JOIN (
//                    SELECT data_uuid, MAX(early_warning_datetime) AS latest_datetime
//                    FROM product_sys_early_warning_info
//                    GROUP BY data_uuid
//            ) AS latest
//            ON e.data_uuid = latest.data_uuid AND e.early_warning_datetime = latest.latest_datetime;
            sql.append("SELECT e.* FROM product_sys_early_warning_info e JOIN (");
            sql.append("SELECT data_uuid, MAX(early_warning_datetime) AS latest_datetime FROM product_sys_early_warning_info ");
            sql.append(" where early_warning_uuid=? and (").append(BaseUtil.buildQuestionMarkFilter("data_uuid", collect.size(), true)).append(") ");
            sql.append("GROUP BY data_uuid) AS latest ON e.data_uuid = latest.data_uuid AND e.early_warning_datetime = latest.latest_datetime");
            DataTableEntity dt = baseDao.listTable(sql.toString(), collect.toArray());
            Map<String, FieldSetEntity> ff = new HashMap<>();
            if (!DataTableEntity.isEmpty(dt)) {
                for (int j = 0; j < dt.getRows(); j++) {
                    FieldSetEntity fse = dt.getFieldSetEntity(j);
                    ff.put(fse.getString("data_uuid"), fse);
                }
            }
            //以data_uuid 进行分组
            for (int j = 0; j < dtService.getRows(); j++) {
                FieldSetEntity fseService = dtService.getFieldSetEntity(j);
                //业务uuid
                String serviceId = fseService.getString(mainTableAlias + "uuid");
                //预警uuid
                String warnUUID = fseWarningConfig.getUUID();
                if (ff.containsKey(serviceId) && StringUtils.isEmpty(cronExpression)) {
                    //如果已经存在预警信息 根据cron表达式判断是否需要再次预警
                    Date preTime = ff.get(serviceId).getDate("early_warning_datetime");
                    if (preTime != null) {
                        long time = new Date().getTime() - preTime.getTime();
                        if (time < seconds * 1000) {
                            continue;
                        }
                    }
                }
                //信息接收人
                Set<String> receiverSet = Sets.newTreeSet();
@@ -241,20 +303,21 @@
            }
        }
    }
    /**
     *     根据提醒内容中的表属性,进行拼接成标准格式
     * @param content                预警内容
     * @param concatField            组合字段
     * @param tableNameAndAlias        表名及别名
     * @param fieldAndAlias            字段名及别名
     * @param fieldReference        字段及参照
     * 根据提醒内容中的表属性,进行拼接成标准格式
     *
     * @param content           预警内容
     * @param concatField       组合字段
     * @param tableNameAndAlias 表名及别名
     * @param fieldAndAlias     字段名及别名
     * @param fieldReference    字段及参照
     * @return
     */
    public Object[] parseWarningContent(String warnContent, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String>fieldAndAlias, Map<String, String> fieldReference) {
    public Object[] parseWarningContent(String warnContent, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String> fieldAndAlias, Map<String, String> fieldReference) {
        int s = 0;
        String tableAndField=null;
        String tableAndField = null;
        while (s >= 0) {
            int c = warnContent.indexOf("{#", s);
            if (c == -1) {
@@ -263,155 +326,158 @@
            }
            int m = warnContent.indexOf("#}", c);
            s = c + 2;
            //表名.字段名
            tableAndField=warnContent.substring(s, m);
            tableAndField = warnContent.substring(s, m);
            //获取表名
            String relationTable=tableAndField.split("\\.")[0];
            String relationTable = tableAndField.split("\\.")[0];
            //表别名
            String relationTableAlias=relationTable+"1";
            String relationTableAlias = relationTable + "1";
            //字段名
            String fieldName=tableAndField.split("\\.")[1];
            if (tableNameAndAlias.get(relationTable)==null) {
            String fieldName = tableAndField.split("\\.")[1];
            if (tableNameAndAlias.get(relationTable) == null) {
                concatField.append(",");
                concatField.append(relationTableAlias);
                concatField.append(".uuid ");
                concatField.append(relationTableAlias);
                concatField.append("uuid");
                fieldAndAlias.put(relationTable+".uuid", relationTable+"1uuid");
                fieldAndAlias.put(relationTable + ".uuid", relationTable + "1uuid");
                tableNameAndAlias.put(relationTable, relationTableAlias);
            }
            //生成字段别名-->表名1字段名
            String tableFieldAlias=tableAndField.replace(".", "1");
            if (fieldAndAlias.get(tableAndField)==null) {
                fieldAndAlias.put(tableAndField,tableFieldAlias);
            String tableFieldAlias = tableAndField.replace(".", "1");
            if (fieldAndAlias.get(tableAndField) == null) {
                fieldAndAlias.put(tableAndField, tableFieldAlias);
                concatField.append(",");
                concatField.append(relationTableAlias+"."+fieldName);
                concatField.append(relationTableAlias + "." + fieldName);
                concatField.append(" ");
                concatField.append(tableFieldAlias);
                fieldReference.put(tableFieldAlias, getReferenceByField(tableAndField));
            }
        }
        return new Object[]{concatField,tableNameAndAlias,fieldAndAlias,fieldReference};
        return new Object[]{concatField, tableNameAndAlias, fieldAndAlias, fieldReference};
    }
    /**
     *     根据提醒内容中的表属性,进行拼接成标准格式
     * @param flowParam                预警内容
     * @param concatField            组合字段
     * @param tableNameAndAlias        表名及别名
     * @param fieldAndAlias            字段名及别名
     * @param fieldReference        字段及参照
     * 根据提醒内容中的表属性,进行拼接成标准格式
     *
     * @param flowParam         预警内容
     * @param concatField       组合字段
     * @param tableNameAndAlias 表名及别名
     * @param fieldAndAlias     字段名及别名
     * @param fieldReference    字段及参照
     * @return
     */
    public Object[] parseFlowParam(String flowParam, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String>fieldAndAlias, Map<String, String> fieldReference) {
        String[] warnAndFlows=flowParam.split(",");
    public Object[] parseFlowParam(String flowParam, StringBuilder concatField, Map<String, String> tableNameAndAlias, Map<String, String> fieldAndAlias, Map<String, String> fieldReference) {
        String[] warnAndFlows = flowParam.split(",");
        for (int i = 0; i < warnAndFlows.length; i++) {
            String[] warnAndFlow=warnAndFlows[i].split("=");
            String tableAndField=warnAndFlow[0];
            String[] warnAndFlow = warnAndFlows[i].split("=");
            String tableAndField = warnAndFlow[0];
            //获取表名
            String relationTable=tableAndField.split("\\.")[0];
            String relationTable = tableAndField.split("\\.")[0];
            //表别名
            String relationTableAlias=relationTable+"1";
            String relationTableAlias = relationTable + "1";
            //字段名
            String fieldName=tableAndField.split("\\.")[1];
            if (tableNameAndAlias.get(relationTable)==null) {
            String fieldName = tableAndField.split("\\.")[1];
            if (tableNameAndAlias.get(relationTable) == null) {
                concatField.append(",");
                concatField.append(relationTableAlias);
                concatField.append(".uuid ");
                concatField.append(relationTableAlias);
                concatField.append("uuid");
                fieldAndAlias.put(relationTable+".uuid", relationTable+"1uuid");
                fieldAndAlias.put(relationTable + ".uuid", relationTable + "1uuid");
                tableNameAndAlias.put(relationTable, relationTableAlias);
            }
            //生成字段别名-->表名1字段名
            String tableFieldAlias=tableAndField.replace(".", "1");
            if (fieldAndAlias.get(tableAndField)==null) {
                fieldAndAlias.put(tableAndField,tableFieldAlias);
            String tableFieldAlias = tableAndField.replace(".", "1");
            if (fieldAndAlias.get(tableAndField) == null) {
                fieldAndAlias.put(tableAndField, tableFieldAlias);
                concatField.append(",");
                concatField.append(relationTableAlias+"."+fieldName);
                concatField.append(relationTableAlias + "." + fieldName);
                concatField.append(" ");
                concatField.append(tableFieldAlias);
                fieldReference.put(tableFieldAlias, getReferenceByField(tableAndField));
            }
        }
        return new Object[]{concatField,tableNameAndAlias,fieldAndAlias,fieldReference};
        return new Object[]{concatField, tableNameAndAlias, fieldAndAlias, fieldReference};
    }
    /**
     *     根据表名和字段的获取对应参照
     * @param tableAndField    表别名.字段名
     * 根据表名和字段的获取对应参照
     *
     * @param tableAndField 表别名.字段名
     * @return 参照名
     */
    public String getReferenceByField(String tableAndField) {
        String [] tableField=tableAndField.replace("1.", ".").split("\\.");
        String tableName=tableField[0];
        String fieldName=tableField[1];
        FieldSetEntity fseTableInfo=baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", "table_name=?",new Object[] {tableName}, false);
        FieldSetEntity fseFieldInfo=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD, "table_uuid=? and field_name=?", new Object[] {fseTableInfo.getUUID(),fieldName}, false);
        if (fseFieldInfo==null) {
        String[] tableField = tableAndField.replace("1.", ".").split("\\.");
        String tableName = tableField[0];
        String fieldName = tableField[1];
        FieldSetEntity fseTableInfo = baseDao.getFieldSetEntityByFilter("product_sys_datamodel_table", "table_name=?", new Object[]{tableName}, false);
        FieldSetEntity fseFieldInfo = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DATAMODEL_FIELD, "table_uuid=? and field_name=?", new Object[]{fseTableInfo.getUUID(), fieldName}, false);
        if (fseFieldInfo == null) {
            throw new BaseException("", "", this.getClass(), "");
        }
        String fieldType=fseFieldInfo.getString(CmnConst.FIELD_TYPE);
        String fieldType = fseFieldInfo.getString(CmnConst.FIELD_TYPE);
        if (CmnConst.USERID.equals(fieldType)) {
            return CmnConst.USERID;
        }else {
        } else {
            return fseFieldInfo.getString(CmnConst.FIELD_REFERENCE);
        }
    }
    /**
     *     生成关联SQL
     * 生成关联SQL
     *
     * @param tableNameAndAlias
     * @param subTable    当前表
     * @param subTable          当前表
     * @return
     */
    public String createTableRelation(Map<String,String>tableNameAndAlias, String subTable) {
    public String createTableRelation(Map<String, String> tableNameAndAlias, String subTable) {
        //关联SQL
        StringBuilder relationSql=new StringBuilder();
        relationSql.append(subTable+" ");
        relationSql.append(subTable+"1");
        StringBuilder relationSql = new StringBuilder();
        relationSql.append(subTable + " ");
        relationSql.append(subTable + "1");
        //判断是否使用子表
        if (tableNameAndAlias!=null) {
        if (tableNameAndAlias != null) {
            //根据关联子表生成关联SQL
            for (String mainTableName : tableNameAndAlias.keySet()) {
                //获取外键字段
                String foreignKey=baseDao.getSubTableRelation(mainTableName, subTable);
                String foreignKey = baseDao.getSubTableRelation(mainTableName, subTable);
                if (!StringUtils.isEmpty(foreignKey)) {
                    relationSql.append(" LEFT JOIN ");
                    relationSql.append(mainTableName+" ");
                    relationSql.append(mainTableName+"1");
                    relationSql.append(mainTableName + " ");
                    relationSql.append(mainTableName + "1");
                    relationSql.append(" ON ");
                    relationSql.append(mainTableName+"1.uuid=");
                    relationSql.append(subTable+"1."+foreignKey);
                    relationSql.append(mainTableName + "1.uuid=");
                    relationSql.append(subTable + "1." + foreignKey);
                }
            }
        }
        return relationSql.toString();
    }
    public String getContentByTableSource(FieldSetEntity fse,String content, Map<String, String> concatFieldReference) {
        if (content.indexOf("{#")==-1) {
    public String getContentByTableSource(FieldSetEntity fse, String content, Map<String, String> concatFieldReference) {
        if (content.indexOf("{#") == -1) {
            return content;
        }
        content=content.replace(".", "1");
        content = content.replace(".", "1");
        return replaceParamText(content, fse, concatFieldReference);
    }
    /**
     * 替换文本参数
     *
     *
     * @param paramText 原文本
     * @param fseData   业务数据
     * @return 新文本
@@ -428,8 +494,8 @@
        Matcher m = p3.matcher(str);
        while (m.find()) {
            String group = m.group(2);
            String replaceValue= SystemParamReplace.replaceSystemParameter(group);
            if(StringUtils.isEmpty(replaceValue)) {
            String replaceValue = SystemParamReplace.replaceSystemParameter(group);
            if (StringUtils.isEmpty(replaceValue)) {
                continue;
            }
            m.appendReplacement(sb1, replaceValue);
@@ -445,8 +511,8 @@
                if (null != value) {
                    if (StringUtils.isEmpty(concatFieldReference.get(group))) {
                        m.appendReplacement(sb2, value);
                    }else {
                        m.appendReplacement(sb2, parseReference(concatFieldReference.get(group),value,fseData));
                    } else {
                        m.appendReplacement(sb2, parseReference(concatFieldReference.get(group), value, fseData));
                    }
                }
            }
@@ -454,136 +520,140 @@
        }
        return sb2.toString();
    }
    /**
     *     参照替换
     * 参照替换
     *
     * @param referenceName
     * @param originValue
     * @param fseData
     * @return
     */
    public String parseReference(String referenceName, String originValue, FieldSetEntity fseData) {
        if (CmnConst.USERID.equals(referenceName)) {    //人员
            FieldSetEntity fseUser=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_USERS, "user_id=?", new Object[] {originValue}, false);
            if (fseUser==null) {
        if (CmnConst.USERID.equals(referenceName)) {    //人员
            FieldSetEntity fseUser = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_USERS, "user_id=?", new Object[]{originValue}, false);
            if (fseUser == null) {
                throw new BaseException("", "", this.getClass(), "");
            }else {
            } else {
                return fseUser.getString(CmnConst.USER_NAME);
            }
        }else if (referenceName.indexOf("》")>-1) {    //数据字典
        } else if (referenceName.indexOf("》") > -1) {    //数据字典
            referenceName.replace("《", "").replace("》", "");
            FieldSetEntity fseDict=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DICT, "dict_name=? AND dict_value=?", new Object[] {referenceName, originValue}, false);
            if (fseDict==null) {
            FieldSetEntity fseDict = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_DICT, "dict_name=? AND dict_value=?", new Object[]{referenceName, originValue}, false);
            if (fseDict == null) {
                throw new BaseException("", "", this.getClass(), "");
            }else {
            } else {
                return fseDict.getString(CmnConst.DICT_LABEL);
            }
        }else {    //高级参照
            FieldSetEntity fsePrompt=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PROMPT, "prompt_name=?", new Object[] {referenceName}, false);
            if (fsePrompt==null) {
                throw new BaseException("", "",this.getClass(),"");
            }else {
                String valueField=fsePrompt.getString("value_field");
                String viewField=fsePrompt.getString("view_fields");
                String sourceTable=fsePrompt.getString("source_table");
                FieldSetEntity fsePromptData=baseDao.getFieldSetEntityByFilter(sourceTable, valueField+"=?", new Object[] {originValue}, false);
                if (fsePromptData!=null) {
        } else {    //高级参照
            FieldSetEntity fsePrompt = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_PROMPT, "prompt_name=?", new Object[]{referenceName}, false);
            if (fsePrompt == null) {
                throw new BaseException("", "", this.getClass(), "");
            } else {
                String valueField = fsePrompt.getString("value_field");
                String viewField = fsePrompt.getString("view_fields");
                String sourceTable = fsePrompt.getString("source_table");
                FieldSetEntity fsePromptData = baseDao.getFieldSetEntityByFilter(sourceTable, valueField + "=?", new Object[]{originValue}, false);
                if (fsePromptData != null) {
                    return fsePromptData.getString(viewField);
                }
            }
        }
        return originValue;
    }
    /**
     *     解析条件表达式
     * 解析条件表达式
     *
     * @param warnCOnditon
     * @param tableNameAndAlias
     * @return
     */
    public String parseWarnCondition(String warnConditon, Map<String, String> tableNameAndAlias) {
        for (String tableName : tableNameAndAlias.keySet()) {
            if (warnConditon.indexOf(tableName)>-1) {
                warnConditon=warnConditon.replace(tableName, tableNameAndAlias.get(tableName));
            if (warnConditon.indexOf(tableName) > -1) {
                warnConditon = warnConditon.replace(tableName, tableNameAndAlias.get(tableName));
            }
        }
        warnConditon=warnConditon.replace("{#", "").replace("#}", "");
        warnConditon=warnConditon.replace("{%", "").replace("%}", "");
        warnConditon = warnConditon.replace("{#", "").replace("#}", "");
        warnConditon = warnConditon.replace("{%", "").replace("%}", "");
        return warnConditon;
    }
    /**
     *     预警发邮件解析
     * 预警发邮件解析
     *
     * @param content
     * @param receiver
     */
    public void parseMail(String content,String receiver) {
        String[] user_ids=receiver.split(",");
    public void parseMail(String content, String receiver) {
        String[] user_ids = receiver.split(",");
        for (int i = 0; i < user_ids.length; i++) {
            FieldSetEntity fseStaff=baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[] {user_ids[i]}, false);
            if (fseStaff==null) {
            FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[]{user_ids[i]}, false);
            if (fseStaff == null) {
                continue;
            }
            String org_level_uuid=fseStaff.getString(CmnConst.ORG_LEVEL_UUID);
            String userEmail=fseStaff.getString("staff_email");
            FieldSetEntity fseCompanySmtp=baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[] {org_level_uuid}, false);
            FieldSetEntity fseMailInfo=new FieldSetEntity();
            String org_level_uuid = fseStaff.getString(CmnConst.ORG_LEVEL_UUID);
            String userEmail = fseStaff.getString("staff_email");
            FieldSetEntity fseCompanySmtp = baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[]{org_level_uuid}, false);
            FieldSetEntity fseMailInfo = new FieldSetEntity();
            fseMailInfo.setTableName(CmnConst.PRODUCT_SYS_MAIL_SEND);
            fseMailInfo.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid);
            fseMailInfo.setValue(CmnConst.ADDRESSEE, userEmail);
            fseMailInfo.setValue(CmnConst.MAIL_TITLE, "预警信息");
            fseMailInfo.setValue(CmnConst.MAIL_CONTENT, content);
            if (fseCompanySmtp!=null) {
            if (fseCompanySmtp != null) {
                fseMailInfo.setValue(CmnConst.SMTP_SERVER_HOST, fseCompanySmtp.getString(CmnConst.SMTP_SERVER_HOST));
                fseMailInfo.setValue(CmnConst.SMTP_SERVER_PORT, fseCompanySmtp.getString(CmnConst.SMTP_SERVER_PORT));
                fseMailInfo.setValue(CmnConst.SMTP_USERNAME, fseCompanySmtp.getString(CmnConst.SMTP_USERNAME));
                fseMailInfo.setValue(CmnConst.SMTP_LICENSE_CODE, fseCompanySmtp.getString(CmnConst.SMTP_LICENSE_CODE));
            }else {
                fseMailInfo.setValue(CmnConst.SMTP_SERVER_HOST, Global.getSystemConfig("spring.mail.host",""));
                fseMailInfo.setValue(CmnConst.SMTP_SERVER_PORT, Global.getSystemConfig("spring.mail.port",""));
                fseMailInfo.setValue(CmnConst.SMTP_USERNAME, Global.getSystemConfig("spring.mail.username",""));
                fseMailInfo.setValue(CmnConst.SMTP_LICENSE_CODE, Global.getSystemConfig("spring.mail.password",""));
            } else {
                fseMailInfo.setValue(CmnConst.SMTP_SERVER_HOST, Global.getSystemConfig("spring.mail.host", ""));
                fseMailInfo.setValue(CmnConst.SMTP_SERVER_PORT, Global.getSystemConfig("spring.mail.port", ""));
                fseMailInfo.setValue(CmnConst.SMTP_USERNAME, Global.getSystemConfig("spring.mail.username", ""));
                fseMailInfo.setValue(CmnConst.SMTP_LICENSE_CODE, Global.getSystemConfig("spring.mail.password", ""));
            }
            fseMailInfo.setValue("send_mode", "smtp");
            SmtpSendMail.sendMail(fseMailInfo,null);
            SmtpSendMail.sendMail(fseMailInfo, null);
            //创建人和创建时间
            if (SpringMVCContextHolder.getCurrentUser()!=null) {
            if (SpringMVCContextHolder.getCurrentUser() != null) {
                fseMailInfo.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
            }
            fseMailInfo.setValue(CmnConst.CREATED_UTC_DATETIME,new Date());
            fseMailInfo.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
            baseDao.add(fseMailInfo);
        }
    }
    /**
     *     预警发短信解析
     * 预警发短信解析
     *
     * @param content
     * @param receiver
     */
    public void parseSMS(String content,String receiver) {
        String[] user_ids=receiver.split(",");
    public void parseSMS(String content, String receiver) {
        String[] user_ids = receiver.split(",");
        for (int i = 0; i < user_ids.length; i++) {
            FieldSetEntity fseuser=baseDao.getFieldSetEntityByFilter("product_sys_users", "user_id=?", new Object[] {user_ids[i]}, false);
            FieldSetEntity fseStaff=baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[] {user_ids[i]}, false);
            if (fseStaff==null) {
            FieldSetEntity fseuser = baseDao.getFieldSetEntityByFilter("product_sys_users", "user_id=?", new Object[]{user_ids[i]}, false);
            FieldSetEntity fseStaff = baseDao.getFieldSetEntityByFilter("product_sys_staffs", "user_id=?", new Object[]{user_ids[i]}, false);
            if (fseStaff == null) {
                continue;
            }
            String org_level_uuid=fseStaff.getString(CmnConst.ORG_LEVEL_UUID);
            String userPhone=fseuser.getString("user_phone_number");
            FieldSetEntity fseMessageInfo=new FieldSetEntity();
            String org_level_uuid = fseStaff.getString(CmnConst.ORG_LEVEL_UUID);
            String userPhone = fseuser.getString("user_phone_number");
            FieldSetEntity fseMessageInfo = new FieldSetEntity();
            fseMessageInfo.setTableName(CmnConst.PRODUCT_SYS_MESSAGE_SEND);
            fseMessageInfo.setValue(CmnConst.ORG_LEVEL_UUID, org_level_uuid);
            fseMessageInfo.setValue("send_user", "2");
            fseMessageInfo.setValue("receive_user",userPhone);
            fseMessageInfo.setValue("receive_user", userPhone);
            fseMessageInfo.setValue("content", content);
            FieldSetEntity fseCompanyMessage=baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[] {org_level_uuid}, false);
            if (fseCompanyMessage!=null) {
            FieldSetEntity fseCompanyMessage = baseDao.getFieldSetEntityByFilter("product_sys_company_email_smtp", "org_level_uuid=?", new Object[]{org_level_uuid}, false);
            if (fseCompanyMessage != null) {
                fseMessageInfo.setValue(CmnConst.USER_ACCOUNT, fseCompanyMessage.getString(CmnConst.USER_ACCOUNT));
                fseMessageInfo.setValue(CmnConst.SECRETKEY, fseCompanyMessage.getString(CmnConst.SECRETKEY));
                fseMessageInfo.setValue(CmnConst.ECNAME, fseCompanyMessage.getString(CmnConst.ECNAME));
@@ -591,7 +661,7 @@
                fseMessageInfo.setValue(CmnConst.ADDSERIAL, fseCompanyMessage.getString(CmnConst.ADDSERIAL));
                fseMessageInfo.setValue(CmnConst.URL, fseCompanyMessage.getString(CmnConst.URL));
                fseMessageInfo.setValue(CmnConst.TREATY, fseCompanyMessage.getString(CmnConst.TREATY));
            }else {
            } else {
                fseMessageInfo.setValue(CmnConst.USER_ACCOUNT, "zgctjt");
                fseMessageInfo.setValue(CmnConst.SECRETKEY, "zgctjt2019");
                fseMessageInfo.setValue(CmnConst.ECNAME, "自贡市城市建设投资开发集团有限公司");
@@ -601,43 +671,44 @@
                fseMessageInfo.setValue(CmnConst.TREATY, "HTTP");
            }
            fseMessageInfo.setValue("send_mode", "smtp");
            HttpSmsSendUtil.sendMsg(fseMessageInfo);
            fseMessageInfo.setValue(CmnConst.CREATED_BY, 1);
            fseMessageInfo.setValue(CmnConst.CREATED_UTC_DATETIME,new Date());
            fseMessageInfo.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
            baseDao.add(fseMessageInfo);
        }
    }
    /**
     *     自动发起流程
     * 自动发起流程
     *
     * @param flowCode
     * @param flowParam
     * @param fseService
     * @param fieldAndAlias
     */
    public void autoStartFlow(String warnName,String flowCode, String flowParam, FieldSetEntity fseService, Map<String, String>fieldAndAlias, Integer createdBy) {
        if (flowCode==null) {
            return ;
    public void autoStartFlow(String warnName, String flowCode, String flowParam, FieldSetEntity fseService, Map<String, String> fieldAndAlias, Integer createdBy) {
        if (flowCode == null) {
            return;
        }
        FieldSetEntity fseFlowService=new FieldSetEntity();
        String [] warnAndFlows=flowParam.split(",");
        FieldSetEntity fseFlowService = new FieldSetEntity();
        String[] warnAndFlows = flowParam.split(",");
        for (int i = 0; i < warnAndFlows.length; i++) {
            String [] warnAndFlow=warnAndFlows[i].split("=");
            String warnField=warnAndFlow[0];
            String flowField=warnAndFlow[1];
            String[] warnAndFlow = warnAndFlows[i].split("=");
            String warnField = warnAndFlow[0];
            String flowField = warnAndFlow[1];
            fseFlowService.setTableName(flowField.split("\\.")[0]);
            fseFlowService.setValue(flowField.split("\\.")[1], fseService.getObject(fieldAndAlias.get(warnField.replace("{#", "").replace("#}", ""))));
        }
        baseDao.add(fseFlowService);
        FieldSetEntity fseFLow=new FieldSetEntity();
        FieldSetEntity fseFLow = new FieldSetEntity();
        fseFLow.setTableName(fseFlowService.getTableName());
        fseFLow.setValue("flow_title", warnName);
        fseFLow.setValue("uuid", fseFlowService.getUUID());
src/main/java/com/product/administration/service/LeaveRequestService.java
@@ -61,16 +61,23 @@
     * 请假申请保存
     */
    public String saveLeaveRequest(FieldSetEntity fs) throws BaseException {
//        fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());//公司
//        fs.setValue("fill_in_time", new Date());//填单时间
//        fs.setValue("department_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());//部门
        fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());//姓名
        fs.setValue("flow_flag", 0);
        if(StringUtils.isEmpty(fs.getString(CmnConst.UUID))){
            return baseDao.add(fs);
        DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_ASK_FOR_LEAVE, " uuid  not in (?) and user_id=? and ((start_time<=? and end_time>=?) or(start_time<=? and end_time>=?))"
                , new String[]{StringUtils.isEmpty(fs.getUUID())?"":fs.getUUID(), fs.getString("user_id"), fs.getString("start_time"), fs.getString("start_time"), fs.getString("end_time"), fs.getString("end_time")});
        if (dataTableEntity.getRows()>0){
            return "1";
        }else {
            baseDao.update(fs);
            return fs.getString(CmnConst.UUID);
            if (StringUtils.isEmpty(fs.getString(CmnConst.UUID))) {
                fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
                fs.setValue("created_utc_datetime", new Date());
                fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
                return baseDao.add(fs);
            } else {
                fs.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
                fs.setValue("updated_utc_datetime", new Date());
                baseDao.update(fs);
                return fs.getString(CmnConst.UUID);
            }
        }
    }
    /**
src/main/java/com/product/administration/service/PunchRecordService.java
@@ -1,11 +1,23 @@
package com.product.administration.service;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -34,29 +46,264 @@
    @Autowired
    BaseDao baseDao;
    /**
     *     考勤打卡列表
     * @param fse
     * @return
     */
    public DataTableEntity listRecordInfo(FieldSetEntity fse) {
    public DataTableEntity listRecordInfo(FieldSetEntity fse) throws ParseException {
        DataTableEntity dt=baseDao.listTable(CmnConst.PRODUCT_OA_PUNCH_RECORD, "created_by=?", new Object[] {SpringMVCContextHolder.getCurrentUser().getUser_id()}, null, CmnConst.CREATED_UTC_DATETIME+" DESC", fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE));
        dt.setFieldFormat("punch_time_one", "yyyy-MM-dd HH:mm:ss");
        dt.setFieldFormat("punch_time_three", "yyyy-MM-dd HH:mm:ss");
        for (int i=0;i<dt.getRows();i++){
            FieldSetEntity fieldSetEntity = dt.getData().get(i);
            String punch_time_one = fieldSetEntity.getValue("punch_time_one").toString();
            Date date1=new Date(punch_time_one);
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String sign_date = dateFormat.format(date1);
            fieldSetEntity.setValue("sign_date",sign_date);
            DateFormat dateFormatGet = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            //获取早退迟到的分钟数
            List<Object>param1=new ArrayList<>();
            param1.add(fieldSetEntity.getValue("created_by").toString());
            param1.add(fieldSetEntity.getValue("punch_congfig_uuid").toString());
            param1.add(fieldSetEntity.getValue("created_by").toString()+",");
            //获取使用到的设置规则
            StringBuilder sbPunchTime=new StringBuilder();
            sbPunchTime.append(" SELECT c.* ");
            sbPunchTime.append(" FROM ( ");
            sbPunchTime.append(" SELECT d.* ");
            sbPunchTime.append(" FROM product_oa_punch_time d ");
            sbPunchTime.append(" left JOIN product_oa_punch_record b ");
            sbPunchTime.append(" on d.punch_site_uuid=b.punch_congfig_uuid and d.created_by=? where d.punch_site_uuid= ? ");
            sbPunchTime.append(" ) c ");
            sbPunchTime.append(" where  c.uuid in ( ");
            sbPunchTime.append(" SELECT DISTINCT uuid ");
            sbPunchTime.append(" FROM product_oa_punch_time ");
            sbPunchTime.append(" where LOCATE(?, concat(attendance_object,','))>0 ");
            sbPunchTime.append(" ) ");
            DataTableEntity dataTableEntity = baseDao.listTable(sbPunchTime.toString(), param1.toArray());
            //处理补卡的情况
            List<Object>param2=new ArrayList<>();
            param2.add(fieldSetEntity.getValue("created_by").toString());
            param2.add(sign_date);
            StringBuilder sbReplenish=new StringBuilder();
            sbReplenish.append(" SELECT T1.id,T1.uuid,T1.created_by,T1.applicant,T1.replenish_date,T1.reason,");
            sbReplenish.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( T1.replacement_card_type, ',', T2.digit + 1 ), ',',- 1 ) AS type ");
            sbReplenish.append(" FROM product_oa_replenish_punch T1 ");
            sbReplenish.append(" JOIN ( SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 ) T2");
            sbReplenish.append(" ON T2.digit < ( length( T1.replacement_card_type )- length( REPLACE ( T1.replacement_card_type, ',', '' ))+ 1 )");
            sbReplenish.append(" where t1.created_by=? ");
            sbReplenish.append(" and DATE_FORMAT( t1.replenish_date, '%Y-%m-%d' )=? ");
            DataTableEntity dataTableEntity1 = baseDao.listTable(sbReplenish.toString(), param2.toArray());
            if(dataTableEntity1.getRows()!=0){
                for(int j=0;j<dataTableEntity1.getRows();j++){
                    String type = dataTableEntity1.getData().get(j).getValue("type").toString();
                    if(type.equals("1")){
                        String morning_work = dataTableEntity.getData().get(0).getValue("morning_work").toString();
                        Date parse = dateFormatGet.parse(morning_work);
                        fieldSetEntity.setValue("punch_time_one", new Timestamp(parse.getTime()));
                    }
                    if(type.equals("2")){
                        String morning_work_off = dataTableEntity.getData().get(0).getValue("morning_work_off").toString();
                        Date parse = dateFormatGet.parse(morning_work_off);
                        fieldSetEntity.setValue("punch_time_two", new Timestamp(parse.getTime()));
                    }
                    if(type.equals("3")){
                        String afternoon_work = dataTableEntity.getData().get(0).getValue("afternoon_work").toString();
                        Date parse = dateFormatGet.parse(afternoon_work);
                        fieldSetEntity.setValue("punch_time_three", new Timestamp(parse.getTime()));
                    }
                    if(type.equals("4")){
                        String afternoon_work_off = dataTableEntity.getData().get(0).getValue("afternoon_work_off").toString();
                        Date parse = dateFormatGet.parse(afternoon_work_off);
                        fieldSetEntity.setValue("punch_time_four", new Timestamp(parse.getTime()));
                    }
                }
            }
            long beLate1 = 0;
            long beLate2 = 0;
            long beEarily1 = 0;
            long beEarily2 = 0;
            if(dataTableEntity.getRows()!=0){
                String morning_work="";
                String morning_work_off="";
                String afternoon_work="";
                String afternoon_work_off="";
                Date  morning_work_date;
                Date  morning_work_off_date;
                Date  afternoon_work_date;
                Date  afternoon_work_off_date;
                DateTime punch_time_one_date;
                DateTime punch_time_two_date;
                DateTime punch_time_three_date;
                DateTime punch_time_four_date;
                SimpleDateFormat dateFormatHHmmss = new SimpleDateFormat("HH:mm:ss");
                StringBuilder  lateSb=new StringBuilder();
                StringBuilder   earilySb=new StringBuilder();
                StringBuilder supereffective_distance=new StringBuilder();
                if(!ObjectUtil.isNotEmpty(dataTableEntity.getData().get(0).getValue("morning_work_off")) && !ObjectUtil.isNotEmpty(dataTableEntity.getData().get(0).getValue("afternoon_work"))){
                    morning_work = dataTableEntity.getData().get(0).getValue("morning_work").toString();
                    afternoon_work_off = dataTableEntity.getData().get(0).getValue("afternoon_work_off").toString();
                    morning_work_date= DateUtil.parse(morning_work.split(" ")[1]);
                    afternoon_work_off_date= DateUtil.parse(afternoon_work_off.split(" ")[1]);
                    int distance = Integer.parseInt(dataTableEntity.getData().get(0).getValue("distance").toString());
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_one"))){
                        String punch_time_one1 = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_one"));
                        punch_time_one_date = DateUtil.parse(punch_time_one1);
                        if(punch_time_one_date.after(morning_work_date)){
                            beLate1 = DateUtil.between(punch_time_one_date, morning_work_date, DateUnit.MINUTE);
                            lateSb.append("迟到:"+beLate1+"分钟");
                            //计算超出的有效距离
                            int punch_range_one = Integer.parseInt(fieldSetEntity.getValue("punch_range_one").toString());
                            if(punch_range_one>distance){
                                int distanceMorning = punch_range_one- distance;
                                fieldSetEntity.setValue("supereffective_distance","上班超有效距离:"+distanceMorning);
                            }
                        }
                    }else {
                        lateSb.append("上班未打卡");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_four"))){
                        String punch_time_four = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_four"));
                        punch_time_four_date = DateUtil.parse(punch_time_four);
                        if(punch_time_four_date.before(afternoon_work_off_date)){
                            beEarily2 = DateUtil.between(punch_time_four_date, afternoon_work_off_date, DateUnit.MINUTE);
                            earilySb.append("早退:"+beEarily2+"分钟");
                            int punch_range_four = Integer.parseInt(fieldSetEntity.getValue("punch_range_four").toString());
                            if(punch_range_four>distance){
                                int distanceMorning = punch_range_four- distance;
                                fieldSetEntity.setValue("supereffective_distance","下班超有效距离:"+distanceMorning);
                            }
                        }
                    }else {
                        earilySb.append("下班未打卡");
                    }
                }else {
                    morning_work = dataTableEntity.getData().get(0).getValue("morning_work").toString();
                    morning_work_date= DateUtil.parse(morning_work.split(" ")[1]);
                    morning_work_off = dataTableEntity.getData().get(0).getValue("morning_work_off").toString();
                    morning_work_off_date= DateUtil.parse(morning_work_off.split(" ")[1]);
                    afternoon_work =dataTableEntity.getData().get(0).getValue("afternoon_work").toString();
                    afternoon_work_date= DateUtil.parse(afternoon_work.split(" ")[1]);
                    afternoon_work_off = dataTableEntity.getData().get(0).getValue("afternoon_work_off").toString();
                    afternoon_work_off_date= DateUtil.parse(afternoon_work_off.split(" ")[1]);
                    int distance = Integer.parseInt(dataTableEntity.getData().get(0).getValue("distance").toString());
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_one"))){
                        String punch_time_one1 = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_one"));
                        punch_time_one_date = DateUtil.parse(punch_time_one1);
                        if(punch_time_one_date.after(morning_work_date)){
                            beLate1 = DateUtil.between(punch_time_one_date, morning_work_date, DateUnit.MINUTE);
                            lateSb.append("早上班迟到:"+beLate1+" ");
                            int punch_range_one = Integer.parseInt(fieldSetEntity.getValue("punch_range_one").toString());
                            if(punch_range_one>distance){
                                int distanceMorning = punch_range_one- distance;
                                supereffective_distance.append("早上班超有效距离:"+distanceMorning);
                            }
                        }
                    }else {
                        lateSb.append("早上班未打卡"+" ");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_two"))){
                        String punch_time_two= dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_two"));
                        punch_time_two_date = DateUtil.parse(punch_time_two);
                        if(punch_time_two_date.before(morning_work_off_date)){
                            beEarily1 = DateUtil.between(punch_time_two_date, morning_work_off_date, DateUnit.MINUTE);
                            earilySb.append("早下班早退:"+beEarily1+" ");
                            int punch_range_two = Integer.parseInt(fieldSetEntity.getValue("punch_range_two").toString());
                            if(punch_range_two>distance){
                                int distanceMorningoff = punch_range_two- distance;
                                supereffective_distance.append("早下班超有效距离:"+distanceMorningoff);
                            }
                        }
                    }else {
                        earilySb.append("早下班未打卡"+" ");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_three"))){
                        String punch_time_three = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_three"));
                        punch_time_three_date = DateUtil.parse(punch_time_three);
                        if(punch_time_three_date.after(afternoon_work_date)){
                            beLate2 = DateUtil.between(punch_time_three_date, afternoon_work_date, DateUnit.MINUTE);
                            lateSb.append("下午上班迟到:"+beLate2+" ");
                            int punch_range_three = Integer.parseInt(fieldSetEntity.getValue("punch_range_three").toString());
                            if(punch_range_three>distance){
                                int distanceAfternoon = punch_range_three- distance;
                                supereffective_distance.append("下午上班超有效距离:"+distanceAfternoon);
                            }
                        }
                    }else {
                        lateSb.append("早上班未打卡"+" ");
                    }
                    if(ObjectUtil.isNotEmpty(fieldSetEntity.getValue("punch_time_four"))){
                        String punch_time_four = dateFormatHHmmss.format(fieldSetEntity.getValue("punch_time_four"));
                        punch_time_four_date = DateUtil.parse(punch_time_four);
                        if(punch_time_four_date.before(afternoon_work_off_date)){
                            beEarily2 = DateUtil.between(punch_time_four_date, afternoon_work_off_date, DateUnit.MINUTE);
                            earilySb.append("下午下班早退:"+beEarily2+" ");
                            int punch_range_four = Integer.parseInt(fieldSetEntity.getValue("punch_range_four").toString());
                            if(punch_range_four>distance){
                                int distanceAfternoonoff = punch_range_four- distance;
                                supereffective_distance.append("下午下班超有效距离:"+distanceAfternoonoff);
                            }
                        }
                    }else {
                        earilySb.append("下午下班未打卡"+" ");
                    }
                }
                fieldSetEntity.setValue("be_late",lateSb);
                fieldSetEntity.setValue("ealy_leave",earilySb);
                fieldSetEntity.setValue("supereffective_distance",supereffective_distance.toString());
            }
        }
        dt.setFieldFormat("punch_time_one", " HH:mm");
        dt.setFieldFormat("punch_time_two", " HH:mm");
        dt.setFieldFormat("punch_time_three", " HH:mm");
        dt.setFieldFormat("punch_time_four", " HH:mm");
        baseDao.loadPromptData(dt);
        return dt;
    }
    /**
     *     考勤打卡详情
     * @param uuid
     * @return
     * @return
     */
    public FieldSetEntity findRecordInfo(String uuid) {
        return baseDao.getFieldSetEntity(CmnConst.PRODUCT_OA_PUNCH_RECORD, uuid, true);
    }
    /**
     *     考勤打卡新增
     * @param fse
@@ -64,18 +311,18 @@
     */
    public String addRecordInfo(FieldSetEntity fse) {
        SimpleDateFormat df = new SimpleDateFormat(CmnConst.YYYYMMDDHHMMSS);
        SystemUser currentUser=SpringMVCContextHolder.getCurrentUser();    //获取打卡人
        Date created_datetime=fse.getDate("created_datetime");            //获取打卡时间
//        Date created_datetime=new Date();                                //获取打卡时间
        String string_created_datetime=df.format(created_datetime);        //时间转string
        //获取公司打卡时间配置信息
        FieldSetEntity fseCompanyPunch=baseDao.getFieldSetEntityByFilter("product_oa_punch_time", "org_level_uuid=?", new Object[] {currentUser.getOrg_level_uuid()}, false);
        if (fseCompanyPunch==null) {
            throw new BaseException(SystemCode.SYSTEM_CONMAPNY_PUNCH_NO_EXIST.getValue(), SystemCode.SYSTEM_CONMAPNY_PUNCH_NO_EXIST.getText(), this.getClass(), "addRecordInfo");
        }
        //获取当天打卡信息
        FieldSetEntity fsePunchInfo=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_OA_PUNCH_RECORD, "created_by=? and DATE_FORMAT(created_utc_datetime,'%Y-%m-%d')like ?", new Object[] {currentUser.getUser_id(),string_created_datetime.substring(0, 10)+"%"}, false);
        if (fsePunchInfo==null) {
@@ -89,13 +336,13 @@
            //新增打卡信息
            return baseDao.add(fseNewPunchInfo);
        }else {
            //打卡模式(0:双卡  1:四卡)
            int punchMode=0;
            if (StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two"))) {
                punchMode=1;
            }
            String punch_time_one=fsePunchInfo.getDate("punch_time_one", CmnConst.YYYYMMDDHHMMSS);
            String punch_time_two=fsePunchInfo.getDate("punch_time_two", CmnConst.YYYYMMDDHHMMSS);
            String punch_time_three=fsePunchInfo.getDate("punch_time_three", CmnConst.YYYYMMDDHHMMSS);
@@ -115,7 +362,7 @@
            }
            list.add(string_created_datetime);
            Collections.sort(list);
            for (int i = 0; i < list.size(); i++) {
                if (punchMode==1) {
                    if (i==0) {
@@ -140,5 +387,5 @@
            return fsePunchInfo.getUUID();
        }
    }
}
src/main/java/com/product/administration/service/WorkAttendanceKanbanService.java
@@ -1,9 +1,11 @@
package com.product.administration.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -25,7 +27,7 @@
    @Autowired
    BaseDao baseDao;
    /**
     *     考勤报表
     * @param dept_uuid        部门
@@ -36,8 +38,8 @@
        Integer monthNum=Integer.valueOf(year_of_month.substring(5, 7));    //获取月份
        Integer yearNum=Integer.valueOf(year_of_month.substring(0,4));        //获取年份
        Integer totalDays=WorkDayUtil.getTotalDays(yearNum, monthNum);
        StringBuilder sb=new StringBuilder();
        sb.append(" SELECT USER_ID, ");
        for (int i = 1; i <= totalDays; i++) {
@@ -68,10 +70,10 @@
        sb.append(" )a GROUP BY USER_ID,DATETIME ORDER BY USER_ID,DATETIME  ");
        sb.append(" )a ");
        sb.append(" GROUP BY USER_ID ");
        return baseDao.listTable(sb.toString(), new Object[] {year_of_month,year_of_month,year_of_month});
    }
    /**
     *     打卡月看板
     * @param fse
@@ -82,173 +84,366 @@
        SystemUser currentUser=SpringMVCContextHolder.getCurrentUser();
        Integer user_id=currentUser.getUser_id();    //user_id
        String org_level_uuid=currentUser.getOrg_level_uuid();    //公司uuid
        //获取公司工作时间配置信息
        FieldSetEntity fseCompanyPunch=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_OA_PUNCH_TIME, "org_level_uuid=?", new Object[] {org_level_uuid}, false);
        if (fseCompanyPunch==null) {
            throw new BaseException(SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getValue(), SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getText(), this.getClass(), "listMonthKanBan");
        }
        //获取查询月份
        String yearAndMonth=fse.getString("yearAndMonth");
        if (StringUtils.isEmpty(yearAndMonth)) {
            yearAndMonth=DateUtils.formatDate(new Date(), "yyyy-MM");
        }
        int workTimeMethod=0;
        if (!StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && !StringUtils.isEmpty(fseCompanyPunch.getString("work_time_three"))) {
            workTimeMethod=1;
        }
        StringBuilder sb=new StringBuilder();
        List<Object> param=new ArrayList<>();
        sb.append(" SELECT ");
        sb.append(" DATE_FORMAT(created_utc_datetime,'%Y-%m-%d')punch_date, ");
        sb.append(" punch_time_one,IF(punch_time_one IS TRUE,IF(DATE_FORMAT(punch_time_one,'%H:%i:%S')>?,'迟到','正常'),'未打卡')result_one, ");
        sb.append(" punch_time_one,IF(punch_time_one IS TRUE,IF(DATE_FORMAT(punch_time_one,'%H:%i:%S')>?,'迟到','正常'),'上午上班未打卡')result_one, ");
        param.add(fseCompanyPunch.getDate("work_time_one","HH:mm:ss"));
        if (workTimeMethod==1) {
            sb.append(" punch_time_two,IF(punch_time_two IS TRUE,IF(DATE_FORMAT(punch_time_two,'%H:%i:%S')<?,'早退','正常'),'未打卡')result_two, ");
            sb.append(" punch_time_two,IF(punch_time_two IS TRUE,IF(DATE_FORMAT(punch_time_two,'%H:%i:%S')<?,'早退','正常'),'上午下班未打卡')result_two, ");
            param.add(fseCompanyPunch.getDate("work_time_two","HH:mm:ss"));
            sb.append(" punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>?,'迟到','正常'),'未打卡')result_three, ");
            sb.append(" punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>?,'迟到','正常'),'下午上班未打卡')result_three, ");
            param.add(fseCompanyPunch.getDate("work_time_three","HH:mm:ss"));
        }
        sb.append(" punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<?,'早退','正常'),'未打卡')result_four ");
        sb.append(" punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<?,'早退','正常'),'下午上班未打卡')result_four ");
        param.add(fseCompanyPunch.getDate("work_time_four","HH:mm:ss"));
        sb.append(" FROM product_oa_punch_record WHERE created_by=?");
        sb.append(" AND DATE_FORMAT(created_utc_datetime,'%Y-%m')=? ");
        sb.append(" AND DATE_FORMAT(created_utc_datetime,'%Y-%m-%d') NOT IN (SELECT DATE_FORMAT(date_holiday,'%Y-%m-%d')FROM product_sys_company_holiday WHERE org_level_uuid=?) ");
        param.add(user_id);
        param.add(yearAndMonth);
        param.add(org_level_uuid);
        return baseDao.listTable(sb.toString(), param.toArray());
    }
    /**
     *     打卡月看板(新)
     * @param fse
     * @return
     */
    public DataTableEntity listMonthKanBanNew(FieldSetEntity fse) {
        //获取当前人信息
        Integer user_id=fse.getInteger("user_id");    //user_id
          if(user_id==null){
              return null;
          }
        //获取查询月份
        String yearAndMonth=fse.getString("yearAndMonth");
        if (StringUtils.isEmpty(yearAndMonth)) {
            yearAndMonth=DateUtils.formatDate(new Date(), "yyyy-MM");
        }
        StringBuilder sb=new StringBuilder();
        List<Object> param=new ArrayList<>();
        sb.append(" SELECT a.punch_date,e.bk,f.morning_work,f.morning_work_off,f.afternoon_work,f.afternoon_work_off, ");
        sb.append(" CONCAT(if(d.punch_range_one is not null and d.punch_range_one>f.distance,'超出打卡范围',0) ");
        sb.append(" ,',',if(d.punch_range_two is not null and d.punch_range_two>f.distance,'超出打卡范围',0) ");
        sb.append(" ,',',if(d.punch_time_three is not null and d.punch_time_three>f.distance,'超出打卡范围',0) ");
        sb.append(" ,',',if(d.punch_range_four is not null and d.punch_range_four>f.distance,'超出打卡范围',0)) dkfw, ");
        sb.append(" CASE  WHEN b.uuid is not null THEN c.dict_label ELSE  ");
        sb.append(" CASE  WHEN d.uuid is not null THEN   ");
        sb.append(" CONCAT(IF(d.punch_time_one IS TRUE, IF ( DATE_FORMAT(d.punch_time_one, '%H:%i:%S' )>DATE_FORMAT(f.morning_work, '%H:%i:%S'), CONCAT('上午迟到',TIMESTAMPDIFF(MINUTE, DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.morning_work, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S'),d.punch_time_one),'分钟'), 0 ), '上午上班未打卡' ) ");
        sb.append(" ,',',IF(d.punch_time_two IS TRUE, IF ( DATE_FORMAT(d.punch_time_two, '%H:%i:%S' )<DATE_FORMAT(f.morning_work_off, '%H:%i:%S') and f.morning_work_off is not null, CONCAT('上午早退',TIMESTAMPDIFF(MINUTE,d.punch_time_two,DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.morning_work_off, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S')),'分钟'), 0 ), '上午下班未打卡' ) ");
        sb.append(" ,',',IF(d.punch_time_three IS TRUE, IF ( DATE_FORMAT(d.punch_time_three, '%H:%i:%S' )>DATE_FORMAT(f.afternoon_work, '%H:%i:%S') and f.afternoon_work is not null, CONCAT('下午迟到',TIMESTAMPDIFF(MINUTE, DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.afternoon_work, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S'),d.punch_time_three),'分钟'), 0 ), '下午上班未打卡' ) ");
        sb.append(" ,',',IF(d.punch_time_four IS TRUE, IF ( DATE_FORMAT(d.punch_time_four, '%H:%i:%S' )<DATE_FORMAT(f.afternoon_work_off, '%H:%i:%S'), CONCAT('下午早退',TIMESTAMPDIFF(MINUTE,d.punch_time_four,DATE_FORMAT(CONCAT(a.punch_date,' ',DATE_FORMAT(f.afternoon_work_off, '%H:%i:%S')),'%Y-%m-%d %H:%i:%S')),'分钟'), 0 ), '下午下班未打卡' )) ");
        sb.append(" ELSE '全天未打卡' END END reidis,CASE  WHEN b.uuid is not null THEN 1 ELSE CASE  WHEN d.uuid is not null THEN 0 ELSE 2 END END type ");
        sb.append(" FROM (SELECT CONCAT(DATE_FORMAT(?, '%Y-%m-'),IF(i<9,CONCAT('0',i + 1),i + 1)) punch_date  ");
        param.add(yearAndMonth+"-01");
        sb.append(" FROM (SELECT @row := @row + 1 as i FROM ");
        sb.append(" (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) t1, ");
        sb.append(" (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) t2, ");
        sb.append(" (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) t3, ");
        sb.append(" (SELECT 0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5) t4, ");
        sb.append(" (SELECT @row := -1) t0) d WHERE i < DAY(last_day(DATE_FORMAT(?, '%Y-%m-01')))) a ");
        param.add(yearAndMonth+"-01");
        sb.append(" LEFT JOIN (SELECT * FROM product_oa_ask_for_leave WHERE user_id=?) b ");
        param.add(user_id);
        sb.append(" on DATE_FORMAT( a.punch_date, '%Y-%m-%d' )>= DATE_FORMAT( b.start_time, '%Y-%m-%d' ) and DATE_FORMAT( a.punch_date, '%Y-%m-%d' )<= DATE_FORMAT( b.end_time, '%Y-%m-%d' ) ");
        sb.append(" LEFT JOIN (SELECT * FROM product_sys_dict where dict_name='Leave_Type') c on b.leave_type =c.dict_value ");
        sb.append(" LEFT JOIN product_oa_punch_record d on a.punch_date=DATE_FORMAT( d.punch_time_one, '%Y-%m-%d' ) ");
        sb.append(" LEFT JOIN (SELECT applicant,DATE_FORMAT( replenish_date, '%Y-%m-%d') replenish_date,max(replacement_card_type) bk FROM product_oa_replenish_punch ");
        sb.append(" where applicant=? GROUP BY applicant,DATE_FORMAT( replenish_date, '%Y-%m-%d')) e on a.punch_date=e.replenish_date  ");
        param.add(user_id);
        sb.append(" LEFT JOIN  product_oa_punch_time f on d.punch_congfig_uuid =f.punch_site_uuid  ");
        sb.append(" where a.punch_date NOT IN (SELECT DATE_FORMAT( date_holiday, '%Y-%m-%d' ) FROM product_sys_company_holiday) ");
        DataTableEntity dt = baseDao.listTable(sb.toString(), param.toArray());
        for (int i = 0; i < dt.getRows(); i++) {
            FieldSetEntity fs = dt.getFieldSetEntity(i);
            //获取补卡标识
            List<String> bk=new ArrayList<>();
            if (!StringUtils.isEmpty(fs.getString("bk"))){
                bk= Arrays.asList(fs.getString("bk").split(","));
            }
            if (fs.getString("reidis").equals("全天未打卡")&&!StringUtils.isEmpty(fs.getString("bk"))){
                if (!bk.contains("1")){
                    fs.setValue("result_one", "上午上班未打卡");
                }
                if (!bk.contains("2")&&!StringUtils.isEmpty(fs.getString("morning_work_off"))){
                    fs.setValue("result_two", "上午下班未打卡");
                }
                if (!bk.contains("3")&&!StringUtils.isEmpty(fs.getString("afternoon_work"))){
                    fs.setValue("result_three", "下午上班未打卡");
                }
                if (!bk.contains("4")){
                    fs.setValue("result_four", "下午下班未打卡");
                }
                continue;
            }
            if ("0".equals(fs.getString("type"))){
                String[] reidis = fs.getString("reidis").split(",");
                String[] dkfwsArr = fs.getString("dkfw").split(",");
                String a="1";
                for (int j = 0; j < reidis.length; j++) {
                    String dkfws="";
                    if (!dkfwsArr[j].equals("0")){
                        dkfws=dkfwsArr[j];
                    }
                    if (reidis[j].contains("上午迟到")) {
                        if (!bk.contains("1")) {
                            fs.setValue("result_one", reidis[j]+dkfws);
                            a = "2";
                        }
                    }
                    if (reidis[j].contains("上午早退")) {
                        if (!bk.contains("2")) {
                            fs.setValue("result_two", reidis[j]+dkfws);
                            a = "2";
                        }
                    }
                    if (reidis[j].contains("下午迟到")) {
                        if (!bk.contains("3")) {
                            fs.setValue("result_three", reidis[j]+dkfws);
                            a = "2";
                        }
                    }
                    if (reidis[j].contains("下午早退")) {
                        if (!bk.contains("3")) {
                            fs.setValue("result_four", reidis[j]+dkfws);
                            a = "2";
                        }
                    }
                }
                if ("1".equals(a)){
                    fs.setValue("type",a);
                    fs.setValue("result_one","正常打卡");
                }
            }else {
                fs.setValue("result_one",fs.getString("reidis"));
            }
        }
        return dt;
    }
    /**
     *     考勤统计报表
     * @param fse
     * @return
     */
    public DataTableEntity listMonthReport(FieldSetEntity fse) {
        //获取当前人信息
        SystemUser currentUser=SpringMVCContextHolder.getCurrentUser();
        String org_level_uuid=currentUser.getOrg_level_uuid();
        //获取公司工作时间配置信息
        FieldSetEntity fseCompanyPunch=baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_OA_PUNCH_TIME, "org_level_uuid=?", new Object[] {org_level_uuid}, false);
        if (fseCompanyPunch==null) {
            throw new BaseException(SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getValue(), SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getText(), this.getClass(), "listMonthReport");
        List<Object>param1=new ArrayList<>();
        param1.add(currentUser.getUser_id());
        param1.add(currentUser.getUser_id()+",");
       //获取使用到的设置规则
        StringBuilder sbPunchTime=new StringBuilder();
        sbPunchTime.append(" SELECT DISTINCT c.* ");
        sbPunchTime.append(" FROM ( ");
        sbPunchTime.append(" SELECT d.* ");
        sbPunchTime.append(" FROM product_oa_punch_time d ");
        sbPunchTime.append(" left JOIN product_oa_punch_record b ");
        sbPunchTime.append(" on d.punch_site_uuid=b.punch_congfig_uuid and d.created_by=? ");
        sbPunchTime.append(" ) c ");
        sbPunchTime.append(" where  c.uuid in ( ");
        sbPunchTime.append(" SELECT DISTINCT uuid ");
        sbPunchTime.append(" FROM product_oa_punch_time ");
        sbPunchTime.append(" where LOCATE(?, concat(attendance_object,','))>0 ");
        sbPunchTime.append(" ) ");
        DataTableEntity dataTableEntity = baseDao.listTable(sbPunchTime.toString(), param1.toArray());
        List<DataTableEntity> dataTableEntityLits=new ArrayList<>();
        for(int i=0;i<dataTableEntity.getRows();i++){
            FieldSetEntity fseCompanyPunch = dataTableEntity.getData().get(i);
            if (fseCompanyPunch==null) {
                throw new BaseException(SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getValue(), SystemCode.COMPANY_PUNCH_TIME_NOT_CONFIG.getText(), this.getClass(), "listMonthReport");
            }
            //获取查询月份
            String yearAndMonth=fse.getString("yearAndMonth");
            if (StringUtils.isEmpty(yearAndMonth)) {
                yearAndMonth=DateUtils.formatDate(new Date(), "yyyy-MM");
            }
         //获取每月天数
            int dayOfMonth = DateUtils.getMonthHasDays(DateUtils.parseDate(yearAndMonth));
         //获取本月节假日
            DataTableEntity dtHoliday=baseDao.listTable("product_sys_company_holiday", "date_holiday like ?", new Object[] {yearAndMonth+"%"});
         //获取每月应上班天数
            int dayOfWork = 0;
            if (BaseUtil.dataTableIsEmpty(dtHoliday)) {
                dayOfWork=dayOfMonth;
            }else {
                dayOfWork=dayOfMonth-dtHoliday.getRows();
            }
            StringBuilder sb=new StringBuilder();
            List<Object>param=new ArrayList<>();
            String morinng_work = fseCompanyPunch.getValue("morning_work").toString().split(" ")[1];
            param.add(morinng_work);
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                String morinng_work_off = fseCompanyPunch.getValue("morning_work_off").toString().split(" ")[1];
                String afternoon_work = fseCompanyPunch.getValue("afternoon_work").toString().split(" ")[1];
                param.add(afternoon_work);
                param.add(morinng_work_off);
            }
            String afternoon_work_off = fseCompanyPunch.getValue("afternoon_work_off").toString().split(" ")[1];
            String uuid = fseCompanyPunch.getValue("uuid").toString();
            param.add(afternoon_work_off);
            param.add(yearAndMonth);
            param.add(uuid);
            param.add(yearAndMonth);
            param.add(yearAndMonth);
            sb.append(" SELECT ");
            sb.append(" (SELECT user_name FROM product_sys_users WHERE user_id=a.created_by)created_by, ");
            sb.append(" (SELECT org_level_name FROM product_sys_org_levels WHERE uuid=dept_uuid)dept_uuid, ");
            sb.append(" dayOfWork,workDayOfMonth,lateCome,leaveEarly,total_hours,casual_leave,medical_leave,marriage_leave,paid_leave,other_leave,(dayOfWork-workDayOfMonth)absenteeism ");
            sb.append(" FROM ( ");
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                sb.append(" SELECT b.created_by,b.dayOfWork,b.workDayOfMonth,b.dept_uuid,b.lateCome1+b.lateCome2 lateCome,b.leaveEarly1+b.leaveEarly2 leaveEarly");
            }else {
                sb.append(" SELECT b.created_by,b.dayOfWork,b.workDayOfMonth,b.dept_uuid,b.lateCome1 lateCome,b.leaveEarly2 leaveEarly");
            }
            sb.append(" FROM ( ");
            sb.append(" SELECT ");
            sb.append(" a.created_by,"+dayOfWork+" dayOfWork,COUNT(day_of_month)workDayOfMonth,a.dept_uuid, ");
            sb.append(" COUNT(");
            sb.append(" IF ");
            sb.append(" ( result1 = '迟到', TRUE, NULL )) lateCome1,");
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                sb.append(" COUNT(");
                sb.append(" IF ");
                sb.append(" ( result2 = '迟到', TRUE, NULL )) lateCome2,");
                sb.append(" COUNT(");
                sb.append(" IF ");
                sb.append(" ( result3 = '早退', TRUE, NULL )) leaveEarly1,");
            }
            sb.append(" COUNT(");
            sb.append(" IF ");
            sb.append(" ( result4 = '早退', TRUE, NULL )) leaveEarly2 ");
            sb.append(" FROM ( ");
            sb.append(" SELECT d.created_by,d.dept_uuid,DATE_FORMAT( d.created_utc_datetime, '%Y-%m-%d' ) day_of_month,punch_time_one, ");
            sb.append(" IF ");
            sb.append(" ( punch_time_one IS TRUE, IF ( DATE_FORMAT( punch_time_one, '%H:%i:%S' )> ?, '迟到', '正常' ), '未打卡' ) ");
            sb.append(" result1 ,");
            if(ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("morning_work_off"))&& ObjectUtil.isNotEmpty(fseCompanyPunch.getValue("afternoon_work"))){
                sb.append(" IF ");
                sb.append(" ( punch_time_three IS TRUE, IF ( DATE_FORMAT( punch_time_three, '%H:%i:%S' )> ?, '迟到', '正常' ), '未打卡' ) ");
                sb.append(" result2 ,");
                sb.append(" IF ");
                sb.append(" ( punch_time_two IS TRUE, IF ( DATE_FORMAT( punch_time_two, '%H:%i:%S' )< ?, '早退', '正常' ), '未打卡' ) ");
                sb.append(" result3 ,");
            }
            sb.append(" IF ");
            sb.append(" ( punch_time_four IS TRUE, IF ( DATE_FORMAT( punch_time_four, '%H:%i:%S' ) < ?, '早退', '正常' ), '未打卡' ) ");
            sb.append(" result4 ");
            sb.append(" FROM product_oa_punch_record d ");
            sb.append(" left JOIN   product_oa_punch_time e ");
            sb.append(" on d.punch_congfig_uuid=e.punch_site_uuid ");
            sb.append(" and DATE_FORMAT( d.created_utc_datetime,'%Y-%m')=? AND DATE_FORMAT(punch_time_one,'%Y-%m-%d') NOT IN(SELECT date_holiday FROM product_sys_company_holiday) ");
            sb.append(" where e.uuid=? ");
            sb.append(" )a  ");
            sb.append(" GROUP BY a.created_by,a.dept_uuid ");
            sb.append(" )b");
            sb.append(" )a ");
            sb.append(" LEFT JOIN (SELECT user_id, sum( duration ) total_hours FROM product_oa_work_overtime o left join product_oa_work_overtime_sub b on o.uuid=b.main_uuid and   DATE_FORMAT( b.start_time, '%Y-%m' )=? GROUP BY o.user_id)b  ");
            sb.append(" ON a.created_by=b.user_id ");
            sb.append(" LEFT JOIN ( ");
            sb.append(" SELECT ");
            sb.append(" created_by,sum(IF(leave_type=1,TRUE,0))casual_leave,sum(IF(leave_type=2,TRUE,0))medical_leave, ");
            sb.append(" sum(IF(leave_type=9,TRUE,0))marriage_leave,sum(IF(leave_type=4,TRUE,0))paid_leave, ");
            sb.append(" sum(IF(leave_type!=1 && leave_type!=2 && leave_type!=4 && leave_type!=9,TRUE,0))other_leave ");
            sb.append(" FROM product_oa_ask_for_leave ");
            sb.append(" WHERE DATE_FORMAT(start_time,'%Y-%m')=? ");
            sb.append(" GROUP BY created_by ");
            sb.append(" )c ");
            sb.append(" ON a.created_by=c.created_by ");
            sb.append(" ORDER BY dept_uuid,a.created_by ");
            DataTableEntity dataTableEntityReport = baseDao.listTable(sb.toString(), param.toArray());
            if(dataTableEntityReport.getRows()!=0){
                dataTableEntityLits.add(baseDao.listTable(sb.toString(), param.toArray()));
            }
        }
        //获取查询月份
        String yearAndMonth=fse.getString("yearAndMonth");
        if (StringUtils.isEmpty(yearAndMonth)) {
            yearAndMonth=DateUtils.formatDate(new Date(), "yyyy-MM");
        DataTableEntity dataTableEntity1=new DataTableEntity();
        if(ObjectUtil.isNotEmpty(dataTableEntityLits)){
            dataTableEntity1=dataTableEntityLits.get(0);
            //本月内迟到早退数的累加
            for (int i = 1; i < dataTableEntityLits.size(); i++) {
                FieldSetEntity fieldSetEntity = dataTableEntityLits.get(i).getData().get(0);
                FieldSetEntity fieldSetEntity1 = dataTableEntity1.getData().get(0);
                dataTableEntity1.getData().get(0).setValue("lateCome",Integer.parseInt(fieldSetEntity.getValue("lateCome").toString())+Integer.parseInt(fieldSetEntity1.getValue("lateCome").toString()));
                dataTableEntity1.getData().get(0).setValue("leaveEarly",Integer.parseInt(fieldSetEntity.getValue("leaveEarly").toString())+Integer.parseInt(fieldSetEntity1.getValue("leaveEarly").toString()));
                dataTableEntity1.getData().get(0).setValue("workDayOfMonth",Integer.parseInt(fieldSetEntity.getValue("workDayOfMonth").toString())+Integer.parseInt(fieldSetEntity1.getValue("workDayOfMonth").toString()));
                dataTableEntity1.getData().get(0).setValue("absenteeism",Integer.parseInt(fieldSetEntity1.getValue("absenteeism").toString())-Integer.parseInt(fieldSetEntity.getValue("workDayOfMonth").toString()));
            }
        }
        //获取每月天数
        int dayOfMonth = DateUtils.getMonthHasDays(DateUtils.parseDate(yearAndMonth));
        //获取本月节假日
        DataTableEntity dtHoliday=baseDao.listTable("product_sys_company_holiday", "date_holiday like ?", new Object[] {yearAndMonth+"%"});
        //获取每月应上班天数
        int dayOfWork = 0;
        if (BaseUtil.dataTableIsEmpty(dtHoliday)) {
            dayOfWork=dayOfMonth;
        }else {
            dayOfWork=dayOfMonth-dtHoliday.getRows();
        //处理补卡的情况
        List<Object>param2=new ArrayList<>();
        param2.add(currentUser);
        param2.add(fse.getString("yearAndMonth"));
        StringBuilder sbReplenish=new StringBuilder();
        sbReplenish.append(" SELECT DISTINCT replenish_date ");
        sbReplenish.append(" FROM product_oa_replenish_punch ");
        sbReplenish.append(" WHERE");
        sbReplenish.append(" created_by =? ");
        sbReplenish.append(" AND DATE_FORMAT( replenish_date, '%Y-%m' )=? ");
        sbReplenish.append(" and DATE_FORMAT( replenish_date, '%Y-%m-%d') ");
        sbReplenish.append(" not in (");
        sbReplenish.append(" SELECT DISTINCT record_data FROM ");
        sbReplenish.append(" ( ");
        sbReplenish.append(" select  DATE_FORMAT(punch_time_one, '%Y-%m-%d') as record_data  from  product_oa_punch_record ");
        sbReplenish.append(" union all select  DATE_FORMAT(punch_time_two, '%Y-%m-%d') as record_data  from  product_oa_punch_record");
        sbReplenish.append(" union all select  DATE_FORMAT(punch_time_three, '%Y-%m-%d') as record_data  from  product_oa_punch_record");
        sbReplenish.append(" union all select  DATE_FORMAT(punch_time_four, '%Y-%m-%d') as record_data  from  product_oa_punch_record");
        sbReplenish.append(" )n )");
        DataTableEntity dataTableEntityReplenish = baseDao.listTable(sbReplenish.toString(), param2.toArray());
        if(dataTableEntityReplenish.getRows()!=0){
            dataTableEntity1.getData().get(0).setValue("workDayOfMonth",Integer.parseInt(dataTableEntity1.getData().get(0).getString("workDayOfMonth"))+dataTableEntityReplenish.getRows());
            dataTableEntity1.getData().get(0).setValue("dayOfWork",Integer.parseInt(dataTableEntity1.getData().get(0).getString("dayOfWork"))-dataTableEntityReplenish.getRows());
        }
        //workTimeMethod 0:上午上班,下午下班  1:一卡 2:四卡  3:上午上班,下午上班
        int workTimeMethod=0;
         if (StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && StringUtils.isEmpty(fseCompanyPunch.getString("work_time_three")) && StringUtils.isEmpty(fseCompanyPunch.getString("work_time_four"))) {
             workTimeMethod=1;
        } else if (!StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && !StringUtils.isEmpty(fseCompanyPunch.getString("work_time_three")) && !StringUtils.isEmpty(fseCompanyPunch.getString("work_time_four"))) {
            workTimeMethod=2;
        } else if (StringUtils.isEmpty(fseCompanyPunch.getString("work_time_two")) && StringUtils.isEmpty(fseCompanyPunch.getString("work_time_four"))) {
            workTimeMethod=3;
        }
        StringBuilder sb=new StringBuilder();
        List<Object>param=new ArrayList<>();
        param.add(yearAndMonth);
        param.add(yearAndMonth);
        param.add(yearAndMonth);
        sb.append(" SELECT ");
        sb.append(" (SELECT user_name FROM product_sys_users WHERE user_id=a.created_by)created_by, ");
        sb.append(" (SELECT org_level_name FROM product_sys_org_levels WHERE uuid=dept_uuid)dept_uuid, ");
        sb.append(" dayOfWork,workDayOfMonth,lateCome,leaveEarly,total_hours,casual_leave,medical_leave,marriage_leave,paid_leave,other_leave,(dayOfWork-workDayOfMonth)absenteeism ");
        sb.append(" FROM ( ");
        sb.append(" SELECT ");
        sb.append(" a.created_by,"+dayOfWork+" dayOfWork,COUNT(day_of_month)workDayOfMonth,a.dept_uuid, ");
        if (workTimeMethod==0) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        }else if (workTimeMethod==1) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" 0 leaveEarly ");
        }else if (workTimeMethod==2) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL))+COUNT(IF(result3='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result2='早退',TRUE,NULL))+COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        }else if (workTimeMethod==3) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL))+COUNT(IF(result3='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" 0 leaveEarly ");
        }
        /*
        if (workTimeMethod==1) {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL))+COUNT(IF(result3='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result2='早退',TRUE,NULL))+COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        } else if (workTimeMethod==2) {
            sb.append("");
        } else if (workTimeMethod==3) {
        } else {
            sb.append(" COUNT(IF(result1='迟到',TRUE,NULL)) lateCome, ");
            sb.append(" COUNT(IF(result4='早退',TRUE,NULL)) leaveEarly ");
        }
        */
        sb.append(" FROM ( ");
        sb.append(" SELECT ");
        sb.append(" created_by,dept_uuid, ");
        sb.append(" DATE_FORMAT(created_utc_datetime,'%Y-%m-%d') day_of_month, ");
        sb.append(" punch_time_one,IF(punch_time_one IS TRUE,IF(DATE_FORMAT(punch_time_one,'%H:%i:%S')>'09:00:00','迟到','正常'),'未打卡') result1 ");
//        sb.append(" punch_time_two,IF(punch_time_two IS TRUE,IF(DATE_FORMAT(punch_time_two,'%H:%i:%S')<'12:00:00','早退','正常'),'未打卡') result2, ");
//        sb.append(" punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>'14:00:00','迟到','正常'),'未打卡') result3, ");
//        sb.append(" punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<'17:00:00','早退','正常'),'未打卡') result4 ");
        if (workTimeMethod==0) {
            sb.append(", punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<'17:00:00','早退','正常'),'未打卡') result4 ");
        }else if (workTimeMethod==2) {
            sb.append(", punch_time_two,IF(punch_time_two IS TRUE,IF(DATE_FORMAT(punch_time_two,'%H:%i:%S')<'12:00:00','早退','正常'),'未打卡') result2 ");
            sb.append(", punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>'14:00:00','迟到','正常'),'未打卡') result3 ");
            sb.append(", punch_time_four,IF(punch_time_four IS TRUE,IF(DATE_FORMAT(punch_time_four,'%H:%i:%S')<'17:00:00','早退','正常'),'未打卡') result4 ");
        }else if (workTimeMethod==3) {
            sb.append(", punch_time_three,IF(punch_time_three IS TRUE,IF(DATE_FORMAT(punch_time_three,'%H:%i:%S')>'14:00:00','迟到','正常'),'未打卡') result3 ");
        }
        sb.append(" FROM product_oa_punch_record ");
        sb.append(" WHERE DATE_FORMAT(created_utc_datetime,'%Y-%m')=? AND DATE_FORMAT(punch_time_one,'%Y-%m-%d') NOT IN(SELECT date_holiday FROM product_sys_company_holiday) ");
        sb.append(" )a  ");
        sb.append(" GROUP BY a.created_by,a.dept_uuid ");
        sb.append(" )a ");
        sb.append(" LEFT JOIN (SELECT user_id,sum(total_hours)total_hours FROM product_oa_work_overtime WHERE flow_flag=2 AND DATE_FORMAT(start_time,'%Y-%m')=? GROUP BY user_id)b  ");
        sb.append(" ON a.created_by=b.user_id ");
        sb.append(" LEFT JOIN ( ");
        sb.append(" SELECT ");
        sb.append(" created_by,sum(IF(leave_type=1,TRUE,0))casual_leave,sum(IF(leave_type=2,TRUE,0))medical_leave, ");
        sb.append(" sum(IF(leave_type=9,TRUE,0))marriage_leave,sum(IF(leave_type=4,TRUE,0))paid_leave, ");
        sb.append(" sum(IF(leave_type!=1 && leave_type!=2 && leave_type!=4 && leave_type!=9,TRUE,0))other_leave ");
        sb.append(" FROM product_oa_ask_for_leave ");
        sb.append(" WHERE DATE_FORMAT(start_time,'%Y-%m')=? ");
        sb.append(" GROUP BY created_by ");
        sb.append(" )c ");
        sb.append(" ON a.created_by=c.created_by ");
        sb.append(" ORDER BY dept_uuid,a.created_by ");
        return baseDao.listTable(sb.toString(), param.toArray());
        return  dataTableEntity1;
    }
}
src/main/java/com/product/administration/service/ide/IConferenceManagerService.java
@@ -1,7 +1,10 @@
package com.product.administration.service.ide;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import java.util.List;
/**
 * 会议室管理
@@ -29,4 +32,9 @@
    boolean delConferenceApply(FieldSetEntity fse)throws BaseException;
    List getKbData(FieldSetEntity fse)throws  BaseException;
    DataTableEntity  getMeetingDetails(FieldSetEntity fse)throws  BaseException;
}
src/main/java/com/product/administration/service/ide/IEarlyWarningManager.java
@@ -7,30 +7,30 @@
import com.product.core.exception.BaseException;
public interface IEarlyWarningManager {
    /**
     *     预警配置新增
     * @param fse
     * @return
     */
    String addWarning(FieldSetEntity fse) throws BaseException, SchedulerException, TaskException;
    /**
     *     预警配置修改
     * @param fse
     * @return
     * @throws TaskException
     * @throws SchedulerException
     * @throws BaseException
     * @throws TaskException
     * @throws SchedulerException
     * @throws BaseException
     */
    boolean updateWarning(FieldSetEntity fse) throws BaseException, SchedulerException, TaskException;
    /**
     *     预警配置删除
     * @param uuid
     * @return
     * @throws SchedulerException
     * @throws BaseException
     * @throws SchedulerException
     * @throws BaseException
     */
    boolean deleteWarning(String uuid) throws BaseException, SchedulerException;
@@ -42,4 +42,10 @@
     * @throws BaseException
     */
    boolean updateEarlyWarningTime(FieldSetEntity fse)throws BaseException, SchedulerException, TaskException;
    /**
     * 转发
     * @param fse
     */
    void transmit(FieldSetEntity fse);
}