|
|
@ -0,0 +1,569 @@
|
|
|
|
|
|
|
|
package com.engine.attendance.component.AttendanceItem.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.attendance.component.AttendanceItem.service.AttendanceItemService;
|
|
|
|
|
|
|
|
import com.engine.common.util.CommonUtil;
|
|
|
|
|
|
|
|
import com.engine.common.util.DateUtil;
|
|
|
|
|
|
|
|
import com.engine.common.util.DbTools;
|
|
|
|
|
|
|
|
import com.engine.common.util.Utils;
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @Author: sy
|
|
|
|
|
|
|
|
* @Description: 考勤项目
|
|
|
|
|
|
|
|
* @Date: 2024/6/17
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
|
|
public class AttendanceItemServiceImpl extends Service implements AttendanceItemService {
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public Map<String, Object> createAttendanceItem(Map<String, Object> params) {
|
|
|
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
// // 如果 sffzcx 是否分组呈现 字段值为1,即根据选择的多个作用时段生成 n+1 笔考勤项目记录
|
|
|
|
|
|
|
|
// String sffzcx = Util.null2String(params.get("sffzcx"));
|
|
|
|
|
|
|
|
// //判断入参中,考勤项目名称是否有重名
|
|
|
|
|
|
|
|
// String mc = Util.null2String(params.get("mc"));
|
|
|
|
|
|
|
|
// if ("".equals(mc)) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目名称不可为空!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// String sql = "select mc from uf_jcl_kq_kqxm";
|
|
|
|
|
|
|
|
// List<Map<String, Object>> data = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// List<String> mcList = data.stream()
|
|
|
|
|
|
|
|
// .map(map -> Util.null2String(map.get("mc")))
|
|
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
|
|
// if (mcList.contains(mc)) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目名称已存在,不可创建重复名称的项目!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //查询formmodeid
|
|
|
|
|
|
|
|
// Map<String,String> formModeIdMap = Utils.getFormmodeIdMap();
|
|
|
|
|
|
|
|
// String formModeId = formModeIdMap.get("uf_jcl_kq_kqxm");
|
|
|
|
|
|
|
|
// params.put("formmodeid",formModeId);
|
|
|
|
|
|
|
|
// params.put("modeuuid", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
// params.put("modedatacreater","1");
|
|
|
|
|
|
|
|
// params.put("modedatacreatertype","0");
|
|
|
|
|
|
|
|
// params.put("modedatacreatedate", DateUtil.getCurrentTime().split(" ")[0]);
|
|
|
|
|
|
|
|
// params.put("modedatacreatetime",DateUtil.getCurrentTime().split(" ")[1]);
|
|
|
|
|
|
|
|
// boolean insertMainItemSign = CommonUtil.makeInsertSql("uf_jcl_kq_kqxm", params);
|
|
|
|
|
|
|
|
// if ("1".equals(sffzcx)) {
|
|
|
|
|
|
|
|
// //先新增主考勤项目
|
|
|
|
|
|
|
|
// if (!insertMainItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "主考勤项目新增失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //查询主考勤项目id
|
|
|
|
|
|
|
|
// String mainItemId;
|
|
|
|
|
|
|
|
// sql = "select id, mc from uf_jcl_kq_kqxm where mc = " + mc;
|
|
|
|
|
|
|
|
// List<Map<String, Object>> mainItemData = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// if (mainItemData.size() == 1) {
|
|
|
|
|
|
|
|
// mainItemId = Util.null2String(mainItemData.get(0).get("id"));
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "主考勤项目新增成功,但再次查询后不唯一或不存在!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //再新增子考勤项目
|
|
|
|
|
|
|
|
// //主考勤项目作用时段
|
|
|
|
|
|
|
|
// String zysd = Util.null2String(params.get("zysd"));
|
|
|
|
|
|
|
|
// List<String> childrenItemZysdList = Arrays.asList(zysd.split(","));
|
|
|
|
|
|
|
|
// //作用时段至少勾选两个时,才创建子考勤项目
|
|
|
|
|
|
|
|
// if (!"".equals(zysd) && childrenItemZysdList.size() > 1) {
|
|
|
|
|
|
|
|
// List<Map<String,Object>> childrenItemList = new ArrayList<>();
|
|
|
|
|
|
|
|
// Map<String,Object> childItem;
|
|
|
|
|
|
|
|
// String childItemMc;
|
|
|
|
|
|
|
|
// for (String itemZtsd : childrenItemZysdList) {
|
|
|
|
|
|
|
|
// childItem = new HashMap<>(params);
|
|
|
|
|
|
|
|
//// childItem = params;
|
|
|
|
|
|
|
|
// //校验子考勤项目名称唯一性
|
|
|
|
|
|
|
|
// childItemMc = mc + "_" + itemZtsd;
|
|
|
|
|
|
|
|
// while(mcList.contains(childItemMc)) {
|
|
|
|
|
|
|
|
// childItemMc = childItemMc + "_" + itemZtsd;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //设置子考勤项目部分字段:名称、上级项目、是否分组呈现
|
|
|
|
|
|
|
|
// childItem.put("mc", childItemMc);
|
|
|
|
|
|
|
|
// childItem.put("sjxm", mainItemId);
|
|
|
|
|
|
|
|
// childItem.put("sffzcx", "0");
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// childItem.put("modeuuid", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
// childrenItemList.add(childItem);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// boolean insertChildItemSign = CommonUtil.insertBatch(childrenItemList, "uf_jcl_kq_kqxm");
|
|
|
|
|
|
|
|
// result.put("status", insertChildItemSign);
|
|
|
|
|
|
|
|
// result.put("message", insertChildItemSign ? "主、子考勤项目新增成功。" : "子考勤项目新增失败!");
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// result.put("status", true);
|
|
|
|
|
|
|
|
// result.put("message", "主考勤项目新增成功,同时作用时段小于两个,不需要创建子考勤项目。");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// result.put("status", insertMainItemSign);
|
|
|
|
|
|
|
|
// result.put("message", insertMainItemSign ? "考勤项目新增成功。" : "考勤项目新增失败!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public Map<String, Object> editAttendanceItem(Map<String, Object> params) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
// //考勤项目id和上级项目id
|
|
|
|
|
|
|
|
// String id = Util.null2String(params.get("id"));
|
|
|
|
|
|
|
|
// String sjxmId = Util.null2String(params.get("sjxm"));
|
|
|
|
|
|
|
|
// String xmzt = Util.null2String(params.get("xmzt"));
|
|
|
|
|
|
|
|
// String sffzcx = Util.null2String(params.get("sffzcx"));
|
|
|
|
|
|
|
|
// //考勤项目作用时段
|
|
|
|
|
|
|
|
// String zysd = Util.null2String(params.get("zysd"));
|
|
|
|
|
|
|
|
// List<String> zysdList = Arrays.asList(zysd.split(","));
|
|
|
|
|
|
|
|
// if ("".equals(id)) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目id不可为空!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //获取当前数据库中考勤项目信息
|
|
|
|
|
|
|
|
// String sql = "select id, mc, zysd, xmzt from uf_jcl_kq_kqxm where id = " + id;
|
|
|
|
|
|
|
|
// Map<String, Object> oldItemData = DbTools.getSqlToMap(sql);
|
|
|
|
|
|
|
|
// String oldXmzt = Util.null2String(oldItemData.get("xmzt"));
|
|
|
|
|
|
|
|
// String oldZysd = Util.null2String(oldItemData.get("zysd"));
|
|
|
|
|
|
|
|
// List<String> oldZysdList = Arrays.asList(oldZysd.split(","));
|
|
|
|
|
|
|
|
// if (zysdList.size() == 0 || oldZysdList.size() == 0) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目编辑前后的作用时段都不应该为空,请检查!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //判断编辑的考勤项目是否有子考勤项目
|
|
|
|
|
|
|
|
// sql = "select id, mc from uf_jcl_kq_kqxm where sjxm = " + id;
|
|
|
|
|
|
|
|
// List<Map<String, Object>> childrenData = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// Map<String, String> childItemZysdToId = childrenData.stream().collect(Collectors.toMap(e->Util.null2String(e.get("zysd")),e->Util.null2String(e.get("id"))));
|
|
|
|
|
|
|
|
// Map<String,Object> condition = Maps.newHashMap();
|
|
|
|
|
|
|
|
// condition.put("id", id);
|
|
|
|
|
|
|
|
// boolean updateSign;
|
|
|
|
|
|
|
|
// /////////////////////
|
|
|
|
|
|
|
|
// boolean xmztNoChangeSign = xmzt.equals(oldXmzt);
|
|
|
|
|
|
|
|
// boolean zysdNoChangeSign = checkZysdNoChange(oldZysdList, zysdList);
|
|
|
|
|
|
|
|
// if ("1".equals(sffzcx)) {
|
|
|
|
|
|
|
|
// if (!sjxmId.equals("")) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "子考勤项目不允许分组呈现!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //分组呈现时,不需要进行1对多主子考勤项目逻辑处理的情况
|
|
|
|
|
|
|
|
// //a-失效->有效,作用时段不多于1个
|
|
|
|
|
|
|
|
// //b-失效->失效
|
|
|
|
|
|
|
|
// //c-有效->有效,作用时段无变化
|
|
|
|
|
|
|
|
// //e-有效->有效,变化前后,作用时段都不多于1个
|
|
|
|
|
|
|
|
// //f-有效->失效,前者的作用时段不多于1个
|
|
|
|
|
|
|
|
// boolean noNeedMainToChildDeal = ("1".equals(xmzt) && !xmztNoChangeSign && zysdList.size() <= 1)
|
|
|
|
|
|
|
|
// || ("0".equals(xmzt) && xmztNoChangeSign)
|
|
|
|
|
|
|
|
// || ("1".equals(xmzt) && xmztNoChangeSign && zysdNoChangeSign)
|
|
|
|
|
|
|
|
// || ("1".equals(xmzt) && xmztNoChangeSign && oldZysdList.size() <= 1 && zysdList.size() <= 1)
|
|
|
|
|
|
|
|
// || ("0".equals(xmzt) && !xmztNoChangeSign && oldZysdList.size() <= 1);
|
|
|
|
|
|
|
|
// //分组呈现时,需要进行1对多主子考勤项目逻辑处理的情况
|
|
|
|
|
|
|
|
// //a-失效->有效,作用时段多于1个
|
|
|
|
|
|
|
|
// //b-有效->有效,作用时段出现变化,且前后至少有一方作用时段多于一个
|
|
|
|
|
|
|
|
// //c-有效->失效,前者的作用时段多于1个
|
|
|
|
|
|
|
|
// boolean needMainToChildDeal = ("1".equals(xmzt) && !xmztNoChangeSign && zysdList.size() > 1)
|
|
|
|
|
|
|
|
// || ("1".equals(xmzt) && xmztNoChangeSign && (oldZysdList.size() > 1 || zysdList.size() > 1))
|
|
|
|
|
|
|
|
// || ("0".equals(xmzt) && !xmztNoChangeSign && oldZysdList.size() > 1);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (noNeedMainToChildDeal) {
|
|
|
|
|
|
|
|
// updateSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", params, condition));
|
|
|
|
|
|
|
|
// result.put("status", updateSign);
|
|
|
|
|
|
|
|
// result.put("message", updateSign ? "" : "主考勤项目更新失败!");
|
|
|
|
|
|
|
|
// } else if (needMainToChildDeal) {
|
|
|
|
|
|
|
|
// result = mainToChildItem(params, id, zysdList, oldZysdList, xmzt, condition, childItemZysdToId, oldItemData);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// if (!"".equals(sjxmId) && !zysdNoChangeSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "子考勤项目不允许更改作用时段!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //不分组呈现时
|
|
|
|
|
|
|
|
// //a-直接保存更新
|
|
|
|
|
|
|
|
// updateSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", params, condition));
|
|
|
|
|
|
|
|
// //b-有子考勤项目时,子考勤项目状态全部置为无效
|
|
|
|
|
|
|
|
// boolean reSetSign = true;
|
|
|
|
|
|
|
|
// if (childrenData.size() > 0) {
|
|
|
|
|
|
|
|
// String reSetXmztSql = "update uf_jcl_kq_kqxm set xmzt = 0 where sjxm = " + id;
|
|
|
|
|
|
|
|
// reSetSign = DbTools.update(reSetXmztSql);
|
|
|
|
|
|
|
|
// log.info("有子考勤项目时,子考勤项目状态全部置为无效,结果:{}", reSetSign);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //c-作为子考勤项目,同时项目状态变化时,已由产品确认,不更新主考勤项目的作用时段和是否分组呈现信息
|
|
|
|
|
|
|
|
// result.put("status", updateSign && reSetSign);
|
|
|
|
|
|
|
|
// result.put("message", (updateSign && reSetSign) ? "" : "不分组呈现时,考勤项目更新失败!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// private boolean checkZysdNoChange(List<String> oldZysdList, List<String> zysdList) {
|
|
|
|
|
|
|
|
// if (oldZysdList.size() != zysdList.size()) {
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// } else if (oldZysdList.size() > 0) {
|
|
|
|
|
|
|
|
// oldZysdList.removeAll(zysdList);
|
|
|
|
|
|
|
|
// return oldZysdList.size() == 0;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
|
|
|
// * 是否分组呈现字段为1的考勤项目,处理1对多子考勤项目情况时的逻辑
|
|
|
|
|
|
|
|
// * //a-失效->有效,作用时段多于1个
|
|
|
|
|
|
|
|
// * //b-有效->有效,作用时段出现变化,且前后至少有一方作用时段多于一个
|
|
|
|
|
|
|
|
// * //c-有效->失效,前者的作用时段多于1个
|
|
|
|
|
|
|
|
// * @param params 编辑后待更新数据
|
|
|
|
|
|
|
|
// * @param id 被编辑的考勤项目id
|
|
|
|
|
|
|
|
// * @param zysdList 作用时段列表
|
|
|
|
|
|
|
|
// * @param oldZysdList 更新前作用时段列表
|
|
|
|
|
|
|
|
// * @param xmzt 更新的项目状态
|
|
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// private Map<String, Object> mainToChildItem(Map<String, Object> params, String id, List<String> zysdList, List<String> oldZysdList,
|
|
|
|
|
|
|
|
// String xmzt, Map<String,Object> condition, Map<String, String> childItemZysdToId, Map<String, Object> oldItemData) {
|
|
|
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
// boolean reSetSign;
|
|
|
|
|
|
|
|
// String sql = "select mc from uf_jcl_kq_kqxm";
|
|
|
|
|
|
|
|
// List<Map<String, Object>> data = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// List<String> mcList = data.stream()
|
|
|
|
|
|
|
|
// .map(map -> Util.null2String(map.get("mc")))
|
|
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
|
|
// if ("1".equals(xmzt)) {
|
|
|
|
|
|
|
|
// String childItemMc;
|
|
|
|
|
|
|
|
// Map<String,Object> childItem;
|
|
|
|
|
|
|
|
// //项目状态有效
|
|
|
|
|
|
|
|
// if (childItemZysdToId.size() == 0) {
|
|
|
|
|
|
|
|
// //不存在子考勤项目
|
|
|
|
|
|
|
|
// //查询formmodeid
|
|
|
|
|
|
|
|
// Map<String,String> formModeIdMap = Utils.getFormmodeIdMap();
|
|
|
|
|
|
|
|
// String formModeId = formModeIdMap.get("uf_jcl_kq_kqxm");
|
|
|
|
|
|
|
|
// params.put("formmodeid",formModeId);
|
|
|
|
|
|
|
|
// params.put("modeuuid", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
// params.put("modedatacreater","1");
|
|
|
|
|
|
|
|
// params.put("modedatacreatertype","0");
|
|
|
|
|
|
|
|
// params.put("modedatacreatedate", DateUtil.getCurrentTime().split(" ")[0]);
|
|
|
|
|
|
|
|
// params.put("modedatacreatetime",DateUtil.getCurrentTime().split(" ")[1]);
|
|
|
|
|
|
|
|
// if (oldZysdList.size() <= 1) {
|
|
|
|
|
|
|
|
// //如果当前考勤项目的作用时段不超过一个,则将当前考勤项目作为子考勤项目,并拷贝编辑后数据作为主考勤项目
|
|
|
|
|
|
|
|
// //先将当前的考勤项目更新为子考勤项目,但是上级项目字段暂时无法设置
|
|
|
|
|
|
|
|
// childItem = oldItemData;
|
|
|
|
|
|
|
|
// String itemZtsd = oldZysdList.get(0);
|
|
|
|
|
|
|
|
// //校验子考勤项目名称唯一性
|
|
|
|
|
|
|
|
// childItemMc = params.get("mc") + "_" + itemZtsd;
|
|
|
|
|
|
|
|
// while(mcList.contains(childItemMc)) {
|
|
|
|
|
|
|
|
// childItemMc = childItemMc + "_" + itemZtsd;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //设置子考勤项目部分字段:名称、上级项目、是否分组呈现
|
|
|
|
|
|
|
|
// childItem.put("mc", childItemMc);
|
|
|
|
|
|
|
|
// childItem.put("sffzcx", "0");
|
|
|
|
|
|
|
|
// childItem.put("xmzt", "1");
|
|
|
|
|
|
|
|
// boolean updateOldItemSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", childItem, condition));
|
|
|
|
|
|
|
|
// log.info("将当前的考勤项目更新为子考勤项目结果:{}", updateOldItemSign);
|
|
|
|
|
|
|
|
// if (!updateOldItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "将当前的考勤项目更新为子考勤项目失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //新增主考勤项目
|
|
|
|
|
|
|
|
// boolean insertMainItemSign = CommonUtil.makeInsertSql("uf_jcl_kq_kqxm", params);
|
|
|
|
|
|
|
|
// log.info("新增主考勤项目-111结果:{}", insertMainItemSign);
|
|
|
|
|
|
|
|
// if (!insertMainItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "新增主考勤项目-111失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //查询主考勤项目的id
|
|
|
|
|
|
|
|
// sql = "select id from uf_jcl_kq_kqxm where mc = '" + params.get("mc") + "'";
|
|
|
|
|
|
|
|
// Map<String, Object> mainData = DbTools.getSqlToMap(sql);
|
|
|
|
|
|
|
|
// String mainId = Util.null2String(mainData.get("id"));
|
|
|
|
|
|
|
|
// //更新上面由老考勤项目转为子考勤项目中的上级项目字段
|
|
|
|
|
|
|
|
// sql = "update uf_jcl_kq_kqxm set sjxm = " + mainId + " where id = " + id;
|
|
|
|
|
|
|
|
// reSetSign = DbTools.update(sql);
|
|
|
|
|
|
|
|
// log.info("更新上面由老考勤项目转为子考勤项目中的上级项目字段结果:{}", reSetSign);
|
|
|
|
|
|
|
|
// if (!reSetSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "更新上面由老考勤项目转为子考勤项目中的上级项目字段失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //新增其他时段的子考勤项目
|
|
|
|
|
|
|
|
// params.put("sjxm", mainId);
|
|
|
|
|
|
|
|
// params.put("xmzt", "1");
|
|
|
|
|
|
|
|
// params.put("sffzcx", "0");
|
|
|
|
|
|
|
|
// zysdList = zysdList.stream().filter(f -> !oldZysdList.contains(f)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// List<Map<String,Object>> childrenItemList = new ArrayList<>();
|
|
|
|
|
|
|
|
// for (String zysd : zysdList) {
|
|
|
|
|
|
|
|
// childItem = new HashMap<>(params);
|
|
|
|
|
|
|
|
// childItem.put("modeuuid", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
// childItem.put("zysd", zysd);
|
|
|
|
|
|
|
|
// childrenItemList.add(childItem);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// boolean insertChildItemSign = CommonUtil.insertBatch(childrenItemList, "uf_jcl_kq_kqxm");
|
|
|
|
|
|
|
|
// log.info("新增其他时段的子考勤项目-111结果:{}", insertChildItemSign);
|
|
|
|
|
|
|
|
// if (!insertChildItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "新增其他时段的子考勤项目-111失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// //如果当前考勤项目的作用时段超过一个,则将当前考勤项目作为主考勤项目,并拷贝编辑后数据作为子考勤项目
|
|
|
|
|
|
|
|
// //更新主考勤项目
|
|
|
|
|
|
|
|
// boolean updateOldItemSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", params, condition));
|
|
|
|
|
|
|
|
// log.info("更新主考勤项目-111结果:{}", updateOldItemSign);
|
|
|
|
|
|
|
|
// if (!updateOldItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "更新主考勤项目-111失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //新增其他时段的子考勤项目
|
|
|
|
|
|
|
|
// params.put("sjxm", id);
|
|
|
|
|
|
|
|
// params.put("xmzt", "1");
|
|
|
|
|
|
|
|
// params.put("sffzcx", "0");
|
|
|
|
|
|
|
|
// List<Map<String,Object>> childrenItemList = new ArrayList<>();
|
|
|
|
|
|
|
|
// for (String zysd : zysdList) {
|
|
|
|
|
|
|
|
// childItem = new HashMap<>(params);
|
|
|
|
|
|
|
|
// childItem.put("modeuuid", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
// childItem.put("zysd", zysd);
|
|
|
|
|
|
|
|
// childrenItemList.add(childItem);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// boolean insertChildItemSign = CommonUtil.insertBatch(childrenItemList, "uf_jcl_kq_kqxm");
|
|
|
|
|
|
|
|
// log.info("新增其他时段的子考勤项目-222结果:{}", insertChildItemSign);
|
|
|
|
|
|
|
|
// if (!insertChildItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "新增其他时段的子考勤项目-222失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// //存在子考勤项目,
|
|
|
|
|
|
|
|
// //更新主考勤项目
|
|
|
|
|
|
|
|
// boolean updateOldItemSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", params, condition));
|
|
|
|
|
|
|
|
// log.info("更新主考勤项目-222结果:{}", updateOldItemSign);
|
|
|
|
|
|
|
|
// if (!updateOldItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "更新主考勤项目-222失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //对于老的作用时段不存在于新的作用时段中的部分相关的子考勤项目,置为无效;
|
|
|
|
|
|
|
|
// List<String> finalZysdList = zysdList;
|
|
|
|
|
|
|
|
// List<String> invalidZysdList = oldZysdList.stream().filter(f -> !finalZysdList.contains(f)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// if (invalidZysdList.size() > 0) {
|
|
|
|
|
|
|
|
// String reSetXmztSql = "update uf_jcl_kq_kqxm set xmzt = 0 where sjxm = " + id + " and zysd in ('" + String.join("','",invalidZysdList)+"')";
|
|
|
|
|
|
|
|
// reSetSign = DbTools.update(reSetXmztSql);
|
|
|
|
|
|
|
|
// log.info("对于老的作用时段不存在于新的作用时段中的部分相关的子考勤项目,置为无效,结果:{}", reSetSign);
|
|
|
|
|
|
|
|
// if (!reSetSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "对于老的作用时段不存在于新的作用时段中的部分相关的子考勤项目,置为无效失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //对于新的作用时段相关的子考勤项目,置为有效;
|
|
|
|
|
|
|
|
// if (zysdList.size() > 0) {
|
|
|
|
|
|
|
|
// String reSetXmztSql = "update uf_jcl_kq_kqxm set xmzt = 1 where sjxm = " + id + " and zysd in ('" + String.join("','",zysdList)+"')";
|
|
|
|
|
|
|
|
// reSetSign = DbTools.update(reSetXmztSql);
|
|
|
|
|
|
|
|
// log.info("对于新的作用时段相关的子考勤项目,置为有效,结果:{}", reSetSign);
|
|
|
|
|
|
|
|
// if (!reSetSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "对于新的作用时段相关的子考勤项目,置为有效失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //对于还未创建的子考勤项目,进行创建,并置为有效。
|
|
|
|
|
|
|
|
// List<String> waitCreateZysdList = zysdList.stream().filter(f -> childItemZysdToId.get(f) == null).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// if (waitCreateZysdList.size() > 0) {
|
|
|
|
|
|
|
|
// //新增其他时段的子考勤项目
|
|
|
|
|
|
|
|
// params.put("sjxm", id);
|
|
|
|
|
|
|
|
// params.put("xmzt", "1");
|
|
|
|
|
|
|
|
// params.put("sffzcx", "0");
|
|
|
|
|
|
|
|
// List<Map<String,Object>> childrenItemList = new ArrayList<>();
|
|
|
|
|
|
|
|
// for (String zysd : waitCreateZysdList) {
|
|
|
|
|
|
|
|
// childItem = new HashMap<>(params);
|
|
|
|
|
|
|
|
// childItem.put("modeuuid", UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
// childItem.put("zysd", zysd);
|
|
|
|
|
|
|
|
// childrenItemList.add(childItem);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// boolean insertChildItemSign = CommonUtil.insertBatch(childrenItemList, "uf_jcl_kq_kqxm");
|
|
|
|
|
|
|
|
// log.info("对于还未创建的子考勤项目,进行创建,并置为有效,结果:{}", insertChildItemSign);
|
|
|
|
|
|
|
|
// if (!insertChildItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "对于还未创建的子考勤项目,进行创建,并置为有效失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// //项目状态无效
|
|
|
|
|
|
|
|
// //更新主考勤项目
|
|
|
|
|
|
|
|
// boolean updateOldItemSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", params, condition));
|
|
|
|
|
|
|
|
// log.info("更新主考勤项目-333结果:{}", updateOldItemSign);
|
|
|
|
|
|
|
|
// if (!updateOldItemSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "更新主考勤项目-333失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //将可能存在的子考勤项目置为无效
|
|
|
|
|
|
|
|
// String reSetXmztSql = "update uf_jcl_kq_kqxm set xmzt = 0 where sjxm = " + id;
|
|
|
|
|
|
|
|
// reSetSign = DbTools.update(reSetXmztSql);
|
|
|
|
|
|
|
|
// log.info("将可能存在的子考勤项目置为无效结果:{}", reSetSign);
|
|
|
|
|
|
|
|
// if (!reSetSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "将可能存在的子考勤项目置为无效失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// result.put("status", true);
|
|
|
|
|
|
|
|
// result.put("message", "");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public Map<String, Object> delAttendanceItem(Map<String, Object> params) {
|
|
|
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
// //考勤项目id和上级项目id
|
|
|
|
|
|
|
|
// String id = Util.null2String(params.get("id"));
|
|
|
|
|
|
|
|
// String sjxmId = Util.null2String(params.get("sjxm"));
|
|
|
|
|
|
|
|
// //考勤项目作用时段
|
|
|
|
|
|
|
|
// String zysd = Util.null2String(params.get("zysd"));
|
|
|
|
|
|
|
|
// if ("".equals(id)) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目id不可为空!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //判断删除考勤项目是否有子考勤项目
|
|
|
|
|
|
|
|
// String sql = "select id, mc from uf_jcl_kq_kqxm where sjxm = " + id;
|
|
|
|
|
|
|
|
// List<Map<String, Object>> data = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// String delSql;
|
|
|
|
|
|
|
|
// if (data.size() == 0) {
|
|
|
|
|
|
|
|
// //删除一般考勤项目或子考勤项目
|
|
|
|
|
|
|
|
// delSql = "delete from uf_jcl_kq_kqxm where id = " + id;
|
|
|
|
|
|
|
|
// if (!"".equals(sjxmId)) {
|
|
|
|
|
|
|
|
// //删除子考勤项目前,还需要更新主考勤项目得作用时段
|
|
|
|
|
|
|
|
// sql = "select id, mc, zysd, sffzcx from uf_jcl_kq_kqxm where id = " + sjxmId;
|
|
|
|
|
|
|
|
// Map<String, Object> mainItemData = DbTools.getSqlToMap(sql);
|
|
|
|
|
|
|
|
// String mainZysd = Util.null2String(mainItemData.get("zysd"));
|
|
|
|
|
|
|
|
// List<String> mainZysdList = Arrays.asList(mainZysd.split(","));
|
|
|
|
|
|
|
|
// mainZysdList = mainZysdList.stream().filter(f -> !f.equals(zysd)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// String newMainSffzcx = mainZysdList.size() > 1 ? "1" : "0";
|
|
|
|
|
|
|
|
// String newMainZysd = String.join(",", mainZysdList);
|
|
|
|
|
|
|
|
// String updateSql = "update uf_jcl_kq_kqxm set zysd = " + newMainZysd + ", sffzcx = " + newMainSffzcx + " where id = " + sjxmId;
|
|
|
|
|
|
|
|
// boolean updateSign = DbTools.update(updateSql);
|
|
|
|
|
|
|
|
// log.info("删除子考勤项目前,更新主考勤项目updateSign:{}", updateSign);
|
|
|
|
|
|
|
|
// if (!updateSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "删除子考勤项目前,还需要更新主考勤项目得作用时段失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// boolean delSign = DbTools.update(delSql);
|
|
|
|
|
|
|
|
// log.info("删除一般考勤项目或子考勤项目delSign:{}", delSign);
|
|
|
|
|
|
|
|
// if (!delSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "删除一般考勤项目或子考勤项目失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// //删除主考勤项目,并同时删除若干子项目
|
|
|
|
|
|
|
|
// delSql = "delete from uf_jcl_kq_kqxm where id = " + id + " or sjxm = " + id;
|
|
|
|
|
|
|
|
// boolean delSign = DbTools.update(delSql);
|
|
|
|
|
|
|
|
// log.info("删除主考勤项目,并同时删除若干子项目delSign:{}", delSign);
|
|
|
|
|
|
|
|
// if (!delSign) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "删除主考勤项目,并同时删除若干子项目,失败!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// result.put("status", true);
|
|
|
|
|
|
|
|
// result.put("message", "删除成功。");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public Map<String, Object> batchDelAttendanceItem(Map<String, Object> params) {
|
|
|
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
// String ids = Util.null2String(params.get("ids"));
|
|
|
|
|
|
|
|
// int successNum = 0;
|
|
|
|
|
|
|
|
// int failNum = 0;
|
|
|
|
|
|
|
|
// List<String> failMessageList = new ArrayList<>();
|
|
|
|
|
|
|
|
// if (!"".equals(ids)) {
|
|
|
|
|
|
|
|
// String sql = "select id, mc, sjxm, zysd from uf_jcl_kq_kqxm where id in (" + ids + ") ";
|
|
|
|
|
|
|
|
// List<Map<String, Object>> dataList = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// for (Map<String, Object> param : dataList) {
|
|
|
|
|
|
|
|
// Map<String, Object> resultItem = delAttendanceItem(params);
|
|
|
|
|
|
|
|
// if (!"true".equals(Util.null2String(resultItem.get("status")))) {
|
|
|
|
|
|
|
|
// failNum++;
|
|
|
|
|
|
|
|
// failMessageList.add(Util.null2String(param.get("mc")) + ",删除失败原因:" + Util.null2String(resultItem.get("message")));
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// successNum++;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// result.put("successNum", successNum);
|
|
|
|
|
|
|
|
// result.put("failNum", failNum);
|
|
|
|
|
|
|
|
// result.put("failMessage", failMessageList);
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public Map<String, Object> reEditAttendanceItem(Map<String, Object> params) {
|
|
|
|
|
|
|
|
// Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
// String id = Util.null2String(params.get("id"));
|
|
|
|
|
|
|
|
// if ("".equals(id)) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目id必填!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //查询入库考勤项目数据
|
|
|
|
|
|
|
|
// String sql = "select id, mc, sjxm, zysd from uf_jcl_kq_kqxm where id = " + id;
|
|
|
|
|
|
|
|
// Map<String, Object> data = DbTools.getSqlToMap(sql);
|
|
|
|
|
|
|
|
// if (data.size() == 0) {
|
|
|
|
|
|
|
|
// result.put("status", false);
|
|
|
|
|
|
|
|
// result.put("message", "考勤项目不存在!");
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //获取上级项目id、项目状态、是否分组呈现、作用时段
|
|
|
|
|
|
|
|
// String sjxmId = Util.null2String(data.get("sjxm"));
|
|
|
|
|
|
|
|
// String xmzt = Util.null2String(data.get("xmzt"));
|
|
|
|
|
|
|
|
// String sffzcx = Util.null2String(data.get("sffzcx"));
|
|
|
|
|
|
|
|
// String zysd = Util.null2String(data.get("zysd"));
|
|
|
|
|
|
|
|
// List<String> zysdList = Arrays.asList(zysd.split(","));
|
|
|
|
|
|
|
|
// //判断编辑的考勤项目是否有子考勤项目
|
|
|
|
|
|
|
|
// sql = "select id, mc from uf_jcl_kq_kqxm where sjxm = " + id;
|
|
|
|
|
|
|
|
// List<Map<String, Object>> childrenData = DbTools.getSqlToList(sql);
|
|
|
|
|
|
|
|
// Map<String, String> childItemZysdToId = childrenData.stream().collect(Collectors.toMap(e->Util.null2String(e.get("zysd")),e->Util.null2String(e.get("id"))));
|
|
|
|
|
|
|
|
// Map<String,Object> condition = Maps.newHashMap();
|
|
|
|
|
|
|
|
// condition.put("id", id);
|
|
|
|
|
|
|
|
// boolean updateSign;
|
|
|
|
|
|
|
|
// //检查当前考勤项目是否分组呈现
|
|
|
|
|
|
|
|
// if ("1".equals(sffzcx)) {
|
|
|
|
|
|
|
|
// //分组呈现时,不需要进行1对多主子考勤项目逻辑处理的情况,todo,功能暂时不做了
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// //不分组呈现时
|
|
|
|
|
|
|
|
// //a-直接保存更新
|
|
|
|
|
|
|
|
// updateSign = DbTools.update(CommonUtil.makeUpdateSql("uf_jcl_kq_kqxm", params, condition));
|
|
|
|
|
|
|
|
// //b-有子考勤项目时,子考勤项目状态全部置为无效
|
|
|
|
|
|
|
|
// boolean reSetSign = true;
|
|
|
|
|
|
|
|
// if (childrenData.size() > 0) {
|
|
|
|
|
|
|
|
// String reSetXmztSql = "update uf_jcl_kq_kqxm set xmzt = 0 where sjxm = " + id;
|
|
|
|
|
|
|
|
// reSetSign = DbTools.update(reSetXmztSql);
|
|
|
|
|
|
|
|
// log.info("有子考勤项目时,子考勤项目状态全部置为无效,结果:{}", reSetSign);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //c-作为子考勤项目,同时项目状态变化时,已由产品确认,不更新主考勤项目的作用时段和是否分组呈现信息
|
|
|
|
|
|
|
|
// result.put("status", updateSign && reSetSign);
|
|
|
|
|
|
|
|
// result.put("message", (updateSign && reSetSign) ? "" : "不分组呈现时,考勤项目更新失败!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return null;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|