|
@@ -0,0 +1,159 @@
|
|
|
|
+package cn.ezhizao.project.business.taksStockLot.controller;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
|
|
+import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
|
|
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
|
|
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
|
+import cn.ezhizao.framework.web.controller.BaseController;
|
|
|
|
+import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
|
+import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
|
+import cn.ezhizao.project.business.product.domain.BizCarrier;
|
|
|
|
+import cn.ezhizao.project.business.product.domain.BizDayworkCarrier;
|
|
|
|
+import cn.ezhizao.project.business.product.service.IBizCarrierService;
|
|
|
|
+import cn.ezhizao.project.business.product.service.IBizDayworkCarrierService;
|
|
|
|
+import cn.ezhizao.project.business.takeStockPeriod.domain.BizTakeStockPeriod;
|
|
|
|
+import cn.ezhizao.project.business.takeStockPeriod.service.IBizTakeStockPeriodService;
|
|
|
|
+import cn.ezhizao.project.business.taksStockLot.domain.BizTaksStockLot;
|
|
|
|
+import cn.ezhizao.project.business.taksStockLot.service.IBizTaksStockLotService;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 盘点批次信息Controller
|
|
|
|
+ *
|
|
|
|
+ * @author ezhizao
|
|
|
|
+ * @date 2024-08-15
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/business/taksStockLot")
|
|
|
|
+public class BizTaksStockLotController extends BaseController
|
|
|
|
+{
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizTaksStockLotService bizTaksStockLotService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizTakeStockPeriodService bizTakeStockPeriodService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizCarrierService bizCarrierService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizDayworkCarrierService bizDayworkCarrierService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询盘点批次信息列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public TableDataInfo list(BizTaksStockLot bizTaksStockLot) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ BizTakeStockPeriod takeStockPeriod = bizTakeStockPeriodService.query().eq("status", 1).one();
|
|
|
|
+ if(takeStockPeriod == null) {
|
|
|
|
+ return getDataTable(new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ bizTaksStockLot.setTakeStockPeriodId(takeStockPeriod.getId());
|
|
|
|
+ List<BizTaksStockLot> list = bizTaksStockLotService.getList(bizTaksStockLot);
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+ @PostMapping("/getTakesStockByCarrierCode")
|
|
|
|
+ @Transactional
|
|
|
|
+ public AjaxResult getTakesStockByCarrierCode(@RequestBody BizTaksStockLot bizTaksStockLot)
|
|
|
|
+ {
|
|
|
|
+ BizCarrier bizCarrier = bizCarrierService.query().eq("code", bizTaksStockLot.getCarrierCode()).one();
|
|
|
|
+ if (bizCarrier == null) {
|
|
|
|
+ return error("该箱号不存在");
|
|
|
|
+ }
|
|
|
|
+ List<BizDayworkCarrier> bizDayworkCarriers = bizDayworkCarrierService.query().eq("process_inspection_id", 0L).eq("carrier_id", bizCarrier.getId()).eq("is_changed", 0).list();
|
|
|
|
+ if (bizDayworkCarriers.isEmpty()) {
|
|
|
|
+ return error("该载具未绑定任何批次!");
|
|
|
|
+ }
|
|
|
|
+ //查询
|
|
|
|
+ List<Long> dayworkIds = bizDayworkCarriers.stream().map(BizDayworkCarrier::getDayworkId).collect(Collectors.toList());
|
|
|
|
+ BizTakeStockPeriod takeStockPeriod = bizTakeStockPeriodService.query().eq("status", 1).one();
|
|
|
|
+ List<BizTaksStockLot> taksStockLotsList = bizTaksStockLotService.query().eq("take_stock_period_id", takeStockPeriod.getId()).list();
|
|
|
|
+ List<Long> taksStockDayworkIds = taksStockLotsList.stream().map(BizTaksStockLot::getDayworkId).collect(Collectors.toList());
|
|
|
|
+ List<Long> needQueryDayworkIds = new ArrayList<>();
|
|
|
|
+ dayworkIds.forEach(item ->{
|
|
|
|
+ if(taksStockDayworkIds.contains(item)) {
|
|
|
|
+ needQueryDayworkIds.add(item);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if(needQueryDayworkIds.isEmpty()) {
|
|
|
|
+ return error("该载具绑定的批次未在此次盘点内!");
|
|
|
|
+ }
|
|
|
|
+ List<BizTaksStockLot> list = taksStockLotsList.stream()
|
|
|
|
+ .filter(item -> needQueryDayworkIds.contains(item.getDayworkId()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ return success(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出盘点批次信息列表
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:taksStockLot:export')")
|
|
|
|
+ @Log(title = "盘点批次信息", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/export")
|
|
|
|
+ public void export(HttpServletResponse response, BizTaksStockLot bizTaksStockLot) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ setTenantId(bizTaksStockLot);
|
|
|
|
+ List<BizTaksStockLot> list = bizTaksStockLotService.getList(bizTaksStockLot);
|
|
|
|
+ ExcelUtil<BizTaksStockLot> util = new ExcelUtil<BizTaksStockLot>(BizTaksStockLot.class);
|
|
|
|
+ util.exportExcel(response, list, "盘点批次信息数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取盘点批次信息详细信息
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:taksStockLot:query')")
|
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
+ {
|
|
|
|
+ return success(bizTaksStockLotService.getById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增盘点批次信息
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:taksStockLot:add')")
|
|
|
|
+ @Log(title = "盘点批次信息", businessType = BusinessType.INSERT)
|
|
|
|
+ @PostMapping
|
|
|
|
+ public AjaxResult add(@RequestBody BizTaksStockLot bizTaksStockLot) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ setTenantId(bizTaksStockLot);
|
|
|
|
+ return toAjax(bizTaksStockLotService.save(bizTaksStockLot));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改盘点批次信息
|
|
|
|
+ */
|
|
|
|
+ @Log(title = "盘点批次信息", businessType = BusinessType.UPDATE)
|
|
|
|
+ @PutMapping
|
|
|
|
+ public AjaxResult edit(@RequestBody List<BizTaksStockLot> bizTaksStockLot) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ bizTaksStockLot.forEach(item -> {
|
|
|
|
+ item.setIsTaksStock(1);
|
|
|
|
+ });
|
|
|
|
+ return toAjax(bizTaksStockLotService.updateBatchById(bizTaksStockLot));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除盘点批次信息
|
|
|
|
+ */
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:taksStockLot:remove')")
|
|
|
|
+ @Log(title = "盘点批次信息", businessType = BusinessType.DELETE)
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public AjaxResult remove(@PathVariable List<Long> ids)
|
|
|
|
+ {
|
|
|
|
+ return toAjax(bizTaksStockLotService.removeBatchByIds(ids));
|
|
|
|
+ }
|
|
|
|
+}
|