| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.sales.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementAddDto; |
| | | import com.ruoyi.procurementrecord.dto.ProcurementRecordOutAdd; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordOut; |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordOutService; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | | import com.ruoyi.sales.mapper.ShipmentApprovalMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShipmentApproval; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import com.ruoyi.sales.service.ShipmentApprovalService; |
| | | import com.ruoyi.sales.service.ShippingInfoService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/shipmentApproval") |
| | | @Api(tags = "å货审æ¹ç®¡ç") |
| | | public class ShipmentApprovalController extends BaseController { |
| | | |
| | | @Autowired |
| | | private ShipmentApprovalService shipmentApprovalService; |
| | | @Autowired |
| | | private ShipmentApprovalMapper shipmentApprovalMapper; |
| | | |
| | | @Autowired |
| | | private ISalesLedgerProductService salesLedgerProductService; |
| | | @Autowired |
| | | private ProcurementRecordOutService procurementRecordOutService; |
| | | @Autowired |
| | | private ProcurementRecordService procurementRecordStorageService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @ApiOperation("å货审æ¹å表") |
| | | public AjaxResult listPage(Page page, ShipmentApproval req) { |
| | | IPage<ShipmentApproval> listPage = shipmentApprovalService.listPage(page,req); |
| | | return AjaxResult.success(listPage); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation("å货审æ¹,æ´æ°å货审æ¹ç¶æ") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult update(@RequestBody ShipmentApproval req) { |
| | | |
| | | // æ¥è¯¢åè´§å®¡æ¹ |
| | | ShipmentApproval shipmentApproval = shipmentApprovalMapper.selectById(req.getId()); |
| | | if (shipmentApproval == null) { |
| | | return AjaxResult.error("å货审æ¹ä¸åå¨"); |
| | | } |
| | | |
| | | // æ´æ°å货审æ¹ç¶æ |
| | | shipmentApproval.setApproveStatus(req.getApproveStatus()); |
| | | boolean update = shipmentApprovalService.updateById(shipmentApproval); |
| | | if (!update) { |
| | | // äºå¡åæ» |
| | | throw new ServiceException("åè´§å®¡æ¹æ´æ°å¤±è´¥"); |
| | | } |
| | | // æ¥è¯¢å
³èçéå®å°è´¦äº§å |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductService.getById(shipmentApproval.getSalesLedgerProductId()); |
| | | if (salesLedgerProduct == null) { |
| | | // æå¼å¸¸äºå¡åæ» |
| | | throw new ServiceException("éå®å°è´¦ä¸åå¨ï¼å®¡æ¹åæ»"); |
| | | } |
| | | |
| | | // åæ¥æ´æ°éå®å°è´¦äº§åç审æ¹ç¶æ |
| | | salesLedgerProduct.setApproveStatus(req.getApproveStatus()); |
| | | salesLedgerProductService.updateById(salesLedgerProduct); |
| | | |
| | | // 审æ¹éè¿ |
| | | if (req.getApproveStatus() == 3) { |
| | | // æ¥è¯¢éè´å
¥åºè®°å½ |
| | | LambdaQueryWrapper<ProcurementRecordStorage> lambdaQueryWrapper = new LambdaQueryWrapper<ProcurementRecordStorage>() |
| | | .eq(ProcurementRecordStorage::getSalesLedgerProductId, req.getSalesLedgerProductId()); |
| | | ProcurementRecordStorage procurementRecordStorage = procurementRecordStorageService.getOne(lambdaQueryWrapper); |
| | | |
| | | if (procurementRecordStorage == null) { |
| | | // ä¿è¯åé¢çä¿®æ¹å
¨é¨åæ» |
| | | throw new ServiceException("éè´è®°å½ä¸åå¨ï¼å®¡æ¹åæ»"); |
| | | } |
| | | |
| | | // çæåºåºè®°å½ |
| | | ProcurementRecordOutAdd procurementRecordOutAdd = new ProcurementRecordOutAdd(); |
| | | procurementRecordOutAdd.setId(procurementRecordStorage.getId()); |
| | | procurementRecordOutAdd.setSalesLedgerProductId(Math.toIntExact(salesLedgerProduct.getId())); |
| | | procurementRecordOutAdd.setType(2); |
| | | procurementRecordOutAdd.setUserId(Math.toIntExact(getUserId())); |
| | | procurementRecordOutAdd.setQuantity(salesLedgerProduct.getQuantity().toPlainString()); |
| | | procurementRecordOutAdd.setTime(LocalDate.now().toString()); |
| | | |
| | | procurementRecordOutService.stockout(procurementRecordOutAdd); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 导åºåè´§ä¿¡æ¯ç®¡ç |
| | | */ |
| | | @PostMapping("/export") |
| | | @ApiOperation("导åºå货审æ¹") |
| | | public void export(HttpServletResponse response) { |
| | | List<ShipmentApproval> list = shipmentApprovalService.list(null); |
| | | ExcelUtil<ShipmentApproval> util = new ExcelUtil<ShipmentApproval>(ShipmentApproval.class); |
| | | util.exportExcel(response, list, "å货审æ¹"); |
| | | } |
| | | |
| | | } |