Просмотр исходного кода

产品批量导入模版修改,增加物料规格填写栏。修改已存在物料更新方法

dongbw 8 лет назад
Родитель
Сommit
ddbd249132

+ 38 - 18
src/main/java/com/uas/platform/b2b/service/impl/BaseInfoServiceImpl.java

@@ -160,10 +160,16 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 						product.setTitle(row.getCell(1).getStringCellValue().trim());
 					}
 
-					// 原厂型号
+					// 物料规格
 					if (row.getCell(2) != null) {
 						row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
-						product.setCmpCode(row.getCell(2).getStringCellValue().trim());
+						product.setSpec(row.getCell(2).getStringCellValue().trim());
+					}
+
+					// 原厂型号
+					if (row.getCell(3) != null) {
+						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
+						product.setCmpCode(row.getCell(3).getStringCellValue().trim());
 						if (product.getCode() == null) {
 							// 生成随机物料编码
 							SimpleDateFormat sdf = new SimpleDateFormat("mmsssss");
@@ -173,47 +179,49 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 					}
 
 					// 品牌
-					if (row.getCell(3) != null) {
-						row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
-						product.setBrand(row.getCell(3).getStringCellValue().trim());
-					}
-
-					// 单位
 					if (row.getCell(4) != null) {
 						row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
-						product.setUnit(row.getCell(4).getStringCellValue().trim());
+						product.setBrand(row.getCell(4).getStringCellValue().trim());
 					}
 
-					// 最小包装量
+					// 单位
 					if (row.getCell(5) != null) {
 						row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(5).getStringCellValue()
 								&& !row.getCell(5).getStringCellValue().trim().equals("")) {
-							product.setMinPack(Double.valueOf(row.getCell(5).getStringCellValue()));
+							product.setUnit(row.getCell(5).getStringCellValue());
 						}
 					}
-					// 最小订购
+					// 最小包装
 					if (row.getCell(6) != null) {
 						row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(6).getStringCellValue().trim()
 								&& !row.getCell(6).getStringCellValue().trim().equals("")) {
-							product.setMinOrder(Double.valueOf(row.getCell(6).getStringCellValue()));
+							product.setMinPack(Double.valueOf(row.getCell(6).getStringCellValue()));
 						}
 					}
-					// 交货周期
+					// 最小订购量
 					if (row.getCell(7) != null) {
 						row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(7).getStringCellValue().trim()
 								&& !row.getCell(7).getStringCellValue().trim().equals("")) {
-							product.setLeadtime(Double.valueOf(row.getCell(7).getStringCellValue()));
+							product.setMinOrder(Double.valueOf(row.getCell(7).getStringCellValue()));
 						}
 					}
-					// 交货提前
+					// 交货
 					if (row.getCell(8) != null) {
 						row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
 						if (null != row.getCell(8).getStringCellValue().trim()
 								&& !row.getCell(8).getStringCellValue().trim().equals("")) {
-							product.setLtinstock(Double.valueOf(row.getCell(8).getStringCellValue()));
+							product.setLeadtime(Double.valueOf(row.getCell(8).getStringCellValue()));
+						}
+					}
+					// 交货提前期
+					if (row.getCell(9) != null) {
+						row.getCell(9).setCellType(Cell.CELL_TYPE_STRING);
+						if (null != row.getCell(9).getStringCellValue().trim()
+								&& !row.getCell(9).getStringCellValue().trim().equals("")) {
+							product.setLtinstock(Double.valueOf(row.getCell(9).getStringCellValue()));
 						}
 					}
 					// 判断是否存在
@@ -222,7 +230,19 @@ public class BaseInfoServiceImpl implements BaseInfoService {
 					if (!CollectionUtils.isEmpty(prods)) {
 						// 如果存在且不是ERP传来的物料,允许修改
 						if (!"ERP".equals(prods.get(0).getSourceApp())) {
-							product.setId(prods.get(0).getId());
+							Product temp = new Product();
+							BeanUtils.copyProperties(prods.get(0), temp);
+							temp.setCode(product.getCode());
+							temp.setTitle(product.getTitle());
+							temp.setSpec(product.getSpec());
+							temp.setCmpCode(product.getCmpCode());
+							temp.setBrand(product.getBrand());
+							temp.setUnit(product.getUnit());
+							temp.setMinPack(product.getMinPack());
+							temp.setMinOrder(product.getMinOrder());
+							temp.setLeadtime(product.getLeadtime());
+							temp.setLtinstock(product.getLtinstock());
+							BeanUtils.copyProperties(temp, product);
 							alters.add(product.getCode());
 						} else {
 							// ERP上传的物料不更新

+ 4 - 4
src/main/java/com/uas/platform/b2b/service/impl/ProductServiceImpl.java

@@ -181,10 +181,10 @@ public class ProductServiceImpl implements ProductService {
 		if (null != param.getOldvalue()) {
 			if (param.getUpdatetype().equals(UpdateType.BRANDUPDATE.getPhrase())) {
 				List<Product> products = new ArrayList<Product>();
-				if (param.getType().equals(UpdateType.sale)) {
+				if (param.getType().equals(UpdateType.sale.getPhrase())) {
 					products = productDao.findByEnUUAndBrandAndIsSale(SystemSession.getUser().getEnterprise().getUu(), param.getOldvalue(),
 							Constant.YES);
-				} else if (param.getType().equals(UpdateType.purchase)) {
+				} else if (param.getType().equals(UpdateType.purchase.getPhrase())) {
 					products = productDao.findByEnUUAndBrandAndIsPurchase(SystemSession.getUser().getEnterprise().getUu(),
 							param.getOldvalue(), Constant.YES);
 				} else {
@@ -203,10 +203,10 @@ public class ProductServiceImpl implements ProductService {
 
 			} else if (param.getUpdatetype().equals(UpdateType.TITLEUPDATE.getPhrase())) {
 				List<Product> products = new ArrayList<Product>();
-				if (param.getType().equals(UpdateType.sale)) {
+				if (param.getType().equals(UpdateType.sale.getPhrase())) {
 					products = productDao.findByEnUUAndTitleAndIsSale(SystemSession.getUser().getEnterprise().getUu(), param.getOldvalue(),
 							Constant.YES);
-				} else if (param.getType().equals(UpdateType.purchase)) {
+				} else if (param.getType().equals(UpdateType.purchase.getPhrase())) {
 					products = productDao.findByEnUUAndTitleAndIsPurchase(SystemSession.getUser().getEnterprise().getUu(),
 							param.getOldvalue(), Constant.YES);
 				} else {

BIN
src/main/resources/jxls-tpl/baseInfo/baseInfo_prod_example.xls