|
@@ -9,10 +9,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.jsh.erp.constants.BusinessConstants;
|
|
import com.jsh.erp.constants.BusinessConstants;
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
import com.jsh.erp.constants.ExceptionConstants;
|
|
import com.jsh.erp.datasource.dto.MaterialDTO;
|
|
import com.jsh.erp.datasource.dto.MaterialDTO;
|
|
|
|
+import com.jsh.erp.datasource.dto.MaterialQueryDTO;
|
|
import com.jsh.erp.datasource.entities.*;
|
|
import com.jsh.erp.datasource.entities.*;
|
|
import com.jsh.erp.datasource.mappers.*;
|
|
import com.jsh.erp.datasource.mappers.*;
|
|
import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
|
|
import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
|
|
import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
|
|
import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
|
|
|
|
+import com.jsh.erp.datasource.vo.MaterialAndExtendVo;
|
|
import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
|
|
import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
|
|
import com.jsh.erp.datasource.pda.vo.PDATypeTree;
|
|
import com.jsh.erp.datasource.pda.vo.PDATypeTree;
|
|
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
|
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
|
@@ -107,7 +109,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<Material> getMaterialListByIds(String ids)throws Exception {
|
|
|
|
|
|
+ public List<Material> getMaterialListByIds(String ids) {
|
|
List<Long> idList = StringUtil.strToLongList(ids);
|
|
List<Long> idList = StringUtil.strToLongList(ids);
|
|
List<Material> list = new ArrayList<>();
|
|
List<Material> list = new ArrayList<>();
|
|
try{
|
|
try{
|
|
@@ -139,9 +141,9 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
* 查询商品管理-商品信息列表查询
|
|
* 查询商品管理-商品信息列表查询
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand, String mfrs,
|
|
|
|
|
|
+ public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand,
|
|
String materialOther, String weight, String expiryNum, String enableSerialNumber,
|
|
String materialOther, String weight, String expiryNum, String enableSerialNumber,
|
|
- String enableBatchNumber, String position, String enabled, String remark, String categoryId,
|
|
|
|
|
|
+ String enabled, String remark, String categoryId,
|
|
String mpList,String reminder) {
|
|
String mpList,String reminder) {
|
|
String[] mpArr = new String[]{};
|
|
String[] mpArr = new String[]{};
|
|
if(StringUtil.isNotEmpty(mpList)){
|
|
if(StringUtil.isNotEmpty(mpList)){
|
|
@@ -155,8 +157,8 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
idList = getListByParentId(Long.parseLong(categoryId));
|
|
idList = getListByParentId(Long.parseLong(categoryId));
|
|
}
|
|
}
|
|
PageUtils.startPage();
|
|
PageUtils.startPage();
|
|
- list= materialMapperEx.selectByConditionMaterial(materialParam, standard, model, color, brand, mfrs, materialOther, weight, expiryNum,
|
|
|
|
- enableSerialNumber, enableBatchNumber, position, enabled, remark, idList, mpList,reminder);
|
|
|
|
|
|
+ list= materialMapperEx.selectByConditionMaterial(materialParam, standard, model, color, brand, materialOther, weight, expiryNum,
|
|
|
|
+ enableSerialNumber, enabled, remark, idList, mpList,reminder);
|
|
if (null != list && list.size()>0) {
|
|
if (null != list && list.size()>0) {
|
|
Map<Long,BigDecimal> initialStockMap = getInitialStockMapByMaterialList(list);
|
|
Map<Long,BigDecimal> initialStockMap = getInitialStockMapByMaterialList(list);
|
|
Map<Long,BigDecimal> currentStockMap = getCurrentStockMapByMaterialList(list);
|
|
Map<Long,BigDecimal> currentStockMap = getCurrentStockMapByMaterialList(list);
|
|
@@ -183,71 +185,66 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
- public int insertMaterial(MaterialDTO material, HttpServletRequest request)throws Exception {
|
|
|
|
- //商品主表信息
|
|
|
|
- Material m = material;
|
|
|
|
- //设置状态
|
|
|
|
- m.setEnabled(true);
|
|
|
|
- //获取类型编码
|
|
|
|
- Long serial_no = materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
|
|
- String sku = serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6);
|
|
|
|
- //设置系统sku
|
|
|
|
- m.setSystemSku(sku);
|
|
|
|
|
|
+ public boolean insertMaterial(MaterialDTO materialDTO, HttpServletRequest request) {
|
|
try{
|
|
try{
|
|
- //添加商品
|
|
|
|
- materialMapperEx.insertSelectiveEx(m);
|
|
|
|
- Long mId = m.getId();
|
|
|
|
- //添加商品条码信息
|
|
|
|
- materialExtendService.saveDetails(material.getMbList(),material.getSortList().toJSONString(),mId,"insert");
|
|
|
|
- //设置初始库存
|
|
|
|
- if(material.getStock()!=null) {
|
|
|
|
- List<MaterialInitialStock> stockArr = material.getStock();
|
|
|
|
- for (int i = 0; i < stockArr.size(); i++) {
|
|
|
|
- MaterialInitialStock jsonObj = stockArr.get(i);
|
|
|
|
- //此时id为仓库id,仓库id、最低安全库存数量、库位不为空
|
|
|
|
- if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null || jsonObj.getHighSafeStock() != null) {
|
|
|
|
- Long depotId = jsonObj.getId();
|
|
|
|
- jsonObj.setDepotId(depotId);
|
|
|
|
- jsonObj.setMaterialId(mId);
|
|
|
|
- jsonObj.setId(null);
|
|
|
|
- //设置初始库
|
|
|
|
- materialInitialStockMapper.insertSelective(jsonObj);
|
|
|
|
- //更新当前库存
|
|
|
|
- depotItemService.updateCurrentStockFun(mId,jsonObj.getDepotId());
|
|
|
|
|
|
+ //商品主表信息
|
|
|
|
+ Material m = materialDTO;
|
|
|
|
+ //设置状态
|
|
|
|
+ m.setEnabled(true);
|
|
|
|
+ //获取类型编码
|
|
|
|
+ Long serial_no = materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
|
|
+ String spu = serial_no + DateUtils.dateTimeNow("yyMMddHHmmss") + RandomHelper.getRandomStr(6);
|
|
|
|
+ //设置系统sku
|
|
|
|
+ m.setSystemSpu(spu);
|
|
|
|
+ //添加商品
|
|
|
|
+ materialMapperEx.insertSelectiveEx(m);
|
|
|
|
+ Long mId = m.getId();
|
|
|
|
+ //保存商品条码信息
|
|
|
|
+ materialExtendService.saveDetails(materialDTO.getMeList(),mId,"insert");
|
|
|
|
+ //设置初始库存
|
|
|
|
+ if(materialDTO.getStock()!=null) {
|
|
|
|
+ List<MaterialInitialStock> stockArr = materialDTO.getStock();
|
|
|
|
+ for (int i = 0; i < stockArr.size(); i++) {
|
|
|
|
+ MaterialInitialStock jsonObj = stockArr.get(i);
|
|
|
|
+ //此时id为仓库id,仓库id、最低安全库存数量、库位不为空
|
|
|
|
+ if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null || jsonObj.getHighSafeStock() != null) {
|
|
|
|
+ Long depotId = jsonObj.getId();
|
|
|
|
+ jsonObj.setDepotId(depotId);
|
|
|
|
+ jsonObj.setMaterialId(mId);
|
|
|
|
+ jsonObj.setId(null);
|
|
|
|
+ //设置初始库
|
|
|
|
+ materialInitialStockMapper.insertSelective(jsonObj);
|
|
|
|
+ //更新当前库存
|
|
|
|
+ depotItemService.updateCurrentStockFun(mId,jsonObj.getDepotId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- logService.insertLog("商品",
|
|
|
|
- new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- catch (BusinessRunTimeException ex) {
|
|
|
|
|
|
+ logService.insertLog("商品",
|
|
|
|
+ new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
|
|
|
|
+ } catch (BusinessRunTimeException ex) {
|
|
throw new BusinessRunTimeException(ex.getCode(), ex.getMessage());
|
|
throw new BusinessRunTimeException(ex.getCode(), ex.getMessage());
|
|
- }
|
|
|
|
- catch(Exception e){
|
|
|
|
|
|
+ } catch(Exception e){
|
|
JshException.writeFail(logger, e);
|
|
JshException.writeFail(logger, e);
|
|
- return 0;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改商品
|
|
* 修改商品
|
|
- * @param obj
|
|
|
|
|
|
+ * @param materialDTO
|
|
* @param request
|
|
* @param request
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
- public int updateMaterial(MaterialDTO obj, HttpServletRequest request) throws Exception{
|
|
|
|
- Material material = obj;
|
|
|
|
|
|
+ public boolean updateMaterial(MaterialDTO materialDTO, HttpServletRequest request){
|
|
try{
|
|
try{
|
|
|
|
+ Material material = materialDTO;
|
|
//修改商品属性
|
|
//修改商品属性
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
materialMapper.updateByPrimaryKeySelective(material);
|
|
- if(material.getUnitId() == null) {
|
|
|
|
- materialMapperEx.setUnitIdToNull(material.getId());
|
|
|
|
- }
|
|
|
|
- materialExtendService.saveDetails(obj.getMbList(), obj.getSortList().toJSONString(),material.getId(), "update");
|
|
|
|
- if(obj.getStock()!=null) {
|
|
|
|
- List<MaterialInitialStock> stockArr = obj.getStock();
|
|
|
|
|
|
+ materialExtendService.saveDetails(materialDTO.getMeList(),material.getId(), "update");
|
|
|
|
+ if(materialDTO.getStock()!=null) {
|
|
|
|
+ List<MaterialInitialStock> stockArr = materialDTO.getStock();
|
|
for (int i = 0; i < stockArr.size(); i++) {
|
|
for (int i = 0; i < stockArr.size(); i++) {
|
|
MaterialInitialStock jsonObj = stockArr.get(i);
|
|
MaterialInitialStock jsonObj = stockArr.get(i);
|
|
if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null || jsonObj.getNumber() != null) {
|
|
if(jsonObj.getId() != null && jsonObj.getLowSafeStock() != null || jsonObj.getPosition() != null || jsonObj.getNumber() != null) {
|
|
@@ -275,19 +272,18 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
}
|
|
}
|
|
logService.insertLog("商品",
|
|
logService.insertLog("商品",
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(material.getName()).toString(), request);
|
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(material.getName()).toString(), request);
|
|
- return 1;
|
|
|
|
}
|
|
}
|
|
catch (BusinessRunTimeException ex) {
|
|
catch (BusinessRunTimeException ex) {
|
|
throw new BusinessRunTimeException(ex.getCode(), ex.getMessage());
|
|
throw new BusinessRunTimeException(ex.getCode(), ex.getMessage());
|
|
}
|
|
}
|
|
catch(Exception e){
|
|
catch(Exception e){
|
|
JshException.writeFail(logger, e);
|
|
JshException.writeFail(logger, e);
|
|
- return 0;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
|
|
public int deleteMaterial(Long id, HttpServletRequest request)throws Exception {
|
|
public int deleteMaterial(Long id, HttpServletRequest request)throws Exception {
|
|
return batchDeleteMaterialByIds(id.toString());
|
|
return batchDeleteMaterialByIds(id.toString());
|
|
}
|
|
}
|
|
@@ -300,7 +296,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
|
- public int batchDeleteMaterialByIds(String ids) throws Exception{
|
|
|
|
|
|
+ public int batchDeleteMaterialByIds(String ids){
|
|
String [] idArray = ids.split(",");
|
|
String [] idArray = ids.split(",");
|
|
//校验单据子表 jsh_depot_item
|
|
//校验单据子表 jsh_depot_item
|
|
List<DepotItem> depotItemList =null;
|
|
List<DepotItem> depotItemList =null;
|
|
@@ -503,6 +499,20 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 商品选择-查找商品信息
|
|
|
|
+ *
|
|
|
|
+ * @param materialQueryDTO
|
|
|
|
+ * @param offset
|
|
|
|
+ * @param rows
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<MaterialVo4Unit> findBySelectWithBarCode(MaterialQueryDTO materialQueryDTO, Integer offset, Integer rows) throws Exception {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public int findBySelectWithBarCodeCount(Long categoryId, String q, String standardOrModel, String color,
|
|
public int findBySelectWithBarCodeCount(Long categoryId, String q, String standardOrModel, String color,
|
|
String brand, String mfrs, String enableSerialNumber, String enableBatchNumber, Long depotId) throws Exception{
|
|
String brand, String mfrs, String enableSerialNumber, String enableBatchNumber, Long depotId) throws Exception{
|
|
@@ -598,7 +608,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
objs[10] = m.getSku();
|
|
objs[10] = m.getSku();
|
|
objs[11] = m.getEnabled() ? "1" : "0";
|
|
objs[11] = m.getEnabled() ? "1" : "0";
|
|
objs[12] = m.getEnableSerialNumber();
|
|
objs[12] = m.getEnableSerialNumber();
|
|
- objs[13] = m.getSystemSku();
|
|
|
|
|
|
+ objs[13] = m.getSystemSpu();
|
|
objs[14] = m.getBarCode();
|
|
objs[14] = m.getBarCode();
|
|
objs[15] = m.getDefaultPurchaseDecimal() == null ? "" : m.getDefaultPurchaseDecimal().toString();
|
|
objs[15] = m.getDefaultPurchaseDecimal() == null ? "" : m.getDefaultPurchaseDecimal().toString();
|
|
objs[16] = m.getDefaultWholesaleDecimal() == null ? "" : m.getDefaultWholesaleDecimal().toString();
|
|
objs[16] = m.getDefaultWholesaleDecimal() == null ? "" : m.getDefaultWholesaleDecimal().toString();
|
|
@@ -706,7 +716,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
//获取类型编码
|
|
//获取类型编码
|
|
Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
//设置系统sku
|
|
//设置系统sku
|
|
- m.setSystemSku(serial_no + DateUtils.dateTimeNow());
|
|
|
|
|
|
+ m.setSystemSpu(serial_no + DateUtils.dateTimeNow());
|
|
if(null!=categoryId){
|
|
if(null!=categoryId){
|
|
m.setCategoryId(categoryId);
|
|
m.setCategoryId(categoryId);
|
|
}
|
|
}
|
|
@@ -1533,7 +1543,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public String getBigUnitStock(BigDecimal stock, Long unitId) throws Exception {
|
|
|
|
|
|
+ public String getBigUnitStock(BigDecimal stock, Long unitId) {
|
|
String bigUnitStock = "";
|
|
String bigUnitStock = "";
|
|
if(null!= unitId) {
|
|
if(null!= unitId) {
|
|
Unit unit = unitService.getUnit(unitId);
|
|
Unit unit = unitService.getUnit(unitId);
|
|
@@ -1903,7 +1913,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
//获取类型编码
|
|
//获取类型编码
|
|
Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
|
|
//设置系统sku
|
|
//设置系统sku
|
|
- m.setSystemSku(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6));
|
|
|
|
|
|
+ m.setSystemSpu(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6));
|
|
//设置默认采购价
|
|
//设置默认采购价
|
|
m.setDefaultPurchaseDecimal(StringUtil.isNotEmpty(defaultPurchaseDecimal) ? new BigDecimal(defaultPurchaseDecimal) : null);
|
|
m.setDefaultPurchaseDecimal(StringUtil.isNotEmpty(defaultPurchaseDecimal) ? new BigDecimal(defaultPurchaseDecimal) : null);
|
|
//设置默认销售价
|
|
//设置默认销售价
|
|
@@ -2167,4 +2177,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
|
|
materialMap.values().forEach(v -> materials.add(v));
|
|
materialMap.values().forEach(v -> materials.add(v));
|
|
return materials;
|
|
return materials;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|