|
|
|
@ -17,6 +17,7 @@ import com.spring.modules.base.service.TransNoControlService; |
|
|
|
import com.spring.modules.base.utils.DataUtils; |
|
|
|
import com.spring.modules.base.utils.HttpClientUtil; |
|
|
|
import com.spring.modules.base.utils.ResponseData; |
|
|
|
import com.spring.modules.change.entity.TechnicalSpecificationData; |
|
|
|
import com.spring.modules.change.vo.ChangeRequestVo; |
|
|
|
import com.spring.modules.customer.entity.CustomerGroupInformationEntity; |
|
|
|
import com.spring.modules.oss.dao.SysOssDao; |
|
|
|
@ -35,13 +36,22 @@ import com.spring.modules.part.service.PartInformationService; |
|
|
|
import com.spring.modules.part.vo.*; |
|
|
|
import com.spring.modules.project.data.PlmProjectPartData; |
|
|
|
import com.spring.modules.report.dao.ProcedureDao; |
|
|
|
import com.spring.modules.sys.entity.GetParamInData; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.*; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -1064,21 +1074,21 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<LocationInformationEntity> getLocationList1(PartInformationEntity data) { |
|
|
|
List<LocationInformationEntity> list = partInformationMapper.getLocationList1(data); |
|
|
|
return list; |
|
|
|
public PageUtils getLocationList1(PartInformationEntity data) { |
|
|
|
IPage<LocationInformationEntity> resultList = this.partInformationMapper.getLocationList1(new Page<PartInformationEntity>(data.getPage(), data.getLimit()), data); |
|
|
|
return new PageUtils(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<LocationInformationEntity> getLocationList2(PartInformationEntity data) { |
|
|
|
public List<LocationInformationEntity> getLocationList2(LocationInformationVo data) { |
|
|
|
List<LocationInformationEntity> list = partInformationMapper.getLocationList2(data); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<LocationInformationEntity> getLocationListBy(LocationInformationVo data) { |
|
|
|
List<LocationInformationEntity> list = partInformationMapper.getLocationListBy(data); |
|
|
|
return list; |
|
|
|
public PageUtils getLocationListBy(LocationInformationVo data) { |
|
|
|
IPage<LocationInformationEntity> resultList = this.partInformationMapper.getLocationListBy(new Page<LocationInformationVo>(data.getPage(), data.getLimit()), data); |
|
|
|
return new PageUtils(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -2292,4 +2302,139 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
public List<PartInformationEntity> queryPart(PartInformationVo data) { |
|
|
|
return baseMapper.queryPart(data); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目物料Excel导入 |
|
|
|
* @param file |
|
|
|
* @param data |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void uploadProjectPartExcel(MultipartFile file, GetParamInData data) { |
|
|
|
try{ |
|
|
|
// 转流 |
|
|
|
InputStream is = file.getInputStream(); |
|
|
|
// 读取工作簿 |
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(is); |
|
|
|
// 读取工作表 |
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0); |
|
|
|
// 获取行数 |
|
|
|
int rows = sheet.getPhysicalNumberOfRows(); |
|
|
|
// 声明对象 |
|
|
|
PartInformationEntity task = null; |
|
|
|
// 遍历每一行(从第二行开始) |
|
|
|
for (int j = 1; j < rows; j++) { |
|
|
|
// 实例化对象 |
|
|
|
task = new PartInformationEntity(); |
|
|
|
//获得该行 |
|
|
|
XSSFRow row = sheet.getRow(j); |
|
|
|
// 为对象赋值 |
|
|
|
task.setSite(data.getOrderRef1()); // site |
|
|
|
task.setProjectId(data.getOrderRef2()); // 项目编码 |
|
|
|
task.setCustomerNo(data.getOrderRef3()); // 客户编码 |
|
|
|
String no = transNoControlService.transNo(data.getOrderRef1(), "project_part_no"); |
|
|
|
if (no == null) { |
|
|
|
throw new RuntimeException("请维护编码生成规则(TransNoControl)!"); |
|
|
|
} |
|
|
|
task.setPartNo(no + "A01"); // 物料编码 |
|
|
|
task.setBuNo(row.getCell(0).getStringCellValue()); // BU |
|
|
|
task.setPartDesc(row.getCell(1).getStringCellValue()); // 物料描述 |
|
|
|
task.setCustomerPartNo(row.getCell(2).getStringCellValue()); // 客户料号 |
|
|
|
task.setPartType(row.getCell(3).getStringCellValue()); // 零件类型 |
|
|
|
task.setProductGroupId4(row.getCell(4).getStringCellValue()); // 计划人 |
|
|
|
task.setUmId(row.getCell(5).getStringCellValue()); // 计量单位 |
|
|
|
task.setCodeNo(row.getCell(6).getStringCellValue()); // 属性模板 |
|
|
|
task.setUomForWeightNet("kg"); |
|
|
|
task.setUomForVolumeNet("m3"); |
|
|
|
task.setActive("Y"); |
|
|
|
task.setLotTrackingCode("Order Based"); |
|
|
|
task.setCreateBy(data.getCreateBy()); |
|
|
|
task.setAssetClass("S"); |
|
|
|
task.setAbcClass("C"); |
|
|
|
task.setFrequencyClass("Very Slow Mover"); |
|
|
|
task.setLifecycleStage("Development"); |
|
|
|
task.setStatus("N"); |
|
|
|
task.setPartStatus("A"); |
|
|
|
task.setConfigurationId("*"); |
|
|
|
task.setInventoryValuationMethod("Standard Cost"); |
|
|
|
task.setInventoryPartCostLevel("Cost Per Part"); |
|
|
|
task.setInvoiceConsideration("Ignore Invoice Price"); |
|
|
|
task.setZeroCostFlag("Zero Cost Forbidden"); |
|
|
|
task.setBackFlushPart("All Locations"); |
|
|
|
task.setIssueType("Reserve And Backflush"); |
|
|
|
task.setMrpControlFlagDb("Y"); |
|
|
|
task.setOverReporting("Allowed"); |
|
|
|
|
|
|
|
// 调用新增方法 |
|
|
|
partInformationSave2(task); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException("导入失败:"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询文件ID |
|
|
|
* @param data |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public SysOssEntity queryFileId(SysOssEntity data) { |
|
|
|
List<SysOssEntity> list = partInformationMapper.queryFileId(data); |
|
|
|
if (list.isEmpty()) { |
|
|
|
throw new RuntimeException("未查到该文件ID,请检查数据!"); |
|
|
|
} |
|
|
|
return list.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 下载文件 |
|
|
|
* @param id |
|
|
|
* @param response |
|
|
|
* @throws UnsupportedEncodingException |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void downLoadObjectFile(Integer id, HttpServletResponse response) throws UnsupportedEncodingException { |
|
|
|
// 处理路径和名称 |
|
|
|
List<SysOssEntity> getFileData = partInformationMapper.getFileData(id); |
|
|
|
if (getFileData.isEmpty()) { |
|
|
|
throw new RuntimeException("该文件不存在,请刷新列表"); |
|
|
|
} |
|
|
|
File file = new File(getFileData.get(0).getUrl()); |
|
|
|
//读取缓存1kb |
|
|
|
byte[] buffer = new byte[1024]; |
|
|
|
FileInputStream fis = null; |
|
|
|
BufferedInputStream bis = null; |
|
|
|
FileOutputStream fos = null; |
|
|
|
BufferedOutputStream bos = null; |
|
|
|
response.setContentType("application/force-download;charset=utf-8"); |
|
|
|
response.setHeader("Content-disposition", "attachment; filename=" + new String(getFileData.get(0).getFileName().getBytes("gbk"), "iso8859-1")); |
|
|
|
try { |
|
|
|
//读取文件 |
|
|
|
fis = new FileInputStream(file); |
|
|
|
//加缓存 |
|
|
|
bis = new BufferedInputStream(fis); |
|
|
|
//开始读取 |
|
|
|
int i = bis.read(buffer); |
|
|
|
//设置输出流 |
|
|
|
ServletOutputStream os = response.getOutputStream(); |
|
|
|
//开始循环读取 |
|
|
|
while (i != -1) { |
|
|
|
os.write(buffer, 0, i); |
|
|
|
i = bis.read(buffer); |
|
|
|
} |
|
|
|
fis.close(); |
|
|
|
fos.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|