|
@@ -0,0 +1,156 @@
|
|
|
+package cn.ezhizao.project.business.product.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.BizDaywork;
|
|
|
+import cn.ezhizao.project.business.product.domain.BizDayworkItemExamine;
|
|
|
+import cn.ezhizao.project.business.product.service.IBizDayworkItemExamineService;
|
|
|
+import cn.ezhizao.project.business.product.service.IBizDayworkService;
|
|
|
+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;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 分选包装审核申请Controller
|
|
|
+ *
|
|
|
+ * @author ezhizao
|
|
|
+ * @date 2024-07-29
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/business/examine")
|
|
|
+public class BizDayworkItemExamineController extends BaseController
|
|
|
+{
|
|
|
+ @Resource
|
|
|
+ private IBizDayworkItemExamineService bizDayworkItemExamineService;
|
|
|
+ @Resource
|
|
|
+ private IBizDayworkService bizDayworkService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询分选包装审核申请列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(BizDayworkItemExamine bizDayworkItemExamine) throws NoSuchFieldException, IllegalAccessException
|
|
|
+ {
|
|
|
+ setTenantId(bizDayworkItemExamine);
|
|
|
+ startPage();
|
|
|
+ List<BizDayworkItemExamine> list = bizDayworkItemExamineService.getList(bizDayworkItemExamine);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+ @GetMapping("/getExamineByDayworkId")
|
|
|
+ public AjaxResult getExamineByDayworkId(BizDayworkItemExamine bizDayworkItemExamine) throws NoSuchFieldException, IllegalAccessException
|
|
|
+ {
|
|
|
+ List<BizDayworkItemExamine> examine = bizDayworkItemExamineService.query().in("daywork_id", bizDayworkItemExamine.getDayworkIds()).list();
|
|
|
+ List<BizDaywork> dayworkList = bizDayworkService.query().in("id", bizDayworkItemExamine.getDayworkIds()).list();
|
|
|
+ if(examine.size() == 0) {
|
|
|
+ String msg = dayworkList.stream().map(BizDaywork::getLotCode).collect(Collectors.joining(","));
|
|
|
+ return error("批次"+msg+"没有提出审核申请,请联系管理员添加");
|
|
|
+ }else {
|
|
|
+ List<Long> examineDayworkIds = examine.stream().map(BizDayworkItemExamine::getDayworkId).collect(Collectors.toList());
|
|
|
+ List<BizDaywork> notDaywork = new ArrayList<>();
|
|
|
+ //判断一箱多批的情况,是否存在一个提申请,一个没提申请
|
|
|
+ bizDayworkItemExamine.getDayworkIds().forEach(item ->{
|
|
|
+ if(!examineDayworkIds.contains(item)) {
|
|
|
+ notDaywork.add(dayworkList.stream().filter(info -> info.getId().equals(item)).collect(Collectors.toList()).get(0));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(notDaywork.size() > 0) {
|
|
|
+ String msg = notDaywork.stream().map(BizDaywork::getLotCode).collect(Collectors.joining(","));
|
|
|
+ return error("批次"+msg+"未提审核申请,请联系管理员添加");
|
|
|
+ }
|
|
|
+ List<BizDayworkItemExamine> collect = examine.stream().filter(item -> item.getStatus().equals(2) ).collect(Collectors.toList());
|
|
|
+ if(collect.size() == 0) {
|
|
|
+ String msg = examine.stream().map(BizDayworkItemExamine::getLotCode).collect(Collectors.joining(","));
|
|
|
+ return error("批次"+msg+"审核尚未通过,请联系管理员");
|
|
|
+ }else {
|
|
|
+ List<BizDayworkItemExamine> notExamine = new ArrayList<>();
|
|
|
+ //判断是否存在一个申请通过,一个未通过
|
|
|
+ examine.forEach(item ->{
|
|
|
+ if(!item.getStatus().equals(2)){
|
|
|
+ notExamine.add(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(notExamine.size() > 0) {
|
|
|
+ String msg = notExamine.stream().map(BizDayworkItemExamine::getLotCode).collect(Collectors.joining(","));
|
|
|
+ return error("批次"+msg+"审核未通过,请联系管理员");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出分选包装审核申请列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:examine:export')")
|
|
|
+ @Log(title = "分选包装审核申请", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, BizDayworkItemExamine bizDayworkItemExamine) throws NoSuchFieldException, IllegalAccessException
|
|
|
+ {
|
|
|
+ setTenantId(bizDayworkItemExamine);
|
|
|
+ List<BizDayworkItemExamine> list = bizDayworkItemExamineService.getList(bizDayworkItemExamine);
|
|
|
+ ExcelUtil<BizDayworkItemExamine> util = new ExcelUtil<BizDayworkItemExamine>(BizDayworkItemExamine.class);
|
|
|
+ util.exportExcel(response, list, "分选包装审核申请数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取分选包装审核申请详细信息
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:examine:query')")
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ return success(bizDayworkItemExamineService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增分选包装审核申请
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:examine:add')")
|
|
|
+ @Log(title = "分选包装审核申请", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@RequestBody BizDayworkItemExamine bizDayworkItemExamine) throws NoSuchFieldException, IllegalAccessException
|
|
|
+ {
|
|
|
+ setTenantId(bizDayworkItemExamine);
|
|
|
+ return toAjax(bizDayworkItemExamineService.save(bizDayworkItemExamine));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改分选包装审核申请
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:examine:edit')")
|
|
|
+ @Log(title = "分选包装审核申请", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody BizDayworkItemExamine bizDayworkItemExamine) throws NoSuchFieldException, IllegalAccessException
|
|
|
+ {
|
|
|
+ setTenantId(bizDayworkItemExamine);
|
|
|
+ return toAjax(bizDayworkItemExamineService.updateById(bizDayworkItemExamine));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除分选包装审核申请
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:examine:remove')")
|
|
|
+ @Log(title = "分选包装审核申请", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable List<Long> ids)
|
|
|
+ {
|
|
|
+ return toAjax(bizDayworkItemExamineService.removeBatchByIds(ids));
|
|
|
+ }
|
|
|
+}
|