1.导入自动解析主体、车间以及产线
2.增加搜索字段
|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | String aa = "[{\"batch\":\"2023090304\",\"packageNo\":\"8\"},{\"batch\":\"2023090304\",\"packageNo\":\"8\"}]"; | 
|---|
|  |  |  | JSONArray jsonArray = JSON.parseArray(aa); | 
|---|
|  |  |  | Object o = jsonArray.get(0); | 
|---|
|  |  |  | System.out.println(o.toString()); | 
|---|
|  |  |  | JSONObject jsonObject = (JSONObject)o; | 
|---|
|  |  |  | System.out.println(jsonObject); | 
|---|
|  |  |  | //        String aa = "[{\"batch\":\"2023090304\",\"packageNo\":\"8\"},{\"batch\":\"2023090304\",\"packageNo\":\"8\"}]"; | 
|---|
|  |  |  | //        JSONArray jsonArray = JSON.parseArray(aa); | 
|---|
|  |  |  | //        Object o = jsonArray.get(0); | 
|---|
|  |  |  | //        System.out.println(o.toString()); | 
|---|
|  |  |  | //        JSONObject jsonObject = (JSONObject)o; | 
|---|
|  |  |  | //        System.out.println(jsonObject); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String s = "2024010502"; | 
|---|
|  |  |  | System.out.println(s.substring(8,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 | 
|---|
|  |  |  | public class PlaController extends BaseController { | 
|---|
|  |  |  | 
|---|
|  |  |  | private OrderDetlService orderDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlaLogService plaLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/pla/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("解除冻结成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * excel导入模板下载 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | @TableField("stock_freeze_date") | 
|---|
|  |  |  | private Date stockFreezeDate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getCreateTime$() { | 
|---|
|  |  |  | if (Cools.isEmpty(this.createTime)){ | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new SimpleDateFormat("yyyy-MM-dd").format(this.createTime); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getPakinTime$() { | 
|---|
|  |  |  | if (Cools.isEmpty(this.pakinTime)){ | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.pakinTime); | 
|---|
|  |  |  | return new SimpleDateFormat("yyyy-MM-dd HH").format(this.pakinTime); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getStockFreezeDate$() { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Mat selectByMatnr(String matnr); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Mat selectByMaktx(String maktx); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<Mat> selectAllPage(Page<Mat> matPage); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.plugins.Page; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.entity.ManLocDetl; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Mat selectByMaktx(String maktx) { | 
|---|
|  |  |  | return this.selectOne(new EntityWrapper<Mat>().eq("maktx",maktx)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Page<Mat> selectAllPage(Page<Mat> matPage) { | 
|---|
|  |  |  | Map<String, Object> condition = matPage.getCondition(); | 
|---|
|  |  |  | List<Mat> manLocDetls = baseMapper.selectAllPage(condition); | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.SpringUtils; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.Mat; | 
|---|
|  |  |  | import com.zy.asrs.entity.Node; | 
|---|
|  |  |  | import com.zy.asrs.entity.Pla; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.GlobleParameter; | 
|---|
|  |  |  | import com.zy.asrs.service.MatService; | 
|---|
|  |  |  | import com.zy.asrs.service.NodeService; | 
|---|
|  |  |  | import com.zy.asrs.service.PlaService; | 
|---|
|  |  |  | import com.zy.common.entity.MatExcel; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class PlaExcelListener extends AnalysisEventListener<PlaExcel> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final String OWNER_HZ = "海正生物"; | 
|---|
|  |  |  | private static final String OWNER_HNE = "海诺尔"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private int total = 0; | 
|---|
|  |  |  | private Long userId; | 
|---|
|  |  |  | 
|---|
|  |  |  | public void invoke(PlaExcel excel, AnalysisContext ctx) { | 
|---|
|  |  |  | PlaService plaService = SpringUtils.getBean(PlaService.class); | 
|---|
|  |  |  | NodeService nodeService = SpringUtils.getBean(NodeService.class); | 
|---|
|  |  |  | MatService matService = SpringUtils.getBean(MatService.class); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 商品 | 
|---|
|  |  |  | 
|---|
|  |  |  | pla.setModifyTime(new Date()); | 
|---|
|  |  |  | pla.setStatus(GlobleParameter.PLA_STATUS_00); | 
|---|
|  |  |  | pla.setStockFreeze(1); | 
|---|
|  |  |  | pla.setWeightAnfme(pla.getWeight()); | 
|---|
|  |  |  | Mat mat = matService.selectByMaktx(pla.getBrand()); | 
|---|
|  |  |  | if(Cools.isEmpty(mat)){ | 
|---|
|  |  |  | throw new CoolException("无法找到对应的牌号信息,牌号=" + pla.getBrand()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pla.setMatnr(mat.getMatnr()); | 
|---|
|  |  |  | pla.setType(getType(mat.getMatnr())); | 
|---|
|  |  |  | //车间、产线、主体 | 
|---|
|  |  |  | setPla(pla); | 
|---|
|  |  |  | if(!Cools.isEmpty(pla.getLocNo())){ | 
|---|
|  |  |  | Node node = nodeService.selectByUuid(pla.getLocNo()); | 
|---|
|  |  |  | if(Cools.isEmpty(node)){ | 
|---|
|  |  |  | throw new CoolException("未能找到相应的库位信息"); | 
|---|
|  |  |  | throw new CoolException("未能找到相应的库位信息,库位编号=" +pla.getLocNo()); | 
|---|
|  |  |  | //log.info("未能找到相应的库位信息,库位编号={}",pla.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | pla.setStash(node.getParentName()); | 
|---|
|  |  |  | pla.setLocNo(node.getUuid()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String getType(String matnr){ | 
|---|
|  |  |  | String type = matnr.substring(0,3); | 
|---|
|  |  |  | if(Cools.eq(type,"301")){ | 
|---|
|  |  |  | return "纯树脂"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.eq(type,"302")){ | 
|---|
|  |  |  | return "改性树脂"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.eq(type,"303")){ | 
|---|
|  |  |  | return "副产物"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.eq(type,"304")){ | 
|---|
|  |  |  | return "委托加工产品"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.eq(type,"305")){ | 
|---|
|  |  |  | return "丙交酯"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void setPla(Pla pla){ | 
|---|
|  |  |  | String batch = pla.getBatch(); | 
|---|
|  |  |  | String line = batch.substring(8,10); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | pla.setLine(line); | 
|---|
|  |  |  | if("纯树脂".equals(pla.getType())){ | 
|---|
|  |  |  | if("01".equals(line) || "02".equals(line)){ | 
|---|
|  |  |  | pla.setOwner(OWNER_HZ); | 
|---|
|  |  |  | pla.setWorkshop("一车间"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | pla.setOwner(OWNER_HNE); | 
|---|
|  |  |  | pla.setWorkshop("三车间"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if ("改性树脂".equals(pla.getType())){ | 
|---|
|  |  |  | if ("01".equals(line) || "02".equals(line) || "03".equals(line) || "04".equals(line)){ | 
|---|
|  |  |  | pla.setOwner(OWNER_HNE); | 
|---|
|  |  |  | pla.setWorkshop("二车间"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 所有数据解析完成了调用 | 
|---|
|  |  |  | * 适合事务 | 
|---|
|  |  |  | 
|---|
|  |  |  | ,{field: 'stockFreezeBy', align: 'center',title: '操作人员',hide:true} | 
|---|
|  |  |  | ,{field: 'stockFreezeDate$', align: 'center',title: '操作日期',hide:true} | 
|---|
|  |  |  | ,{align: 'center', title: '流转明细', toolbar: '#tbLook'} | 
|---|
|  |  |  | ,{field: 'createTime$', title: '创建时间', align: 'center' , sort:true} | 
|---|
|  |  |  | // ,{field: 'orderNo', align: 'center',title: '单号', hide:true} | 
|---|
|  |  |  | // ,{field: 'pakoutTime', align: 'center',title: '出库时间', hide:true} | 
|---|
|  |  |  | // ,{field: 'orderWeight', align: 'center',title: '重量', hide:true} | 
|---|
|  |  |  | 
|---|
|  |  |  | base: baseUrl + "/static/layui/lay/modules/" | 
|---|
|  |  |  | }).extend({ | 
|---|
|  |  |  | dropdown: 'dropdown/dropdown', | 
|---|
|  |  |  | }).use(['table','laydate', 'form', 'admin', 'dropdown'], function() { | 
|---|
|  |  |  | }).use(['table','laydate', 'form', 'admin', 'dropdown', 'laydate'], function() { | 
|---|
|  |  |  | var table = layui.table; | 
|---|
|  |  |  | var $ = layui.jquery; | 
|---|
|  |  |  | var layer = layui.layer; | 
|---|
|  |  |  | 
|---|
|  |  |  | $('.layui-table-header .layui-table').css('transform', left); //设置表格header的内容反向(-)移动 | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | layDate.render({ | 
|---|
|  |  |  | elem: '.layui-laydate-range' | 
|---|
|  |  |  | ,type: 'datetime' | 
|---|
|  |  |  | ,range: true | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | table.on('tool(plaDetl)', function (obj) { | 
|---|
|  |  |  | var data = obj.data; | 
|---|
|  |  |  | var layEvent = obj.event; | 
|---|
|  |  |  | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-inline"> | 
|---|
|  |  |  | <div class="layui-input-inline cool-auto-complete"> | 
|---|
|  |  |  | <input id="maktx" class="layui-input" type="text" style="display: none"> | 
|---|
|  |  |  | <input id="maktxV" name="brand" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" placeholder="牌号" type="text" onfocus=this.blur()> | 
|---|
|  |  |  | <div class="cool-auto-complete-window"> | 
|---|
|  |  |  | <input class="cool-auto-complete-window-input" data-key="matMaktxQueryByMaktx" onkeyup="autoLoad(this.getAttribute('data-key'))"> | 
|---|
|  |  |  | <select class="cool-auto-complete-window-select" data-key="matMaktxQueryByMaktxSelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-inline"> | 
|---|
|  |  |  | <div class="layui-input-inline"> | 
|---|
|  |  |  | <input class="layui-input" type="text" name="brand" placeholder="牌号" autocomplete="off"> | 
|---|
|  |  |  | <input class="layui-input" type="text" name="type" placeholder="物资类别" autocomplete="off"> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-inline"> | 
|---|
|  |  |  | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--    <div class="layui-inline">--> | 
|---|
|  |  |  | <!--        <div class="layui-input-inline">--> | 
|---|
|  |  |  | <!--            <input class="layui-input" type="text" name="row" placeholder="排数" autocomplete="off">--> | 
|---|
|  |  |  | <!--        </div>--> | 
|---|
|  |  |  | <!--    </div>--> | 
|---|
|  |  |  | <div class="layui-inline" style="width: 300px"> | 
|---|
|  |  |  | <div class="layui-input-inline"> | 
|---|
|  |  |  | <input class="layui-input layui-laydate-range" name="create_time" type="text" placeholder="起始时间 - 终止时间" autocomplete="off" style="width: 300px"> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <div class="layui-inline"> | 
|---|
|  |  |  | <div class="layui-input-inline"> | 
|---|
|  |  |  | <input class="layui-input" type="text" name="condition" placeholder="请输入" autocomplete="off"> | 
|---|