From 558ecd11e9dbdac537e6cf669fd079d7b713469a Mon Sep 17 00:00:00 2001 From: zhc077 <565291854> Date: Tue, 16 May 2023 16:07:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E8=AE=A1=E5=88=92=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96-=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96=205.16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/message/ZySpeechMessageList.vue | 28 +- .../service/impl/ZyOrdersServiceImpl.java | 709 +++++---- .../controller/ZyProductPlanController.java | 2 +- .../impl/IZyProductPlanAutoServiceImpl.java | 22 +- .../service/impl/WorkOrderServiceImpl.java | 1278 +++++++++-------- 5 files changed, 1034 insertions(+), 1005 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/message/ZySpeechMessageList.vue b/ant-design-vue-jeecg/src/views/message/ZySpeechMessageList.vue index a2ab4071..d246f80b 100644 --- a/ant-design-vue-jeecg/src/views/message/ZySpeechMessageList.vue +++ b/ant-design-vue-jeecg/src/views/message/ZySpeechMessageList.vue @@ -84,11 +84,14 @@ class="j-table-force-nowrap" @change="handleTableChange"> + 重置 + + 播放 - - 删除 - + + 删除 + @@ -133,7 +136,7 @@ export default { dataIndex: 'message' }, { - title: '播报状态', + title: '已播报', align: "center", dataIndex: 'status_dictText' }, @@ -223,7 +226,7 @@ export default { onend: () => { // console.log("End utterance"); console.log("------------delete----------【" + mess + "】消息播报完成,删除该消息") - this.updateMessageStatus(obj['id']); + this.updateMessageStatus(obj['id'], 1); }, //恢复播放 onresume: () => { @@ -257,18 +260,25 @@ export default { }) }, - updateMessageStatus(id) { + reSetStatus(id, ststus) { + this.updateMessageStatus(id, ststus); + // this.getMessageList(); + this.loading = false + this.loadData(); + }, + + updateMessageStatus(id, status) { // console.log("删除已播报消息:" + id); let parma = { "id": id, - "status": '1', + "status": status, } putAction(this.url.edit, parma).then((res) => { if (res.success) { for (let i = 0; i < this.messageList.length; i++) { if (this.messageList[i].id === id) { //消息删除成功,从datasource队列中删除消息 - this.messageList.splice(i, 1); + this.messageList.splice(i, '1'); } } } else { @@ -288,7 +298,7 @@ export default { console.log("--------timer is exec,the current time:" + new Date().toLocaleString()) this.getMessageList(); } else { - console.log("-------上次消息列表未处理完---HOLD DOWN") + console.log("-------上次消息列表未处理完---HOLD ON") } }, this.millisec) }, diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/service/impl/ZyOrdersServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/service/impl/ZyOrdersServiceImpl.java index 4b6c4e6d..ce734e63 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/service/impl/ZyOrdersServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/zyorders/service/impl/ZyOrdersServiceImpl.java @@ -1,355 +1,354 @@ -package org.jeecg.modules.demo.zyorders.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.jeecg.modules.demo.customerinvoice.entity.CustomerInvoice; -import org.jeecg.modules.demo.customerinvoice.mapper.CustomerInvoiceMapper; -import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress; -import org.jeecg.modules.demo.customerreceivingaddress.mapper.CustomerReceivingAddressMapper; -import org.jeecg.modules.demo.goodsaccessories.entity.GoodsAccessories; -import org.jeecg.modules.demo.goodsaccessories.mapper.GoodsAccessoriesMapper; -import org.jeecg.modules.demo.goodsfabric.entity.GoodsFabric; -import org.jeecg.modules.demo.goodsfabric.mapper.GoodsFabricMapper; -import org.jeecg.modules.demo.goodsmodule.entity.GoodsModule; -import org.jeecg.modules.demo.goodsmodule.mapper.GoodsModuleMapper; -import org.jeecg.modules.demo.ordergoods.entity.OrderGoods; -import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk; -import org.jeecg.modules.demo.ordergoods.mapper.OrderGoodsMapper; -import org.jeecg.modules.demo.ordergoodsaccessories.entity.OrderGoodsAccessories; -import org.jeecg.modules.demo.ordergoodsaccessories.mapper.OrderGoodsAccessoriesMapper; -import org.jeecg.modules.demo.ordergoodsfabric.entity.OrderGoodsFabric; -import org.jeecg.modules.demo.ordergoodsfabric.mapper.OrderGoodsFabricMapper; -import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; -import org.jeecg.modules.demo.ordergoodsmodule.mapper.OrderGoodsModuleMapper; -import org.jeecg.modules.demo.zygoods.entity.ZyGoods; -import org.jeecg.modules.demo.zygoods.mapper.ZyGoodsMapper; -import org.jeecg.modules.demo.zyorders.entity.ZyOrders; -import org.jeecg.modules.demo.zyorders.entity.ZyOrdersJk; -import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper; -import org.jeecg.modules.demo.zyorders.service.IZyOrdersService; -import org.jeecg.modules.message.entity.ZySpeechMessage; -import org.jeecg.modules.message.mapper.ZySpeechMessageMapper; -import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -/** - * @Description: 订单基本信息管理 - * @Author: jeecg-boot - * @Date: 2022-12-26 - * @Version: V1.0 - */ -@Service -public class ZyOrdersServiceImpl extends ServiceImpl implements IZyOrdersService { - - //商品 - @Autowired - private ZyGoodsMapper zyGoodsMapper; - - //订单商品表 - @Autowired - private OrderGoodsMapper zyOrderGoodsMapper; - - //商品模块表 - @Autowired - private GoodsModuleMapper zyGoodsModuleMapper; - - - //订单商品模块表 - @Autowired - private OrderGoodsModuleMapper zyOrderGoodsModuleMapper; - - - //商品面料表 - @Autowired - private GoodsFabricMapper zyGoodsFabricMapper; - - //订单商品面料表 - @Autowired - private OrderGoodsFabricMapper zyOrderGoodsFabricMapper; - - //商品辅料表 - @Autowired - private GoodsAccessoriesMapper zyGoodsAccessoriesMapper; - - //订单商品辅料表 - @Autowired - private OrderGoodsAccessoriesMapper zyOrderGoodsAccessoriesMapper; - - - - //顾客地址表 - @Autowired - CustomerReceivingAddressMapper customerReceivingAddressMapper; - - //客户发票信息 - @Autowired - CustomerInvoiceMapper customerInvoiceMapper; - - //定时播报 - @Autowired - private ZySpeechMessageMapper zySpeechMessageMapper; - - - - - /** - * 大屏数据-获取订单的状态 - * @return - */ - @Override - public List getOrderStatus() { - String starTime; - String endTime; - Date date = new Date(); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - String todayStr = formatter.format(date);//今天 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - //把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天) - calendar.add(Calendar.DATE, 1); - //这个时间就是日期往后推一天的结果,明天 - date = calendar.getTime(); - String tomorrowStr = formatter.format(date); - - starTime = todayStr + " 00:00:00"; - endTime = tomorrowStr + " 00:00:00"; - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.ge("create_time", starTime).le("create_time", endTime).eq("payment_status", 1); - - List zyOrderList = baseMapper.selectList(wrapper); - return zyOrderList; - } - - /** - * 大屏数据-获取历史订单 - * @return - */ - @Override - public List getOldOrder() { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper -// .eq("is_delete", 0) - .orderByDesc("create_time"); - List orderList = baseMapper.selectList(wrapper); - return orderList; - } - - /** - * 获取今日订单及七日订单 - * @return - */ - @Override - public TodayOrderAndQIriVo getOrder() { - TodayOrderAndQIriVo todayOrderAndQIriVo = baseMapper.getTotalOrderAndWeek(); - if (todayOrderAndQIriVo != null) { - return todayOrderAndQIriVo; - } else { - return null; - } - } - - /** - * - * @param zyOrdersJk - * @param orderGoodsJkList - * @return - */ - @Override - public List orderJk(ZyOrdersJk zyOrdersJk, List orderGoodsJkList) { - - Double actual_payment = 0.00; - Double money = 0.00; - for(int i = 0 ; i < orderGoodsJkList.size() ; i++){ - ZyGoods zyGoods = zyGoodsMapper.selectById(orderGoodsJkList.get(i).getGoodsId()); - money = money + zyGoods.getUnitPrice()*orderGoodsJkList.get(i).getGoodsNum(); - actual_payment = actual_payment + zyGoods.getPromotionPrice()*orderGoodsJkList.get(i).getGoodsNum(); - } - ZyOrders zyOrders = new ZyOrders(); - zyOrders.setIschild(0); - zyOrders.setOrderTime(new Date()); - zyOrders.setOrdersNum(getOrdersNum()); - zyOrders.setMoney(money); - zyOrders.setFreight(zyOrdersJk.getFreight()); - zyOrders.setPromotionPrice(money-actual_payment); - zyOrders.setActualPayment(actual_payment); - zyOrders.setDeliveryTime(zyOrdersJk.getDeliveryTime()); - zyOrders.setOrdersType(zyOrdersJk.getOrdersType()); - zyOrders.setUserId(zyOrdersJk.getUserId()); - zyOrders.setGoodsQuantity(zyOrdersJk.getGoodsQuantity()); - //顾客地址 - if(zyOrdersJk.getAddressId()!=null&&zyOrdersJk.getAddressId()!="") - { - CustomerReceivingAddress customerReceivingAddress = customerReceivingAddressMapper.selectById(zyOrdersJk.getAddressId()); - zyOrders.setCityId(customerReceivingAddress.getCityId()); - zyOrders.setAddress(customerReceivingAddress.getAddress()); - zyOrders.setZipCode(customerReceivingAddress.getZipCode()); - zyOrders.setReceiver(zyOrdersJk.getReceiver()); - zyOrders.setMobile(customerReceivingAddress.getMobile()); - } - - //顾客发票 - if(zyOrdersJk.getInvoiceId()!=null&&zyOrdersJk.getInvoiceId()!="") - { - CustomerInvoice customerInvoice = customerInvoiceMapper.selectById(zyOrdersJk.getInvoiceId()); - zyOrders.setInvoiceCustomerType(Integer.parseInt(customerInvoice.getCustomerType())); - zyOrders.setInvoiceType(Integer.parseInt(customerInvoice.getInvoiceType())); - zyOrders.setTaxIdentificationNumber(customerInvoice.getTaxIdentificationNumber()); - zyOrders.setAddressBilling(customerInvoice.getAddress()); - zyOrders.setTelephone(customerInvoice.getTelephone()); - zyOrders.setBankPublic(customerInvoice.getBankDeposit()); - zyOrders.setAccountNumber(customerInvoice.getAccountNumber()); - } - - zyOrders.setSalesEnterpriseId(zyOrdersJk.getSalesEnterpriseId()); - zyOrders.setSalespersonId(zyOrdersJk.getSalespersonId()); - zyOrders.setLogisticsEnterprisesId(zyOrdersJk.getLogisticsEnterprisesId()); - zyOrders.setDeliveryStatus(0); - zyOrders.setPaymentStatus(1); - zyOrders.setPaymentTime(new Date()); - baseMapper.insert(zyOrders); - for(int j = 0 ; j < orderGoodsJkList.size() ; j++){ - ZyGoods zyGoods = zyGoodsMapper.selectById(orderGoodsJkList.get(j).getGoodsId()); - OrderGoods orderGoods = new OrderGoods(); - orderGoods.setOrdersId(zyOrders.getId()); - orderGoods.setGoodsId(orderGoodsJkList.get(j).getGoodsId()); - orderGoods.setGoodsNum(orderGoodsJkList.get(j).getGoodsNum()); - orderGoods.setGoodsCode(zyGoods.getGoodsCode()); - orderGoods.setGoodsName(zyGoods.getGoodsName()); - orderGoods.setGoodsIntr(zyGoods.getGoodsIntr()); - orderGoods.setCustomized(zyGoods.getCustomized()); - orderGoods.setMeasureId(zyOrdersJk.getMeasureId()); - orderGoods.setGoodsPicture(zyGoods.getGoodsPicture()); - orderGoods.setDefaultPicture(zyGoods.getDefaultPicture()); - orderGoods.setGoodsVideo(zyGoods.getGoodsVideo()); - orderGoods.setClothsTypeId(zyGoods.getClothsTypeId()); - orderGoods.setStyleId(zyGoods.getStyleId()); - orderGoods.setModelId(zyGoods.getModelId()); - orderGoods.setUnit(zyGoods.getUnit()); - orderGoods.setNumber(zyGoods.getNumber()); - orderGoods.setUnitPrice(zyGoods.getUnitPrice()); - orderGoods.setDiscount(zyGoods.getDiscount()); - orderGoods.setPromotionPrice(zyGoods.getPromotionPrice()); - orderGoods.setRecommend(zyGoods.getRecommend()); - orderGoods.setPlaceOrigin(zyGoods.getPlaceOrigin()); - orderGoods.setStatus(zyGoods.getStatus()); - orderGoods.setTotalPrice(zyGoods.getUnitPrice()*orderGoodsJkList.get(j).getGoodsNum()); - orderGoods.setPayTotalPrice(zyGoods.getPromotionPrice()*orderGoodsJkList.get(j).getGoodsNum()); - zyOrderGoodsMapper.insert(orderGoods); - GoodsModule goodsModule = new GoodsModule(); - QueryWrapper queryWrapperzsm = new QueryWrapper(); - queryWrapperzsm.eq("goods_id",zyGoods.getId()); - queryWrapperzsm.eq("style_id",zyGoods.getStyleId()); - List listzsm = zyGoodsModuleMapper.selectList(queryWrapperzsm); - for (int k = 0 ; k < listzsm.size() ; k++){ - OrderGoodsModule orderGoodsModule = new OrderGoodsModule(); - orderGoodsModule.setOrderGoodsId(orderGoods.getId()); - orderGoodsModule.setGoodsId(zyGoods.getId()); - orderGoodsModule.setStyleId(zyGoods.getStyleId()); - orderGoodsModule.setStyleModuleId(listzsm.get(k).getStyleModuleId()); - orderGoodsModule.setModuleId(listzsm.get(k).getModuleId()); - zyOrderGoodsModuleMapper.insert(orderGoodsModule); - } - GoodsFabric goodsFabric = new GoodsFabric(); - QueryWrapper queryWrapperzsf =new QueryWrapper(); - queryWrapperzsf.eq("goods_id",zyGoods.getId()); - List listzsf = zyGoodsFabricMapper.selectList(queryWrapperzsf); - for (int o = 0 ; o < listzsf.size() ; o++){ - OrderGoodsFabric orderGoodsFabric = new OrderGoodsFabric(); - orderGoodsFabric.setOrderGoodsId(orderGoods.getId()); - orderGoodsFabric.setGoodsId(zyGoods.getId()); - orderGoodsFabric.setFabricId(listzsf.get(o).getFabricId()); - zyOrderGoodsFabricMapper.insert(orderGoodsFabric); - } - GoodsAccessories goodsAccessories = new GoodsAccessories(); - QueryWrapper queryWrapperzsa = new QueryWrapper(); - queryWrapperzsa.eq("goods_id",zyGoods.getId()); - List listzsa = zyGoodsAccessoriesMapper.selectList(queryWrapperzsa); - for (int p = 0 ; p < listzsa.size() ; p++){ - OrderGoodsAccessories orderGoodsAccessories = new OrderGoodsAccessories(); - orderGoodsAccessories.setOrderGoodsId(orderGoods.getId()); - orderGoodsAccessories.setGoodsId(zyGoods.getId()); - orderGoodsAccessories.setAccessoriesId(listzsa.get(p).getAccessoriesId()); - zyOrderGoodsAccessoriesMapper.insert(orderGoodsAccessories); - } - - - } - List ids = new ArrayList<>(); - ZyOrders zos = new ZyOrders(); - QueryWrapper queryWrapperzos = new QueryWrapper(); - queryWrapperzos.eq("order_id",zyOrders.getId()); - List listzos = baseMapper.selectList(queryWrapperzos); - if(listzos.size()>0){ - //return Result.error("该订单已经拆分,不可以再次拆单!"); - return null; - }else{ - OrderGoods orderGoods = new OrderGoods(); - QueryWrapper queryWrapperog = new QueryWrapper(); - queryWrapperog.eq("orders_id",zyOrders.getId()); - List listog = zyOrderGoodsMapper.selectList(queryWrapperog); - if(listog.size()>0){ - for (int i = 0 ; i < listog.size() ; i++){ - ZyOrders zo = new ZyOrders(); - zo = zyOrders; - zo.setId(null); - zo.setOrdersNum(getOrdersNum()); - zo.setOrderId(listog.get(i).getId()); - zo.setFreight(Double.parseDouble("0")); - zo.setIschild(1); - zo.setOrderId(zyOrders.getId()); - zo.setMoney(listog.get(i).getTotalPrice()); - zo.setPromotionPrice(listog.get(i).getPromotionPrice()); - zo.setActualPayment(listog.get(i).getPayTotalPrice()); - zo.setGoodsQuantity(1); - baseMapper.insert(zo); - ids.add(zo.getId()); - OrderGoods og = new OrderGoods(); - og = listog.get(i); - og.setOrdersId(zo.getId()); - zyOrderGoodsMapper.updateById(og); - //定时播报 - ZySpeechMessage message=new ZySpeechMessage(); - //订单商品id - message.setOrdergoodsId(zo.getId()); -// //工单id -// message.setWorkorderId(); -// //生产计划工序id -// message.setZyplanprocessId(); - //消息 - message.setMessage("您有新的订单,订单编号:"+zo.getOrdersNum()+",请及时查看!"); - zySpeechMessageMapper.insert(message); - } - } - } - return ids; - } - - - /** - * 生成订单编号 - * - * @param - * @return - */ - public String getOrdersNum() { - String mrstr = "000000000000000000"; - QueryWrapper qw=new QueryWrapper(); - int listsize = baseMapper.selectCount(qw); - int strsize = listsize+1; - String str = strsize+""; - int strlength = str.length(); - String substr = mrstr.substring(0,mrstr.length()-strlength); - String OrdersNum = substr+str; - return OrdersNum; - } - -} +package org.jeecg.modules.demo.zyorders.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.jeecg.modules.demo.customerinvoice.entity.CustomerInvoice; +import org.jeecg.modules.demo.customerinvoice.mapper.CustomerInvoiceMapper; +import org.jeecg.modules.demo.customerreceivingaddress.entity.CustomerReceivingAddress; +import org.jeecg.modules.demo.customerreceivingaddress.mapper.CustomerReceivingAddressMapper; +import org.jeecg.modules.demo.goodsaccessories.entity.GoodsAccessories; +import org.jeecg.modules.demo.goodsaccessories.mapper.GoodsAccessoriesMapper; +import org.jeecg.modules.demo.goodsfabric.entity.GoodsFabric; +import org.jeecg.modules.demo.goodsfabric.mapper.GoodsFabricMapper; +import org.jeecg.modules.demo.goodsmodule.entity.GoodsModule; +import org.jeecg.modules.demo.goodsmodule.mapper.GoodsModuleMapper; +import org.jeecg.modules.demo.ordergoods.entity.OrderGoods; +import org.jeecg.modules.demo.ordergoods.entity.OrderGoodsJk; +import org.jeecg.modules.demo.ordergoods.mapper.OrderGoodsMapper; +import org.jeecg.modules.demo.ordergoodsaccessories.entity.OrderGoodsAccessories; +import org.jeecg.modules.demo.ordergoodsaccessories.mapper.OrderGoodsAccessoriesMapper; +import org.jeecg.modules.demo.ordergoodsfabric.entity.OrderGoodsFabric; +import org.jeecg.modules.demo.ordergoodsfabric.mapper.OrderGoodsFabricMapper; +import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; +import org.jeecg.modules.demo.ordergoodsmodule.mapper.OrderGoodsModuleMapper; +import org.jeecg.modules.demo.zygoods.entity.ZyGoods; +import org.jeecg.modules.demo.zygoods.mapper.ZyGoodsMapper; +import org.jeecg.modules.demo.zyorders.entity.ZyOrders; +import org.jeecg.modules.demo.zyorders.entity.ZyOrdersJk; +import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper; +import org.jeecg.modules.demo.zyorders.service.IZyOrdersService; +import org.jeecg.modules.message.entity.ZySpeechMessage; +import org.jeecg.modules.message.mapper.ZySpeechMessageMapper; +import org.jeecg.modules.orderbymakeclothplan.vo.TodayOrderAndQIriVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * @Description: 订单基本信息管理 + * @Author: jeecg-boot + * @Date: 2022-12-26 + * @Version: V1.0 + */ +@Service +public class ZyOrdersServiceImpl extends ServiceImpl implements IZyOrdersService { + + //商品 + @Autowired + private ZyGoodsMapper zyGoodsMapper; + + //订单商品表 + @Autowired + private OrderGoodsMapper zyOrderGoodsMapper; + + //商品模块表 + @Autowired + private GoodsModuleMapper zyGoodsModuleMapper; + + + //订单商品模块表 + @Autowired + private OrderGoodsModuleMapper zyOrderGoodsModuleMapper; + + + //商品面料表 + @Autowired + private GoodsFabricMapper zyGoodsFabricMapper; + + //订单商品面料表 + @Autowired + private OrderGoodsFabricMapper zyOrderGoodsFabricMapper; + + //商品辅料表 + @Autowired + private GoodsAccessoriesMapper zyGoodsAccessoriesMapper; + + //订单商品辅料表 + @Autowired + private OrderGoodsAccessoriesMapper zyOrderGoodsAccessoriesMapper; + + + //顾客地址表 + @Autowired + CustomerReceivingAddressMapper customerReceivingAddressMapper; + + //客户发票信息 + @Autowired + CustomerInvoiceMapper customerInvoiceMapper; + + //定时播报 + @Autowired + private ZySpeechMessageMapper zySpeechMessageMapper; + + + /** + * 大屏数据-获取订单的状态 + * + * @return + */ + @Override + public List getOrderStatus() { + String starTime; + String endTime; + Date date = new Date(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + String todayStr = formatter.format(date);//今天 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + //把日期往后增加一天.整数往后推,负数往前移动(1:表示明天、-1:表示昨天,0:表示今天) + calendar.add(Calendar.DATE, 1); + //这个时间就是日期往后推一天的结果,明天 + date = calendar.getTime(); + String tomorrowStr = formatter.format(date); + + starTime = todayStr + " 00:00:00"; + endTime = tomorrowStr + " 00:00:00"; + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.ge("create_time", starTime).le("create_time", endTime).eq("payment_status", 1); + + List zyOrderList = baseMapper.selectList(wrapper); + return zyOrderList; + } + + /** + * 大屏数据-获取历史订单 + * + * @return + */ + @Override + public List getOldOrder() { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper +// .eq("is_delete", 0) + .orderByDesc("create_time"); + List orderList = baseMapper.selectList(wrapper); + return orderList; + } + + /** + * 获取今日订单及七日订单 + * + * @return + */ + @Override + public TodayOrderAndQIriVo getOrder() { + TodayOrderAndQIriVo todayOrderAndQIriVo = baseMapper.getTotalOrderAndWeek(); + if (todayOrderAndQIriVo != null) { + return todayOrderAndQIriVo; + } else { + return null; + } + } + + /** + * @param zyOrdersJk + * @param orderGoodsJkList + * @return + */ + @Override + public List orderJk(ZyOrdersJk zyOrdersJk, List orderGoodsJkList) { + + Double actual_payment = 0.00; + Double money = 0.00; + for (int i = 0; i < orderGoodsJkList.size(); i++) { + ZyGoods zyGoods = zyGoodsMapper.selectById(orderGoodsJkList.get(i).getGoodsId()); + money = money + zyGoods.getUnitPrice() * orderGoodsJkList.get(i).getGoodsNum(); + actual_payment = actual_payment + zyGoods.getPromotionPrice() * orderGoodsJkList.get(i).getGoodsNum(); + } + ZyOrders zyOrders = new ZyOrders(); + zyOrders.setIschild(0); + zyOrders.setOrderTime(new Date()); + zyOrders.setOrdersNum(getOrdersNum()); + zyOrders.setMoney(money); + zyOrders.setFreight(zyOrdersJk.getFreight()); + zyOrders.setPromotionPrice(money - actual_payment); + zyOrders.setActualPayment(actual_payment); + zyOrders.setDeliveryTime(zyOrdersJk.getDeliveryTime()); + zyOrders.setOrdersType(zyOrdersJk.getOrdersType()); + zyOrders.setUserId(zyOrdersJk.getUserId()); + zyOrders.setGoodsQuantity(zyOrdersJk.getGoodsQuantity()); + //顾客地址 + if (zyOrdersJk.getAddressId() != null && zyOrdersJk.getAddressId() != "") { + CustomerReceivingAddress customerReceivingAddress = customerReceivingAddressMapper.selectById(zyOrdersJk.getAddressId()); + zyOrders.setCityId(customerReceivingAddress.getCityId()); + zyOrders.setAddress(customerReceivingAddress.getAddress()); + zyOrders.setZipCode(customerReceivingAddress.getZipCode()); + zyOrders.setReceiver(zyOrdersJk.getReceiver()); + zyOrders.setMobile(customerReceivingAddress.getMobile()); + } + + //顾客发票 + if (zyOrdersJk.getInvoiceId() != null && zyOrdersJk.getInvoiceId() != "") { + CustomerInvoice customerInvoice = customerInvoiceMapper.selectById(zyOrdersJk.getInvoiceId()); + zyOrders.setInvoiceCustomerType(Integer.parseInt(customerInvoice.getCustomerType())); + zyOrders.setInvoiceType(Integer.parseInt(customerInvoice.getInvoiceType())); + zyOrders.setTaxIdentificationNumber(customerInvoice.getTaxIdentificationNumber()); + zyOrders.setAddressBilling(customerInvoice.getAddress()); + zyOrders.setTelephone(customerInvoice.getTelephone()); + zyOrders.setBankPublic(customerInvoice.getBankDeposit()); + zyOrders.setAccountNumber(customerInvoice.getAccountNumber()); + } + + zyOrders.setSalesEnterpriseId(zyOrdersJk.getSalesEnterpriseId()); + zyOrders.setSalespersonId(zyOrdersJk.getSalespersonId()); + zyOrders.setLogisticsEnterprisesId(zyOrdersJk.getLogisticsEnterprisesId()); + zyOrders.setDeliveryStatus(0); + zyOrders.setPaymentStatus(1); + zyOrders.setPaymentTime(new Date()); + baseMapper.insert(zyOrders); + for (int j = 0; j < orderGoodsJkList.size(); j++) { + ZyGoods zyGoods = zyGoodsMapper.selectById(orderGoodsJkList.get(j).getGoodsId()); + OrderGoods orderGoods = new OrderGoods(); + orderGoods.setOrdersId(zyOrders.getId()); + orderGoods.setGoodsId(orderGoodsJkList.get(j).getGoodsId()); + orderGoods.setGoodsNum(orderGoodsJkList.get(j).getGoodsNum()); + orderGoods.setGoodsCode(zyGoods.getGoodsCode()); + orderGoods.setGoodsName(zyGoods.getGoodsName()); + orderGoods.setGoodsIntr(zyGoods.getGoodsIntr()); + orderGoods.setCustomized(zyGoods.getCustomized()); + orderGoods.setMeasureId(zyOrdersJk.getMeasureId()); + orderGoods.setGoodsPicture(zyGoods.getGoodsPicture()); + orderGoods.setDefaultPicture(zyGoods.getDefaultPicture()); + orderGoods.setGoodsVideo(zyGoods.getGoodsVideo()); + orderGoods.setClothsTypeId(zyGoods.getClothsTypeId()); + orderGoods.setStyleId(zyGoods.getStyleId()); + orderGoods.setModelId(zyGoods.getModelId()); + orderGoods.setUnit(zyGoods.getUnit()); + orderGoods.setNumber(zyGoods.getNumber()); + orderGoods.setUnitPrice(zyGoods.getUnitPrice()); + orderGoods.setDiscount(zyGoods.getDiscount()); + orderGoods.setPromotionPrice(zyGoods.getPromotionPrice()); + orderGoods.setRecommend(zyGoods.getRecommend()); + orderGoods.setPlaceOrigin(zyGoods.getPlaceOrigin()); + orderGoods.setStatus(zyGoods.getStatus()); + orderGoods.setTotalPrice(zyGoods.getUnitPrice() * orderGoodsJkList.get(j).getGoodsNum()); + orderGoods.setPayTotalPrice(zyGoods.getPromotionPrice() * orderGoodsJkList.get(j).getGoodsNum()); + zyOrderGoodsMapper.insert(orderGoods); + GoodsModule goodsModule = new GoodsModule(); + QueryWrapper queryWrapperzsm = new QueryWrapper(); + queryWrapperzsm.eq("goods_id", zyGoods.getId()); + queryWrapperzsm.eq("style_id", zyGoods.getStyleId()); + List listzsm = zyGoodsModuleMapper.selectList(queryWrapperzsm); + for (int k = 0; k < listzsm.size(); k++) { + OrderGoodsModule orderGoodsModule = new OrderGoodsModule(); + orderGoodsModule.setOrderGoodsId(orderGoods.getId()); + orderGoodsModule.setGoodsId(zyGoods.getId()); + orderGoodsModule.setStyleId(zyGoods.getStyleId()); + orderGoodsModule.setStyleModuleId(listzsm.get(k).getStyleModuleId()); + orderGoodsModule.setModuleId(listzsm.get(k).getModuleId()); + zyOrderGoodsModuleMapper.insert(orderGoodsModule); + } + GoodsFabric goodsFabric = new GoodsFabric(); + QueryWrapper queryWrapperzsf = new QueryWrapper(); + queryWrapperzsf.eq("goods_id", zyGoods.getId()); + List listzsf = zyGoodsFabricMapper.selectList(queryWrapperzsf); + for (int o = 0; o < listzsf.size(); o++) { + OrderGoodsFabric orderGoodsFabric = new OrderGoodsFabric(); + orderGoodsFabric.setOrderGoodsId(orderGoods.getId()); + orderGoodsFabric.setGoodsId(zyGoods.getId()); + orderGoodsFabric.setFabricId(listzsf.get(o).getFabricId()); + zyOrderGoodsFabricMapper.insert(orderGoodsFabric); + } + GoodsAccessories goodsAccessories = new GoodsAccessories(); + QueryWrapper queryWrapperzsa = new QueryWrapper(); + queryWrapperzsa.eq("goods_id", zyGoods.getId()); + List listzsa = zyGoodsAccessoriesMapper.selectList(queryWrapperzsa); + for (int p = 0; p < listzsa.size(); p++) { + OrderGoodsAccessories orderGoodsAccessories = new OrderGoodsAccessories(); + orderGoodsAccessories.setOrderGoodsId(orderGoods.getId()); + orderGoodsAccessories.setGoodsId(zyGoods.getId()); + orderGoodsAccessories.setAccessoriesId(listzsa.get(p).getAccessoriesId()); + zyOrderGoodsAccessoriesMapper.insert(orderGoodsAccessories); + } + + + } + List ids = new ArrayList<>(); + ZyOrders zos = new ZyOrders(); + QueryWrapper queryWrapperzos = new QueryWrapper(); + queryWrapperzos.eq("order_id", zyOrders.getId()); + List listzos = baseMapper.selectList(queryWrapperzos); + if (listzos.size() > 0) { + //return Result.error("该订单已经拆分,不可以再次拆单!"); + return null; + } else { + OrderGoods orderGoods = new OrderGoods(); + QueryWrapper queryWrapperog = new QueryWrapper(); + queryWrapperog.eq("orders_id", zyOrders.getId()); + List listog = zyOrderGoodsMapper.selectList(queryWrapperog); + if (listog.size() > 0) { + for (int i = 0; i < listog.size(); i++) { + ZyOrders zo = new ZyOrders(); + zo = zyOrders; + zo.setId(null); + zo.setOrdersNum(getOrdersNum()); + zo.setOrderId(listog.get(i).getId()); + zo.setFreight(Double.parseDouble("0")); + zo.setIschild(1); + zo.setOrderId(zyOrders.getId()); + zo.setMoney(listog.get(i).getTotalPrice()); + zo.setPromotionPrice(listog.get(i).getPromotionPrice()); + zo.setActualPayment(listog.get(i).getPayTotalPrice()); + zo.setGoodsQuantity(1); + baseMapper.insert(zo); + ids.add(zo.getId()); + OrderGoods og = new OrderGoods(); + og = listog.get(i); + og.setOrdersId(zo.getId()); + zyOrderGoodsMapper.updateById(og); + //定时播报 + ZySpeechMessage message = new ZySpeechMessage(); + //订单商品id + message.setOrdergoodsId(zo.getId()); +// //工单id +// message.setWorkorderId(); +// //生产计划工序id +// message.setZyplanprocessId(); + //消息 + String ordersNum = zo.getOrdersNum(); + String code = ordersNum.substring(ordersNum.length() - 6); + message.setMessage("您有新的订单,订单尾号:" + code + ",请及时查看!"); + zySpeechMessageMapper.insert(message); + } + } + } + return ids; + } + + + /** + * 生成订单编号 + * + * @param + * @return + */ + public String getOrdersNum() { + String mrstr = "000000000000000000"; + QueryWrapper qw = new QueryWrapper(); + int listsize = baseMapper.selectCount(qw); + int strsize = listsize + 1; + String str = strsize + ""; + int strlength = str.length(); + String substr = mrstr.substring(0, mrstr.length() - strlength); + String OrdersNum = substr + str; + return OrdersNum; + } + +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/controller/ZyProductPlanController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/controller/ZyProductPlanController.java index b090c7f7..2bbd6b06 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/controller/ZyProductPlanController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/controller/ZyProductPlanController.java @@ -99,7 +99,7 @@ public class ZyProductPlanController extends JeecgController()).forEach(e -> { // 5,生成物料单 zyPlanProcessService.createMaterialBill(e); - // 5,发送到仓库 + // 6,发送到仓库 zyPlanProcessService.sendToRepository(e); }); @@ -320,10 +321,27 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/workorder/service/impl/WorkOrderServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/workorder/service/impl/WorkOrderServiceImpl.java index 9391b8bd..03ce94e4 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/workorder/service/impl/WorkOrderServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/workorder/service/impl/WorkOrderServiceImpl.java @@ -1,638 +1,640 @@ -package org.jeecg.modules.workorder.service.impl; - - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.jeecg.common.api.vo.Result; -import org.jeecg.modules.demo.base.mapper.ZyProcessMapper; -import org.jeecg.modules.demo.customermeasure.entity.CustomerMeasure; -import org.jeecg.modules.demo.customermeasure.mapper.CustomerMeasureMapper; -import org.jeecg.modules.demo.ordergoods.entity.OrderGoods; -import org.jeecg.modules.demo.ordergoods.mapper.OrderGoodsMapper; -import org.jeecg.modules.demo.ordergoodsaccessories.entity.OrderGoodsAccessories; -import org.jeecg.modules.demo.ordergoodsaccessories.mapper.OrderGoodsAccessoriesMapper; -import org.jeecg.modules.demo.ordergoodsfabric.entity.OrderGoodsFabric; -import org.jeecg.modules.demo.ordergoodsfabric.mapper.OrderGoodsFabricMapper; -import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; -import org.jeecg.modules.demo.ordergoodsmodule.mapper.OrderGoodsModuleMapper; -import org.jeecg.modules.demo.pro.entity.ZyProcessAccessories; -import org.jeecg.modules.demo.pro.entity.ZyProcessFabric; -import org.jeecg.modules.demo.pro.entity.ZyProcessMachine; -import org.jeecg.modules.demo.pro.mapper.ZyProcessMachineMapper; -import org.jeecg.modules.demo.zyStyleModular.entity.ZyStyleModular; -import org.jeecg.modules.demo.zyStyleModular.mapper.ZyStyleModularMapper; -import org.jeecg.modules.demo.zyorders.entity.ZyOrders; -import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper; -import org.jeecg.modules.message.entity.ZySpeechMessage; -import org.jeecg.modules.message.mapper.ZySpeechMessageMapper; -import org.jeecg.modules.operationtool.entity.ZyOperationtool; -import org.jeecg.modules.operationtool.mapper.ZyOperationtoolMapper; -import org.jeecg.modules.product.pdaccessories.entity.ProductAccessories; -import org.jeecg.modules.product.pdaccessories.mapper.ProductAccessoriesMapper; -import org.jeecg.modules.product.pdfabric.entity.ProductFabric; -import org.jeecg.modules.product.pdfabric.mapper.ProductFabricMapper; -import org.jeecg.modules.product.pdmachine.entity.ProductMachine; -import org.jeecg.modules.product.pdmachine.mapper.ProductMachineMapper; -import org.jeecg.modules.product.pdoperationtool.entity.ProductOperationtool; -import org.jeecg.modules.product.pdoperationtool.mapper.ProductOperationtoolMapper; -import org.jeecg.modules.product.productModule.entity.ProductModule; -import org.jeecg.modules.product.productModule.mapper.ProductModuleMapper; -import org.jeecg.modules.product.zyproductprocess.entity.ZyProductProcess; -import org.jeecg.modules.product.zyproductprocess.mapper.ZyProductProcessMapper; -import org.jeecg.modules.productprocessaccessories.entity.ProductProcessAccessories; -import org.jeecg.modules.productprocessaccessories.mapper.ProductProcessAccessoriesMapper; -import org.jeecg.modules.productprocessfabric.entity.ProductProcessFabric; -import org.jeecg.modules.productprocessfabric.mapper.ProductProcessFabricMapper; -import org.jeecg.modules.system.entity.SysDepart; -import org.jeecg.modules.system.mapper.SysDepartMapper; -import org.jeecg.modules.workorder.entity.WorkOrder; -import org.jeecg.modules.workorder.entity.WorkOrderVo; -import org.jeecg.modules.workorder.mapper.WorkOrderMapper; -import org.jeecg.modules.workorder.service.IWorkOrderService; -import org.jeecg.modules.workproduct.entity.ZyProduct; -import org.jeecg.modules.workproduct.mapper.ZyProductMapper; -import org.jeecg.modules.zyProcessModular.entity.ZyProcessModular; -import org.jeecg.modules.zyProcessModular.mapper.ZyProcessModularMapper; -import org.jeecg.modules.zyclothsample.entity.ZyClothSample; -import org.jeecg.modules.zyclothsample.mapper.ZyClothSampleMapper; -import org.jeecg.modules.zyclothsstyle.entity.ZyClothsStyle; -import org.jeecg.modules.zyclothsstyle.mapper.ZyClothsStyleMapper; -import org.jeecg.modules.zystylemodel.entity.ZyStyleModel; -import org.jeecg.modules.zystylemodel.mapper.ZyStyleModelMapper; -import org.jeecg.modules.zystylemodule.entity.ZyStyleModule; -import org.jeecg.modules.zystylemodule.mapper.ZyStyleModuleMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import java.util.ArrayList; -import java.util.List; - -/** - * @Description: 工单订单完工 - * @Author: jeecg-boot - * @Date: 2023-01-07 - * @Version: V1.0 - */ -@Service -public class WorkOrderServiceImpl extends ServiceImpl implements IWorkOrderService { - - //订单 - @Autowired - private ZyOrdersMapper zyOrdersMapper; - - //部门 - @Autowired - private SysDepartMapper sysDepartMapper; - - //订单商品 - @Autowired - private OrderGoodsMapper orderGoodsMapper; - - //服装款式表 - @Autowired - private ZyClothsStyleMapper clothsStyleMapper; - - //服装型号 - @Autowired - private ZyStyleModelMapper styleModelMapper; - - //成衣样板 - @Autowired - private ZyClothSampleMapper clothSampleMapper; - - //顾客测体 - @Autowired - private CustomerMeasureMapper customerMeasureMapper; - - //工单产品 - @Autowired - private ZyProductMapper productMapper; - - //服装工序 - @Autowired - private ZyStyleModularMapper styleModularMapper; - - //基本工序 - @Autowired - private ZyProcessMapper processMapper; - - //款式模块 - @Autowired - private ZyStyleModuleMapper zyStyleModuleMapper; - - //款式模块工序 - @Autowired - private ZyProcessModularMapper zyProcessModularMapper; - - - //产品工序 - @Autowired - private ZyProductProcessMapper productProcessMapper; - - - - //工序工具 - @Autowired - private ZyOperationtoolMapper zyOperationtoolMapper; - //产品工具 - @Autowired - private ProductOperationtoolMapper productOperationtoolMapper; - - //工序设备 - @Autowired - private ZyProcessMachineMapper zyProcessMachine; - //产品设备 - @Autowired - private ProductMachineMapper productMachineMapper; - - - - - //订单商品模块表 - @Autowired - private OrderGoodsModuleMapper orderGoodsModuleMapper; - //产品模块 - @Autowired - private ProductModuleMapper productModuleMapper; - - //订单商品面料表 - @Autowired - private OrderGoodsFabricMapper orderGoodsFabricMapper; - //产品面料表 - @Autowired - private ProductFabricMapper productFabricMapper; - - //订单商品辅料表 - @Autowired - private OrderGoodsAccessoriesMapper orderGoodsAccessoriesMapper; - //产品辅料表 - @Autowired - private ProductAccessoriesMapper productAccessoriesMapper; - //产品工序面料 - @Autowired - private ProductProcessFabricMapper productProcessFabricMapper; - //产品工序辅料 - @Autowired - private ProductProcessAccessoriesMapper productProcessAccessoriesMapper; - - //定时播报 - @Autowired - private ZySpeechMessageMapper zySpeechMessageMapper; - - - /** - * 自定义分页查询 - * @param page - * @param workOrder - * @return - */ - @Override - public IPage selectPage(Page page, WorkOrderVo workOrder) { - return baseMapper.selectListPage(page,workOrder); - } - - /** - * 派单 - * @param zyOrders - * @return - */ - @Override - public Result paidan(ZyOrders zyOrders,String depId) { - //订单ID - String orderId=zyOrders.getId(); - //商品订单是否存在 - QueryWrapper ogWrapper=new QueryWrapper(); - ogWrapper.eq("orders_id",orderId); - List ogList=orderGoodsMapper.selectList(ogWrapper); - //工单 - WorkOrder workOrder=new WorkOrder(); - if(ogList.size()>0) - {//start if 02 - // 保存工单 - - //获取订单商品 - OrderGoods ogModel=ogList.get(0); - - //服装款式 - //QueryWrapper csWrapper=new QueryWrapper(); - ZyClothsStyle csModel=clothsStyleMapper.selectById(ogModel.getStyleId()); - - - //服装型号 - //QueryWrapper sm=new QueryWrapper(); - ZyStyleModel smModel=styleModelMapper.selectById(ogModel.getModelId()); - if(csModel==null ||smModel==null) - { - return Result.error("该订单服装型号或服装款式不存在,请检查后在操作!"); - } - //得到结构图和排排料图 - QueryWrapper csWrapper=new QueryWrapper(); - csWrapper.eq("style_id",ogModel.getStyleId()); - csWrapper.eq("stylemodel_id",ogModel.getModelId()); - //成衣样板 - List csList=clothSampleMapper.selectList(csWrapper); - if(csList.size()<=0) - { - return Result.error("商品成衣样板不存在,请检查后在操作!"); - } - ZyClothSample cSampleModel=csList.get(0); - - //生成工单 - int goodNum=ogModel.getGoodsNum(); - - workOrder.setProductCode(CreateWorkCode(csModel.getNums(),smModel.getModelNumber()));//工单编号 - workOrder.setOrdersId(orderId);//订单id - workOrder.setOrderGoodsId(ogModel.getId());// 订单商品 - workOrder.setGoodsNum(goodNum);//商品数量 - workOrder.setOrderTime(zyOrders.getOrderTime());//下单时间 - workOrder.setDeliveryTime(zyOrders.getDeliveryTime());//交货期 - workOrder.setWorkOrderStatus(0);//工单状态 - workOrder.setEnterprisesId(depId);//企业id - baseMapper.insert(workOrder); - //定时播报 - ZySpeechMessage message=new ZySpeechMessage(); - //订单商品id - message.setWorkorderId(workOrder.getId()); - //消息 - message.setMessage("您的工单已生成,工单编号:"+workOrder.getProductCode()+",请及时查看!"); - zySpeechMessageMapper.insert(message); - - //保存产品 - if(goodNum>0) - { - //量体数据 - CustomerMeasure mesureModel=customerMeasureMapper.selectById(ogModel.getMeasureId()); - if(mesureModel==null) { - return Result.error("未找到对客户量体数据!"); - } - - //#region 商品数量对应产品 保存产品 - for(int i=0;i styleModularLWrapper=new QueryWrapper(); - styleModularLWrapper.eq("style_id",ogModel.getStyleId()); - List zyStyleModularList=styleModularMapper.selectList(styleModularLWrapper); - - List pplist=new ArrayList<>(); - //将款式工序保存到变量pplist中 - for(ZyStyleModular item:zyStyleModularList) - { - ZyProductProcess zpp=new ZyProductProcess(); - zpp.setProductId(productModel.getId());//产品id - zpp.setProcessId(item.getProcessId());//工序id - zpp.setNumber(item.getSerialnumber());//序号 - productProcessMapper.insert(zpp);//保存 - pplist.add(zpp); - } - - //模块工序 - QueryWrapper qwStyleModule = new QueryWrapper<>(); - qwStyleModule.eq("style_id",ogModel.getStyleId()); - List smList=zyStyleModuleMapper.selectList(qwStyleModule); - //将模块工序保存到变量pplist中 - for(ZyStyleModule item:smList) - { - //读取模块工序 - QueryWrapper qwProcessModular = new QueryWrapper<>(); - qwProcessModular.eq("modular_id",item.getModularId()); - List pmList=zyProcessModularMapper.selectList(qwProcessModular); - for(ZyProcessModular pm:pmList) - { - ZyProductProcess zpp=new ZyProductProcess(); - zpp.setProductId(productModel.getId());//产品id - zpp.setProcessId(pm.getProcessId());//工序id - zpp.setNumber(pm.getSerialnumber());//序号 - productProcessMapper.insert(zpp);//保存 - pplist.add(zpp); - } - - } - - - //将工序保存到产品工序中 - //List productProcessList=new ArrayList<>(); - for(ZyProductProcess item:pplist) - { - - //首先查询到对应的产品工序id,由于产品和工序对应应该唯一 - String productprocessId=productProcessMapper.findProductProcessId(item.getProductId(),item.getProcessId()); - //然后根据对应的工序id去基本工序关联的辅料和面料表中找到对应的数据 - //面料 - List listFabric= productProcessMapper.findFabric(item.getProcessId()); - //辅料 - List listAccessories=productProcessMapper.findAccessories(item.getProcessId()); - //然后将产品工序id和辅料面料绑定 - //产品工序面料 - for (ZyProcessFabric zyProcessFabric : listFabric) { - ProductProcessFabric fabric=new ProductProcessFabric(); - fabric.setFabricId(zyProcessFabric.getFabricId()); - fabric.setAmount(zyProcessFabric.getAmount()); - fabric.setProductProcessId(productprocessId); - fabric.setId(null); - productProcessFabricMapper.insert(fabric); - } - //产品工序辅料 - for (ZyProcessAccessories listAccessory : listAccessories) { - ProductProcessAccessories accessories=new ProductProcessAccessories(); - accessories.setAccessoriesId(listAccessory.getAccessoriesId()); - accessories.setAmount(listAccessory.getAmount()); - accessories.setProductProcessId(productprocessId); - accessories.setId(null); - productProcessAccessoriesMapper.insert(accessories); - } - //ZyProcess =processMapper.selectById(item.getProcessId()); - - //region 获取工序工具 - QueryWrapper operationtoolWrapper=new QueryWrapper(); - //根据工序ID - operationtoolWrapper.eq("operationid",item.getProcessId()); - List operationtoolList=zyOperationtoolMapper.selectList(operationtoolWrapper); - int sort=1; - for(ZyOperationtool itemTool:operationtoolList) - { - ProductOperationtool poModel=new ProductOperationtool(); - poModel.setProductId(productModel.getId());//产品id - poModel.setOperationtoolId(itemTool.getToolid());//工具id - - poModel.setSort(sort++);//序号 - productOperationtoolMapper.insert(poModel); - - } - //endregion - - //region 获取工序设备 - QueryWrapper processMachineWrapper=new QueryWrapper(); - //根据工序ID - processMachineWrapper.eq("process_id",item.getProcessId()); - List processMachineList=zyProcessMachine.selectList(processMachineWrapper); - //遍历设备 - sort=1; - for(ZyProcessMachine itemMachine:processMachineList) - { - ProductMachine pmModel=new ProductMachine(); - pmModel.setProductId(productModel.getId());//产品id - pmModel.setMachineId(itemMachine.getMachineId());//设备 - pmModel.setSort(sort++);//序号 - productMachineMapper.insert(pmModel); - - } - //endregion - - //productProcessList.add(zpp); - } - //zyProductProcessService.save() - //#endregion - - - //#region 产品模块-添加(从订单中读取) - //订单商品模块表-根据订单商品id - QueryWrapper productModuleWrapper=new QueryWrapper(); - productModuleWrapper.eq("order_goods_id",ogModel.getId()); - List orderGoodsModuleList=orderGoodsModuleMapper.selectList(productModuleWrapper); - //循环保存 - List ProductModuleList=new ArrayList<>(); - for(OrderGoodsModule item:orderGoodsModuleList) - { - ProductModule pmModel=new ProductModule(); - pmModel.setProductId(productModel.getId());//产品id - pmModel.setStyleModuleId(item.getStyleModuleId());//款式模块id - pmModel.setModuleId(item.getModuleId());//模块id - //保存 - productModuleMapper.insert(pmModel); - //ProductModuleList.add(pmModel); - } - - //productModuleMapper.saveBatch(ProductModuleList); - //#endregion - - //#region 产品面料-添加(从订单中读取) - - //订单商品面料表-根据订单商品id - QueryWrapper ogFabricWrapper=new QueryWrapper(); - ogFabricWrapper.eq("order_goods_id",ogModel.getId()); - List orderGoodsFabricList=orderGoodsFabricMapper.selectList(ogFabricWrapper); - //循环保存 - List productFabricList=new ArrayList<>(); - for(OrderGoodsFabric item:orderGoodsFabricList) - { - ProductFabric ptModel=new ProductFabric(); - ptModel.setProductId(productModel.getId());//产品id - ptModel.setFabricId(item.getFabricId());//面料id - // productFabricList.add(ptModel); - //保存 - productFabricMapper.insert(ptModel); - } - //保存 - // productFabricMapper.saveBatch(productFabricList); - //#endregion - - //#region 产品辅料-添加(从订单中读取) - //订单商品辅料表-根据订单商品id - QueryWrapper ogAccessoriesWrapper=new QueryWrapper(); - ogAccessoriesWrapper.eq("order_goods_id",ogModel.getId()); - List orderGoodsAccessoriesList=orderGoodsAccessoriesMapper.selectList(ogAccessoriesWrapper); - //循环保存 - List productAccessoriesList=new ArrayList<>(); - for(OrderGoodsAccessories item:orderGoodsAccessoriesList) - { - ProductAccessories paModel=new ProductAccessories(); - paModel.setProductId(productModel.getId());//产品id - paModel.setAccessoriesId(item.getAccessoriesId());//辅料id - - productAccessoriesMapper.insert(paModel); - // productAccessoriesList.add(paModel); - } - //保存 - // productAccessoriesMapper.saveBatch(productAccessoriesList); - //#endregion - } - //#endregion - } - - else - { - return Result.error("订单商品数量小于0!"); - - } - - }else//end if 02 - { - return Result.error("订单商品数据未找到!"); - } - //修改订单状态 - zyOrders.setDeliveryStatus(3); - zyOrdersMapper.updateById(zyOrders); - return Result.OK("成功",workOrder); - } - - /** - * 撤销工单 - * @param woModel - * @return - */ - @Override - public Result cancellationWorkOrder(WorkOrder woModel) { - //根据工单获取产品列表,然后循环删除产品列表中的工序,以及工序对应的设备、工具,再删除产品中对应模块、面料、辅料 - - //工单 - //-产品 - QueryWrapper productWrapper = new QueryWrapper(); - productWrapper.eq("work_order_id", woModel.getId()); - List productList = productMapper.selectList(productWrapper); - - for (ZyProduct model:productList) - { - //-工序 - QueryWrapper productProcessWrapper = new QueryWrapper(); - productProcessWrapper.eq("product_id",model.getId()); - productProcessMapper.delete(productProcessWrapper); - //-工具 - QueryWrapper productOperationtoolWrapper = new QueryWrapper(); - productOperationtoolWrapper.eq("product_id",model.getId()); - productOperationtoolMapper.delete(productOperationtoolWrapper); - //-设备 - QueryWrapper productMachineWrapper = new QueryWrapper(); - productMachineWrapper.eq("product_id",model.getId()); - productMachineMapper.delete(productMachineWrapper); - - //产品模块 - QueryWrapper productModuleWrapper = new QueryWrapper(); - productModuleWrapper.eq("product_id",model.getId()); - productModuleMapper.delete(productModuleWrapper); - - //产品面料 - QueryWrapper productFabricWrapper = new QueryWrapper(); - productFabricWrapper.eq("product_id",model.getId()); - productFabricMapper.delete(productFabricWrapper); - - //产品面料 - QueryWrapper productAccessoriesWrapper = new QueryWrapper(); - productAccessoriesWrapper.eq("product_id",model.getId()); - productAccessoriesMapper.delete(productAccessoriesWrapper); - } - - - //修改订单 - UpdateWrapper updateWrapper = new UpdateWrapper(); - updateWrapper.eq("id", woModel.getOrdersId()); - updateWrapper.set("delivery_status", 2); - int update = zyOrdersMapper.update(null, updateWrapper); - - //产品 - productMapper.delete(productWrapper); - //工单 - baseMapper.deleteById(woModel.getId()); - return Result.OK("成功"); - } - - @Override - public List jobPaidan(List orderIds) { - //获取生产部门 - QueryWrapper queryWrapper=new QueryWrapper(); - queryWrapper.eq("org_category",2); - List sysDepList = sysDepartMapper.selectList(queryWrapper); - if(sysDepList.size()>0) - { - - List wordOderIds=new ArrayList<>(); - //生产随机数,然后随机获取生产部门 - int r=(int)Math.random() * sysDepList.size(); - SysDepart dep=sysDepList.get(r); - for(String orderId:orderIds) - { - ZyOrders model=zyOrdersMapper.selectById(orderId); - Result result=this.paidan(model,dep.getId()); - if (result.getCode().toString().equals("500")) - { - return null; - } - WorkOrder wo=(WorkOrder)result.getResult(); - wordOderIds.add(wo.getId()); - } - return wordOderIds; - } - return null; - } - - - //生成工单编号 - - /** - * - * @param styleCode 款式编号 - * @param modelCode 型号编号 - * @return - */ - private String CreateWorkCode(String styleCode,String modelCode) - {//编号规则:款式编号(10)+型号(4)+顺序号(8) - String mrstr = "00000000"; - QueryWrapper query = new QueryWrapper(); - int listsize = baseMapper.selectList(query).size(); - int strsize = listsize+1; - String str = strsize+""; - int strlength = str.length(); - String substr = mrstr.substring(0,mrstr.length()-strlength); - String workCode = styleCode+modelCode+substr+str; - return workCode; - } - - /** - * - * @param workCode 工单编号 - * @return - */ - private String CreateProductCode(String workCode) - {//编号规则:工单编号(22)+顺序号(8) - String mrstr = "00000000"; - QueryWrapper query = new QueryWrapper(); - int listsize = productMapper.selectList(query).size(); - int strsize = listsize+1; - String str = strsize+""; - int strlength = str.length(); - String substr = mrstr.substring(0,mrstr.length()-strlength); - String produceCode = workCode+substr+str; - return produceCode; - } - - -} +package org.jeecg.modules.workorder.service.impl; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.demo.base.mapper.ZyProcessMapper; +import org.jeecg.modules.demo.customermeasure.entity.CustomerMeasure; +import org.jeecg.modules.demo.customermeasure.mapper.CustomerMeasureMapper; +import org.jeecg.modules.demo.ordergoods.entity.OrderGoods; +import org.jeecg.modules.demo.ordergoods.mapper.OrderGoodsMapper; +import org.jeecg.modules.demo.ordergoodsaccessories.entity.OrderGoodsAccessories; +import org.jeecg.modules.demo.ordergoodsaccessories.mapper.OrderGoodsAccessoriesMapper; +import org.jeecg.modules.demo.ordergoodsfabric.entity.OrderGoodsFabric; +import org.jeecg.modules.demo.ordergoodsfabric.mapper.OrderGoodsFabricMapper; +import org.jeecg.modules.demo.ordergoodsmodule.entity.OrderGoodsModule; +import org.jeecg.modules.demo.ordergoodsmodule.mapper.OrderGoodsModuleMapper; +import org.jeecg.modules.demo.pro.entity.ZyProcessAccessories; +import org.jeecg.modules.demo.pro.entity.ZyProcessFabric; +import org.jeecg.modules.demo.pro.entity.ZyProcessMachine; +import org.jeecg.modules.demo.pro.mapper.ZyProcessMachineMapper; +import org.jeecg.modules.demo.zyStyleModular.entity.ZyStyleModular; +import org.jeecg.modules.demo.zyStyleModular.mapper.ZyStyleModularMapper; +import org.jeecg.modules.demo.zyorders.entity.ZyOrders; +import org.jeecg.modules.demo.zyorders.mapper.ZyOrdersMapper; +import org.jeecg.modules.message.entity.ZySpeechMessage; +import org.jeecg.modules.message.mapper.ZySpeechMessageMapper; +import org.jeecg.modules.operationtool.entity.ZyOperationtool; +import org.jeecg.modules.operationtool.mapper.ZyOperationtoolMapper; +import org.jeecg.modules.product.pdaccessories.entity.ProductAccessories; +import org.jeecg.modules.product.pdaccessories.mapper.ProductAccessoriesMapper; +import org.jeecg.modules.product.pdfabric.entity.ProductFabric; +import org.jeecg.modules.product.pdfabric.mapper.ProductFabricMapper; +import org.jeecg.modules.product.pdmachine.entity.ProductMachine; +import org.jeecg.modules.product.pdmachine.mapper.ProductMachineMapper; +import org.jeecg.modules.product.pdoperationtool.entity.ProductOperationtool; +import org.jeecg.modules.product.pdoperationtool.mapper.ProductOperationtoolMapper; +import org.jeecg.modules.product.productModule.entity.ProductModule; +import org.jeecg.modules.product.productModule.mapper.ProductModuleMapper; +import org.jeecg.modules.product.zyproductprocess.entity.ZyProductProcess; +import org.jeecg.modules.product.zyproductprocess.mapper.ZyProductProcessMapper; +import org.jeecg.modules.productprocessaccessories.entity.ProductProcessAccessories; +import org.jeecg.modules.productprocessaccessories.mapper.ProductProcessAccessoriesMapper; +import org.jeecg.modules.productprocessfabric.entity.ProductProcessFabric; +import org.jeecg.modules.productprocessfabric.mapper.ProductProcessFabricMapper; +import org.jeecg.modules.system.entity.SysDepart; +import org.jeecg.modules.system.mapper.SysDepartMapper; +import org.jeecg.modules.workorder.entity.WorkOrder; +import org.jeecg.modules.workorder.entity.WorkOrderVo; +import org.jeecg.modules.workorder.mapper.WorkOrderMapper; +import org.jeecg.modules.workorder.service.IWorkOrderService; +import org.jeecg.modules.workproduct.entity.ZyProduct; +import org.jeecg.modules.workproduct.mapper.ZyProductMapper; +import org.jeecg.modules.zyProcessModular.entity.ZyProcessModular; +import org.jeecg.modules.zyProcessModular.mapper.ZyProcessModularMapper; +import org.jeecg.modules.zyclothsample.entity.ZyClothSample; +import org.jeecg.modules.zyclothsample.mapper.ZyClothSampleMapper; +import org.jeecg.modules.zyclothsstyle.entity.ZyClothsStyle; +import org.jeecg.modules.zyclothsstyle.mapper.ZyClothsStyleMapper; +import org.jeecg.modules.zystylemodel.entity.ZyStyleModel; +import org.jeecg.modules.zystylemodel.mapper.ZyStyleModelMapper; +import org.jeecg.modules.zystylemodule.entity.ZyStyleModule; +import org.jeecg.modules.zystylemodule.mapper.ZyStyleModuleMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Description: 工单订单完工 + * @Author: jeecg-boot + * @Date: 2023-01-07 + * @Version: V1.0 + */ +@Service +public class WorkOrderServiceImpl extends ServiceImpl implements IWorkOrderService { + + //订单 + @Autowired + private ZyOrdersMapper zyOrdersMapper; + + //部门 + @Autowired + private SysDepartMapper sysDepartMapper; + + //订单商品 + @Autowired + private OrderGoodsMapper orderGoodsMapper; + + //服装款式表 + @Autowired + private ZyClothsStyleMapper clothsStyleMapper; + + //服装型号 + @Autowired + private ZyStyleModelMapper styleModelMapper; + + //成衣样板 + @Autowired + private ZyClothSampleMapper clothSampleMapper; + + //顾客测体 + @Autowired + private CustomerMeasureMapper customerMeasureMapper; + + //工单产品 + @Autowired + private ZyProductMapper productMapper; + + //服装工序 + @Autowired + private ZyStyleModularMapper styleModularMapper; + + //基本工序 + @Autowired + private ZyProcessMapper processMapper; + + //款式模块 + @Autowired + private ZyStyleModuleMapper zyStyleModuleMapper; + + //款式模块工序 + @Autowired + private ZyProcessModularMapper zyProcessModularMapper; + + + //产品工序 + @Autowired + private ZyProductProcessMapper productProcessMapper; + + + + //工序工具 + @Autowired + private ZyOperationtoolMapper zyOperationtoolMapper; + //产品工具 + @Autowired + private ProductOperationtoolMapper productOperationtoolMapper; + + //工序设备 + @Autowired + private ZyProcessMachineMapper zyProcessMachine; + //产品设备 + @Autowired + private ProductMachineMapper productMachineMapper; + + + + + //订单商品模块表 + @Autowired + private OrderGoodsModuleMapper orderGoodsModuleMapper; + //产品模块 + @Autowired + private ProductModuleMapper productModuleMapper; + + //订单商品面料表 + @Autowired + private OrderGoodsFabricMapper orderGoodsFabricMapper; + //产品面料表 + @Autowired + private ProductFabricMapper productFabricMapper; + + //订单商品辅料表 + @Autowired + private OrderGoodsAccessoriesMapper orderGoodsAccessoriesMapper; + //产品辅料表 + @Autowired + private ProductAccessoriesMapper productAccessoriesMapper; + //产品工序面料 + @Autowired + private ProductProcessFabricMapper productProcessFabricMapper; + //产品工序辅料 + @Autowired + private ProductProcessAccessoriesMapper productProcessAccessoriesMapper; + + //定时播报 + @Autowired + private ZySpeechMessageMapper zySpeechMessageMapper; + + + /** + * 自定义分页查询 + * @param page + * @param workOrder + * @return + */ + @Override + public IPage selectPage(Page page, WorkOrderVo workOrder) { + return baseMapper.selectListPage(page,workOrder); + } + + /** + * 派单 + * @param zyOrders + * @return + */ + @Override + public Result paidan(ZyOrders zyOrders,String depId) { + //订单ID + String orderId=zyOrders.getId(); + //商品订单是否存在 + QueryWrapper ogWrapper=new QueryWrapper(); + ogWrapper.eq("orders_id",orderId); + List ogList=orderGoodsMapper.selectList(ogWrapper); + //工单 + WorkOrder workOrder=new WorkOrder(); + if(ogList.size()>0) + {//start if 02 + // 保存工单 + + //获取订单商品 + OrderGoods ogModel=ogList.get(0); + + //服装款式 + //QueryWrapper csWrapper=new QueryWrapper(); + ZyClothsStyle csModel=clothsStyleMapper.selectById(ogModel.getStyleId()); + + + //服装型号 + //QueryWrapper sm=new QueryWrapper(); + ZyStyleModel smModel=styleModelMapper.selectById(ogModel.getModelId()); + if(csModel==null ||smModel==null) + { + return Result.error("该订单服装型号或服装款式不存在,请检查后在操作!"); + } + //得到结构图和排排料图 + QueryWrapper csWrapper=new QueryWrapper(); + csWrapper.eq("style_id",ogModel.getStyleId()); + csWrapper.eq("stylemodel_id",ogModel.getModelId()); + //成衣样板 + List csList=clothSampleMapper.selectList(csWrapper); + if(csList.size()<=0) + { + return Result.error("商品成衣样板不存在,请检查后在操作!"); + } + ZyClothSample cSampleModel=csList.get(0); + + //生成工单 + int goodNum=ogModel.getGoodsNum(); + + workOrder.setProductCode(CreateWorkCode(csModel.getNums(),smModel.getModelNumber()));//工单编号 + workOrder.setOrdersId(orderId);//订单id + workOrder.setOrderGoodsId(ogModel.getId());// 订单商品 + workOrder.setGoodsNum(goodNum);//商品数量 + workOrder.setOrderTime(zyOrders.getOrderTime());//下单时间 + workOrder.setDeliveryTime(zyOrders.getDeliveryTime());//交货期 + workOrder.setWorkOrderStatus(0);//工单状态 + workOrder.setEnterprisesId(depId);//企业id + baseMapper.insert(workOrder); + //定时播报 + ZySpeechMessage message=new ZySpeechMessage(); + //订单商品id + message.setWorkorderId(workOrder.getId()); + //消息 + String productCode = workOrder.getProductCode(); + String code = productCode.substring(productCode.length() - 6); + message.setMessage("您的工单已生成,工单尾号:"+code+",请及时查看!"); + zySpeechMessageMapper.insert(message); + + //保存产品 + if(goodNum>0) + { + //量体数据 + CustomerMeasure mesureModel=customerMeasureMapper.selectById(ogModel.getMeasureId()); + if(mesureModel==null) { + return Result.error("未找到对客户量体数据!"); + } + + //#region 商品数量对应产品 保存产品 + for(int i=0;i styleModularLWrapper=new QueryWrapper(); + styleModularLWrapper.eq("style_id",ogModel.getStyleId()); + List zyStyleModularList=styleModularMapper.selectList(styleModularLWrapper); + + List pplist=new ArrayList<>(); + //将款式工序保存到变量pplist中 + for(ZyStyleModular item:zyStyleModularList) + { + ZyProductProcess zpp=new ZyProductProcess(); + zpp.setProductId(productModel.getId());//产品id + zpp.setProcessId(item.getProcessId());//工序id + zpp.setNumber(item.getSerialnumber());//序号 + productProcessMapper.insert(zpp);//保存 + pplist.add(zpp); + } + + //模块工序 + QueryWrapper qwStyleModule = new QueryWrapper<>(); + qwStyleModule.eq("style_id",ogModel.getStyleId()); + List smList=zyStyleModuleMapper.selectList(qwStyleModule); + //将模块工序保存到变量pplist中 + for(ZyStyleModule item:smList) + { + //读取模块工序 + QueryWrapper qwProcessModular = new QueryWrapper<>(); + qwProcessModular.eq("modular_id",item.getModularId()); + List pmList=zyProcessModularMapper.selectList(qwProcessModular); + for(ZyProcessModular pm:pmList) + { + ZyProductProcess zpp=new ZyProductProcess(); + zpp.setProductId(productModel.getId());//产品id + zpp.setProcessId(pm.getProcessId());//工序id + zpp.setNumber(pm.getSerialnumber());//序号 + productProcessMapper.insert(zpp);//保存 + pplist.add(zpp); + } + + } + + + //将工序保存到产品工序中 + //List productProcessList=new ArrayList<>(); + for(ZyProductProcess item:pplist) + { + + //首先查询到对应的产品工序id,由于产品和工序对应应该唯一 + String productprocessId=productProcessMapper.findProductProcessId(item.getProductId(),item.getProcessId()); + //然后根据对应的工序id去基本工序关联的辅料和面料表中找到对应的数据 + //面料 + List listFabric= productProcessMapper.findFabric(item.getProcessId()); + //辅料 + List listAccessories=productProcessMapper.findAccessories(item.getProcessId()); + //然后将产品工序id和辅料面料绑定 + //产品工序面料 + for (ZyProcessFabric zyProcessFabric : listFabric) { + ProductProcessFabric fabric=new ProductProcessFabric(); + fabric.setFabricId(zyProcessFabric.getFabricId()); + fabric.setAmount(zyProcessFabric.getAmount()); + fabric.setProductProcessId(productprocessId); + fabric.setId(null); + productProcessFabricMapper.insert(fabric); + } + //产品工序辅料 + for (ZyProcessAccessories listAccessory : listAccessories) { + ProductProcessAccessories accessories=new ProductProcessAccessories(); + accessories.setAccessoriesId(listAccessory.getAccessoriesId()); + accessories.setAmount(listAccessory.getAmount()); + accessories.setProductProcessId(productprocessId); + accessories.setId(null); + productProcessAccessoriesMapper.insert(accessories); + } + //ZyProcess =processMapper.selectById(item.getProcessId()); + + //region 获取工序工具 + QueryWrapper operationtoolWrapper=new QueryWrapper(); + //根据工序ID + operationtoolWrapper.eq("operationid",item.getProcessId()); + List operationtoolList=zyOperationtoolMapper.selectList(operationtoolWrapper); + int sort=1; + for(ZyOperationtool itemTool:operationtoolList) + { + ProductOperationtool poModel=new ProductOperationtool(); + poModel.setProductId(productModel.getId());//产品id + poModel.setOperationtoolId(itemTool.getToolid());//工具id + + poModel.setSort(sort++);//序号 + productOperationtoolMapper.insert(poModel); + + } + //endregion + + //region 获取工序设备 + QueryWrapper processMachineWrapper=new QueryWrapper(); + //根据工序ID + processMachineWrapper.eq("process_id",item.getProcessId()); + List processMachineList=zyProcessMachine.selectList(processMachineWrapper); + //遍历设备 + sort=1; + for(ZyProcessMachine itemMachine:processMachineList) + { + ProductMachine pmModel=new ProductMachine(); + pmModel.setProductId(productModel.getId());//产品id + pmModel.setMachineId(itemMachine.getMachineId());//设备 + pmModel.setSort(sort++);//序号 + productMachineMapper.insert(pmModel); + + } + //endregion + + //productProcessList.add(zpp); + } + //zyProductProcessService.save() + //#endregion + + + //#region 产品模块-添加(从订单中读取) + //订单商品模块表-根据订单商品id + QueryWrapper productModuleWrapper=new QueryWrapper(); + productModuleWrapper.eq("order_goods_id",ogModel.getId()); + List orderGoodsModuleList=orderGoodsModuleMapper.selectList(productModuleWrapper); + //循环保存 + List ProductModuleList=new ArrayList<>(); + for(OrderGoodsModule item:orderGoodsModuleList) + { + ProductModule pmModel=new ProductModule(); + pmModel.setProductId(productModel.getId());//产品id + pmModel.setStyleModuleId(item.getStyleModuleId());//款式模块id + pmModel.setModuleId(item.getModuleId());//模块id + //保存 + productModuleMapper.insert(pmModel); + //ProductModuleList.add(pmModel); + } + + //productModuleMapper.saveBatch(ProductModuleList); + //#endregion + + //#region 产品面料-添加(从订单中读取) + + //订单商品面料表-根据订单商品id + QueryWrapper ogFabricWrapper=new QueryWrapper(); + ogFabricWrapper.eq("order_goods_id",ogModel.getId()); + List orderGoodsFabricList=orderGoodsFabricMapper.selectList(ogFabricWrapper); + //循环保存 + List productFabricList=new ArrayList<>(); + for(OrderGoodsFabric item:orderGoodsFabricList) + { + ProductFabric ptModel=new ProductFabric(); + ptModel.setProductId(productModel.getId());//产品id + ptModel.setFabricId(item.getFabricId());//面料id + // productFabricList.add(ptModel); + //保存 + productFabricMapper.insert(ptModel); + } + //保存 + // productFabricMapper.saveBatch(productFabricList); + //#endregion + + //#region 产品辅料-添加(从订单中读取) + //订单商品辅料表-根据订单商品id + QueryWrapper ogAccessoriesWrapper=new QueryWrapper(); + ogAccessoriesWrapper.eq("order_goods_id",ogModel.getId()); + List orderGoodsAccessoriesList=orderGoodsAccessoriesMapper.selectList(ogAccessoriesWrapper); + //循环保存 + List productAccessoriesList=new ArrayList<>(); + for(OrderGoodsAccessories item:orderGoodsAccessoriesList) + { + ProductAccessories paModel=new ProductAccessories(); + paModel.setProductId(productModel.getId());//产品id + paModel.setAccessoriesId(item.getAccessoriesId());//辅料id + + productAccessoriesMapper.insert(paModel); + // productAccessoriesList.add(paModel); + } + //保存 + // productAccessoriesMapper.saveBatch(productAccessoriesList); + //#endregion + } + //#endregion + } + + else + { + return Result.error("订单商品数量小于0!"); + + } + + }else//end if 02 + { + return Result.error("订单商品数据未找到!"); + } + //修改订单状态 + zyOrders.setDeliveryStatus(3); + zyOrdersMapper.updateById(zyOrders); + return Result.OK("成功",workOrder); + } + + /** + * 撤销工单 + * @param woModel + * @return + */ + @Override + public Result cancellationWorkOrder(WorkOrder woModel) { + //根据工单获取产品列表,然后循环删除产品列表中的工序,以及工序对应的设备、工具,再删除产品中对应模块、面料、辅料 + + //工单 + //-产品 + QueryWrapper productWrapper = new QueryWrapper(); + productWrapper.eq("work_order_id", woModel.getId()); + List productList = productMapper.selectList(productWrapper); + + for (ZyProduct model:productList) + { + //-工序 + QueryWrapper productProcessWrapper = new QueryWrapper(); + productProcessWrapper.eq("product_id",model.getId()); + productProcessMapper.delete(productProcessWrapper); + //-工具 + QueryWrapper productOperationtoolWrapper = new QueryWrapper(); + productOperationtoolWrapper.eq("product_id",model.getId()); + productOperationtoolMapper.delete(productOperationtoolWrapper); + //-设备 + QueryWrapper productMachineWrapper = new QueryWrapper(); + productMachineWrapper.eq("product_id",model.getId()); + productMachineMapper.delete(productMachineWrapper); + + //产品模块 + QueryWrapper productModuleWrapper = new QueryWrapper(); + productModuleWrapper.eq("product_id",model.getId()); + productModuleMapper.delete(productModuleWrapper); + + //产品面料 + QueryWrapper productFabricWrapper = new QueryWrapper(); + productFabricWrapper.eq("product_id",model.getId()); + productFabricMapper.delete(productFabricWrapper); + + //产品面料 + QueryWrapper productAccessoriesWrapper = new QueryWrapper(); + productAccessoriesWrapper.eq("product_id",model.getId()); + productAccessoriesMapper.delete(productAccessoriesWrapper); + } + + + //修改订单 + UpdateWrapper updateWrapper = new UpdateWrapper(); + updateWrapper.eq("id", woModel.getOrdersId()); + updateWrapper.set("delivery_status", 2); + int update = zyOrdersMapper.update(null, updateWrapper); + + //产品 + productMapper.delete(productWrapper); + //工单 + baseMapper.deleteById(woModel.getId()); + return Result.OK("成功"); + } + + @Override + public List jobPaidan(List orderIds) { + //获取生产部门 + QueryWrapper queryWrapper=new QueryWrapper(); + queryWrapper.eq("org_category",2); + List sysDepList = sysDepartMapper.selectList(queryWrapper); + if(sysDepList.size()>0) + { + + List wordOderIds=new ArrayList<>(); + //生产随机数,然后随机获取生产部门 + int r=(int)Math.random() * sysDepList.size(); + SysDepart dep=sysDepList.get(r); + for(String orderId:orderIds) + { + ZyOrders model=zyOrdersMapper.selectById(orderId); + Result result=this.paidan(model,dep.getId()); + if (result.getCode().toString().equals("500")) + { + return null; + } + WorkOrder wo=(WorkOrder)result.getResult(); + wordOderIds.add(wo.getId()); + } + return wordOderIds; + } + return null; + } + + + //生成工单编号 + + /** + * + * @param styleCode 款式编号 + * @param modelCode 型号编号 + * @return + */ + private String CreateWorkCode(String styleCode,String modelCode) + {//编号规则:款式编号(10)+型号(4)+顺序号(8) + String mrstr = "00000000"; + QueryWrapper query = new QueryWrapper(); + int listsize = baseMapper.selectList(query).size(); + int strsize = listsize+1; + String str = strsize+""; + int strlength = str.length(); + String substr = mrstr.substring(0,mrstr.length()-strlength); + String workCode = styleCode+modelCode+substr+str; + return workCode; + } + + /** + * + * @param workCode 工单编号 + * @return + */ + private String CreateProductCode(String workCode) + {//编号规则:工单编号(22)+顺序号(8) + String mrstr = "00000000"; + QueryWrapper query = new QueryWrapper(); + int listsize = productMapper.selectList(query).size(); + int strsize = listsize+1; + String str = strsize+""; + int strlength = str.length(); + String substr = mrstr.substring(0,mrstr.length()-strlength); + String produceCode = workCode+substr+str; + return produceCode; + } + + +}