食堂项目功能修改
This commit is contained in:
@@ -9,7 +9,9 @@ import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
|||||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||||
import com.zf.foodpurchase.common.utils.DateUtils;
|
import com.zf.foodpurchase.common.utils.DateUtils;
|
||||||
|
import com.zf.foodpurchase.fdsafe.entity.FoodRepo;
|
||||||
import com.zf.foodpurchase.fdsafe.entity.Repository;
|
import com.zf.foodpurchase.fdsafe.entity.Repository;
|
||||||
|
import com.zf.foodpurchase.fdsafe.mapper.FoodRepoMapper;
|
||||||
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
|
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
|
||||||
import com.zf.foodpurchase.fdsafe.vo.RepositoryVO;
|
import com.zf.foodpurchase.fdsafe.vo.RepositoryVO;
|
||||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||||
@@ -20,6 +22,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -37,6 +41,8 @@ public class RepositoryController extends BaseController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
@Autowired
|
||||||
|
private FoodRepoMapper foodRepoMapper;
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(Repository repository) {
|
public AjaxResult list(Repository repository) {
|
||||||
@@ -105,7 +111,23 @@ public class RepositoryController extends BaseController {
|
|||||||
public AjaxResult delete(Long[] ids) {
|
public AjaxResult delete(Long[] ids) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
List<Long> list = Arrays.asList(ids);
|
List<Long> list = Arrays.asList(ids);
|
||||||
flag = repositoryService.removeByIds( list);
|
List<FoodRepo> foodRepos = foodRepoMapper.selectByRepoId(list);
|
||||||
|
List<Long> newList = new ArrayList<>();
|
||||||
|
for (Long repoId : list) {
|
||||||
|
List<FoodRepo> matchRepos = foodRepos.stream()
|
||||||
|
.filter(foodRepo -> repoId.longValue() == foodRepo.getRepoId())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 1.无记录 || 2.存在记录数量>0
|
||||||
|
boolean allZero = matchRepos.isEmpty()
|
||||||
|
|| matchRepos.stream().allMatch(foodRepo -> Objects.equals(foodRepo.getFoodProductNum(), 0));
|
||||||
|
if(allZero){
|
||||||
|
newList.add(repoId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollectionUtil.isEmpty(newList)){
|
||||||
|
return AjaxResult.error("存在商品数量不为0的仓库,不能删除");
|
||||||
|
}
|
||||||
|
flag = repositoryService.removeByIds( newList);
|
||||||
return flag?AjaxResult.success("删除成功"):AjaxResult.error("删除失败");
|
return flag?AjaxResult.success("删除成功"):AjaxResult.error("删除失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public interface OrderStatusConstants {
|
|||||||
public static final Integer DELIVERING = 2;
|
public static final Integer DELIVERING = 2;
|
||||||
public static final Integer COMPLETED = 3;
|
public static final Integer COMPLETED = 3;
|
||||||
public static final Integer CANCELED = 4;
|
public static final Integer CANCELED = 4;
|
||||||
|
public static final Integer INREPO = 5;
|
||||||
|
|
||||||
// 订单是否可参与结算
|
// 订单是否可参与结算
|
||||||
public static final Integer CAN_SETTLEMENT = 1;
|
public static final Integer CAN_SETTLEMENT = 1;
|
||||||
|
|||||||
@@ -8,7 +8,5 @@ public class FoodRepo {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
private Integer foodProductId;
|
private Integer foodProductId;
|
||||||
private Integer repoId;
|
private Integer repoId;
|
||||||
private String orderNo;
|
|
||||||
private String orderItemNo;
|
|
||||||
private Integer foodProductNum;
|
private Integer foodProductNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ package com.zf.foodpurchase.fdsafe.mapper;
|
|||||||
import com.zf.foodpurchase.fdsafe.entity.FoodRepo;
|
import com.zf.foodpurchase.fdsafe.entity.FoodRepo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface FoodRepoMapper {
|
public interface FoodRepoMapper {
|
||||||
|
|
||||||
int insert(FoodRepo foodRepo);
|
int insert(FoodRepo foodRepo);
|
||||||
int update(FoodRepo foodRepo);
|
int update(FoodRepo foodRepo);
|
||||||
FoodRepo selectByProductIdAndRepoId(@Param("productId") Long productId, @Param("repoId") Long repoId);
|
FoodRepo selectByProductIdAndRepoId(@Param("productId") Long productId, @Param("repoId") Long repoId);
|
||||||
|
|
||||||
|
List<FoodRepo> selectByRepoId(@Param("repoIds") List<Long> repoIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRec
|
|||||||
Integer repoId = inRepoVO.getRepoId();
|
Integer repoId = inRepoVO.getRepoId();
|
||||||
Integer productNum = inRepoVO.getProductNum() == null ? 0 : inRepoVO.getProductNum();
|
Integer productNum = inRepoVO.getProductNum() == null ? 0 : inRepoVO.getProductNum();
|
||||||
String orderNo = inRepoVO.getOrderNo();
|
String orderNo = inRepoVO.getOrderNo();
|
||||||
String orderItemNo = inRepoVO.getOrderItemNo();
|
|
||||||
Integer supplierId = inRepoVO.getSupplierId();
|
Integer supplierId = inRepoVO.getSupplierId();
|
||||||
Integer categoryId = inRepoVO.getTypeId();
|
Integer categoryId = inRepoVO.getTypeId();
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
@@ -82,8 +81,6 @@ public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRec
|
|||||||
FoodRepo foodRepo = new FoodRepo();
|
FoodRepo foodRepo = new FoodRepo();
|
||||||
foodRepo.setFoodProductId(productId);
|
foodRepo.setFoodProductId(productId);
|
||||||
foodRepo.setRepoId(repoId);
|
foodRepo.setRepoId(repoId);
|
||||||
foodRepo.setOrderNo(orderNo);
|
|
||||||
foodRepo.setOrderItemNo(orderItemNo);
|
|
||||||
foodRepo.setFoodProductNum(productNum);
|
foodRepo.setFoodProductNum(productNum);
|
||||||
foodRepoMapper.insert(foodRepo);
|
foodRepoMapper.insert(foodRepo);
|
||||||
}
|
}
|
||||||
@@ -129,8 +126,11 @@ public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRec
|
|||||||
if(!user.isAdmin()){
|
if(!user.isAdmin()){
|
||||||
repoRecord.setDeptId(user.getDeptId());
|
repoRecord.setDeptId(user.getDeptId());
|
||||||
}
|
}
|
||||||
repoRecordMapper.insertRepoRecord(repoRecord);
|
|
||||||
FoodRepo oldFoodRepo = foodRepoMapper.selectByProductIdAndRepoId(productId.longValue(),repoId.longValue());
|
FoodRepo oldFoodRepo = foodRepoMapper.selectByProductIdAndRepoId(productId.longValue(),repoId.longValue());
|
||||||
|
if(oldFoodRepo.getFoodProductNum()<productNum){
|
||||||
|
return AjaxResult.warn("出库数量不能大于库存数量");
|
||||||
|
}
|
||||||
|
repoRecordMapper.insertRepoRecord(repoRecord);
|
||||||
Integer foodProductNumNew = oldFoodRepo.getFoodProductNum() - productNum;
|
Integer foodProductNumNew = oldFoodRepo.getFoodProductNum() - productNum;
|
||||||
oldFoodRepo.setFoodProductNum(foodProductNumNew);
|
oldFoodRepo.setFoodProductNum(foodProductNumNew);
|
||||||
foodRepoMapper.update(oldFoodRepo);
|
foodRepoMapper.update(oldFoodRepo);
|
||||||
|
|||||||
@@ -265,6 +265,8 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
|
|||||||
throw new ServiceException("订单处于取消状态,无法再次取消");
|
throw new ServiceException("订单处于取消状态,无法再次取消");
|
||||||
}else if(OrderStatusConstants.COMPLETED.equals(orderStatus)){
|
}else if(OrderStatusConstants.COMPLETED.equals(orderStatus)){
|
||||||
throw new ServiceException("订单处于已完成,无法取消");
|
throw new ServiceException("订单处于已完成,无法取消");
|
||||||
|
}else if(OrderStatusConstants.INREPO.equals(orderStatus)){
|
||||||
|
throw new ServiceException("订单中的商品已入库,无法取消");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
left join food_spec d on a.spec_id=d.spec_id
|
left join food_spec d on a.spec_id=d.spec_id
|
||||||
left join food_unit e on a.unit_id=e.unit_id
|
left join food_unit e on a.unit_id=e.unit_id
|
||||||
left join supplier sup on a.supplier_id=sup.supplier_id
|
left join supplier sup on a.supplier_id=sup.supplier_id
|
||||||
where b.repo_id=#{repoId} and a.del_flag=0
|
where b.repo_id=#{repoId} and a.del_flag=0 and b.food_product_num >0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateDelFlag">
|
<update id="updateDelFlag">
|
||||||
|
|||||||
@@ -6,14 +6,10 @@
|
|||||||
insert into food_repo(
|
insert into food_repo(
|
||||||
<if test="foodProductId != null">food_product_id,</if>
|
<if test="foodProductId != null">food_product_id,</if>
|
||||||
<if test="repoId != null">repo_id,</if>
|
<if test="repoId != null">repo_id,</if>
|
||||||
<if test="orderNo != null and orderNo != ''">order_no,</if>
|
|
||||||
<if test="orderItemNo != null and orderItemNo != ''">order_item_no,</if>
|
|
||||||
<if test="foodProductNum != null">food_product_num</if>
|
<if test="foodProductNum != null">food_product_num</if>
|
||||||
)values(
|
)values(
|
||||||
<if test="foodProductId != null">#{foodProductId},</if>
|
<if test="foodProductId != null">#{foodProductId},</if>
|
||||||
<if test="repoId != null">#{repoId},</if>
|
<if test="repoId != null">#{repoId},</if>
|
||||||
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
|
|
||||||
<if test="orderItemNo != null and orderItemNo != ''">#{orderItemNo},</if>
|
|
||||||
<if test="foodProductNum != null">#{foodProductNum}</if>)
|
<if test="foodProductNum != null">#{foodProductNum}</if>)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -22,8 +18,6 @@
|
|||||||
<set>
|
<set>
|
||||||
<if test="foodProductId != null">food_product_id=#{foodProductId},</if>
|
<if test="foodProductId != null">food_product_id=#{foodProductId},</if>
|
||||||
<if test="repoId != null">repo_id=#{repoId},</if>
|
<if test="repoId != null">repo_id=#{repoId},</if>
|
||||||
<if test="orderNo != null and orderNo != ''">order_no=#{orderNo},</if>
|
|
||||||
<if test="orderItemNo != null and orderItemNo != ''">order_item_no=#{orderItemNo},</if>
|
|
||||||
<if test="foodProductNum != null">food_product_num=#{foodProductNum}</if>
|
<if test="foodProductNum != null">food_product_num=#{foodProductNum}</if>
|
||||||
</set>
|
</set>
|
||||||
where id=#{id}
|
where id=#{id}
|
||||||
@@ -31,8 +25,17 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="selectByProductIdAndRepoId" resultType="FoodRepo">
|
<select id="selectByProductIdAndRepoId" resultType="FoodRepo">
|
||||||
select id, food_product_id foodProductId, repo_id repoId, order_no orderNo, order_item_no orderItemNo, food_product_num foodProductNum
|
select id, food_product_id foodProductId, repo_id repoId, food_product_num foodProductNum
|
||||||
from food_repo where food_product_id=#{productId} and repo_id=#{repoId}
|
from food_repo where food_product_id=#{productId} and repo_id=#{repoId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByRepoId" resultType="FoodRepo">
|
||||||
|
select id, food_product_id foodProductId, repo_id repoId, food_product_num foodProductNum
|
||||||
|
from food_repo where repo_id in
|
||||||
|
<foreach collection="repoIds" item="repoId" index="index"
|
||||||
|
separator="," open="(" close=")">
|
||||||
|
#{repoId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -25,7 +25,26 @@
|
|||||||
</sql>
|
</sql>
|
||||||
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.vo.RepositoryVO"
|
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.vo.RepositoryVO"
|
||||||
parameterType="com.zf.foodpurchase.fdsafe.entity.Repository">
|
parameterType="com.zf.foodpurchase.fdsafe.entity.Repository">
|
||||||
select r.id,r.merchant_id,r.repo_num,r.repo_name,r.area_code,r.detail_address,r.default_repo,r.create_time,r.update_time,r.oper_id,r.manager,r.order_num,d.dept_name merchant_name,count(fr.food_product_num) spCount,ifnull(sum(fr.food_product_num),0) wpCount,su.user_name managerName
|
select
|
||||||
|
r.id,
|
||||||
|
r.merchant_id,
|
||||||
|
r.repo_num,
|
||||||
|
r.repo_name,
|
||||||
|
r.area_code,
|
||||||
|
r.detail_address,
|
||||||
|
r.default_repo,
|
||||||
|
r.create_time,
|
||||||
|
r.update_time,
|
||||||
|
r.oper_id,
|
||||||
|
r.manager,
|
||||||
|
r.order_num,
|
||||||
|
d.dept_name merchant_name,
|
||||||
|
CASE
|
||||||
|
WHEN ifnull(sum(fr.food_product_num),0) = 0 THEN 0
|
||||||
|
ELSE count(fr.food_product_num)
|
||||||
|
END AS spCount,
|
||||||
|
ifnull(sum(fr.food_product_num),0) wpCount,
|
||||||
|
su.user_name managerName
|
||||||
from repository r
|
from repository r
|
||||||
left join sys_dept d on r.merchant_id=d.dept_id
|
left join sys_dept d on r.merchant_id=d.dept_id
|
||||||
left join food_repo fr on r.id=fr.repo_id
|
left join food_repo fr on r.id=fr.repo_id
|
||||||
|
|||||||
Reference in New Issue
Block a user