|
@@ -0,0 +1,176 @@
|
|
|
+package com.platform.service.sbUnused.impl;
|
|
|
+import com.platform.common.bean.AbstractPageResultBean;
|
|
|
+import com.platform.common.cache.ConfigCache;
|
|
|
+import com.platform.common.exception.BusinessException;
|
|
|
+import com.platform.common.model.UserInfo;
|
|
|
+import com.platform.common.util.*;
|
|
|
+import com.platform.dao.bean.MyPage;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.platform.dao.dto.longyanpurchaseorder.LongYanPurchaseOrderDTO;
|
|
|
+import com.platform.dao.dto.repair.RepairApplicationFormDTO;
|
|
|
+import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
+import com.platform.dao.dto.sbUnuseddetail.SbUnusedDetailDTO;
|
|
|
+import com.platform.dao.entity.sbUnuseddetail.SbUnusedDetail;
|
|
|
+import com.platform.dao.enums.SbUnusedStatusEnum;
|
|
|
+import com.platform.dao.enums.SysConfigEnum;
|
|
|
+import com.platform.dao.enums.WorkplaceBacklogDetailTypeEnum;
|
|
|
+import com.platform.dao.enums.WorkplaceBacklogTypeEnum;
|
|
|
+import com.platform.dao.mapper.sbUnuseddetail.SbUnusedDetailMapper;
|
|
|
+import com.platform.dao.util.MessageTemplateUtil;
|
|
|
+import com.platform.dao.vo.query.project.ProjectVO;
|
|
|
+import com.platform.dao.vo.query.sbUnused.SbUnusedVO;
|
|
|
+import com.platform.dao.dto.sbUnused.SbUnusedDTO;
|
|
|
+import com.platform.dao.entity.sbUnused.SbUnused;
|
|
|
+import com.platform.dao.mapper.sbUnused.SbUnusedMapper;
|
|
|
+import com.platform.dao.vo.query.sbUnuseddetail.SbUnusedDetailVO;
|
|
|
+import com.platform.service.event.WorkplaceBacklogEvent;
|
|
|
+import com.platform.service.sbUnused.SbUnusedService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import tk.mybatis.mapper.weekend.Weekend;
|
|
|
+import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description 设备闲置表 service 实现类
|
|
|
+ * @Author lsq
|
|
|
+ * @Date 2023-08-22 15:50:16
|
|
|
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
|
|
|
+ */
|
|
|
+@AllArgsConstructor
|
|
|
+@Service("sbUnusedService")
|
|
|
+public class SbUnusedServiceImpl extends BaseServiceImpl<SbUnusedMapper, SbUnused, SbUnusedDTO> implements SbUnusedService {
|
|
|
+
|
|
|
+ private SbUnusedDetailMapper sbUnusedDetailMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SbUnusedVO getModelById2(String id) {
|
|
|
+
|
|
|
+ SbUnusedVO vo = mapper.getUnusedVO(id);
|
|
|
+ SbUnusedDetailDTO queryDetail = new SbUnusedDetailDTO();
|
|
|
+ queryDetail.setSbUnusedId(id);
|
|
|
+ List<SbUnusedDetailVO> sbUnusedDetailVOS = sbUnusedDetailMapper.selectList(queryDetail);
|
|
|
+ vo.setSbUnusedDetailVOS(sbUnusedDetailVOS);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void unusedVerify(String id, SbUnusedDTO dto) {
|
|
|
+ SbUnused unused = mapper.selectByPrimaryKey(id);
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+
|
|
|
+ String domain = getAndCheckPcDomain();
|
|
|
+
|
|
|
+ //审核被拒,通知申请人
|
|
|
+ if (dto.getStatus()==SbUnusedStatusEnum.refused.getValue()){
|
|
|
+ userIds.add(unused.getApplyUserId());
|
|
|
+ String unusedUrl = domain + "sbUnused/unused?id=" + unused.getId();
|
|
|
+ String info = MessageTemplateUtil.getRefuseUnusedSbVmHtmlContent(unusedUrl,
|
|
|
+ BeanConverterUtil.copyObjectProperties(unused,SbUnusedDTO.class));
|
|
|
+ sendWorkplaceAndEmailNew(null,userIds,unused.getId(),info, WorkplaceBacklogDetailTypeEnum.SB_UNUSED_VERIFY.getValue());
|
|
|
+ }else if (dto.getStatus()==SbUnusedStatusEnum.verifying_two.getValue()){
|
|
|
+ userIds.add("636c57bd3abe1415981b18ec");//何经理
|
|
|
+ String unusedUrl = domain + "sbUnused/unused?id=" + unused.getId();
|
|
|
+ String info = MessageTemplateUtil.getUnusedSbVmHtmlContent(unusedUrl,
|
|
|
+ BeanConverterUtil.copyObjectProperties(unused,SbUnusedDTO.class));
|
|
|
+ sendWorkplaceAndEmailNew(null,userIds,unused.getId(),info, WorkplaceBacklogDetailTypeEnum.SB_UNUSED_VERIFY.getValue());
|
|
|
+ }else if (dto.getStatus()==SbUnusedStatusEnum.success.getValue()){
|
|
|
+ //何经理审核通过
|
|
|
+ userIds.add(unused.getApplyUserId());
|
|
|
+// String unusedUrl = domain + "sbUnused/unused?no=" + unused.getNo();
|
|
|
+ String info = MessageTemplateUtil.getUnusedSbSuccessVmHtmlContent(
|
|
|
+ BeanConverterUtil.copyObjectProperties(unused,SbUnusedDTO.class));
|
|
|
+ sendWorkplaceAndEmailNew(null,userIds,unused.getId(),info, WorkplaceBacklogDetailTypeEnum.SB_UNUSED_VERIFY.getValue());
|
|
|
+ }
|
|
|
+ SbUnused upd = new SbUnused();
|
|
|
+ upd.setId(unused.getId());
|
|
|
+ upd.setStatus(dto.getStatus());
|
|
|
+ upd.setAdvice(dto.getAdvice());
|
|
|
+ mapper.updateByPrimaryKeySelective(upd);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SbUnused saveModelByDTO(SbUnusedDTO model) {
|
|
|
+
|
|
|
+ UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
+ model.setApplyUserId(userInfo.getUserId());
|
|
|
+ model.setApplyTime(LocalDateTime.now());
|
|
|
+ model.setStatus(SbUnusedStatusEnum.verifying_one.getValue());
|
|
|
+
|
|
|
+ int countNum = mapper.selectCount(new SbUnused());
|
|
|
+ model.setNo(IdGeneratorUtils.getUnusedSbNo(countNum));
|
|
|
+
|
|
|
+ SbUnused unused = super.saveModelByDTO(model);
|
|
|
+ List<SbUnusedDetail> sbUnusedDetails = new ArrayList<>();
|
|
|
+ for (SbInfoDTO dto:model.getSbInfoDTOS()){
|
|
|
+ SbUnusedDetail detail = new SbUnusedDetail();
|
|
|
+ detail.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ detail.setSbId(dto.getId());
|
|
|
+ detail.setSbName(dto.getName());
|
|
|
+ detail.setPositionNo(dto.getPositionNo());
|
|
|
+ detail.setSbNo(dto.getNo());
|
|
|
+ detail.setCreatedTime(LocalDateTime.now());
|
|
|
+ detail.setCreatedUserId(userInfo.getUserId());
|
|
|
+ detail.setUpdateTime(LocalDateTime.now());
|
|
|
+ detail.setUpdateUserId(userInfo.getUserId());
|
|
|
+ sbUnusedDetails.add(detail);
|
|
|
+ }
|
|
|
+ sbUnusedDetailMapper.insertListforComplex(sbUnusedDetails);
|
|
|
+
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ userIds.add(model.getVerityUserId());
|
|
|
+
|
|
|
+ String domain = getAndCheckPcDomain();
|
|
|
+ String unusedUrl = domain + "sbUnused/unused?id=" + unused.getId();
|
|
|
+ String info = MessageTemplateUtil.getUnusedSbVmHtmlContent(unusedUrl,
|
|
|
+ BeanConverterUtil.copyObjectProperties(unused,SbUnusedDTO.class));
|
|
|
+ sendWorkplaceAndEmailNew(null,userIds,unused.getId(),info, WorkplaceBacklogDetailTypeEnum.SB_UNUSED_VERIFY.getValue());
|
|
|
+ return unused;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sendWorkplaceAndEmailNew(List<String> mails,List<String> userIds,String repairId,String content,Integer detailType){
|
|
|
+ // 通过给当天值班维修人员
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), detailType,
|
|
|
+ repairId, content, repairId, userIds, mails));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int batchDelete(List<String> ids) {
|
|
|
+ Weekend<SbUnused> weekend = new Weekend<>(SbUnused.class);
|
|
|
+ WeekendCriteria<SbUnused, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
+ weekendCriteria.andIn(SbUnused::getId, ids);
|
|
|
+ mapper.deleteByExample(weekend);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ public String getAndCheckPcDomain(){
|
|
|
+ String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
+ if (StringUtils.isBlank(domain)) {
|
|
|
+ throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
|
|
|
+ }
|
|
|
+ if (!domain.endsWith("/")) {
|
|
|
+ domain = domain + "/";
|
|
|
+ }
|
|
|
+ return domain;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AbstractPageResultBean<SbUnusedVO> selectPageList(SbUnusedDTO record, int pageNum, int pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ return new MyPage(mapper.selectList(record));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AbstractPageResultBean<SbUnused> selectPageInfo(SbUnusedDTO record, int pageNum, int pageSize) {
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
+ return new MyPage(mapper.selectList(record));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|