|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
+import com.management.platform.service.ExcelExportService;
|
|
|
import com.management.platform.service.ProdMaterialService;
|
|
|
import com.management.platform.service.ProdProcedureService;
|
|
|
import com.management.platform.service.ProductService;
|
|
@@ -15,7 +16,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
|
-import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
@@ -23,7 +23,6 @@ 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.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -46,8 +45,8 @@ import java.util.*;
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
|
|
|
- /*@Value(value = "${upload.path}")
|
|
|
- private String path;*/
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String path;
|
|
|
@Resource
|
|
|
ProductMapper productMapper;
|
|
|
@Resource
|
|
@@ -64,7 +63,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
PlanMapper planMapper;
|
|
|
@Resource
|
|
|
ProdCategoryMapper prodCategoryMapper;
|
|
|
+ @Resource
|
|
|
+ WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ExcelExportService excelExportService;
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg getProductPage(Integer cateId, Integer pageIndex, Integer pageSize, String name, String code, HttpServletRequest request) {
|
|
@@ -104,11 +107,13 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
User user = userMapper.selectById(token);
|
|
|
|
|
|
product.setCompanyId(user.getCompanyId());
|
|
|
+
|
|
|
+ Integer count = productMapper.selectCount(new LambdaQueryWrapper<Product>()
|
|
|
+ .eq(user.getCompanyId() != null, Product::getCompanyId, user.getCompanyId())
|
|
|
+ .eq(!StringUtils.isEmpty(product.getName()), Product::getName, product.getName())
|
|
|
+ );
|
|
|
if (product.getId() == null) {
|
|
|
- Integer count = productMapper.selectCount(new LambdaQueryWrapper<Product>()
|
|
|
- .eq(user.getCompanyId() != null, Product::getCompanyId, user.getCompanyId())
|
|
|
- .eq(!StringUtils.isEmpty(product.getName()), Product::getName, product.getName())
|
|
|
- );
|
|
|
+ //新增
|
|
|
if(count==0){
|
|
|
productMapper.insert(product);
|
|
|
|
|
@@ -116,12 +121,18 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
msg.setError("产品名重复");
|
|
|
}
|
|
|
} else {
|
|
|
- Product selectOne = productMapper.selectOne(new LambdaQueryWrapper<Product>()
|
|
|
- .eq(user.getCompanyId() != null, Product::getCompanyId, user.getCompanyId())
|
|
|
- .eq(!StringUtils.isEmpty(product.getName()), Product::getName, product.getName())
|
|
|
- );
|
|
|
- if(selectOne.getId()==product.getId()){
|
|
|
+ //修改
|
|
|
+ if(count<2){
|
|
|
productMapper.updateById(product);
|
|
|
+
|
|
|
+ //修改对应工序中产品的名字
|
|
|
+ ProdProcedure prodProcedure=new ProdProcedure();
|
|
|
+ prodProcedure.setProductName(product.getName());
|
|
|
+ prodProcedureService.update(prodProcedure,
|
|
|
+ new LambdaQueryWrapper<ProdProcedure>()
|
|
|
+ .eq(product.getId()!=null,ProdProcedure::getProductId,product.getId())
|
|
|
+ .eq(user.getCompanyId() != null, ProdProcedure::getCompanyId, user.getCompanyId())
|
|
|
+ );
|
|
|
}else{
|
|
|
msg.setError("产品名重复");
|
|
|
}
|
|
@@ -258,7 +269,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
unitCell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
if(groupNumberCell!=null){
|
|
|
- groupNumberCell.setCellType(CellType.NUMERIC);
|
|
|
+ groupNumberCell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
if(columnNumberCell!=null){
|
|
|
columnNumberCell.setCellType(CellType.NUMERIC);
|
|
@@ -312,7 +323,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
return msg;
|
|
|
}
|
|
|
if(groupNumberCell!=null){
|
|
|
- product.setGroupNumber((int) Math.round(groupNumberCell.getNumericCellValue()));
|
|
|
+ product.setGroupNumber(groupNumberCell.getStringCellValue());
|
|
|
}else{
|
|
|
msg.setError("编组不能为空");
|
|
|
return msg;
|
|
@@ -387,7 +398,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
msg.setError("工序名称不能为空");
|
|
|
}
|
|
|
if(workingTimeCell!=null){
|
|
|
- prodProcedure.setWorkingTime((int) Math.round(workingTimeCell.getNumericCellValue()));
|
|
|
+ prodProcedure.setWorkingTime(workingTimeCell.getNumericCellValue());
|
|
|
|
|
|
}else{
|
|
|
msg.setError("单件工时不能为空");
|
|
@@ -415,6 +426,16 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
//检查同一版本的同一版本号工序中有没有重复的
|
|
|
for (ProdProcedure prodProcedure : prodProcedureList) {
|
|
|
|
|
|
+ if(prodProcedureList.stream().filter(procedure ->{
|
|
|
+ return prodProcedure.getName().equals(procedure.getName())&&!prodProcedure.getVersionNumber().equals(procedure.getVersionNumber());
|
|
|
+ } ).count()>0){
|
|
|
+ msg.setError("一个产品只能导入一个产品号");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
long count = prodProcedureList.stream()
|
|
|
.filter(procedure -> procedure.getProductName().equals(prodProcedure.getProductName()) && procedure.getVersionNumber().equals(prodProcedure.getVersionNumber()) && procedure.getName().equals(prodProcedure.getName()))
|
|
|
.count();
|
|
@@ -480,7 +501,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
+/* @Override
|
|
|
public HttpRespMsg exportData(String date, Integer productType) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
|
@@ -598,9 +619,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
- //导出excel
|
|
|
+ *//* //导出excel
|
|
|
String result="系统提示:Excel文件导出成功!";
|
|
|
-
|
|
|
+ //生成Excel文件
|
|
|
+ String fileUrlSuffix = "产品详情"+System.currentTimeMillis();
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileUrlSuffix,dataList,path);*//*
|
|
|
+//
|
|
|
String title= "产品详情"+System.currentTimeMillis();
|
|
|
String fileName= title+".xlsx";
|
|
|
String path="D://cloud/upload/";
|
|
@@ -619,10 +643,90 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- msg.data ="/upload/"+fileName;
|
|
|
+// msg.data ="/upload/"+fileName;
|
|
|
|
|
|
}
|
|
|
return msg;
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportData(String date, Integer productType, HttpServletRequest request) {
|
|
|
+ List<Integer> productIdList =Arrays.asList( JSONObject.parseObject(date, Integer[].class));
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
+ if(productIdList!=null&&productIdList.size()>0) {
|
|
|
+
|
|
|
+ //获取数据
|
|
|
+ List<Product> productList = productMapper.selectBatchIds(productIdList);
|
|
|
+ List<ProdProcedure> prodProcedureList = prodProcedureMapper.selectList(new LambdaQueryWrapper<ProdProcedure>().in(ProdProcedure::getProductId, productIdList));
|
|
|
+
|
|
|
+ List<List<String>> dataProductList = new ArrayList<>();
|
|
|
+ List<String> titleProductList = new ArrayList<>();
|
|
|
+ titleProductList.add("产品名称");
|
|
|
+ titleProductList.add("项目代码");
|
|
|
+ titleProductList.add("订单数量");
|
|
|
+ titleProductList.add("单位");
|
|
|
+ titleProductList.add("编组");
|
|
|
+ titleProductList.add("每列数量");
|
|
|
+ titleProductList.add("每辆数量");
|
|
|
+ titleProductList.add("描述");
|
|
|
+
|
|
|
+ dataProductList.add(titleProductList);
|
|
|
+ for (Product product : productList) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ item.add(product.getName());
|
|
|
+ item.add(product.getCode());
|
|
|
+ item.add(product.getOrderNumber().toString());
|
|
|
+ item.add(product.getUnit());
|
|
|
+ item.add(product.getGroupNumber());
|
|
|
+ item.add(product.getColumnNumber().toString());
|
|
|
+ item.add(product.getVehicleNumber().toString());
|
|
|
+ item.add(product.getDescription());
|
|
|
+
|
|
|
+ dataProductList.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<List<String>> dataProcedureList = new ArrayList<>();
|
|
|
+ List<String> titleProcedureList = new ArrayList<>();
|
|
|
+ titleProcedureList.add("产品名称");
|
|
|
+ titleProcedureList.add("版本号");
|
|
|
+ titleProcedureList.add("工序名称");
|
|
|
+ titleProcedureList.add("单件工时");
|
|
|
+ titleProcedureList.add("单件工价");
|
|
|
+ titleProcedureList.add("质检类型");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ dataProcedureList.add(titleProcedureList);
|
|
|
+ for (ProdProcedure prodProcedure : prodProcedureList) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ item.add(prodProcedure.getProductName());
|
|
|
+ item.add(prodProcedure.getVersionNumber());
|
|
|
+ item.add(prodProcedure.getName());
|
|
|
+ item.add(prodProcedure.getWorkingTime().toString());
|
|
|
+ item.add(prodProcedure.getUnitPrice().toString());
|
|
|
+
|
|
|
+ switch (prodProcedure.getCheckType()){
|
|
|
+ case 0: item.add("自检");break;
|
|
|
+ case 1: item.add("互检");break;
|
|
|
+ case 2: item.add("专检");break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* //导出excel
|
|
|
+ String result="系统提示:Excel文件导出成功!";
|
|
|
+ //生成Excel文件
|
|
|
+ String fileName = "产品详情"+System.currentTimeMillis();
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);*/
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|