|
@ -10,8 +10,16 @@ import com.ruoyi.common.utils.DateUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
import com.ruoyi.erp.domain.ErpBom; |
|
|
import com.ruoyi.erp.domain.ErpBom; |
|
|
|
|
|
import com.ruoyi.erp.domain.ErpInboundOrder; |
|
|
|
|
|
import com.ruoyi.erp.domain.ErpInboundOrderDetail; |
|
|
import com.ruoyi.erp.service.IErpBomService; |
|
|
import com.ruoyi.erp.service.IErpBomService; |
|
|
import com.ruoyi.purchase.service.IPurchasePlanService; |
|
|
import com.ruoyi.purchase.service.IPurchasePlanService; |
|
|
|
|
|
import com.ruoyi.quality.domain.QualityOrder; |
|
|
|
|
|
import com.ruoyi.quality.domain.QualityOrderDetail; |
|
|
|
|
|
import com.ruoyi.quality.domain.QualityOrderReport; |
|
|
|
|
|
import com.ruoyi.quality.mapper.QualityOrderDetailMapper; |
|
|
|
|
|
import com.ruoyi.quality.mapper.QualityOrderMapper; |
|
|
|
|
|
import com.ruoyi.quality.mapper.QualityOrderReportMapper; |
|
|
import com.ruoyi.system.domain.SysMakeOrder; |
|
|
import com.ruoyi.system.domain.SysMakeOrder; |
|
|
import com.ruoyi.system.domain.SysMakeorderBom; |
|
|
import com.ruoyi.system.domain.SysMakeorderBom; |
|
|
import com.ruoyi.system.domain.SysSalesOrderChild; |
|
|
import com.ruoyi.system.domain.SysSalesOrderChild; |
|
@ -20,6 +28,7 @@ import com.ruoyi.system.dto.SysEquipDetailDto; |
|
|
import com.ruoyi.system.dto.SysEquipMaterialDto; |
|
|
import com.ruoyi.system.dto.SysEquipMaterialDto; |
|
|
import com.ruoyi.system.dto.SysMakeorderMaterialDto; |
|
|
import com.ruoyi.system.dto.SysMakeorderMaterialDto; |
|
|
import com.ruoyi.system.mapper.SysMakeOrderMapper; |
|
|
import com.ruoyi.system.mapper.SysMakeOrderMapper; |
|
|
|
|
|
import com.ruoyi.system.mapper.SysSalesOrderChildMapper; |
|
|
import com.ruoyi.system.service.*; |
|
|
import com.ruoyi.system.service.*; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; |
|
|
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; |
|
@ -31,9 +40,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生产订单Service业务层处理 |
|
|
* 生产订单Service业务层处理 |
|
@ -57,6 +64,9 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ISysSalesOrderService salesOrderService; |
|
|
private ISysSalesOrderService salesOrderService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SysSalesOrderChildMapper salesOrderChildMapper; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private ISysSalesOrderChildService salesOrderChildService; |
|
|
private ISysSalesOrderChildService salesOrderChildService; |
|
|
|
|
|
|
|
@ -72,6 +82,14 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
@Autowired |
|
|
@Autowired |
|
|
private AfterSalesShippingDeviceMapper afterSalesShippingDeviceMapper; |
|
|
private AfterSalesShippingDeviceMapper afterSalesShippingDeviceMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private QualityOrderMapper qualityOrderMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private QualityOrderDetailMapper orderDetailMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private QualityOrderReportMapper orderReportMapper; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询生产订单 |
|
|
* 查询生产订单 |
|
@ -408,4 +426,107 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 添加保存创建生产入库和设备履历设置 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
@Override |
|
|
|
|
|
public int addProduceInboundSave(ErpInboundOrder erpInboundOrder) { |
|
|
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
|
|
erpInboundOrder.setCreateBy(loginName); |
|
|
|
|
|
erpInboundOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
|
String qualityOrderCode = redisCache.generateBillNo("PZ"); |
|
|
|
|
|
QualityOrder qualityOrder = createQualityOrder(qualityOrderCode, erpInboundOrder, loginName); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, SysSalesOrderChild> materialInfoMap = fetchMaterialInfoMap(erpInboundOrder); |
|
|
|
|
|
|
|
|
|
|
|
addQualityOrderDetails(qualityOrder, erpInboundOrder, materialInfoMap); |
|
|
|
|
|
addQualityOrderReports(qualityOrder, erpInboundOrder, materialInfoMap); |
|
|
|
|
|
|
|
|
|
|
|
return qualityOrderMapper.insertQualityOrder(qualityOrder); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private QualityOrder createQualityOrder(String code, ErpInboundOrder erpInboundOrder, String loginName) { |
|
|
|
|
|
QualityOrder qualityOrder = new QualityOrder(); |
|
|
|
|
|
qualityOrder.setQualityOrderCode(code); |
|
|
|
|
|
qualityOrder.setRelatedOrderCode(erpInboundOrder.getMakeNo()); |
|
|
|
|
|
qualityOrder.setQualityStatus("0"); |
|
|
|
|
|
qualityOrder.setQualityStorageStatus("4"); |
|
|
|
|
|
qualityOrder.setQualityOrderType("1"); |
|
|
|
|
|
qualityOrder.setCreateTime(new Date()); |
|
|
|
|
|
qualityOrder.setCreateBy(loginName); |
|
|
|
|
|
return qualityOrder; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//先查询所有必要的信息并将其存储在一个Map中,提高查询效率
|
|
|
|
|
|
private Map<String, SysSalesOrderChild> fetchMaterialInfoMap(ErpInboundOrder erpInboundOrder) { |
|
|
|
|
|
List<ErpInboundOrderDetail> inboundDetails = erpInboundOrder.getInboundDetails(); |
|
|
|
|
|
Map<String, SysSalesOrderChild> materialInfoMap = new HashMap<>(); |
|
|
|
|
|
for (ErpInboundOrderDetail detail : inboundDetails) { |
|
|
|
|
|
SysSalesOrderChild sysSalesOrderChild = new SysSalesOrderChild(); |
|
|
|
|
|
sysSalesOrderChild.setMaterialCode(detail.getMaterialNo()); |
|
|
|
|
|
sysSalesOrderChild.setQuoteId(erpInboundOrder.getSaleNo()); |
|
|
|
|
|
SysSalesOrderChild child = salesOrderChildMapper.selectSalesOrderChildByCodeAndNo(sysSalesOrderChild); |
|
|
|
|
|
materialInfoMap.put(detail.getMaterialNo(), child); |
|
|
|
|
|
} |
|
|
|
|
|
return materialInfoMap; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void addQualityOrderDetails(QualityOrder qualityOrder, ErpInboundOrder erpInboundOrder, Map<String, SysSalesOrderChild> materialInfoMap) { |
|
|
|
|
|
for (ErpInboundOrderDetail detail : erpInboundOrder.getInboundDetails()) { |
|
|
|
|
|
SysSalesOrderChild salesOrderChild = materialInfoMap.get(detail.getMaterialNo()); |
|
|
|
|
|
QualityOrderDetail qualityOrderDetail = createQualityOrderDetail(qualityOrder, detail, salesOrderChild); |
|
|
|
|
|
int result = orderDetailMapper.insertQualityOrderDetail(qualityOrderDetail); |
|
|
|
|
|
if (result <= 0) { |
|
|
|
|
|
throw new BusinessException("新增品质单详情失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private QualityOrderDetail createQualityOrderDetail(QualityOrder qualityOrder, ErpInboundOrderDetail detail, SysSalesOrderChild salesOrderChild) { |
|
|
|
|
|
QualityOrderDetail qualityOrderDetail = new QualityOrderDetail(); |
|
|
|
|
|
qualityOrderDetail.setQualityOrderCode(qualityOrder.getQualityOrderCode()); |
|
|
|
|
|
qualityOrderDetail.setMaterialNo(detail.getMaterialNo()); |
|
|
|
|
|
qualityOrderDetail.setMaterialName(salesOrderChild.getMaterialName()); |
|
|
|
|
|
qualityOrderDetail.setMaterialType(salesOrderChild.getMaterialType()); |
|
|
|
|
|
qualityOrderDetail.setMaterialBrand(salesOrderChild.getBrand()); |
|
|
|
|
|
qualityOrderDetail.setMaterialDescribe(salesOrderChild.getDescribe()); |
|
|
|
|
|
qualityOrderDetail.setMaterialUnit(salesOrderChild.getUnit()); |
|
|
|
|
|
qualityOrderDetail.setMaterialProcessMethod(salesOrderChild.getProcessMethod()); |
|
|
|
|
|
qualityOrderDetail.setMaterialDeptType("0"); |
|
|
|
|
|
qualityOrderDetail.setMakeTotal(salesOrderChild.getMaterialNum()); |
|
|
|
|
|
qualityOrderDetail.setMakeCompletionNum(Math.toIntExact(detail.getCurrentNum())); |
|
|
|
|
|
qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
qualityOrderDetail.setCreateTime(new Date()); |
|
|
|
|
|
return qualityOrderDetail; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//添加品质单报告数据
|
|
|
|
|
|
private void addQualityOrderReports(QualityOrder qualityOrder, ErpInboundOrder erpInboundOrder, Map<String, SysSalesOrderChild> materialInfoMap) { |
|
|
|
|
|
|
|
|
|
|
|
for (ErpInboundOrderDetail detail : erpInboundOrder.getInboundDetails()) { |
|
|
|
|
|
SysSalesOrderChild salesOrderChild = materialInfoMap.get(detail.getMaterialNo()); |
|
|
|
|
|
QualityOrderReport qualityOrderReport = createQualityOrderReport(qualityOrder, detail, salesOrderChild); |
|
|
|
|
|
int result = orderReportMapper.insertQualityOrderReport(qualityOrderReport); |
|
|
|
|
|
if (result <= 0) { |
|
|
|
|
|
throw new BusinessException("新增品质单报告失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private QualityOrderReport createQualityOrderReport(QualityOrder qualityOrder, ErpInboundOrderDetail detail, SysSalesOrderChild salesOrderChild) { |
|
|
|
|
|
QualityOrderReport qualityOrderReport = new QualityOrderReport(); |
|
|
|
|
|
|
|
|
|
|
|
qualityOrderReport.setQualityOrderCode(qualityOrder.getQualityOrderCode()); |
|
|
|
|
|
qualityOrderReport.setMaterialNo(detail.getMaterialNo()); |
|
|
|
|
|
qualityOrderReport.setMaterialName(salesOrderChild.getMaterialName()); |
|
|
|
|
|
qualityOrderReport.setMakeTotal(salesOrderChild.getMaterialNum()); |
|
|
|
|
|
qualityOrderReport.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
qualityOrderReport.setCreateTime(new Date()); |
|
|
|
|
|
return qualityOrderReport; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|