jiangping
2025-04-14 0536f5fdc90f391f7ea19dff459ce2c916f36e5b
server/src/main/java/com/doumee/service/business/impl/WorkorderServiceImpl.java
@@ -22,6 +22,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.Manager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@@ -42,6 +43,7 @@
 * @since 2025/04/02 17:49
 */
@Service
@Slf4j
public class WorkorderServiceImpl implements WorkorderService {
    @Autowired
@@ -135,6 +137,8 @@
    }
    private static final String []  qwDetailUrls = {"/pages/details_she/details_she","/pages/workOrder_dca/workOrder_dca","","/pages/workOrder_she/workOrder_she"};
    /**
     * 通知文案整理
     * @param workorder
@@ -147,6 +151,7 @@
    public QywxTextCardMsgRequest dealMessageContent(Workorder workorder,String userName ,String categoryName,Integer contentType,String csInfo){
        QywxTextCardMsgRequest textCard = new QywxTextCardMsgRequest();
        String message = "";
        textCard.setUrl(qwDetailUrls[workorder.getType()]+"?id="+workorder.getId());
        if(Constants.equalsInteger(workorder.getType(),Constants.ZERO)){
            textCard.setTitle("【SHE事件上报】");
            if(Constants.equalsInteger(workorder.getMemberType(),Constants.ZERO)){
@@ -365,7 +370,7 @@
    }
    @Override
    public Workorder getDetail(Integer id){
    public Workorder getDetail(Integer id,Member member){
        Workorder workorder = workorderMapper.selectJoinOne(Workorder.class,
                new MPJLambdaWrapper<Workorder>()
                        .selectAll(Workorder.class)
@@ -373,14 +378,15 @@
                        .selectAs(Member::getName,Workorder::getMemberName)
                        .selectAs(Member::getCompanyName,Workorder::getCompanyName)
                        .select(" c3.name ",Workorder::getTypeName)
                        .select(" c4.name ",Workorder::getProblemName)
                        .select(" c4.name ",Workorder::getCategoryName)
                        .leftJoin(Member.class,Member::getId,Workorder::getMemberId)
                        .leftJoin(" category c3 on  t.TYPE_ID = c3.id   ") //风险类型
                        .leftJoin(" category c4 on  t.PROBLEM_ID = c4.id   ") //DCA问题编码
                        .leftJoin(" category c4 on  t.CATEGORY_ID = c4.id   ") //DCA问题编码
                        .eq(Workorder::getId,id)
                        .last(" limit 1 ")
        );
        if(Objects.nonNull(workorder)){
            this.dealButton(workorder,member);
            //查询附件信息
            List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda().eq(Multifile::getIsdeleted,Constants.ZERO)
                    .eq(Multifile::getObjId,workorder.getId()).orderByAsc(Multifile::getId));
@@ -405,6 +411,29 @@
        return workorder;
    }
    public void dealButton(Workorder workorder,Member member){
        workorder.setPassOnButton(Constants.ZERO);
        workorder.setCloseButton(Constants.ZERO);
        if(org.apache.commons.lang3.StringUtils.isNotBlank(member.getQwId())){
            List<String> closeUserList = new ArrayList<>();
            closeUserList.addAll(Arrays.asList(workorder.getQwnoticeMemberIds().split(",")));
            closeUserList.add(org.apache.commons.lang3.StringUtils.isNotBlank(workorder.getManagerId())?workorder.getManagerId():null);
            closeUserList.add(org.apache.commons.lang3.StringUtils.isNotBlank(workorder.getDealerId())?workorder.getDealerId():null);
            workorder.setCloseButton(closeUserList.stream().filter(i->i.equals(member.getQwId())).collect(Collectors.toList()).size()>Constants.ZERO?Constants.ONE:Constants.ZERO);
            List<String> passOnUserList = new ArrayList<>();
            //待分配状态 处理转交按钮
            if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitConfirm.getKey())){
                passOnUserList.addAll(Arrays.asList(workorder.getQwnoticeMemberIds().split(",")));
            }else if(Constants.equalsInteger(workorder.getStatus(),Constants.WorkOrderStatus.waitAllocation.getKey())){
                closeUserList.add(workorder.getManagerId());
            }
            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(passOnUserList)){
                workorder.setPassOnButton(passOnUserList.stream().filter(i->i.equals(member.getQwId())).collect(Collectors.toList()).size()>Constants.ZERO?Constants.ONE:Constants.ZERO);
            }
        }
    }
    public List<WorkorderLog> getLogList(Integer orderId){
        List<WorkorderLog> logList = workorderLogMapper.selectJoinList(WorkorderLog.class,
@@ -418,7 +447,7 @@
        );
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(logList)){
            String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode()
                    +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_FILE_PATH).getCode();
                    +systemDictDataBiz.queryByCode(Constants.FTP,Constants.WORKORDER_LOG_FILE_PATH).getCode();
            for (WorkorderLog workorderLog:logList) {
                //查询附件信息
                List<Multifile> multifileList = multifileMapper.selectList(new QueryWrapper<Multifile>().lambda()
@@ -770,6 +799,27 @@
        }
    }
    @Override
    public void sendSheEmail(){
        if(Constants.WORKORDER_SHE_EMAIL_SENDING){
            return;
        }
        Constants.WORKORDER_SHE_EMAIL_SENDING = true;
        try {
            List<Notices> list = noticesMapper.selectList(new QueryWrapper<Notices>().lambda()
                    .eq(Notices::getIsdeleted,Constants.ZERO)
                    .eq(Notices::getStatus,Constants.ZERO)
                    .eq(Notices::getType,Constants.THREE)//邮箱通知
            );
        }catch (Exception e){
            log.error("==================定时发生SHE邮件失败:"+e.getMessage());
        }finally {
            Constants.WORKORDER_SHE_EMAIL_SENDING = false;
        }
    }
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})