diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AfterSalesShippingDeviceMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AfterSalesShippingDeviceMapper.java index e324a2c1..26f40117 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AfterSalesShippingDeviceMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AfterSalesShippingDeviceMapper.java @@ -97,4 +97,9 @@ public interface AfterSalesShippingDeviceMapper * 销售单-出库 物料信息关联设备信息 */ List selectShippingDeviceList(AfterSalesShippingDevice afterSalesShippingDevice); + + /* + * 根据生产单号和关联销售单号查询出货设备履历信息 + * */ + List selectAfterSalesShippingDeviceByNoAndCode(AfterSalesShippingDevice afterSalesShippingDevice); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAfterSalesShippingDeviceService.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAfterSalesShippingDeviceService.java index 78c9aff6..a91ebf7a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAfterSalesShippingDeviceService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAfterSalesShippingDeviceService.java @@ -7,6 +7,7 @@ import com.ruoyi.aftersales.domain.dto.AfterSalesMakeOrderDto; import com.ruoyi.aftersales.domain.dto.AfterSalesShippingDeviceEditDto; import com.ruoyi.aftersales.domain.dto.WarehouseAndAfterSalesDto; import com.ruoyi.aftersales.domain.vo.SelectDeviceVO; +import com.ruoyi.system.dto.SysEquipDetailDto; /** * 出货设备Service接口 @@ -111,4 +112,11 @@ public interface IAfterSalesShippingDeviceService * @return */ List selectOptionDevices(String makeNo); + + + /* + * 根据生产单号和关联销售单号查询出货设备履历信息 + * */ + List selectAfterSalesShippingDeviceByNoAndCode(AfterSalesShippingDevice afterSalesShippingDevice); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AfterSalesShippingDeviceServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AfterSalesShippingDeviceServiceImpl.java index 21ef839e..6fdc89d8 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AfterSalesShippingDeviceServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AfterSalesShippingDeviceServiceImpl.java @@ -13,6 +13,7 @@ import com.ruoyi.aftersales.mapper.AftersalesComplaintNoticeMapper; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.dto.SysEquipDetailDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.aftersales.mapper.AfterSalesShippingDeviceMapper; @@ -20,6 +21,7 @@ import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; import com.ruoyi.aftersales.service.IAfterSalesShippingDeviceService; import com.ruoyi.common.core.text.Convert; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; /** * 出货设备Service业务层处理 @@ -241,4 +243,24 @@ public class AfterSalesShippingDeviceServiceImpl implements IAfterSalesShippingD selectDeviceVos.add(selectDeviceVo); return selectDeviceVos; } + + /* + * 根据生产单号和关联销售单号查询出货设备履历信息 + * */ + @Override + public List selectAfterSalesShippingDeviceByNoAndCode(AfterSalesShippingDevice afterSalesShippingDevice) { + + List sysEquipDetailDtos = new ArrayList<>(); + List afterSalesShippingDeviceList = afterSalesShippingDeviceMapper.selectAfterSalesShippingDeviceByNoAndCode(afterSalesShippingDevice); + if (!CollectionUtils.isEmpty(afterSalesShippingDeviceList)){ + for (AfterSalesShippingDevice salesShippingDevice : afterSalesShippingDeviceList) { + SysEquipDetailDto sysEquipDetailDto = new SysEquipDetailDto(); + sysEquipDetailDto.setEquipmentId(salesShippingDevice.getShippingDeviceId()); + sysEquipDetailDto.setSerialNo(salesShippingDevice.getDeviceRunningNumber()); + sysEquipDetailDto.setEquipmentModel(salesShippingDevice.getDeviceModelCode()); + sysEquipDetailDtos.add(sysEquipDetailDto); + } + } + return sysEquipDetailDtos; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java index a536b003..77aeba35 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysMakeOrderController.java @@ -2,6 +2,8 @@ package com.ruoyi.system.controller; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.lang.Assert; +import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; +import com.ruoyi.aftersales.service.IAfterSalesShippingDeviceService; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -12,10 +14,13 @@ import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.erp.service.IErpMaterialService; +import com.ruoyi.financial.domain.FinancialReceivables; +import com.ruoyi.financial.domain.FinancialReceivablesRecords; import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeorderDept; import com.ruoyi.system.domain.SysSalesOrder; import com.ruoyi.system.domain.SysSalesOrderChild; +import com.ruoyi.system.dto.SysEquipDetailDto; import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderDeptDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; @@ -57,6 +62,10 @@ public class SysMakeOrderController extends BaseController @Autowired private ISysSalesOrderService salesOrderService; + @Autowired + private IAfterSalesShippingDeviceService salesShippingDeviceService; + + @GetMapping("/test") public AjaxResult test(){ sysMakeOrderService.generateMakeOrderBySalesOrderCode("XS20240411007"); @@ -209,6 +218,34 @@ public class SysMakeOrderController extends BaseController } + /** + * 添加保存设备履历 + */ + @ResponseBody + @PostMapping("/addEquipmentResumeSave") + public AjaxResult addEquipmentResumeSave(@RequestBody SysEquipMaterialDto equipMaterialDto) + { + + return toAjax(sysMakeOrderService.addEquipmentResumeSave(equipMaterialDto)); + } + + /** + * 查找已经添加的设备履历 + */ + @PostMapping("/getEquipMaterialDetails") + @ResponseBody + public TableDataInfo getEquipMaterialDetails(SysEquipMaterialDto equipMaterialDto){ + startPage(); + String makeNo = equipMaterialDto.getMakeNo(); + String salesOrderCode = equipMaterialDto.getQuoteId(); + AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); + afterSalesShippingDevice.setMakeNo(makeNo); + afterSalesShippingDevice.setSalesOrderCode(salesOrderCode); + List equipDetailDtos = salesShippingDeviceService.selectAfterSalesShippingDeviceByNoAndCode(afterSalesShippingDevice); + return getDataTable(equipDetailDtos); + } + + /** * 部门评审 * @param makeorderDeptDto diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipMaterialDto.java b/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipMaterialDto.java index 499cf399..fa128aae 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipMaterialDto.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/dto/SysEquipMaterialDto.java @@ -26,4 +26,7 @@ public class SysEquipMaterialDto implements Serializable { private String makeNo; private Integer curIndex; private String inboundOrderNo; + + //出货设备详情集合 + private List sysEquipDetailDtos; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java index 1228a758..4adfdb1f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysMakeOrderService.java @@ -1,6 +1,7 @@ package com.ruoyi.system.service; import com.ruoyi.system.domain.SysMakeOrder; +import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; @@ -112,4 +113,10 @@ public interface ISysMakeOrderService * 仓库采购入库单进行入库的时候更新生产订单数据 * */ int updateSysMakeOrderByWarehouseStorageOrder(WarehouseStorageOrder warehouseStorageOrder, List warehouseStorageOrderDetailList); + + /** + * 添加保存设备履历 + */ + int addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java index f42ff0f2..5495e766 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java @@ -1,8 +1,11 @@ package com.ruoyi.system.service.impl; import cn.hutool.core.collection.CollectionUtil; +import com.ruoyi.aftersales.domain.AfterSalesShippingDevice; +import com.ruoyi.aftersales.mapper.AfterSalesShippingDeviceMapper; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; @@ -13,6 +16,8 @@ import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeorderBom; import com.ruoyi.system.domain.SysSalesOrderChild; import com.ruoyi.system.domain.SysSalesOrderVo; +import com.ruoyi.system.dto.SysEquipDetailDto; +import com.ruoyi.system.dto.SysEquipMaterialDto; import com.ruoyi.system.dto.SysMakeorderMaterialDto; import com.ruoyi.system.mapper.SysMakeOrderMapper; import com.ruoyi.system.service.*; @@ -23,6 +28,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Date; @@ -62,6 +68,10 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService @Autowired private IPurchasePlanService purchasePlanService; + @Autowired + private AfterSalesShippingDeviceMapper afterSalesShippingDeviceMapper; + + /** * 查询生产订单 * @@ -324,4 +334,51 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService return updateResult; } + + /** + * 添加保存设备履历 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto) { + if (CollectionUtils.isEmpty(equipMaterialDto.getSysEquipDetailDtos())) { + log.warn("设备履历详情数据为空"); + throw new BusinessException("设备履历详情数据为空"); + } + + int result = 0; + + for (SysEquipDetailDto sysEquipDetailDto : equipMaterialDto.getSysEquipDetailDtos()) { + AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); + + // 设置通用信息,这些信息对于插入和更新都是共通的 + afterSalesShippingDevice.setMakeNo(equipMaterialDto.getMakeNo()); + afterSalesShippingDevice.setSalesOrderCode(equipMaterialDto.getQuoteId()); + afterSalesShippingDevice.setMaterialNo(equipMaterialDto.getMaterialCode()); + afterSalesShippingDevice.setMaterialName(equipMaterialDto.getMaterialName()); + afterSalesShippingDevice.setMaterialType(equipMaterialDto.getMaterialType()); + afterSalesShippingDevice.setMaterialBrand(equipMaterialDto.getBrand()); + afterSalesShippingDevice.setMaterialUnit(equipMaterialDto.getUnit()); + afterSalesShippingDevice.setMaterialDescribe(equipMaterialDto.getDescribe()); + afterSalesShippingDevice.setDeviceModelCode(sysEquipDetailDto.getEquipmentModel()); + afterSalesShippingDevice.setDeviceRunningNumber(sysEquipDetailDto.getSerialNo()); + + if (StringUtils.isEmpty(sysEquipDetailDto.getEquipmentId())) { + // 如果设备ID为空,说明是新记录,需要插入 + afterSalesShippingDevice.setShippingDeviceId(redisCache.generateBillNo("CHSB")); + afterSalesShippingDevice.setCreateBy(ShiroUtils.getLoginName()); + afterSalesShippingDevice.setCreateTime(new Date()); + result += afterSalesShippingDeviceMapper.insertAfterSalesShippingDevice(afterSalesShippingDevice); + } else { + // 设备ID不为空,假设需要更新逻辑(根据业务需求确定是否需要此分支) + afterSalesShippingDevice.setShippingDeviceId(sysEquipDetailDto.getEquipmentId()); // 确保ID设置正确 + afterSalesShippingDevice.setUpdateBy(ShiroUtils.getLoginName()); + afterSalesShippingDevice.setUpdateTime(new Date()); + // 注意:这里假设了updateAfterSalesShippingDevice方法是存在的且逻辑正确,根据实际情况调整 + result += afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(afterSalesShippingDevice); + } + } + + return result; + } } diff --git a/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml b/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml index bea7cb80..dce6234c 100644 --- a/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml @@ -94,11 +94,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + insert into aftersales_shipping_device shipping_device_id, + sales_order_code, make_no, material_no, material_photoUrl, @@ -136,6 +144,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{shippingDeviceId}, + #{salesOrderCode}, #{makeNo}, #{materialNo}, #{materialPhotourl}, @@ -177,6 +186,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update aftersales_shipping_device shipping_device_id = #{shippingDeviceId}, + sales_order_code = #{salesOrderCode}, make_no = #{makeNo}, material_no = #{materialNo}, material_photoUrl = #{materialPhotourl}, diff --git a/ruoyi-admin/src/main/resources/templates/system/makeorder/addEquipmentResume.html b/ruoyi-admin/src/main/resources/templates/system/makeorder/addEquipmentResume.html index 49304149..6756d2b3 100644 --- a/ruoyi-admin/src/main/resources/templates/system/makeorder/addEquipmentResume.html +++ b/ruoyi-admin/src/main/resources/templates/system/makeorder/addEquipmentResume.html @@ -102,114 +102,186 @@ + + + + + + + + + + +
+ +
+ +
- -
-
+
+
- + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html b/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html index 9b6f0e16..3944901e 100644 --- a/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html +++ b/ruoyi-admin/src/main/resources/templates/system/makeorder/addProduceInbound.html @@ -46,6 +46,7 @@ +