|
@@ -0,0 +1,142 @@
|
|
|
|
+package cn.ezhizao.project.business.outsource.controller;
|
|
|
|
+
|
|
|
|
+import java.lang.reflect.Array;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+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.outsource.domain.BizOutsourcedOrderDetail;
|
|
|
|
+import cn.ezhizao.project.business.outsource.service.IBizOutsourcedOrderDetailService;
|
|
|
|
+import cn.ezhizao.project.business.product.domain.BizCarrier;
|
|
|
|
+import cn.ezhizao.project.business.product.service.IBizCarrierService;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
+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;
|
|
|
|
+import cn.ezhizao.project.business.outsource.domain.BizOutsourcedOrder;
|
|
|
|
+import cn.ezhizao.project.business.outsource.service.IBizOutsourcedOrderService;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 外协单主
|
|
|
|
+带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子Controller
|
|
|
|
+ *
|
|
|
|
+ * @author ezhizao
|
|
|
|
+ * @date 2024-05-28
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/business/outsourcedOrder")
|
|
|
|
+public class BizOutsourcedOrderController extends BaseController
|
|
|
|
+{
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizOutsourcedOrderService bizOutsourcedOrderService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizOutsourcedOrderDetailService bizOutsourcedOrderDetailService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizCarrierService carrierService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子列表
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/list")
|
|
|
|
+ public TableDataInfo list(BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
|
+ startPage();
|
|
|
|
+ List<BizOutsourcedOrder> list = bizOutsourcedOrderService.getList(bizOutsourcedOrder);
|
|
|
|
+ List<BizOutsourcedOrderDetail> details = bizOutsourcedOrderDetailService.query().in("master_id", list.isEmpty() ? Collections.singletonList(0L) : list.stream().map(BizOutsourcedOrder::getId).collect(Collectors.toList())).list();
|
|
|
|
+ list.forEach(l -> l.setCarrierCount(details.stream().filter(v -> v.getMasterId().equals(l.getId())).mapToInt(v ->l.getPackagingMethod().equals("0") ? v.getOriginalCarrierCount() : v.getNewCarrierCount()).sum()));
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子列表
|
|
|
|
+ */
|
|
|
|
+ @Log(title = "外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.EXPORT)
|
|
|
|
+ @PostMapping("/export")
|
|
|
|
+ public void export(HttpServletResponse response, BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
|
+ List<BizOutsourcedOrder> list = bizOutsourcedOrderService.getList(bizOutsourcedOrder);
|
|
|
|
+ ExcelUtil<BizOutsourcedOrder> util = new ExcelUtil<BizOutsourcedOrder>(BizOutsourcedOrder.class);
|
|
|
|
+ util.exportExcel(response, list, "外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子详细信息
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
+ {
|
|
|
|
+ return success(bizOutsourcedOrderService.getById(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 新增外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
|
+ */
|
|
|
|
+ @Log(title = "外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.INSERT)
|
|
|
|
+ @PostMapping
|
|
|
|
+ public AjaxResult add(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
|
+ return toAjax(bizOutsourcedOrderService.save(bizOutsourcedOrder));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
|
+ */
|
|
|
|
+ @Log(title = "外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.UPDATE)
|
|
|
|
+ @PutMapping
|
|
|
|
+ public AjaxResult edit(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
+ {
|
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
|
+ return toAjax(bizOutsourcedOrderService.updateById(bizOutsourcedOrder));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
|
|
+ */
|
|
|
|
+ @Log(title = "外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子", businessType = BusinessType.DELETE)
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public AjaxResult remove(@PathVariable List<Long> ids)
|
|
|
|
+ {
|
|
|
|
+ return toAjax(bizOutsourcedOrderService.removeBatchByIds(ids));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Log(title = "外协单获取外协绑定箱码和箱", businessType = BusinessType.SELECT)
|
|
|
|
+ @PostMapping("/getCarriers")
|
|
|
|
+ public AjaxResult getCarriers(@RequestBody BizOutsourcedOrder outsourcedOrder) {
|
|
|
|
+ List<BizOutsourcedOrderDetail> details = bizOutsourcedOrderDetailService.query().eq("master_id", outsourcedOrder.getId()).list();
|
|
|
|
+ List<BizCarrier> carriers = new ArrayList<>();
|
|
|
|
+ List<Long> carrierIds = new ArrayList<>();
|
|
|
|
+ details.stream().filter(v -> v.getNewCarrier().contains("|")).forEach(v -> {
|
|
|
|
+ List<String> splitCarriers = Arrays.asList(v.getNewCarrier().split(","));
|
|
|
|
+ carrierIds.addAll(splitCarriers.stream().map(t -> Long.parseLong(t.split("\\|")[0])).collect(Collectors.toList()));
|
|
|
|
+ });
|
|
|
|
+ List<String> carrierCodes = new ArrayList<>();
|
|
|
|
+ details.stream().filter(v -> !v.getNewCarrier().contains("|")).forEach(v -> {
|
|
|
|
+ List<String> splitCarriers = Arrays.asList(v.getNewCarrier().split(","));
|
|
|
|
+ carrierCodes.addAll(splitCarriers);
|
|
|
|
+ });
|
|
|
|
+ carriers.addAll(carrierService.query().in("id", carrierIds.isEmpty() ? Collections.singletonList(0L) : carrierIds).list());
|
|
|
|
+ carriers.addAll(carrierService.query().in("code", carrierCodes.isEmpty() ? Collections.singletonList("x") : carrierCodes).list());
|
|
|
|
+ details.forEach(l -> {
|
|
|
|
+ l.setCarriers(carriers.stream().filter(v -> l.getNewCarrier().contains(v.getCode())).collect(Collectors.toList()));
|
|
|
|
+ });
|
|
|
|
+ return success(details);
|
|
|
|
+ }
|
|
|
|
+}
|