|
@@ -11,10 +11,13 @@ import com.platform.dao.bean.MyPage;
|
|
|
import com.platform.dao.dto.preparation.PreparationDTO;
|
|
|
import com.platform.dao.dto.upms.SysUserDTO;
|
|
|
import com.platform.dao.entity.preparation.Preparation;
|
|
|
+import com.platform.dao.entity.preparation.PreparationRecord;
|
|
|
import com.platform.dao.entity.sb.SbPosition;
|
|
|
import com.platform.dao.entity.upms.SysFile;
|
|
|
+import com.platform.dao.entity.upms.SysUser;
|
|
|
import com.platform.dao.enums.*;
|
|
|
import com.platform.dao.mapper.preparation.PreparationMapper;
|
|
|
+import com.platform.dao.mapper.preparation.PreparationRecordMapper;
|
|
|
import com.platform.dao.mapper.sb.SbPositionMapper;
|
|
|
import com.platform.dao.mapper.upms.SysDeptMapper;
|
|
|
import com.platform.dao.mapper.upms.SysUserDeptMapper;
|
|
@@ -68,6 +71,8 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
private SysDeptMapper sysDeptMapper;
|
|
|
@Resource
|
|
|
private SysUserRoleMapper sysUserRoleMapper;
|
|
|
+ @Resource
|
|
|
+ private PreparationRecordMapper preparationRecordMapper;
|
|
|
|
|
|
@Override
|
|
|
public List<ExportPreparationNumVO> getPreparationReportByPositionId(PreparationDTO dto) {
|
|
@@ -238,24 +243,6 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
List<PreparationVO> detailList = new ArrayList<PreparationVO>();
|
|
|
vo.setYear(map.get("searchStartTimeMonth").getYear());
|
|
|
vo.setMonth(map.get("searchStartTimeMonth").getMonthValue());
|
|
|
-
|
|
|
-// // 维修描述
|
|
|
-// Weekend<CustomFieldTemplateData> weekend = new Weekend<>(CustomFieldTemplateData.class);
|
|
|
-// WeekendCriteria<CustomFieldTemplateData, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
-// weekendCriteria = weekendCriteria.andEqualTo(CustomFieldTemplateData::getRemark, CommonConstants.REPAIR_RECORD);
|
|
|
-// weekendCriteria.andLessThan(CustomFieldTemplateData::getCreatedTime,map.get("searchEndTimeMonth"));
|
|
|
-// weekendCriteria.andGreaterThan(CustomFieldTemplateData::getCreatedTime,map.get("searchStartTimeMonth"));
|
|
|
-// List<CustomFieldTemplateData> listCustomer = customFieldTemplateDataMapper.selectByExample(weekend);
|
|
|
-// Map<String,CustomFieldTemplateData> dataMap = new HashMap<>();
|
|
|
-// if(listCustomer != null && listCustomer.size() > 0){
|
|
|
-// listCustomer.forEach(item->{
|
|
|
-// String key = item.getObjId() + "&" + item.getCreatedUserId();
|
|
|
-// CustomFieldTemplateData tempData = dataMap.get(key);
|
|
|
-// if(tempData == null){
|
|
|
-// dataMap.put(key,item);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
for (PreparationVO preparationVO : list) {
|
|
|
if (preparationVO.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && preparationVO.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
i++;
|
|
@@ -287,13 +274,15 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
record.setTempUserId(userInfo.getUserId());
|
|
|
if(record.getSearchType() != null && record.getStatus() == null){
|
|
|
List<Integer> statusList = new ArrayList<>();
|
|
|
- if(record.getSearchType() == 1){ // 我的工单
|
|
|
+ if(record.getSearchType() == 1){ // 待接工单
|
|
|
+ statusList.add(PreparationStatusEnum.VERIFY_SUCCESS.getValue());
|
|
|
+ record.setTempUserId(null);
|
|
|
+ }else if(record.getSearchType() == 2){ // 待审核工单
|
|
|
+ statusList.add(PreparationStatusEnum.NOT_ALLOCATED.getValue());
|
|
|
+ }else if(record.getSearchType() == 3){ // 我的工单
|
|
|
statusList.add(PreparationStatusEnum.NOT_ALLOCATED.getValue());
|
|
|
statusList.add(PreparationStatusEnum.PROCESSING.getValue());
|
|
|
statusList.add(PreparationStatusEnum.FINISHED.getValue());
|
|
|
- }else if(record.getSearchType() == 2){ // 待接工单
|
|
|
- statusList.add(PreparationStatusEnum.VERIFY_SUCCESS.getValue());
|
|
|
- record.setTempUserId(null);
|
|
|
}
|
|
|
// 超级管理员可以看到各个状态下的所有数据 相关领导,可以在这里进行设置
|
|
|
if(userInfo.getSuperAdmin() == 1 || record.getSearchType() == -1){
|
|
@@ -306,14 +295,19 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
|
|
|
@Override
|
|
|
public Preparation saveByDTO(PreparationDTO model) {
|
|
|
+ if(StringUtils.isEmpty(model.getExecuteDept())){
|
|
|
+ throw new DeniedException("执行部门不能为空");
|
|
|
+ }
|
|
|
// 获取筹建主管角色,当一人时,直接赋值,多人时,接单派单
|
|
|
SysUserDTO queryUserDTO = new SysUserDTO();
|
|
|
queryUserDTO.setRoleCode(SysRoleCodeEnum.PREPARATION_MANAGER.name());
|
|
|
+ queryUserDTO.setDeptId(model.getExecuteDept());
|
|
|
List<SysUserVO> userVOS = sysUserMapper.selectDeptRoleUser(queryUserDTO);
|
|
|
+ // 判断执行部门是否有人接单
|
|
|
if(userVOS == null || userVOS.size() == 0){
|
|
|
- throw new DeniedException("报修失败,筹建部门,尚无派单主管。");
|
|
|
+ throw new DeniedException("报修失败,执行部门,尚无派单主管。");
|
|
|
}
|
|
|
- if(userVOS.size() == 1){
|
|
|
+ if(userVOS.size() == 1){ // 当只有一个主管时,直接划归此人名下,多名主管时,让他们接单后派单
|
|
|
model.setDispatchUserId(userVOS.get(0).getUserId());
|
|
|
}
|
|
|
// 获取申请人部门
|
|
@@ -327,11 +321,30 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
model.setNo(IdGeneratorUtils.getPreparationNo(++count));
|
|
|
model.setStatus(PreparationStatusEnum.NOT_ALLOCATED.getValue()); // 待审核
|
|
|
Preparation preparation = this.saveModelByDTO(model);
|
|
|
- // 给主管发送消息
|
|
|
- sendMessageToManger(userVOS,preparation);
|
|
|
+ // 给申请部门主管发送信息,通知审核
|
|
|
+ SysUser sendUser = sysUserMapper.selectByPrimaryKey(model.getApplyVerifyUserId());
|
|
|
+ sendMessageToApplyManger(sendUser,preparation);
|
|
|
+ // 存储操作记录
|
|
|
+ addRecord(preparation);
|
|
|
return preparation;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加操作记录
|
|
|
+ * @param info
|
|
|
+ */
|
|
|
+ private void addRecord(Preparation info){
|
|
|
+ PreparationRecord record = new PreparationRecord();
|
|
|
+ record.setCreatedTime(LocalDateTime.now());
|
|
|
+ record.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ record.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ record.setRealName(SecurityUtils.getUserInfo().getRealName());
|
|
|
+ record.setStatus(info.getStatus());
|
|
|
+ record.setPreparationId(info.getId());
|
|
|
+ record.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ preparationRecordMapper.insert(record);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void dispatchPreparation(PreparationDTO model) {
|
|
|
String roles = getRoles();
|
|
@@ -359,6 +372,16 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
sendMessageToRepairer(userVOS,model);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void verifyPreparation(PreparationDTO model) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void receivePreparation(PreparationDTO model) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前用户的角色集合
|
|
|
* @return
|
|
@@ -414,8 +437,32 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
});
|
|
|
vo.setImageList(imageList);
|
|
|
vo.setFileList(fileList);
|
|
|
- if(!StringUtils.isEmpty(vo.getDispatchUserId())){
|
|
|
- vo.setDispatchUserName(sysUserMapper.selectUserNameById(vo.getDispatchUserId()));
|
|
|
+ // 审批主管
|
|
|
+ if(!StringUtils.isEmpty(vo.getApplyVerifyUserId())){
|
|
|
+ vo.setApplyVerifyUser(sysUserMapper.selectUserNameById(vo.getApplyVerifyUserId()));
|
|
|
+ }
|
|
|
+ // 执行部门
|
|
|
+ if(!StringUtils.isEmpty(vo.getExecuteDept())){
|
|
|
+ vo.setExecuteDeptName(sysDeptMapper.selectByPrimaryKey(vo.getExecuteDept()).getName());
|
|
|
+ if(vo.getStatus() == PreparationStatusEnum.PROCESSING.getValue()
|
|
|
+ || vo.getStatus() == PreparationStatusEnum.FINISHED.getValue()
|
|
|
+ || vo.getStatus() == PreparationStatusEnum.WAIT_DISPATCH.getValue()){
|
|
|
+ vo.setDispatchUserName(sysUserMapper.selectUserNameById(vo.getDispatchUserId()));
|
|
|
+ }else{
|
|
|
+ // 获取筹建主管角色
|
|
|
+ SysUserDTO queryUserDTO = new SysUserDTO();
|
|
|
+ queryUserDTO.setRoleCode(SysRoleCodeEnum.PREPARATION_MANAGER.name());
|
|
|
+ queryUserDTO.setDeptId(vo.getExecuteDept());
|
|
|
+ List<SysUserVO> userVOS = sysUserMapper.selectDeptRoleUser(queryUserDTO);
|
|
|
+ // 判断执行部门是否有人接单
|
|
|
+ if(userVOS != null || userVOS.size() > 0){
|
|
|
+ StringBuilder info = new StringBuilder();
|
|
|
+ userVOS.forEach(item->{
|
|
|
+ info.append(item.getRealName()).append("、");
|
|
|
+ });
|
|
|
+ vo.setExecuteMangers(info.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return vo;
|
|
|
}
|
|
@@ -446,23 +493,25 @@ public class PreparationServiceImpl extends BaseServiceImpl<PreparationMapper, P
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 给筹建主管发送消息
|
|
|
- * @param userVOS
|
|
|
+ * 给申请部门主管发送消息
|
|
|
+ * @param user
|
|
|
* @param preparation
|
|
|
*/
|
|
|
- private void sendMessageToManger(List<SysUserVO> userVOS,Preparation preparation){
|
|
|
+ private void sendMessageToApplyManger(SysUser user,Preparation preparation){
|
|
|
String info = MessageTemplateUtil.getPreparationSuccess(preparation.getNo());
|
|
|
Integer detailType = WorkplaceBacklogDetailTypeEnum.PREPARATION_REPAIR.getValue();
|
|
|
- String[] values = new String[]{"有一条新的筹建消息!",preparation.getNo(),"无",preparation.getContent(),sbPositionMapper.selectNameById(preparation.getPositionId()),"请尽快派工"};
|
|
|
+ String[] values = new String[]{"【"+user.getRealName()+"】发起筹建工单申请",preparation.getNo(),"无",preparation.getContent(),sbPositionMapper.selectNameById(preparation.getPositionId()),"请审核"};
|
|
|
String wechatTemplateId = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_SEND_SUCCESS_WECHAT_TEMPLATE_ID.name());;
|
|
|
String detailUrl = "pages/preparation/preparation-detail?id=" + preparation.getId();
|
|
|
+ List<SysUserVO> userVOS = ListUtils.newArrayList();
|
|
|
+ userVOS.add(BeanConverterUtil.copyObjectProperties(user,SysUserVO.class));
|
|
|
Map<String,List<String>> maps = getPushReceivers(userVOS);
|
|
|
// 1、站内信
|
|
|
sendWorkplaceAndEmailNew(maps.get("mails"),maps.get("userIds"),preparation.getId(),info, detailType);
|
|
|
// 2、微信
|
|
|
SendMessageUtils.sendWechatNew(maps.get("openIds"),detailUrl,values,wechatTemplateId,1);
|
|
|
// 3、短信
|
|
|
- SendMessageUtils.sendCommonSms(maps.get("phones"),info);
|
|
|
+ //SendMessageUtils.sendCommonSms(maps.get("phones"),info);
|
|
|
}
|
|
|
|
|
|
private Map<String,List<String>> getPushReceivers(List<SysUserVO> userVOS){
|