From 57e23c353a177b9c003a2f524a2adeaf641e2e4c Mon Sep 17 00:00:00 2001 From: ZY <zc857179121@qq.com> Date: 星期五, 16 八月 2024 17:09:55 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/wms-dev' into wms-dev --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/LocDetlController.java | 51 ++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 44 insertions(+), 7 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/LocDetlController.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/LocDetlController.java index 26147cd..94ebbef 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/LocDetlController.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/controller/LocDetlController.java @@ -1,12 +1,13 @@ package com.zy.asrs.wms.asrs.controller; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.common.R; import com.zy.asrs.wms.asrs.entity.*; +import com.zy.asrs.wms.asrs.mapper.LocDetlMapper; import com.zy.asrs.wms.asrs.service.LocDetlFieldService; import com.zy.asrs.wms.asrs.service.MatFieldService; import com.zy.asrs.wms.common.annotation.OperationLog; @@ -21,10 +22,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; @RestController @RequestMapping("/api") @@ -36,6 +34,8 @@ private MatFieldService matFieldService; @Autowired private LocDetlFieldService locDetlFieldService; + + @PreAuthorize("hasAuthority('asrs:locDetl:list')") @PostMapping("/locDetl/page") @@ -64,6 +64,14 @@ public R list(@RequestBody Map<String, Object> map) { List<LocDetl> list = locDetlService.getLocDetlList(map); return R.ok().add(list); + } + + @PreAuthorize("hasAuthority('asrs:locDetl:list')") + @GetMapping("/locDetl/locId/{locId}") + public R list(@PathVariable("locId") Long locId) { + List<LocDetl> list = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locId)); + List<LocDetl> locDetls = locDetlService.parseLocDetl(list); + return R.ok().add(locDetls); } @PreAuthorize("hasAuthority('asrs:locDetl:list')") @@ -104,7 +112,11 @@ @PreAuthorize("hasAuthority('asrs:locDetl:update')") @OperationLog("淇敼搴撳瓨鏄庣粏") @PostMapping("/locDetl/update") - public R update(@RequestBody LocDetl locDetl) { + public R update(@RequestBody HashMap<String,Object> param) { + LocDetl locDetl = JSON.parseObject(JSON.toJSONString(param), LocDetl.class, Feature.DisableCircularReferenceDetect); + //璁剧疆鎵╁睍瀛楁 + setLocDetlField(param, locDetl); + if (!locDetlService.updateById(locDetl)) { return R.error("淇敼澶辫触"); } @@ -138,7 +150,32 @@ @PreAuthorize("hasAuthority('asrs:locDetl:list')") @PostMapping("/locDetl/export") public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { - ExcelUtil.build(ExcelUtil.create(locDetlService.list(), LocDetl.class), response); + List<LocDetl> locDetls = locDetlService.parseLocDetl(locDetlService.list()); + List<MatField> locFields = matFieldService.getLocFields(); + ExcelUtil.build(ExcelUtil.create(locDetls, LocDetl.class, locFields), response); + } + + private void setLocDetlField(HashMap<String, Object> param, LocDetl locDetl) { + //鑾峰彇鎵╁睍瀛楁 + List<MatField> matFields = matFieldService.list(new LambdaQueryWrapper<MatField>().eq(MatField::getFieldType, 1)); + for (MatField matField : matFields) { + if (param.containsKey(matField.getName())) { + LocDetlField fieldValue = locDetlFieldService.getOne(new LambdaQueryWrapper<LocDetlField>() + .eq(LocDetlField::getDetlId, locDetl.getId()) + .eq(LocDetlField::getFieldId, matField.getId())); + if (fieldValue == null) { + fieldValue = new LocDetlField(); + fieldValue.setDetlId(locDetl.getId()); + fieldValue.setFieldId(matField.getId()); + fieldValue.setName(matField.getName()); + fieldValue.setValue(param.get(matField.getName()).toString()); + locDetlFieldService.save(fieldValue); + }else { + fieldValue.setValue(param.get(matField.getName()).toString()); + locDetlFieldService.updateById(fieldValue); + } + } + } } } -- Gitblit v1.9.1