From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:51:38 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocRelativeServiceImpl.java | 135 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 135 insertions(+), 0 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocRelativeServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocRelativeServiceImpl.java new file mode 100644 index 0000000..768e547 --- /dev/null +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocRelativeServiceImpl.java @@ -0,0 +1,135 @@ +package org.jeecg.modules.dnc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; +import org.jeecg.modules.dnc.entity.DocInfo; +import org.jeecg.modules.dnc.entity.DocRelative; +import org.jeecg.modules.dnc.exception.ExceptionCast; +import org.jeecg.modules.dnc.ext.NcTxtFilePathInfo; +import org.jeecg.modules.dnc.mapper.DocInfoMapper; +import org.jeecg.modules.dnc.mapper.DocRelativeMapper; +import org.jeecg.modules.dnc.response.CommonCode; +import org.jeecg.modules.dnc.service.IDocRelativeService; +import org.jeecg.modules.dnc.utils.ValidateUtil; +import org.jeecg.modules.dnc.utils.date.DateUtil; +import org.jeecg.modules.dnc.utils.file.FileUtilS; +import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.mdc.service.IMdcEquipmentService; +import org.jeecg.modules.system.service.IMdcProductionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +public class DocRelativeServiceImpl extends ServiceImpl<DocRelativeMapper, DocRelative> implements IDocRelativeService { + + @Autowired + private DocInfoMapper docInfoMapper; + @Autowired + private IMdcEquipmentService iMdcEquipmentService; + @Autowired + private IMdcProductionService iMdcProductionService; + + + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean deleteByDocAttr(Integer attrType, String attrId) { + LambdaQueryWrapper<DocRelative> lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(DocRelative::getAttributionType, attrType).eq(DocRelative::getAttributionId, attrId); + return super.remove(lambdaQueryWrapper); + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean deleteByDocId(String id) { + LambdaQueryWrapper<DocRelative> lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(DocRelative::getDocId, id); + return super.remove(lambdaQueryWrapper); + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean deleteDocByAttr(String docId, Integer attrType, String attrId) { + List<DocRelative> docRelatives = super.lambdaQuery().eq(DocRelative::getDocId, docId). + eq(DocRelative::getAttributionType, attrType). + eq(DocRelative::getAttributionId, attrId).list(); + boolean docRel = false; + DocRelative docRelative = new DocRelative(); + if (docRelatives != null && !docRelatives.isEmpty()) { + String classificationId = "1259647678577995778"; + docRelative = docRelatives.get(0); + if (classificationId.equals(docRelative.getClassificationId())) { + docRel = true; + } + } + LambdaQueryWrapper<DocRelative> lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(DocRelative::getDocId, docId); + lambdaQueryWrapper.eq(DocRelative::getAttributionType, attrType); + lambdaQueryWrapper.eq(DocRelative::getAttributionId, attrId); + boolean b = super.remove(lambdaQueryWrapper); + + if (b && docRel) { + DocInfo info = docInfoMapper.selectById(docId); + //todo 淇敼涓簃dc璁惧 + MdcEquipment mdcEquipment=iMdcEquipmentService.getById(attrId); + List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); + if (strings != null && !strings.isEmpty()) { + String path = StringUtils.join(strings.toArray(), "/"); + boolean deleteFile = FileUtilS.deleteFilePathZip(path + "/"+ mdcEquipment.getEquipmentId(), + info.getDocName(), info.getDocSuffix()); + if (!deleteFile) { + return false; + } + //澶勭悊鏂囦欢鍚嶇О 鏂囦欢璺緞 + + NcTxtFilePathInfo ncTxt = new NcTxtFilePathInfo(); + ncTxt.setEquipmentId(mdcEquipment.getEquipmentId()); + ncTxt.setFilePath(path + "/"+ mdcEquipment.getEquipmentId() + "/" ); + ncTxt.setFileTxtName("02A"+DateUtil.format(DateUtil.getNow(),DateUtil.STR_YEARMONTHDAY)); + ncTxt.setOrigFileName(info.getDocName()); + ncTxt.setOrigFileSuffix(info.getDocSuffix()); + ncTxt.setFileAddOrDelete(2); +// String loFilePath = localFilePath + "\\" + ncTxt.getFileTxtName() + ".nc"; +// try { +// /* ObjectMapper mapper = new ObjectMapper(); +// String json = mapper.writeValueAsString(ncTxt);*/ +// String allList = new String(); +// allList=(ncTxt.getFileTxtName()+"\n"); +// allList+=(ncTxt.getFileNcName()+"\n"); +// allList+=(ncTxt.getOrigFileName()+"\n"); +// allList+=(ncTxt.getOrigFileSuffix()+"\n"); +// allList+=(ncTxt.getFilePath()+"\n"); +// allList+=(ncTxt.getEquipmentId()+"\n"); +// allList+=(ncTxt.getFileAddOrDelete().toString()); +// FileUtilS.fileWriterSql(loFilePath,allList); +// }catch (Exception e) { +// return true; +// } + } + } + return b; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public boolean deleteCopyDocByAttrNext(String docId, Integer attrType, String attrId) { + LambdaQueryWrapper<DocRelative> lambdaQueryWrapper = Wrappers.lambdaQuery(); + lambdaQueryWrapper.eq(DocRelative::getDocId, docId); + lambdaQueryWrapper.eq(DocRelative::getAttributionType, attrType); + lambdaQueryWrapper.eq(DocRelative::getAttributionId, attrId); + boolean b = super.remove(lambdaQueryWrapper); + return b; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public List<MdcEquipment> findDeviceByDocId(String docId) { + if(!ValidateUtil.validateString(docId)) + ExceptionCast.cast(CommonCode.INVALID_PARAM); + return super.getBaseMapper().findDeviceByDocId(docId); + } +} -- Gitblit v1.9.3