Browse Source

Merge remote-tracking branch 'origin/master'

master
qiezi 1 year ago
parent
commit
b202d8d3f4
  1. 48
      src/main/java/com/spring/modules/part/controller/PartInformationController.java
  2. 11
      src/main/java/com/spring/modules/part/mapper/PartInformationMapper.java
  3. 17
      src/main/java/com/spring/modules/part/service/PartInformationService.java
  4. 159
      src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java
  5. 34
      src/main/resources/mapper/part/PartInformationMapper.xml

48
src/main/java/com/spring/modules/part/controller/PartInformationController.java

@ -9,6 +9,7 @@ import com.spring.modules.base.data.PlmPropertiesModelHeaderData;
import com.spring.modules.change.vo.ChangeRequestVo;
import com.spring.modules.customer.entity.CustomerGroupInformationEntity;
import com.spring.modules.customer.vo.CustomerInformationVo;
import com.spring.modules.oss.entity.SysOssEntity;
import com.spring.modules.part.entity.*;
import com.spring.modules.part.service.PartInformationService;
import com.spring.modules.part.vo.*;
@ -16,9 +17,13 @@ import com.spring.modules.project.data.PlmProjectInfoData;
import com.spring.modules.project.data.PlmProjectPartData;
import com.spring.modules.quotation.entity.QuotationInformationEntity;
import com.spring.modules.quotation.vo.QuotationInformationVo;
import com.spring.modules.sys.entity.GetParamInData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
@ -306,9 +311,10 @@ public class PartInformationController {
* 查询库位列表
*/
@PostMapping("/getLocationList")
public R getLocationList(@RequestBody PartInformationEntity data) {
public R getLocationList(@RequestBody LocationInformationVo data) {
// 获取当前物料不包含的库位
List<LocationInformationEntity> row1 = partInformationService.getLocationList1(data);
//PageUtils row1 = partInformationService.getLocationList1(data);
PageUtils row1 = partInformationService.getLocationListBy(data);
// 获取当前物料所包含的库位
List<LocationInformationEntity> row2 = partInformationService.getLocationList2(data);
return R.ok().put("row1", row1).put("row2", row2);
@ -321,8 +327,8 @@ public class PartInformationController {
*/
@PostMapping("getLocationListBy")
public R getLocationListBy(@RequestBody LocationInformationVo data) {
List<LocationInformationEntity> rows = partInformationService.getLocationListBy(data);
return R.ok().put("rows", rows);
PageUtils page = partInformationService.getLocationListBy(data);
return R.ok().put("page", page);
}
/**
@ -666,4 +672,38 @@ public class PartInformationController {
List<PartInformationEntity> list = partInformationService.queryPart(data);
return R.ok().put("rows", list);
}
/**
* 项目物料Excel导入
* @param file
* @param data
* @return
*/
@PostMapping("/uploadProjectPartExcel")
public R uploadProjectPartExcel(@RequestParam(value = "file") MultipartFile file, @ModelAttribute GetParamInData data){
partInformationService.uploadProjectPartExcel(file, data);
return R.ok();
}
/**
* 查询文件ID
* @param data
* @return
*/
@PostMapping("/queryFileId")
public R queryFileId(@RequestBody SysOssEntity data){
SysOssEntity sysOss = partInformationService.queryFileId(data);
return R.ok().put("data",sysOss);
}
/**
* 下载文件
* @param id
* @param response
* @throws UnsupportedEncodingException
*/
@PostMapping(value = "/downLoadFile")
public void downLoadFile(@RequestParam("id") Integer id, HttpServletResponse response) throws UnsupportedEncodingException {
partInformationService.downLoadObjectFile(id,response);
}
}

11
src/main/java/com/spring/modules/part/mapper/PartInformationMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spring.modules.base.data.*;
import com.spring.modules.change.entity.TechnicalSpecificationData;
import com.spring.modules.change.vo.ChangeRequestVo;
import com.spring.modules.oss.entity.SysOssEntity;
import com.spring.modules.part.entity.*;
@ -91,11 +92,11 @@ public interface PartInformationMapper extends BaseMapper<PartInformationEntity>
List<PartSubPropertiesValueData> queryCodeNo(PartInformationEntity data);
List<LocationInformationEntity> getLocationList1(PartInformationEntity data);
IPage<LocationInformationEntity> getLocationList1(Page<PartInformationEntity> technicalSpecificationDataPage, @Param("query") PartInformationEntity data);
List<LocationInformationEntity> getLocationList2(PartInformationEntity data);
List<LocationInformationEntity> getLocationList2(LocationInformationVo data);
List<LocationInformationEntity> getLocationListBy(LocationInformationVo data);
IPage<LocationInformationEntity> getLocationListBy(Page<LocationInformationVo> technicalSpecificationDataPage, @Param("query") LocationInformationVo data);
List<LocationInformationVo> getDefaultLocation(LocationInformationVo data);
@ -252,4 +253,8 @@ public interface PartInformationMapper extends BaseMapper<PartInformationEntity>
List<PartInformationEntity> queryPartByPartNo(@Param("site") String site,
@Param("partNo") String partNo,
@Param("partDesc") String partDesc);
List<SysOssEntity> queryFileId(SysOssEntity data);
List<SysOssEntity> getFileData(Integer id);
}

17
src/main/java/com/spring/modules/part/service/PartInformationService.java

@ -6,10 +6,15 @@ import com.spring.modules.base.data.PlmPropertiesItemData;
import com.spring.modules.base.data.PlmPropertiesModelDetailData;
import com.spring.modules.base.data.PlmPropertiesModelHeaderData;
import com.spring.modules.change.vo.ChangeRequestVo;
import com.spring.modules.oss.entity.SysOssEntity;
import com.spring.modules.part.entity.*;
import com.spring.modules.part.vo.*;
import com.spring.modules.project.data.PlmProjectPartData;
import com.spring.modules.sys.entity.GetParamInData;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
@ -73,11 +78,11 @@ public interface PartInformationService {
void deletePartItem(PartSubPropertiesValueData inData);
List<LocationInformationEntity> getLocationList1(PartInformationEntity data);
PageUtils getLocationList1(PartInformationEntity data);
List<LocationInformationEntity> getLocationList2(PartInformationEntity data);
List<LocationInformationEntity> getLocationList2(LocationInformationVo data);
List<LocationInformationEntity> getLocationListBy(LocationInformationVo data);
PageUtils getLocationListBy(LocationInformationVo data);
List<LocationInformationVo> getDefaultLocation(LocationInformationVo data);
@ -128,4 +133,10 @@ public interface PartInformationService {
String getNextPartNo(PartInformationVo data);
List<PartInformationEntity> queryPart(PartInformationVo data);
void uploadProjectPartExcel(MultipartFile file, GetParamInData data);
SysOssEntity queryFileId(SysOssEntity data);
void downLoadObjectFile(Integer id, HttpServletResponse response) throws UnsupportedEncodingException;
}

159
src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java

@ -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());
}
}
}

34
src/main/resources/mapper/part/PartInformationMapper.xml

@ -575,12 +575,12 @@
a.update_by,
a.location_type
FROM location as a
left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{partNo}
where a.site = #{site} and b.part_no is null
left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{query.partNo}
where a.site = #{query.site} and b.part_no is null
</select>
<!-- 获取当前物料所包含的库位 -->
<select id="getLocationList2" resultType="LocationInformationEntity" parameterType="PartInformationEntity">
<select id="getLocationList2" resultType="LocationInformationEntity" parameterType="com.spring.modules.part.vo.LocationInformationVo">
SELECT
a.site,
a.location_id,
@ -611,14 +611,14 @@
a.update_by,
a.location_type
FROM location as a
left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{partNo}
left join plm_part_location as b on a.site = b.site and a.location_id = b.location_id and b.part_no = #{query.partNo}
<where>
a.site = #{site} and b.part_no is null
<if test = "locationId != null and locationId != ''">
AND a.location_id LIKE #{locationId}
a.site = #{query.site} and b.part_no is null
<if test = "query.locationId != null and query.locationId != ''">
AND a.location_id LIKE #{query.locationId}
</if>
<if test = "locationName != null and locationName != ''">
AND a.location_name LIKE #{locationName}
<if test = "query.locationName != null and query.locationName != ''">
AND a.location_name LIKE #{query.locationName}
</if>
</where>
</select>
@ -1790,4 +1790,20 @@
and part_desc like #{partDesc}
</if>
</select>
<!-- 查询文件ID -->
<select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
SELECT id, file_name
FROM sys_oss
WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
</select>
<select id="getFileData" resultType="SysOssEntity">
select
url,
file_name,
new_file_name
from sys_oss
where id = #{id}
</select>
</mapper>
Loading…
Cancel
Save