| | |
| | | |
| | | <properties> |
| | | <java.version>1.8</java.version> |
| | | <cool.version>3.0.0</cool.version> |
| | | <cool.version>3.1.0</cool.version> |
| | | <mysql-driver.version>5.1.47</mysql-driver.version> |
| | | <mybatis-plus.version>2.3.2</mybatis-plus.version> |
| | | <fastjson.version>1.2.58</fastjson.version> |
| | |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("保存订单主档失败"); |
| | | } |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | } else { |
| | | list.add(dto); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setCreateBy(getUserId()); |
| | |
| | | orderDetl.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok("订单添加成功"); |
| | |
| | | } |
| | | } |
| | | // 修改明细档 |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | // 1.清空明细档 |
| | | if (!orderDetlService.delete(new EntityWrapper<OrderDetl>().eq("order_id", order.getId()))) { |
| | | throw new CoolException("清空订单明细失败"); |
| | | } |
| | | // 2.重组数据 |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : param.getOrderDetlList()) { |
| | | OrderDetl detl = orderDetlService.findByLook(orderDetls, order.getId(), orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | // 新增 |
| | | if (detl == null) { |
| | | detl = orderDetl; |
| | | detl.setOrderId(order.getId()); |
| | | detl.setOrderNo(order.getOrderNo()); |
| | | detl.setCreateTime(now); |
| | | detl.setCreateBy(userId); |
| | | detl.setUpdateTime(now); |
| | | detl.setUpdateBy(userId); |
| | | detl.setStatus(1); |
| | | detl.setQty(0.0D); |
| | | // 修改 |
| | | } else { |
| | | detl.setAnfme(orderDetl.getAnfme()); // 修改数量 |
| | | detl.setUpdateTime(now); |
| | | detl.setUpdateBy(userId); |
| | | DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | if (DetlDto.has(list, dto)) { |
| | | OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch()); |
| | | item.setAnfme(item.getAnfme() + orderDetl.getAnfme()); |
| | | if (!orderDetlService.updateById(item)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | // 持久化 |
| | | if (!orderDetlService.insert(detl)) { |
| | | throw new CoolException("新增订单明细失败"); |
| | | } else { |
| | | list.add(dto); |
| | | orderDetl.setOrderId(order.getId()); |
| | | orderDetl.setOrderNo(order.getOrderNo()); |
| | | orderDetl.setCreateBy(getUserId()); |
| | | orderDetl.setCreateTime(now); |
| | | orderDetl.setUpdateBy(getUserId()); |
| | | orderDetl.setUpdateTime(now); |
| | | orderDetl.setStatus(1); |
| | | orderDetl.setQty(0.0D); |
| | | if (!orderDetlService.insert(orderDetl)) { |
| | | throw new CoolException("保存订单明细档失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok("订单修改成功"); |
| | |
| | | public OrderDetl findByLook(List<OrderDetl> orderDetls, Long orderId, String matnr, String batch) { |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | if (orderDetl.getOrderId().equals(orderId) && orderDetl.getMatnr().equals(matnr)) { |
| | | if (!Cools.isEmpty(batch)) { |
| | | if (orderDetl.getBatch().equals(batch)) { |
| | | return orderDetl; |
| | | } |
| | | } else { |
| | | if (Cools.eq(batch, orderDetl.getBatch())) { |
| | | return orderDetl; |
| | | } |
| | | } |
| | |
| | | this.anfme = anfme; |
| | | } |
| | | |
| | | public DetlDto(String matnr, String batch) { |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | | } |
| | | |
| | | public DetlDto(String matnr, String batch, Double anfme) { |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | |
| | | |
| | | public static boolean has(List<DetlDto> detlDtos, DetlDto detlDto) { |
| | | for (DetlDto dto : detlDtos) { |
| | | if (Cools.isEmpty(dto.getBatch()) && Cools.isEmpty(detlDto.getBatch())) { |
| | | if (dto.getMatnr().equals(detlDto.getMatnr())) { |
| | | if (dto.getMatnr().equals(detlDto.getMatnr()) && Cools.eq(dto.getBatch(), detlDto.getBatch())) { |
| | | return true; |
| | | } |
| | | } else { |
| | | if (!Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(detlDto.getBatch())) { |
| | | if (dto.getMatnr().equals(detlDto.getMatnr()) && dto.getBatch().equals(detlDto.getBatch())) { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | |
| | | return null; |
| | | } |
| | | for (DetlDto detlDto : detlDtos) { |
| | | if (!matnr.equals(detlDto.getMatnr())) { |
| | | continue; |
| | | } |
| | | if (Cools.isEmpty(batch) && Cools.isEmpty(detlDto.getBatch())) { |
| | | return detlDto; |
| | | } |
| | | if (Cools.isEmpty(batch) && !Cools.isEmpty(detlDto.getBatch())) { |
| | | continue; |
| | | } |
| | | if (Cools.isEmpty(detlDto.getBatch()) && !Cools.isEmpty(batch)) { |
| | | continue; |
| | | } |
| | | if (batch.equals(detlDto.getBatch())) { |
| | | if (matnr.equals(detlDto.getMatnr()) && Cools.eq(batch, detlDto.getBatch())) { |
| | | return detlDto; |
| | | } |
| | | } |
| | |
| | | } |
| | | let nList = admin.util.deepClone(xxDataList); |
| | | for (let xi = 0; xi < nList.length; xi++) { |
| | | // if (nList[xi].inQty > 0 && inQtys[xi] !== nList[xi].anfme) { |
| | | // layer.msg("已入库无法修改", {icon: 2}) |
| | | // return false; |
| | | // } else if (nList[xi].anfme > 0) { |
| | | // param.push({ |
| | | // billNo: data.field.billNo, |
| | | // billType: data.field.billType, |
| | | // matNo: nList[xi].matNo, |
| | | // matName: nList[xi].matName, |
| | | // color: nList[xi].color, |
| | | // size: nList[xi].size, |
| | | // specs: nList[xi].specs, |
| | | // memo: nList[xi].memo, |
| | | // unit: nList[xi].unit, |
| | | // qty: nList[xi].qty, |
| | | // inQty: nList[xi].inQty, |
| | | // }) |
| | | // } else if (nList[xi].anfme <= 0){ |
| | | // layer.msg('明细修改数量不合法', {icon: 2}); |
| | | // return false; |
| | | // } |
| | | if (nList[xi].anfme <= 0){ |
| | | layer.msg('明细修改数量不合法', {icon: 2}); |
| | | return false; |
| | |
| | | {type: 'numbers', title: '#'}, |
| | | {field: 'matnr', title: '商品编码', width: 160}, |
| | | {field: 'maktx', title: '商品名称', width: 200}, |
| | | {field: 'batch', title: '批号'}, |
| | | {field: 'batch', title: '批号', edit: true}, |
| | | {field: 'specs', title: '规格'}, |
| | | {field: 'anfme', title: '数量(修改)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110}, |
| | | // {field: 'inQty', title: '已入库量', minWidth: 100, width: 100}, |
| | |
| | | }); |
| | | // 明细数据修改 |
| | | table.on('edit(formSSXMTable)', function (obj) { |
| | | if (obj.field === 'memo'){ |
| | | for (let i=0;i<xxDataList.length;i++) { |
| | | if (xxDataList[i]["matnr"] === obj.data.matnr && xxDataList[i]["batch"] === obj.data.batch) { |
| | | xxDataList[i]["memo"] = obj.value; |
| | | break; |
| | | } |
| | | } |
| | | } else if (obj.field==='anfme'){ |
| | | let index = obj.tr.attr("data-index"); |
| | | let data = xxDataList[index]; |
| | | if (obj.field === 'anfme'){ |
| | | let vle = Number(obj.value); |
| | | if (isNaN(vle)) { |
| | | layer.msg("请输入数字", {icon: 2}); |
| | | return false; |
| | | } else { |
| | | if (vle > 0) { |
| | | for (let i=0;i<xxDataList.length;i++) { |
| | | if (xxDataList[i]["matnr"] === obj.data.matnr && xxDataList[i]["batch"] === obj.data.batch) { |
| | | xxDataList[i]["anfme"] = vle; |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | if (vle <= 0) { |
| | | layer.msg("数量必须大于零", {icon: 2}); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | data[obj.field] = obj.value; |
| | | insTbSSXM.reload({data: xxDataList}); |
| | | }); |
| | | // |
| | | |
| | | $('#matAddBtnComment').click(function () { |
| | | showEditModel2(); |
| | | }); |
| | |
| | | mvn install:install-file -Dfile=framework-2.0.0.jar -DgroupId=cn.cool -DartifactId=framework -Dversion=2.0.0 -Dpackaging=jar -DgeneratePom=true |
| | | mvn install:install-file -Dfile=framework-3.1.0.jar -DgroupId=cn.cool -DartifactId=framework -Dversion=3.1.0 -Dpackaging=jar -DgeneratePom=true |