package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.whyc.mapper.ProductBomApprovingMapper;
|
import com.whyc.mapper.WorksheetLinkMapper;
|
import com.whyc.pojo.ProductBomApproving;
|
import com.whyc.pojo.WorksheetLink;
|
import com.whyc.pojo.WorksheetMain;
|
import com.whyc.util.CommonUtil;
|
import org.aspectj.util.FileUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import javax.naming.CommunicationException;
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class WorksheetLinkService {
|
|
@Resource
|
private WorksheetMainService mainService;
|
|
@Resource
|
private WorksheetLinkMapper linkMapper;
|
|
@Autowired
|
private ProductBomApprovingMapper approvingMapper;
|
|
@Autowired
|
private ProductBomService bomService;
|
|
@Autowired
|
private ProductBomHistoryService historyService;
|
|
@Transactional
|
public void audit(WorksheetLink link) {
|
link.setDealTime(new Date());
|
//更新节点信息
|
linkMapper.updateById(link);
|
if(link.getLinkStatus() == 2){ //驳回
|
//驳回到员工进行处理
|
//查询工单的员工
|
Long createUserId = mainService.getInfoById(link.getMainId()).getCreateUserId();
|
WorksheetLink link2 = new WorksheetLink();
|
link2.setMainId(link.getMainId());
|
link2.setParentId(link.getId());
|
link2.setDealUserId(createUserId);
|
link2.setDealType(0);
|
link2.setDealDesc("工单被经理驳回,驳回信息:"+link.getDealReason());
|
link2.setLinkStatus(0);
|
link2.setEnableArchive(0);
|
linkMapper.insert(link2);
|
//更新主表状态
|
mainService.updateStatusById(link.getMainId(),0);
|
}else{
|
//进入下一节点,总经理审批
|
WorksheetLink link2 = new WorksheetLink();
|
link2.setMainId(link.getMainId());
|
link2.setParentId(link.getId());
|
link2.setDealUserId(link.getNextUser());
|
link2.setDealType(2);
|
link2.setDealDesc("工单被经理审核通过,信息:"+link.getDealReason());
|
link2.setLinkStatus(0);
|
link2.setEnableArchive(1);
|
linkMapper.insert(link2);
|
//更新主表状态
|
mainService.updateStatusById(link.getMainId(),2);
|
}
|
}
|
|
@Transactional
|
public void approve(WorksheetLink link) {
|
link.setDealTime(new Date());
|
//更新节点信息
|
linkMapper.updateById(link);
|
if(link.getLinkStatus() == 2){ //驳回
|
//驳回到员工进行处理
|
//查询工单的员工
|
Long createUserId = mainService.getInfoById(link.getMainId()).getCreateUserId();
|
WorksheetLink link2 = new WorksheetLink();
|
link2.setMainId(link.getMainId());
|
link2.setParentId(link.getId());
|
link2.setDealUserId(createUserId);
|
link2.setDealType(0);
|
link2.setDealDesc("工单被经理驳回,驳回信息:"+link.getDealReason());
|
link2.setLinkStatus(0);
|
link2.setEnableArchive(0);
|
linkMapper.insert(link2);
|
//更新主表状态
|
mainService.updateStatusById(link.getMainId(),0);
|
}else{
|
//审批通过,更新主表状态
|
mainService.updateEndStatusById(link.getMainId(),"完结",5);
|
//将产品文件复制至正式路径
|
QueryWrapper<ProductBomApproving> query = Wrappers.query();
|
query.eq("main_id",link.getMainId());
|
List<ProductBomApproving> approvingList = approvingMapper.selectList(query);
|
|
//增加->增加部件(增加记录,同时所有eVersion+1)
|
//修改->修改部件图纸,修改部件非图纸(增加记录,同时修改非原部件的所有eVersion+1)
|
//删除? TODO 需要约定逻辑
|
|
//查询部件最新的版本号
|
Integer version = bomService.getProduct(approvingList.get(0).getParentModel()).getVersion();
|
if(version==null){
|
version = 0;
|
}
|
Integer nextVersion = version+1;
|
//更新到product_bom_history,需要sVersion和eVersion
|
//增加所有部件,排查出相关的原部件,非也是更新
|
//historyService.get
|
|
//更新到product_bom
|
|
/*String projectDir = CommonUtil.getProjectDir();
|
FileUtil.copyDir()*/
|
|
|
//将产品bom表的url修正,更新到正式表
|
}
|
}
|
|
/**
|
* 获取节点信息(包含main表)列表
|
* @param id
|
* @return
|
*/
|
public List<WorksheetLink> getInfoList(Long id) {
|
return linkMapper.getInfoList(id);
|
}
|
|
/**
|
*
|
* @param userId 总经理对应的userId
|
* @param statusExp 0:未审批,1:已审批(包含状态值1,2)
|
* @return
|
*/
|
public List<WorksheetMain> getInfoList2(Long userId, int statusExp) {
|
return linkMapper.getInfoList2(userId,statusExp);
|
}
|
|
/**
|
*
|
* @param userId 总经理对应的userId
|
* @param statusExp 0:未审批,1:已审批(包含状态值1,2)
|
* @return
|
*/
|
public List<WorksheetMain> getInfoList3(Long userId, int statusExp) {
|
return linkMapper.getInfoList3(userId,statusExp);
|
}
|
}
|