Преглед изворни кода

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

Administrator пре 4 година
родитељ
комит
106d3d66d4
18 измењених фајлова са 432 додато и 10 уклоњено
  1. 2 1
      boman-api/boman-domain/src/main/java/com.boman.domain/constant/FormDataConstant.java
  2. 21 0
      boman-api/boman-domain/src/main/java/com.boman.domain/constant/LeaveConst.java
  3. 9 0
      boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java
  4. 2 2
      boman-common/boman-common-datascope/src/main/java/com/boman/common/datascope/aspect/DataScopeAspect.java
  5. 38 0
      boman-web-core/src/main/java/com/boman/web/core/controller/CancelLeaveController.java
  6. 1 1
      boman-web-core/src/main/java/com/boman/web/core/controller/ImportExportExcelController.java
  7. 5 0
      boman-web-core/src/main/java/com/boman/web/core/controller/LeaveController.java
  8. 28 0
      boman-web-core/src/main/java/com/boman/web/core/mapper/LeaveMapper.java
  9. 60 2
      boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java
  10. 1 1
      boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java
  11. 13 0
      boman-web-core/src/main/java/com/boman/web/core/service/common/CommonServiceImpl.java
  12. 9 0
      boman-web-core/src/main/java/com/boman/web/core/service/common/ICommonService.java
  13. 42 0
      boman-web-core/src/main/java/com/boman/web/core/service/leave/LeaveService.java
  14. 121 0
      boman-web-core/src/main/java/com/boman/web/core/service/leave/LeaveServiceImpl.java
  15. 32 0
      boman-web-core/src/main/java/com/boman/web/core/service/update/BaseUpdateServiceImpl.java
  16. 11 0
      boman-web-core/src/main/java/com/boman/web/core/service/update/IBaseUpdateService.java
  17. 24 3
      boman-web-core/src/main/java/com/boman/web/core/utils/HandlerFormDataUtils.java
  18. 13 0
      boman-web-core/src/main/java/com/boman/web/core/utils/JSONObjectUtils.java

+ 2 - 1
boman-api/boman-domain/src/main/java/com.boman.domain/constant/FormDataConstant.java

@@ -90,6 +90,7 @@ public class FormDataConstant {
 
     public static final String CHAR = "char";
     public static final String DATETIME = "datetime";
+    public static final String DATE = "date";
     public static final String TIMESTAMP = "timestamp";
 
     /**  根据表名查询表单时,返回给前台的查询字段   */
@@ -150,7 +151,7 @@ public class FormDataConstant {
     public static final List<String> NEED_QUERY_DICT_LIST = Stream.of(RADIO, CHECKBOX, SELECT).collect(Collectors.toList());
 
     /**  需要转换时间类型的 */
-    public static final List<String> NEED_CONVERT_DATE_LIST = Stream.of(DATETIME).collect(Collectors.toList());
+    public static final List<String> NEED_CONVERT_DATE_LIST = Stream.of(DATETIME, DATE).collect(Collectors.toList());
 
     /**  hr 日志、基础信息..... */
     public static final String HR = "HR";

+ 21 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/constant/LeaveConst.java

@@ -16,4 +16,25 @@ public class LeaveConst {
 
     public static final String MONTH_LEAVE_COUNT = "month";
     public static final String YEAR_LEAVE_COUNT = "year";
+
+
+    /************ 销假标准表 ************/
+    public static final String ID = "id";
+    public static final String DEPT_ID = "dept_id";
+    /**
+     * 可销假时长(小时)
+     **/
+    public static final String OFFSET_TIME = "offset_time";
+    public static final String TABLE_NAME_OFFSET_LEAVEFROM_STANDARD = "offset_leavefrom_standard";
+
+
+    /************ 临时请假表 ************/
+    public static final String TABLE_NAME_BOMAN_TEMP_LEAVEFORM = "boman_temp_leaveform";
+    public static final String LEAVEFROM_USER_NAME = "leavefrom_user_name";
+    public static final String LEAVEFROM_TIME = "leavefrom_time";
+    /** 是否销假  Y N **/
+    public static final String LEAVE_STATUS = "leave_status";
+    public static final String Y = "Y";
+    public static final String N = "N";
+
 }

+ 9 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java

@@ -140,6 +140,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
     }
 
+    public static final String getTime1(final Date date) {
+
+        return dateTime1(date);
+    }
+
     public static final String dateTimeNow() {
         return dateTimeNow(YYYYMMDDHHMMSS);
     }
@@ -152,6 +157,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return parseDateToStr(YYYY_MM_DD, date);
     }
 
+    public static final String dateTime1(final Date date) {
+        return parseDateToStr(YYYY_MM_DD_HH_MM_SS, date);
+    }
+
     public static final String parseDateToStr(final String format, final Date date) {
         return new SimpleDateFormat(format).format(date);
     }

+ 2 - 2
boman-common/boman-common-datascope/src/main/java/com/boman/common/datascope/aspect/DataScopeAspect.java

@@ -81,11 +81,11 @@ public class DataScopeAspect
      */
     @AfterReturning(returning = "rvt", pointcut = "@annotation(com.boman.common.datascope.annotation.DataScope)")
     public Object AfterExec(JoinPoint joinPoint, Object rvt) {
-        System.out.println("AfterReturning增强:获取目标方法的返回值:" + rvt);
+//        System.out.println("AfterReturning增强:获取目标方法的返回值:" + rvt);
         MethodSignature signature = (MethodSignature) joinPoint.getSignature();
         Method method = signature.getMethod();
         String name = method.getName();
-        System.out.println("AfterReturning增强:获取目标方法的方法:" + name);
+//        System.out.println("AfterReturning增强:获取目标方法的方法:" + name);
         return rvt;
     }
 

+ 38 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/CancelLeaveController.java

@@ -0,0 +1,38 @@
+package com.boman.web.core.controller;
+
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.service.leave.LeaveService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @description 销假
+ * @author shiqian
+ * @date 2021年07月26日 13:46
+ **/
+@RestController
+@RequestMapping("cancel/leave")
+public class CancelLeaveController {
+
+    @Resource
+    private LeaveService leaveService;
+
+    /**
+     * 功能描述: 销假 (自己销自己的)
+     *
+     * @param idList idList
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @PostMapping
+    public AjaxResult cancelLeave(@RequestBody List<Long> idList) {
+        boolean leave = leaveService.cancelLeave(idList);
+        return leave ? AjaxResult.success() : AjaxResult.error();
+    }
+
+
+}

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/controller/ImportExportExcelController.java

@@ -16,7 +16,7 @@ import java.util.List;
  * @author shiqian
  * @date 2021年06月08日 09:31
  **/
-@RequestMapping("web-core/file/common")
+@RequestMapping("/file/common")
 @RestController
 public class ImportExportExcelController {
 

+ 5 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/LeaveController.java

@@ -31,4 +31,9 @@ public class LeaveController {
         Map<String, Integer> result = service.statisticByType(yyyy);
         return AjaxResult.success(result);
     }
+
+    @GetMapping("/statistic/count/staticLeave")
+    public AjaxResult staticLeave() {
+        return AjaxResult.success(service.statisticLeave());
+    }
 }

+ 28 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/LeaveMapper.java

@@ -0,0 +1,28 @@
+package com.boman.web.core.mapper;
+
+import org.apache.ibatis.annotations.SelectProvider;
+
+import javax.xml.crypto.Data;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public interface LeaveMapper {
+
+    @SelectProvider(type = LeaveMapper.SqlProvider.class, method = "statisticLeave")
+    Integer statisticLeave();
+
+    class SqlProvider {
+
+        public String statisticLeave() {
+            Date date = new Date();
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            return "SELECT (SELECT count(*) FROM leavefrom f WHERE f.status = 2 and '" + sdf.format(date) + "' "
+                    + " BETWEEN date_format(f.leavefrom_start_time, \"%Y-%m-%d\" ) "
+                    + " and date_format( f.leavefrom_end_time, \"%Y-%m-%d\" )) "
+                    + " + (SELECT count(*) FROM boman_temp_leaveform t WHERE  t.status = 2 and  '" + sdf.format(date) + "' "
+                    + " BETWEEN date_format(t.leavefrom_start_time, \"%Y-%m-%d\" ) "
+                    + " and date_format(t.leavefrom_end_time, \"%Y-%m-%d\" )) as count "
+                    + " FROM DUAL";
+        }
+    }
+}

+ 60 - 2
boman-web-core/src/main/java/com/boman/web/core/mapper/StandardlyMapper.java

@@ -29,8 +29,8 @@ public interface StandardlyMapper {
     Logger LOGGER = LoggerFactory.getLogger(StandardlyMapper.class);
 
 
-    /** {@link SqlProvider#update(java.util.Map)} */
-    @UpdateProvider(type = SqlProvider.class, method = "update")
+    /** {@link SqlProvider#updateById(java.util.Map)} */
+    @UpdateProvider(type = SqlProvider.class, method = "updateById")
     int updateById(@Param("tableName") String var1, @Param("model") JSONObject var2
             , @Param("pkName") String pkName, @Param("ids") Long[] ids);
 
@@ -236,6 +236,24 @@ public interface StandardlyMapper {
             "\tAND user_id = #{userId}")
     List<JSONObject> findDate(@Param("date")String date, @Param("userId")Long userId);
 
+    /**
+     * 功能描述: 通用修改  {@link SqlProvider#update(java.util.Map)}
+     *
+     * @param tableName      tableName
+     * @param packCommitData packCommitData
+     * @param condition      condition
+     * @return int
+     */
+    @UpdateProvider(type = SqlProvider.class, method = "update")
+    int update(@Param("tableName") String tableName, @Param("packCommitData") JSONObject packCommitData
+            , @Param("packColCondition") JSONObject packColCondition, @Param("condition") JSONObject condition);
+
+    /******************************************************  临时请假当月的总时长 ******************************************************/
+    /** {@link SqlProvider#sumBeforeTempLeaveTime(java.util.Map)}**/
+    @SelectProvider(type = SqlProvider.class, method = "sumBeforeTempLeaveTime")
+    String sumBeforeTempLeaveTime(@Param("username") String username, @Param("startTime") String startTime
+            , @Param("endTime") String endTime, @Param("idList") List<Long> idList);
+
     @SuppressWarnings("unchecked")
     class SqlProvider {
         static final String[] READONLY_COLUMNS = new String[]{"OWNERID", "OWNERNAME", "OWNERENAME", "CREATIONDATE", "ID"};
@@ -282,6 +300,33 @@ public interface StandardlyMapper {
         }
 
         public String update(Map<String, Object> para) {
+            String tableName = (String) para.get("tableName");
+            JSONObject packCommitData = (JSONObject) para.get("packCommitData");
+            JSONObject packColCondition = (JSONObject) para.get("packColCondition");
+
+            StringBuilder wholeSql = new StringBuilder();
+            wholeSql.append("update ").append(tableName).append(" set ");
+
+            for (Map.Entry<String, Object> entry : packCommitData.entrySet()) {
+                String key = entry.getKey();
+                Object valueObj = entry.getValue();
+                List<String> types = ((List<String>) valueObj);
+                /** {@link com.boman.web.core.utils.ColumnUtils.packColCondition} 这里是拼参数的地方 **/
+                Object value = types.get(0);
+                String queryType = types.get(1);
+                String columnType = types.get(2);
+                wholeSql.append(key).append(covert(queryType, columnType, key, value)).append(" , ");
+            }
+
+            wholeSql = new StringBuilder(StringUtils.substringBeforeLast(wholeSql.toString(), " , "));
+            packCondition(packColCondition, wholeSql);
+
+            String sqlStr = wholeSql.toString();
+            LOGGER.info("通用的更新sql语句为: {} \r\n 提交的数据为: {} \r\n 条件为: {}", sqlStr, packCommitData, packColCondition);
+            return sqlStr;
+        }
+
+        public String updateById(Map<String, Object> para) {
             String tableName = (String) para.get("tableName");
             JSONObject model = (JSONObject) para.get("model");
             String pkName = (String) para.get("pkName");
@@ -715,6 +760,19 @@ public interface StandardlyMapper {
             return sqlBuilder.toString();
         }
 
+        public String sumBeforeTempLeaveTime(Map<String, Object> params) {
+            String username = (String) params.get("username");
+            String startTime = (String) params.get("startTime");
+            String endTime = (String) params.get("endTime");
+            List<Long> idList = (List<Long>) params.get("idList");
+
+            String sql = String.format("select sum(leavefrom_time) from boman_temp_leaveform where leavefrom_user_name = '%s' and " +
+                            "leavefrom_start_time >= '%s' and leave_status = 'Y' and leavefrom_end_time <= '%s' and id not in (%s)"
+                    , username, startTime, endTime, ColumnUtils.joinList1(idList));
+            LOGGER.info("查找总销假时长sql:{}", sql);
+            return sql;
+        }
+
         /**
          * 功能描述: 判断传过来的值是否需要转义
          *

+ 1 - 1
boman-web-core/src/main/java/com/boman/web/core/service/TableServiceCmdService.java

@@ -261,7 +261,7 @@ public class TableServiceCmdService {
         rows.put(FormDataConstant.PAGE_TOTAL, total);
         rows.put(TABLE_HEAD_LIST, getTableHeadList(genTable));
         if (total <= 0) {
-            rows.put(FormDataConstant.PAGE_ROWS, null);
+            rows.put(FormDataConstant.PAGE_ROWS, Collections.EMPTY_LIST);
             return AjaxResult.success(rows);
         }
 

+ 13 - 0
boman-web-core/src/main/java/com/boman/web/core/service/common/CommonServiceImpl.java

@@ -5,8 +5,10 @@ import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.domain.GenTable;
 import com.boman.domain.dto.FormDataDto;
+import com.boman.domain.dto.UpdateDto;
 import com.boman.web.core.service.TableServiceCmdService;
 import com.boman.web.core.service.select.IBaseSelectService;
+import com.boman.web.core.service.update.IBaseUpdateService;
 import com.boman.web.core.utils.IdUtils;
 import org.springframework.stereotype.Service;
 
@@ -26,6 +28,8 @@ public class CommonServiceImpl implements ICommonService {
     @Resource
     private IBaseSelectService selectService;
     @Resource
+    private IBaseUpdateService updateService;
+    @Resource
     private RedisService redisService;
     @Resource
     private TableServiceCmdService cmdService;
@@ -105,4 +109,13 @@ public class CommonServiceImpl implements ICommonService {
         requireNonNull(tableName, "tableName is empty");
         return selectService.getNewest(tableName);
     }
+
+    @Override
+    public int update(UpdateDto dto) {
+        String tableName = requireNonNull(dto.getTableName(), "tableName is empty");
+        JSONObject condition = requireNonNull(dto.getCondition(), "condition is empty, 条件为空不允许调用修改接口,防止误操作");
+        JSONObject commitData = requireNonNull(dto.getCommitData(), "commitData is empty");
+
+        return updateService.update(tableName, commitData, condition);
+    }
 }

+ 9 - 0
boman-web-core/src/main/java/com/boman/web/core/service/common/ICommonService.java

@@ -2,6 +2,7 @@ package com.boman.web.core.service.common;
 
 import com.alibaba.fastjson.JSONObject;
 import com.boman.domain.dto.FormDataDto;
+import com.boman.domain.dto.UpdateDto;
 
 import java.util.List;
 
@@ -56,4 +57,12 @@ public interface ICommonService {
      * @return com.alibaba.fastjson.JSONObject
      */
     JSONObject getNewest(String tableName);
+
+    /**
+     * 功能描述: 通用修改数据
+     *
+     * @param dto dto
+     * @return int
+     */
+    int update(UpdateDto dto);
 }

+ 42 - 0
boman-web-core/src/main/java/com/boman/web/core/service/leave/LeaveService.java

@@ -1,5 +1,9 @@
 package com.boman.web.core.service.leave;
 
+import com.alibaba.fastjson.JSONObject;
+
+import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -16,4 +20,42 @@ public interface LeaveService {
      * @return int
      */
     Map<String, Integer> statisticByType(String yyyy);
+
+    /**
+     * 当天请假人数
+     * @return
+     */
+    Integer statisticLeave();
+
+    /**
+     * 功能描述: 根据deptId获取销假标准
+     *
+     * @param deptId deptId
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    JSONObject getStandard(Long deptId);
+
+    /**
+     * 功能描述: 根据id查找
+     *
+     * @param id id
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    JSONObject getTempLeave(Long id);
+
+    /**
+     * 功能描述: 拿到当前人,当月的总临时时长
+     *
+     * @param username username
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    BigDecimal sumBeforeTempLeaveTime(String username, String startTime, String endTime, List<Long> idList);
+
+    /**
+     * 功能描述: 销假 (自己销自己的)
+     *
+     * @param idList idList
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    boolean cancelLeave(List<Long> idList);
 }

+ 121 - 0
boman-web-core/src/main/java/com/boman/web/core/service/leave/LeaveServiceImpl.java

@@ -2,12 +2,21 @@ package com.boman.web.core.service.leave;
 
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.DateUtils;
+import com.boman.domain.dto.UpdateDto;
+import com.boman.system.api.model.LoginUser;
+import com.boman.web.core.mapper.LeaveMapper;
+import com.boman.web.core.mapper.StandardlyMapper;
 import com.boman.web.core.service.common.ICommonService;
+import com.boman.web.core.utils.AuthUtils;
+import com.boman.web.core.utils.JSONObjectUtils;
+import org.apache.commons.collections4.MapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.sql.Timestamp;
 import java.util.Date;
 import java.util.HashMap;
@@ -30,6 +39,11 @@ public class LeaveServiceImpl implements LeaveService {
 
     @Resource
     private ICommonService commonService;
+    @Resource
+    private StandardlyMapper standardlyMapper;
+
+    @Autowired
+    private LeaveMapper leaveMapper;
 
     /**
      * 功能描述: 直接查询一年的
@@ -68,6 +82,17 @@ public class LeaveServiceImpl implements LeaveService {
         return map;
     }
 
+    /**
+     * 功能描述: 直接查询一年的
+     *
+     * @return int
+     */
+    @Override
+    public Integer statisticLeave() {
+        Integer count = leaveMapper.statisticLeave();
+        return count == null ? 0 : count;
+    }
+
     private List<JSONObject> listByTime(String startTime, String endTime) {
         JSONObject condition = new JSONObject();
         condition.put(LEAVEFROM_START_TIME, startTime);
@@ -75,5 +100,101 @@ public class LeaveServiceImpl implements LeaveService {
         return commonService.getByMap(TABLE_NAME, condition);
     }
 
+    /**
+     * 功能描述: 根据deptId获取销假标准
+     *
+     * @param deptId deptId
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    @Override
+    public JSONObject getStandard(Long deptId) {
+        requireNonNull(deptId, "deptId is empty");
+        JSONObject condition = new JSONObject();
+        condition.put(DEPT_ID, deptId);
+        JSONObject standard = commonService.getOneByMap(TABLE_NAME_OFFSET_LEAVEFROM_STANDARD, condition);
+        if (MapUtils.isEmpty(standard)) {
+            LOGGER.error(String.format("该部门 = [%s], 未配置销假标准", deptId));
+            throw new IllegalArgumentException("该人员所在部门未配置销假标准");
+        }
+
+        return standard;
+    }
+
+    /**
+     * 功能描述: 根据id查找
+     *
+     * @param id id
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    @Override
+    public JSONObject getTempLeave(Long id) {
+        requireNonNull(id, "tempLeave id is empty");
+
+        JSONObject tempLeave = commonService.getOneByMap(TABLE_NAME_BOMAN_TEMP_LEAVEFORM, JSONObjectUtils.putValue(ID, id));
+        if (MapUtils.isEmpty(tempLeave)) {
+            LOGGER.error(String.format("id = [%s]的临时请假数据不存在", id));
+            throw new IllegalArgumentException("临时请假数据不存在");
+        }
+
+        return tempLeave;
+    }
+
+    /**
+     * 功能描述: 拿到当前人,当月的总临时时长
+     *
+     * @param username username
+     * @return com.alibaba.fastjson.JSONObject
+     */
+    @Override
+    public BigDecimal sumBeforeTempLeaveTime(String username, String startTime, String endTime, List<Long> idList) {
+        requireNonNull(username, "sumBeforeTempLeaveTime username is empty");
+        requireNonNull(startTime, "sumBeforeTempLeaveTime startTime is empty");
+        requireNonNull(endTime, "sumBeforeTempLeaveTime endTime is empty");
+        requireNonNull(idList, "sumBeforeTempLeaveTime idList is empty");
+
+        String sum = standardlyMapper.sumBeforeTempLeaveTime(username, startTime, endTime, idList);
+        return isEmpty(sum) ? BigDecimal.ZERO : new BigDecimal(sum);
+    }
+
+    /**
+     * 功能描述: 销假 (自己销自己的)
+     *
+     * @param idList idList
+     * @return com.boman.domain.dto.AjaxResult
+     */
+    @Override
+    public boolean cancelLeave(List<Long> idList) {
+        requireNonNull(idList, "sumBeforeTempLeaveTime idList is empty");
+        LoginUser loginUser = AuthUtils.getLoginUser();
+        JSONObject jsonObject = getStandard(loginUser.getSysUser().getDeptId());
+        BigDecimal standard = jsonObject.getBigDecimal(OFFSET_TIME);
+
+        List<JSONObject> tempList = commonService.getByMap(TABLE_NAME_BOMAN_TEMP_LEAVEFORM,  JSONObjectUtils.putValue(ID, idList));
+
+        BigDecimal passDecimal = BigDecimal.ZERO;
+        for (JSONObject object : tempList) {
+            BigDecimal decimal = object.getBigDecimal(LEAVEFROM_TIME);
+            passDecimal = passDecimal.add(decimal);
+        }
+
+        String first = DateUtils.getFirstDayOfMonthStr();
+        String last = DateUtils.getLastDayOfMonthStr();
+        BigDecimal beforeSum = sumBeforeTempLeaveTime(loginUser.getUsername(), first, last, idList);
+        if ((beforeSum.add(passDecimal).subtract(standard)).compareTo(BigDecimal.ZERO) > 0) {
+            // 超过可销假时长
+            throw new IllegalArgumentException(String.format("超过本部门人员可销假总时长(%s h), 无法销假", standard));
+        }
+
+        // 修改状态
+        UpdateDto updateDto = new UpdateDto();
+        updateDto.setTableName(TABLE_NAME_BOMAN_TEMP_LEAVEFORM);
+        JSONObject commitData = JSONObjectUtils.putValue(LEAVE_STATUS, Y);
+        JSONObject condition = JSONObjectUtils.putValue(ID, idList);
+        updateDto.setCommitData(commitData);
+        updateDto.setCondition(condition);
+
+        int update = commonService.update(updateDto);
+        return update == idList.size();
+    }
 
 }

+ 32 - 0
boman-web-core/src/main/java/com/boman/web/core/service/update/BaseUpdateServiceImpl.java

@@ -2,6 +2,9 @@ package com.boman.web.core.service.update;
 
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.obj.ObjectUtils;
+import com.boman.common.redis.RedisKey;
+import com.boman.common.redis.service.RedisService;
+import com.boman.domain.GenTable;
 import com.boman.domain.GenTableColumn;
 import com.boman.web.core.domain.TableContext;
 import com.boman.web.core.mapper.StandardlyMapper;
@@ -11,6 +14,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.sql.Timestamp;
 import java.util.List;
 import java.util.Map;
@@ -30,6 +34,8 @@ public class BaseUpdateServiceImpl implements IBaseUpdateService {
 
     @Autowired
     private StandardlyMapper mapper;
+    @Resource
+    private RedisService redisService;
 
     /**
      * 功能描述: 批量修改, 默认需要更改的model,更改的字段类型和字段值都是一致的
@@ -53,6 +59,32 @@ public class BaseUpdateServiceImpl implements IBaseUpdateService {
         return mapper.updateByIdList(tableName, pkName, idList, commitData);
     }
 
+    /**
+     * 功能描述: 通用修改数据
+     *
+     * @param tableName  tableName
+     * @param commitData commitData
+     * @param condition  condition
+     * @return int
+     */
+    @Override
+    public int update(String tableName, JSONObject commitData, JSONObject condition) {
+        requireNonNull(tableName, "tableName is empty");
+        requireNonNull(condition, "condition is empty, 条件为空不允许调用修改接口,防止误操作");
+        requireNonNull(commitData, "commitData is empty");
+
+        GenTable genTable = redisService.getCacheObject(RedisKey.TABLE_INFO + tableName);
+        List<GenTableColumn> columns = genTable.getColumns();
+        Timestamp currentTime = new Timestamp(System.currentTimeMillis());
+
+        ColumnUtils.packUpdateByAndTime(columns, commitData, currentTime, false);
+
+        JSONObject packColCondition = ColumnUtils.packColCondition(columns, condition);
+        JSONObject packCommitData = ColumnUtils.packColCondition(columns, commitData);
+
+        return mapper.update(tableName, packCommitData, packColCondition, condition);
+    }
+
     private JSONObject escapeByQueryType(List<GenTableColumn> columns, JSONObject commitData) {
         requireNonNull(columns, "columns is empty");
         JSONObject result = new JSONObject(columns.size());

+ 11 - 0
boman-web-core/src/main/java/com/boman/web/core/service/update/IBaseUpdateService.java

@@ -1,5 +1,6 @@
 package com.boman.web.core.service.update;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.web.core.domain.TableContext;
 
 import java.util.List;
@@ -18,4 +19,14 @@ public interface IBaseUpdateService {
      * @return int
      */
     int updateByIdList(TableContext context, List<Long> idList);
+
+    /**
+     * 功能描述: 通用修改数据
+     *
+     * @param tableName  tableName
+     * @param commitData commitData
+     * @param condition  condition
+     * @return int
+     */
+    int update(String tableName, JSONObject commitData, JSONObject condition);
 }

+ 24 - 3
boman-web-core/src/main/java/com/boman/web/core/utils/HandlerFormDataUtils.java

@@ -23,6 +23,7 @@ import java.util.*;
 
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 import static com.boman.domain.constant.FormDataConstant.*;
+import static com.boman.domain.constant.FormDataConstant.DATE;
 import static com.boman.web.core.utils.JSONObjectUtils.containsKeyIgnoreCase;
 
 /**
@@ -83,15 +84,35 @@ public class HandlerFormDataUtils {
 
         for (JSONObject jsonObject : result) {
             for (GenTableColumn column : allColumns) {
-                String columnName = column.getColumnName();
-                String columnType = column.getColumnType();
-                if (containsKeyIgnoreCase(jsonObject, columnName) && NEED_CONVERT_DATE_LIST.contains(columnType)) {
+                String columnName = column.getColumnName(), columnType = column.getColumnType();
+
+                if (!containsKeyIgnoreCase(jsonObject, columnName)) {
+                    continue;
+                }
+
+                if (DATE.equals(columnType)) {
                     jsonObject.put(columnName, getStrDate(jsonObject.getTimestamp(columnName)));
+                } else if (DATETIME.equals(columnType)) {
+                    jsonObject.put(columnName, getStrTimeStamp(jsonObject.getTimestamp(columnName)));
                 }
             }
         }
     }
 
+    /**
+     * 功能描述: yyyy-MM-dd
+     *
+     * @param date date
+     * @return java.lang.String
+     */
+    public static String getStrTimeStamp(Date date) {
+        if (null == date) {
+            return null;
+        }
+
+        return DateUtils.getTime1(date);
+    }
+
     /**
      * 功能描述: 处理外键
      *

+ 13 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/JSONObjectUtils.java

@@ -16,5 +16,18 @@ public class JSONObjectUtils {
         return json.containsKey(key.toLowerCase()) || json.containsKey(key.toUpperCase());
     }
 
+    public static JSONObject putValue(String key, Object value) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put(key, value);
+        return jsonObject;
+    }
+
+    public static JSONObject putValue(String key1, Object value1, String key2, Object value2) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put(key1, value1);
+        jsonObject.put(key2, value2);
+        return jsonObject;
+    }
+
 
 }