From 855a58b58bc9d4f8b4cc71f28d99e0b4a82febc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=93=B2=E5=A5=87?= <13840175730@139.com> Date: Sun, 1 Dec 2024 16:44:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4=E6=8A=9B=E4=B8=B8=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5=E9=80=BB=E8=BE=91,=E6=A0=B9=E6=8D=AE=E5=9E=9B?= =?UTF-8?q?=E4=BD=8D=E7=82=B9=E5=87=BB=E5=90=8E=E5=8B=BE=E9=80=89=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5,=E6=B4=BE=E5=B7=A5=E5=AE=8C=E6=88=90=E5=AF=BC?= =?UTF-8?q?=E5=87=BAexcel=E4=BE=9B=E6=8A=9B=E4=B8=B8=E4=BD=BF=E7=94=A8=202?= =?UTF-8?q?.=E4=BF=AE=E6=94=B9=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3ws=E6=9C=8D=E5=8A=A1=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dsic/gj_erp/bean/zyjh/PwExcel.java | 27 +++++++++ .../com/dsic/gj_erp/bean/zyjh/YcldwInfo.java | 14 ++++- .../controller/zyjh/ZyjhController.java | 42 +++++++++++++- .../gj_erp/controller/zyjh/dto/PwpgDto.java | 15 +++++ .../gj_erp/listeners/ExcelPwListener.java | 57 +++++++++++++++++++ src/main/resources/application-localws.yml | 2 +- src/main/resources/application-ws.yml | 2 +- .../resources/mappers/zyjh/YcldwMapper.xml | 3 +- 8 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/dsic/gj_erp/bean/zyjh/PwExcel.java create mode 100644 src/main/java/com/dsic/gj_erp/controller/zyjh/dto/PwpgDto.java create mode 100644 src/main/java/com/dsic/gj_erp/listeners/ExcelPwListener.java diff --git a/src/main/java/com/dsic/gj_erp/bean/zyjh/PwExcel.java b/src/main/java/com/dsic/gj_erp/bean/zyjh/PwExcel.java new file mode 100644 index 0000000..c8823e7 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/bean/zyjh/PwExcel.java @@ -0,0 +1,27 @@ +package com.dsic.gj_erp.bean.zyjh; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class PwExcel { + + @ExcelProperty(value = "船号") + public String dcCh; + + @ExcelProperty(value = "批量") + public String dcPl; + + @ExcelProperty(value = "分段") + public String dcFd; + + @ExcelProperty(value = "套料图") + public String tlth; + + @ExcelProperty(value = "备注") + public String bz; + + public int dataOrder; +} diff --git a/src/main/java/com/dsic/gj_erp/bean/zyjh/YcldwInfo.java b/src/main/java/com/dsic/gj_erp/bean/zyjh/YcldwInfo.java index b08bb4f..6cfca3f 100644 --- a/src/main/java/com/dsic/gj_erp/bean/zyjh/YcldwInfo.java +++ b/src/main/java/com/dsic/gj_erp/bean/zyjh/YcldwInfo.java @@ -44,6 +44,13 @@ public class YcldwInfo { return info; } + public static YcldwInfo ofPwpg(YcldwInfo info){ + YcldwInfo info1=new YcldwInfo(); + info1.setId(info.getId()); + info1.pwpg(); + return info1; + } + private void sl(){ this.bfrq= DateUtil.date().toString("yyyy/MM/dd"); this.baifang(); @@ -53,11 +60,16 @@ public class YcldwInfo { this.zt=ZtEnum.BF; } + private void pwpg(){ + this.zt=ZtEnum.PG; + } + public void paowan(){ this.zt=ZtEnum.PW; } private enum ZtEnum{ - BF,PW + //摆放,派工,抛丸 + BF,PG,PW } } diff --git a/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java b/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java index 6e76507..1966b1c 100644 --- a/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java +++ b/src/main/java/com/dsic/gj_erp/controller/zyjh/ZyjhController.java @@ -3,15 +3,19 @@ package com.dsic.gj_erp.controller.zyjh; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.dsic.gj_erp.annotation.AuthFunction; import com.dsic.gj_erp.bean.ResultBean; import com.dsic.gj_erp.bean.jhgk.DmYdjh; +import com.dsic.gj_erp.bean.jhgk.excel.GdxqExcel; +import com.dsic.gj_erp.bean.zyjh.PwExcel; import com.dsic.gj_erp.bean.zyjh.Ycldw; import com.dsic.gj_erp.bean.zyjh.YcldwInfo; import com.dsic.gj_erp.controller.zyjh.dto.*; import com.dsic.gj_erp.exception.ServiceException; +import com.dsic.gj_erp.listeners.ExcelPwListener; import com.dsic.gj_erp.service.zyjh.YcldwInfoService; import com.dsic.gj_erp.service.zyjh.YcldwService; import com.dsic.gj_erp.service.zyjh.ZyjhService; @@ -21,10 +25,14 @@ import com.dsic.gj_erp.wsclient.WebSocketService; import lombok.AllArgsConstructor; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; +import java.io.IOException; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @RestController @RequestMapping("zyjh") @@ -41,6 +49,18 @@ public class ZyjhController { private final WebSocketService webSocketService; + /** + * 抛丸导入 + */ + @PostMapping("pwdr") + public ResultBean pwdr(MultipartFile file) throws IOException { + ExcelPwListener excelPwListener = new ExcelPwListener(); + EasyExcel.read(file.getInputStream(), GdxqExcel.class, excelPwListener).sheet(0).headRowNumber(1).doRead(); + List objList = excelPwListener.getObjectList(); + + return new ResultBean<>(); + } + /** * 根据状态或班组长,获取作业计划,用于报工 */ @@ -85,6 +105,27 @@ public class ZyjhController { return new ResultBean<>(zyjhService.getForeman(zyq)); } + /** + * 抛丸派工 + */ + @PostMapping("pwpg") + @Transactional(rollbackFor = Exception.class) + public ResultBean pwpg(@RequestBody PwpgDto dto){ + List ydjhList=new ArrayList<>(); + String date=DateUtil.date().toString("yyyy/MM/dd HH:mm:ss"); + List collect = dto.getList().stream().map(item -> { + DmYdjh dmYdjh = new DmYdjh(); + dmYdjh.setId(item.getYdid()); + dmYdjh.setPwpgry(dto.getWorker()); + dmYdjh.setPwpgrq(date); + ydjhList.add(dmYdjh); + return YcldwInfo.ofPwpg(item); + }).collect(Collectors.toList()); + ycldwInfoService.updateBatchById(collect); + zyjhService.updateBatchById(ydjhList); + return new ResultBean<>(); + } + /** * 作业计划执行,派工&反馈 */ @@ -283,7 +324,6 @@ public class ZyjhController { return new ResultBean<>(list); } - /** * 获取预处理垛位信息 */ diff --git a/src/main/java/com/dsic/gj_erp/controller/zyjh/dto/PwpgDto.java b/src/main/java/com/dsic/gj_erp/controller/zyjh/dto/PwpgDto.java new file mode 100644 index 0000000..9689308 --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/controller/zyjh/dto/PwpgDto.java @@ -0,0 +1,15 @@ +package com.dsic.gj_erp.controller.zyjh.dto; + +import com.dsic.gj_erp.bean.zyjh.YcldwInfo; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class PwpgDto { + + private String worker; + private List list; +} diff --git a/src/main/java/com/dsic/gj_erp/listeners/ExcelPwListener.java b/src/main/java/com/dsic/gj_erp/listeners/ExcelPwListener.java new file mode 100644 index 0000000..ebc0e2b --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/listeners/ExcelPwListener.java @@ -0,0 +1,57 @@ +package com.dsic.gj_erp.listeners; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.dsic.gj_erp.bean.zyjh.PwExcel; +import com.dsic.gj_erp.util.ObjConvertUtils; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Excel通用监听器 + */ +public class ExcelPwListener extends AnalysisEventListener { + + private static final int BATCH_COUNT = 500; + + @Getter + List objectList = new ArrayList<>(); + List headList = new ArrayList<>(); + + List datas = new ArrayList<>(); + + @Override + public void invoke(PwExcel excelDemo, AnalysisContext analysisContext) { + boolean b = ObjConvertUtils.checkObjAllFieldsIsNull(excelDemo); + if(!b){ + datas.add(excelDemo); + } + + if (datas.size() >= BATCH_COUNT) { + saveData(); + datas.clear(); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + } + + //获取表头 + @Override + public void invokeHeadMap(Map headMap, AnalysisContext context) { + headList.add(headMap); + } + + /** + * 入库 + */ + private void saveData() { + objectList.addAll(datas); + } + +} diff --git a/src/main/resources/application-localws.yml b/src/main/resources/application-localws.yml index fbc2ea4..9674cc9 100644 --- a/src/main/resources/application-localws.yml +++ b/src/main/resources/application-localws.yml @@ -9,5 +9,5 @@ ws: maxHttpContentLength: 1048576 maxFramePayloadLength: 1048576 client: - url: ws://192.168.18.1:9000 + url: ws://192.168.13.10:9000 id: 100000000001 \ No newline at end of file diff --git a/src/main/resources/application-ws.yml b/src/main/resources/application-ws.yml index c6a5680..0616ec5 100644 --- a/src/main/resources/application-ws.yml +++ b/src/main/resources/application-ws.yml @@ -9,5 +9,5 @@ ws: maxHttpContentLength: 1048576 maxFramePayloadLength: 1048576 client: - url: ws://127.0.0.1:9000 + url: ws://192.127.2.199:9000 id: 100000000001 \ No newline at end of file diff --git a/src/main/resources/mappers/zyjh/YcldwMapper.xml b/src/main/resources/mappers/zyjh/YcldwMapper.xml index 77cee38..b57409d 100644 --- a/src/main/resources/mappers/zyjh/YcldwMapper.xml +++ b/src/main/resources/mappers/zyjh/YcldwMapper.xml @@ -24,13 +24,14 @@ + b.id info_id,b.dw_id info_dw_id,b.ceng info_ceng,b.czbh info_czbh,b.pl info_pl,b.fd info_fd,b.kw info_kw,b.zl info_zl, b.tlth info_tlth,b.wpgg info_wpgg,b.wph info_wph,b.sljhrq info_sljhrq,b.qgjhrq info_qgjhrq,b.bfr info_bfr, - b.bfrq info_bfrq,b.zt info_zt + b.bfrq info_bfrq,b.zt info_zt,b.ydid info_ydid