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<PwExcel> 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<DmYdjh> ydjhList=new ArrayList<>(); + String date=DateUtil.date().toString("yyyy/MM/dd HH:mm:ss"); + List<YcldwInfo> 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<YcldwInfo> 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<PwExcel> { + + private static final int BATCH_COUNT = 500; + + @Getter + List<PwExcel> objectList = new ArrayList<>(); + List<Object> headList = new ArrayList<>(); + + List<PwExcel> 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<Integer, String> 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 @@ <result column="bfr" property="bfr" jdbcType="VARCHAR" /> <result column="bfrq" property="bfrq" jdbcType="VARCHAR" /> <result column="zt" property="zt" jdbcType="VARCHAR" /> + <result column="ydid" property="ydid" jdbcType="VARCHAR" /> </collection> </resultMap> <sql id="ycldwInfo" > 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 </sql> <select id="ycldwList" resultMap="ycldwVo">