上传文件至 'op-modules/op-sap/src/main/java/com/op/sap/service/impl'

highway
zhaoxl 1 year ago
parent 8f8a7b479e
commit d22b40f91f

@ -0,0 +1,110 @@
package com.op.sap.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.utils.DateUtils;
import com.op.sap.domain.SapBaseFile;
import com.op.sap.mapper.SapBaseFileMapper;
import com.op.sap.service.SapBaseFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author Open Platform
* @date 2023-07-10
*/
@Service
public class SapBaseFileServiceImpl implements SapBaseFileService {
@Autowired
private SapBaseFileMapper baseFileMapper;
/**
*
*
* @param fileId
* @return
*/
@Override
@DS("#header.poolName")
public SapBaseFile selectBaseFileByFileId(String fileId) {
return baseFileMapper.selectBaseFileByFileId(fileId);
}
/**
*
*
* @param baseFile
* @return
*/
@Override
@DS("#header.poolName")
public List<SapBaseFile> selectBaseFileList(SapBaseFile baseFile) {
return baseFileMapper.selectBaseFileList(baseFile);
}
/**
*
*
* @param baseFile
* @return
*/
@Override
@DS("#header.poolName")
public int insertBaseFile(SapBaseFile baseFile) {
baseFile.setCreateTime(DateUtils.getNowDate());
return baseFileMapper.insertBaseFile(baseFile);
}
/**
*
*
* @param baseFile
* @return
*/
@Override
@DS("#header.poolName")
public int updateBaseFile(SapBaseFile baseFile) {
baseFile.setUpdateTime(DateUtils.getNowDate());
return baseFileMapper.updateBaseFile(baseFile);
}
/**
*
*
* @param fileIds
* @return
*/
@Override
@DS("#header.poolName")
public int deleteBaseFileByFileIds(String[] fileIds) {
return baseFileMapper.deleteBaseFileByFileIds(fileIds);
}
/**
*
*
* @param fileId
* @return
*/
@Override
@DS("#header.poolName")
public int deleteBaseFileByFileId(String fileId) {
return baseFileMapper.deleteBaseFileByFileId(fileId);
}
/**
*
*
* @param baseFiles
* @return
*/
@Override
@DS("#header.poolName")
public Boolean insertBaseFileBatch(List<BaseFileData> baseFiles) {
return baseFileMapper.insertBaseFileBatch(baseFiles);
}
}

@ -0,0 +1,118 @@
package com.op.sap.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.sap.domain.SapBaseProduct;
import com.op.sap.domain.SapConn;
import com.op.sap.mapper.SapBaseProductMapper;
import com.op.sap.service.ISapBaseProductService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.RemotePlanService;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* Service
*
* @author Open Platform
* @date 2023-07-18
*/
@Service
public class SapBaseProductServiceImpl implements ISapBaseProductService {
@Autowired
private SapBaseProductMapper baseProductMapper;
/**
*
*
* @param productId
* @return
*/
@Override
@DS("#header.poolName")
public SapBaseProduct selectBaseProductByProductId(String productId) {
return baseProductMapper.selectBaseProductByProductId(productId);
}
/**
*
*
* @param baseProduct
* @return
*/
@Override
@DS("#header.poolName")
public List<SapBaseProduct> selectBaseProductList(SapBaseProduct baseProduct) {
return baseProductMapper.selectBaseProductList(baseProduct);
}
/**
*
*
* @param baseProduct
* @return
*/
@Override
@DS("#header.poolName")
public int insertBaseProduct(SapBaseProduct baseProduct) {
baseProduct.setCreateTime(DateUtils.getNowDate());
baseProduct.setCreateBy(SecurityUtils.getUsername());
return baseProductMapper.insertBaseProduct(baseProduct);
}
/**
*
*
* @param baseProduct
* @return
*/
@Override
@DS("#header.poolName")
public int updateBaseProduct(SapBaseProduct baseProduct) {
baseProduct.setUpdateTime(DateUtils.getNowDate());
baseProduct.setUpdateBy(SecurityUtils.getUsername());
return baseProductMapper.updateBaseProduct(baseProduct);
}
/**
*
*
* @param productIds
* @return
*/
@Override
@DS("#header.poolName")
public int deleteBaseProductByProductIds(String[] productIds) {
return baseProductMapper.deleteBaseProductByProductIds(productIds);
}
/**
*
*
* @param productId
* @return
*/
@Override
@DS("#header.poolName")
public int deleteBaseProductByProductId(String productId) {
return baseProductMapper.deleteBaseProductByProductId(productId);
}
@Override
public String selectBaseProductIDByProductCode(String productCode) {
return baseProductMapper.selectBaseProductIDByProductCode(productCode);
}
}

@ -0,0 +1,132 @@
package com.op.sap.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.sap.domain.SapProRouteProduct;
import com.op.sap.mapper.SapProRouteProductMapper;
import com.op.sap.service.SapProRouteProductService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 线Service
*
* @author Open Platform
* @date 2023-07-13
*/
@Service
public class SapProRouteProductServiceImpl implements SapProRouteProductService {
@Autowired
private SapProRouteProductMapper proRouteProductMapper;
/**
* 线
*
* @param recordId 线
* @return 线
*/
@Override
@DS("#header.poolName")
public SapProRouteProduct selectProRouteProductByRecordId(String recordId) {
return proRouteProductMapper.selectProRouteProductByRecordId(recordId);
}
/**
* 线
*
* @param proRouteProduct 线
* @return 线
*/
@Override
@DS("#header.poolName")
public List<SapProRouteProduct> selectProRouteProductList(SapProRouteProduct proRouteProduct) {
return proRouteProductMapper.selectProRouteProductList(proRouteProduct);
}
/**
* 线
*
* @param proRouteProduct 线
* @return
*/
@Override
@DS("#header.poolName")
public int insertProRouteProduct(SapProRouteProduct proRouteProduct) {
Date now = DateUtils.getNowDate();
if(StringUtils.isNotBlank(proRouteProduct.getRouteId())){
//删除之前的关联关系
proRouteProductMapper.deleteByRouteId(proRouteProduct);
}
if(proRouteProduct.getSelectedValues()!=null){
SapProRouteProduct proRouteProductDto =null;
for(String ProductCode:proRouteProduct.getSelectedValues()){
//查询物料编码对应的各种信息
proRouteProductDto = new SapProRouteProduct();
proRouteProductDto.setRecordId(IdUtils.fastSimpleUUID());
proRouteProductDto.setCreateTime(now);
proRouteProductDto.setCreateBy(SecurityUtils.getUsername());
proRouteProductDto.setRouteId(proRouteProduct.getRouteId());
proRouteProductDto.setItemId(proRouteProduct.getItemId());
proRouteProductDto.setItemCode(ProductCode);
proRouteProductDto.setItemName(proRouteProduct.getItemName());
proRouteProductMapper.insertProRouteProduct(proRouteProductDto);
}
}
//新增关联关系
return 1;
}
/**
* 线
*
* @param proRouteProduct 线
* @return
*/
@Override
@DS("#header.poolName")
public int updateProRouteProduct(SapProRouteProduct proRouteProduct) {
proRouteProduct.setUpdateTime(DateUtils.getNowDate());
return proRouteProductMapper.updateProRouteProduct(proRouteProduct);
}
/**
* 线
*
* @param recordIds 线
* @return
*/
@Override
@DS("#header.poolName")
public int deleteProRouteProductByRecordIds(String[] recordIds) {
return proRouteProductMapper.deleteProRouteProductByRecordIds(recordIds);
}
/**
* 线
*
* @param recordId 线
* @return
*/
@Override
@DS("#header.poolName")
public int deleteProRouteProductByRecordId(String recordId) {
return proRouteProductMapper.deleteProRouteProductByRecordId(recordId);
}
@Override
@DS("#header.poolName")
public SapProRouteProduct getList(SapProRouteProduct proRouteProduct) {
SapProRouteProduct dto = new SapProRouteProduct();
List<SapProRouteProduct> unSelected = proRouteProductMapper.getRouteProdProductListUndo(proRouteProduct);
dto.setUnSelect(unSelected);
List<SapProRouteProduct> selected= proRouteProductMapper.getRouteProdProductListDo(proRouteProduct);
dto.setSelected(selected);
return dto;
}
}

@ -0,0 +1,209 @@
package com.op.sap.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.constant.UserConstants;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.sap.domain.SapBaseFile;
import com.op.sap.domain.SapProRoute;
import com.op.sap.mapper.SapBaseFileMapper;
import com.op.sap.mapper.SapProRouteMapper;
import com.op.sap.service.SapProRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 线Service
*
* @author yinjinlu
* @date 2022-05-12
*/
@Service
public class SapProRouteServiceImpl implements SapProRouteService {
@Autowired
private SapProRouteMapper proRouteMapper;
@Autowired
private SapBaseFileMapper baseFileMapper;
/**
* 线
*
* @param routeId 线
* @return 线
*/
@Override
@DS("#header.poolName")
public SapProRoute selectProRouteByRouteId(String routeId) {
SapProRoute p = proRouteMapper.selectProRouteByRouteId(routeId);
List<SapBaseFile> files = baseFileMapper.getBaseFileBatch(routeId);
if (!CollectionUtils.isEmpty(files)) {
p.setFiles(files);
}
return p;
}
/**
* 线
*
* @param proRoute 线
* @return 线
*/
@Override
@DS("#header.poolName")
public List<SapProRoute> selectProRouteList(SapProRoute proRoute) {
return proRouteMapper.selectProRouteList(proRoute);
}
@Override
public SapProRoute getRouteByProductId(String itemId) {
return proRouteMapper.getRouteByProductId(itemId);
}
@Override
@DS("#header.poolName")
public Boolean checkRouteCodeUnique(SapProRoute proRoute) {
SapProRoute route = proRouteMapper.checkRouteCodeUnique(proRoute);
String routeId = proRoute.getRouteId();
if (StringUtils.isNotNull(route) && !route.getRouteId().equals(routeId)) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* 线
*
* @param proRoute 线
* @return
*/
@Override
@DS("#header.poolName")
public int insertProRoute(SapProRoute proRoute) {
proRoute.setCreateTime(DateUtils.getNowDate());
proRoute.setRouteVersion("V.1");
//上传附件
if (StringUtils.isNotEmpty(proRoute.getFileList())) {
String[] ids = proRoute.getFileList().split(",");
List<BaseFileData> files = new ArrayList<>();
BaseFileData file = null;
for (String id : ids) {
file = new BaseFileData();
file.setFileId(IdUtils.fastSimpleUUID());
file.setFileName(id.split("&fileName=")[1]);
file.setFileAddress(id);
file.setSourceId(proRoute.getRouteId());
file.setCreateBy(SecurityUtils.getUsername());
file.setCreateTime(new Date());
files.add(file);
}
baseFileMapper.insertBaseFileBatch(files);
}
return proRouteMapper.insertProRoute(proRoute);
}
/**
* 线
*
* @param proRoute 线
* @return
*/
@Override
@DS("#header.poolName")
public int updateProRoute(SapProRoute proRoute) {
proRoute.setUpdateTime(DateUtils.getNowDate());
//上传附件
if (StringUtils.isNotEmpty(proRoute.getFileList())) {
baseFileMapper.deleteBaseFileBySourceId(proRoute.getRouteId());
String[] ids = proRoute.getFileList().split(",");
List<BaseFileData> files = new ArrayList<>();
BaseFileData file = null;
for (String id : ids) {
file = new BaseFileData();
file.setFileId(IdUtils.fastSimpleUUID());
file.setFileAddress(id);
file.setFileName(id.split("&fileName=")[1]);
file.setSourceId(proRoute.getRouteId());
file.setCreateBy(SecurityUtils.getUsername());
file.setCreateTime(new Date());
files.add(file);
}
baseFileMapper.insertBaseFileBatch(files);
}
//更新版本V.1->递增
String nowRouteVersion = proRoute.getRouteVersion().replace("V", "")
.replace(".", "");
int nowRouteVersionNum = Integer.parseInt(nowRouteVersion);
String newRouteVersionNum = "V." + (++nowRouteVersionNum);
proRoute.setRouteVersion(newRouteVersionNum);
return proRouteMapper.updateProRoute(proRoute);
}
/**
* 线
*
* @param routeIds 线
* @return
*/
@Override
@DS("#header.poolName")
public int deleteProRouteByRouteIds(String[] routeIds) {
return proRouteMapper.deleteProRouteByRouteIds(routeIds);
}
/**
* 线
*
* @param routeId 线
* @return
*/
@Override
@DS("#header.poolName")
public int deleteProRouteByRouteId(String routeId) {
return proRouteMapper.deleteProRouteByRouteId(routeId);
}
@Override
@DS("#header.poolName")
public int batchInsertProRoute(SapProRoute proRoute) {
proRoute.setCreateTime(DateUtils.getNowDate());
if (StringUtils.isNotEmpty(proRoute.getFileList())) {
List<String> ids = proRoute.getIdList();
// for (int j = ids.size(); j < 1; j--) {
for (String id :ids) {
String[] f = proRoute.getFileList().split(",");
List<BaseFileData> files = new ArrayList<>();
BaseFileData file = null;
for (String file1 : f) {
file = new BaseFileData();
file.setFileId(IdUtils.fastSimpleUUID());
file.setFileName(file1.split("&fileName=")[1]);
file.setFileAddress(file1);
file.setSourceId(id);
file.setCreateBy(SecurityUtils.getUsername());
file.setCreateTime(new Date());
files.add(file);
}
baseFileMapper.insertBaseFileBatch(files);
}
}
return 1;
}
@Override
public int selectProRrouteByRouteCode(String routeCode) {
return proRouteMapper.selectProRouteByRouteCode(routeCode);
}
}
Loading…
Cancel
Save