| | |
| | | package com.zy.asrs.common.domain.dto; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.common.wms.entity.LocDetl; |
| | | import com.zy.asrs.common.wms.service.LocDetlService; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/25 |
| | |
| | | @Data |
| | | public class SafeStoDo { |
| | | |
| | | private Long node_id; |
| | | private Long id; |
| | | |
| | | private String node_name; |
| | | private String locNo; |
| | | |
| | | private String matnr; |
| | | |
| | | private String maktx; |
| | | |
| | | private Double safe_qua; |
| | | private Double safeQua; |
| | | |
| | | private Double amount; |
| | | private Long hostId; |
| | | |
| | | private String progress; |
| | | public String getLocNo$() { |
| | | if (this.locNo == null) { |
| | | return "全部"; |
| | | } |
| | | return this.locNo; |
| | | } |
| | | |
| | | private Integer status; |
| | | public Double getAmount() { |
| | | Double sum = 0.0; |
| | | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | LambdaQueryWrapper<LocDetl> wrapper = new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getMatnr, this.matnr).eq(LocDetl::getHostId, this.hostId); |
| | | if (this.locNo != null) { |
| | | wrapper.eq(LocDetl::getLocNo, this.locNo); |
| | | } |
| | | List<LocDetl> list = locDetlService.list(wrapper); |
| | | for (LocDetl locDetl : list) { |
| | | sum += locDetl.getAnfme(); |
| | | } |
| | | return sum; |
| | | } |
| | | |
| | | public Integer getStatus() { |
| | | Integer status = 1; |
| | | Double amount = getAmount(); |
| | | double percent = amount / safeQua; |
| | | if (percent >= 1) { |
| | | status = 1;//满仓 |
| | | } else if (percent >= 0.75) { |
| | | status = 2;//安全 |
| | | }else { |
| | | status = 3;//危险 |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | public String getProgress() { |
| | | Double amount = getAmount(); |
| | | double percent = (amount / safeQua) * 100; |
| | | return String.valueOf(percent) + "%"; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.common.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/5/3 |
| | | */ |
| | | @Data |
| | | public class SafeStoDto { |
| | | |
| | | private Long id; |
| | | |
| | | private String locNo; |
| | | |
| | | private String nodeName; |
| | | |
| | | private Long matId; |
| | | |
| | | private String matnr; |
| | | |
| | | private Double safeQua; |
| | | |
| | | private String memo; |
| | | |
| | | } |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @RequestMapping(value = "/node/tree/auth") |
| | | @ManagerAuth |
| | | public R tree(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | LambdaQueryWrapper<Node> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Node::getHostId, getHostId()); |
| | | return R.parse("0-操作成功").add(nodeService.list(wrapper)); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("wms_loc_mast") |
| | | @TableName("common_loc_mast") |
| | | public class LocMast implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | private String maktx; |
| | | |
| | | /** |
| | | * 关联货位 |
| | | * 库位号 |
| | | */ |
| | | @ApiModelProperty(value= "关联货位") |
| | | private Long nodeId; |
| | | |
| | | /** |
| | | * 货位名称 |
| | | */ |
| | | @ApiModelProperty(value= "货位名称") |
| | | private String nodeName; |
| | | @ApiModelProperty(value= "库位号") |
| | | private String locNo; |
| | | |
| | | /** |
| | | * 安全库存 |
| | |
| | | |
| | | public Prior() {} |
| | | |
| | | public Prior(String uuid,String name,Long matId,String matnr,String maktx,Long nodeId,String nodeName,Double safeQua,Integer prio,String barcode,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | public Prior(String uuid,String name,Long matId,String matnr,String maktx,String locNo,Double safeQua,Integer prio,String barcode,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.uuid = uuid; |
| | | this.name = name; |
| | | this.matId = matId; |
| | | this.matnr = matnr; |
| | | this.maktx = maktx; |
| | | this.nodeId = nodeId; |
| | | this.nodeName = nodeName; |
| | | this.locNo = locNo; |
| | | this.safeQua = safeQua; |
| | | this.prio = prio; |
| | | this.barcode = barcode; |
| | |
| | | |
| | | <sql id="pageCondition"> |
| | | <if test="map.host_id != null and map.host_id != ''"> |
| | | and mp0.host_id = #{map.host_id} |
| | | and host_id = #{map.host_id} |
| | | </if> |
| | | <if test="map.matnr != null and map.matnr != ''"> |
| | | and mp0.matnr like concat('%',#{map.matnr},'%') |
| | | and matnr like concat('%',#{map.matnr},'%') |
| | | </if> |
| | | <if test="map.maktx != null and map.maktx != ''"> |
| | | and mp0.maktx like concat('%',#{map.maktx},'%') |
| | | and maktx like concat('%',#{map.maktx},'%') |
| | | </if> |
| | | <if test="map.node_id != null and map.node_id != ''"> |
| | | and mp0.node_id like concat('%',#{map.node_id},'%') |
| | | <if test="map.loc_no != null and map.loc_no != ''"> |
| | | and loc_no like concat('%',#{map.loc_no},'%') |
| | | </if> |
| | | </sql> |
| | | |
| | | <select id="selectSafeStoPage" resultType="com.zy.asrs.common.domain.dto.SafeStoDo"> |
| | | select |
| | | mp0.node_id, |
| | | mp0.node_name, |
| | | mp0.matnr, |
| | | mp0.maktx, |
| | | mp0.safe_qua, |
| | | ISNULL(dual.amount, 0) as amount, |
| | | ISNULL((cast(round((dual.amount/(mp0.safe_qua*1.0))*100,2) as varchar)+'%'), '0.00%') as progress, |
| | | case |
| | | when isnull(round((dual.amount/mp0.safe_qua),2),0) >= 1 then 1 |
| | | when isnull(round((dual.amount/mp0.safe_qua),2),0) > 0.75 then 2 |
| | | else 3 |
| | | end as status |
| | | from wms_prior mp0 |
| | | left join |
| | | ( |
| | | select |
| | | mp.node_id, |
| | | mp.matnr, |
| | | ISNULL(sum(ls.amount), 0) as amount |
| | | from wms_prior mp |
| | | left join |
| | | ( |
| | | select |
| | | mld.node_id, |
| | | mn.path, |
| | | mld.matnr, |
| | | sum(mld.anfme) as amount |
| | | from wms_loc_detl mld |
| | | left join wms_node mn on mld.node_id = mn.id |
| | | group by mld.node_id, mld.matnr, mn.path |
| | | ) as ls on ls.matnr = mp.matnr and (ls.node_id = mp.node_id or CHARINDEX(','+cast(mp.node_id as varchar)+',', ','+ls.path+',') > 0) |
| | | group by mp.node_id, mp.matnr |
| | | ) as dual on mp0.node_id = dual.node_id and mp0.matnr = dual.matnr |
| | | select * from wms_prior |
| | | where 1=1 |
| | | <include refid="pageCondition"></include> |
| | | </select> |
| | |
| | | LambdaQueryWrapper<Mat> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Mat::getHostId, getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(Mat::getId, condition); |
| | | wrapper.like(Mat::getMatnr, condition); |
| | | } |
| | | matService.page(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(item.getMatnr(), item.getId()))); |
| | | return R.ok().add(vos); |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.common.domain.dto.SafeStoDo; |
| | | import com.zy.asrs.common.domain.dto.SafeStoDto; |
| | | import com.zy.asrs.common.wms.entity.Mat; |
| | | import com.zy.asrs.common.wms.entity.Prior; |
| | | import com.zy.asrs.common.wms.service.MatService; |
| | | import com.zy.asrs.common.wms.service.PriorService; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.common.*; |
| | | import com.zy.asrs.framework.domain.KeyValueVo; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.common.web.BaseController; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | |
| | | |
| | | @Autowired |
| | | private PriorService priorService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | @RequestMapping(value = "/prior/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | if (hostId != null) { |
| | | param.put("host_id", hostId); |
| | | } |
| | | return R.ok(priorService.getSafeQtyPage(curr, limit, param)); |
| | | IPage<SafeStoDo> safeQtyPage = priorService.getSafeQtyPage(curr, limit, param); |
| | | return R.ok(safeQtyPage); |
| | | } |
| | | |
| | | @RequestMapping(value = "/safeSto/add/auth") |
| | | @ManagerAuth(memo = "添加安全库存") |
| | | public R del(@RequestBody SafeStoDto dto){ |
| | | if (Cools.isEmpty(dto.getMatId(), dto.getSafeQua())) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (dto.getSafeQua() <= 0.0D) { |
| | | return R.error("安全库存量必须大于零"); |
| | | } |
| | | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getId, dto.getMatId()).eq(Mat::getHostId, getHostId())); |
| | | if (mat != null) { |
| | | Prior prior = new Prior(); |
| | | prior.setHostId(getHostId()); |
| | | prior.setUuid("SP" + snowflakeIdWorker.nextId()); |
| | | prior.setMatId(mat.getId()); |
| | | prior.setMatnr(mat.getMatnr()); |
| | | prior.setMaktx(mat.getMaktx()); |
| | | prior.setLocNo(dto.getLocNo()); |
| | | prior.setSafeQua(dto.getSafeQua()); |
| | | prior.setCreateBy(getUserId()); |
| | | prior.setCreateTime(new Date()); |
| | | prior.setUpdateBy(getUserId()); |
| | | prior.setUpdateTime(new Date()); |
| | | prior.setStatus(1); |
| | | prior.setMemo(dto.getMemo()); |
| | | if (!priorService.save(prior)) { |
| | | throw new CoolException("数据保存失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/safeSto/delete/auth") |
| | | @ManagerAuth(memo = "删除库存预警") |
| | | @Transactional |
| | | public R del(@RequestBody List<SafeStoDto> dtos){ |
| | | if (Cools.isEmpty(dtos)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | for (SafeStoDto dto : dtos) { |
| | | if (!priorService.remove(new LambdaQueryWrapper<Prior>().eq(Prior::getId, dto.getId()).eq(Prior::getHostId, getHostId()))) { |
| | | throw new CoolException("删除安全库存失败,请重新尝试"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | var pageCurr; |
| | | function getCol() { |
| | | var cols = [ |
| | | {field: 'locNo$', align: 'center',title: '库位号'}, |
| | | {field: 'locNo', align: 'center',title: '库位号'}, |
| | | {field: 'matnr', align: 'center',title: '商品编号', sort:true} |
| | | ,{field: 'maktx', align: 'center',title: '商品名称', sort:true} |
| | | ,{field: 'orderNo', align: 'center',title: '单据编号', hide: false} |
| | |
| | | cellMinWidth: 50, |
| | | cols: [[ |
| | | {type: 'numbers', fixed: 'left'} |
| | | ,{field: 'node_name', align: 'center',title: '货位'} |
| | | ,{field: 'locNo$', align: 'center',title: '库位'} |
| | | ,{field: 'matnr', align: 'center',title: '商品编号'} |
| | | ,{field: 'maktx', align: 'center',title: '商品名称'} |
| | | ,{field: 'progress', align: 'center',title: '使用情况', templet: '#progressTpl', width: 350} |
| | | ,{field: 'status', align: 'center',title: '警报', templet: '#statusTpl', width: 100} |
| | | ,{field: 'safe_qua', align: 'center',title: '安全库存量', style: 'font-weight: bold'} |
| | | ,{field: 'safeQua', align: 'center',title: '安全库存量', style: 'font-weight: bold'} |
| | | ,{field: 'amount', align: 'center',title: '当前库存量', style: 'font-weight: bold; color: #2d8cf0'} |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ]], |
| | |
| | | case 'del': |
| | | var params = []; |
| | | params.push({ |
| | | nodeId: data.node_id, |
| | | nodeName: data.node_name, |
| | | id: data.id, |
| | | locNo: data.locNo, |
| | | matnr: data.matnr |
| | | }) |
| | | doDel(params); |
| | |
| | | form.val('detail', mData); |
| | | // 表单提交事件 |
| | | form.on('submit(editSubmit)', function (data) { |
| | | data.field.nodeId = insNodeXmSel.getValue()[0] ? insNodeXmSel.getValue()[0].id : null; |
| | | data.field.locNo = locNoXmSelect.getValue()[0] ? locNoXmSelect.getValue()[0].name : null; |
| | | data.field.matId = matXmSelect.getValue()[0] ? matXmSelect.getValue()[0].value : null; |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | |
| | | }) |
| | | return false; |
| | | }); |
| | | // 渲染仓库下拉树 |
| | | var insNodeXmSel; |
| | | $.ajax({ |
| | | url: baseUrl + "/node/tree/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | async: false, |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | insNodeXmSel = xmSelect.render({ |
| | | el: '#nodeSel', |
| | | autoRow: true, |
| | | radio: true, // 单选 |
| | | filterable: true, |
| | | height: '300px', |
| | | tree: { |
| | | show: true, |
| | | showFolderIcon: true, |
| | | showLine: true, |
| | | indent: 20, |
| | | strict: false, // 父节点也能选中,重要 |
| | | clickExpand: true, |
| | | clickCheck: false, |
| | | expandedKeys: true |
| | | }, |
| | | prop: { |
| | | name: 'title', |
| | | value: 'id', |
| | | }, |
| | | toolbar: { |
| | | show: true, |
| | | list: ['ALL', 'REVERSE', 'CLEAR'] |
| | | }, |
| | | data: function(){ |
| | | return res.data |
| | | // 渲染商品选择 |
| | | var locNoXmSelect = xmSelect.render({ |
| | | el: '#locNo', |
| | | radio: true, |
| | | autoRow: true, |
| | | toolbar: { show: true }, |
| | | filterable: true, |
| | | remoteSearch: true, |
| | | remoteMethod: function(val, cb, show){ |
| | | //这里如果val为空, 则不触发搜索 |
| | | // if(!val){ |
| | | // return cb([]); |
| | | // } |
| | | $.ajax({ |
| | | url: baseUrl+"/locMast/all/get/kv", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | condition: val |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | cb(res.data) |
| | | } else { |
| | | cb([]); |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | }) |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }) |
| | | // 渲染商品选择 |
| | |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <div class="layui-input-inline cool-auto-complete"> |
| | | <input id="nodeId" class="layui-input" name="node_id" type="text" placeholder="请输入" autocomplete="off" style="display: none"> |
| | | <input id="nodeId$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="关联货位" onfocus=this.blur()> |
| | | <div class="cool-auto-complete-window"> |
| | | <input class="cool-auto-complete-window-input" data-key="nodeQueryBynodeId" onkeyup="autoLoad(this.getAttribute('data-key'))"> |
| | | <select class="cool-auto-complete-window-select" data-key="nodeQueryBynodeIdSelect" onchange="confirmed(this.getAttribute('data-key'))" multiple="multiple"> |
| | | </select> |
| | | </div> |
| | | <div class="layui-input-inline"> |
| | | <input class="layui-input" type="text" name="loc_no" placeholder="库位号" autocomplete="off"> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | <div class="layui-col-md12"> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">仓库/货位</label> |
| | | <label class="layui-form-label">库位</label> |
| | | <div class="layui-input-block"> |
| | | <div id="nodeSel" class="ew-xmselect-tree"></div> |
| | | <div id="locNo" name="locNo"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |