| | |
| | | package com.ruoyi.sales.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | // 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.approve.mapper.ApproveProcessMapper; |
| | | import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl; |
| | | import com.ruoyi.approve.vo.ApproveProcessVO; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | // import com.ruoyi.approve.mapper.ApproveProcessMapper; |
| | | // import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl; |
| | | // import com.ruoyi.approve.vo.ApproveProcessVO; |
| | | // import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | // import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | // import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.other.service.impl.TempFileServiceImpl; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | // import com.ruoyi.other.service.impl.TempFileServiceImpl; |
| | | // import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.sales.dto.ShippingInfoDto; |
| | | import com.ruoyi.sales.mapper.ShipmentApprovalMapper; |
| | | // import com.ruoyi.sales.mapper.ShipmentApprovalMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.ShipmentApproval; |
| | | // import com.ruoyi.sales.pojo.ShipmentApproval; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.service.ShippingInfoService; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | // import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | // import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ShippingInfoService shippingInfoService; |
| | | |
| | | @Autowired |
| | | private CommonFileServiceImpl commonFileService; |
| | | // @Autowired |
| | | // private CommonFileServiceImpl commonFileService; |
| | | |
| | | // @Autowired |
| | | // private ApproveProcessServiceImpl approveProcessService; |
| | | |
| | | // @Autowired |
| | | // private StockUtils stockUtils; |
| | | |
| | | @Autowired |
| | | private ApproveProcessServiceImpl approveProcessService; |
| | | private ISalesLedgerProductService salesLedgerProductService; |
| | | |
| | | @Autowired |
| | | private StockUtils stockUtils; |
| | | private ISalesLedgerService salesLedgerService; |
| | | |
| | | |
| | | @GetMapping("/listPage") |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Log(title = "åè´§ä¿¡æ¯ç®¡ç", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody ShippingInfoDto req) throws Exception { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | // LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH"); |
| | | |
| | | /* // åæçå产ååè´§å审æ¹é»è¾ |
| | | // åè´§å®¡æ¹ |
| | | ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | approveProcessVO.setApproveType(7); |
| | |
| | | req.setStatus("å¾
å®¡æ ¸"); |
| | | boolean save = shippingInfoService.save(req); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | */ |
| | | |
| | | // ææ´ä¸ªè®¢ååè´§ï¼ä¸éå®¡æ¹ |
| | | if (req.getSalesLedgerId() == null) { |
| | | return AjaxResult.error("è¯·éæ©å货订å"); |
| | | } |
| | | |
| | | // è·å该订åä¸çææäº§å |
| | | SalesLedgerProduct query = new SalesLedgerProduct(); |
| | | query.setSalesLedgerId(req.getSalesLedgerId()); |
| | | List<SalesLedgerProduct> productList = salesLedgerProductService.selectSalesLedgerProductList(query); |
| | | |
| | | if (CollectionUtils.isEmpty(productList)) { |
| | | return AjaxResult.error("该订å䏿 å¾
å货产å"); |
| | | } |
| | | |
| | | // 为æ¯ä¸ªäº§åå建åè´§ä¿¡æ¯ |
| | | List<ShippingInfo> shippingInfoList = new ArrayList<>(); |
| | | for (SalesLedgerProduct product : productList) { |
| | | ShippingInfo shippingInfo = new ShippingInfo(); |
| | | shippingInfo.setSalesLedgerId(req.getSalesLedgerId()); |
| | | shippingInfo.setSalesLedgerProductId(product.getId()); |
| | | shippingInfo.setShippingNo(sh); |
| | | shippingInfo.setStatus("å®¡æ ¸éè¿"); // ç´æ¥è®¾ä¸ºå®¡æ ¸éè¿ï¼è·³è¿å®¡æ¹ |
| | | shippingInfo.setType(req.getType()); |
| | | shippingInfo.setExpressCompany(req.getExpressCompany()); |
| | | shippingInfo.setExpressNumber(req.getExpressNumber()); |
| | | shippingInfo.setShippingDate(req.getShippingDate()); |
| | | shippingInfo.setShippingCarNumber(req.getShippingCarNumber()); |
| | | shippingInfoList.add(shippingInfo); |
| | | } |
| | | |
| | | boolean save = shippingInfoService.saveBatch(shippingInfoList); |
| | | if (save) { |
| | | // æ´æ°éå®å°è´¦çåè´§ç¶æä¸ºå·²åè´§ |
| | | SalesLedger salesLedger = new SalesLedger(); |
| | | salesLedger.setId(req.getSalesLedgerId()); |
| | | salesLedger.setDeliveryStatus(1); |
| | | salesLedgerService.updateById(salesLedger); |
| | | } |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @ApiOperation("åè´§æ£åºå") |