| | |
| | | package com.example.erp.service.sd; |
| | | |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.dto.sd.OrderDTO; |
| | | import com.example.erp.dto.sd.OrderSearchDTO; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.userInfo.Log; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.pp.FlowCardMapper; |
| | | import com.example.erp.mapper.pp.WorkOrderMapper; |
| | | import com.example.erp.mapper.sd.*; |
| | | import com.example.erp.service.userInfo.LogService; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import com.sun.org.apache.regexp.internal.RE; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.sql.SQLOutput; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | |
| | | private final OrderGlassDetailMapper orderGlassDetailMapper; |
| | | private final SysErrorService sysErrorService; |
| | | private final OrderOtherMoneyMapper orderOtherMoneyMapper; |
| | | private final ProductMapper productMapper; |
| | | private final LogService logService; |
| | | private final WorkOrderMapper workOrderMapper; |
| | | private final FlowCardMapper flowCardMapper; |
| | | |
| | | private final OrderProcessDetailMapper orderProcessDetailMapper; |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper) { |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper, LogService logService, WorkOrderMapper workOrderMapper, FlowCardMapper flowCardMapper) { |
| | | this.orderMapper = orderMapper; |
| | | this.orderDetailMapper = orderDetailMapper; |
| | | this.orderGlassDetailMapper = orderGlassDetailMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | this.sysErrorService = sysErrorService; |
| | | this.orderOtherMoneyMapper = orderOtherMoneyMapper; |
| | | this.productMapper = productMapper; |
| | | this.logService = logService; |
| | | this.workOrderMapper = workOrderMapper; |
| | | this.flowCardMapper = flowCardMapper; |
| | | } |
| | | |
| | | public boolean saveOrder(Map<String,Object> orderMap) throws Exception { |
| | | JSONObject orderJson = new JSONObject(orderMap); |
| | | String orderIdType = orderJson.getString("orderIdType"); |
| | | Order order = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("title")), Order.class); |
| | | List<OrderDetail> OrderDetails = JSONArray.parseArray(JSONObject.toJSONString(orderJson.get("detail")), OrderDetail.class); |
| | | List<OrderOtherMoney> orderOtherMoneyList = JSONArray.parseArray(JSONObject.toJSONString(orderJson.get("otherMoney")), OrderOtherMoney.class); |
| | | if(orderOtherMoneyList != null ){ |
| | | orderOtherMoneyList = orderOtherMoneyList.stream().filter(o -> o.getColumn().indexOf("M")==0).collect(Collectors.toList()); |
| | | } |
| | | |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | //判断传入id参数是否为空,未传入id为空插入订单表,传入更新表 |
| | | try{ |
| | | Log log = new Log(); |
| | | log.setOperator(orderJson.getString("creator")); |
| | | log.setOperatorId(orderJson.getString("creatorId")); |
| | | log.setContent(orderMap.toString()); |
| | | |
| | | if(order.getOrderId() == null || order.getOrderId().isEmpty()){ |
| | | insertOrder(order,OrderDetails,orderOtherMoneyList); |
| | | insertOrder(order,OrderDetails,orderOtherMoneyList,orderIdType, (Map<String, String>) orderMap.get("position")); |
| | | log.setFunction("saveOrder创建:"+order.getOrderId()); |
| | | }else { |
| | | updateOrder(order,OrderDetails,orderOtherMoneyList); |
| | | updateOrder(order,OrderDetails,orderOtherMoneyList,(Map<String, String>) orderMap.get("position")); |
| | | log.setFunction("saveOrder修改:"+order.getOrderId()); |
| | | } |
| | | logService.saveLog(log); |
| | | }catch (Exception e){ |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | //throw new Exception(); |
| | | } |
| | | return saveState; |
| | | } |
| | | |
| | | public boolean saveOrderTitle(Map<String,Object> orderMap) throws Exception { |
| | | JSONObject orderJson = new JSONObject(orderMap); |
| | | Order order = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("title")), Order.class); |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | //判断传入id参数是否为空,未传入id为空插入订单表,传入更新表 |
| | | try{ |
| | | Log log = new Log(); |
| | | log.setOperator(order.getCreator()); |
| | | log.setOperatorId(order.getCreatorId()); |
| | | log.setContent(orderMap.toString()); |
| | | log.setFunction("saveOrderTitle保存表头:"+order.getOrderId()); |
| | | |
| | | Order order1 = orderMapper.selectOrderId(order.getOrderId()); |
| | | //使用订单原本的状态和计算方式 |
| | | order.setCalculateType(order1.getCalculateType()); |
| | | order.setCreateOrder(order1.getCreateOrder()); |
| | | order.setProcessReview(order1.getProcessReview()); |
| | | order.setOrderReview(order1.getOrderReview()); |
| | | order.setProductionOrder(order1.getProductionOrder()); |
| | | order.setProcessingCard(order1.getProcessingCard()); |
| | | order.setWarehousing(order1.getWarehousing()); |
| | | order.setDelivery(order1.getDelivery()); |
| | | |
| | | LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(Order::getOrderId, order.getOrderId()); |
| | | order.setCreateTime(null); |
| | | orderMapper.update(order,updateWrapper); |
| | | //修改订单主表面积与周长以及重量 |
| | | orderMapper.updateOrderParameter(order.getOrderId()); |
| | | logService.saveLog(log); |
| | | |
| | | }catch (Exception e){ |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | //throw new Exception(); |
| | | } |
| | | return saveState; |
| | | } |
| | | |
| | | |
| | | public Map<String,Object> selectOrder(Map<String,Object> orderMap) throws Exception { |
| | | JSONObject orderJson = new JSONObject(orderMap); |
| | | Order order = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("title")), Order.class); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | if(order.getOrderId()!=null && !order.getOrderId().isEmpty()){ |
| | | map.put("data",0); |
| | | }else{ |
| | | map.put("data",orderMapper.selectOrder(order)); |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | //生成订单数据 |
| | | public void insertOrder(Order order,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | Integer maxOrderId = orderMapper.selectMaxOrderId(); |
| | | //查询订单id,并且自增 |
| | | String formattedNumber = String.format("%02d", maxOrderId+1); |
| | | //格式化当前日期 |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | String orderId = "NG"+formattedDate+formattedNumber; |
| | | public void insertOrder(Order order, List<OrderDetail> OrderDetails, List<OrderOtherMoney> orderOtherMoneyList, String orderIdType, Map<String,String> position) { |
| | | //根据传入的当前月份或者当天生成订单id |
| | | String orderId = getOrderId(orderIdType); |
| | | //往主表插数据 |
| | | order.setOrderId(orderId); |
| | | order.setCreateOrder(2); |
| | | orderMapper.insert(order); |
| | | insertOtherDetail(orderId,OrderDetails,orderOtherMoneyList); |
| | | |
| | | insertOtherDetail(orderId,OrderDetails,orderOtherMoneyList,position); |
| | | } |
| | | |
| | | private String getOrderId(String dateType){ |
| | | String orderId = null; |
| | | if(dateType==null || dateType.equals("day")){ |
| | | Integer maxOrderId = orderMapper.selectMaxOrderId(); |
| | | //查询订单id,并且自增 |
| | | String formattedNumber = String.format("%02d", maxOrderId+1); |
| | | //格式化当前日期 |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | orderId = "NG"+formattedDate+formattedNumber; |
| | | }else if(dateType.equals("month")){ |
| | | Integer maxOrderId = orderMapper.selectMaxOrderIdByMonth(); |
| | | String formattedNumber = String.format("%04d", maxOrderId+1); |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyMM"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | orderId = "NG"+formattedDate+formattedNumber; |
| | | |
| | | }else if(dateType.equals("year")){ |
| | | Integer maxOrderId = orderMapper.selectMaxOrderIdByYear(); |
| | | String formattedNumber = String.format("%06d", maxOrderId+1); |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yy"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | orderId = "NG"+formattedDate+formattedNumber; |
| | | } |
| | | return orderId; |
| | | } |
| | | |
| | | |
| | | //修改订单数据,并且重新生成多个副表数据 |
| | | public void updateOrder(Order order,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | public void updateOrder(Order order, List<OrderDetail> OrderDetails, List<OrderOtherMoney> orderOtherMoneyList, Map<String, String> position) throws Exception { |
| | | Order oldOrder = orderMapper.selectOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderId,order.getOrderId())); |
| | | if(oldOrder.getProcessReview()==2){ |
| | | throw new ServiceException(Constants.Code_600,"该订单已经审核,无法修改"); |
| | | } |
| | | if(!Objects.equals(oldOrder.getVersion(), order.getVersion())){ |
| | | throw new ServiceException(Constants.Code_600,"该订单已经修改,请刷新页面"); |
| | | } |
| | | order.setCreateTime(null); |
| | | order.setVersion(order.getVersion()+1); |
| | | LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(Order::getOrderId, order.getOrderId()); |
| | | orderMapper.update(order,updateWrapper); |
| | |
| | | //删除其他金额明细表 |
| | | orderOtherMoneyMapper.delete(new LambdaQueryWrapper<OrderOtherMoney>().eq(OrderOtherMoney::getOrderId, order.getOrderId())); |
| | | |
| | | |
| | | //删除订单工艺表 |
| | | // orderProcessDetailMapper.delete(new LambdaQueryWrapper<OrderProcessDetail>().eq(OrderProcessDetail::getOrderId, order.getOrderId())); |
| | | insertOtherDetail(order.getOrderId(),OrderDetails,orderOtherMoneyList); |
| | | // orderProcessDetailMapper.delete(new LambdaQueryWrapper<OrderProcessDetail>().eq(OrderProcessDetail::getOrderId, order.getOrderId())); |
| | | |
| | | orderDetailMapper.deleteOrderFile(order.getOrderId()); |
| | | |
| | | insertOtherDetail(order.getOrderId(),OrderDetails,orderOtherMoneyList, position); |
| | | } |
| | | |
| | | |
| | | //插入其他副表数据,被其他方法引用 |
| | | public void insertOtherDetail(String orderId,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | |
| | | //插入其他副表数据,被其他方法引用 |
| | | public void insertOtherDetail(String orderId, List<OrderDetail> OrderDetails, List<OrderOtherMoney> orderOtherMoneyList, Map<String, String> position) { |
| | | //先把其他金额副表的金额与数量置0 |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | orderOtherMoney.setQuantity(0.0); |
| | | }); |
| | | if(orderOtherMoneyList!=null){ |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | orderOtherMoney.setQuantity(0.0); |
| | | }); |
| | | } |
| | | |
| | | |
| | | //循环给订单明细表字段添加序号和周长 |
| | | for (int i = 0; i < OrderDetails.size(); i++) { |
| | | OrderDetails.get(i).setOrderNumber(i+1); |
| | | OrderDetails.get(i).setOrderId(orderId); |
| | | OrderDetails.get(i).setPerimeter(OrderDetails.get(i).getWidth()*OrderDetails.get(i).getHeight()*2/1000); |
| | | OrderDetails.get(i).setWeight(1.0); |
| | | if(OrderDetails.get(i).getBendRadius()!=null && OrderDetails.get(i).getBendRadius()!=0){ |
| | | OrderDetails.get(i).setPerimeter(Double.valueOf(String.format("%.3f",(OrderDetails.get(i).getWidth()+OrderDetails.get(i).getHeight())*2/1000*OrderDetails.get(i).getQuantity()))); |
| | | OrderDetails.get(i).setMonolithicPerimeter(Double.valueOf(String.format("%.3f",(OrderDetails.get(i).getWidth()+OrderDetails.get(i).getHeight())*2/1000))); |
| | | Product product = productMapper.selectById(OrderDetails.get(i).getProductId()); |
| | | |
| | | OrderDetails.get(i).setWeight(Double.valueOf(String.format("%.2f",product.getThickness()*OrderDetails.get(i).getWidth()*OrderDetails.get(i).getHeight()/1000000*2.5))); |
| | | /*if(OrderDetails.get(i).getBendRadius()!=null && OrderDetails.get(i).getBendRadius()!=0){ |
| | | //获取弯钢弧度 |
| | | Double bendRadius = OrderDetails.get(i).getBendRadius(); |
| | | //获取宽 |
| | |
| | | String archRiseS = String.format("%.1f",bendRadius-(bendRadius*Math.cos(width/2/bendRadius))); |
| | | Double archRise = Double.parseDouble(archRiseS); |
| | | OrderDetails.get(i).setArchRise(archRise); |
| | | } |
| | | }*/ |
| | | |
| | | Map<String,Object> otherColumns = JSON.parseObject(OrderDetails.get(i).getOtherColumns(), new TypeReference<Map<String, Object>>(){}); |
| | | int finalI = i; |
| | | |
| | | if(otherColumns!=null){ |
| | | otherColumns.values().removeIf(value -> value == null || value.equals("")); |
| | | OrderDetails.get(i).setOtherColumns(JSON.toJSONString(otherColumns)); |
| | | otherColumns.forEach((key, value) ->{ |
| | | if(value!=null && key.contains("M")) { |
| | | |
| | | if(value!=null && !value.equals("") && key.contains("M")) { |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | if (orderOtherMoney.getColumn().equals(key)) { |
| | | orderOtherMoney.setQuantity(orderOtherMoney.getQuantity()+(Double.parseDouble((String) value) * OrderDetails.get(finalI).getQuantity())); |
| | | orderOtherMoney.setQuantity( |
| | | orderOtherMoney.getQuantity()+(Double.parseDouble((String) value) * OrderDetails.get(finalI).getQuantity())); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | }else{ |
| | | OrderDetails.get(i).setOtherColumns("{}"); |
| | | } |
| | | if(OrderDetails.get(i).getFileName()!=null&&!OrderDetails.get(i).getFileName().trim().isEmpty()){ |
| | | orderMapper.saveOrderFile(OrderDetails.get(i).getFileName(), OrderDetails.get(i).getFileData(),orderId,OrderDetails.get(i).getOrderNumber(),OrderDetails.get(i).getFileJson()); |
| | | } |
| | | if(OrderDetails.get(i).getShape()==null){ |
| | | OrderDetails.get(i).setShape("1"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //往明细表插数据 |
| | | orderDetailMapper.insertBatch(OrderDetails); |
| | | //往小片表传入产品数据 |
| | | orderGlassDetailMapper.insertOrderGlassDetail(orderId); |
| | | //往订单其他金额副表传入数据 |
| | | orderOtherMoneyList.forEach(orderOtherMoney ->{ |
| | | orderOtherMoney.setId(null); |
| | | orderOtherMoney.setOrderId(orderId); |
| | | if(orderOtherMoney.getQuantity()!=null && orderOtherMoney.getPrice()!=null){ |
| | | orderOtherMoney.setMoney((orderOtherMoney.getQuantity()*orderOtherMoney.getPrice())); |
| | | orderGlassDetailMapper.insertOrderGlassDetail(orderId,position.get("outside"),position.get("inside")); |
| | | //修改成品拱高 |
| | | List<OrderDetail> orderDetails = orderDetailMapper |
| | | .selectList(new LambdaQueryWrapper<OrderDetail>() |
| | | .eq(OrderDetail::getOrderId, orderId) |
| | | .isNotNull(OrderDetail::getBendRadius) |
| | | ); |
| | | |
| | | orderDetails.forEach(orderDetail -> { |
| | | //获取最小弧度 |
| | | List<OrderGlassDetail> orderGlassDetails = orderGlassDetailMapper |
| | | .selectList(new LambdaQueryWrapper<OrderGlassDetail>() |
| | | .eq(OrderGlassDetail::getOrderId, orderId) |
| | | .eq(OrderGlassDetail::getOrderNumber, orderDetail.getOrderNumber()) |
| | | ); |
| | | |
| | | for(OrderGlassDetail orderGlassDetail:orderGlassDetails) { |
| | | //获取当前层数与之前层数的厚度 |
| | | Double glassThickness = productMapper |
| | | .getGlassThickness(orderDetail.getProductId(), orderGlassDetail.getTechnologyNumber()); |
| | | //内半径 |
| | | Double radius = orderDetail.getBendRadius() - glassThickness; |
| | | |
| | | |
| | | //内片内弧长 |
| | | Double innerArc = orderGlassDetails.get(0).getArc() |
| | | - orderGlassDetails.get(0).getArc() * glassThickness / orderDetail.getBendRadius(); |
| | | |
| | | //拱高 |
| | | String archRiseS = String.format("%.1f", radius - radius * Math.cos(innerArc / 2 / radius)); |
| | | Double archRise = Double.parseDouble(archRiseS); |
| | | orderGlassDetailMapper.update(null, new LambdaUpdateWrapper<OrderGlassDetail>() |
| | | .set(OrderGlassDetail::getArchRise, archRise) |
| | | .eq(OrderGlassDetail::getId, orderGlassDetail.getId()) |
| | | ); |
| | | |
| | | // orderDetailMapper.update(null,new LambdaUpdateWrapper<OrderDetail>() |
| | | // .set(OrderDetail::getArchRise,archRise) |
| | | // .eq(OrderDetail::getId, orderDetail.getId()) |
| | | } |
| | | orderOtherMoneyMapper.insert(orderOtherMoney); |
| | | |
| | | }); |
| | | |
| | | |
| | | if(orderOtherMoneyList!=null){ |
| | | orderOtherMoneyList.forEach(orderOtherMoney ->{ |
| | | orderOtherMoney.setId(null); |
| | | orderOtherMoney.setOrderId(orderId); |
| | | if(orderOtherMoney.getQuantity()!=null && orderOtherMoney.getPrice()!=null){ |
| | | BigDecimal getQuantity= BigDecimal.valueOf(orderOtherMoney.getQuantity()); |
| | | BigDecimal getPrice= BigDecimal.valueOf(orderOtherMoney.getPrice()); |
| | | orderOtherMoney.setMoney(getQuantity.multiply(getPrice).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | }else { |
| | | orderOtherMoney.setMoney(0.0); |
| | | } |
| | | orderOtherMoneyMapper.insert(orderOtherMoney); |
| | | }); |
| | | } |
| | | |
| | | //修改订单主表面积与周长以及重量 |
| | | orderMapper.updateOrderParameter(orderId); |
| | | |
| | | //查询订单小片表获取工艺传入小片工艺表 |
| | | //List<OrderGlassDetail> orderGlassDetails = orderGlassDetailMapper.selectOrderGlassDetail(orderId); |
| | | /*List<OrderProcessDetail> orderProcessDetailList = getOrderProcessDetails(orderGlassDetails); |
| | | //赋值订单工艺表 |
| | | orderProcessDetailMapper.insertOrderProcessDetail(orderProcessDetailList);*/ |
| | | } |
| | | |
| | | public static List<OrderProcessDetail> getOrderProcessDetails(List<OrderGlassDetail> orderGlassDetails) { |
| | |
| | | } |
| | | |
| | | //查询获取列表 |
| | | public Map<String,Object> getOrderList(Integer pageNum, Integer pageSize, List<String> selectDate, Order order,Integer orderType) { |
| | | public Map<String,Object> getOrderList(Integer pageNum, Integer pageSize, List<String> selectDate, Map<String,Object> config,Integer orderType) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | String startDate = LocalDate.now().minusDays(365).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | JSONObject orderJson = new JSONObject(config); |
| | | OrderSearchDTO order = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("filter")), OrderSearchDTO.class); |
| | | Map<String,String> sortDate = (Map<String, String>) config.get("sort"); |
| | | String field = sortDate.get("field").replaceAll("(?<!^)([A-Z])", "_$1").toLowerCase(); |
| | | String orderBy = sortDate.get("order"); |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderMapper.getOrderList(offset, pageSize, startDate, endDate, order,orderType)); |
| | | map.put("data",orderMapper.getOrderList(offset, pageSize, startDate, endDate, order,orderType, field, orderBy)); |
| | | map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, order,orderType)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | |
| | | } |
| | | //删除订单 |
| | | public Integer deleteOrder(String id) { |
| | | return orderMapper.delete( |
| | | orderDetailMapper.deleteOrderFile(id); |
| | | return orderMapper.delete( |
| | | new QueryWrapper<Order>().eq("order_id",id) |
| | | ); |
| | | } |
| | |
| | | Order order = orderMapper.selectOne(new QueryWrapper<Order>().eq("order_id",id)); |
| | | List<OrderDetail> orderDetails = orderDetailMapper.selectList(new QueryWrapper<OrderDetail>().eq("order_id",id)); |
| | | List<OrderOtherMoney> orderOtherMoneyList = orderOtherMoneyMapper.findById(id); |
| | | List<Map<String,String>> orderFileList = orderMapper.selectOrderFileList(id); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("order",order); |
| | | map.put("orderDetails",orderDetails); |
| | | map.put("orderOtherMoneyList",orderOtherMoneyList); |
| | | map.put("orderFile",orderFileList); |
| | | return map; |
| | | } |
| | | //订单审核 |
| | | public boolean reviewOrderById(String id,Integer status) { |
| | | public boolean reviewOrderById(String id, Integer status, String userId, String userName) { |
| | | Log log = new Log(); |
| | | log.setOperator(userName); |
| | | log.setOperatorId(userId); |
| | | log.setContent(status.toString()); |
| | | log.setFunction("reviewOrderById:"+id); |
| | | logService.saveLog(log); |
| | | Order order = orderMapper.selectOne(new QueryWrapper<Order>().eq("order_id",id)); |
| | | if(order.getProcessReview()!=2){ |
| | | throw new ServiceException(Constants.Code_600,"该订单还未审核"); |
| | | }else if(status==0){ |
| | | return orderMapper.reviewOrderByIds(id,status,userId,userName); |
| | | }else{ |
| | | return orderMapper.reviewOrderById(id,status,userId,userName); |
| | | } |
| | | return orderMapper.reviewOrderById(id,status); |
| | | |
| | | } |
| | | //工艺审核界面审核更新数据 |
| | | public boolean reviewProcessById(String id, Integer status,List<OrderGlassDetail> orderGlassDetails) { |
| | | Log log = new Log(); |
| | | log.setContent(orderGlassDetails.toString()); |
| | | log.setFunction("reviewProcessById:"+id); |
| | | if(!orderGlassDetails.isEmpty() && status==2){ |
| | | orderGlassDetails.forEach(orderGlassDetail ->{ |
| | | double area = Math.round((orderGlassDetail.getChildWidth()*orderGlassDetail.getChildHeight()/1000000) * 100) * 0.01d; |
| | |
| | | // //赋值订单工艺表 |
| | | // orderProcessDetailMapper.insertOrderProcessDetail(orderProcessDetailList); |
| | | } |
| | | |
| | | logService.saveLog(log); |
| | | return orderMapper.reviewProcessById(id,status); |
| | | } |
| | | //工艺审核界面数据查询 |
| | |
| | | JSONObject jsonObject = new JSONObject(map); |
| | | Order order = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("order")), Order.class); |
| | | List<OrderDetail> OrderDetails = JSONArray.parseArray(JSONObject.toJSONString(jsonObject.get("detail")), OrderDetail.class); |
| | | List<OrderOtherMoney> orderOtherMoneyList = JSONArray.parseArray(JSONObject.toJSONString(jsonObject.get("otherMoney")), OrderOtherMoney.class); |
| | | |
| | | if(orderOtherMoneyList != null ){ |
| | | orderOtherMoneyList = orderOtherMoneyList.stream().filter(o -> o.getColumn().indexOf("M")==0).collect(Collectors.toList()); |
| | | } |
| | | if(orderOtherMoneyList!=null){ |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | orderOtherMoney.setQuantity(0.0); |
| | | }); |
| | | } |
| | | |
| | | Log log = new Log(); |
| | | log.setOperator(order.getCreator()); |
| | | log.setOperatorId(order.getCreatorId()); |
| | | log.setContent(jsonObject.toString()); |
| | | log.setFunction("updateOrderMoney金额重置:"+order.getOrderId()); |
| | | |
| | | //删除其他金额明细表 |
| | | orderOtherMoneyMapper.delete(new LambdaQueryWrapper<OrderOtherMoney>().eq(OrderOtherMoney::getOrderId, order.getOrderId())); |
| | | List<OrderOtherMoney> orderOtherMoneyLists=orderOtherMoneyList; |
| | | |
| | | double money = 0; |
| | | for (OrderDetail orderDetail : OrderDetails) { |
| | | orderDetail = updateOrderMoneyComputed(orderDetail,order.getCalculateType()); |
| | | money+= orderDetail.getGrossAmount(); |
| | | BigDecimal getGrossAmount= BigDecimal.valueOf(orderDetail.getGrossAmount()); |
| | | money+=getGrossAmount.doubleValue(); |
| | | |
| | | Map<String,Object> otherColumns = JSON.parseObject(orderDetail.getOtherColumns(), new TypeReference<Map<String, Object>>(){}); |
| | | if(otherColumns!=null){ |
| | | otherColumns.values().removeIf(value -> value == null || value.equals("")); |
| | | orderDetail.setOtherColumns(JSON.toJSONString(otherColumns)); |
| | | |
| | | OrderDetail finalOrderDetail = orderDetail; |
| | | otherColumns.forEach((key, value) ->{ |
| | | |
| | | if(value!=null && !value.equals("") && key.contains("M")) { |
| | | orderOtherMoneyLists.forEach(orderOtherMoney -> { |
| | | if (orderOtherMoney.getColumn().equals(key)) { |
| | | orderOtherMoney.setQuantity( |
| | | orderOtherMoney.getQuantity()+(Double.parseDouble((String) value) * finalOrderDetail.getQuantity())); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | }else{ |
| | | orderDetail.setOtherColumns("{}"); |
| | | } |
| | | |
| | | } |
| | | order.setMoney(money); |
| | | |
| | | if(orderOtherMoneyLists!=null){ |
| | | orderOtherMoneyLists.forEach(orderOtherMoney ->{ |
| | | orderOtherMoney.setId(null); |
| | | orderOtherMoney.setOrderId(order.getOrderId()); |
| | | if(orderOtherMoney.getQuantity()!=null && orderOtherMoney.getPrice()!=null){ |
| | | orderOtherMoney.setMoney((orderOtherMoney.getQuantity()*orderOtherMoney.getPrice())); |
| | | }else { |
| | | orderOtherMoney.setMoney(0.0); |
| | | } |
| | | orderOtherMoneyMapper.insert(orderOtherMoney); |
| | | }); |
| | | } |
| | | |
| | | order.setMoney(money+orderOtherMoneyMapper.selectGrossAmount(order.getOrderId())); |
| | | order.setOtherMoney(orderOtherMoneyMapper.selectGrossAmount(order.getOrderId())); |
| | | orderMapper.updateMoney(order); |
| | | orderDetailMapper.updateOrderMoney(OrderDetails); |
| | | logService.saveLog(log); |
| | | return false; |
| | | } |
| | | |
| | | private OrderDetail updateOrderMoneyComputed(OrderDetail orderDetail, Integer calculateType) { |
| | | BigDecimal getPrice= BigDecimal.valueOf(orderDetail.getPrice()); |
| | | BigDecimal getQuantity= BigDecimal.valueOf(orderDetail.getQuantity()); |
| | | BigDecimal getComputeGrossArea= BigDecimal.valueOf(orderDetail.getComputeGrossArea()); |
| | | BigDecimal getComputeArea= BigDecimal.valueOf(orderDetail.getComputeArea()); |
| | | BigDecimal getWidth= BigDecimal.valueOf(orderDetail.getWidth()); |
| | | BigDecimal getHeight= BigDecimal.valueOf(orderDetail.getHeight()); |
| | | if (calculateType == 3) { |
| | | orderDetail.setGrossAmount(orderDetail.getPrice() * orderDetail.getQuantity()); |
| | | } else { |
| | | orderDetail.setGrossAmount(orderDetail.getComputeGrossArea() * orderDetail.getPrice()); |
| | | orderDetail.setGrossAmount(getPrice.multiply(getQuantity).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | }else if (calculateType == 4) { |
| | | if(Objects.equals(orderDetail.getArea(), orderDetail.getComputeArea())&&Objects.equals(orderDetail.getGrossArea(), orderDetail.getComputeGrossArea())){ |
| | | orderDetail.setGrossAmount(getWidth.multiply(getHeight).multiply(getQuantity).multiply(getPrice). |
| | | divide(BigDecimal.valueOf(1000000), 2, RoundingMode.HALF_UP).doubleValue()); |
| | | }else{ |
| | | orderDetail.setGrossAmount(getPrice.multiply(getComputeGrossArea).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | }else if (calculateType == 1){ |
| | | orderDetail.setGrossAmount(getPrice.multiply(getComputeArea).multiply(getQuantity).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | }else{ |
| | | orderDetail.setGrossAmount(getPrice.multiply(getComputeGrossArea).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | return orderDetail; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public Map<String,Object> getOrderReport(Integer pageNum, Integer pageSize, List<String> selectDate, OrderDetail orderDetail) { |
| | | public Map<String,Object> getOrderReport(Integer pageNum, Integer pageSize, List<String> selectDate, OrderDetail orderDetail, Integer model, Integer scope) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | String startDate = LocalDate.now().minusDays(30).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail)); |
| | | map.put("data",orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail,model,scope)); |
| | | map.put("total",orderDetailMapper.getOrderReportTotal(offset, pageSize, startDate, endDate, orderDetail,"order")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | |
| | | return orderDetailMapper.exportOrderReport(dates); |
| | | } |
| | | |
| | | public Map<String,Object> getOrderSummaryReport(Integer pageNum, Integer pageSize, List<String> selectDate, Order order) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(30).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderSummaryReport(offset, pageSize, startDate, endDate, order)); |
| | | map.put("total",orderDetailMapper.getOrderSummaryReportTotal(offset, pageSize, startDate, endDate, order,"order")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | // map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, orderDetail)); |
| | | return map; |
| | | } |
| | | |
| | | public List<Order> exportOrderSummary(List<LocalDate> dates) { |
| | | return orderDetailMapper.exportOrderSummary(dates); |
| | | } |
| | | |
| | | public Map<String,Object> getOrderProductSummary(Integer pageNum, Integer pageSize, List<String> selectDate, OrderDetail orderDetail) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | String startDate = LocalDate.now().minusDays(30).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | |
| | | return orderDetailMapper.exportOrderProductSummary(dates); |
| | | } |
| | | |
| | | |
| | | public Map<String,String> getOrderProductDetailTag(String orderId) { |
| | | return orderDetailMapper.getOrderProductDetailTag(orderId); |
| | | } |
| | |
| | | orderProductDetailMap.put("productName",map.get("productName")); |
| | | List<OrderDetail> orderDetails = orderDetailMapper.getOrderProductByProductId(map.get("productId"),orderId); |
| | | orderDetails.forEach(orderDetail->{ |
| | | orderDetail.setGrossArea( |
| | | Double.parseDouble(String.format("%.3f", |
| | | orderDetail.getWidth()*orderDetail.getHeight()/1000000) |
| | | ) * orderDetail.getQuantity() |
| | | ); |
| | | |
| | | List<OrderGlassDetail> orderGlassDetails = |
| | | orderGlassDetailMapper.selectList( |
| | | new QueryWrapper<OrderGlassDetail>(). |
| | | eq("order_id",orderId). |
| | | eq("order_number",orderDetail.getOrderNumber()) |
| | | ); |
| | | Integer differentSize = orderGlassDetailMapper.getDifferentSizeNumber(orderId,orderDetail.getOrderNumber()); |
| | | orderDetail.setDifferentSize(differentSize); |
| | | orderDetail.setOrderGlassDetails(orderGlassDetails); |
| | | }); |
| | | |
| | | orderProductDetailMap.put("productDetail",orderDetails); |
| | |
| | | |
| | | returns.put("orderProductDetail",orderProductDetail); |
| | | returns.put("order",orderMapper.selectOne(new QueryWrapper<Order>().eq("order_id",orderId))); |
| | | return returns; |
| | | } |
| | | |
| | | public Object printOrderProductDetails(String orderId,List<String> productId) { |
| | | List<Map<String,Object>> orderProductDistinct; |
| | | if (productId.size()>0){ |
| | | orderProductDistinct = orderDetailMapper.getOrderProductDistinctByIds(orderId,productId); |
| | | }else{ |
| | | orderProductDistinct = orderDetailMapper.getOrderProductDistinctById(orderId); |
| | | } |
| | | List<Map<String,Object>> orderProductDetail = new ArrayList<>(); |
| | | orderProductDistinct.forEach(map->{ |
| | | Map<String,Object> orderProductDetailMap = new HashMap<>(); |
| | | orderProductDetailMap.put("productId",map.get("productId")); |
| | | orderProductDetailMap.put("productName",map.get("productName")); |
| | | List<OrderDetail> orderDetails = orderDetailMapper.getOrderProductByProductId(map.get("productId"),orderId); |
| | | orderDetails.forEach(orderDetail->{ |
| | | |
| | | List<OrderGlassDetail> orderGlassDetails = |
| | | orderGlassDetailMapper.selectList( |
| | | new QueryWrapper<OrderGlassDetail>(). |
| | | eq("order_id",orderId). |
| | | eq("order_number",orderDetail.getOrderNumber()) |
| | | ); |
| | | Integer differentSize = orderGlassDetailMapper.getDifferentSizeNumber(orderId,orderDetail.getOrderNumber()); |
| | | orderDetail.setDifferentSize(differentSize); |
| | | orderDetail.setOrderGlassDetails(orderGlassDetails); |
| | | }); |
| | | |
| | | |
| | | orderProductDetailMap.put("productDetail",orderDetails); |
| | | orderProductDetail.add(orderProductDetailMap); |
| | | }); |
| | | |
| | | Map<String,Object> returns = new HashMap<>(); |
| | | |
| | | returns.put("orderProductDetail",orderProductDetail); |
| | | returns.put("order",orderMapper.selectOne(new QueryWrapper<Order>().eq("order_id",orderId))); |
| | | return returns; |
| | | } |
| | | |
| | | public Object printOrderProductGlassDetailMonolithic(String orderId,List<String> productId) { |
| | | List<Map<String,Object>> orderProductDistinct; |
| | | if (productId.size()>0){ |
| | | orderProductDistinct = orderDetailMapper.getOrderProductDistinctByIds(orderId,productId); |
| | | }else{ |
| | | orderProductDistinct = orderDetailMapper.getOrderProductDistinctById(orderId); |
| | | } |
| | | |
| | | Map<String,Object> returns = new HashMap<>(); |
| | | returns.put("order",orderMapper.selectOne(new QueryWrapper<Order>().eq("order_id",orderId))); |
| | | |
| | | List<Map<String,Object>> orderProductDetail = new ArrayList<>(); |
| | | |
| | | orderProductDistinct.forEach(map->{ |
| | | Map<String,Object> orderProductDetailMap = new HashMap<>(); |
| | | orderProductDetailMap.put("productId",map.get("productId")); |
| | | orderProductDetailMap.put("productName",map.get("productName")); |
| | | List<Map<String,Object>> orderDetails = orderDetailMapper.getOrderProductByProductIds(map.get("productId"),orderId); |
| | | List<Map<String,Object>> orderProductDetail1 = new ArrayList<>(); |
| | | |
| | | for(Map<String,Object> objectMap:orderDetails){ |
| | | Map<String,Object> orderProductDetailMap1 = new HashMap<>(); |
| | | orderProductDetailMap1.put("detail",objectMap.get("detail").toString()); |
| | | List<Map<String,Object>> orderGlassDetails =orderGlassDetailMapper.getOrderGlassDetailByProductId(objectMap.get("order_id").toString(), |
| | | objectMap.get("detail").toString(), Long.valueOf(objectMap.get("product_id").toString())); |
| | | orderProductDetailMap1.put("orderGlassDetails",orderGlassDetails); |
| | | orderProductDetail1.add(orderProductDetailMap1); |
| | | } |
| | | |
| | | /*orderDetails.forEach(orderDetail->{ |
| | | List<OrderGlassDetail> glassChildList=orderGlassDetailMapper.getOrderGlassDetailByProductIdGlassChild(orderDetail.getOrderId(),orderDetail.getOrderNumber()); |
| | | |
| | | for (OrderGlassDetail glassChildLists:glassChildList){ |
| | | orderProductDetailMap1.put("glassChild",glassChildLists.getGlassChild()); |
| | | List<OrderGlassDetail> orderGlassDetails =orderGlassDetailMapper.getOrderGlassDetailByProductId(orderDetail.getOrderId(),orderDetail.getOrderNumber(),glassChildLists.getGlassChild()); |
| | | Integer differentSize = orderGlassDetailMapper.getDifferentSizeNumber(orderId,orderDetail.getOrderNumber()); |
| | | orderDetail.setDifferentSize(differentSize); |
| | | orderDetail.setOrderGlassDetails(orderGlassDetails); |
| | | orderProductDetailMap1.put("orderGlassDetail",orderGlassDetails); |
| | | } |
| | | orderProductDetail1.add(orderProductDetailMap1); |
| | | |
| | | });*/ |
| | | orderProductDetailMap.put("productDetail",orderProductDetail1); |
| | | orderProductDetail.add(orderProductDetailMap); |
| | | }); |
| | | returns.put("orderDetail",orderProductDetail); |
| | | return returns; |
| | | } |
| | | |
| | |
| | | List<OrderDetail> orderDetails = orderDetailMapper.getOrderProductByProductId(map.get("productId"),orderId); |
| | | orderDetails.forEach(orderDetail->{ |
| | | orderDetail.setGrossArea( |
| | | Double.parseDouble(String.format("%.3f", |
| | | orderDetail.getWidth()*orderDetail.getHeight()/1000000) |
| | | ) * orderDetail.getQuantity() |
| | | /*Double.parseDouble(String.format("%.3f",Double.parseDouble( |
| | | String.format("%.3f", |
| | | orderDetail.getWidth()*orderDetail.getHeight()/1000000) |
| | | ) * orderDetail.getQuantity()))*/ |
| | | orderDetail.getComputeGrossArea() |
| | | ); |
| | | |
| | | List<OrderGlassDetail> orderGlassDetails = |
| | |
| | | new QueryWrapper<OrderGlassDetail>(). |
| | | eq("order_id",orderId). |
| | | eq("order_number",orderDetail.getOrderNumber()) |
| | | ); |
| | | ); |
| | | Integer differentSize = orderGlassDetailMapper.getDifferentSizeNumber(orderId,orderDetail.getOrderNumber()); |
| | | orderDetail.setDifferentSize(differentSize); |
| | | orderDetail.setOrderGlassDetails(orderGlassDetails); |
| | | }); |
| | | |
| | |
| | | }); |
| | | returns.put("orderDetail",orderProductDetail); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | return returns; |
| | | } |
| | | |
| | | public boolean updateOrderPrintNumber(String orderId) { |
| | | return orderMapper.updateOrderPrintNumber(orderId); |
| | | } |
| | | |
| | | public String updateOrderId(Map<String, Object> map) { |
| | | String saveState = "true"; |
| | | JSONObject orderJson = new JSONObject(map); |
| | | String oldOrderId = orderJson.getString("oldOrderId"); |
| | | String newOrderId = orderJson.getString("newOrderId"); |
| | | String orderIdType = orderJson.getString("orderIdType"); |
| | | |
| | | Log log = new Log(); |
| | | log.setContent(map.toString()); |
| | | log.setFunction("updateOrderId修改订单号"); |
| | | log.setOperator(orderJson.getString("creator")); |
| | | |
| | | |
| | | if(!Objects.equals(newOrderId, oldOrderId)){ |
| | | if(newOrderId.length()!=10){ |
| | | return "false4"; |
| | | } |
| | | if(!newOrderId.substring(2, 10).matches("\\d+")){ |
| | | return "false5"; |
| | | } |
| | | if(Objects.equals(orderIdType, "day")){ |
| | | if(orderMapper.selectOrderIdDay(oldOrderId)==1){ |
| | | return "false6"; |
| | | } |
| | | }else if(Objects.equals(orderIdType, "month")){ |
| | | if(orderMapper.selectOrderIdMonth(oldOrderId)==1){ |
| | | return "false6"; |
| | | } |
| | | }else if(Objects.equals(orderIdType, "year")){ |
| | | if(orderMapper.selectOrderIdYear(oldOrderId)==1){ |
| | | return "false6"; |
| | | } |
| | | } |
| | | String substring = newOrderId.substring(1, 3); |
| | | Integer substringInt = Integer.parseInt(newOrderId.substring(2, 10)); |
| | | if(!substring.equals("NG")){ |
| | | substring="NG"; |
| | | } |
| | | //大于输入订单号的数量 |
| | | Integer count1 = orderMapper.selectOrderIdMin(substringInt); |
| | | //输入订单号存在的数量 |
| | | Integer count2 = orderMapper.selectOrderIdIs(substringInt); |
| | | if(count1>0 && count2==0){ |
| | | orderMapper.updateOrderId(oldOrderId,newOrderId); |
| | | saveState= "true"; |
| | | logService.saveLog(log); |
| | | }else if(count1==0){ |
| | | saveState= "false1"; |
| | | ; |
| | | }else if(count2>0){ |
| | | saveState= "false2"; |
| | | } |
| | | }else{ |
| | | saveState= "false3"; |
| | | } |
| | | return saveState; |
| | | } |
| | | |
| | | public Boolean selectDifferentSize(String orderId) { |
| | | return !orderMapper.selectDifferentSize(orderId).isEmpty(); |
| | | } |
| | | |
| | | public Object processBack(String orderId,Integer status) { |
| | | //判断是否转优化 |
| | | if(flowCardMapper.flowCardToOptimizeCount(orderId)>0){ |
| | | return "false1"; |
| | | } |
| | | //判断是否有报工 |
| | | if(flowCardMapper.reportingWorkCountByOrderId(orderId)>0){ |
| | | return "false2"; |
| | | } |
| | | //判断是否有库存 |
| | | if(orderMapper.searchOrderWarehousing(orderId)>0){ |
| | | return "false3"; |
| | | } |
| | | //退回到生产加工单 |
| | | if(status<5){ |
| | | //更新小片明细表分架状态 |
| | | flowCardMapper.updateDeleteState(orderId,"all"); |
| | | //删除此订单小片流程报工明细 |
| | | flowCardMapper.deleteReportingWorkByOrderId(orderId); |
| | | //删除流程卡 |
| | | flowCardMapper.deleteFlowCardMp(orderId,"all"); |
| | | //删除流程卡排序 |
| | | flowCardMapper.deleteflowCardSortByOrderId(orderId); |
| | | flowCardMapper.updateProcessingCard(orderId, 0); |
| | | } |
| | | //退回到订单审核后 |
| | | if(status<4){ |
| | | workOrderMapper.deleteOrderWorkMp(orderId, null); |
| | | workOrderMapper.updateWorkType(orderId, 0); |
| | | } |
| | | //退回到工艺审核后 |
| | | if(status<3){ |
| | | orderMapper.backReviewOrderById(orderId); |
| | | } |
| | | //退回到下单后 |
| | | if(status<2){ |
| | | orderMapper.reviewProcessById(orderId,0); |
| | | } |
| | | //日志传入 |
| | | Log log = new Log(); |
| | | log.setOperator((String) StpUtil.getLoginId()); |
| | | log.setOperatorId((String) StpUtil.getLoginId()); |
| | | log.setContent(String.valueOf(status)); |
| | | log.setFunction("updateOrderMoney金额重置:"+orderId); |
| | | return true; |
| | | } |
| | | |
| | | public Object scannerGlassInfo(String projectNo) { |
| | | try{ |
| | | String projectId = "P" + projectNo.substring(0,8); |
| | | //炉号 |
| | | Integer heatNo = Integer.valueOf(projectNo.substring(8,11)); |
| | | //炉内序号 |
| | | Integer sortNo = Integer.valueOf(projectNo.substring(11,14)); |
| | | String processId = orderMapper.getProcessIdByOptimizeHeatDetail(projectId,heatNo,sortNo); |
| | | String orderId = flowCardMapper.getOrderIdByProcessId(processId); |
| | | return orderMapper.scannerGlassInfo(projectId,heatNo,sortNo,orderId); |
| | | }catch (Exception e){ |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | | public Object uploadDxf(Map<String,Object> object) { |
| | | String fileName = ""; |
| | | if (object.get("fileName") != null) { |
| | | fileName = object.get("fileName").toString(); |
| | | } |
| | | String fileData = ""; |
| | | if (object.get("fileData") != null) { |
| | | fileData = object.get("fileData").toString(); |
| | | } |
| | | byte[] dxfData = Base64.getDecoder().decode(fileData); |
| | | String orderId="NG25010101"; |
| | | Integer orderNumber=1; |
| | | //orderMapper.saveOrderFile(fileName, fileData,orderId,orderNumber); |
| | | return true; |
| | | } |
| | | |
| | | public Map<String,Object> selectUploadDxf(Map<String,Object> object) { |
| | | String orderId = ""; |
| | | if (object.get("orderId") != null) { |
| | | orderId = object.get("orderId").toString(); |
| | | } |
| | | int orderNumber =0; |
| | | if (object.get("orderNumber") != null) { |
| | | orderNumber = Integer.parseInt(object.get("orderNumber").toString()); |
| | | } |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderMapper.selectOrderFile(orderId,orderNumber)); |
| | | return map; |
| | | } |
| | | |
| | | public boolean updateOrderFile(JSONObject object) throws JsonProcessingException { |
| | | String orderId = ""; |
| | | if (object.get("orderId") != null) { |
| | | orderId = object.get("orderId").toString(); |
| | | } |
| | | int orderNumber =0; |
| | | if (object.get("orderNumber") != null) { |
| | | orderNumber = Integer.parseInt(object.get("orderNumber").toString()); |
| | | } |
| | | String dataBase64 = ""; |
| | | if (object.get("dataBase64") != null) { |
| | | dataBase64 = object.get("dataBase64").toString(); |
| | | } |
| | | String fileJson = null; |
| | | ObjectMapper om = new ObjectMapper(); |
| | | if (object.get("fileJson") != null) { |
| | | fileJson = om.writeValueAsString(object.get("fileJson")); |
| | | } |
| | | Map<String,String> orderFile =orderMapper.selectOrderFile(orderId,orderNumber); |
| | | if(orderFile!=null){ |
| | | orderMapper.updateOrderFile("map.dxf", dataBase64,orderId,orderNumber,fileJson); |
| | | }else{ |
| | | orderMapper.saveOrderFile("map.dxf", dataBase64,orderId,orderNumber,fileJson); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public Map<String,Object> appGetOrderList(List<String> dates) { |
| | | //设置当前时间 |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(30).toString(); |
| | | if(dates !=null && dates.size()==2){ |
| | | if(dates.get(0) != null){ |
| | | startDate = String.valueOf(dates.get(0)); |
| | | } |
| | | if(dates.get(1) != null){ |
| | | endDate = String.valueOf(dates.get(1)); |
| | | } |
| | | } |
| | | List<String> date = new ArrayList<>(); |
| | | date.add(startDate); |
| | | date.add(endDate); |
| | | |
| | | List<Order> list = orderMapper.selectList(new LambdaQueryWrapper<Order>() |
| | | .apply("create_order > 0") |
| | | .apply("date(create_time) between {0} and {1}",startDate, endDate) |
| | | ); |
| | | Integer quantity = 0; |
| | | Double area = 0.00; |
| | | Double perimeter = 0.00; |
| | | for(Order order:list){ |
| | | quantity += Integer.parseInt(String.valueOf(order.getQuantity())); |
| | | area += Double.parseDouble(String.valueOf(order.getArea())); |
| | | perimeter += order.getPerimeter(); |
| | | } |
| | | Map<String, Object> totalSum = new HashMap<>(); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | totalSum.put("quantity",quantity); |
| | | totalSum.put("area", df.format(area)); |
| | | totalSum.put("perimeter", df.format(perimeter)); |
| | | totalSum.put("count", list.size()); |
| | | |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",list); |
| | | map.put("date",date); |
| | | map.put("totalSum",totalSum); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | //工艺属性配置查询 |
| | | public Map<String,Object> processAttributeConfig() { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | List<Map<String,Object>> processList = orderMapper.selectProcessAttributeConfigOne(); |
| | | for (Map<String,Object> objectMap:processList){ |
| | | objectMap.put("detail",orderMapper.selectProcessAttributeConfigTow(objectMap.get("input_type").toString())); |
| | | } |
| | | map.put("data",processList); |
| | | return map; |
| | | } |
| | | } |