|
|
@ -9,10 +9,13 @@ import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
import com.win.module.wms.controller.bom.vo.*; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRequest.vo.PurchasereceiptRequestMainImportErrorVO; |
|
|
|
import com.win.module.wms.convert.bom.BomConvert; |
|
|
|
import com.win.module.wms.convert.purchasereceiptRequest.PurchasereceiptRequestMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.bom.BomDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.productionlineitem.ProductionlineitemDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestMainDO; |
|
|
|
import com.win.module.wms.dal.mysql.bom.BomMapper; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
@ -93,73 +96,76 @@ public class BomServiceImpl implements BomService { |
|
|
|
return bomMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String validateBomImport( BomDO bomDo ){ |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateBomExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateProductItemCodeExists(null,bomDo.getProductItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateComponentUomExists(bomDo.getComponentUom()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(bomDo.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateComponentItemCodeExists(bomDo.getComponentItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateComponentQtyExists(bomDo.getComponentQty()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateProcessCodeExists(bomDo.getProcessCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<BomImportExcelVo> importBomList(List<BomImportExcelVo> boms, Integer mode, Boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(boms)) { |
|
|
|
public List<BomImportErrorVO> importBomList(List<BomImportExcelVo> datas, Integer mode, Boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(BOM_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<BomImportExcelVo> errorList = new ArrayList<>(); |
|
|
|
boms.forEach(bom -> { |
|
|
|
String massage = ""; |
|
|
|
if(mode == 2){ |
|
|
|
try { |
|
|
|
validateBomExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateProductItemCodeExists(null,bom.getProductItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateComponentUomExists(bom.getComponentUom()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(bom.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateComponentItemCodeExists(bom.getComponentItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateComponentQtyExists(bom.getComponentQty()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateProcessCodeExists(bom.getProcessCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
|
|
|
|
if(StrUtil.isNotEmpty(massage)){ |
|
|
|
massage.substring(0,massage.length()-1); |
|
|
|
errorList.add(bom); |
|
|
|
} |
|
|
|
if(errorList == null){ |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
BomDO existAccountcalendar = bomMapper.selectByProductItemCode(bom.getProductItemCode()); |
|
|
|
if (existAccountcalendar == null&& mode != 3) { |
|
|
|
bomMapper.insert(BomConvert.INSTANCE.convert(bom)); |
|
|
|
} |
|
|
|
else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
BomDO bomDO = BomConvert.INSTANCE.convert(bom); |
|
|
|
bomDO.setId(existAccountcalendar.getId()); |
|
|
|
bomMapper.updateById(bomDO); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
List<BomImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(bom -> { |
|
|
|
BomDO bomDO = BomConvert.INSTANCE.convert(bom); |
|
|
|
String massage = this.validateBomImport(bomDO); |
|
|
|
boolean flag = true; |
|
|
|
if(!massage.isEmpty()){ |
|
|
|
BomImportErrorVO importErrorVO = BomConvert.INSTANCE.convert2(bom); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
if(flag) { |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
BomDO existAccountcalendar = bomMapper.selectByProductItemCode(bom.getProductItemCode()); |
|
|
|
if (existAccountcalendar == null && mode != 3) { |
|
|
|
bomMapper.insert(bomDO); |
|
|
|
} else if (existAccountcalendar != null && mode != 2) { // 如果存在,判断是否允许更新
|
|
|
|
bomDO.setId(existAccountcalendar.getId()); |
|
|
|
bomMapper.updateById(bomDO); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
|
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|