Browse Source

供应商供货

dev
wangzhenglan 2 years ago
parent
commit
d08a49bfd0
  1. 29
      textja/src/main/java/com/lan/textja/controller/dealer/DealerController.java
  2. 33
      textja/src/main/java/com/lan/textja/controller/supplier/SupplyController.java
  3. 18
      textja/src/main/java/com/lan/textja/entity/Dealer.java
  4. 30
      textja/src/main/java/com/lan/textja/entity/Order.java
  5. 3
      textja/src/main/java/com/lan/textja/entity/Supply.java
  6. 13
      textja/src/main/java/com/lan/textja/mapper/DealerMapper.java
  7. 9
      textja/src/main/java/com/lan/textja/mapper/OrderMapper.java
  8. 7
      textja/src/main/java/com/lan/textja/mapper/SupplierMapper.java
  9. 6
      textja/src/main/java/com/lan/textja/mapper/SupplyMapper.java
  10. 9
      textja/src/main/java/com/lan/textja/service/dealer/DealerService.java
  11. 22
      textja/src/main/java/com/lan/textja/service/dealer/DealerServiceImp.java
  12. 10
      textja/src/main/java/com/lan/textja/service/supplier/SupplyService.java
  13. 116
      textja/src/main/java/com/lan/textja/service/supplier/SupplyServiceImp.java
  14. 22
      textja/src/main/resources/com/lan/textja/mapper/DealerMapper.xml
  15. 65
      textja/src/main/resources/com/lan/textja/mapper/OrderMapper.xml
  16. 14
      textja/src/main/resources/com/lan/textja/mapper/SupplierMapper.xml
  17. 33
      textja/src/main/resources/com/lan/textja/mapper/SupplyMapper.xml

29
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<Dealer> dealerNames= dealerService.dealerNames();
return JsonResult.ok(dealerNames);
}
}

33
textja/src/main/java/com/lan/textja/controller/supplier/SupplyController.java

@ -1,5 +1,6 @@
package com.lan.textja.controller.supplier; package com.lan.textja.controller.supplier;
import com.lan.textja.entity.Order;
import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supplier;
import com.lan.textja.entity.Supply; import com.lan.textja.entity.Supply;
import com.lan.textja.service.supplier.SupplierService; 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.JsonResult;
import com.lan.textja.util.PageResult; import com.lan.textja.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.*;
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; import java.util.List;
import java.util.Map; import java.util.Map;
@ -53,4 +51,31 @@ public class SupplyController {
List<Supply> Onorder=supplyService.Onorder(supply); List<Supply> Onorder=supplyService.Onorder(supply);
return JsonResult.ok(Onorder); return JsonResult.ok(Onorder);
} }
@RequestMapping(value = "/SureOrder",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
public JsonResult SureOrder(@RequestParam(required = false) Map<String,Object> 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<Supplier> supplierNames=supplyService.supplierName();
return JsonResult.ok(supplierNames);
}
@RequestMapping(value = "/onAddSupply",method = RequestMethod.POST)
public JsonResult onAddSupply(@RequestParam(required = false) Map<String,Object> params){
supplyService.onAddSupply(params);
return JsonResult.ok(JsonResult.SUCCESS);
}
} }

18
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;
}

30
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;
}

3
textja/src/main/java/com/lan/textja/entity/Supply.java

@ -20,5 +20,6 @@ public class Supply {
private String goodsSize; private String goodsSize;
private String goodsEffect; private String goodsEffect;
private Boolean goodsState; private Boolean goodsState;
private List<Supplier> supplierList; private Supplier supplierList;
// private List<Dealer> dealerList;
} }

13
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<Dealer> {
List<Dealer> dealerNames();
Dealer select(String dealerName);
}

9
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<Order> {
void SureOrder(Order order);
}

7
textja/src/main/java/com/lan/textja/mapper/SupplierMapper.java

@ -23,4 +23,11 @@ public interface SupplierMapper extends BaseMapper<Supplier> {
List<Supplier> onSubmit(Supplier supplier); List<Supplier> onSubmit(Supplier supplier);
List<Integer> SupplierNum(); List<Integer> SupplierNum();
Supplier select(Integer goodsSupplierFirm);
List<Supplier> supplierName();
Supplier goodsSupplierFirm(String supplierName);
} }

6
textja/src/main/java/com/lan/textja/mapper/SupplyMapper.java

@ -1,6 +1,7 @@
package com.lan.textja.mapper; package com.lan.textja.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lan.textja.entity.Order;
import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supplier;
import com.lan.textja.entity.Supply; import com.lan.textja.entity.Supply;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
@ -20,4 +21,9 @@ public interface SupplyMapper extends BaseMapper<Supply> {
List<Supply> goodsTypes(); List<Supply> goodsTypes();
List<Supply> Onorder(Supply supply); List<Supply> Onorder(Supply supply);
List<Integer> goodsNum();
void onAddSupply(Supply supply);
} }

9
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<Dealer> dealerNames();
}

22
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<Dealer> dealerNames() {
List<Dealer> dealerNames =dealerMapper.dealerNames();
return dealerNames;
}
}

10
textja/src/main/java/com/lan/textja/service/supplier/SupplyService.java

@ -1,5 +1,6 @@
package com.lan.textja.service.supplier; package com.lan.textja.service.supplier;
import com.lan.textja.entity.Order;
import com.lan.textja.entity.Supplier; import com.lan.textja.entity.Supplier;
import com.lan.textja.entity.Supply; import com.lan.textja.entity.Supply;
import com.lan.textja.util.PageResult; import com.lan.textja.util.PageResult;
@ -17,4 +18,13 @@ public interface SupplyService {
List<Supply> goodsTypes(); List<Supply> goodsTypes();
List<Supply> Onorder(Supply supply); List<Supply> Onorder(Supply supply);
void SureOrder(Map<String,Object> params);
Integer goodsNum();
List<Supplier> supplierName();
void onAddSupply(Map<String, Object> params);
} }

116
textja/src/main/java/com/lan/textja/service/supplier/SupplyServiceImp.java

@ -1,30 +1,44 @@
package com.lan.textja.service.supplier; 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.Supplier;
import com.lan.textja.entity.Supply; 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.mapper.SupplyMapper;
import com.lan.textja.util.PageResult; import com.lan.textja.util.PageResult;
import com.sun.org.apache.regexp.internal.RE; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.*;
import java.util.Map;
@Service @Service
public class SupplyServiceImp implements SupplyService{ public class SupplyServiceImp implements SupplyService {
@Autowired @Autowired
private SupplyMapper supplyMapper; private SupplyMapper supplyMapper;
@Autowired
private DealerMapper dealerMapper;
@Autowired
private OrderMapper orderMapper;
@Autowired
private SupplierMapper supplierMapper;
@Override @Override
public PageResult supplyList(PageResult pageResult) { public PageResult supplyList(PageResult pageResult) {
//起始位置 //起始位置
int start = (pageResult.getPageNum()-1) * pageResult.getPageSize(); int start = (pageResult.getPageNum() - 1) * pageResult.getPageSize();
//每页条数 //每页条数
int size = pageResult.getPageSize(); int size = pageResult.getPageSize();
//分页结果 //分页结果
List<Supply> supplyList = supplyMapper.supplyList(start,size); List<Supply> supplyList = supplyMapper.supplyList(start, size);
//是user表的总数信息 暂时不需要where条件. //是user表的总数信息 暂时不需要where条件.
long total = supplyMapper.selectCount(null); long total = supplyMapper.selectCount(null);
//封装数据实现返回 //封装数据实现返回
@ -34,25 +48,109 @@ public class SupplyServiceImp implements SupplyService{
@Override @Override
public List<Supplier> supplyDetail(Supply supply) { public List<Supplier> supplyDetail(Supply supply) {
List<Supplier> supplierList= supplyMapper.supplyDetail(supply); List<Supplier> supplierList = supplyMapper.supplyDetail(supply);
return supplierList; return supplierList;
} }
@Override @Override
public List<Supply> supplyselect(Supply supply) { public List<Supply> supplyselect(Supply supply) {
List<Supply>supplyselect=supplyMapper.supplyselect(supply); List<Supply> supplyselect = supplyMapper.supplyselect(supply);
return supplyselect; return supplyselect;
} }
@Override @Override
public List<Supply> goodsTypes() { public List<Supply> goodsTypes() {
List<Supply>goodsTypes=supplyMapper.goodsTypes(); List<Supply> goodsTypes = supplyMapper.goodsTypes();
return goodsTypes; return goodsTypes;
} }
@Override @Override
public List<Supply> Onorder(Supply supply) { public List<Supply> Onorder(Supply supply) {
List<Supply> Onorder=supplyMapper.Onorder(supply); List<Supply> Onorder = supplyMapper.Onorder(supply);
return Onorder; return Onorder;
} }
@Override
public void SureOrder(Map<String, Object> 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<Integer> Nums = supplyMapper.goodsNum();
System.out.println(Nums);
Integer maxValue = Collections.max(Nums);
System.out.println(maxValue);
maxValue++;
return maxValue;
}
@Override
public List<Supplier> supplierName() {
List<Supplier> supplierNames = supplierMapper.supplierName();
return supplierNames;
}
@Override
public void onAddSupply(Map<String, Object> 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);
}
} }

22
textja/src/main/resources/com/lan/textja/mapper/DealerMapper.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lan.textja.mapper.DealerMapper">
<sql id="dealerColumns">
dealer_Num AS "dealerNum",
dealer_Name AS "dealerName",
dealer_Contact AS "dealerContact",
dealer_Address AS "dealerAddress",
dealer_Number AS "dealerNumber",
</sql>
<select id="dealerNames" resultType="com.lan.textja.entity.Dealer">
select distinct dealer_Name,dealer_Num from dealer
</select>
<select id="select" resultType="com.lan.textja.entity.Dealer">
select dealer_Contact,dealer_Address,dealer_Number,dealer_Num from dealer
where dealer_Name=#{dealerName}
</select>
</mapper>

65
textja/src/main/resources/com/lan/textja/mapper/OrderMapper.xml

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lan.textja.mapper.OrderMapper">
<sql id="OrderColumns">
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"
</sql>
<insert id="SureOrder" parameterType="com.lan.textja.entity.Order">
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}
)
</insert>
</mapper>

14
textja/src/main/resources/com/lan/textja/mapper/SupplierMapper.xml

@ -87,6 +87,20 @@
<select id="SupplierNum" resultType="Integer"> <select id="SupplierNum" resultType="Integer">
select distinct supplier_Num from supplier select distinct supplier_Num from supplier
</select> </select>
<select id="select" resultType="com.lan.textja.entity.Supplier">
select supplier_Contact,supplier_Address,supplier_Number,supplier_Num from supplier
where supplier_Num=#{goodsSupplierFirm}
</select>
<select id="supplierName" resultType="com.lan.textja.entity.Supplier">
select distinct supplier_Name from supplier
</select>
<select id="goodsSupplierFirm" resultType="com.lan.textja.entity.Supplier">
select supplier_Num from supplier
where supplier_Name=#{supplierName}
</select>
</mapper> </mapper>

33
textja/src/main/resources/com/lan/textja/mapper/SupplyMapper.xml

@ -58,8 +58,39 @@
</select> </select>
<select id="Onorder" resultMap="supply"> <select id="Onorder" resultMap="supply">
select a.goods_Name,a.goods_Price,a.goods_Type,a.goods_Supplier,b.supplier_Address,b.supplier_Receiver,b.supplier_Number select a.goods_Num,a.goods_Name,a.goods_Price,a.goods_Type,a.goods_Supplier,a.goods_Supplier_Firm,b.supplier_Address,b.supplier_Contact,b.supplier_Number
from supplier_goods a join supplier b on a.goods_Supplier_Firm=b.supplier_Num from supplier_goods a join supplier b on a.goods_Supplier_Firm=b.supplier_Num
where a.goods_Num=#{goodsNum} where a.goods_Num=#{goodsNum}
</select> </select>
<select id="goodsNum" resultType="Integer">
select distinct goods_Num from supplier_goods
</select>
<insert id="onAddSupply" parameterType="com.lan.textja.entity.Supply">
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}
)
</insert>
</mapper> </mapper>

Loading…
Cancel
Save