浏览代码

处理作息配置接口超时问题

jingyuanchao 1 年之前
父节点
当前提交
4d55133caa

+ 7 - 3
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysWorkTimeSetDayofweekMapper.java

@@ -1,9 +1,10 @@
 package com.xunmei.system.mapper;
 
-import java.util.List;
-
-import com.xunmei.system.domain.SysWorkTimeSetDayofweek;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.system.domain.SysWorkTimeSetDayofweek;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 【请填写功能名称】Mapper接口
@@ -59,4 +60,7 @@ public interface SysWorkTimeSetDayofweekMapper extends BaseMapper<SysWorkTimeSet
      * @return 结果
      */
      int deleteSysWorkTimeSetDayofweekByIds(Long[] ids);
+
+    int batchInsertByXML(@Param("list") List<SysWorkTimeSetDayofweek> list);
+    int batchUpdateByXML(@Param("list") List<SysWorkTimeSetDayofweek> list);
 }

+ 11 - 6
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysWorkTimeSetMapper.java

@@ -1,19 +1,17 @@
 package com.xunmei.system.mapper;
 
-import java.util.Date;
-import java.util.List;
-
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
 import com.xunmei.system.domain.SysWorkTimeSet;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * 作息设置Mapper接口
  *
@@ -37,6 +35,8 @@ public interface SysWorkTimeSetMapper extends BaseMapper<SysWorkTimeSet> {
      */
     SysWorkTimeSet selectSysWorkTimeSetByOrgId(Long orgId);
 
+    SysWorkTimeSet selectSysWorkTimeSetByOrgIdLimit1(Long orgId);
+
     @MapKey("id")
      IPage<SysWorkTimeSet> selectByPage(Page<SysWorkTimeSet> page,SysWorkTimeSet sysWorkTimeSet );
 
@@ -84,4 +84,9 @@ public interface SysWorkTimeSetMapper extends BaseMapper<SysWorkTimeSet> {
      int deleteSysWorkTimeSetByIds(Long[] ids);
 
     Page<SysWorkTimeSet> selectWorkTimeSetPage(Page<SysWorkTimeSet> page, @Param(Constants.WRAPPER) Wrapper<SysWorkTimeSet> queryWrapper);
+
+    int batchInsertByXML(@Param("list") List<SysWorkTimeSet> list);
+    int batchUpdateByXML(@Param("list") List<SysWorkTimeSet> list);
+
+    List<SysWorkTimeSet> selectByOrgIdList(@Param("list") List<Long> list);
 }

+ 102 - 94
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysWorkTimeSetServiceImpl.java

@@ -8,17 +8,21 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.common.core.constant.CacheConstants;
 import com.xunmei.common.core.domain.worktime.domain.SysWorkTime;
+import com.xunmei.common.core.thread.ThreadPoolConfig;
 import com.xunmei.common.core.util.BeanHelper;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.utils.Ymd;
 import com.xunmei.common.core.utils.snowId.DateHelper;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.redis.utils.RedisUtils;
 import com.xunmei.common.security.utils.SecurityUtils;
-import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.vo.SysOrgVO;
 import com.xunmei.system.domain.SysWorkTimeSet;
 import com.xunmei.system.domain.SysWorkTimeSetDayofweek;
 import com.xunmei.system.mapper.SysWorkTimeMapper;
@@ -28,14 +32,19 @@ import com.xunmei.system.service.ISysOrgService;
 import com.xunmei.system.service.ISysWorkTimeService;
 import com.xunmei.system.service.ISysWorkTimeSetService;
 import com.xunmei.system.util.StreamHelper;
+import io.netty.util.internal.StringUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 import static com.xunmei.common.core.web.domain.AjaxResult.error;
@@ -47,6 +56,7 @@ import static com.xunmei.common.core.web.domain.AjaxResult.success;
  * @author xunmei
  * @date 2023-08-14
  */
+@Slf4j
 @Service
 public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper, SysWorkTimeSet> implements ISysWorkTimeSetService {
     @Autowired
@@ -59,6 +69,9 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
     private SysWorkTimeMapper sysWorkTimeMapper;
     @Autowired
     private ISysWorkTimeService workTimeService;
+    @Autowired
+    @Qualifier(ThreadPoolConfig.SOC_EXECUTOR)
+    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
 
     @Override
     public TableDataInfo<SysWorkTimeSet> selectPage(SysWorkTimeSet sysWorkTimeSet) {
@@ -345,28 +358,22 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
 //        if (CollectionUtils.isNotEmpty(orgIds)) {
         List<SysWorkTimeSet> sets = new ArrayList<>();
         SysWorkTimeSet set = null;
-        SysOrg org = null;
+        //此处应该判断缓存是否为空,但是若此处缓存为空,系统应该处于不可用的情况的,所以不判断了
+        List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
+        List<SysOrgVO> collect = cacheList.stream().filter(o -> orgIds.contains(o.getId())).collect(Collectors.toList());
         List<SysWorkTimeSetDayofweek> dayOfWeeks = new ArrayList<>();
-        Set<Long> workTimeSetIds = new HashSet<>();
+        List<SysWorkTimeSet> insertList = new ArrayList<>();
+        List<SysWorkTimeSet> updateList = new ArrayList<>();
+        List<SysWorkTimeSet> list = sysWorkTimeSetMapper.selectByOrgIdList(orgIds);
         for (Long orgId : orgIds) {
-
-            QueryWrapper<SysWorkTimeSet> qw = new QueryWrapper<>();
-            qw.lambda().eq(SysWorkTimeSet::getOrgId, orgId);
-            List<SysWorkTimeSet> list = sysWorkTimeSetMapper.selectList(qw);
-            if (list.isEmpty()) {
+            Optional<SysOrgVO> orgOptional = collect.stream().filter(o -> o.getId().equals(orgId)).findFirst();
+            set = list.stream().filter(f -> ObjectUtil.equal(f.getOrgId(), orgId)).findFirst().orElse(null);
+            if (set == null) {
                 set = new SysWorkTimeSet();
-                org = orgService.selectSysOrgById(orgId);
-            } else {
-                set = list.get(0);
+                set.setCreateTime(new Date());
+                set.setCreateBy(SecurityUtils.getUsername());
+                set.setOrgName(orgOptional.isPresent() ? orgOptional.get().getName() : StringUtil.EMPTY_STRING);
             }
-
-
-            /*if (request.getId() != null) {
-                set = sysWorkTimeSetMapper.selectById(request.getId());
-            } else {
-                set = new SysWorkTimeSet();
-                org = orgService.selectSysOrgById(orgId);
-            }*/
             BeanHelper.copyProperties(set, request);
             set.setOrgId(orgId);
             set.setYear((long) year);
@@ -374,41 +381,34 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
             set.setUpdateTime(new Date());
             set.setUpdateBy(SecurityUtils.getUsername());
             if (set.getId() == null) {
-                if (org != null) {
-                    set.setOrgName(org.getShortName());
-                }
-                set.setCreateTime(new Date());
-                set.setCreateBy(SecurityUtils.getUsername());
-                sysWorkTimeSetMapper.insert(set);
-
+                set.setId(IdWorker.getId());
+                insertList.add(set);
             } else {
-                sysWorkTimeSetMapper.updateById(set);
+                updateList.add(set);
             }
-
             Long id = set.getId();
-
-            List<SysWorkTimeSetDayofweek> tmp = request.getDayOfWeeks().stream().map(w -> {
-                SysWorkTimeSetDayofweek dw = new SysWorkTimeSetDayofweek();
-                BeanUtils.copyProperties(w, dw);
-                return dw;
-            }).collect(Collectors.toList());
-            tmp.forEach(w -> {
+            request.getDayOfWeeks().forEach(w -> {
                 w.setWorkTimeSetId(id);
             });
-
-            dayOfWeeks.addAll(tmp);
-            set.setDayOfWeeks(dayOfWeeks);
+            dayOfWeeks.addAll(request.getDayOfWeeks());
+            set.setDayOfWeeks(request.getDayOfWeeks());
             sets.add(set);
-            workTimeSetIds.add(id);
+        }
+
+        if (!insertList.isEmpty()) {
+            baseMapper.batchInsertByXML(insertList);
+        }
+        if (!updateList.isEmpty()) {
+            baseMapper.batchUpdateByXML(updateList);
         }
         //清除可能存在的旧作息数据
+        List<Long> workTimeSetIds = sets.stream().map(SysWorkTimeSet::getId).collect(Collectors.toList());
         sysWorkTimeSetDayofweekMapper.delete(new LambdaQueryWrapper<SysWorkTimeSetDayofweek>().in(SysWorkTimeSetDayofweek::getWorkTimeSetId, workTimeSetIds));
-        for (SysWorkTimeSetDayofweek s : dayOfWeeks) {
-            sysWorkTimeSetDayofweekMapper.insert(s);
-        }
+        sysWorkTimeSetDayofweekMapper.batchInsertByXML(dayOfWeeks);
         if (CollectionUtils.isNotEmpty(dayOfWeeks)) {
             changeOrgWorkTime(sets, request.getEffectiveDate(), orgIds);
         }
+
 //        }
         return success();
     }
@@ -506,7 +506,8 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
         }
     }
 
-    private void changeOrgWorkTime(List<SysWorkTimeSet> sets, Date effectiveDate, List<Long> orgIds) {
+    @Transactional(rollbackFor = Exception.class)
+    public void changeOrgWorkTime(List<SysWorkTimeSet> sets, Date effectiveDate, List<Long> orgIds) {
         //如果生效年份等于当前年份,那么就重新生成生效日期后当年以及下一年的作息时间
         int effectiveYear = new DateHelper(effectiveDate).getYear();
         int dateNowYear = new DateHelper(new Date()).getYear();
@@ -531,64 +532,71 @@ public class SysWorkTimeSetServiceImpl extends ServiceImpl<SysWorkTimeSetMapper,
             //添加当月生效日期后的作息时间及下个月的作息时间
             final List<DateTime> dateTimeList = DateUtil.rangeToList(effectiveDate, cal.getTime(), DateField.DAY_OF_MONTH);
             List<SysWorkTime> workTimeEditDtoListAll = new ArrayList<>();
-            for (SysWorkTimeSet workTime : sets) {
-                List<SysWorkTime> workTimeEditDtoList = new ArrayList<>();
-                for (DateTime time : dateTimeList) {
-                    Optional<SysWorkTimeSetDayofweek> dayOfWeekSetNew = workTime.getDayOfWeeks().stream().filter(w -> w.getDayOfWeek() == time.dayOfWeek()).findFirst();
-                    SysWorkTimeSetDayofweek dayOfWeekSet = dayOfWeekSetNew.orElse(null);
-                    boolean isEnable = ObjectUtil.isNotNull(dayOfWeekSet) && ObjectUtil.isNotNull(dayOfWeekSet.getIsWorkday()) && dayOfWeekSet.getIsWorkday() > 0;
-                    SysWorkTime dto = new SysWorkTime();
-                    dto.setDate(time);
-                    dto.setIsEnable(isEnable ? 1L : 0);
-                    dto.setIsDuty(ObjectUtil.isNotNull(dayOfWeekSet) ? dayOfWeekSet.getIsDuty() : null);
 
-                    if (ObjectUtil.isNull(dayOfWeekSet) || !(dayOfWeekSet.getIsWorkday() > 0)) {
-                        Optional<SysWorkTimeSetDayofweek> firstWorkDay = workTime.getDayOfWeeks().stream().filter(f -> f.getIsWorkday() > 0).findFirst();
-                        dayOfWeekSet = firstWorkDay.orElseGet(SysWorkTimeSetDayofweek::new);
-                    }
-                    dto.setWorkTime(dayOfWeekSet.getWorkTime());
-                    dto.setWorkOffTime(dayOfWeekSet.getWorkOffTime());
-                    dto.setOpenTime(dayOfWeekSet.getOpenTime());
-                    dto.setCloseTime(dayOfWeekSet.getCloseTime());
-                    dto.setNoonbreakStart(dayOfWeekSet.getNoonbreakStart());
-                    dto.setNoonbreakEnd(dayOfWeekSet.getNoonbreakEnd());
-                    workTimeEditDtoList.add(dto);
+            CompletableFuture.runAsync(() -> {
+                buildData(sets, effectiveDate, orgIds, dateTimeList, workTimeEditDtoListAll, list);
+            }, threadPoolTaskExecutor);
+        }
+    }
+
+    private void buildData(List<SysWorkTimeSet> sets, Date effectiveDate, List<Long> orgIds, List<DateTime> dateTimeList, List<SysWorkTime> workTimeEditDtoListAll, List<SysWorkTime> list) {
+        for (SysWorkTimeSet workTime : sets) {
+            List<SysWorkTime> workTimeEditDtoList = new ArrayList<>();
+            for (DateTime time : dateTimeList) {
+                Optional<SysWorkTimeSetDayofweek> dayOfWeekSetNew = workTime.getDayOfWeeks().stream().filter(w -> w.getDayOfWeek() == time.dayOfWeek()).findFirst();
+                SysWorkTimeSetDayofweek dayOfWeekSet = dayOfWeekSetNew.orElse(null);
+                boolean isEnable = ObjectUtil.isNotNull(dayOfWeekSet) && ObjectUtil.isNotNull(dayOfWeekSet.getIsWorkday()) && dayOfWeekSet.getIsWorkday() > 0;
+                SysWorkTime dto = new SysWorkTime();
+                dto.setDate(time);
+                dto.setIsEnable(isEnable ? 1L : 0);
+                dto.setIsDuty(ObjectUtil.isNotNull(dayOfWeekSet) ? dayOfWeekSet.getIsDuty() : null);
+
+                if (ObjectUtil.isNull(dayOfWeekSet) || !(dayOfWeekSet.getIsWorkday() > 0)) {
+                    Optional<SysWorkTimeSetDayofweek> firstWorkDay = workTime.getDayOfWeeks().stream().filter(f -> f.getIsWorkday() > 0).findFirst();
+                    dayOfWeekSet = firstWorkDay.orElseGet(SysWorkTimeSetDayofweek::new);
                 }
-                workTimeEditDtoListAll.addAll(workTimeEditDtoList);
+                dto.setWorkTime(dayOfWeekSet.getWorkTime());
+                dto.setWorkOffTime(dayOfWeekSet.getWorkOffTime());
+                dto.setOpenTime(dayOfWeekSet.getOpenTime());
+                dto.setCloseTime(dayOfWeekSet.getCloseTime());
+                dto.setNoonbreakStart(dayOfWeekSet.getNoonbreakStart());
+                dto.setNoonbreakEnd(dayOfWeekSet.getNoonbreakEnd());
+                workTimeEditDtoList.add(dto);
             }
-            if (CollectionUtils.isNotEmpty(workTimeEditDtoListAll)) {
-                SysWorkTimeSet requesta = new SysWorkTimeSet();
-                requesta.setOrgIds(orgIds);
-                //获取所有的作息配置
-                List<SysWorkTimeSet> listSet = sysWorkTimeSetMapper.selectWorkTimeSetList(requesta);
-                for (Long orgId : orgIds) {
-                    List<SysWorkTimeSet> listSetOrg = listSet.stream().filter(f -> f.getOrgId().equals(orgId) && f.getEffectiveDate().getTime() != effectiveDate.getTime()).collect(Collectors.toList());
-                    if (CollectionUtils.isNotEmpty(listSetOrg)) {
-                        List<Date> dateList = new ArrayList<>();
-                        dateList.add(effectiveDate);
-                        listSetOrg.forEach(f -> {
-                            dateList.add(f.getEffectiveDate());
-                        });
-                        //dateList排序
-                        dateList.sort(Comparator.comparing(Date::getTime));
-                        //取出request.getEffectiveDate()在dateList中的位置
-                        int index = dateList.indexOf(effectiveDate);
-                        if (index != dateList.size() - 1) {
-                            Date effectiveDateNext = dateList.get(index + 1);
-                            //取出workTimeEditDtoListAll中ymd_date在EffectiveDate和effectiveDateNext之间的数据
-                            List<SysWorkTime> workTimeEditDtoList = workTimeEditDtoListAll.stream().filter(f -> f.getDate().getTime() >= effectiveDate.getTime() && f.getDate().getTime() < effectiveDateNext.getTime()).collect(Collectors.toList());
-                            List<Date> remDates = workTimeEditDtoList.stream().map(SysWorkTime::getDate).collect(Collectors.toList());
-                            workTimeService.remove(new LambdaQueryWrapper<SysWorkTime>().eq(SysWorkTime::getOrgId, orgId).in(SysWorkTime::getYmdDate, remDates).eq(SysWorkTime::getIsManual, 0));
-                            batchnew(orgId, workTimeEditDtoList, list);
-                        } else {
-                            workTimeService.remove(new LambdaQueryWrapper<SysWorkTime>().eq(SysWorkTime::getOrgId, orgId).ge(SysWorkTime::getYmdDate, effectiveDate).eq(SysWorkTime::getIsManual, 0));
-                            batchnew(orgId, workTimeEditDtoListAll, list);
-                        }
+            workTimeEditDtoListAll.addAll(workTimeEditDtoList);
+        }
+        if (CollectionUtils.isNotEmpty(workTimeEditDtoListAll)) {
+            SysWorkTimeSet requesta = new SysWorkTimeSet();
+            requesta.setOrgIds(orgIds);
+            //获取所有的作息配置
+            List<SysWorkTimeSet> listSet = sysWorkTimeSetMapper.selectWorkTimeSetList(requesta);
+            for (Long orgId : orgIds) {
+                List<SysWorkTimeSet> listSetOrg = listSet.stream().filter(f -> f.getOrgId().equals(orgId) && f.getEffectiveDate().getTime() != effectiveDate.getTime()).collect(Collectors.toList());
+                if (CollectionUtils.isNotEmpty(listSetOrg)) {
+                    List<Date> dateList = new ArrayList<>();
+                    dateList.add(effectiveDate);
+                    listSetOrg.forEach(f -> {
+                        dateList.add(f.getEffectiveDate());
+                    });
+                    //dateList排序
+                    dateList.sort(Comparator.comparing(Date::getTime));
+                    //取出request.getEffectiveDate()在dateList中的位置
+                    int index = dateList.indexOf(effectiveDate);
+                    if (index != dateList.size() - 1) {
+                        Date effectiveDateNext = dateList.get(index + 1);
+                        //取出workTimeEditDtoListAll中ymd_date在EffectiveDate和effectiveDateNext之间的数据
+                        List<SysWorkTime> workTimeEditDtoList = workTimeEditDtoListAll.stream().filter(f -> f.getDate().getTime() >= effectiveDate.getTime() && f.getDate().getTime() < effectiveDateNext.getTime()).collect(Collectors.toList());
+                        List<Date> remDates = workTimeEditDtoList.stream().map(SysWorkTime::getDate).collect(Collectors.toList());
+                        workTimeService.remove(new LambdaQueryWrapper<SysWorkTime>().eq(SysWorkTime::getOrgId, orgId).in(SysWorkTime::getYmdDate, remDates).eq(SysWorkTime::getIsManual, 0));
+                        batchnew(orgId, workTimeEditDtoList, list);
                     } else {
+                        workTimeService.remove(new LambdaQueryWrapper<SysWorkTime>().eq(SysWorkTime::getOrgId, orgId).ge(SysWorkTime::getYmdDate, effectiveDate).eq(SysWorkTime::getIsManual, 0));
                         batchnew(orgId, workTimeEditDtoListAll, list);
                     }
-
+                } else {
+                    batchnew(orgId, workTimeEditDtoListAll, list);
                 }
+
             }
         }
     }

+ 80 - 0
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysWorkTimeSetDayofweekMapper.xml

@@ -158,4 +158,84 @@
             #{id}
         </foreach>
     </delete>
+
+    <insert id="batchInsertByXML">
+        INSERT INTO sys_work_time_set_dayofweek (
+        work_time_set_id,
+        is_workday,
+        day_of_week,
+        work_time,
+        open_time,
+        noonbreak_start,
+        noonbreak_end,
+        close_time,
+        work_off_time,
+        create_by,
+        update_by,
+        create_time,
+        update_time,
+        is_duty
+        ) VALUES
+        <foreach item="item" index="index" collection="list" separator=",">
+            (#{item.workTimeSetId},
+            #{item.isWorkday},
+            #{item.dayOfWeek},
+            #{item.workTime},
+            #{item.openTime},
+            #{item.noonbreakStart},
+            #{item.noonbreakEnd},
+            #{item.closeTime},
+            #{item.workOffTime},
+            #{item.createBy},
+            #{item.updateBy},
+            #{item.createTime},
+            #{item.updateTime},
+            #{item.isDuty})
+        </foreach>
+    </insert>
+
+    <update id="batchUpdateByXML">
+        <foreach item="item" index="index" collection="list" separator=";">
+            UPDATE sys_work_time_set_dayofweek
+            <set>
+                <if test="item.workTimeSetId != null">
+                    work_time_set_id = #{item.workTimeSetId},
+                </if>
+                <if test="item.isWorkday != null">
+                    is_workday = #{item.isWorkday},
+                </if>
+                <if test="item.dayOfWeek != null">
+                    day_of_week = #{item.dayOfWeek},
+                </if>
+                <if test="item.workTime != null and item.workTime != ''">
+                    work_time = #{item.workTime},
+                </if>
+                <if test="item.openTime != null and item.openTime != ''">
+                    open_time = #{item.openTime},
+                </if>
+                <if test="item.noonbreakStart != null and item.noonbreakStart != ''">
+                    noonbreak_start = #{item.noonbreakStart},
+                </if>
+                <if test="item.noonbreakEnd != null and item.noonbreakEnd != ''">
+                    noonbreak_end = #{item.noonbreakEnd},
+                </if>
+                <if test="item.closeTime != null and item.closeTime != ''">
+                    close_time = #{item.closeTime},
+                </if>
+                <if test="item.workOffTime != null and item.workOffTime != ''">
+                    work_off_time = #{item.workOffTime},
+                </if>
+                <if test="item.updateBy != null">
+                    update_by = #{item.updateBy},
+                </if>
+                <if test="item.updateTime != null">
+                    update_time = #{item.updateTime},
+                </if>
+                <if test="item.isDuty != null">
+                    is_duty = #{item.isDuty},
+                </if>
+            </set>
+            WHERE id = #{item.id}
+        </foreach>
+    </update>
 </mapper>

+ 156 - 0
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysWorkTimeSetMapper.xml

@@ -116,6 +116,11 @@
         <include refid="selectSysWorkTimeSetVo"/>
         where org_id = #{orgId}
     </select>
+    <select id="selectSysWorkTimeSetByOrgIdLimit1" parameterType="Long"
+            resultMap="SysWorkTimeSetResult">
+        <include refid="selectSysWorkTimeSetVo"/>
+        where org_id = #{orgId} limit 1
+    </select>
     <select id="selectByPage" resultType="com.xunmei.system.domain.SysWorkTimeSet">
 
 select  * from sys_work_time_set
@@ -350,4 +355,155 @@ select  * from sys_work_time_set
             #{id}
         </foreach>
     </delete>
+
+    <insert id="batchInsertByXML">
+        INSERT INTO sys_work_time_set (
+        id,
+        org_id,
+        org_name,
+        month_enable,
+        monday,
+        tuesday,
+        wednesday,
+        thursday,
+        friday,
+        saturday,
+        sunday,
+        work_time,
+        open_time,
+        noonbreak_start,
+        noonbreak_end,
+        close_time,
+        work_off_time,
+        create_time,
+        modified_id,
+        modified_name,
+        update_time,
+        year,
+        deleted,
+        effective_date,
+        create_by,
+        update_by
+        ) VALUES
+        <foreach item="item" index="index" collection="list" separator=",">
+            (#{item.id},
+            #{item.orgId},
+            #{item.orgName},
+            #{item.monthEnable},
+            #{item.monday},
+            #{item.tuesday},
+            #{item.wednesday},
+            #{item.thursday},
+            #{item.friday},
+            #{item.saturday},
+            #{item.sunday},
+            #{item.workTime},
+            #{item.openTime},
+            #{item.noonbreakStart},
+            #{item.noonbreakEnd},
+            #{item.closeTime},
+            #{item.workOffTime},
+            #{item.createTime},
+            #{item.modifiedId},
+            #{item.modifiedName},
+            #{item.updateTime},
+            #{item.year},
+            #{item.deleted},
+            #{item.effectiveDate},
+            #{item.createBy},
+            #{item.updateBy})
+        </foreach>
+
+    </insert>
+
+    <update id="batchUpdateByXML">
+        <foreach item="item" index="index" collection="list" separator=";">
+            UPDATE sys_work_time_set
+            <set>
+                <if test="item.orgId != null">
+                    org_id = #{item.orgId},
+                </if>
+                <if test="item.orgName != null">
+                    org_name = #{item.orgName},
+                </if>
+                <if test="item.monthEnable != null">
+                    month_enable = #{item.monthEnable},
+                </if>
+                <if test="item.monday != null">
+                    monday = #{item.monday},
+                </if>
+                <if test="item.tuesday != null">
+                    tuesday = #{item.tuesday},
+                </if>
+                <if test="item.wednesday != null">
+                    wednesday = #{item.wednesday},
+                </if>
+                <if test="item.thursday != null">
+                    thursday = #{item.thursday},
+                </if>
+                <if test="item.friday != null">
+                    friday = #{item.friday},
+                </if>
+                <if test="item.saturday != null">
+                    saturday = #{item.saturday},
+                </if>
+                <if test="item.sunday != null">
+                    sunday = #{item.sunday},
+                </if>
+                <if test="item.workTime != null and item.workTime != ''">
+                    work_time = #{item.workTime},
+                </if>
+                <if test="item.openTime != null and item.openTime != ''">
+                    open_time = #{item.openTime},
+                </if>
+                <if test="item.noonbreakStart != null and item.noonbreakStart != ''">
+                    noonbreak_start = #{item.noonbreakStart},
+                </if>
+                <if test="item.noonbreakEnd != null and item.noonbreakEnd != ''">
+                    noonbreak_end = #{item.noonbreakEnd},
+                </if>
+                <if test="item.closeTime != null and item.closeTime != ''">
+                    close_time = #{item.closeTime},
+                </if>
+                <if test="item.workOffTime != null and item.workOffTime != ''">
+                    work_off_time = #{item.workOffTime},
+                </if>
+                <if test="item.createTime != null">
+                    create_time = #{item.createTime},
+                </if>
+                <if test="item.modifiedId != null">
+                    modified_id = #{item.modifiedId},
+                </if>
+                <if test="item.modifiedName != null">
+                    modified_name = #{item.modifiedName},
+                </if>
+                <if test="item.updateTime != null">
+                    update_time = #{item.updateTime},
+                </if>
+                <if test="item.year != null">
+                    year = #{item.year},
+                </if>
+                <if test="item.deleted != null">
+                    deleted = #{item.deleted},
+                </if>
+                <if test="item.effectiveDate != null">
+                    effective_date = #{item.effectiveDate},
+                </if>
+                <if test="item.createBy != null">
+                    create_by = #{item.createBy},
+                </if>
+                <if test="item.updateBy != null">
+                    update_by = #{item.updateBy},
+                </if>
+            </set>
+            WHERE id = #{item.id}
+        </foreach>
+    </update>
+
+    <select id="selectByOrgIdList" resultMap="SysWorkTimeSetResult">
+        select * from sys_work_time_set where org_id in
+            <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+    </select>
 </mapper>