| | |
| | | package zy.cloud.wms.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import zy.cloud.wms.common.model.BillDto; |
| | | import zy.cloud.wms.common.service.erp.ErpService; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.entity.param.*; |
| | |
| | | /** |
| | | * Created by vincent on 2021/2/25 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/work") |
| | | public class WorkController extends BaseController { |
| | |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private ErpService erpService; |
| | | |
| | | |
| | | @RequestMapping("/stock/pakin") |
| | | @ManagerAuth(memo = "入库") |
| | |
| | | return R.ok("审核成功数量:" + success); |
| | | } |
| | | |
| | | // 盘点上传 |
| | | @RequestMapping("/check/upload") |
| | | @ManagerAuth(memo = "盘点上传") |
| | | public R checkUpload(@RequestBody CheckUploadParam params) { |
| | | List<BillDto> dtos = new ArrayList<>(); |
| | | if (params.getMats().size() > 0) { |
| | | for (Mat matList : params.getMats()) { |
| | | BillDto dto = new BillDto(); |
| | | dto.setMatnr(matList.getMatnr()); |
| | | dto.setQty(matList.getCount().doubleValue()); |
| | | dtos.add(dto); |
| | | } |
| | | } else { |
| | | throw new CoolException("数据异常"); |
| | | } |
| | | int docId; |
| | | String docNum; |
| | | if (params.getType().equals("1")) { // 盘盈 |
| | | docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 14; // 报溢单 |
| | | } else if (params.getType().equals("2")) { // 盘亏 |
| | | docNum = "CD-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 9; // 报损单 |
| | | } else { |
| | | throw new CoolException("数据异常"); |
| | | } |
| | | // erp上传盘盈盘亏 |
| | | if (!erpService.uploadBill(dtos, docId, docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | } |
| | | String dotsStr = JSON.toJSONString(dtos); |
| | | log.info("盘点上传,类型:" + (docId == 14 ? "盘盈" : "盘亏") + ",单号:" + docNum + ",上传物料清单:" + dotsStr); |
| | | log.info("==============================================================================================="); |
| | | return R.ok().add("上报至erp成功"); |
| | | } |
| | | |
| | | /******************************************************************************************************/ |
| | | |
| | | @Autowired |
| | |
| | | List<Item> items = itemService.selectList(new EntityWrapper<Item>().eq("status", 1).orderBy("create_time", false)); |
| | | return R.ok().add(items); |
| | | } |
| | | |
| | | // 获取所有项目 |
| | | @RequestMapping("/item/all/get/kv") |
| | | @ManagerAuth |
New file |
| | |
| | | package zy.cloud.wms.manager.entity.param; |
| | | |
| | | import lombok.Data; |
| | | import zy.cloud.wms.manager.entity.Mat; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/6/21 |
| | | */ |
| | | @Data |
| | | public class CheckUploadParam { |
| | | private String type; |
| | | |
| | | private List<Mat> mats; |
| | | } |
| | |
| | | matCodeData = []; |
| | | var tableIns; |
| | | |
| | | function getCol() { |
| | | var cols = [ |
| | | { |
| | | fixed: 'left', |
| | | field: 'count', |
| | | title: '数量(必填)', |
| | | align: 'center', |
| | | edit: 'text', |
| | | width: 120, |
| | | style: 'color: blue;font-weight: bold' |
| | | } |
| | | ]; |
| | | cols.push.apply(cols, matCols); |
| | | cols.push({fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 80}) |
| | | return cols; |
| | | } |
| | | |
| | | layui.use(['table', 'laydate', 'form'], function () { |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | |
| | | tableIns = table.render({ |
| | | elem: '#chooseData', |
| | | data: [], |
| | | even: true, |
| | | limit: 500, |
| | | cellMinWidth: 50, |
| | | toolbar: '#toolbar', |
| | | cols: [getCol()], |
| | | done: function (res, curr, count) { |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 监听行工具事件-移除 |
| | | table.on('tool(chooseData)', function (obj) { |
| | | var data = obj.data; |
| | | switch (obj.event) { |
| | | case 'remove': |
| | | for (var i = matCodeData.length - 1; i >= 0; i--) { |
| | | if (matCodeData[i].matnr === data.matnr) { |
| | | matCodeData.splice(i, 1); |
| | | } |
| | | } |
| | | tableIns.reload({ |
| | | data: matCodeData, done: function (res) { |
| | | limit(); |
| | | // 覆盖render方法的done |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 页面修改 |
| | | table.on('edit(chooseData)', function (obj) { |
| | | updateMatCodeData(obj.data.matnr, Number(obj.value)); |
| | | }); |
| | | |
| | | // 操作栏重置事件 |
| | | form.on('submit(reset)', function (data) { |
| | | $("#type").val(""); |
| | | form.render(); |
| | | matCodeData = []; |
| | | tableIns.reload({data: []}); |
| | | }); |
| | | |
| | | // 操作栏提交事件 |
| | | form.on('submit(submit)', function (data) { |
| | | var type = $("#type").val(); |
| | | if (isEmpty(type)) { |
| | | layer.msg("请选择盈亏情况"); |
| | | return; |
| | | } |
| | | if (!matCodeData || matCodeData.length == 0) { |
| | | layer.msg("商品信息不可为空"); |
| | | return; |
| | | } |
| | | for (var i = 0; i < matCodeData.length; i++) { |
| | | if (matCodeData[i].count == 0) { |
| | | layer.msg("商品" + matCodeData[i].maktx + "数量不可为空"); |
| | | return; |
| | | } |
| | | } |
| | | // 调用上传erp接口 |
| | | console.log('matCodeData:', matCodeData, ";type:", type); |
| | | $.ajax({ |
| | | url : baseUrl+'/work/check/upload', |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | data: JSON.stringify({ |
| | | mats: matCodeData, |
| | | type: type, |
| | | }), |
| | | success : function(res) { |
| | | if (res.code == 200) { |
| | | layer.msg(res.data) |
| | | matCodeData = []; |
| | | tableIns.reload({data: []}); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | }); |
| | | |
| | | |
| | | // 提取物料 |
| | | var matCodeLayerIdx; |
| | | |
| | | function getMat() { |
| | | matCodeLayerIdx = layer.open({ |
| | | type: 2, |
| | | title: '提取物料', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: '../ioWorks/matQuery.html', |
| | | success: function (layero, index) { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 添加表格数据 |
| | | function addTableData(data) { |
| | | for (var i = 0; i < data.length; i++) { |
| | | let pass = false; |
| | | for (var j = 0; j < matCodeData.length; j++) { |
| | | if (data[i].matnr === matCodeData[j].matnr) { |
| | | pass = true; |
| | | break; |
| | | } |
| | | } |
| | | if (pass) { |
| | | data.splice(i--, 1); |
| | | } else { |
| | | data[i]["count"] = 0; |
| | | } |
| | | } |
| | | matCodeData.push.apply(matCodeData, data); |
| | | tableIns.reload({data: matCodeData}); |
| | | layer.close(matCodeLayerIdx); |
| | | } |
| | | |
| | | function updateMatCodeData(matnr, count) { |
| | | if (isNaN(count)) { |
| | | layer.msg("请输入数字"); |
| | | } else { |
| | | if (count > 0) { |
| | | for (var i = 0; i < matCodeData.length; i++) { |
| | | if (matCodeData[i]["matnr"] === matnr) { |
| | | matCodeData[i]["count"] = count; |
| | | } |
| | | } |
| | | } else { |
| | | layer.msg("数量必须大于零"); |
| | | } |
| | | } |
| | | |
| | | tableIns.reload({ |
| | | data: matCodeData, done: function (res) { |
| | | limit(); |
| | | // 覆盖render方法的done |
| | | } |
| | | }); |
| | | } |
| | |
| | | <link rel="stylesheet" href="../../static/css/cool.css" media="all"> |
| | | <link rel="stylesheet" href="../../static/css/common.css" media="all"> |
| | | </head> |
| | | <style> |
| | | .function-btn { |
| | | font-size: 16px; |
| | | padding: 1px 1px 1px 1px; |
| | | width: 100px; |
| | | height: 50px; |
| | | border-color: #2b425b; |
| | | border-radius: 4px; |
| | | border-width: 2px; |
| | | background: none; |
| | | border-style: solid; |
| | | transition: 0.4s; |
| | | cursor: pointer; |
| | | letter-spacing: 3px; |
| | | } |
| | | |
| | | .function-btn:hover { |
| | | background-color: #2b425b; |
| | | color: #fff; |
| | | } |
| | | |
| | | .function-area { |
| | | padding: 20px 50px; |
| | | } |
| | | </style> |
| | | <body> |
| | | <div>盘点上传</div> |
| | | |
| | | <div> |
| | | <!-- 操作栏 --> |
| | | <div id="search-box" class="layui-form layui-card-header"> |
| | | <div class="layui-inline"> |
| | | <select id="type"> |
| | | <option value="">盈亏情况</option> |
| | | <option value="1">盘盈</option> |
| | | <option value="2">盘亏</option> |
| | | </select> |
| | | </div> |
| | | |
| | | <!-- 待添加 --> |
| | | <div id="data-search-btn" class="layui-btn-container layui-form-item"> |
| | | <button style="margin-top: -5px" id="submit" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit |
| | | lay-filter="submit">提交 |
| | | </button> |
| | | <button style="margin-top: -5px" id="reset" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="reset">重置</button> |
| | | </div> |
| | | </div> |
| | | <!-- 功能区 --> |
| | | <div class="function-area"> |
| | | <button id="mat-query" class="function-btn" onclick="getMat()">新增</button> |
| | | </div> |
| | | </div> |
| | | <!-- 表格区 --> |
| | | <div> |
| | | <table class="layui-table" id="chooseData" lay-filter="chooseData"></table> |
| | | </div> |
| | | |
| | | <!-- 行 --> |
| | | <script type="text/html" id="operate"> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove">移除</a> |
| | | </script> |
| | | |
| | | </body> |
| | | <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script> |
New file |
| | |
| | | insert into sys_resource(code, name, resource_id, [level], sort, status) values ('check/check_upload.html', '盘点上传', 20428, 2, 10, 1) |