Commit 356fe707 authored by chenhao's avatar chenhao

修改bug 2472

parent 12dd8fae
...@@ -37,7 +37,7 @@ public interface IDutyCommonService { ...@@ -37,7 +37,7 @@ public interface IDutyCommonService {
* @param endDate 结束日期 * @param endDate 结束日期
* @return ResponseModel * @return ResponseModel
*/ */
List<Map<String, Object>> list(String beginDate, String endDate) throws ParseException; List<Map<String, Object>> list(Long teamId,String beginDate, String endDate) throws ParseException;
/** /**
* 获取表单参数 * 获取表单参数
......
...@@ -16,177 +16,184 @@ import java.util.Map; ...@@ -16,177 +16,184 @@ import java.util.Map;
* @date 2021-06-18 * @date 2021-06-18
*/ */
public interface IOrgUsrService { public interface IOrgUsrService {
/** /**
* 查询上级单位 * 查询上级单位
* *
* @param parent_id * @param parent_id
* @return * @return
*/ */
String selectUpUnitByParam(String parent_id); String selectUpUnitByParam(String parent_id);
/**
* 获取父级
*
* @param topId
* @param entityList
* @param packageURL
* @param IDMethodName
* @param IDHierarchy
* @param NAMEMethodName
* @param PARENTIDMethodName
* @param OrgTypeMethodName
* @return
* @throws Exception
*/
List<OrgMenuDto> getTree(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy,
String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception;
/**
* 获取子数据集合
*
* @param topId
* @param entityList
* @param packageURL
* @param IDMethodName
* @param IDHierarchy
* @param NAMEMethodName
* @param PARENTIDMethodName
* @param OrgTypeMethodName
* @return
* @throws Exception
*/
List<OrgMenuDto> getSub(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy,
String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception;
/**
* 组装融合调度单位人员信息
*
* @param ids
* @return
* @throws Exception
*/
List<Map<String, Object>> returnCompanyPersonMsg(List<Long> ids) throws Exception;
/**
* 获取动态表单数据
*
* @param id
* @return
* @throws Exception
*/
List<FormValue> getFormValue(Long id) throws Exception;
/**
* 保存 机构/部门/人员基本信息
*
* @param
* @throws Exception
*/
void saveOrgUsr(OrgUsr orgUsr, OrgUsr oriOrgUsr) throws Exception;
/**
* 新增机构/部门/人员基本信息和动态表单数据
*
* @param orgUsr
* @param alertFromValuelist
*/
void saveOrgUsrDynamicFormInstance(OrgUsr orgUsr, List<DynamicFormInstance> alertFromValuelist) throws Exception;
/**
* 更新机构/部门/人员基本信息和动态表单数据
*
* @param instanceId 实例id
* @param fromValueList 动态表单数据列表
* @throws Exception
*/
void updateDynamicFormInstance(Long instanceId, List<DynamicFormInstance> fromValueList) throws Exception;
/**
* @param id
* @throws Exception
*/
Map<String, Object> selectForShowById(OrgUsr orgUsr, Long id) throws Exception;
List<OrgUsr> selectCompanyDepartmentMsg();
void saveOrgUsr(OrgUsrDto OrgUsrDto) throws Exception;
void saveOrgPerson(OrgPersonDto OrgPersonDto) throws Exception;
void updateByIdOrgUsr(OrgUsrDto OrgUsrDto, Long id) throws Exception;
void updateByIdOrgPerson(OrgPersonDto OrgPersonDto, Long id) throws Exception;
OrgUsrFormDto selectCompanyById(Long id) throws Exception;
IPage bizOrgTypeListPage(String pageNum, String pageSize, String bizOrgType) throws Exception;
void saveDepartment(List<OrgDepartmentDto> OrgDepartmentDto, Long id) throws Exception;
void saveCompany(List<OrgUsrDto> OrgUsrDto) throws Exception;
OrgPersonFormDto selectPersonById(Long id) throws Exception;
OrgPersonFormDto selectPersonByIdDetail(Long id) throws Exception;
List<OrgMenuDto> selectPersonTree() throws Exception;
void savePersonList(List<OrgPersonDto> OrgPersonDto) throws Exception;
void saveOrgDepartment(OrgDepartmentDto OrgDepartmentDto) throws Exception;
void updateByIdOrgDepartment(OrgDepartmentDto OrgDepartmentDto, Long id) throws Exception;
OrgDepartmentFormDto selectDepartmentById(Long id) throws Exception;
List<Map<String, Object>> selectForShowByListId(List<Long> ids) throws Exception;
/**
* * @param null
*
* @return <PRE>
* author tw
* date 2021/7/20
* </PRE>
* 列表
*/
List<CompanyDto> listContractDto(Integer pageNum, Integer pageSize, RequestData requestData);
/** /**
* * @param null * 获取父级
* *
* @return <PRE> * @param topId
* author tw * @param entityList
* date 2021/7/20 * @param packageURL
* </PRE> * @param IDMethodName
* 统计 * @param IDHierarchy
*/ * @param NAMEMethodName
Integer listContractDtoCount(RequestData par); * @param PARENTIDMethodName
* @param OrgTypeMethodName
* @return
* @throws Exception
*/
List<OrgMenuDto> getTree(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy,
String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception;
/** /**
* * @param null * 获取子数据集合
* *
* @return <PRE> * @param topId
* author tw * @param entityList
* date 2021/7/26 * @param packageURL
* </PRE> * @param IDMethodName
*/ * @param IDHierarchy
* @param NAMEMethodName
* @param PARENTIDMethodName
* @param OrgTypeMethodName
* @return
* @throws Exception
*/
List<OrgMenuDto> getSub(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy,
String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception;
List<OrgUsrzhDto> getOrgUsrzhDto(String name); /**
* 组装融合调度单位人员信息
*
* @param ids
* @return
* @throws Exception
*/
List<Map<String, Object>> returnCompanyPersonMsg(List<Long> ids) throws Exception;
List<ESOrgUsrDto> selectByIddata(String name); /**
* 获取动态表单数据
*
* @param id
* @return
* @throws Exception
*/
List<FormValue> getFormValue(Long id) throws Exception;
List<Map<String, Object>> getparent(); /**
* 保存 机构/部门/人员基本信息
*
* @param
* @throws Exception
*/
void saveOrgUsr(OrgUsr orgUsr, OrgUsr oriOrgUsr) throws Exception;
List<OrgUsrExcelDto> exportToExcel(); /**
* 新增机构/部门/人员基本信息和动态表单数据
*
* @param orgUsr
* @param alertFromValuelist
*/
void saveOrgUsrDynamicFormInstance(OrgUsr orgUsr, List<DynamicFormInstance> alertFromValuelist) throws Exception;
UserUnitDto getUserUnit(String userId); /**
* 更新机构/部门/人员基本信息和动态表单数据
*
* @param instanceId 实例id
* @param fromValueList 动态表单数据列表
* @throws Exception
*/
void updateDynamicFormInstance(Long instanceId, List<DynamicFormInstance> fromValueList) throws Exception;
/**
* @param id
* @throws Exception
*/
Map<String, Object> selectForShowById(OrgUsr orgUsr, Long id) throws Exception;
List<OrgUsr> selectCompanyDepartmentMsg();
void saveOrgUsr(OrgUsrDto OrgUsrDto) throws Exception;
void saveOrgPerson(OrgPersonDto OrgPersonDto) throws Exception;
void updateByIdOrgUsr(OrgUsrDto OrgUsrDto, Long id) throws Exception;
void updateByIdOrgPerson(OrgPersonDto OrgPersonDto, Long id) throws Exception;
OrgUsrFormDto selectCompanyById(Long id) throws Exception;
IPage bizOrgTypeListPage(String pageNum, String pageSize, String bizOrgType) throws Exception;
void saveDepartment(List<OrgDepartmentDto> OrgDepartmentDto, Long id) throws Exception;
void saveCompany(List<OrgUsrDto> OrgUsrDto) throws Exception;
OrgPersonFormDto selectPersonById(Long id) throws Exception;
OrgPersonFormDto selectPersonByIdDetail(Long id) throws Exception;
List<OrgMenuDto> selectPersonTree() throws Exception;
void savePersonList(List<OrgPersonDto> OrgPersonDto) throws Exception;
void saveOrgDepartment(OrgDepartmentDto OrgDepartmentDto) throws Exception;
void updateByIdOrgDepartment(OrgDepartmentDto OrgDepartmentDto, Long id) throws Exception;
OrgDepartmentFormDto selectDepartmentById(Long id) throws Exception;
List<Map<String, Object>> selectForShowByListId(List<Long> ids) throws Exception;
/**
* * @param null
*
* @return
*
* <PRE>
* author tw
* date 2021/7/20
* </PRE>
*
* 列表
*/
List<CompanyDto> listContractDto(Integer pageNum, Integer pageSize, RequestData requestData);
/**
* * @param null
*
* @return
*
* <PRE>
* author tw
* date 2021/7/20
* </PRE>
*
* 统计
*/
Integer listContractDtoCount(RequestData par);
/**
* * @param null
*
* @return
*
* <PRE>
* author tw
* date 2021/7/26
* </PRE>
*/
List<OrgUsrzhDto> getOrgUsrzhDto(String name);
List<ESOrgUsrDto> selectByIddata(String name);
List<Map<String, Object>> getparent();
List<OrgUsrExcelDto> exportToExcel();
UserUnitDto getUserUnit(String userId);
/** /**
* 根据登陆人获取公司部门人员树 * 根据登陆人获取公司部门人员树
*/ */
List<OrgMenuDto> companyUserTreeByUser (AgencyUserModel user); List<OrgMenuDto> companyUserTreeByUser(AgencyUserModel user);
/** /**
* 根据登陆人获取公司部门树 * 根据登陆人获取公司部门树
...@@ -198,4 +205,6 @@ public interface IOrgUsrService { ...@@ -198,4 +205,6 @@ public interface IOrgUsrService {
*/ */
List<OrgUsrTreeDto> companyListByUser(AgencyUserModel user); List<OrgUsrTreeDto> companyListByUser(AgencyUserModel user);
List<OrgUsr> getPersonListByParentId(Long id);
} }
...@@ -61,8 +61,9 @@ public class DutyPersonController extends BaseController { ...@@ -61,8 +61,9 @@ public class DutyPersonController extends BaseController {
@GetMapping(value = "/list") @GetMapping(value = "/list")
@ApiOperation(httpMethod = "GET", value = "值班列表视图-不分页", notes = "值班列表视图-不分页") @ApiOperation(httpMethod = "GET", value = "值班列表视图-不分页", notes = "值班列表视图-不分页")
public ResponseModel list(@ApiParam(value = "开始日期", required = true) @RequestParam String beginDate, public ResponseModel list(@ApiParam(value = "开始日期", required = true) @RequestParam String beginDate,
@ApiParam(value = "结束日期", required = true) @RequestParam String endDate) throws ParseException { @ApiParam(value = "结束日期", required = true) @RequestParam String endDate,
return ResponseHelper.buildResponse(iDutyPersonService.list(beginDate, endDate)); @RequestParam(required = false) Long teamId) throws ParseException {
return ResponseHelper.buildResponse(iDutyPersonService.list(teamId,beginDate, endDate));
} }
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
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.CompanyPerson;
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.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;
...@@ -14,6 +15,7 @@ import com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift; ...@@ -14,6 +15,7 @@ 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.DutyShift;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn; 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.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.service.IDutyCommonService; import com.yeejoin.amos.boot.module.common.api.service.IDutyCommonService;
...@@ -39,325 +41,342 @@ import java.util.stream.Collectors; ...@@ -39,325 +41,342 @@ import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class DutyCommonServiceImpl implements IDutyCommonService { public class DutyCommonServiceImpl implements IDutyCommonService {
@Autowired @Autowired
DynamicFormColumnServiceImpl dynamicFormColumnService; DynamicFormColumnServiceImpl dynamicFormColumnService;
@Autowired @Autowired
DynamicFormInstanceServiceImpl dynamicFormInstanceService; DynamicFormInstanceServiceImpl dynamicFormInstanceService;
@Autowired @Autowired
DutyPersonShiftServiceImpl dutyPersonShiftService; DutyPersonShiftServiceImpl dutyPersonShiftService;
@Autowired @Autowired
Sequence sequence; Sequence sequence;
@Autowired @Autowired
HttpServletRequest request; HttpServletRequest request;
@Autowired @Autowired
DutyShiftServiceImpl dutyShiftService; DutyShiftServiceImpl dutyShiftService;
@Autowired @Autowired
OrgUsrServiceImpl orgUsrService; OrgUsrServiceImpl orgUsrService;
/** /**
* 每天单个班次执勤人数全部小于等于3人 * 每天单个班次执勤人数全部小于等于3人
*/ */
final int LIMIT_PERSON_NUMBER = 3; final int LIMIT_PERSON_NUMBER = 3;
/** /**
* 班次小于等于2 * 班次小于等于2
*/ */
final int LIMIT_SHIFT_NUMBER = 2; final int LIMIT_SHIFT_NUMBER = 2;
@Override
public IPage<Map<String, Object>> pageList(int current, int size, String beginDate, String endDate)
throws ParseException {
// 1.已column为准 进行返回
String groupCode = this.getGroupCode();
IPage<Map<String, Object>> iPage = dynamicFormInstanceService.pageList(current, size, groupCode);
for (Map<String, Object> m : iPage.getRecords()) {
this.fillDutyShiftData(beginDate, endDate, m);
}
return iPage;
}
@Override private void fillDutyShiftData(String beginDate, String endDate, Map<String, Object> m) throws ParseException {
public IPage<Map<String, Object>> pageList(int current, int size, String beginDate, String endDate) throws ParseException { String instanceId = m.get("instanceId").toString();
//1.已column为准 进行返回 List<DutyShift> dutyShifts = dutyShiftService.list(new LambdaQueryWrapper<DutyShift>()
String groupCode = this.getGroupCode(); .eq(BaseEntity::getIsDelete, false).eq(DutyShift::getAppKey, RequestContext.getAppKey()));
IPage<Map<String, Object>> iPage = dynamicFormInstanceService.pageList(current, size, groupCode); Map<Long, DutyShift> keyNameMap = dutyShifts.stream()
for (Map<String, Object> m : iPage.getRecords()) { .collect(Collectors.toMap(BaseEntity::getSequenceNbr, Function.identity()));
this.fillDutyShiftData(beginDate, endDate, m); List<DutyPersonShiftDto> personShiftList = dutyPersonShiftService
} .list(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId, instanceId)
return iPage; .ge(beginDate != null, DutyPersonShift::getDutyDate, beginDate)
} .le(endDate != null, DutyPersonShift::getDutyDate, endDate))
.stream().map(e -> {
DutyPersonShiftDto dto = new DutyPersonShiftDto();
Bean.copyExistPropertis(e, dto);
// 没值班信息,默认休
DutyShift dutyShift = keyNameMap.get(e.getShiftId());
dto.setShiftName(dutyShift != null ? dutyShift.getName() : "休");
dto.setColor(dutyShift != null ? dutyShift.getColor() : "");
return dto;
}).collect(Collectors.toList());
m.put("dutyShift", personShiftList);
}
private void fillDutyShiftData(String beginDate, String endDate, Map<String, Object> m) throws ParseException { @Override
String instanceId = m.get("instanceId").toString(); public List<Map<String, Object>> statisticsDay(String beginDate, String endDate) throws ParseException {
List<DutyShift> dutyShifts = DutyViewTypeEnum viewTypeEnum = this.inferView(beginDate, endDate, RequestContext.getAppKey());
dutyShiftService.list(new LambdaQueryWrapper<DutyShift>().eq(BaseEntity::getIsDelete, false).eq(DutyShift::getAppKey, RequestContext.getAppKey())); List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate);
Map<Long, DutyShift> keyNameMap = dutyShifts.stream().collect(Collectors.toMap(BaseEntity::getSequenceNbr, return rangeDate.stream().map(p -> {
Function.identity())); Map<String, Object> result = new LinkedHashMap<>();
List<DutyPersonShiftDto> personShiftList = dutyPersonShiftService.list(new LambdaQueryWrapper<DutyPersonShift>() result.put("key", p.get("date"));
.eq(DutyPersonShift::getInstanceId, instanceId) result.put("viewType", viewTypeEnum.getCode());
.ge(beginDate != null, DutyPersonShift::getDutyDate, beginDate) result.put("data", this.buildViewData(viewTypeEnum, p.get("date").toString(), RequestContext.getAppKey()));
.le(endDate != null, DutyPersonShift::getDutyDate, endDate)).stream().map(e -> { return result;
DutyPersonShiftDto dto = new DutyPersonShiftDto(); }).collect(Collectors.toList());
Bean.copyExistPropertis(e, dto); }
//没值班信息,默认休
DutyShift dutyShift = keyNameMap.get(e.getShiftId());
dto.setShiftName(dutyShift != null ? dutyShift.getName() : "休");
dto.setColor(dutyShift != null ? dutyShift.getColor() : "");
return dto;
}).collect(Collectors.toList());
m.put("dutyShift", personShiftList);
}
@Override private Object buildViewData(DutyViewTypeEnum viewTypeEnum, String dutyDate, String appKey) {
public List<Map<String, Object>> statisticsDay(String beginDate, String endDate) throws ParseException { List<Map<String, Object>> result = new ArrayList<>();
DutyViewTypeEnum viewTypeEnum = this.inferView(beginDate, endDate, RequestContext.getAppKey()); switch (viewTypeEnum) {
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate); case BANK:
return rangeDate.stream().map(p -> { result = dutyPersonShiftService.getBaseMapper().bankViewData(dutyDate, appKey, this.getGroupCode());
Map<String, Object> result = new LinkedHashMap<>(); break;
result.put("key", p.get("date")); case STATION:
result.put("viewType", viewTypeEnum.getCode()); result = dutyPersonShiftService.getBaseMapper().stationViewData(dutyDate, appKey, this.getGroupCode());
result.put("data", this.buildViewData(viewTypeEnum, p.get("date").toString(), RequestContext.getAppKey())); break;
return result; default:
}).collect(Collectors.toList()); break;
} }
return result;
}
private Object buildViewData(DutyViewTypeEnum viewTypeEnum, String dutyDate, String appKey) { private DutyViewTypeEnum inferView(String beginDate, String endDate, String appKey) {
List<Map<String, Object>> result = new ArrayList<>(); Map<String, Long> result = dutyPersonShiftService.getBaseMapper().calMaxPersonAndShiftNum(beginDate, endDate,
switch (viewTypeEnum) { appKey, this.getGroupCode());
case BANK: // 计算班次最大执勤人数,时间区间内
result = dutyPersonShiftService.getBaseMapper().bankViewData(dutyDate, appKey, this.getGroupCode()); Long maxDutyPersonNumDay = result.get("maxDutyPersonNumDay");
break; // 计算天的最大班次数量,时间区间内
case STATION: Long maxShiftNumDay = result.get("maxShiftNumDay");
result = dutyPersonShiftService.getBaseMapper().stationViewData(dutyDate, appKey, this.getGroupCode()); if (maxDutyPersonNumDay <= LIMIT_PERSON_NUMBER && maxShiftNumDay <= LIMIT_SHIFT_NUMBER) {
break; return DutyViewTypeEnum.BANK;
default: } else {
break; return DutyViewTypeEnum.STATION;
} }
return result; }
}
private DutyViewTypeEnum inferView(String beginDate, String endDate, String appKey) { @Override
Map<String, Long> result = dutyPersonShiftService.getBaseMapper().calMaxPersonAndShiftNum(beginDate, endDate, public List<Map<String, Object>> list(Long teamId, String beginDate, String endDate) throws ParseException {
appKey, this.getGroupCode()); // 1.已column为准 进行返回
//计算班次最大执勤人数,时间区间内 String groupCode = this.getGroupCode();
Long maxDutyPersonNumDay = result.get("maxDutyPersonNumDay"); List<Map<String, Object>> list = dynamicFormInstanceService.listAll(groupCode);
//计算天的最大班次数量,时间区间内
Long maxShiftNumDay = result.get("maxShiftNumDay"); // 2.组织值班数据
if (maxDutyPersonNumDay <= LIMIT_PERSON_NUMBER && maxShiftNumDay <= LIMIT_SHIFT_NUMBER) { for (Map<String, Object> map : list) {
return DutyViewTypeEnum.BANK; this.fillDutyShiftData(beginDate, endDate, map);
} else { }
return DutyViewTypeEnum.STATION; /*bug2472 添加根据部门id筛选数据的方法 陈浩 2021-08-21 开始 */
} if(teamId!=null && teamId.intValue()!=0) {
} List<OrgUsr> orgUsrList = orgUsrService.getPersonListByParentId(teamId);
List<Map<String, Object>> resultList= new ArrayList<Map<String, Object>>();
list.stream().forEach(i->{
orgUsrList.forEach(m->{
if(i.get("userId").toString().equals(m.getSequenceNbr().longValue()+"")) {
resultList.add(i);
}
});
});
return resultList;
}
/*bug2472 添加根据部门id筛选数据的方法 陈浩 2021-08-21 结束 */
return list;
}
@Override @Override
public List<Map<String, Object>> list(String beginDate, String endDate) throws ParseException { public String getGroupCode() {
//1.已column为准 进行返回 return null;
String groupCode = this.getGroupCode(); }
List<Map<String, Object>> list = dynamicFormInstanceService.listAll(groupCode);
//2.组织值班数据
for (Map<String, Object> map : list) {
this.fillDutyShiftData(beginDate, endDate, map);
}
return list;
}
@Override @Override
public String getGroupCode() { public List downloadList(String beginDate, String endDate) throws ParseException {
return null; List<Map<String, Object>> maps = this.list(null,beginDate, endDate);
} JSONArray jsonArray = new JSONArray();
jsonArray.addAll(maps);
List<?> list = new ArrayList<>();
String groupCode = this.getGroupCode();
String fileName;
if ("dutyCar".equals(groupCode)) {
list = jsonArray.toJavaList(DutyCarDto.class);
} else {
list = jsonArray.toJavaList(DutyPersonDto.class);
}
return list;
}
@Override @Override
public List downloadList(String beginDate, String endDate) throws ParseException { public void saveImportData(List<Map<String, Object>> dataList) {
List<Map<String, Object>> maps = this.list(beginDate, endDate); List<DynamicFormInstance> formInstanceList = new ArrayList<>();
JSONArray jsonArray = new JSONArray(); Set<DutyPersonShift> dutyPersonShifts = new HashSet<>();
jsonArray.addAll(maps); dataList.forEach(d -> {
List<?> list = new ArrayList<>(); // TODO: 业务唯一索引,用户id
String groupCode = this.getGroupCode(); String userId = d.get("userId").toString();
String fileName; List<DynamicFormInstance> instances = dynamicFormInstanceService
if ("dutyCar".equals(groupCode)) { .list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getFieldCode, "userId")
list = jsonArray.toJavaList(DutyCarDto.class); .eq(DynamicFormInstance::getFieldValue, userId)
} else { .eq(DynamicFormInstance::getGroupCode, this.getGroupCode()));
list = jsonArray.toJavaList(DutyPersonDto.class); Long instanceId = null;
} List<DynamicFormColumn> columns = dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>()
return list; .eq(DynamicFormColumn::getGroupCode, this.getGroupCode()));
} // 1.组装动态表单数据
if (!instances.isEmpty()) {
// 0.定位instanceId,准备进行更新操作
instanceId = instances.get(0).getInstanceId();
// 1.查询已有数据
List<DynamicFormInstance> instancesInDb = dynamicFormInstanceService
.list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId,
instanceId));
// 2.list 转 map
Map<Object, DynamicFormInstance> instanceMap = Bean.listToMap(instancesInDb, "fieldCode",
DynamicFormInstance.class);
// 3.待更新数据组装,待批量入库
this.updateFormValue(formInstanceList, d, instanceId, columns, instanceMap);
} else {
// 0.新数据,生成id
instanceId = sequence.nextId();
Long finalInstanceId1 = instanceId;
// 1.组装数据
List<DynamicFormInstance> newInstances = columns.stream().map(column -> {
DynamicFormInstance instance = new DynamicFormInstance();
buildFormInstanceData(finalInstanceId1, d, column, instance);
return instance;
}).collect(Collectors.toList());
// 2.待更新数据组装,待批量入库
formInstanceList.addAll(newInstances);
}
// 2.组装值班数据
List<DutyPersonShiftDto> shiftDtos = (List<DutyPersonShiftDto>) d.get("dutyShift");
Long finalInstanceId = instanceId;
// 按照业务唯一索引查询主键
List<DutyPersonShift> dutyPersonShiftsDb = dutyPersonShiftService
.list(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId, instanceId));
Map<Date, Long> dutyPersonShiftMap = dutyPersonShiftsDb.stream()
.collect(Collectors.toMap(DutyPersonShift::getDutyDate, DutyPersonShift::getSequenceNbr));
// todo: 只更新当天及值班之后数据
Set<DutyPersonShift> needToDb = shiftDtos.stream()
.filter(s -> DateUtils.dateCompare(s.getDutyDate(), new Date()) >= 0).map(shiftDto -> {
DutyPersonShift dutyPersonShift = new DutyPersonShift();
Bean.copyExistPropertis(shiftDto, dutyPersonShift);
dutyPersonShift.setInstanceId(finalInstanceId);
dutyPersonShift.setAppKey(RequestContext.getAppKey());
dutyPersonShift.setSequenceNbr(dutyPersonShiftMap.get(dutyPersonShift.getDutyDate()));
return dutyPersonShift;
}).collect(Collectors.toSet());
dutyPersonShifts.addAll(needToDb);
});
if (!formInstanceList.isEmpty()) {
dynamicFormInstanceService.saveOrUpdateBatch(formInstanceList);
}
if (!dutyPersonShifts.isEmpty()) {
dutyPersonShiftService.saveOrUpdateBatch(dutyPersonShifts);
}
}
@Override public void updateFormValue(List<DynamicFormInstance> formInstanceList, Map<String, Object> d, Long instanceId,
public void saveImportData(List<Map<String, Object>> dataList) { List<DynamicFormColumn> columns, Map<Object, DynamicFormInstance> instanceMap) {
List<DynamicFormInstance> formInstanceList = new ArrayList<>(); for (DynamicFormColumn column : columns) {
Set<DutyPersonShift> dutyPersonShifts = new HashSet<>(); DynamicFormInstance formInstance = instanceMap.get(column.getFieldCode());
dataList.forEach(d -> { if (!ObjectUtils.isEmpty(formInstance)) {
//TODO: 业务唯一索引,用户id // 有的更新
String userId = d.get("userId").toString(); formInstance.setFieldValue(
List<DynamicFormInstance> instances = d.get(column.getFieldCode()) != null ? d.get(column.getFieldCode()).toString() : "");
dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>() } else {
.eq(DynamicFormInstance::getFieldCode, "userId") // 没有的新增
.eq(DynamicFormInstance::getFieldValue, userId) formInstance = new DynamicFormInstance();
.eq(DynamicFormInstance::getGroupCode, this.getGroupCode())); buildFormInstanceData(instanceId, d, column, formInstance);
Long instanceId = null; }
List<DynamicFormColumn> columns = formInstanceList.add(formInstance);
dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, this.getGroupCode())); }
//1.组装动态表单数据 }
if (!instances.isEmpty()) {
//0.定位instanceId,准备进行更新操作
instanceId = instances.get(0).getInstanceId();
//1.查询已有数据
List<DynamicFormInstance> instancesInDb =
dynamicFormInstanceService.list(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
//2.list 转 map
Map<Object, DynamicFormInstance> instanceMap = Bean.listToMap(instancesInDb, "fieldCode",
DynamicFormInstance.class);
//3.待更新数据组装,待批量入库
this.updateFormValue(formInstanceList, d, instanceId, columns, instanceMap);
} else {
//0.新数据,生成id
instanceId = sequence.nextId();
Long finalInstanceId1 = instanceId;
//1.组装数据
List<DynamicFormInstance> newInstances = columns.stream().map(column -> {
DynamicFormInstance instance = new DynamicFormInstance();
buildFormInstanceData(finalInstanceId1, d, column, instance);
return instance;
}).collect(Collectors.toList());
//2.待更新数据组装,待批量入库
formInstanceList.addAll(newInstances);
}
//2.组装值班数据
List<DutyPersonShiftDto> shiftDtos = (List<DutyPersonShiftDto>) d.get("dutyShift");
Long finalInstanceId = instanceId;
//按照业务唯一索引查询主键
List<DutyPersonShift> dutyPersonShiftsDb =
dutyPersonShiftService.list(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId, instanceId));
Map<Date, Long> dutyPersonShiftMap =
dutyPersonShiftsDb.stream().collect(Collectors.toMap(DutyPersonShift::getDutyDate,
DutyPersonShift::getSequenceNbr));
//todo: 只更新当天及值班之后数据
Set<DutyPersonShift> needToDb = shiftDtos.stream().filter(s -> DateUtils.dateCompare(s.getDutyDate(),
new Date()) >= 0).map(shiftDto -> {
DutyPersonShift dutyPersonShift = new DutyPersonShift();
Bean.copyExistPropertis(shiftDto, dutyPersonShift);
dutyPersonShift.setInstanceId(finalInstanceId);
dutyPersonShift.setAppKey(RequestContext.getAppKey());
dutyPersonShift.setSequenceNbr(dutyPersonShiftMap.get(dutyPersonShift.getDutyDate()));
return dutyPersonShift;
}).collect(Collectors.toSet());
dutyPersonShifts.addAll(needToDb);
});
if (!formInstanceList.isEmpty()) {
dynamicFormInstanceService.saveOrUpdateBatch(formInstanceList);
}
if (!dutyPersonShifts.isEmpty()) {
dutyPersonShiftService.saveOrUpdateBatch(dutyPersonShifts);
}
}
public void updateFormValue(List<DynamicFormInstance> formInstanceList, Map<String, Object> d, Long instanceId, private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column,
List<DynamicFormColumn> columns, Map<Object, DynamicFormInstance> instanceMap) { DynamicFormInstance formInstance) {
for (DynamicFormColumn column : columns) { fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId());
DynamicFormInstance formInstance = instanceMap.get(column.getFieldCode()); }
if (!ObjectUtils.isEmpty(formInstance)) {
//有的更新
formInstance.setFieldValue(d.get(column.getFieldCode()) != null ?
d.get(column.getFieldCode()).toString() : "");
} else {
//没有的新增
formInstance = new DynamicFormInstance();
buildFormInstanceData(instanceId, d, column, formInstance);
}
formInstanceList.add(formInstance);
}
}
private void buildFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, static void fillFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column,
DynamicFormInstance formInstance) { DynamicFormInstance formInstance, long l) {
fillFormInstanceData(instanceId, map, column, formInstance, sequence.nextId()); Bean.copyExistPropertis(column, formInstance);
} formInstance.setAppKey(RequestContext.getAppKey());
formInstance.setInstanceId(instanceId);
formInstance.setSequenceNbr(l);
formInstance.setFormColumnId(column.getSequenceNbr());
formInstance
.setFieldValue(map.get(column.getFieldCode()) != null ? map.get(column.getFieldCode()).toString() : "");
}
static void fillFormInstanceData(Long instanceId, Map<String, Object> map, DynamicFormColumn column, @Override
DynamicFormInstance formInstance, long l) { public Boolean deleteDutyData(Long instanceId) {
Bean.copyExistPropertis(column, formInstance); dynamicFormInstanceService.remove(
formInstance.setAppKey(RequestContext.getAppKey()); new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
formInstance.setInstanceId(instanceId); dutyPersonShiftService
formInstance.setSequenceNbr(l); .remove(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId, instanceId));
formInstance.setFormColumnId(column.getSequenceNbr()); return true;
formInstance.setFieldValue(map.get(column.getFieldCode()) != null ? }
map.get(column.getFieldCode()).toString() : "");
}
@Override @Override
public Boolean deleteDutyData(Long instanceId) { public List<Map<String, Object>> dayDutyPersonList(String dutyDay, Long shiftId, String postType) {
dynamicFormInstanceService.remove(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId)); String groupCode = this.getGroupCode();
dutyPersonShiftService.remove(new LambdaQueryWrapper<DutyPersonShift>().eq(DutyPersonShift::getInstanceId, Map<String, String> params = new HashMap<>();
instanceId)); params.put("postType", postType);
return true; List<DynamicFormColumn> columns = dynamicFormColumnService
} .list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class);
return dynamicFormInstanceService.getBaseMapper().listOneDayDutyPerson(dutyDay, shiftId, fieldCodes,
RequestContext.getAppKey(), groupCode, params);
}
@Override @Override
public List<Map<String, Object>> dayDutyPersonList(String dutyDay, Long shiftId, String postType) { public List<Map<String, Object>> listOnDutyPerson() {
String groupCode = this.getGroupCode(); String groupCode = this.getGroupCode();
Map<String, String> params = new HashMap<>(); // 获取当前班次列表
params.put("postType", postType); DateTime now = new DateTime();
List<DynamicFormColumn> columns = List<Long> shiftIdList = getOnDuty(now);
dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode)); String shiftIds = StringUtils.join(shiftIdList.toArray(), ",");
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class); String dutyDay = now.toString("yyyy-MM-dd");
return dynamicFormInstanceService.getBaseMapper().listOneDayDutyPerson(dutyDay, shiftId, fieldCodes, // 获取当前值班人员
RequestContext.getAppKey(), groupCode, params); List<DynamicFormColumn> columns = dynamicFormColumnService
} .list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode));
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class);
List<Map<String, Object>> maps = dynamicFormInstanceService.getBaseMapper().listOnDutyPerson(dutyDay, shiftIds,
fieldCodes, groupCode);
// 获取人员照片和电话
List<Long> ids = new ArrayList<>();
maps.forEach(item -> ids.add(Long.valueOf(String.valueOf(item.get("userId")))));
try {
List<Map<String, Object>> orgUsrList = orgUsrService.selectForShowByListId(ids);
maps.forEach(item -> {
String userId = String.valueOf(item.get("userId"));
for (Map<String, Object> usr : orgUsrList) {
if (userId.equals(String.valueOf(usr.get("sequenceNbr")))) {
item.put("personImg", usr.get("personImg"));
item.put("telephone", usr.get("telephone"));
break;
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
return maps;
}
@Override private List<Long> getOnDuty(DateTime now) {
public List<Map<String, Object>> listOnDutyPerson() { List<DutyShiftDto> dutyShiftDtos = dutyShiftService.queryForDutyShiftList(false);
String groupCode = this.getGroupCode(); List<Long> shiftIds = new ArrayList<>();
// 获取当前班次列表 int hour = now.getHourOfDay();
DateTime now = new DateTime(); int minute = now.getMinuteOfHour();
List<Long> shiftIdList = getOnDuty(now); dutyShiftDtos.forEach(item -> {
String shiftIds = StringUtils.join(shiftIdList.toArray(), ","); String[] start = item.getStartTime().split(": ");
String dutyDay = now.toString("yyyy-MM-dd"); String[] startTime = start[1].split(":");
// 获取当前值班人员 Integer startHour = Integer.valueOf(startTime[0]);
List<DynamicFormColumn> columns = Integer startMinute = Integer.valueOf(startTime[1]);
dynamicFormColumnService.list(new LambdaQueryWrapper<DynamicFormColumn>().eq(DynamicFormColumn::getGroupCode, groupCode)); String[] end = item.getEndTime().split(": ");
Map<String, Object> fieldCodes = Bean.listToMap(columns, "fieldCode", "queryStrategy", DynamicFormColumn.class); String[] endTime = end[1].split(":");
List<Map<String, Object>> maps = dynamicFormInstanceService.getBaseMapper().listOnDutyPerson(dutyDay, Integer endHour = Integer.valueOf(endTime[0]);
shiftIds, fieldCodes, groupCode); Integer endMinute = Integer.valueOf(endTime[1]);
// 获取人员照片和电话 if ("当日".equals(start[0])) {
List<Long> ids = new ArrayList<>(); if (hour > startHour || hour == startHour && minute > startMinute) {
maps.forEach(item -> ids.add(Long.valueOf(String.valueOf(item.get("userId"))))); if ("次日".equals(end[0])
try { || "当日".equals(end[0]) && (hour < endHour || hour == endHour && minute < endMinute)) {
List<Map<String, Object>> orgUsrList = orgUsrService.selectForShowByListId(ids); shiftIds.add(item.getSequenceNbr());
maps.forEach(item -> { }
String userId = String.valueOf(item.get("userId")); }
for (Map<String, Object> usr : orgUsrList) { }
if (userId.equals(String.valueOf(usr.get("sequenceNbr")))) { });
item.put("personImg", usr.get("personImg")); return shiftIds;
item.put("telephone", usr.get("telephone")); }
break;
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
return maps;
}
private List<Long> getOnDuty(DateTime now) {
List<DutyShiftDto> dutyShiftDtos = dutyShiftService.queryForDutyShiftList(false);
List<Long> shiftIds = new ArrayList<>();
int hour = now.getHourOfDay();
int minute = now.getMinuteOfHour();
dutyShiftDtos.forEach(item -> {
String[] start = item.getStartTime().split(": ");
String[] startTime = start[1].split(":");
Integer startHour = Integer.valueOf(startTime[0]);
Integer startMinute = Integer.valueOf(startTime[1]);
String[] end = item.getEndTime().split(": ");
String[] endTime = end[1].split(":");
Integer endHour = Integer.valueOf(endTime[0]);
Integer endMinute = Integer.valueOf(endTime[1]);
if ("当日".equals(start[0])) {
if (hour > startHour || hour == startHour && minute > startMinute) {
if ("次日".equals(end[0]) || "当日".equals(end[0]) && (hour < endHour || hour == endHour && minute < endMinute)) {
shiftIds.add(item.getSequenceNbr());
}
}
}
});
return shiftIds;
}
} }
...@@ -20,6 +20,9 @@ import com.yeejoin.amos.boot.module.common.api.service.IOrgUsrService; ...@@ -20,6 +20,9 @@ import com.yeejoin.amos.boot.module.common.api.service.IOrgUsrService;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import net.bytebuddy.asm.Advice.This;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -1294,6 +1297,22 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -1294,6 +1297,22 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return pid; return pid;
} }
/**
* 查询组织机构下面的人员信息
* @param id
* @return
*/
public List<OrgUsr> getPersonListByParentId(Long id) {
LambdaQueryWrapper<OrgUsr> wrapper = new LambdaQueryWrapper<OrgUsr>();
wrapper.eq(OrgUsr::getIsDelete, false);
wrapper.eq(OrgUsr::getParentId,id);
wrapper.eq(OrgUsr::getBizOrgType, OrgPersonEnum.人员.getKey());
return this.baseMapper.selectList(wrapper);
}
} }
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