Commit e2d64218 authored by 李秀明's avatar 李秀明

fix(JCS#14822|#14821) 人员更换单位、执勤人员换车导致排班历史数据被修改

parent 24b24622
...@@ -2,8 +2,6 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -2,8 +2,6 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.CommonExplicitConstraint;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -28,40 +26,10 @@ public class DutyCarExcelDto implements Serializable { ...@@ -28,40 +26,10 @@ public class DutyCarExcelDto implements Serializable {
private Integer number; private Integer number;
@ExcelIgnore @ExcelIgnore
@ApiModelProperty(value = "消防队伍id")
private String teamId;
@ExcelProperty(value = "消防队伍", index = 1)
@ApiModelProperty(value = "消防队伍名称")
private String teamName;
@ExcelIgnore
@ApiModelProperty(value = "用户id")
private String userId;
@ExcelProperty(value = "姓名", index = 2)
@ApiModelProperty(value = "用户名称")
private String userName;
@ExcelIgnore
@ApiModelProperty(value = "岗位id")
private String postType;
@ExcelProperty(value = "岗位", index = 3)
@ApiModelProperty(value = "岗位名称")
private String postTypeName;
@ExcelIgnore
@ApiModelProperty(value = "车辆id") @ApiModelProperty(value = "车辆id")
private String carId; private String carId;
@ExplicitConstraint(indexNum = 4, sourceClass = CommonExplicitConstraint.class, method = "getCarList") //固定下拉内容 @ExcelProperty(value = "车辆名称", index = 1)
@ExcelProperty(value = "车辆名称(车牌)", index = 4)
@ApiModelProperty(value = "车辆名称") @ApiModelProperty(value = "车辆名称")
private String carName; private String carName;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15 }
@ExplicitConstraint(indexNum = 5, sourceClass = CommonExplicitConstraint.class, method = "getDutyArea") //固定下拉内容
@ExcelProperty(value = "值班区域", index = 5)
@ApiModelProperty(value = "值班区域")
private String dutyArea;
}
...@@ -34,26 +34,26 @@ public class DutyPersonExcelDto implements Serializable { ...@@ -34,26 +34,26 @@ public class DutyPersonExcelDto implements Serializable {
@ExcelProperty(value = "姓名", index = 2) @ExcelProperty(value = "姓名", index = 2)
@ApiModelProperty(value = "用户名称") @ApiModelProperty(value = "用户名称")
private String userName; private String userName;
//
@ExcelIgnore // @ExcelIgnore
@ApiModelProperty(value = "部门id") // @ApiModelProperty(value = "部门id")
private String deptId; // private String deptId;
//
@ExcelProperty(value = "单位/部门", index = 3) // @ExcelProperty(value = "单位/部门", index = 3)
@ApiModelProperty(value = "部门名称") // @ApiModelProperty(value = "部门名称")
private String deptName; // private String deptName;
//
@ExcelIgnore // @ExcelIgnore
@ApiModelProperty(value = "岗位id") // @ApiModelProperty(value = "岗位id")
private String postType; // private String postType;
//
@ExplicitConstraint(type = "DUTY_POST_TYPE", indexNum = 4, sourceClass = CommonExplicitConstraint.class) //动态下拉内容 // @ExplicitConstraint(type = "DUTY_POST_TYPE", indexNum = 4, sourceClass = CommonExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "岗位", index = 4) // @ExcelProperty(value = "岗位", index = 4)
@ApiModelProperty(value = "岗位名称") // @ApiModelProperty(value = "岗位名称")
private String postTypeName; // private String postTypeName;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15 // // 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint(indexNum = 5, sourceClass = CommonExplicitConstraint.class, method = "getDutyArea") //固定下拉内容 // @ExplicitConstraint(indexNum = 5, sourceClass = CommonExplicitConstraint.class, method = "getDutyArea") //固定下拉内容
@ExcelProperty(value = "值班区域", index = 5) // @ExcelProperty(value = "值班区域", index = 5)
@ApiModelProperty(value = "值班区域") // @ApiModelProperty(value = "值班区域")
private String dutyArea; // private String dutyArea;
} }
package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.CommonExplicitConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel(value = "TemplateDutyCarExcelDto", description = "值班车辆")
public class TemplateDutyCarExcelDto implements Serializable {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "序号", index = 0)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelIgnore
@ApiModelProperty(value = "消防队伍id")
private String teamId;
@ExcelProperty(value = "消防队伍", index = 1)
@ApiModelProperty(value = "消防队伍名称")
private String teamName;
@ExcelIgnore
@ApiModelProperty(value = "用户id")
private String userId;
@ExcelProperty(value = "姓名", index = 2)
@ApiModelProperty(value = "用户名称")
private String userName;
@ExcelIgnore
@ApiModelProperty(value = "岗位id")
private String postType;
@ExcelProperty(value = "岗位", index = 3)
@ApiModelProperty(value = "岗位名称")
private String postTypeName;
@ExcelIgnore
@ApiModelProperty(value = "车辆id")
private String carId;
@ExplicitConstraint(indexNum = 4, sourceClass = CommonExplicitConstraint.class, method = "getCarList") //固定下拉内容
@ExcelProperty(value = "车辆名称(车牌)", index = 4)
@ApiModelProperty(value = "车辆名称")
private String carName;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint(indexNum = 5, sourceClass = CommonExplicitConstraint.class, method = "getDutyArea") //固定下拉内容
@ExcelProperty(value = "值班区域", index = 5)
@ApiModelProperty(value = "值班区域")
private String dutyArea;
}
package com.yeejoin.amos.boot.module.common.api.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.excel.CommonExplicitConstraint;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel(value = "TemplateDutyPersonExcelDto", description = "值班人")
public class TemplateDutyPersonExcelDto implements Serializable {
@ExcelIgnore
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "序号", index = 0)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "用户ID", index = 1)
@ApiModelProperty(value = "用户id")
private String userId;
@ExcelProperty(value = "姓名", index = 2)
@ApiModelProperty(value = "用户名称")
private String userName;
@ExcelIgnore
@ApiModelProperty(value = "部门id")
private String deptId;
@ExcelProperty(value = "单位/部门", index = 3)
@ApiModelProperty(value = "部门名称")
private String deptName;
@ExcelIgnore
@ApiModelProperty(value = "岗位id")
private String postType;
@ExplicitConstraint(type = "DUTY_POST_TYPE", indexNum = 4, sourceClass = CommonExplicitConstraint.class) //动态下拉内容
@ExcelProperty(value = "岗位", index = 4)
@ApiModelProperty(value = "岗位名称")
private String postTypeName;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint(indexNum = 5, sourceClass = CommonExplicitConstraint.class, method = "getDutyArea") //固定下拉内容
@ExcelProperty(value = "值班区域", index = 5)
@ApiModelProperty(value = "值班区域")
private String dutyArea;
}
package com.yeejoin.amos.boot.module.common.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 值班人员日期日志表
*/
@Data
@Accessors(chain = true)
@TableName("cb_duty_person_shift_log")
public class DutyPersonShiftLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 实例ID
*/
@TableField("instance_id")
private Long instanceId;
/**
* 值班日期
*/
@TableField("duty_date")
private Date dutyDate;
/**
* 分组类型
*/
@TableField("group_code")
private String groupCode;
/**
* 消防队伍
*/
@TableField("dept_name")
private String deptName;
/**
* 值班人
*/
@TableField("duty_user_id")
private String dutyUserId;
/**
* 值班人
*/
@TableField("duty_user")
private String dutyUser;
/**
* 岗位
*/
@TableField("post_type_name")
private String postTypeName;
/**
* 值班区域
*/
@TableField("duty_area")
private String dutyArea;
/**
* 值班类型
*/
@TableField("shift_name")
private String shiftName;
/**
* 车辆名称
*/
@TableField("car_name")
private String carName;
}
package com.yeejoin.amos.boot.module.common.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShiftLog;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 值班人员日期日志表 Mapper 接口
*/
public interface DutyPersonShiftLogMapper extends BaseMapper<DutyPersonShiftLog> {
List<Map<String, String>> selectSpecificDateLogForCar(@Param("dutyDate") String dutyDate);
List<Map<String, String>> selectSpecificDateLogForPerson(@Param("dutyDate") String dutyDate);
List<Map<String, String>> selectSpecificDateLogForPersonGroupByPostTypeName(@Param("dutyDate") String dutyDate);
}
...@@ -11,6 +11,7 @@ import org.apache.poi.ss.formula.functions.T; ...@@ -11,6 +11,7 @@ import org.apache.poi.ss.formula.functions.T;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* 值班人员日期关联关系表 Mapper 接口 * 值班人员日期关联关系表 Mapper 接口
...@@ -66,7 +67,7 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> { ...@@ -66,7 +67,7 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
@Param("appKey") String appKey, @Param("appKey") String appKey,
@Param("groupCode") String groupCode @Param("groupCode") String groupCode
); );
List<Map<String, Object>> newStationViewData( List<Map<String, Object>> newStationViewData(
@Param("dutyDate") String dutyDate, @Param("dutyDate") String dutyDate,
@Param("groupCode") String groupCode @Param("groupCode") String groupCode
...@@ -97,7 +98,7 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> { ...@@ -97,7 +98,7 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
* @return * @return
*/ */
List<Map<String, Object>> getSpecifyDateList(String dutyDate,String groupCode,String[] instanceIds,String params); List<Map<String, Object>> getSpecifyDateList(String dutyDate,String groupCode,String[] instanceIds,String params);
/** /**
* 获取指定日期下的装备ID、eg:车辆、微型消防站 * 获取指定日期下的装备ID、eg:车辆、微型消防站
* @param dutyDate * @param dutyDate
...@@ -106,8 +107,8 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> { ...@@ -106,8 +107,8 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
* @return * @return
*/ */
List<Map<String, Object>> getEquipmentForSpecifyDate(String dutyDate,String groupCode,String equipmentId,String equipmentName,String teamName,String groupByName); List<Map<String, Object>> getEquipmentForSpecifyDate(String dutyDate,String groupCode,String equipmentId,String equipmentName,String teamName,String groupByName);
/** /**
* 通过装备ID查询指定如期下的该装备所包含的InstanceId * 通过装备ID查询指定如期下的该装备所包含的InstanceId
* @param dutyDate * @param dutyDate
...@@ -116,7 +117,7 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> { ...@@ -116,7 +117,7 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
* @return * @return
*/ */
Map<String, Object> getInstanceIdForSpecifyDateAndEquipment(String dutyDate,String groupCode,String targetId); Map<String, Object> getInstanceIdForSpecifyDateAndEquipment(String dutyDate,String groupCode,String targetId);
/** /**
* 获取指定日期装备的操作人员,例如车辆的驾驶员 * 获取指定日期装备的操作人员,例如车辆的驾驶员
* @param dutyDate * @param dutyDate
...@@ -126,8 +127,8 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> { ...@@ -126,8 +127,8 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
* @return * @return
*/ */
Map<String, Object> getEquipmentOperator(String dutyDate,String groupCode,String[] instanceIds,String operator,String duty); Map<String, Object> getEquipmentOperator(String dutyDate,String groupCode,String[] instanceIds,String operator,String duty);
/** /**
* 获取指定日期下的排班人员与岗位等信息 * 获取指定日期下的排班人员与岗位等信息
* @param dutyDate * @param dutyDate
...@@ -136,23 +137,25 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> { ...@@ -136,23 +137,25 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
* @return * @return
*/ */
List<Map<String, Object>> getPositionStaffDutyForSpecifyDate(String dutyDate,String groupCode,String[] instanceIds,String duty, String fieldCode); List<Map<String, Object>> getPositionStaffDutyForSpecifyDate(String dutyDate,String groupCode,String[] instanceIds,String duty, String fieldCode);
/** /**
* 获取指定日期下的班次信息 * 获取指定日期下的班次信息
* @param duty * @param duty
* @return * @return
*/ */
List<Map<String, Object>> getDutyForSpecifyDate(String duty); List<Map<String, Object>> getDutyForSpecifyDate(String duty);
Map<String, Object> getFireTeamBySequenceNbr (long sequenceNbr); Map<String, Object> getFireTeamBySequenceNbr (long sequenceNbr);
List<Map<String, Object>> getFirstAidForTypeCodeAndCompanyId(long company); List<Map<String, Object>> getFirstAidForTypeCodeAndCompanyId(long company);
List<Map<String, Object>> queryByCompanyId(@Param(value="bizNames") List<String> bizNames); List<Map<String, Object>> queryByCompanyId(@Param(value="bizNames") List<String> bizNames);
List<Map<String, Object>> queryByCompanyNew(String bizOrgName); List<Map<String, Object>> queryByCompanyNew(String bizOrgName);
List<DutyPersonShift> getOldDutyPersonShifts(String groupCode);
List<Map<String, Object>> getNewEquipmentForSpecifyDate(String dutyDate,String groupCode,String equipmentId,String equipmentName,String groupByName); List<Map<String, Object>> getNewEquipmentForSpecifyDate(String dutyDate,String groupCode,String equipmentId,String equipmentName,String groupByName);
......
...@@ -20,7 +20,7 @@ import java.util.Map; ...@@ -20,7 +20,7 @@ import java.util.Map;
*/ */
public interface OrgUsrMapper extends BaseMapper<OrgUsr> { public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
String selectUpUnitByParam(@Param("id")String biz_org_code); String selectUpUnitByParam(@Param("id")String biz_org_code);
int selectPersonListCount(@Param("map")Map<String, Object> map); int selectPersonListCount(@Param("map")Map<String, Object> map);
List<Map<String, Object>> selectPersonList(@Param("map")Map<String, Object> map); List<Map<String, Object>> selectPersonList(@Param("map")Map<String, Object> map);
...@@ -95,7 +95,7 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -95,7 +95,7 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
void updatelistByParentId(String codex, String code); void updatelistByParentId(String codex, String code);
List< Map<String,String>> getPersonSimpleDetail(); List< Map<String,String>> getPersonSimpleDetail();
List<Map<String, Long>> countDeptByCompanyId(@Param("companyIdList") List<String> companyIdList); List<Map<String, Long>> countDeptByCompanyId(@Param("companyIdList") List<String> companyIdList);
...@@ -137,4 +137,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -137,4 +137,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<DynamicFormInstance> checkCertificatesNumber(String certificatesNumber, Long orgUserId); List<DynamicFormInstance> checkCertificatesNumber(String certificatesNumber, Long orgUserId);
OrgUsr queryByCompanyCode(@Param("companyCode") String companyCode); OrgUsr queryByCompanyCode(@Param("companyCode") String companyCode);
List<Map<String, String>> selectUserDeptMap(@Param("ids") List<Long> userIds);
} }
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.common.api.service; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.common.api.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto;
import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -39,4 +40,6 @@ public interface IDutyCarService extends IDutyCommonService { ...@@ -39,4 +40,6 @@ public interface IDutyCarService extends IDutyCommonService {
//查询今日值班车辆 //查询今日值班车辆
List<Map<String, String>>getDutyCar(); List<Map<String, String>>getDutyCar();
void writeHistoryDutyLog();
} }
package com.yeejoin.amos.boot.module.common.api.service; package com.yeejoin.amos.boot.module.common.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import java.text.ParseException; import java.text.ParseException;
...@@ -134,13 +135,13 @@ public interface IDutyCommonService { ...@@ -134,13 +135,13 @@ public interface IDutyCommonService {
* @param startTime * @param startTime
*/ */
public void saveDutyPersonShiftDetail( Long instanceId ,List<DutyPersonShiftDto> dutyShift ,String startTime) ; public void saveDutyPersonShiftDetail( Long instanceId ,List<DutyPersonShiftDto> dutyShift ,String startTime) ;
/** /**
* 添加值班人的信息 可以保存空信息 * 添加值班人的信息 可以保存空信息
* @param instanceId * @param instanceId
* @param dutyShiftList * @param dutyShiftList
*/ */
public void insertPersonShift(Long instanceId, List<DutyPersonShiftDto> dutyShiftList,String type); public void insertPersonShift(Long instanceId, List<DutyPersonShiftDto> dutyShiftList,String type);
public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode); public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode);
} }
...@@ -37,4 +37,6 @@ public interface IDutyPersonService extends IDutyCommonService { ...@@ -37,4 +37,6 @@ public interface IDutyPersonService extends IDutyCommonService {
List<Map<String, Object>> queryByCompanyId(List<String> bizNames); List<Map<String, Object>> queryByCompanyId(List<String> bizNames);
List<Map<String, Object>> queryByCompanyNew(String bizOrgName); List<Map<String, Object>> queryByCompanyNew(String bizOrgName);
void writeHistoryDutyLog();
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper">
<select id="selectSpecificDateLogForCar" resultType="java.util.Map">
select
car_name AS carName,
dept_name AS teamName,
post_type_name as postTypeName,
group_concat(duty_user) AS dutyUsers
from
cb_duty_person_shift_log
where
group_code = 'dutyCar'
and duty_date = #{dutyDate}
group by
car_name, dept_name, post_type_name
</select>
<select id="selectSpecificDateLogForPerson" resultType="java.util.Map">
select
dept_name as deptName,
post_type_name as postTypeName,
group_concat(duty_user) AS dutyUsers
from
cb_duty_person_shift_log
where
group_code = 'dutyPerson'
and duty_date = #{dutyDate}
group by
dept_name, post_type_name
</select>
<select id="selectSpecificDateLogForPersonGroupByPostTypeName" resultType="java.util.Map">
select
post_type_name as postTypeName,
group_concat(duty_user) AS dutyUsers
from
cb_duty_person_shift_log
where
group_code = 'dutyPerson'
and duty_date = #{dutyDate}
group by
post_type_name
</select>
</mapper>
...@@ -245,7 +245,6 @@ ...@@ -245,7 +245,6 @@
cd.FIELD_VALUE cd.FIELD_VALUE
END END
) AS #{teamName} ) AS #{teamName}
FROM FROM
cb_dynamic_form_instance cd cb_dynamic_form_instance cd
LEFT JOIN ( LEFT JOIN (
...@@ -267,6 +266,20 @@ ...@@ -267,6 +266,20 @@
</if> </if>
</select> </select>
<select id="getOldDutyPersonShifts" resultType='com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift'>
SELECT
DISTINCT dp.duty_date AS dutyDate
FROM
cb_duty_person_shift dp
LEFT JOIN cb_dynamic_form_instance cd ON dp.instance_id = cd.instance_id
AND cd.group_code = #{groupCode}
AND cd.instance_id IS NOT NULL
AND dp.instance_id IS NOT NULL
AND cd.is_delete = 0
AND dp.is_delete = 0
ORDER BY dp.duty_date DESC
</select>
<select id='getNewEquipmentForSpecifyDate' resultType='map'> <select id='getNewEquipmentForSpecifyDate' resultType='map'>
select *, select *,
(SELECT (SELECT
...@@ -295,13 +308,16 @@ ...@@ -295,13 +308,16 @@
WHEN cd.FIELD_CODE = #{equipmentName} THEN WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE cd.FIELD_VALUE
END END
) AS #{equipmentName} ) AS #{equipmentName},
cds.instance_row AS instanceRow
FROM FROM
cb_dynamic_form_instance cd cb_dynamic_form_instance cd
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
dp.instance_id, dp.instance_id,
ds.`name` ds.`name`,
dp.instance_row
FROM FROM
cb_duty_person_shift dp cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
......
...@@ -1100,5 +1100,31 @@ LEFT JOIN ( ...@@ -1100,5 +1100,31 @@ LEFT JOIN (
cb_org_usr.is_delete=0 AND cb_org_usr.amos_org_id IS NOT NULL AND cb_org_usr.amos_org_id !='' cb_org_usr.is_delete=0 AND cb_org_usr.amos_org_id IS NOT NULL AND cb_org_usr.amos_org_id !=''
</select> </select>
<select id="selectUserDeptMap" resultType="map">
-- 根据人员的id列表查询人员所属部门名称,根据parent_id查询。 返回map,人员名称对应人员部门
SELECT
u.biz_org_name AS userName,
(
SELECT
biz_org_name
FROM
cb_org_usr
WHERE
sequence_nbr = u.parent_id
) AS deptName
FROM
cb_org_usr u
<where>
u.biz_org_type = 'PERSON'
AND u.is_delete = 0
<if test="ids != null and ids.size > 0">
AND u.sequence_nbr IN
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
</mapper> </mapper>
...@@ -43,7 +43,7 @@ import io.swagger.annotations.ApiParam; ...@@ -43,7 +43,7 @@ import io.swagger.annotations.ApiParam;
@Api(tags = "值班车辆接口Api") @Api(tags = "值班车辆接口Api")
@RequestMapping(value = "/common/duty-car") @RequestMapping(value = "/common/duty-car")
public class DutyCarController extends BaseController { public class DutyCarController extends BaseController {
@Autowired @Autowired
IDutyCarService iDutyCarService; IDutyCarService iDutyCarService;
...@@ -156,7 +156,7 @@ public class DutyCarController extends BaseController { ...@@ -156,7 +156,7 @@ public class DutyCarController extends BaseController {
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @return ResponseModel * @return ResponseModel
* @throws Exception * @throws Exception
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping("/{instanceId}/{startTime}/{endTime}") @DeleteMapping("/{instanceId}/{startTime}/{endTime}")
...@@ -186,4 +186,15 @@ public class DutyCarController extends BaseController { ...@@ -186,4 +186,15 @@ public class DutyCarController extends BaseController {
public ResponseModel<List<Map<String, Object>>> theCarDutyPerson(@RequestParam Long carId){ public ResponseModel<List<Map<String, Object>>> theCarDutyPerson(@RequestParam Long carId){
return ResponseHelper.buildResponse(iDutyCarService.theCarDutyPerson(carId)); return ResponseHelper.buildResponse(iDutyCarService.theCarDutyPerson(carId));
} }
/**
* 写入历史展板数据到日志表
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping ("/write-history-duty-log")
@ApiOperation(httpMethod = "GET", value = "历史值班数据写入日志表", notes = "历史值班数据写入日志表")
public ResponseModel writeHistoryDutyLog() {
iDutyCarService.writeHistoryDutyLog();
return ResponseHelper.buildResponse("running...");
}
} }
\ No newline at end of file
...@@ -159,7 +159,7 @@ public class DutyPersonController extends BaseController { ...@@ -159,7 +159,7 @@ public class DutyPersonController extends BaseController {
* @param startTime 开始时间 * @param startTime 开始时间
* @param endTime 结束时间 * @param endTime 结束时间
* @return ResponseModel * @return ResponseModel
* @throws Exception * @throws Exception
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping("/{instanceId}/{startTime}/{endTime}") @DeleteMapping("/{instanceId}/{startTime}/{endTime}")
...@@ -250,5 +250,14 @@ public class DutyPersonController extends BaseController { ...@@ -250,5 +250,14 @@ public class DutyPersonController extends BaseController {
// return ResponseHelper.buildResponse(iDutyPersonService.queryByCompanyId(companyId)); // return ResponseHelper.buildResponse(iDutyPersonService.queryByCompanyId(companyId));
// } // }
/**
* 写入历史展板数据到日志表
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping ("/write-history-duty-log")
@ApiOperation(httpMethod = "GET", value = "历史值班数据写入日志表", notes = "历史值班数据写入日志表")
public ResponseModel writeHistoryDutyLog() {
iDutyPersonService.writeHistoryDutyLog();
return ResponseHelper.buildResponse("running...");
}
} }
package com.yeejoin.amos.boot.module.common.biz.service.impl; package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.util.ArrayList; import java.text.ParseException;
import java.util.LinkedHashMap; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.common.biz.enums.ActionStatus; import com.yeejoin.amos.boot.module.common.biz.enums.ActionStatus;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -20,9 +26,6 @@ import com.alibaba.fastjson.JSONObject; ...@@ -20,9 +26,6 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.FirefightersMapper; import com.yeejoin.amos.boot.module.common.api.mapper.FirefightersMapper;
...@@ -38,7 +41,7 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -38,7 +41,7 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
DynamicFormInstanceServiceImpl dynamicFormInstanceService; DynamicFormInstanceServiceImpl dynamicFormInstanceService;
@Autowired @Autowired
FirefightersMapper firefightersMapper; FirefightersMapper firefightersMapper;
@Autowired @Autowired
EquipFeignClient equipFeignClient; EquipFeignClient equipFeignClient;
...@@ -51,6 +54,12 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -51,6 +54,12 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
@Autowired @Autowired
DutyPersonShiftMapper dutyPersonShiftMapper; DutyPersonShiftMapper dutyPersonShiftMapper;
@Autowired
DataDictionaryMapper dataDictionaryMapper;
@Autowired
OrgUsrMapper orgUsrMapper;
@Override @Override
public String getGroupCode() { public String getGroupCode() {
return "dutyCar"; return "dutyCar";
...@@ -76,8 +85,15 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -76,8 +85,15 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
// 修改操作动态表单的方法,修改人陈浩 -------------start 2021-09-28 // 修改操作动态表单的方法,修改人陈浩 -------------start 2021-09-28
Long instanceId = excuteDynamicFormInstance(dutyCarDto.getUserId(), map, this.getGroupCode()); Long instanceId = excuteDynamicFormInstance(dutyCarDto.getUserId(), map, this.getGroupCode());
saveDutyPersonShiftDetail(instanceId, dutyCarDto.getDutyShift(), dutyCarDto.getStartTime()); saveDutyPersonShiftDetail(instanceId, dutyCarDto.getDutyShift(), dutyCarDto.getStartTime());
insertPersonShift(instanceId, dutyCarDto.getDutyShift(), ActionStatus.METHOD_ADD.getCode()); TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
insertPersonShift(instanceId, dutyCarDto.getDutyShift(), ActionStatus.METHOD_ADD.getCode());
}
});
// 修改操作动态表单的方法,修改人陈浩 -------------end 2021-09-28 // 修改操作动态表单的方法,修改人陈浩 -------------end 2021-09-28
// 生成变更日志
createDutyPersonShiftLog(dutyCarDto, false, ActionStatus.METHOD_UPDATE.getCode());
// 3.返回保存后的数据 // 3.返回保存后的数据
return dutyCarDto; return dutyCarDto;
...@@ -85,15 +101,87 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -85,15 +101,87 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
@Override @Override
public DutyCarDto update(Long instanceId, DutyCarDto dutyCarDto) { public DutyCarDto update(Long instanceId, DutyCarDto dutyCarDto) {
// 修改操作动态表单修改的逻辑方法,陈浩 start ----2021-09-28 // 修改操作动态表单修改的逻辑方法,陈浩 start ----2021-09-28
updateDynamicFormInstance(this.getGroupCode(), instanceId, Bean.BeantoMap(dutyCarDto)); updateDynamicFormInstance(this.getGroupCode(), instanceId, Bean.BeantoMap(dutyCarDto));
// 修改操作动态表单修改的逻辑方法,陈浩 end ----2021-09-28 // 修改操作动态表单修改的逻辑方法,陈浩 end ----2021-09-28
// 5.更新值班信息人日期数据 // 5.更新值班信息人日期数据
insertPersonShift(instanceId, dutyCarDto.getDutyShift(), ActionStatus.METHOD_UPDATE.getCode()); insertPersonShift(instanceId, dutyCarDto.getDutyShift(), ActionStatus.METHOD_UPDATE.getCode());
// 生成变更日志
createDutyPersonShiftLog(dutyCarDto, false, ActionStatus.METHOD_UPDATE.getCode());
return dutyCarDto; return dutyCarDto;
} }
public void insertPersonShift(Long instanceId, List<DutyPersonShiftDto> dutyShiftList, String type) {
//1.查询已有数据
List<DynamicFormInstance> instances = dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
Map<Object, DynamicFormInstance> instanceMap = Bean.listToMap(instances, "fieldCode", DynamicFormInstance.class);
dutyPersonService.dataCheck(dutyShiftList,instanceId,type);
Set<DutyPersonShift> personShiftList = dutyShiftList.stream().map(dto -> {
// 根据instanceId 和 日期查找 如果有则更新
DutyPersonShift dutyPersonShift = dutyPersonShiftService.getOne(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId,instanceId).eq(DutyPersonShift::getDutyDate,dto.getDutyDate()));
if(dutyPersonShift == null) {
dutyPersonShift = new DutyPersonShift();
}
dto.setInstanceId(instanceId);
Bean.copyExistPropertis(dto, dutyPersonShift);
dutyPersonShift.setAppKey(RequestContext.getAppKey());
return dutyPersonShift;
}).collect(Collectors.toSet());
if (!personShiftList.isEmpty()) {
dutyPersonShiftService.saveOrUpdateBatch(personShiftList);
}
}
@Override
public Object getDutyPersonShiftLogData(String dutyDay, String fieldCode){
List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getEquipmentForSpecifyDate(dutyDay,
this.getGroupCode(), "carId", "carName", "teamName", "result.carId");
if (equipmentList == null || equipmentList.isEmpty() || equipmentList.get(0) == null) {
return null;
}
List<Object> detailList = new ArrayList<>();
for (Map<String, Object> map : equipmentList) {
List<Map<String, Object>> resultList = new ArrayList<>();
LinkedHashMap<String, Object> titleMap_1 = new LinkedHashMap<>();
if (map.containsKey("carName") && map.get("carName") != null) {
titleMap_1.put("消防车辆", map.get("carName").toString());
}
resultList.add(titleMap_1);
LinkedHashMap<String, Object> titleMap_2 = new LinkedHashMap<>();
if (map.containsKey("teamName") && map.get("teamName") != null) {
titleMap_2.put("单位/部门", map.get("teamName").toString());
}
resultList.add(titleMap_2);
String carId = map.get("carId").toString();
Map<String, Object> instanceMap = dutyPersonShiftMapper.getInstanceIdForSpecifyDateAndEquipment(
dutyDay, this.getGroupCode(), carId
);
if (instanceMap == null) {
continue;
}
String instanceId = instanceMap.get("instanceIds").toString();
if (StringUtils.isNotBlank(instanceId)) {
String[] instanceIds = instanceId.split(",");
List<Map<String, Object>> specifyDateList = dutyPersonShiftMapper.getPositionStaffDutyForSpecifyDate(
dutyDay, this.getGroupCode(), instanceIds, null, fieldCode
);
if (!specifyDateList.isEmpty()) {
for (Map<String, Object> specify : specifyDateList) {
LinkedHashMap<String, Object> infoMap_2 = new LinkedHashMap<>();
if (specify.containsKey("postTypeName") && specify.get("postTypeName") != null && specify.containsKey("userName") && specify.get("userName") != null) {
infoMap_2.put(specify.get("postTypeName").toString(), specify.get("userName").toString());
resultList.add(infoMap_2);
}
}
}
}
detailList.add(resultList);
}
return detailList;
}
private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column,
DynamicFormInstance formInstance) { DynamicFormInstance formInstance) {
fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId()); fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId());
...@@ -144,71 +232,83 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -144,71 +232,83 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
} }
public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode) { public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode) {
List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getEquipmentForSpecifyDate(dutyDay, List<List<Map<String, String>>> result = new ArrayList<>();
this.getGroupCode(), "carId", "carName", "teamName","result.carId"); List<Map<String, String>> dutyCarLogs = dutyPersonShiftLogMapper.selectSpecificDateLogForCar(dutyDay);
if(equipmentList==null || equipmentList.size()<1 || equipmentList.get(0)==null) { // 按照车辆分组
return null; dutyCarLogs = dutyCarLogs.stream().filter(v -> Objects.nonNull(v.get("carName"))).collect(Collectors.toList());
} Map<String, List<Map<String, String>>> dutyCarLogGroups = dutyCarLogs.stream().collect(Collectors.groupingBy(v -> v.get("carName")));
List<Object> detailList = new ArrayList<Object>(); // 按照车辆排序
for (Map<String, Object> map : equipmentList) { // 1. 获取排序 BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); List<OrgUsr> orgUserSortRules = orgUsrMapper.selectList(
LinkedHashMap<String, Object> titleMap_1 =new LinkedHashMap<String, Object>(); Wrappers.<OrgUsr>lambdaQuery()
titleMap_1.put("消防车辆", map.get("carName").toString()); .select(OrgUsr::getBizOrgName, OrgUsr::getOrgExpandAttr1)
if(map.containsKey("carName") && map.get("carName") != null){ .isNotNull(OrgUsr::getOrgExpandAttr1)
titleMap_1.put("消防车辆", map.get("carName").toString()); .ne(OrgUsr::getOrgExpandAttr1, "")
} );
resultList.add(titleMap_1); // 2. dutyCarLogGroups.keySet() 为车辆名称,根据车辆名称获取部门值班列表。获取车辆下第一个部门,按照此部门对dutyCarLogGroups进行排序,排序后的结果保存到一个有序的LinkedHashMap中.
LinkedHashMap<String, Object> titleMap_2 =new LinkedHashMap<String, Object>(); // sortNum为数字类型,数字越小越靠前 | 车辆对应的部门列表可能为空,注意判空,无法排序的车辆放到最后
//titleMap_2.put("单位/部门", map.get("teamName").toString()); Map<String, List<Map<String, String>>> sortedDutyCarLogGroups = new LinkedHashMap<>();
if(map.containsKey("teamName") && map.get("teamName") != null){ Map<String, Integer> dutyCarSortNumMap = new HashMap<>();
titleMap_2.put("单位/部门", map.get("teamName").toString()); for (String carName : dutyCarLogGroups.keySet()) {
} List<Map<String, String>> dutyCarLogGroup = dutyCarLogGroups.get(carName);
resultList.add(titleMap_2); Map<String, String> team = dutyCarLogGroup.get(0);
String carId =map.get("carId").toString(); if (Objects.isNull(team)) {
Map<String, Object> instanceMap = dutyPersonShiftMapper.getInstanceIdForSpecifyDateAndEquipment(dutyDay,
this.getGroupCode(), carId);
if(instanceMap==null) {
continue; continue;
} }
String instanceId = instanceMap.get("instanceIds").toString(); String teamName = team.get("teamName");
if (StringUtils.isNotBlank(instanceId)) { // 根据teamName从orgUserSortRules中获取排序号
String[] instanceIds = instanceId.split(","); Optional<OrgUsr> orgUsrOptional = orgUserSortRules.stream().filter(v -> Objects.equals(v.getBizOrgName(), teamName)).findFirst();
if (orgUsrOptional.isPresent()) {
// List<Map<String, Object>> dutyList = dutyPersonShiftMapper.getDutyForSpecifyDate(dutyDay); OrgUsr orgUsr = orgUsrOptional.get();
// if(dutyList!=null && dutyList.size()>0) { String sortNum = orgUsr.getOrgExpandAttr1();
// for (Map<String, Object> dutyDetail : dutyList) { dutyCarSortNumMap.put(carName, Integer.parseInt(sortNum));
// if(!dutyDetail.containsKey("name")) {
// continue;
// }
// 获取当前装备ID下的排版数据
List<Map<String, Object>> specifyDateList = dutyPersonShiftMapper.getPositionStaffDutyForSpecifyDate(dutyDay,
this.getGroupCode(), instanceIds,null, fieldCode);
/*if(specifyDateList==null || specifyDateList.size() < 1 || specifyDateList.get(0)==null) {
continue;
}*/
LinkedHashMap<String, Object> infoMap_1 =new LinkedHashMap<String, Object>();
//取消掉班次的显示---2022-01-16 by chenhao ---start
//infoMap_1.put(dutyDetail.get("name").toString(), "");
//resultList.add(infoMap_1);
//取消掉班次的显示---2022-01-16 by chenhao ---end
if (specifyDateList.size()>0 && specifyDateList != null) {
for (Map<String, Object> specify : specifyDateList) {
LinkedHashMap<String, Object> infoMap_2 = new LinkedHashMap<String, Object>();
// infoMap_2.put(specify.get("postTypeName").toString(),specify.get("userName").toString());
// resultList.add(infoMap_2);
if (specify.containsKey("postTypeName") && specify.get("postTypeName") != null && specify.containsKey("userName") && specify.get("userName") != null) {
infoMap_2.put(specify.get("postTypeName").toString(), specify.get("userName").toString());
resultList.add(infoMap_2);
}
}
}
// }
//}
} }
detailList.add(resultList);
} }
return detailList; // 根据dutyCarSortNumMap对dutyCarLogGroups进行排序
List<Map.Entry<String, List<Map<String, String>>>> dutyCarLogGroupEntries = new ArrayList<>(dutyCarLogGroups.entrySet());
dutyCarLogGroupEntries.sort((o1, o2) -> {
Integer sortNum1 = dutyCarSortNumMap.getOrDefault(o1.getKey(), Integer.MAX_VALUE);
Integer sortNum2 = dutyCarSortNumMap.getOrDefault(o2.getKey(), Integer.MAX_VALUE);
return sortNum1.compareTo(sortNum2);
});
for (Map.Entry<String, List<Map<String, String>>> entry : dutyCarLogGroupEntries) {
sortedDutyCarLogGroups.put(entry.getKey(), entry.getValue());
}
// 3. 根据排序后的sortedDutyCarLogGroups生成返回结果
Set<Map.Entry<String, List<Map<String, String>>>> entries = sortedDutyCarLogGroups.entrySet();
for (Map.Entry<String, List<Map<String, String>>> entry : entries) {
String key = entry.getKey();
List<Map<String, String>> value = entry.getValue();
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> item1 = new HashMap<String, String>() {{
this.put("消防车辆", key);
}};
list.add(item1);
Map<String, String> item2 = new HashMap<String, String>() {{
this.put("单位/部门", value.get(0).getOrDefault("teamName", ""));
}};
list.add(item2);
// value 是一个部门的值班列表,按照postTypeName的字符串排序
List<Map<String, String>> posts = new LinkedList<>();
for (Map<String, String> val : value) {
Map<String, String> itemN = new HashMap<String, String>() {{
this.put(val.getOrDefault("postTypeName", ""), val.getOrDefault("dutyUsers", ""));
}};
posts.add(itemN);
}
posts.sort((o1, o2) -> {
String postTypeName1 = o1.keySet().iterator().next();
String postTypeName2 = o2.keySet().iterator().next();
return postTypeName1.compareTo(postTypeName2);
});
list.addAll(posts);
result.add(list);
}
return result.isEmpty() ? this.getDutyPersonShiftLogData(dutyDay, fieldCode) : result;
} }
@Override @Override
public int getDutyCarCount(Long carId) { public int getDutyCarCount(Long carId) {
List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getEquipmentForSpecifyDate(DateUtils.getDateNowShortStr(), List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getEquipmentForSpecifyDate(DateUtils.getDateNowShortStr(),
...@@ -248,7 +348,7 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -248,7 +348,7 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
String[] instanceIds = instanceId.split(","); String[] instanceIds = instanceId.split(",");
specifyDateList = dutyPersonShiftMapper.getPositionStaffDutyForSpecifyDate(dutyDay, specifyDateList = dutyPersonShiftMapper.getPositionStaffDutyForSpecifyDate(dutyDay,
this.getGroupCode(), instanceIds,null, null); this.getGroupCode(), instanceIds,null, null);
} }
return specifyDateList; return specifyDateList;
} }
@Override @Override
...@@ -258,4 +358,189 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa ...@@ -258,4 +358,189 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
return instanceMap; return instanceMap;
} }
@Override
public void writeHistoryDutyLog() {
List<Map<String, Object>> list;
try {
list = this.list(null, "1980-01-01", "9999-12-12");
} catch (ParseException e) {
throw new RuntimeException(e);
}
for (Map<String, Object> map : list) {
DutyCarDto dutyCarDto = (DutyCarDto) Bean.mapToBean(map, DutyCarDto.class);
this.createDutyPersonShiftLog(dutyCarDto, true, null);
}
}
public Map<String, List<DutyPersonShiftLog>> getDownloadData(String beginDate, String endDate) throws ParseException {
Map<String, List<DutyPersonShiftLog>> resultSortedMap = new LinkedHashMap<>();
List<DutyPersonShiftLog> dutyCarLogs = dutyPersonShiftLogMapper.selectList(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.ge(DutyPersonShiftLog::getDutyDate, beginDate)
.le(DutyPersonShiftLog::getDutyDate, endDate)
.eq(DutyPersonShiftLog::getGroupCode, "dutyCar")
.eq(DutyPersonShiftLog::getIsDelete, false)
);
Map<String, List<DutyPersonShiftLog>> unsortedMap = dutyCarLogs.stream()
.filter(v -> Objects.nonNull(v.getCarName()))
.collect(Collectors.groupingBy(DutyPersonShiftLog::getCarName));
// 获取排序 BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List<OrgUsr> orgUserSortRules = orgUsrMapper.selectList(
Wrappers.<OrgUsr>lambdaQuery()
.select(OrgUsr::getBizOrgName, OrgUsr::getOrgExpandAttr1)
.isNotNull(OrgUsr::getOrgExpandAttr1)
.ne(OrgUsr::getOrgExpandAttr1, "")
).stream().sorted(Comparator.comparing(v -> Integer.parseInt(v.getOrgExpandAttr1()))).collect(Collectors.toList());
// map的key为车辆名称,根据车辆名称获取部门值班列表。获取车辆下第一个部门,按照此部门对map进行排序,排序后的结果保存到一个有序的LinkedHashMap中.
// sortNum为数字类型,数字越小越靠前 | 车辆对应的部门列表可能为空,注意判空,无法排序的车辆放到最后
Map<String, List<DutyPersonShiftLog>> sortedMap = new LinkedHashMap<>();
Map<String, Integer> dutyCarSortNumMap = new HashMap<>();
for (String carName : unsortedMap.keySet()) {
List<DutyPersonShiftLog> dutyCarLogGroup = unsortedMap.get(carName);
DutyPersonShiftLog dutyPersonShiftLog = dutyCarLogGroup.get(0);
if (Objects.isNull(dutyPersonShiftLog)) {
continue;
}
String teamName = dutyPersonShiftLog.getDeptName();
// 根据teamName从orgUserSortRules中获取排序号
Optional<OrgUsr> orgUsrOptional = orgUserSortRules.stream().filter(v -> Objects.equals(v.getBizOrgName(), teamName)).findFirst();
if (orgUsrOptional.isPresent()) {
OrgUsr orgUsr = orgUsrOptional.get();
String sortNum = orgUsr.getOrgExpandAttr1();
dutyCarSortNumMap.put(carName, Integer.parseInt(sortNum));
}
}
// 根据dutyCarSortNumMap对map进行排序
List<Map.Entry<String, List<DutyPersonShiftLog>>> dutyCarLogGroupEntries = new ArrayList<>(unsortedMap.entrySet());
dutyCarLogGroupEntries.sort((o1, o2) -> {
Integer sortNum1 = dutyCarSortNumMap.getOrDefault(o1.getKey(), Integer.MAX_VALUE);
Integer sortNum2 = dutyCarSortNumMap.getOrDefault(o2.getKey(), Integer.MAX_VALUE);
return sortNum1.compareTo(sortNum2);
});
for (Map.Entry<String, List<DutyPersonShiftLog>> entry : dutyCarLogGroupEntries) {
sortedMap.put(entry.getKey(), entry.getValue());
}
// 根据排序后的sortedMap生成返回结果
Set<Map.Entry<String, List<DutyPersonShiftLog>>> entries = sortedMap.entrySet();
for (Map.Entry<String, List<DutyPersonShiftLog>> entry : entries) {
String key = entry.getKey();
List<DutyPersonShiftLog> value = entry.getValue();
resultSortedMap.put(key, value);
}
return resultSortedMap;
}
@SuppressWarnings("Duplicates")
public void createDutyPersonShiftLog(DutyCarDto dutyCarDto, boolean isInit, String actionCode) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<DutyPersonShiftDto> dutyPersonShift = dutyCarDto.getDutyShift();
final String groupCode = "dutyCar";
// 新建/更新排班时处理跨月数据
if (!isInit && StringUtils.isNotBlank(actionCode)) {
if (Objects.nonNull(dutyPersonShift) && !dutyPersonShift.isEmpty()) {
// 拿到排班月份 yyyy-MM
String dutyDate = dateFormat.format(dutyPersonShift.get(0).getDutyDate());
dutyDate = dutyDate.substring(0, 7);
String today = dateFormat.format(new Date());
if (today.substring(0, 7).equals(dutyDate)) {
dutyDate = today;
} else {
dutyDate += "-01";
}
dutyPersonShiftLogMapper.delete(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.eq(DutyPersonShiftLog::getGroupCode, groupCode)
.eq(DutyPersonShiftLog::getDutyUser, dutyCarDto.getUserName())
.ge(DutyPersonShiftLog::getDutyDate, dutyDate)
.ge(DutyPersonShiftLog::getDutyDate, dateFormat.format(new Date()))
.eq(DutyPersonShiftLog::getIsDelete, false)
);
}
dutyPersonShift.clear();
try {
List<Map<String, Object>> list = list(null, dateFormat.format(new Date()), "9999-12-12");
list = list.stream().filter(map -> Objects.equals(map.get("userName"), dutyCarDto.getUserName())).collect(Collectors.toList());
for (Map<String, Object> map : list) {
DutyCarDto dutyCarDto = (DutyCarDto) Bean.mapToBean(map, DutyCarDto.class);
List<DutyPersonShiftDto> dutyShifts = dutyCarDto.getDutyShift().stream().filter(v -> isAfterToday(v.getDutyDate())).collect(Collectors.toList());
dutyPersonShift.addAll(dutyShifts);
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
Set<String> dutyDates = dutyPersonShift.stream().map(v -> dateFormat.format(v.getDutyDate())).collect(Collectors.toSet());
if (dutyDates.isEmpty()) {
return;
}
Map<Date, List<DutyPersonShiftLog>> dutyLogGroups = dutyPersonShiftLogMapper.selectList(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.in(DutyPersonShiftLog::getDutyDate, dutyDates)
.eq(DutyPersonShiftLog::getGroupCode, groupCode)
.eq(DutyPersonShiftLog::getDutyUser, dutyCarDto.getUserName())
.eq(DutyPersonShiftLog::getIsDelete, false)
).stream().collect(Collectors.groupingBy(DutyPersonShiftLog::getDutyDate));
for (DutyPersonShiftDto dutyPersonShiftDto : dutyPersonShift) {
// 非初始化非历史数据禁止修改
if (!isAfterToday(dutyPersonShiftDto.getDutyDate()) && !isInit) {
continue;
}
List<DutyPersonShiftLog> dutyPersonShiftLogs = dutyLogGroups.get(dutyPersonShiftDto.getDutyDate());
DutyPersonShiftLog dutyPersonShiftLog = Objects.nonNull(dutyPersonShiftLogs) && !dutyPersonShiftLogs.isEmpty() ? dutyPersonShiftLogs.get(0) : null;
// 日志不存在:新建
if (Objects.isNull(dutyPersonShiftLog)) {
dutyPersonShiftLog = new DutyPersonShiftLog();
dutyPersonShiftLog.setInstanceId(dutyPersonShiftDto.getInstanceId());
dutyPersonShiftLog.setDutyDate(dutyPersonShiftDto.getDutyDate());
dutyPersonShiftLog.setGroupCode(groupCode);
dutyPersonShiftLog.setDeptName(dutyCarDto.getTeamName());
dutyPersonShiftLog.setDutyUserId(dutyCarDto.getUserId());
dutyPersonShiftLog.setDutyUser(dutyCarDto.getUserName());
dutyPersonShiftLog.setPostTypeName(dutyCarDto.getPostTypeName());
dutyPersonShiftLog.setDutyArea(dutyCarDto.getDutyArea());
dutyPersonShiftLog.setCarName(dutyCarDto.getCarName());
String shiftName = dutyPersonShiftDto.getShiftName();
if (StringUtils.isBlank(shiftName) && Objects.nonNull(dutyPersonShiftDto.getShiftId())) {
DutyShift dutyShift = dutyShiftService.getById(dutyPersonShiftDto.getShiftId());
dutyPersonShiftDto.setShiftName(dutyShift.getName());
}
dutyPersonShiftLog.setShiftName(dutyPersonShiftDto.getShiftName());
dutyPersonShiftLogMapper.insert(dutyPersonShiftLog);
continue;
}
// 日志存在:更新
if (isAfterToday(dutyPersonShiftDto.getDutyDate())) {
dutyPersonShiftLog.setInstanceId(dutyPersonShiftDto.getInstanceId());
dutyPersonShiftLog.setDeptName(dutyCarDto.getTeamName());
dutyPersonShiftLog.setPostTypeName(dutyCarDto.getPostTypeName());
dutyPersonShiftLog.setDutyArea(dutyCarDto.getDutyArea());
dutyPersonShiftLog.setCarName(dutyCarDto.getCarName());
String shiftName = dutyPersonShiftDto.getShiftName();
if (StringUtils.isBlank(shiftName) && Objects.nonNull(dutyPersonShiftDto.getShiftId())) {
DutyShift dutyShift = dutyShiftService.getById(dutyPersonShiftDto.getShiftId());
dutyPersonShiftDto.setShiftName(dutyShift.getName());
}
dutyPersonShiftLog.setShiftName(dutyPersonShiftDto.getShiftName());
dutyPersonShiftLogMapper.update(
dutyPersonShiftLog,
Wrappers.<DutyPersonShiftLog>lambdaUpdate()
.eq(DutyPersonShiftLog::getDutyDate, dutyPersonShiftDto.getDutyDate())
.eq(DutyPersonShiftLog::getGroupCode, groupCode)
.eq(DutyPersonShiftLog::getDutyUser, dutyCarDto.getUserName())
.eq(DutyPersonShiftLog::getIsDelete, false)
);
}
}
}
});
}
} }
...@@ -3,21 +3,34 @@ package com.yeejoin.amos.boot.module.common.biz.service.impl; ...@@ -3,21 +3,34 @@ package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper;
import com.yeejoin.amos.boot.module.common.biz.enums.DynamicGroupCode; import com.yeejoin.amos.boot.module.common.biz.enums.DynamicGroupCode;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
...@@ -34,11 +47,6 @@ import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto; ...@@ -34,11 +47,6 @@ import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyShiftDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyShiftDto;
import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift;
import com.yeejoin.amos.boot.module.common.api.entity.DutyShift;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.enums.DutyViewTypeEnum; import com.yeejoin.amos.boot.module.common.api.enums.DutyViewTypeEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper;
import com.yeejoin.amos.boot.module.common.api.service.IDutyCommonService; import com.yeejoin.amos.boot.module.common.api.service.IDutyCommonService;
...@@ -72,10 +80,13 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -72,10 +80,13 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
@Autowired @Autowired
OrgUsrServiceImpl orgUsrService; OrgUsrServiceImpl orgUsrService;
@Autowired @Autowired
DutyPersonShiftMapper dutyPersonShiftMapper; DutyPersonShiftMapper dutyPersonShiftMapper;
@Autowired
DutyPersonShiftLogMapper dutyPersonShiftLogMapper;
/** /**
* 每天单个班次执勤人数全部小于等于3人 * 每天单个班次执勤人数全部小于等于3人
*/ */
...@@ -287,7 +298,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -287,7 +298,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
return resultMap; return resultMap;
/*bug2468 值班排班,日历视图单班次执勤人数满足≤3且班次≤2时,值班显示方式错误 陈召 结束*/ /*bug2468 值班排班,日历视图单班次执勤人数满足≤3且班次≤2时,值班显示方式错误 陈召 结束*/
} }
public List<Map<String, Object>> newStatisticsDay(String beginDate, String endDate, String fieldCode) throws ParseException { public List<Map<String, Object>> newStatisticsDay(String beginDate, String endDate, String fieldCode) throws ParseException {
Date dateBegin = DateUtils.dateParse(beginDate, DateUtils.DATE_PATTERN); Date dateBegin = DateUtils.dateParse(beginDate, DateUtils.DATE_PATTERN);
...@@ -330,7 +341,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -330,7 +341,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
} }
return resultMap; return resultMap;
} }
/** /**
* 排班值班人员的统计类型为: * 排班值班人员的统计类型为:
* 岗位: 岗位人员数量 * 岗位: 岗位人员数量
...@@ -343,7 +354,18 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -343,7 +354,18 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
if (StringUtils.isNotBlank(fieldCode)) { if (StringUtils.isNotBlank(fieldCode)) {
return dutyPersonShiftService.getBaseMapper().newStationViewDataByFieldCode(dutyDate, this.getGroupCode(), fieldCode); return dutyPersonShiftService.getBaseMapper().newStationViewDataByFieldCode(dutyDate, this.getGroupCode(), fieldCode);
} }
return dutyPersonShiftService.getBaseMapper().newStationViewData(dutyDate, this.getGroupCode()); // return dutyPersonShiftService.getBaseMapper().newStationViewData(dutyDate, this.getGroupCode());
List<Map<String, String>> dutyLogs = dutyPersonShiftLogMapper.selectSpecificDateLogForPersonGroupByPostTypeName(dutyDate);
List<Map<String, Object>> result = new ArrayList<>();
for (Map<String, String> dutyLog : dutyLogs) {
Map<String, Object> item = new HashMap<String, Object>() {{
this.put("postTypeName", dutyLog.getOrDefault("postTypeName", ""));
this.put("total", dutyLog.getOrDefault("dutyUsers", "").split(",").length);
}};
result.add(item);
}
return result;
} }
/** /**
* 车辆值班人员左侧的统计: 只有几辆车 * 车辆值班人员左侧的统计: 只有几辆车
...@@ -351,26 +373,25 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -351,26 +373,25 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
* @return * @return
*/ */
public Object getCarPostTypeNameAndCount(String dutyDate) { public Object getCarPostTypeNameAndCount(String dutyDate) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
int station =0; List<DutyPersonShiftLog> dutyCarLogs = dutyPersonShiftLogMapper.selectList(
int person=0; Wrappers.<DutyPersonShiftLog>lambdaQuery()
List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getEquipmentForSpecifyDate(dutyDate, .select(DutyPersonShiftLog::getCarName)
this.getGroupCode(), "carId", "carName", "teamName","result.carId"); .eq(DutyPersonShiftLog::getDutyDate, dutyDate)
if(equipmentList==null || equipmentList.size()<1 || equipmentList.get(0)==null) { .eq(DutyPersonShiftLog::getGroupCode, "dutyCar")
station =0; .eq(DutyPersonShiftLog::getIsDelete, false)
}else { );
station=equipmentList.size(); dutyCarLogs = dutyCarLogs.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
Map<String, List<DutyPersonShiftLog>> logsMap = dutyCarLogs.stream().collect(Collectors.groupingBy(DutyPersonShiftLog::getCarName));
int station = logsMap.size();
map.put("station", station); map.put("station", station);
List<Map<String, Object>> list = dutyPersonShiftService.getBaseMapper().newStationViewData(dutyDate, this.getGroupCode()); map.put("person", dutyCarLogs.size());
for (Map<String, Object> map2 : list) {
person = person +Integer.parseInt(map2.get("total").toString());
}
map.put("person", person);
return map; return map;
} }
public Object getFireFightingPostTypeNameAndCount(String dutyDate) { public Object getFireFightingPostTypeNameAndCount(String dutyDate) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
int station =0; int station =0;
...@@ -390,7 +411,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -390,7 +411,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
map.put("person", person); map.put("person", person);
return map; return map;
} }
public Object getFirstAidPostTypeNameAndCount(String dutyDate) { public Object getFirstAidPostTypeNameAndCount(String dutyDate) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
int station =0; int station =0;
...@@ -410,8 +431,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -410,8 +431,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
map.put("person", person); map.put("person", person);
return map; return map;
} }
private Object buildViewData(DutyViewTypeEnum viewTypeEnum, String dutyDate, String appKey) { private Object buildViewData(DutyViewTypeEnum viewTypeEnum, String dutyDate, String appKey) {
List<Map<String, Object>> result = new ArrayList<>(); List<Map<String, Object>> result = new ArrayList<>();
switch (viewTypeEnum) { switch (viewTypeEnum) {
...@@ -447,7 +468,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -447,7 +468,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
String groupCode = this.getGroupCode(); String groupCode = this.getGroupCode();
// 动态表单查询所有值班信息 // 动态表单查询所有值班信息
List<Map<String, Object>> list = dynamicFormInstanceService.listAll(groupCode); List<Map<String, Object>> list = dynamicFormInstanceService.listAll(groupCode);
// 2.组织值班数据 // 2.组织值班数据
for (Map<String, Object> map : list) { for (Map<String, Object> map : list) {
this.fillDutyShiftData(beginDate, endDate, map); this.fillDutyShiftData(beginDate, endDate, map);
...@@ -634,6 +655,13 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -634,6 +655,13 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
//dynamicFormInstanceService.remove(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId)); //dynamicFormInstanceService.remove(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
dutyPersonShiftService dutyPersonShiftService
.remove(new LambdaQueryWrapper<DutyPersonShift>().ge(DutyPersonShift::getDutyDate,startTime).le(DutyPersonShift::getDutyDate,endTime).eq(DutyPersonShift::getInstanceId, instanceId)); .remove(new LambdaQueryWrapper<DutyPersonShift>().ge(DutyPersonShift::getDutyDate,startTime).le(DutyPersonShift::getDutyDate,endTime).eq(DutyPersonShift::getInstanceId, instanceId));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dutyPersonShiftLogMapper.delete(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.eq(DutyPersonShiftLog::getInstanceId, instanceId)
.ge(DutyPersonShiftLog::getDutyDate, dateFormat.format(new Date()))
.le(DutyPersonShiftLog::getDutyDate, endTime)
);
return true; return true;
} }
...@@ -721,7 +749,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -721,7 +749,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
} }
/*** /***
* 将操作动态表单的方法单独提出来 * 将操作动态表单的方法单独提出来
* @author 陈浩 * @author 陈浩
* @serialData 2021-09-28 * @serialData 2021-09-28
* @param userId * @param userId
* @param map * @param map
...@@ -766,7 +794,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -766,7 +794,7 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
} }
return instanceId; return instanceId;
} }
public void updateDynamicFormInstance(String groupCode,Long instanceId, Map<String, Object> map) { public void updateDynamicFormInstance(String groupCode,Long instanceId, Map<String, Object> map) {
//1.查询已有数据 //1.查询已有数据
List<DynamicFormInstance> instances = dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId)); List<DynamicFormInstance> instances = dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
...@@ -781,8 +809,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -781,8 +809,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
if (!entrys.isEmpty()) { if (!entrys.isEmpty()) {
dynamicFormInstanceService.saveOrUpdateBatch(entrys); dynamicFormInstanceService.saveOrUpdateBatch(entrys);
} }
} }
public void saveDutyPersonShiftDetail( Long instanceId ,List<DutyPersonShiftDto> dutyShift ,String startTime) { public void saveDutyPersonShiftDetail( Long instanceId ,List<DutyPersonShiftDto> dutyShift ,String startTime) {
if(dutyShift != null && dutyShift.size() == 0) { if(dutyShift != null && dutyShift.size() == 0) {
Calendar startDate = Calendar.getInstance(); Calendar startDate = Calendar.getInstance();
...@@ -802,8 +830,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -802,8 +830,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
dutyPersonShiftService.saveOrUpdateBatch(dutyShiftList); dutyPersonShiftService.saveOrUpdateBatch(dutyShiftList);
} }
} }
public void insertPersonShift(Long instanceId, List<DutyPersonShiftDto> dutyShiftList,String type) {
public void insertPersonShift(Long instanceId, List<DutyPersonShiftDto> dutyShiftList, String type) {
dutyPersonService.dataCheck(dutyShiftList,instanceId,type); dutyPersonService.dataCheck(dutyShiftList,instanceId,type);
Set<DutyPersonShift> personShiftList = dutyShiftList.stream().map(dto -> { Set<DutyPersonShift> personShiftList = dutyShiftList.stream().map(dto -> {
// BUG 2807 修改时发现BUG 车辆保存有问题 by kongfm 2021-09-14 // BUG 2807 修改时发现BUG 车辆保存有问题 by kongfm 2021-09-14
...@@ -815,16 +843,38 @@ public class DutyCommonServiceImpl implements IDutyCommonService { ...@@ -815,16 +843,38 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
dto.setInstanceId(instanceId); dto.setInstanceId(instanceId);
Bean.copyExistPropertis(dto, dutyPersonShift); Bean.copyExistPropertis(dto, dutyPersonShift);
dutyPersonShift.setAppKey(RequestContext.getAppKey()); dutyPersonShift.setAppKey(RequestContext.getAppKey());
return dutyPersonShift; return dutyPersonShift;
}).collect(Collectors.toSet()); }).collect(Collectors.toSet());
if (!personShiftList.isEmpty()) { if (!personShiftList.isEmpty()) {
dutyPersonShiftService.saveOrUpdateBatch(personShiftList); dutyPersonShiftService.saveOrUpdateBatch(personShiftList);
} }
} }
/**
* 判断是否是历史值班日
* @param dutyDate 值班日期
*/
public boolean isAfterToday(Date dutyDate) {
// 获取今天的开始时间
Calendar todayStart = Calendar.getInstance();
todayStart.set(Calendar.HOUR_OF_DAY, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);
Calendar duty = Calendar.getInstance();
duty.setTime(dutyDate);
return duty.after(todayStart) || duty.equals(todayStart);
}
@Override @Override
public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode) { public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
public Object getDutyPersonShiftLogData(String dutyDay, String fieldCode){
return null;
}
} }
package com.yeejoin.amos.boot.module.common.biz.service.impl; package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto;
import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper;
import com.yeejoin.amos.boot.module.common.biz.enums.ActionStatus; import com.yeejoin.amos.boot.module.common.biz.enums.ActionStatus;
...@@ -13,7 +27,6 @@ import org.springframework.stereotype.Service; ...@@ -13,7 +27,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -21,9 +34,6 @@ import com.alibaba.fastjson.JSONArray; ...@@ -21,9 +34,6 @@ import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto; import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto;
import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.api.service.IDutyPersonService; import com.yeejoin.amos.boot.module.common.api.service.IDutyPersonService;
...@@ -37,7 +47,15 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -37,7 +47,15 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
EquipFeignClient equipFeign; EquipFeignClient equipFeign;
@Autowired @Autowired
DutyPersonShiftMapper dutyPersonShiftMapper; DutyPersonShiftMapper dutyPersonShiftMapper;
@Autowired
DutyPersonShiftLogMapper dutyPersonShiftLogMapper;
@Autowired
DataDictionaryMapper dataDictionaryMapper;
@Autowired
OrgUsrMapper orgUsrMapper;
@Override @Override
public String getGroupCode(){ public String getGroupCode(){
...@@ -121,11 +139,10 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -121,11 +139,10 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
} }
//2.保存值班信息 //2.保存值班信息
insertPersonShift(instanceId, dutyPersonDto,ActionStatus.METHOD_ADD.getCode()); insertPersonShift(instanceId, dutyPersonDto,ActionStatus.METHOD_ADD.getCode());
// 生成变更日志
createDutyPersonShiftLog(dutyPersonDto, false, ActionStatus.METHOD_ADD.getCode());
//3.返回保存后的数据 //3.返回保存后的数据
return dutyPersonDto; return dutyPersonDto;
} }
@Override @Override
...@@ -158,6 +175,8 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -158,6 +175,8 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
} }
//5.更新值班信息人日期数据 //5.更新值班信息人日期数据
insertPersonShift(instanceId, dutyPersonDto, ActionStatus.METHOD_UPDATE.getCode()); insertPersonShift(instanceId, dutyPersonDto, ActionStatus.METHOD_UPDATE.getCode());
// 生成变更日志
createDutyPersonShiftLog(dutyPersonDto, false, ActionStatus.METHOD_UPDATE.getCode());
return dutyPersonDto; return dutyPersonDto;
} }
...@@ -179,7 +198,6 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -179,7 +198,6 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
} }
} }
public void dataCheck(List<DutyPersonShiftDto> dutyShiftList,Long instanceId ,String type){ public void dataCheck(List<DutyPersonShiftDto> dutyShiftList,Long instanceId ,String type){
try { try {
//获取排班月份的最大及最小日期 //获取排班月份的最大及最小日期
...@@ -197,7 +215,7 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -197,7 +215,7 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
}; };
} }
}); });
//若修改时将原有值班改为请选择 需删除原有排班 否则无法置空原有数据 //若修改时将原有值班改为请选择 需删除原有排班 否则无法置空原有数据
if (currentData.size()>0 && ActionStatus.METHOD_UPDATE.getCode().equals(type) ){ if (currentData.size()>0 && ActionStatus.METHOD_UPDATE.getCode().equals(type) ){
ArrayList<Long> ids = new ArrayList<>(); ArrayList<Long> ids = new ArrayList<>();
currentData.stream().forEach(e->ids.add(e.getSequenceNbr())); currentData.stream().forEach(e->ids.add(e.getSequenceNbr()));
...@@ -270,12 +288,12 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut ...@@ -270,12 +288,12 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
}); });
return temp; return temp;
} }
public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType) { public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType) {
List<Map<String, Object>> list = dayDutyPersonList(dutyDay, shiftId, postType); List<Map<String, Object>> list = dayDutyPersonList(dutyDay, shiftId, postType);
list.stream().forEach(i->{ list.stream().forEach(i->{
List<Object> fieldsList= new ArrayList<Object>(); List<Object> fieldsList= new ArrayList<Object>();
...@@ -288,14 +306,14 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType ...@@ -288,14 +306,14 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType
map.clear(); map.clear();
map.put("name", "微型消防站"); map.put("name", "微型消防站");
map.put("value",i.get("deptName").toString()); map.put("value",i.get("deptName").toString());
}); });
return postType; return postType;
} }
public static void main(String[] args) { public static void main(String[] args) {
String ssString="[{\"teamName\":\"发士大夫大师傅\",\"shiftId\":\"1437585222345547778\",\"carName\":\"特种消防车(46586458)\",\"postType\":\"\",\"dutyArea\":\"测试控制室\",\"dutyAreaId\":\"1382166994773610497\",\"postTypeName\":\"\",\"userName\":\"故障报修\",\"userId\":\"1428653787706347522\",\"dutyDate\":\"2021-10-12 00:00:00\",\"carId\":\"1432590747256770562\",\"shiftName\":\"晚班\",\"instanceId\":\"1447490875843239937\",\"teamId\":\"1404995716634050561\",\"groupCode\":\"dutyCar\"},{\"teamName\":\"发士大夫大师傅\",\"shiftId\":\"1432883228491972609\",\"carName\":\"特种消防车(46586458)\",\"postType\":\"\",\"dutyArea\":\"消防小室-shg\",\"dutyAreaId\":\"1382530839199387650\",\"postTypeName\":\"\",\"userName\":\"78678676\",\"userId\":\"1435886728803000322\",\"dutyDate\":\"2021-10-12 00:00:00\",\"carId\":\"1432590747256770562\",\"shiftName\":\"夜班\",\"instanceId\":\"1447490812534415361\",\"teamId\":\"1404995716634050561\",\"groupCode\":\"dutyCar\"},{\"teamName\":\"发士大夫大师傅\",\"shiftId\":\"1432883228491972609\",\"carName\":\"特种消防车(46586458)\",\"postType\":\"1\",\"dutyArea\":\"建构住-shg\",\"dutyAreaId\":\"1382157469081407490\",\"postTypeName\":\"指挥员\",\"userName\":\"张小四6\",\"userId\":\"1435072204550225922\",\"dutyDate\":\"2021-10-12 00:00:00\",\"carId\":\"1432590747256770562\",\"shiftName\":\"夜班\",\"instanceId\":\"1447490699435008001\",\"teamId\":\"1404995716634050561\",\"groupCode\":\"dutyCar\"}]\r\n" String ssString="[{\"teamName\":\"发士大夫大师傅\",\"shiftId\":\"1437585222345547778\",\"carName\":\"特种消防车(46586458)\",\"postType\":\"\",\"dutyArea\":\"测试控制室\",\"dutyAreaId\":\"1382166994773610497\",\"postTypeName\":\"\",\"userName\":\"故障报修\",\"userId\":\"1428653787706347522\",\"dutyDate\":\"2021-10-12 00:00:00\",\"carId\":\"1432590747256770562\",\"shiftName\":\"晚班\",\"instanceId\":\"1447490875843239937\",\"teamId\":\"1404995716634050561\",\"groupCode\":\"dutyCar\"},{\"teamName\":\"发士大夫大师傅\",\"shiftId\":\"1432883228491972609\",\"carName\":\"特种消防车(46586458)\",\"postType\":\"\",\"dutyArea\":\"消防小室-shg\",\"dutyAreaId\":\"1382530839199387650\",\"postTypeName\":\"\",\"userName\":\"78678676\",\"userId\":\"1435886728803000322\",\"dutyDate\":\"2021-10-12 00:00:00\",\"carId\":\"1432590747256770562\",\"shiftName\":\"夜班\",\"instanceId\":\"1447490812534415361\",\"teamId\":\"1404995716634050561\",\"groupCode\":\"dutyCar\"},{\"teamName\":\"发士大夫大师傅\",\"shiftId\":\"1432883228491972609\",\"carName\":\"特种消防车(46586458)\",\"postType\":\"1\",\"dutyArea\":\"建构住-shg\",\"dutyAreaId\":\"1382157469081407490\",\"postTypeName\":\"指挥员\",\"userName\":\"张小四6\",\"userId\":\"1435072204550225922\",\"dutyDate\":\"2021-10-12 00:00:00\",\"carId\":\"1432590747256770562\",\"shiftName\":\"夜班\",\"instanceId\":\"1447490699435008001\",\"teamId\":\"1404995716634050561\",\"groupCode\":\"dutyCar\"}]\r\n"
+ ""; + "";
...@@ -333,66 +351,296 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType ...@@ -333,66 +351,296 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType
public List<Map<String, Object>> queryByCompanyNew(String bizOrgName){ public List<Map<String, Object>> queryByCompanyNew(String bizOrgName){
return dutyPersonShiftMapper.queryByCompanyNew(bizOrgName); return dutyPersonShiftMapper.queryByCompanyNew(bizOrgName);
} }
public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode) { public Object getSchedulingDutyForSpecifyDate(String dutyDay, Long shiftId, String postType, String fieldCode) {
List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getNewEquipmentForSpecifyDate(dutyDay, List<Map<String, String>> dutyLogs = dutyPersonShiftLogMapper.selectSpecificDateLogForPerson(dutyDay);
this.getGroupCode(), "deptId", "deptName", "result.deptId"); Map<String, List<Map<String, String>>> dutyLogGroups = dutyLogs.stream().collect(Collectors.groupingBy(v -> v.get("deptName")));
if (equipmentList == null || equipmentList.size() < 1 || equipmentList.get(0) == null) { List<Object> result = new ArrayList<>();
return null;
} // 获取排序规则: BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List<Object> detailList = new ArrayList<Object>(); List<OrgUsr> orgUserSortRules = orgUsrMapper.selectList(
for (Map<String, Object> map : equipmentList) { Wrappers.<OrgUsr>lambdaQuery()
List<Object> resultList = new ArrayList<Object>(); .select(OrgUsr::getBizOrgName, OrgUsr::getOrgExpandAttr1)
LinkedHashMap<String, Object> titleMap_2 = new LinkedHashMap<String, Object>(); .isNotNull(OrgUsr::getOrgExpandAttr1)
if(map.containsKey("deptName") && map.get("deptName") != null){ .ne(OrgUsr::getOrgExpandAttr1, "")
resultList.add( map.get("deptName").toString()); ).stream().sorted(Comparator.comparing(v -> Integer.parseInt(v.getOrgExpandAttr1()))).collect(Collectors.toList());
} // orgUserSortRules中的BizOrgName对应dutyLogGroups的key, 按照OrgExpandAttr1排序, OrgExpandAttr1值越小越靠前,否则靠后。
String carId = map.get("deptId").toString(); Map<String, List<Map<String, String>>> sortedDutyLogGroups = new LinkedHashMap<>();
Map<String, Object> instanceMap = dutyPersonShiftMapper.getInstanceIdForSpecifyDateAndEquipment(dutyDay, for (OrgUsr orgUsr : orgUserSortRules) {
this.getGroupCode(), carId); String bizOrgName = orgUsr.getBizOrgName();
if (instanceMap == null) { if (dutyLogGroups.containsKey(bizOrgName)) {
continue; sortedDutyLogGroups.put(bizOrgName, dutyLogGroups.get(bizOrgName));
} }
String instanceId = instanceMap.get("instanceIds").toString(); }
if (StringUtils.isNotBlank(instanceId)) { for (Map.Entry<String, List<Map<String, String>>> entry : dutyLogGroups.entrySet()) {
String[] instanceIds = instanceId.split(","); String key = entry.getKey();
if (!sortedDutyLogGroups.containsKey(key)) {
// 获取当前装备ID下的排版数据 sortedDutyLogGroups.put(key, entry.getValue());
List<Map<String, Object>> specifyDateList = dutyPersonShiftMapper }
.getPositionStaffDutyForSpecifyDate(dutyDay, this.getGroupCode(), instanceIds, }
null, fieldCode);
if (specifyDateList == null || specifyDateList.size() < 1 || specifyDateList.get(0) == null) { // 岗位排序规则 name: 岗位名称,sortNum: 排序字段
continue; List<DataDictionary> postSortRules = dataDictionaryMapper.selectList(
} Wrappers.<DataDictionary>lambdaQuery()
for (Map<String, Object> specify : specifyDateList) { .select(DataDictionary::getName, DataDictionary::getSortNum)
LinkedHashMap<String, Object> infoMap_2 = new LinkedHashMap<String, Object>(); .eq(DataDictionary::getType, "DUTY_POST_TYPE")
if( specify.containsKey("postTypeName")&& specify.get("postTypeName")!=null && specify.containsKey("userName")&& specify.get("userName")!=null ) { .eq(DataDictionary::getIsDelete, false)
infoMap_2.put(specify.get("postTypeName").toString(),specify.get("userName").toString()); ).stream().sorted(Comparator.comparing(DataDictionary::getSortNum)).collect(Collectors.toList());
resultList.add(infoMap_2);
} // 组装数据
} for (Map.Entry<String, List<Map<String, String>>> entry : sortedDutyLogGroups.entrySet()) {
} List<Object> items = new ArrayList<>();
detailList.add(resultList); String key = entry.getKey();
} List<Map<String, String>> value = entry.getValue();
return detailList;
items.add(key);
// postSortRules的name对应value的postTypeName,按照sortNum排序,sortNum值越小越靠前,否则靠后。
Map<String, String> sortedValue = new LinkedHashMap<>();
for (DataDictionary dataDictionary : postSortRules) {
String name = dataDictionary.getName();
for (Map<String, String> map : value) {
if (name.equals(map.get("postTypeName"))) {
sortedValue.put(name, map.getOrDefault("dutyUsers", ""));
}
}
}
// 未匹配到的数据,按照原有顺序放到最后
for (Map<String, String> map : value) {
String postTypeName = map.get("postTypeName");
if (!sortedValue.containsKey(postTypeName)) {
sortedValue.put(postTypeName, map.getOrDefault("dutyUsers", ""));
}
}
for (Map.Entry<String, String> sortedEntry : sortedValue.entrySet()) {
Map<String, String> itemN = new HashMap<String, String>() {{
this.put(sortedEntry.getKey(), sortedEntry.getValue());
}};
items.add(itemN);
}
result.add(items);
}
return result;
} }
public Object getDutyPersonShiftLogData(String dutyDay, String fieldCode) {
List<Map<String, Object>> equipmentList = dutyPersonShiftMapper.getNewEquipmentForSpecifyDate(dutyDay,
this.getGroupCode(), "deptId", "deptName", "result.deptId");
if (equipmentList == null || equipmentList.isEmpty() || equipmentList.get(0) == null) {
return null;
}
List<Object> detailList = new ArrayList<>();
for (Map<String, Object> map : equipmentList) {
List<Object> resultList = new ArrayList<>();
if(map.containsKey("deptName") && map.get("deptName") != null){
resultList.add( map.get("deptName").toString());
}
String carId = map.get("deptId").toString();
Map<String, Object> instanceMap = dutyPersonShiftMapper.getInstanceIdForSpecifyDateAndEquipment(dutyDay,
this.getGroupCode(), carId);
if (instanceMap == null) {
continue;
}
String instanceId = instanceMap.get("instanceIds").toString();
if (StringUtils.isNotBlank(instanceId)) {
String[] instanceIds = instanceId.split(",");
// 获取当前装备ID下的排版数据
List<Map<String, Object>> specifyDateList = dutyPersonShiftMapper
.getPositionStaffDutyForSpecifyDate(dutyDay, this.getGroupCode(), instanceIds,
null, fieldCode);
if (specifyDateList == null || specifyDateList.isEmpty() || specifyDateList.get(0) == null) {
continue;
}
for (Map<String, Object> specify : specifyDateList) {
LinkedHashMap<String, Object> infoMap_2 = new LinkedHashMap<>();
if( specify.containsKey("postTypeName")&& specify.get("postTypeName")!=null && specify.containsKey("userName")&& specify.get("userName")!=null ) {
infoMap_2.put(specify.get("postTypeName").toString(),specify.get("userName").toString());
resultList.add(infoMap_2);
}
}
}
detailList.add(resultList);
}
return detailList;
}
@Override
public void writeHistoryDutyLog() {
List<Map<String, Object>> list;
try {
list = this.list(null, "1980-01-01", "9999-12-12");
} catch (ParseException e) {
throw new RuntimeException(e);
}
for (Map<String, Object> map : list) {
DutyPersonDto dutyPersonDto = (DutyPersonDto) Bean.mapToBean(map, DutyPersonDto.class);
this.createDutyPersonShiftLog(dutyPersonDto, true, null);
}
}
public Map<String, List<DutyPersonShiftLog>> getDownloadData(String beginDate, String endDate) throws ParseException {
Map<String, List<DutyPersonShiftLog>> resultSortedMap = new LinkedHashMap<>();
List<DutyPersonShiftLog> dutyCarLogs = dutyPersonShiftLogMapper.selectList(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.ge(DutyPersonShiftLog::getDutyDate, beginDate)
.le(DutyPersonShiftLog::getDutyDate, endDate)
.eq(DutyPersonShiftLog::getGroupCode, "dutyPerson")
.eq(DutyPersonShiftLog::getIsDelete, false)
);
if (dutyCarLogs.isEmpty()) {
return resultSortedMap;
}
List<Long> userIds = dutyCarLogs.stream().map(v -> Long.valueOf(v.getDutyUserId())).distinct().collect(Collectors.toList());
// 获取人员姓名与人员部门的关系
List<Map<String, String>> userDeptMapList = orgUsrMapper.selectUserDeptMap(userIds);
// userDeptMapList 转为 Map, key: userName, value
Map<String, String> userDeptMap = new HashMap<>();
for (Map<String, String> map : userDeptMapList) {
userDeptMap.put(map.get("userName"), map.get("deptName"));
}
Map<String, List<DutyPersonShiftLog>> unsortedMap = dutyCarLogs.stream().collect(Collectors.groupingBy(DutyPersonShiftLog::getDutyUser));
// 先按照人员所属部门排序, 部门相同的情况下按照人员岗位排序即可
// 获取人员部门排序规则: BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List<OrgUsr> orgUserSortRules = orgUsrMapper.selectList(
Wrappers.<OrgUsr>lambdaQuery()
.select(OrgUsr::getBizOrgName, OrgUsr::getOrgExpandAttr1)
.isNotNull(OrgUsr::getOrgExpandAttr1)
.ne(OrgUsr::getOrgExpandAttr1, "")
).stream().sorted(Comparator.comparing(v -> Integer.parseInt(v.getOrgExpandAttr1()))).collect(Collectors.toList());
// 进行排序:按照人员部门排序 userDeptMap为人员与所属部门映射,orgUserSortRules为部门排序规则。orgUserSortRules中部门的顺序即为部门排序规则
for (OrgUsr orgUsr : orgUserSortRules) {
String bizOrgName = orgUsr.getBizOrgName();
for (Map.Entry<String, List<DutyPersonShiftLog>> entry : unsortedMap.entrySet()) {
String userName = entry.getKey();
List<DutyPersonShiftLog> dutyPersonShiftLogs = entry.getValue();
if (userDeptMap.containsKey(userName) && userDeptMap.get(userName).equals(bizOrgName)) {
resultSortedMap.put(userName, dutyPersonShiftLogs);
}
}
}
// 未匹配到的数据,按照原有顺序放到最后
for (Map.Entry<String, List<DutyPersonShiftLog>> entry : unsortedMap.entrySet()) {
String userName = entry.getKey();
List<DutyPersonShiftLog> dutyPersonShiftLogs = entry.getValue();
if (!resultSortedMap.containsKey(userName)) {
resultSortedMap.put(userName, dutyPersonShiftLogs);
}
}
return resultSortedMap;
}
@SuppressWarnings("Duplicates")
public void createDutyPersonShiftLog(DutyPersonDto dutyPersonDto, boolean isInit, String actionCode) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<DutyPersonShiftDto> dutyPersonShift = dutyPersonDto.getDutyShift();
final String groupCode = "dutyPerson";
// 新建/更新排班时处理跨月数据
if (!isInit && StringUtils.isNotBlank(actionCode)) {
if (Objects.nonNull(dutyPersonShift) && !dutyPersonShift.isEmpty()) {
// 拿到排班月份 yyyy-MM
String dutyDate = dateFormat.format(dutyPersonShift.get(0).getDutyDate());
dutyDate = dutyDate.substring(0, 7);
String today = dateFormat.format(new Date());
if (today.substring(0, 7).equals(dutyDate)) {
dutyDate = today;
} else {
dutyDate += "-01";
}
dutyPersonShiftLogMapper.delete(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.eq(DutyPersonShiftLog::getGroupCode, groupCode)
.eq(DutyPersonShiftLog::getDutyUser, dutyPersonDto.getUserName())
.ge(DutyPersonShiftLog::getDutyDate, dutyDate)
.ge(DutyPersonShiftLog::getDutyDate, dateFormat.format(new Date()))
.eq(DutyPersonShiftLog::getIsDelete, false)
);
}
dutyPersonShift.clear();
try {
List<Map<String, Object>> list = list(null, dateFormat.format(new Date()), "9999-12-12");
list = list.stream().filter(map -> Objects.equals(map.get("userName"), dutyPersonDto.getUserName())).collect(Collectors.toList());
for (Map<String, Object> map : list) {
DutyCarDto dutyCarDto = (DutyCarDto) Bean.mapToBean(map, DutyCarDto.class);
List<DutyPersonShiftDto> dutyShifts = dutyCarDto.getDutyShift().stream().filter(v -> isAfterToday(v.getDutyDate())).collect(Collectors.toList());
dutyPersonShift.addAll(dutyShifts);
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
Set<String> dutyDates = dutyPersonShift.stream().map(v -> dateFormat.format(v.getDutyDate())).collect(Collectors.toSet());
if (dutyDates.isEmpty()) {
return;
}
Map<Date, List<DutyPersonShiftLog>> dutyLogGroups = dutyPersonShiftLogMapper.selectList(
Wrappers.<DutyPersonShiftLog>lambdaQuery()
.in(DutyPersonShiftLog::getDutyDate, dutyDates)
.eq(DutyPersonShiftLog::getGroupCode, groupCode)
.eq(DutyPersonShiftLog::getDutyUser, dutyPersonDto.getUserName())
.eq(DutyPersonShiftLog::getIsDelete, false)
).stream().collect(Collectors.groupingBy(DutyPersonShiftLog::getDutyDate));
for (DutyPersonShiftDto dutyPersonShiftDto : dutyPersonShift) {
// 非初始化非历史数据禁止修改
if (!isAfterToday(dutyPersonShiftDto.getDutyDate()) && !isInit) {
continue;
}
List<DutyPersonShiftLog> dutyPersonShiftLogs = dutyLogGroups.get(dutyPersonShiftDto.getDutyDate());
DutyPersonShiftLog dutyPersonShiftLog = Objects.nonNull(dutyPersonShiftLogs) && !dutyPersonShiftLogs.isEmpty() ? dutyPersonShiftLogs.get(0) : null;
// 日志不存在:新建
if (Objects.isNull(dutyPersonShiftLog)) {
dutyPersonShiftLog = new DutyPersonShiftLog();
dutyPersonShiftLog.setInstanceId(dutyPersonShiftDto.getInstanceId());
dutyPersonShiftLog.setDutyDate(dutyPersonShiftDto.getDutyDate());
dutyPersonShiftLog.setGroupCode(groupCode);
dutyPersonShiftLog.setDeptName(dutyPersonDto.getDeptName());
dutyPersonShiftLog.setDutyUserId(dutyPersonDto.getUserId());
dutyPersonShiftLog.setDutyUser(dutyPersonDto.getUserName());
dutyPersonShiftLog.setPostTypeName(dutyPersonDto.getPostTypeName());
dutyPersonShiftLog.setDutyArea(dutyPersonDto.getDutyArea());
String shiftName = dutyPersonShiftDto.getShiftName();
if (StringUtils.isBlank(shiftName) && Objects.nonNull(dutyPersonShiftDto.getShiftId())) {
DutyShift dutyShift = dutyShiftService.getById(dutyPersonShiftDto.getShiftId());
dutyPersonShiftDto.setShiftName(dutyShift.getName());
}
dutyPersonShiftLog.setShiftName(dutyPersonShiftDto.getShiftName());
dutyPersonShiftLogMapper.insert(dutyPersonShiftLog);
continue;
}
if (isAfterToday(dutyPersonShiftDto.getDutyDate())) {
dutyPersonShiftLog.setInstanceId(dutyPersonShiftDto.getInstanceId());
dutyPersonShiftLog.setDeptName(dutyPersonDto.getDeptName());
dutyPersonShiftLog.setPostTypeName(dutyPersonDto.getPostTypeName());
dutyPersonShiftLog.setDutyArea(dutyPersonDto.getDutyArea());
String shiftName = dutyPersonShiftDto.getShiftName();
if (StringUtils.isBlank(shiftName) && Objects.nonNull(dutyPersonShiftDto.getShiftId())) {
DutyShift dutyShift = dutyShiftService.getById(dutyPersonShiftDto.getShiftId());
dutyPersonShiftDto.setShiftName(dutyShift.getName());
}
dutyPersonShiftLog.setShiftName(dutyPersonShiftDto.getShiftName());
dutyPersonShiftLogMapper.update(
dutyPersonShiftLog,
Wrappers.<DutyPersonShiftLog>lambdaUpdate()
.eq(DutyPersonShiftLog::getDutyDate, dutyPersonShiftDto.getDutyDate())
.eq(DutyPersonShiftLog::getGroupCode, groupCode)
.eq(DutyPersonShiftLog::getDutyUser, dutyPersonDto.getUserName())
.eq(DutyPersonShiftLog::getIsDelete, false)
);
}
}
;
}
});
}
} }
...@@ -13,7 +13,9 @@ import javax.servlet.http.HttpServletResponse; ...@@ -13,7 +13,9 @@ import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.dto.*; import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.*;
import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint; import com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper; import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto; import com.yeejoin.amos.boot.module.jcs.api.dto.SignDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto; import com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto;
...@@ -52,21 +54,6 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils; ...@@ -52,21 +54,6 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.QRCodeUtil; import com.yeejoin.amos.boot.biz.common.utils.QRCodeUtil;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.api.entity.FireChemical;
import com.yeejoin.amos.boot.module.common.api.entity.FireExperts;
import com.yeejoin.amos.boot.module.common.api.entity.FireStation;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.entity.Firefighters;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersContacts;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersEducation;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersPost;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersWorkexperience;
import com.yeejoin.amos.boot.module.common.api.entity.MaintenanceCompany;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.entity.RescueEquipment;
import com.yeejoin.amos.boot.module.common.api.entity.SpecialPositionStaff;
import com.yeejoin.amos.boot.module.common.api.excel.ExcelUtil; import com.yeejoin.amos.boot.module.common.api.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.common.api.service.IDutyFireFightingService; import com.yeejoin.amos.boot.module.common.api.service.IDutyFireFightingService;
import com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService; import com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService;
...@@ -192,7 +179,10 @@ public class ExcelServiceImpl { ...@@ -192,7 +179,10 @@ public class ExcelServiceImpl {
@Autowired @Autowired
SignServiceImpl signServiceImpl; SignServiceImpl signServiceImpl;
@Autowired
DutyPersonShiftLogMapper dutyPersonShiftLogMapper;
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException { public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl(); String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url); Class<?> clz = Class.forName(url);
...@@ -236,7 +226,7 @@ public class ExcelServiceImpl { ...@@ -236,7 +226,7 @@ public class ExcelServiceImpl {
} }
public void commonExport(HttpServletResponse response, ExcelDto excelDto, Map par) { public void commonExport(HttpServletResponse response, ExcelDto excelDto, Map par) {
// ReginParams reginParams= getCurrentAllInfo(); // ReginParams reginParams= getCurrentAllInfo();
// boolean authFalg= false; // boolean authFalg= false;
// if(reginParams ==null) { // if(reginParams ==null) {
...@@ -330,7 +320,7 @@ public class ExcelServiceImpl { ...@@ -330,7 +320,7 @@ public class ExcelServiceImpl {
break; break;
} }
String nameString =null; String nameString =null;
Long bizCompanyId =null; Long bizCompanyId =null;
if(par!=null && par.size()>0) { if(par!=null && par.size()>0) {
nameString =par.containsKey("name")?par.get("name").toString():null; nameString =par.containsKey("name")?par.get("name").toString():null;
bizCompanyId =par.containsKey("bizCompanyId")?Long.parseLong(par.get("bizCompanyId").toString()):null; bizCompanyId =par.containsKey("bizCompanyId")?Long.parseLong(par.get("bizCompanyId").toString()):null;
...@@ -1246,7 +1236,7 @@ public class ExcelServiceImpl { ...@@ -1246,7 +1236,7 @@ public class ExcelServiceImpl {
} }
private void excelImportFireStation(MultipartFile multipartFile) throws Exception { private void excelImportFireStation(MultipartFile multipartFile) throws Exception {
List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1); List<FireStationDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, FireStationDto.class, 1);
Map<String, String> maps = getAllBuildingIdForParentBuilingIds(excelDtoList); Map<String, String> maps = getAllBuildingIdForParentBuilingIds(excelDtoList);
List<FireStation> excelEntityList = new ArrayList<>(); List<FireStation> excelEntityList = new ArrayList<>();
...@@ -1585,7 +1575,7 @@ public class ExcelServiceImpl { ...@@ -1585,7 +1575,7 @@ public class ExcelServiceImpl {
redisUtils.set(uuidString, 2); redisUtils.set(uuidString, 2);
} }
} }
} }
private void ImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception { private void ImportDutyPerson(MultipartFile multipartFile, String dutyType) throws Exception {
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
...@@ -1622,7 +1612,7 @@ public class ExcelServiceImpl { ...@@ -1622,7 +1612,7 @@ public class ExcelServiceImpl {
dutyFirstAidService.saveImportData(dataList); dutyFirstAidService.saveImportData(dataList);
} }
} }
} }
private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyFirstAidData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) { for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) {
...@@ -1689,7 +1679,7 @@ public class ExcelServiceImpl { ...@@ -1689,7 +1679,7 @@ public class ExcelServiceImpl {
Map<String, Object> dutyPersonDtoMap = Bean.BeantoMap(dutyFirstAidDto); Map<String, Object> dutyPersonDtoMap = Bean.BeantoMap(dutyFirstAidDto);
dataList.add(dutyPersonDtoMap); dataList.add(dutyPersonDtoMap);
} }
} }
private void excelImportSafeReport(MultipartFile multipartFile) throws Exception { private void excelImportSafeReport(MultipartFile multipartFile) throws Exception {
...@@ -1784,6 +1774,12 @@ public class ExcelServiceImpl { ...@@ -1784,6 +1774,12 @@ public class ExcelServiceImpl {
dataList.add(dutyCarDtoMap); dataList.add(dutyCarDtoMap);
} }
} }
// 生成变更日志
dataList.forEach(v -> {
DutyCarDto dutyCarDto = (DutyCarDto) Bean.mapToBean(v, DutyCarDto.class);
dutyCarService.createDutyPersonShiftLog(dutyCarDto, false, null);
});
} }
private void initDutyPersonData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyPersonData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
...@@ -1848,6 +1844,12 @@ public class ExcelServiceImpl { ...@@ -1848,6 +1844,12 @@ public class ExcelServiceImpl {
dataList.add(dutyPersonDtoMap); dataList.add(dutyPersonDtoMap);
} }
} }
// 生成变更日志
dataList.forEach(v -> {
DutyPersonDto dutyPersonDto = (DutyPersonDto) Bean.mapToBean(v, DutyPersonDto.class);
dutyPersonService.createDutyPersonShiftLog(dutyPersonDto, false, null);
});
} }
private void initDutyFireFightingData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) { private void initDutyFireFightingData(XSSFSheet sheet, List<Map<String, Object>> dataList, List<Date> dayByMonth) {
...@@ -1956,8 +1958,10 @@ public class ExcelServiceImpl { ...@@ -1956,8 +1958,10 @@ public class ExcelServiceImpl {
String ids) { String ids) {
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
if (ExcelEnums.CLZQ.getType().equals(excelDto.getType())) { if (ExcelEnums.CLZQ.getType().equals(excelDto.getType())) {
excelDto.setClassUrl("com.yeejoin.amos.boot.module.common.api.dto.TemplateDutyCarExcelDto");
data = initDutyCarTemplate(ids); data = initDutyCarTemplate(ids);
} else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) { } else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) {
excelDto.setClassUrl("com.yeejoin.amos.boot.module.common.api.dto.TemplateDutyPersonExcelDto");
data = initDutyPersonTemplate(ids); data = initDutyPersonTemplate(ids);
} else if (ExcelEnums.WXXFZB.getType().equals(excelDto.getType())) { } else if (ExcelEnums.WXXFZB.getType().equals(excelDto.getType())) {
data = initDutyDutyFireFightingTemplate(ids); data = initDutyDutyFireFightingTemplate(ids);
...@@ -2170,28 +2174,45 @@ public class ExcelServiceImpl { ...@@ -2170,28 +2174,45 @@ public class ExcelServiceImpl {
private List<List<Object>> initDutyCarInfo(String beginDate, String endDate, List<String> dayByMonth) private List<List<Object>> initDutyCarInfo(String beginDate, String endDate, List<String> dayByMonth)
throws ParseException { throws ParseException {
// 查询已值班数据 // 查询已值班数据
List<DutyCarDto> contentList = dutyCarService.downloadList(beginDate, endDate); Map<String, List<DutyPersonShiftLog>> dutyPersonShiftLogs = dutyCarService.getDownloadData(beginDate, endDate);
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
List<String> monthDays = getMonthDays(beginDate);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// 组装导出数据 // 组装导出数据
if (!contentList.isEmpty()) { if (!dutyPersonShiftLogs.isEmpty()) {
AtomicInteger row = new AtomicInteger(1); AtomicInteger row = new AtomicInteger(1);
contentList.forEach(o -> { for (Map.Entry<String, List<DutyPersonShiftLog>> entry : dutyPersonShiftLogs.entrySet()) {
String carName = entry.getKey();
List<DutyPersonShiftLog> shiftLogs = entry.getValue();
Map<String, List<DutyPersonShiftLog>> shiftLogsMap = shiftLogs.stream().collect(Collectors.groupingBy(v -> formatter.format(v.getDutyDate())));
ArrayList<Object> list = new ArrayList<>(); ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement()); list.add(row.getAndIncrement());
list.add(o.getTeamName()); list.add(carName);
list.add(o.getUserName());
list.add(o.getPostTypeName());
list.add(o.getCarName());
list.add(o.getDutyArea());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, list);
for (String monthDay : monthDays) {
List<DutyPersonShiftLog> targetLogs = shiftLogsMap.get(monthDay);
if (Objects.isNull(targetLogs) || targetLogs.isEmpty()) {
list.add("");
continue;
}
DutyPersonShiftLog shiftLog = targetLogs.get(0);
String deptName = shiftLog.getDeptName();
String dutyUsers = targetLogs.stream().map(DutyPersonShiftLog::getDutyUser).distinct().collect(Collectors.joining(","));
String value = String.format("%s|%s", deptName, dutyUsers);
list.add(value);
}
data.add(list); data.add(list);
}); }
} }
return data; return data;
} }
private List<String> getMonthDays(String date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return DateUtils.getDayByMonth(date).stream().map(formatter::format).collect(Collectors.toList());
}
private void initDutyShift(List<String> dayByMonth, List<DutyPersonShiftDto> dutyShift, ArrayList<Object> list) { private void initDutyShift(List<String> dayByMonth, List<DutyPersonShiftDto> dutyShift, ArrayList<Object> list) {
HashMap<String, String> dutyShiftMap = new HashMap<>(); HashMap<String, String> dutyShiftMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
...@@ -2209,24 +2230,36 @@ public class ExcelServiceImpl { ...@@ -2209,24 +2230,36 @@ public class ExcelServiceImpl {
private List<List<Object>> initDutyPersonInfo(String beginDate, String endDate, List<String> dayByMonth) private List<List<Object>> initDutyPersonInfo(String beginDate, String endDate, List<String> dayByMonth)
throws ParseException { throws ParseException {
// 查询已值班数据 // 查询已值班数据
List<DutyPersonDto> contentList = iDutyPersonService.downloadList(beginDate, endDate); Map<String, List<DutyPersonShiftLog>> dutyPersonShiftLogs = dutyPersonService.getDownloadData(beginDate, endDate);
List<List<Object>> data = new ArrayList<>(); List<List<Object>> data = new ArrayList<>();
List<String> monthDays = getMonthDays(beginDate);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// 组装导出数据 // 组装导出数据
if (!contentList.isEmpty()) { if (!dutyPersonShiftLogs.isEmpty()) {
AtomicInteger row = new AtomicInteger(1); AtomicInteger row = new AtomicInteger(1);
contentList.forEach(o -> { for (Map.Entry<String, List<DutyPersonShiftLog>> entry : dutyPersonShiftLogs.entrySet()) {
String userName = entry.getKey();
List<DutyPersonShiftLog> shiftLogs = entry.getValue();
shiftLogs = shiftLogs.stream().sorted(Comparator.comparing(DutyPersonShiftLog::getDutyDate)).collect(Collectors.toList());
DutyPersonShiftLog dutyPersonShiftLog = shiftLogs.get(0);
ArrayList<Object> list = new ArrayList<>(); ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement()); list.add(row.getAndIncrement());
list.add(o.getUserId()); list.add(dutyPersonShiftLog.getDutyUserId());
list.add(o.getUserName()); list.add(userName);
list.add(o.getDeptName());
list.add(o.getPostTypeName()); for (String monthDay : monthDays) {
list.add(o.getDutyArea()); List<DutyPersonShiftLog> targetLogs = shiftLogs.stream().filter(v -> Objects.equals(monthDay, formatter.format(v.getDutyDate()))).collect(Collectors.toList());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift(); if (targetLogs.isEmpty()) {
initDutyShift(dayByMonth, dutyShift, list); list.add(NOT_DUTY);
continue;
}
DutyPersonShiftLog shiftLog = targetLogs.get(0);
String value = String.format("%s|%s|%s|%s", shiftLog.getDeptName(), shiftLog.getPostTypeName(), Objects.isNull(shiftLog.getDutyArea()) ? "无" : shiftLog.getDutyArea(), shiftLog.getShiftName());
list.add(value);
}
data.add(list); data.add(list);
}); }
} }
return data; return data;
} }
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="chenhao" id="2021-08-31-chenhao-1"> <changeSet author="chenhao" id="2021-08-31-chenhao-1">
<comment>modify table cb_firefighters_thought add one columns</comment> <comment>modify table cb_firefighters_thought add one columns</comment>
<sql> <sql>
ALTER TABLE `cb_firefighters_thought` modify talking_time datetime COMMENT '谈话时间'; ALTER TABLE `cb_firefighters_thought` modify talking_time datetime COMMENT '谈话时间';
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
INSERT INTO cb_data_dictionary (`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES ('1169', '1169', '环支状管网', 'XFJSGW', NULL, NULL, NULL, NULL, NULL, '\0', '1'); INSERT INTO cb_data_dictionary (`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES ('1169', '1169', '环支状管网', 'XFJSGW', NULL, NULL, NULL, NULL, NULL, '\0', '1');
INSERT INTO cb_data_dictionary (`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES ('1170', '1170', '可用', 'SYZT', NULL, NULL, NULL, NULL, NULL, '\0', '1'); INSERT INTO cb_data_dictionary (`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES ('1170', '1170', '可用', 'SYZT', NULL, NULL, NULL, NULL, NULL, '\0', '1');
INSERT INTO cb_data_dictionary (`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES ('1171', '1171', '不可用', 'SYZT', NULL, NULL, NULL, NULL, NULL, '\0', '1'); INSERT INTO cb_data_dictionary (`sequence_nbr`, `code`, `name`, `type`, `type_desc`, `parent`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`, `sort_num`) VALUES ('1171', '1171', '不可用', 'SYZT', NULL, NULL, NULL, NULL, NULL, '\0', '1');
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="guowubin" id="1629430730658-1"> <changeSet author="guowubin" id="1629430730658-1">
<comment>alter table jc_controller</comment> <comment>alter table jc_controller</comment>
...@@ -561,7 +561,7 @@ ...@@ -561,7 +561,7 @@
'调派任务状态(执行中:executing,已完成:finished)'; '调派任务状态(执行中:executing,已完成:finished)';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="chenhao" id="2021-09-13-chenhao-1"> <changeSet author="chenhao" id="2021-09-13-chenhao-1">
<comment>update data cb_firefighters_workexperience</comment> <comment>update data cb_firefighters_workexperience</comment>
<sql> <sql>
...@@ -1583,7 +1583,7 @@ ...@@ -1583,7 +1583,7 @@
INSERT INTO cb_dynamic_form_group (`sequence_nbr`, `group_name`, `group_code`, `parent_id`, `group_config`, `org_code`, `sort`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`) VALUES ('132828674815', '值班消防', 'dutyFireFighting', '0', NULL, '10', '1', NULL, NULL, '2021-09-28 10:34:05', '\0'); INSERT INTO cb_dynamic_form_group (`sequence_nbr`, `group_name`, `group_code`, `parent_id`, `group_config`, `org_code`, `sort`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`) VALUES ('132828674815', '值班消防', 'dutyFireFighting', '0', NULL, '10', '1', NULL, NULL, '2021-09-28 10:34:05', '\0');
</sql> </sql>
</changeSet> </changeSet>
<changeSet id="2021-10-13" author="chenhao-2"> <changeSet id="2021-10-13" author="chenhao-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="cb_dynamic_form_column" /> <tableExists tableName="cb_dynamic_form_column" />
...@@ -1775,7 +1775,7 @@ ...@@ -1775,7 +1775,7 @@
INSERT INTO cb_dynamic_form_group (`sequence_nbr`, `group_name`, `group_code`, `parent_id`, `group_config`, `org_code`, `sort`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`) VALUES ('132828674816', '值班120急救站', 'dutyFirstAid', '0', NULL, '10', '1', NULL, NULL, '2021-10-14 16:48:41', '\0'); INSERT INTO cb_dynamic_form_group (`sequence_nbr`, `group_name`, `group_code`, `parent_id`, `group_config`, `org_code`, `sort`, `rec_user_name`, `rec_user_id`, `rec_date`, `is_delete`) VALUES ('132828674816', '值班120急救站', 'dutyFirstAid', '0', NULL, '10', '1', NULL, NULL, '2021-10-14 16:48:41', '\0');
</sql> </sql>
</changeSet> </changeSet>
<changeSet id="2021-10-14" author="chenhao-2"> <changeSet id="2021-10-14" author="chenhao-2">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<tableExists tableName="cb_dynamic_form_column" /> <tableExists tableName="cb_dynamic_form_column" />
...@@ -2032,8 +2032,8 @@ ...@@ -2032,8 +2032,8 @@
<sql> <sql>
ALTER TABLE cb_firefighters ADD fire_team_name varchar(100) NULL COMMENT '消防队伍名称' ALTER TABLE cb_firefighters ADD fire_team_name varchar(100) NULL COMMENT '消防队伍名称'
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="chenhao" id="2021-11-02-3"> <changeSet author="chenhao" id="2021-11-02-3">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -2044,8 +2044,8 @@ ...@@ -2044,8 +2044,8 @@
<sql> <sql>
ALTER TABLE cb_key_site ADD belong_name varchar(100) NULL COMMENT '所属单位/部门名称'; ALTER TABLE cb_key_site ADD belong_name varchar(100) NULL COMMENT '所属单位/部门名称';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="chenhao" id="2021-11-02-4"> <changeSet author="chenhao" id="2021-11-02-4">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -2056,8 +2056,8 @@ ...@@ -2056,8 +2056,8 @@
<sql> <sql>
ALTER TABLE cb_org_usr ADD parent_name varchar(100) NULL COMMENT '归属机构/部门/人员名称'; ALTER TABLE cb_org_usr ADD parent_name varchar(100) NULL COMMENT '归属机构/部门/人员名称';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="chenhao" id="2021-11-04-1"> <changeSet author="chenhao" id="2021-11-04-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -2068,8 +2068,8 @@ ...@@ -2068,8 +2068,8 @@
<sql> <sql>
ALTER TABLE cb_fire_team ADD parent_name varchar(100) NULL COMMENT '父级队伍名称'; ALTER TABLE cb_fire_team ADD parent_name varchar(100) NULL COMMENT '父级队伍名称';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="litw" id="2021-11-03-01"> <changeSet author="litw" id="2021-11-03-01">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -2093,7 +2093,7 @@ ...@@ -2093,7 +2093,7 @@
) COMMENT = '消防水源物联参数' ; ) COMMENT = '消防水源物联参数' ;
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="chenhao" id="2021-11-05-1"> <changeSet author="chenhao" id="2021-11-05-1">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
<not> <not>
...@@ -2104,7 +2104,7 @@ ...@@ -2104,7 +2104,7 @@
<sql> <sql>
ALTER TABLE cb_maintenance_company ADD parent_name varchar(100) NULL COMMENT '所属单位/部门名称'; ALTER TABLE cb_maintenance_company ADD parent_name varchar(100) NULL COMMENT '所属单位/部门名称';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="litw" id="2021-11-05-01"> <changeSet author="litw" id="2021-11-05-01">
<preConditions onFail="MARK_RAN"> <preConditions onFail="MARK_RAN">
...@@ -2745,7 +2745,7 @@ ...@@ -2745,7 +2745,7 @@
ALTER TABLE cb_fire_station ADD parent_building_id varchar(1000) NULL COMMENT '所属建筑节点的所有父节点id集合'; ALTER TABLE cb_fire_station ADD parent_building_id varchar(1000) NULL COMMENT '所属建筑节点的所有父节点id集合';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="tw" id="20220207-1" runAlways="true"> <changeSet author="tw" id="20220207-1" runAlways="true">
<comment>`getParentList`</comment> <comment>`getParentList`</comment>
<sql endDelimiter="#"> <sql endDelimiter="#">
...@@ -3643,6 +3643,33 @@ ...@@ -3643,6 +3643,33 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="lixiuming" id="2023-10-24-01">
<preConditions onFail="MARK_RAN">
<tableExists tableName="cb_duty_person_shift_log"/>
</preConditions>
<comment>create table cb_duty_person_shift_log 值班人员日期变更日志表</comment>
<sql>
CREATE TABLE `cb_duty_person_shift_log` (
`sequence_nbr` bigint NOT NULL COMMENT '物理主键',
`instance_id` bigint COMMENT '实例ID',
`duty_date` date COMMENT '值班日期',
`group_code` varchar(255) COMMENT '分组code',
`dept_name` varchar(255) COMMENT '单位/部门',
`duty_user_id` varchar(255) COMMENT '值班人ID',
`duty_user` varchar(255) COMMENT '值班人',
`post_type_name` varchar(255) COMMENT '岗位',
`duty_area` varchar(255) COMMENT '值班区域',
`shift_name` varchar(255) COMMENT '值班类型',
`car_name` varchar(255) COMMENT '车辆名称(车辆特有)',
`rec_user_id` bigint NULL DEFAULT NULL COMMENT '更新人员id',
`rec_user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人员',
`rec_date` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`is_delete` bit(1) NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`sequence_nbr`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '值班人员日期变更日志表' ROW_FORMAT = Dynamic;
</sql>
</changeSet>
......
...@@ -307,18 +307,18 @@ ...@@ -307,18 +307,18 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
<!--<repository> <id>Releases</id> <name>Releases</name> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/releases/</url> <!--<repository> <id>Releases</id> <name>Releases</name> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/releases/</url>
</repository> <repository> <id>Snapshots</id> <name>Snapshots</name> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url> </repository> <repository> <id>Snapshots</id> <name>Snapshots</name> <url>http://4v059425e3.zicp.vip:13535/nexus/content/repositories/snapshots/</url>
</repository> --> </repository> -->
<repository> <repository>
<id>Releases</id> <id>Releases</id>
<name>Releases</name> <name>Releases</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/releases/</url> <url>http://113.142.68.105:8081/nexus/content/repositories/releases/</url>
</repository> </repository>
<repository> <repository>
<id>Snapshots</id> <id>Snapshots</id>
<name>Snapshots</name> <name>Snapshots</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url> <url>http://113.142.68.105:8081/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>com.e-iceblue</id> <id>com.e-iceblue</id>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment