From 0c0cd17fb9162c0c949c354adcd422d605aad7b9 Mon Sep 17 00:00:00 2001 From: zyx <zyx123456> Date: 星期一, 15 四月 2024 16:11:32 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/PlaController.java | 129 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 119 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/PlaController.java b/src/main/java/com/zy/asrs/controller/PlaController.java index 4b7c317..da4ebed 100644 --- a/src/main/java/com/zy/asrs/controller/PlaController.java +++ b/src/main/java/com/zy/asrs/controller/PlaController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.core.annotations.ManagerAuth; +import com.core.common.Cools; import com.core.common.DateUtils; import com.core.common.R; import com.core.exception.CoolException; @@ -13,9 +14,11 @@ import com.zy.asrs.service.*; import com.zy.asrs.utils.PlaExcelListener; import com.zy.asrs.utils.SaasUtils; +import com.zy.common.CodeRes; import com.zy.common.entity.PlaExcel; import com.zy.common.web.BaseController; import lombok.Synchronized; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -25,12 +28,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; @RestController +@Slf4j public class PlaController extends BaseController { @Autowired @@ -45,6 +46,8 @@ private OrderDetlService orderDetlService; @Autowired private PlaLogService plaLogService; + @Autowired + private MatService matService; @RequestMapping(value = "/pla/list/auth") @ManagerAuth @@ -54,8 +57,19 @@ @RequestParam Map<String, Object> param){ excludeTrash(param); EntityWrapper<Pla> wrapper = new EntityWrapper<>(); + + if(!Cools.isEmpty(param.get("brand"))){ + wrapper.eq("brand",param.get("brand")); + param.remove("brand"); + } + // 娌℃湁閫夋嫨鐨勬椂鍊欓粯璁や笉鏄剧ず宸插嚭搴撶殑鐗╂枡 + if (Cools.isEmpty(param.get("status"))) { + wrapper.ne("status", "鍏ㄩ儴鍑哄簱"); + } + + convert(param, wrapper); - wrapper.orderBy("modify_time",false); + wrapper.orderBy("batch",true).orderBy("package_no" ,true); allLike(Pla.class, param.keySet(), wrapper, condition); return R.ok(plaService.selectPage(new Page<>(curr, limit), wrapper)); } @@ -83,6 +97,7 @@ BeanUtils.copyProperties(plaSave,plaLog); plaLog.setId(null); plaLog.setCreateTime(new Date()); + plaLog.setModifyUser(getUser().getUsername()); plaLogService.insert(plaLog); }); @@ -94,8 +109,8 @@ public R delete(@RequestBody List<Pla> plas) { System.out.println(plas.toString()); plas.forEach(pla -> { - if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) || pla.getStatus().equals(GlobleParameter.PLA_STATUS_0)){ - throw new CoolException("闈炲緟鍏ュ簱鐨勬暟鎹棤娉曡鍒犻櫎"); + if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_0) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_1)){ + throw new CoolException("宸插叆搴撶殑鏁版嵁鏃犳硶琚垹闄�"); } Pla plaSave = plaService.selectById(pla.getId()); pla.setModifyTime(new Date()); @@ -105,6 +120,7 @@ BeanUtils.copyProperties(plaSave,plaLog); plaLog.setId(null); plaLog.setCreateTime(new Date()); + plaLog.setModifyUser(getUser().getUsername()); plaLogService.insert(plaLog); }); @@ -130,6 +146,10 @@ OrderDetl orderDetl = orderDetlService.selectByOrderNoAndMaktx(orderNo, maktx); for (Pla pla : plas){ + + if(pla.getStockFreeze() == 0){ + throw new CoolException("搴撳瓨宸茶鍐荤粨锛岃閲嶆柊閫夋嫨搴撳瓨"); + } allOrderWeight += pla.getOrderWeight(); @@ -193,10 +213,81 @@ pla.setModifyTime(new Date()); pla.setWeightAnfme(0.0); plaService.updateById(pla); - SaasUtils.insertLog(1,pla.getLocNo(),pla.getBatch()+","+pla.getPackageNo(),anfme,getUser().getUsername()); + SaasUtils.insertLog(1,pla.getLocNo(),pla.getBrand(),anfme,getUser().getUsername(), + null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop()); }); return R.ok(); + } + + @RequestMapping(value = "/pla/updateStockFreeze") + @Transactional + @ManagerAuth(memo = "搴撲綅鍐荤粨") + public R updateStockFreeze(@RequestBody List<Pla> plas){ + if (Cools.isEmpty(plas)){ + return R.error("鏃犳暟鎹�"); + } + for (Pla pla : plas){ + if (pla.getStockFreeze() == 0){ + throw new CoolException("搴撳瓨宸茶鍐荤粨锛�"); + } + pla.setStockFreeze(0); + pla.setStockFreezeBy(getUser().getUsername()); + pla.setStockFreezeDate(new Date()); + pla.setModifyTime(new Date()); + plaService.updateById(pla); + } + return R.ok("鍐荤粨鎴愬姛"); + } + + @RequestMapping(value = "/pla/updateStockDisFreeze") + @ManagerAuth(memo = "搴撲綅瑙e喕") + public R updateStockDisFreeze(@RequestBody List<Pla> plas){ + if (Cools.isEmpty(plas)){ + return R.error("鏃犳暟鎹�"); + } + for (Pla pla : plas){ + if (pla.getStockFreeze() == 1){ + throw new CoolException("搴撲綅鏈喕缁擄紝鏃犻渶瑙e喕"); + } + if(!Cools.eq(pla.getStockFreezeBy(),getUser().getUsername())){ + throw new CoolException("鏃犳硶瑙e喕鍏朵粬鐢ㄦ埛鍐荤粨鐨勫簱浣�"); + } + pla.setStockFreeze(1); + pla.setStockFreezeBy(getUser().getUsername()); + pla.setStockFreezeDate(new Date()); + pla.setModifyTime(new Date()); + plaService.updateById(pla); + + } + return R.ok("瑙i櫎鍐荤粨鎴愬姛"); + } + + @RequestMapping(value = "/matMaktxQuery/auth") + @ManagerAuth + public R queryMat(String condition) { + EntityWrapper<Mat> wrapper = new EntityWrapper<>(); + wrapper.like("maktx", condition); + Page<Mat> page = matService.selectPage(new Page<>(0, 10), wrapper); + List<Map<String, Object>> result = new ArrayList<>(); + for (Mat mat : page.getRecords()){ + Map<String, Object> map = new HashMap<>(); + map.put("id", mat.getMaktx()); + map.put("value", mat.getMaktx()); + result.add(map); + } + return R.ok(result); + } + + @RequestMapping(value = "/pla/statis/auth") + @ManagerAuth + public R statis(@RequestParam(defaultValue = "1")Integer curr, + @RequestParam(defaultValue = "10")Integer limit, + @RequestParam Map<String, Object> param) { + + Page<Pla> stockStatis = plaService.getStockStatisAll(toPage(curr, limit, param, Pla.class)); + + return R.ok().add(stockStatis); } /** @@ -224,9 +315,26 @@ try { EasyExcel.read(file.getInputStream(), PlaExcel.class, listener).sheet().doRead(); }catch (Exception e){ - throw new CoolException("瀵煎叆鐨勬暟鎹牸寮忛敊璇紝鍘熷洜锛�" + e.getMessage()); + e.printStackTrace(); + int index = listener.getIndex() - 1; + throw new CoolException("瀵煎叆鐨勬暟鎹牸寮忛敊璇紝鍘熷洜锛�" + e.getMessage() + "锛岀" + index + "锛屾暟鎹牸寮忎笉瀵�"); } + log.info("瀵煎叆淇敼淇℃伅杈撳嚭锛�" + listener.getRecordLog()); return R.ok("鎴愬姛鍚屾"+listener.getTotal()+"鏉la鐗╂枡鏁版嵁"); + } + + // 鎵撳嵃 + @RequestMapping(value = "/pla/print/auth") + @ManagerAuth(memo = "pla缂栫爜鎵撳嵃") + public R matCodePrint(@RequestBody List<Pla> plas) { + if(Cools.isEmpty(plas)) { + return R.parse(CodeRes.EMPTY); + } + List<Pla> res = new ArrayList<>(); + for (Pla pla : plas){ + res.add(pla); + } + return R.ok().add(res); } private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ @@ -254,7 +362,7 @@ manPakOut.setMaktx(plaQty.getBrand()); manPakOut.setLocNo(plaQty.getLocNo()); manPakOut.setBatch(plaQty.getBatch()); - manPakOut.setBarcode(plaQty.getPackageNo()); + manPakOut.setBarcode(plaQty.getPackageNo() + ""); manPakOut.setUuid(String.valueOf(System.currentTimeMillis())); manPakOut.setCreateTime(new Date()); manPakOut.setUpdateTime(new Date()); @@ -263,6 +371,7 @@ manPakOut.setStatus(0); manPakOut.setDocId(plaQty.getOrderDetlId()); manPakOut.setNodeId(plaQty.getId()); + manPakOut.setCustName(plaQty.getCustomer()); //manPakOut.setNodeId(plaQty.getOrderDetlId()); manPakOutService.insert(manPakOut); return R.ok(); -- Gitblit v1.9.1