diff --git a/textja/src/main/java/com/lan/textja/controller/dealer/DealerController.java b/textja/src/main/java/com/lan/textja/controller/dealer/DealerController.java new file mode 100644 index 0000000..22eb66f --- /dev/null +++ b/textja/src/main/java/com/lan/textja/controller/dealer/DealerController.java @@ -0,0 +1,29 @@ +package com.lan.textja.controller.dealer; + +import com.lan.textja.entity.Dealer; +import com.lan.textja.entity.Supplier; +import com.lan.textja.entity.Supply; +import com.lan.textja.service.dealer.DealerService; +import com.lan.textja.util.JsonResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@CrossOrigin +@RequestMapping("/Dealer") +public class DealerController { + + @Autowired + private DealerService dealerService; + + @RequestMapping(value = "/dealerNames",method = RequestMethod.GET) + public JsonResult dealerNames(){ + List dealerNames= dealerService.dealerNames(); + return JsonResult.ok(dealerNames); + } +} diff --git a/textja/src/main/java/com/lan/textja/controller/supplier/SupplyController.java b/textja/src/main/java/com/lan/textja/controller/supplier/SupplyController.java index 91b8f2c..0ea2c70 100644 --- a/textja/src/main/java/com/lan/textja/controller/supplier/SupplyController.java +++ b/textja/src/main/java/com/lan/textja/controller/supplier/SupplyController.java @@ -1,5 +1,6 @@ package com.lan.textja.controller.supplier; +import com.lan.textja.entity.Order; import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supply; import com.lan.textja.service.supplier.SupplierService; @@ -7,10 +8,7 @@ import com.lan.textja.service.supplier.SupplyService; import com.lan.textja.util.JsonResult; import com.lan.textja.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @@ -53,4 +51,31 @@ public class SupplyController { List Onorder=supplyService.Onorder(supply); return JsonResult.ok(Onorder); } + + @RequestMapping(value = "/SureOrder",method = RequestMethod.POST,produces = "application/json;charset=UTF-8") + public JsonResult SureOrder(@RequestParam(required = false) Map params){ + System.out.println(params); + supplyService.SureOrder(params); + return JsonResult.ok(JsonResult.SUCCESS); + } + + + @RequestMapping(value = "/goodsNum",method = RequestMethod.GET) + public JsonResult goodsNum(){ + Integer goodsNum=supplyService.goodsNum(); + return JsonResult.ok(goodsNum); + } + + @RequestMapping(value = "/supplierNames",method = RequestMethod.GET) + public JsonResult supplierNames(){ + List supplierNames=supplyService.supplierName(); + return JsonResult.ok(supplierNames); + } + + + @RequestMapping(value = "/onAddSupply",method = RequestMethod.POST) + public JsonResult onAddSupply(@RequestParam(required = false) Map params){ + supplyService.onAddSupply(params); + return JsonResult.ok(JsonResult.SUCCESS); + } } diff --git a/textja/src/main/java/com/lan/textja/entity/Dealer.java b/textja/src/main/java/com/lan/textja/entity/Dealer.java new file mode 100644 index 0000000..65e7c84 --- /dev/null +++ b/textja/src/main/java/com/lan/textja/entity/Dealer.java @@ -0,0 +1,18 @@ +package com.lan.textja.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +@Data +@TableName("dealer") +@Accessors(chain = true) +public class Dealer implements Serializable { + private Integer dealerNum; + private String dealerName; + private String dealerContact; + private String dealerAddress; + private String dealerNumber; + +} diff --git a/textja/src/main/java/com/lan/textja/entity/Order.java b/textja/src/main/java/com/lan/textja/entity/Order.java new file mode 100644 index 0000000..1b87838 --- /dev/null +++ b/textja/src/main/java/com/lan/textja/entity/Order.java @@ -0,0 +1,30 @@ +package com.lan.textja.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@Accessors(chain = true) +@TableName("orders") +public class Order implements Serializable { + private Integer orderNo; + private String orderName; + private Integer orderPrice; + private Integer orderQty; + private Integer orderTotalPrice; + private String orderType; + private String orderSupplierContact; + private String orderSupplierAddress; + private String orderSupplierNumber; + private String orderDealerContact; + private String orderDealerAddress; + private String orderDealerNumber; + private Integer orderGoodsNo; + private Integer orderSupplierNo; + private Integer orderDealerNo; + private Boolean orderState; + +} diff --git a/textja/src/main/java/com/lan/textja/entity/Supply.java b/textja/src/main/java/com/lan/textja/entity/Supply.java index 62d585d..e20a3ed 100644 --- a/textja/src/main/java/com/lan/textja/entity/Supply.java +++ b/textja/src/main/java/com/lan/textja/entity/Supply.java @@ -20,5 +20,6 @@ public class Supply { private String goodsSize; private String goodsEffect; private Boolean goodsState; - private List supplierList; + private Supplier supplierList; +// private List dealerList; } diff --git a/textja/src/main/java/com/lan/textja/mapper/DealerMapper.java b/textja/src/main/java/com/lan/textja/mapper/DealerMapper.java new file mode 100644 index 0000000..0b66d80 --- /dev/null +++ b/textja/src/main/java/com/lan/textja/mapper/DealerMapper.java @@ -0,0 +1,13 @@ +package com.lan.textja.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lan.textja.entity.Dealer; + +import java.util.List; + +public interface DealerMapper extends BaseMapper { + List dealerNames(); + + + Dealer select(String dealerName); +} diff --git a/textja/src/main/java/com/lan/textja/mapper/OrderMapper.java b/textja/src/main/java/com/lan/textja/mapper/OrderMapper.java new file mode 100644 index 0000000..91f43c9 --- /dev/null +++ b/textja/src/main/java/com/lan/textja/mapper/OrderMapper.java @@ -0,0 +1,9 @@ +package com.lan.textja.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lan.textja.entity.Order; + +public interface OrderMapper extends BaseMapper { + + void SureOrder(Order order); +} diff --git a/textja/src/main/java/com/lan/textja/mapper/SupplierMapper.java b/textja/src/main/java/com/lan/textja/mapper/SupplierMapper.java index 52e12c1..37ed34e 100644 --- a/textja/src/main/java/com/lan/textja/mapper/SupplierMapper.java +++ b/textja/src/main/java/com/lan/textja/mapper/SupplierMapper.java @@ -23,4 +23,11 @@ public interface SupplierMapper extends BaseMapper { List onSubmit(Supplier supplier); List SupplierNum(); + + Supplier select(Integer goodsSupplierFirm); + + List supplierName(); + + + Supplier goodsSupplierFirm(String supplierName); } diff --git a/textja/src/main/java/com/lan/textja/mapper/SupplyMapper.java b/textja/src/main/java/com/lan/textja/mapper/SupplyMapper.java index 44f1c65..2e4d7ff 100644 --- a/textja/src/main/java/com/lan/textja/mapper/SupplyMapper.java +++ b/textja/src/main/java/com/lan/textja/mapper/SupplyMapper.java @@ -1,6 +1,7 @@ package com.lan.textja.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.lan.textja.entity.Order; import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supply; import org.apache.ibatis.annotations.Select; @@ -20,4 +21,9 @@ public interface SupplyMapper extends BaseMapper { List goodsTypes(); List Onorder(Supply supply); + + + List goodsNum(); + + void onAddSupply(Supply supply); } diff --git a/textja/src/main/java/com/lan/textja/service/dealer/DealerService.java b/textja/src/main/java/com/lan/textja/service/dealer/DealerService.java new file mode 100644 index 0000000..43bbd4b --- /dev/null +++ b/textja/src/main/java/com/lan/textja/service/dealer/DealerService.java @@ -0,0 +1,9 @@ +package com.lan.textja.service.dealer; + +import com.lan.textja.entity.Dealer; + +import java.util.List; + +public interface DealerService{ + List dealerNames(); +} diff --git a/textja/src/main/java/com/lan/textja/service/dealer/DealerServiceImp.java b/textja/src/main/java/com/lan/textja/service/dealer/DealerServiceImp.java new file mode 100644 index 0000000..a13c8c4 --- /dev/null +++ b/textja/src/main/java/com/lan/textja/service/dealer/DealerServiceImp.java @@ -0,0 +1,22 @@ +package com.lan.textja.service.dealer; + +import com.lan.textja.entity.Dealer; +import com.lan.textja.entity.Supplier; +import com.lan.textja.mapper.DealerMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class DealerServiceImp implements DealerService{ + + @Autowired + private DealerMapper dealerMapper; + + @Override + public List dealerNames() { + List dealerNames =dealerMapper.dealerNames(); + return dealerNames; + } +} diff --git a/textja/src/main/java/com/lan/textja/service/supplier/SupplyService.java b/textja/src/main/java/com/lan/textja/service/supplier/SupplyService.java index bb74e28..68465a7 100644 --- a/textja/src/main/java/com/lan/textja/service/supplier/SupplyService.java +++ b/textja/src/main/java/com/lan/textja/service/supplier/SupplyService.java @@ -1,5 +1,6 @@ package com.lan.textja.service.supplier; +import com.lan.textja.entity.Order; import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supply; import com.lan.textja.util.PageResult; @@ -17,4 +18,13 @@ public interface SupplyService { List goodsTypes(); List Onorder(Supply supply); + + void SureOrder(Map params); + + Integer goodsNum(); + + List supplierName(); + + + void onAddSupply(Map params); } diff --git a/textja/src/main/java/com/lan/textja/service/supplier/SupplyServiceImp.java b/textja/src/main/java/com/lan/textja/service/supplier/SupplyServiceImp.java index a2e5139..fd8b859 100644 --- a/textja/src/main/java/com/lan/textja/service/supplier/SupplyServiceImp.java +++ b/textja/src/main/java/com/lan/textja/service/supplier/SupplyServiceImp.java @@ -1,30 +1,44 @@ package com.lan.textja.service.supplier; +import com.lan.textja.entity.Dealer; +import com.lan.textja.entity.Order; import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supply; +import com.lan.textja.mapper.DealerMapper; +import com.lan.textja.mapper.OrderMapper; +import com.lan.textja.mapper.SupplierMapper; import com.lan.textja.mapper.SupplyMapper; import com.lan.textja.util.PageResult; import com.sun.org.apache.regexp.internal.RE; +import org.apache.ibatis.javassist.expr.NewArray; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; +import java.util.*; @Service -public class SupplyServiceImp implements SupplyService{ +public class SupplyServiceImp implements SupplyService { @Autowired private SupplyMapper supplyMapper; + @Autowired + private DealerMapper dealerMapper; + + @Autowired + private OrderMapper orderMapper; + + @Autowired + private SupplierMapper supplierMapper; + @Override public PageResult supplyList(PageResult pageResult) { //起始位置 - int start = (pageResult.getPageNum()-1) * pageResult.getPageSize(); + int start = (pageResult.getPageNum() - 1) * pageResult.getPageSize(); //每页条数 int size = pageResult.getPageSize(); //分页结果 - List supplyList = supplyMapper.supplyList(start,size); + List supplyList = supplyMapper.supplyList(start, size); //是user表的总数信息 暂时不需要where条件. long total = supplyMapper.selectCount(null); //封装数据实现返回 @@ -34,25 +48,109 @@ public class SupplyServiceImp implements SupplyService{ @Override public List supplyDetail(Supply supply) { - List supplierList= supplyMapper.supplyDetail(supply); - return supplierList; + List supplierList = supplyMapper.supplyDetail(supply); + return supplierList; } @Override public List supplyselect(Supply supply) { - Listsupplyselect=supplyMapper.supplyselect(supply); + List supplyselect = supplyMapper.supplyselect(supply); return supplyselect; } @Override public List goodsTypes() { - ListgoodsTypes=supplyMapper.goodsTypes(); + List goodsTypes = supplyMapper.goodsTypes(); return goodsTypes; } @Override public List Onorder(Supply supply) { - List Onorder=supplyMapper.Onorder(supply); + List Onorder = supplyMapper.Onorder(supply); return Onorder; } + + @Override + public void SureOrder(Map params) { + + Order order = new Order(); + //设置订单号 + int max = 10000; + int min = 1000; + Random random = new Random(); + int fileName = (random.nextInt(max - min) + min + 1); + order.setOrderNo(fileName); + //设置订单相关值 + order.setOrderGoodsNo(Integer.parseInt(String.valueOf(params.get("goodsNum")))); + order.setOrderName(String.valueOf(Optional.ofNullable(params.get("goodsName")).orElse(""))); + order.setOrderPrice(Integer.parseInt(String.valueOf(params.get("goodsPrice")))); + order.setOrderQty(Integer.parseInt(String.valueOf(params.get("goodsQty")))); + order.setOrderTotalPrice(Integer.parseInt(String.valueOf(params.get("totalPrice")))); + order.setOrderType(String.valueOf(Optional.ofNullable(params.get("goodsType")).orElse(""))); + + //获取dealer信息 + String dealerName = String.valueOf(Optional.ofNullable(params.get("dealerName")).orElse("")); + Dealer dealerList = dealerMapper.select(dealerName); + order.setOrderDealerContact(dealerList.getDealerContact()); + order.setOrderDealerAddress(dealerList.getDealerAddress()); + order.setOrderDealerNumber(dealerList.getDealerNumber()); + order.setOrderDealerNo(dealerList.getDealerNum()); + + Integer goodsSupplierFirm = Integer.parseInt(String.valueOf(params.get("goodsSupplierFirm"))); + Supplier supplierList = supplierMapper.select(goodsSupplierFirm); + + //获取supplier信息 + order.setOrderSupplierContact(supplierList.getSupplierContact()); + order.setOrderSupplierAddress(supplierList.getSupplierAddress()); + order.setOrderSupplierNumber(supplierList.getSupplierNumber()); + order.setOrderSupplierNo(supplierList.getSupplierNum()); + //订单进行中 + order.setOrderState(true); + + orderMapper.SureOrder(order); + } + + @Override + public Integer goodsNum() { + List Nums = supplyMapper.goodsNum(); + System.out.println(Nums); + Integer maxValue = Collections.max(Nums); + System.out.println(maxValue); + maxValue++; + return maxValue; + } + + @Override + public List supplierName() { + List supplierNames = supplierMapper.supplierName(); + return supplierNames; + } + + @Override + public void onAddSupply(Map params) { + Supply supply =new Supply(); + supply.setGoodsNum(Integer.parseInt(String.valueOf(params.get("goodsNum")))); + supply.setGoodsName(String.valueOf(Optional.ofNullable(params.get("goodsName")).orElse(""))); + supply.setGoodsType(String.valueOf(Optional.ofNullable(params.get("goodsType")).orElse(""))); + supply.setGoodsSupplier(String.valueOf(Optional.ofNullable(params.get("supplierName")).orElse(""))); + supply.setGoodsPrice(Integer.parseInt(String.valueOf(params.get("goodsPrice")))); + supply.setGoodsSize(String.valueOf(Optional.ofNullable(params.get("goodsSize")).orElse(""))); + supply.setGoodsEffect(String.valueOf(Optional.ofNullable(params.get("goodsEffect")).orElse(""))); + + //设置goodsState 0无 1有 + Integer goodsState=Integer.parseInt(String.valueOf(params.get("goodsState"))); + if(goodsState==0){ + supply.setGoodsState(false); + } + supply.setGoodsState(true); + + //拿到supplierNum 设置goodsSupplierFirm + String supplierName=String.valueOf(Optional.ofNullable(params.get("supplierName")).orElse("")); + Supplier supplierList = supplierMapper.goodsSupplierFirm(supplierName); + supply.setGoodsSupplierFirm(supplierList.getSupplierNum()); + + supplyMapper.onAddSupply(supply); + } + + } diff --git a/textja/src/main/resources/com/lan/textja/mapper/DealerMapper.xml b/textja/src/main/resources/com/lan/textja/mapper/DealerMapper.xml new file mode 100644 index 0000000..7fef872 --- /dev/null +++ b/textja/src/main/resources/com/lan/textja/mapper/DealerMapper.xml @@ -0,0 +1,22 @@ + + + + + dealer_Num AS "dealerNum", + dealer_Name AS "dealerName", + dealer_Contact AS "dealerContact", + dealer_Address AS "dealerAddress", + dealer_Number AS "dealerNumber", + + + + + + diff --git a/textja/src/main/resources/com/lan/textja/mapper/OrderMapper.xml b/textja/src/main/resources/com/lan/textja/mapper/OrderMapper.xml new file mode 100644 index 0000000..c44583e --- /dev/null +++ b/textja/src/main/resources/com/lan/textja/mapper/OrderMapper.xml @@ -0,0 +1,65 @@ + + + + + order_No AS "orderNo", + order_Name AS "orderName", + order_Price AS "orderPrice", + order_Qty AS "orderQty", + order_Total_Price AS "orderTotalPrice", + order_Type AS "orderType", + order_Supplier_Contact AS "orderSupplierContact", + order_Supplier_Address AS "orderSupplierAddress", + order_Supplier_Number AS "orderSupplierNumber", + order_Dealer_Contact AS "orderDealerContact", + order_Dealer_Address AS "orderDealerAddress", + order_Dealer_Number AS "orderDealerNumber", + order_Goods_No AS "orderGoodsNo", + order_Supplier_No AS "orderSupplierNo", + order_Dealer_No AS "orderDealerNo", + order_State AS "orderState" + + + + insert into + orders ( + order_No, + order_Name, + order_Price, + order_Qty, + order_Total_Price, + order_Type, + order_Supplier_Contact, + order_Supplier_Address, + order_Supplier_Number, + order_Dealer_Contact, + order_Dealer_Address, + order_Dealer_Number, + order_Goods_No, + order_Supplier_No, + order_Dealer_No, + order_State + ) + values ( + #{orderNo}, + #{orderName}, + #{orderPrice}, + #{orderQty}, + #{orderTotalPrice}, + #{orderType}, + #{orderSupplierContact}, + #{orderSupplierAddress}, + #{orderSupplierNumber}, + #{orderDealerContact}, + #{orderDealerAddress}, + #{orderDealerNumber}, + #{orderGoodsNo}, + #{orderSupplierNo}, + #{orderDealerNo}, + #{orderState} + ) + + + diff --git a/textja/src/main/resources/com/lan/textja/mapper/SupplierMapper.xml b/textja/src/main/resources/com/lan/textja/mapper/SupplierMapper.xml index e6a728f..c70978e 100644 --- a/textja/src/main/resources/com/lan/textja/mapper/SupplierMapper.xml +++ b/textja/src/main/resources/com/lan/textja/mapper/SupplierMapper.xml @@ -87,6 +87,20 @@ + + + + + + diff --git a/textja/src/main/resources/com/lan/textja/mapper/SupplyMapper.xml b/textja/src/main/resources/com/lan/textja/mapper/SupplyMapper.xml index 2b7cf13..d38a0f1 100644 --- a/textja/src/main/resources/com/lan/textja/mapper/SupplyMapper.xml +++ b/textja/src/main/resources/com/lan/textja/mapper/SupplyMapper.xml @@ -58,8 +58,39 @@ + + + + + insert into + supplier_goods( + goods_Num, + goods_Name, + goods_Price, + goods_Supplier_Firm, + goods_Type, + goods_Supplier, + goods_Size, + goods_Effect, + goods_State + ) + values ( + #{goodsNum}, + #{goodsName}, + #{goodsPrice}, + #{goodsSupplierFirm}, + #{goodsType}, + #{goodsSupplier}, + #{goodsSize}, + #{goodsEffect}, + #{goodsState} + + ) +