package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.whyc.config.EnumWorksheetType;
|
import com.whyc.mapper.ProductBomApprovingMapper;
|
import com.whyc.mapper.WorksheetLinkMapper;
|
import com.whyc.pojo.*;
|
import com.whyc.util.CommonUtil;
|
import com.whyc.util.FileUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.util.FileCopyUtils;
|
|
import javax.annotation.Resource;
|
import java.io.File;
|
import java.io.IOException;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
@Service
|
public class WorksheetLinkService {
|
|
@Resource
|
private WorksheetMainService mainService;
|
|
@Resource
|
private WorksheetLinkMapper linkMapper;
|
//lxw修改
|
@Autowired(required = false)
|
private ProductBomApprovingMapper approvingMapper;
|
|
@Autowired
|
private ProductBomService bomService;
|
|
@Autowired
|
private ProductApprovingService paService;
|
|
@Autowired
|
private ProductService productService;
|
|
@Autowired
|
private ProductBomHistoryService historyService;
|
|
@Autowired
|
private ProductBomApprovingService pbaService;
|
|
@Autowired
|
private MaterialProductHistoryService cphService;
|
|
@Autowired
|
private MaterialProductApprovingService cpAService;
|
|
@Autowired
|
private MaterialApprovingService mAService;
|
|
@Autowired
|
private MaterialService mService;
|
|
@Autowired
|
private ProductSoftwareApprovingService productSoftwareApprovingService;
|
|
@Autowired
|
private ProductSoftwareService productSoftwareService;
|
|
@Autowired
|
private ProductHistoryService phService;
|
|
@Transactional
|
public void audit(WorksheetLink link) {
|
link.setDealTime(new Date());
|
//更新节点信息
|
linkMapper.updateById(link);
|
if(link.getLinkStatus() == 2){ //驳回
|
//查看是否为物料审批,是则需要更新物料审批表中的状态为完结
|
if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Material.getType())){
|
mAService.endStatus(link.getMainId());
|
}
|
//项目经理驳回,驳回即终止
|
mainService.updateEndStatusById(link.getMainId(),"经理驳回,驳回原因:"+link.getDealReason(),0);
|
//项目经理驳回前,还曾经过总经理,则需要增加总经理驳回原因
|
if(link.getParentId()!=0) {
|
QueryWrapper<WorksheetLink> query = Wrappers.query();
|
query.eq("id", link.getParentId());
|
WorksheetLink parentLink = linkMapper.selectOne(query);
|
//这个是无效的,用户跟角色对比,不管,下面代码永不生效
|
if (parentLink.getDealUserId() == 1003) {
|
mainService.updateEndStatusById(link.getMainId(),
|
"经理驳回,驳回原因:" + link.getDealReason() + ";总经理驳回,驳回原因:" + parentLink.getDealReason(),
|
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) {
|
//根据节点,查询主表类型
|
Integer type = mainService.getInfoById(link.getMainId()).getType();
|
link.setDealTime(new Date());
|
//更新节点信息
|
linkMapper.updateById(link);
|
if(link.getLinkStatus() == 2){ //驳回
|
if(link.getParentId()!=0) {
|
//查询对应的项目经理
|
Long createUserId = linkMapper.selectById(link.getParentId()).getDealUserId();
|
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(), 1);
|
}else{
|
//说明是项目经理提交的,驳回即终止
|
mainService.updateEndStatusById(link.getMainId(),"总经理驳回,驳回原因:"+link.getDealReason(),0);
|
}
|
}else {
|
//审批通过,更新主表状态
|
mainService.updateEndStatusById(link.getMainId(), "完结", 5);
|
if (type.intValue() == EnumWorksheetType.ProductBom.getType()) { //产品审批
|
|
ProductApproving productApproving = paService.getByMainId(link.getMainId());
|
List<ProductBomApproving> approvingList = pbaService.getList(productApproving.getId());
|
//查询产品最新的版本号
|
String parentModel = productApproving.getParentModel();
|
String parentCode = productApproving.getParentCode();
|
String customCode = productApproving.getCustomCode();
|
Product product = productService.getVersion(parentCode, customCode);
|
int currentVersion = 0;
|
if (product != null) {
|
currentVersion = product.getVersion();
|
}
|
Integer nextVersion = currentVersion + 1;
|
//将产品文件复制至正式路径
|
//文件转移,未跟子件挂钩的所有图纸图片转移到产品版本下:doc_file/product/{产品型号}/standard或者{customCode}}/{version}/
|
//跟子件挂钩的转移到子件图纸下:doc_file/material/
|
//存储本次审批文件夹绝对路径
|
String fileUrl = productApproving.getFileUrl();
|
File file = new File(fileUrl);
|
List<String> fileUrlList = new LinkedList<>();
|
List<String> dwgUrlList = null;
|
List<String> picUrlList = null;
|
//存于物料下,bom内有对应
|
List<String> materialUrlList = new LinkedList<>();
|
//存于产品下,bom内没对应
|
List<String> productUrlList = new LinkedList<>();
|
|
List<Material> materialDwgUrlNameList = new LinkedList<>();
|
|
fileUrlList = FileUtil.getStaticFilePath(file,fileUrlList);
|
//图纸dwg 子件/产品
|
dwgUrlList = fileUrlList.stream().filter(url->url.contains(".dwg")).collect(Collectors.toList());
|
picUrlList = fileUrlList.stream().filter(url->url.contains(".png") || url.contains(".jpeg")).collect(Collectors.toList());
|
|
dwgUrlList.forEach(dwgUrl->{
|
boolean existFlag = false;
|
for (ProductBomApproving approving :approvingList){
|
String filename = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1, dwgUrl.length() - 4);
|
String fileFullName = dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1);
|
if(approving.getSubModel().toUpperCase().equals(filename.toUpperCase())){
|
materialUrlList.add(dwgUrl);
|
existFlag = true;
|
|
Material temp = new Material();
|
temp.setSubModel(approving.getSubModel());
|
temp.setNotes(CommonUtil.getProjectDir() + File.separator + "doc_file" + File.separator + "material"
|
+ File.separator + fileFullName);
|
materialDwgUrlNameList.add(temp);
|
break;
|
}
|
}
|
if(!existFlag) {
|
productUrlList.add(dwgUrl);
|
}
|
});
|
|
//一定是有对应物料的,从bom内剥离的
|
picUrlList.forEach(picUrl->{
|
for (ProductBomApproving approving :approvingList){
|
String filename = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1, picUrl.length() - 4);
|
String fileFullName = picUrl.substring(picUrl.lastIndexOf(File.separator) + 1);
|
if(approving.getSubModel().toUpperCase().equals(filename.toUpperCase())){
|
approving.setPictureUrl(CommonUtil.getProjectDir() + File.separator + "doc_file" + File.separator + "material"
|
+ File.separator + fileFullName);
|
break;
|
}
|
}
|
});
|
|
//转移路径
|
String projectDir = CommonUtil.getProjectDir();
|
//doc_file/product/{产品型号}/standard或者{customCode}}/{version}/
|
//跟子件挂钩的转移到子件图纸下:doc_file/material/
|
String customCodeString = null;
|
if(customCode==null) {
|
customCodeString = "standard";
|
}else{
|
customCodeString = customCode;
|
}
|
String productDir = projectDir + File.separator + "doc_file" + File.separator + "product" + File.separator + parentModel
|
+ File.separator + customCodeString + File.separator +nextVersion;
|
String materialDir = projectDir + File.separator + "doc_file" + File.separator + "material";
|
File productDirFile = new File(productDir);
|
File materialFile = new File(materialDir);
|
if(!productDirFile.exists()){
|
productDirFile.mkdirs();
|
}
|
if(!materialFile.exists()){
|
materialFile.mkdirs();
|
}
|
productUrlList.forEach(productUrl->{
|
String dwgName = productUrl.substring(productUrl.lastIndexOf(File.separator) + 1, productUrl.length() - 4);
|
|
try {
|
FileCopyUtils.copy(new File(productUrl),new File(productDir+File.separator+dwgName+".dwg"));
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
});
|
|
materialUrlList.forEach(materialUrl->{
|
String dwgName = materialUrl.substring(materialUrl.lastIndexOf(File.separator) + 1, materialUrl.length() - 4);
|
try {
|
FileCopyUtils.copy(new File(materialUrl),new File(materialDir+File.separator+dwgName+".dwg"));
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
});
|
|
|
//转移审批表数据到历史表/最新版本表 product_history/product_bom_history/product/product_bom
|
ProductHistory productHistory = new ProductHistory();
|
productHistory.setParentCode(parentCode);
|
productHistory.setParentName(productApproving.getParentName());
|
productApproving.setParentModel(parentModel);
|
productHistory.setNotes(productApproving.getNotes());
|
productHistory.setCustomCode(customCode);
|
productHistory.setCreateTime(new Date());
|
productHistory.setVersion(nextVersion);
|
productHistory.setEnabled(1);
|
|
phService.insertAndUpdateEnabled(productHistory);
|
int productId = productService.updateVersion(parentCode,customCode,nextVersion);
|
|
List<ProductBomHistory> productBomHistoryList = new LinkedList<>();
|
List<ProductBom> productBomList = new LinkedList<>();
|
approvingList.forEach(approving->{
|
ProductBomHistory bomHistory = new ProductBomHistory();
|
ProductBom bom = new ProductBom();
|
|
bom.setProductId(productId);
|
bom.setCategory(approving.getCategory());
|
bom.setCreateDate(new Date());
|
bom.setDwgUrl(approving.getDwgUrl());
|
bom.setFileUrl(approving.getFileUrl());
|
bom.setMaterial(approving.getMaterial());
|
bom.setNotes(approving.getNotes());
|
bom.setPictureUrl(approving.getPictureUrl());
|
bom.setProducer(approving.getProducer());
|
bom.setQuantity(approving.getQuantity());
|
bom.setSubCode(approving.getSubCode());
|
bom.setSubModel(approving.getSubModel());
|
bom.setSubName(approving.getSubName());
|
bom.setSurfaceDetail(approving.getSurfaceDetail());
|
bom.setThickness(approving.getThickness());
|
bom.setType(approving.getType());
|
bom.setUnit(approving.getUnit());
|
bom.setUpUserId(approving.getUpUserId());
|
bom.setVersion(nextVersion);
|
|
bomHistory.setProductId(productHistory.getId());
|
bomHistory.setCategory(approving.getCategory());
|
bomHistory.setCreateDate(new Date());
|
bomHistory.setDwgUrl(approving.getDwgUrl());
|
bomHistory.setFileUrl(approving.getFileUrl());
|
bomHistory.setMaterial(approving.getMaterial());
|
bomHistory.setNotes(approving.getNotes());
|
bomHistory.setPictureUrl(approving.getPictureUrl());
|
bomHistory.setProducer(approving.getProducer());
|
bomHistory.setQuantity(approving.getQuantity());
|
bomHistory.setSubCode(approving.getSubCode());
|
bomHistory.setSubModel(approving.getSubModel());
|
bomHistory.setSubName(approving.getSubName());
|
bomHistory.setSurfaceDetail(approving.getSurfaceDetail());
|
bomHistory.setThickness(approving.getThickness());
|
bomHistory.setType(approving.getType());
|
bomHistory.setUnit(approving.getUnit());
|
bomHistory.setUpUserId(approving.getUpUserId());
|
bomHistory.setVersion(nextVersion);
|
|
productBomHistoryList.add(bomHistory);
|
productBomList.add(bom);
|
});
|
historyService.addBatch(productBomHistoryList);
|
bomService.insertBatch(productBomList);
|
|
//物料表中不存在的,则添加到物料表中去
|
List<String> codeList = approvingList.stream().map(ProductBomApproving::getSubCode).collect(Collectors.toList());
|
List<String> existCodeList = mService.getListByCodeList(codeList);
|
List<Material> materialList = new LinkedList<>();
|
approvingList.forEach(approving->{
|
if(!existCodeList.contains(approving.getSubCode())){ //这个审批bom中的物料不在物料管理内
|
Material temp = new Material();
|
temp.setCategory(approving.getCategory());
|
temp.setCreateDate(new Date());
|
temp.setDwgUrl(approving.getDwgUrl());
|
temp.setFileUrl(approving.getFileUrl());
|
temp.setMaterial(approving.getMaterial());
|
temp.setNotes(approving.getNotes());
|
temp.setPictureUrl(approving.getPictureUrl());
|
temp.setProducer(approving.getProducer());
|
temp.setQuantity(approving.getQuantity());
|
temp.setStatus(1);
|
temp.setSubCode(approving.getSubCode());
|
temp.setSubModel(approving.getSubModel());
|
temp.setSubName(approving.getSubName());
|
temp.setSurfaceDetail(approving.getSurfaceDetail());
|
temp.setThickness(approving.getThickness());
|
temp.setType(approving.getType());
|
temp.setUnit(approving.getUnit());
|
materialList.add(temp);
|
}
|
});
|
mService.insertBatch(materialList);
|
|
//将dwg图纸,全部更新到对应的记录url中
|
mService.updateDwgUrl(materialDwgUrlNameList);
|
/*List<ProductBomApproving> fileBomApprovingList = approvingList.stream()
|
.filter(productBomApproving ->
|
productBomApproving.getPictureUrl() != null || productBomApproving.getDwgUrl() != null
|
).collect(Collectors.toList());
|
String projectDir = CommonUtil.getProjectDir();
|
fileBomApprovingList.forEach(fileBom -> {
|
try {
|
String pictureUrl = fileBom.getPictureUrl();
|
String dwgUrl = fileBom.getDwgUrl();
|
if (pictureUrl != null) {
|
String newPictureUrl = "doc_file" + File.separator + "product" + File.separator + fileBom.getParentModel() + File.separator + pictureUrl.substring(pictureUrl.lastIndexOf(File.separator) + 1);
|
File newPictureDir = new File(projectDir + File.separator + "doc_file" + File.separator + "product" + File.separator + fileBom.getParentModel());
|
if (!newPictureDir.exists()) {
|
newPictureDir.mkdirs();
|
}
|
FileCopyUtils.copy(new File(projectDir + File.separator + pictureUrl),
|
new File(projectDir + File.separator + newPictureUrl));
|
fileBom.setPictureUrl(newPictureUrl);
|
}
|
if (dwgUrl != null) {
|
String newDwgUrl = "doc_file" + File.separator + "product" + File.separator + fileBom.getParentModel() + File.separator + dwgUrl.substring(dwgUrl.lastIndexOf(File.separator) + 1);
|
File newDwgDir = new File(projectDir + File.separator + "doc_file" + File.separator + "product" + File.separator + fileBom.getParentModel());
|
if (!newDwgDir.exists()) {
|
newDwgDir.mkdirs();
|
}
|
FileCopyUtils.copy(new File(projectDir + File.separator + dwgUrl),
|
new File(projectDir + File.separator + newDwgUrl));
|
fileBom.setDwgUrl(newDwgUrl);
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
});
|
//更新正式bom的对应url
|
bomService.updateUrl(fileBomApprovingList);*/
|
}
|
else if(type.intValue() == EnumWorksheetType.Material.getType()){ //物料
|
List<MaterialApproving> approvingList = mAService.getListByMainId(link.getMainId());
|
List<Material> MaterialList = new LinkedList<>();
|
//区分是新增还是删除
|
Integer MaterialId = approvingList.get(0).getMaterialId();
|
if(MaterialId==null) { //新增
|
//将物料从审批表中转移到正式表
|
approvingList.forEach(approve -> {
|
Material material = new Material();
|
material.setCategory(approve.getCategory());
|
material.setSubCode(approve.getSubCode());
|
material.setSubName(approve.getSubName());
|
material.setSubModel(approve.getSubModel());
|
material.setUnit(approve.getUnit());
|
material.setQuantity(approve.getQuantity());
|
material.setProducer(approve.getProducer());
|
material.setNotes(approve.getNotes());
|
material.setCreateDate(new Date());
|
material.setStatus(1);
|
MaterialList.add(material);
|
});
|
mService.insertBatch(MaterialList);
|
}else{ //删除
|
List<Integer> MaterialIdList = approvingList.stream().map(MaterialApproving::getMaterialId).collect(Collectors.toList());
|
mService.deleteBatch(MaterialIdList);
|
}
|
//更新物料审批子表中type为完结
|
mAService.endStatus(link.getMainId());
|
}
|
else if(type.intValue() == EnumWorksheetType.MaterialProduct.getType()){ //更新物料-产品关系
|
//查找到对应的物料-产品关系数据
|
List<MaterialProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
|
//查询部件最新的版本号
|
//lxw修改
|
//ProductBom product = bomService.getProduct(cpAList.get(0).getParentModel());
|
ProductBom product=new ProductBom();
|
int currentVersion = -1;
|
if (product != null) {
|
currentVersion = product.getVersion();
|
}
|
Integer nextVersion = currentVersion + 1;
|
//关联/接触关联,更新版本
|
//替换,更新版本,同时bom表历史中对应的subName 版本号不变(排除更新)
|
Map<Integer, List<MaterialProductApproving>> linkTypeMap = cpAList.stream().collect(Collectors.groupingBy(MaterialProductApproving::getLinkType));
|
List<MaterialProductApproving> addedList = new LinkedList<>();
|
List<MaterialProductApproving> replacedList = new LinkedList<>();
|
List<MaterialProductApproving> removedList = new LinkedList<>();
|
linkTypeMap.forEach((linkType,list)->{
|
if(linkType == 1){
|
addedList.addAll(list);
|
}else if(linkType == 2){
|
replacedList.addAll(list);
|
}else{
|
removedList.addAll(list);
|
}
|
});
|
List<MaterialProductHistory> newHistoryList = new LinkedList<>();
|
//查询最新版本生效的相关物料
|
//lxw注释
|
//List<MaterialProductHistory> nowHistoryList = cphService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
|
List<MaterialProductHistory> nowHistoryList =new ArrayList<>();
|
//查询历史中最新版本生效的bom
|
//List<ProductBomHistory> nowBomHistoryList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
|
List<ProductBomHistory> nowBomHistoryList = new ArrayList<>();
|
/*
|
对于关联的,判断当前版本中是否存在替换关系,存在,则直接下个版本插入关联;
|
同时,其他当前版本的相关物料-产品记录更新版本,排除存在的替换关系
|
*/
|
|
/*
|
对于替换的,判断当前版本中是否存在关联关系,存在,直接下个版本替换,记录插入;
|
同时,当前版本的相关物料-产品记录更新版本,排除存在的关联关系;
|
同时,bom表更新到下个版本时,排除被替换件
|
*/
|
|
//对于解除关联的,当前版本的相关物料-产品记录更新版本,排除解除关联的记录
|
//处理思路:先解除关联,再替换,再关联
|
if(removedList.size()!=0){
|
removedList.forEach(remove -> {
|
/*nowHistoryList.forEach(nowHistory -> {
|
if (remove.getMaterialId().intValue() == nowHistory.getMaterialId()) {
|
nowHistoryList.remove(nowHistory);
|
}
|
});*/
|
Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
|
while (iterator.hasNext()){
|
MaterialProductHistory next = iterator.next();
|
//lxw注释
|
/*if(remove.getMaterialId().intValue() == next.getMaterialId()
|
&&remove.getSubName().equals(next.getSubName())
|
){
|
iterator.remove();
|
break;
|
}*/
|
}
|
});
|
}
|
|
//处理替换
|
if(replacedList.size()!=0){
|
replacedList.forEach(replace -> {
|
//当前生效的物料-产品列表
|
/*nowHistoryList.forEach(nowHistory -> {
|
if (replace.getMaterialId().intValue() == nowHistory.getMaterialId()) {
|
nowHistoryList.remove(nowHistory);
|
}
|
});*/
|
if(nowHistoryList.size()!=0) {
|
Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
|
while (iterator.hasNext()) {
|
MaterialProductHistory next = iterator.next();
|
//lxw注释
|
/*if (replace.getMaterialId().intValue() == next.getMaterialId()
|
&& replace.getSubName().equals(next.getSubName())
|
) {
|
iterator.remove();
|
break;
|
}*/
|
}
|
}
|
//下个版本新增替换的物料-产品列表
|
MaterialProductHistory newHistory = new MaterialProductHistory();
|
newHistory.setMaterialId(replace.getMaterialId());
|
//lxw注释
|
//newHistory.setParentModel(replace.getParentModel());
|
//newHistory.setSubName(replace.getSubName());
|
newHistory.setQuantity(replace.getQuantity());
|
newHistory.setCreateTime(new Date());
|
newHistory.setLinkType(2);
|
//newHistory.setSVersion(nextVersion);
|
//newHistory.setEVersion(nextVersion);
|
newHistoryList.add(newHistory);
|
//当前生效的bom列表
|
/*nowBomHistoryList.forEach(nowBomHistory->{
|
if(replace.getSubName().equals(nowBomHistory.getSubName())){
|
nowBomHistoryList.remove(nowBomHistory);
|
}
|
});*/
|
Iterator<ProductBomHistory> iterator1 = nowBomHistoryList.iterator();
|
while (iterator1.hasNext()){
|
//lxw注释
|
/*if(replace.getSubName().equals(iterator1.next().getSubName())){
|
iterator1.remove();
|
break;
|
}*/
|
}
|
});
|
}
|
|
//处理关联
|
addedList.forEach(add -> {
|
/*nowHistoryList.forEach(nowHistory -> {
|
if (add.getMaterialId().intValue() == nowHistory.getMaterialId()) {
|
nowHistoryList.remove(nowHistory);
|
}
|
});*/
|
if(nowHistoryList.size()!=0) {
|
Iterator<MaterialProductHistory> iterator = nowHistoryList.iterator();
|
while (iterator.hasNext()) {
|
MaterialProductHistory next = iterator.next();
|
//lxw注释
|
/*if (add.getMaterialId().intValue() == next.getMaterialId()
|
&& add.getSubName().equals(next.getSubName())
|
) {
|
iterator.remove();
|
break;
|
}*/
|
}
|
}
|
|
MaterialProductHistory newHistory = new MaterialProductHistory();
|
newHistory.setMaterialId(add.getMaterialId());
|
//newHistory.setParentModel(add.getParentModel());
|
//newHistory.setSubName(add.getSubName());
|
newHistory.setQuantity(add.getQuantity());
|
newHistory.setCreateTime(new Date());
|
newHistory.setLinkType(1);
|
//newHistory.setSVersion(nextVersion);
|
//newHistory.setEVersion(nextVersion);
|
newHistoryList.add(newHistory);
|
|
});
|
|
//处理完成,进行表单数据更新,分为nowHistoryList,newHistoryList,nowBomHistoryList
|
//nowHistoryList.forEach(nowHis->nowHis.setEVersion(nextVersion));
|
//lxw注释
|
//if(newHistoryList.size()!=0){newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});}
|
//if(nowBomHistoryList.size()!=0){nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));}
|
|
if(nowHistoryList.size()!=0){cphService.updateVersionBatch(nowHistoryList);}
|
if(newHistoryList.size()!=0){cphService.insertBatch(newHistoryList);}
|
if(nowBomHistoryList.size()!=0){historyService.updateVersionBatch(nowBomHistoryList);}
|
//更新ProductBom
|
//lxw注释
|
//List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion);
|
//bomService.updateNewBom(newBomList);
|
}
|
else if(type.intValue() == EnumWorksheetType.ProductSoftware.getType()){ //软件下载
|
//转移记录到正式表
|
ProductSoftwareApproving productSoftwareApproving = productSoftwareApprovingService.getByMainId(link.getMainId());
|
ProductSoftware productSoftware = new ProductSoftware();
|
productSoftware.setParentModel(productSoftwareApproving.getParentModel());
|
productSoftware.setSoftwareName(productSoftwareApproving.getSoftwareName());
|
productSoftware.setSoftwareUrl(productSoftwareApproving.getSoftwareUrl());
|
productSoftware.setSubmitTime(productSoftwareApproving.getCreateTime());
|
productSoftware.setCreateTime(new Date());
|
|
productSoftwareService.insert(productSoftware);
|
}
|
}
|
}
|
|
/**
|
* 获取节点信息(包含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);
|
}
|
|
public DocUser getApprovingUser(Integer mainId) {
|
return linkMapper.getApprovingUser(mainId);
|
}
|
}
|