You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
528 lines
25 KiB
Java
528 lines
25 KiB
Java
package com.glxp.api.controller.purchase;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
import com.glxp.api.annotation.RepeatSubmit;
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
import com.glxp.api.constant.Constant;
|
|
import com.glxp.api.constant.ConstantStatus;
|
|
import com.glxp.api.constant.ConstantType;
|
|
import com.glxp.api.entity.basic.BasicBusTypeChangeEntity;
|
|
import com.glxp.api.entity.basic.BasicProductsEntity;
|
|
import com.glxp.api.entity.inout.IoOrderDetailBizEntity;
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
import com.glxp.api.entity.purchase.*;
|
|
import com.glxp.api.req.purchase.PostPurApplyRequest;
|
|
import com.glxp.api.req.purchase.PurApplyDetailRequest;
|
|
import com.glxp.api.req.purchase.PurApplyRequest;
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
import com.glxp.api.res.purchase.PurApplyResponse;
|
|
import com.glxp.api.res.purchase.PurOrderDetailResponse;
|
|
import com.glxp.api.service.auth.CustomerService;
|
|
import com.glxp.api.service.basic.IBasicBusTypeChangeService;
|
|
import com.glxp.api.service.inout.IoOrderDetailBizService;
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
import com.glxp.api.service.purchase.*;
|
|
import com.glxp.api.util.CustomUtil;
|
|
import com.glxp.api.util.GennerOrderUtils;
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.validation.constraints.NotEmpty;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* pur
|
|
*
|
|
* @author anthony.ywj
|
|
* @date 2022-10-12
|
|
*/
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
public class PurApplyController {
|
|
|
|
@Resource
|
|
PurApplyService purApplyService;
|
|
@Resource
|
|
PurApplyDetailService purApplyDetailService;
|
|
@Resource
|
|
PurPlanService purPlanService;
|
|
@Resource
|
|
PurPlanDetailService purPlanDetailService;
|
|
|
|
@Resource
|
|
IBasicBusTypeChangeService basicBusTypeChangeService;
|
|
@Resource
|
|
CustomerService customerService;
|
|
@Resource
|
|
GennerOrderUtils gennerOrderUtils;
|
|
@Resource
|
|
PurOrderService purOrderService;
|
|
@Resource
|
|
PurOrderDetailService purOrderDetailService;
|
|
@Resource
|
|
IoOrderService ioOrderService;
|
|
@Resource
|
|
IoOrderDetailBizService ioOrderDetailBizService;
|
|
@Resource
|
|
IoPurChangeService purChangeService;
|
|
|
|
/**
|
|
* 新增申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/purchase/apply/postOrder")
|
|
public BaseResponse postOrder(@RequestBody PostPurApplyRequest postPurApplyRequest) {
|
|
|
|
Long userId = customerService.getUserId();
|
|
PurApplyEntity purApplyEntity = postPurApplyRequest.getPurApplyEntity();
|
|
purApplyEntity.setCreateUser(userId + "");
|
|
purApplyEntity.setCreateTime(new Date());
|
|
purApplyEntity.setUpdateTime(new Date());
|
|
purApplyEntity.setStatus(postPurApplyRequest.getEditStatus()); //草稿状态
|
|
if (postPurApplyRequest.getType() != null) {
|
|
String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.SG_ORDER, "yyyyMMdd"));
|
|
purApplyEntity.setBillNo(billNo);
|
|
}
|
|
if (purApplyEntity.getId() == null) {
|
|
purApplyService.insert(purApplyEntity);
|
|
} else {
|
|
purApplyService.update(purApplyEntity);
|
|
}
|
|
|
|
return ResultVOUtils.success("提交成功!");
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询申购单列表
|
|
*/
|
|
@PostMapping("/purchase/apply/list")
|
|
public BaseResponse list(@RequestBody PurApplyRequest purApplyRequest) {
|
|
|
|
if (purApplyRequest.getStatus() == null) {
|
|
purApplyRequest.setStatus(11); //查询未审核和草稿状态
|
|
}
|
|
|
|
List<PurApplyResponse> purApplyEntities = purApplyService.queryPageList(purApplyRequest);
|
|
PageInfo<PurApplyResponse> pageInfo;
|
|
pageInfo = new PageInfo<>(purApplyEntities);
|
|
PageSimpleResponse<PurApplyResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(purApplyEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询申购单列表
|
|
*/
|
|
@PostMapping("/purchase/apply/auditList")
|
|
public BaseResponse auditList(@RequestBody PurApplyRequest purApplyRequest) {
|
|
|
|
if (purApplyRequest.getStatus() == null) {
|
|
purApplyRequest.setStatus(10); //查询未审核和已审核状态
|
|
}
|
|
|
|
List<PurApplyResponse> purApplyEntities = purApplyService.queryPageList(purApplyRequest);
|
|
PageInfo<PurApplyResponse> pageInfo;
|
|
pageInfo = new PageInfo<>(purApplyEntities);
|
|
PageSimpleResponse<PurApplyResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(purApplyEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 审核申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@PostMapping("/purchase/apply/auditOrder")
|
|
public BaseResponse auditOrder(@RequestBody PurApplyResponse purApplyRequest) {
|
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
PurApplyEntity purApplyEntity = new PurApplyEntity();
|
|
BeanUtils.copyProperties(purApplyRequest, purApplyEntity);
|
|
purApplyEntity.setUpdateTime(new Date());
|
|
purApplyEntity.setAuditTime(new Date());
|
|
purApplyEntity.setAuditUser(userId + "");
|
|
purApplyService.update(purApplyEntity);
|
|
if (purApplyRequest.getStatus() == 3) {
|
|
purChangeService.purApplyChange(purApplyEntity);
|
|
}
|
|
|
|
|
|
// //审核通过后转换成采购计划单
|
|
// if (purApplyEntity.getStatus() == ConstantStatus.APPLY_AUDIT_ED && purApplyRequest.isAudtoPlan()) {
|
|
// PurPlanEntity purPlanEntity = new PurPlanEntity();
|
|
// String billNo = gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.JH_ORDER, "yyyyMMdd"));
|
|
// purPlanEntity.setBillNo(billNo);
|
|
// purPlanEntity.setBillDate(new Date());
|
|
// purPlanEntity.setInvCode(purApplyEntity.getInvCode());
|
|
// purPlanEntity.setDeptCode(purApplyEntity.getDeptCode());
|
|
// purApplyEntity.setCreateUser(customerService.getUserId()+"");
|
|
// purPlanEntity.setUpdateUser(purApplyEntity.getUpdateUser());
|
|
// purPlanEntity.setStatus(ConstantStatus.APPLY_DRAFT);
|
|
// purPlanEntity.setBillType("purPlan");
|
|
// purPlanEntity.setCreateTime(new Date());
|
|
// purPlanEntity.setUpdateTime(new Date());
|
|
// purPlanEntity.setApplyBillNo(purApplyEntity.getBillNo());
|
|
// purPlanEntity.setApplyCreateUser(purApplyEntity.getCreateUser());
|
|
// purPlanEntity.setApplyRemark(purApplyEntity.getRemark());
|
|
// purPlanEntity.setApplyAuditUser(purApplyEntity.getAuditUser());
|
|
// purPlanEntity.setRemark("申购科室:" + purApplyRequest.getTargetInvCode() +
|
|
// ";申购人:" + purApplyRequest.getCreateByName() + ";申购原因:" + purApplyRequest.getRemark());
|
|
// purApplyEntity.setPlanBillNo(purPlanEntity.getBillNo());
|
|
// purApplyEntity.setGeneratePlan(true);
|
|
// purApplyService.update(purApplyEntity);
|
|
// purPlanService.insert(purPlanEntity);
|
|
// List<PurApplyDetailEntity> purApplyDetailEntities = purApplyDetailService.findByOrderId(purApplyEntity.getId() + "");
|
|
// if (CollUtil.isNotEmpty(purApplyDetailEntities)) {
|
|
// for (PurApplyDetailEntity purApplyDetailEntity : purApplyDetailEntities) {
|
|
// PurPlanDetailEntity purPlanDetailEntity = new PurPlanDetailEntity();
|
|
// BeanUtils.copyProperties(purApplyDetailEntity, purPlanDetailEntity);
|
|
// purPlanDetailEntity.setOrderIdFk(purPlanEntity.getId() + "");
|
|
// purPlanDetailService.insert(purPlanDetailEntity);
|
|
// }
|
|
// }
|
|
// }
|
|
return ResultVOUtils.success("更新成功!");
|
|
}
|
|
|
|
|
|
//根据单据生成新单据
|
|
public Boolean generateDocument(PurApplyEntity purApplyEntity) {
|
|
BasicBusTypeChangeEntity basicBusTypeChangeEntity = new BasicBusTypeChangeEntity();
|
|
//查询申购详情
|
|
List<PurApplyDetailEntity> purApplyDetailEntityList = purApplyDetailService.findByOrderId(purApplyEntity.getId() + "");
|
|
//---------------------------------判断申购为已审核就生成计划单-------------------------------------------//
|
|
PurPlanEntity purPlanEntity = new PurPlanEntity();
|
|
List<PurPlanDetailEntity> purPlanDetailEntityList = new ArrayList<>();
|
|
if (purApplyEntity.getStatus() == 3) {
|
|
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CPSG");
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
purPlanEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.JH_ORDER, "yyyyMMdd")));
|
|
purPlanEntity.setBillDate(purApplyEntity.getBillDate());
|
|
purPlanEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
|
|
purPlanEntity.setRemark(purApplyEntity.getRemark());
|
|
purPlanEntity.setEmergency(purApplyEntity.getEmergency());
|
|
purPlanEntity.setArrivalTime(purApplyEntity.getArrivalTime());
|
|
purPlanEntity.setInvCode(purApplyEntity.getInvCode());
|
|
purPlanEntity.setDeptCode(purApplyEntity.getDeptCode());
|
|
purPlanEntity.setCreateUser(purApplyEntity.getAuditUser());
|
|
purPlanEntity.setCreateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
purPlanEntity.setUpdateUser(purApplyEntity.getAuditUser());
|
|
purPlanEntity.setUpdateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
if (purPlanEntity.getStatus() == 3) {
|
|
purPlanEntity.setAuditUser("");
|
|
purPlanEntity.setAuditTime(new Date());
|
|
}
|
|
//插入计划主表
|
|
purPlanService.insert(purPlanEntity);
|
|
//用stream流复制list
|
|
purPlanDetailEntityList = purApplyDetailEntityList.stream().map(e -> {
|
|
PurPlanDetailEntity d = new PurPlanDetailEntity();
|
|
d.setOrderIdFk(purPlanEntity.getId() + "");
|
|
d.setProductId(e.getProductId());
|
|
d.setProductName(e.getProductName());
|
|
d.setCount(e.getCount());
|
|
d.setSupId(e.getSupId());
|
|
d.setZczbhhzbapzbh(e.getZczbhhzbapzbh());
|
|
return d;
|
|
}).collect(Collectors.toList());
|
|
purPlanDetailService.insertPurPlanDetailEntity(purPlanDetailEntityList);
|
|
//更新申购表信息插入计划单号
|
|
PurApplyEntity purApplyEntity1 = new PurApplyEntity();
|
|
purApplyEntity1.setId(purApplyEntity.getId());
|
|
purApplyEntity1.setPlanBillNo(purPlanEntity.getBillNo());
|
|
purApplyEntity1.setGeneratePlan(true);
|
|
purApplyService.update(purApplyEntity1);
|
|
//---------------------------------判断计划为已审核就生成计划单-------------------------------------------//\
|
|
PurOrderEntity purOrderEntity = new PurOrderEntity();
|
|
if (purPlanEntity.getStatus() == 3) {
|
|
basicBusTypeChangeEntity = basicBusTypeChangeService.selectByOriginAction("CGJH");
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetBusAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
purOrderEntity.setBillNo(gennerOrderUtils.createStOrderNo(new OrderNoTypeBean(Constant.CG_ORDER, "yyyyMMdd")));
|
|
purOrderEntity.setBillDate(purApplyEntity.getBillDate());
|
|
purOrderEntity.setStatus(basicBusTypeChangeEntity.getBusAuditStatus());
|
|
purOrderEntity.setRemark(purApplyEntity.getRemark());
|
|
purOrderEntity.setEmergency(purApplyEntity.getEmergency());
|
|
purOrderEntity.setArrivalTime(purApplyEntity.getArrivalTime());
|
|
purOrderEntity.setInvCode(purApplyEntity.getInvCode());
|
|
purOrderEntity.setDeptCode(purApplyEntity.getDeptCode());
|
|
purOrderEntity.setCreateUser(purApplyEntity.getAuditUser());
|
|
purOrderEntity.setCreateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
purOrderEntity.setUpdateUser(purApplyEntity.getAuditUser());
|
|
purOrderEntity.setUpdateTime(timeProcess(purApplyEntity.getCreateTime(), basicBusTypeChangeEntity.getBusBeforeTime()));
|
|
if (purOrderEntity.getStatus() == 3) {
|
|
purOrderEntity.setAuditUser("");
|
|
purOrderEntity.setAuditTime(new Date());
|
|
}
|
|
//插入订单主表
|
|
purOrderService.insert(purOrderEntity);
|
|
//用stream流复制list
|
|
List<PurOrderDetailEntity> purOrderDetailEntityList = purApplyDetailEntityList.stream().map(e -> {
|
|
PurOrderDetailEntity d = new PurOrderDetailEntity();
|
|
d.setOrderIdFk(purOrderEntity.getId() + "");
|
|
d.setProductId(e.getProductId());
|
|
d.setProductName(e.getProductName());
|
|
d.setCount(e.getCount());
|
|
d.setSupId(e.getSupId());
|
|
d.setZczbhhzbapzbh(e.getZczbhhzbapzbh());
|
|
return d;
|
|
}).collect(Collectors.toList());
|
|
purOrderDetailService.insertPurOrderDetailEntity(purOrderDetailEntityList);
|
|
// 更新计划表信息插入订单单号
|
|
PurPlanEntity purPlanEntity1 = new PurPlanEntity();
|
|
purPlanEntity1.setId(purPlanEntity.getId());
|
|
purPlanEntity1.setStockOrderNo(purOrderEntity.getBillNo());
|
|
// purPlanEntity.sets(true);
|
|
purPlanService.update(purPlanEntity1);
|
|
}
|
|
//---------------------------------判断计划为已审核就生成采购入库单-------------------------------------------//\
|
|
//查询申购单详情
|
|
List<PurPlanDetailEntity> purPlanDetailEntities = purPlanDetailService.findByOrderId(purPlanEntity.getId() + "");
|
|
//对计划单里面的供应商进行分组
|
|
Map<String, List<PurPlanDetailEntity>> map = purPlanDetailEntities.stream().collect(Collectors.groupingBy(PurPlanDetailEntity::getSupId));
|
|
String billNo = "";
|
|
if (basicBusTypeChangeEntity != null && StrUtil.isNotEmpty(basicBusTypeChangeEntity.getTargetAction()) && basicBusTypeChangeEntity.isEnable() == true) {
|
|
for (Map.Entry<String, List<PurPlanDetailEntity>> m : map.entrySet()) {
|
|
//生产单据表信息
|
|
IoOrderEntity ioOrderEntity = new IoOrderEntity();
|
|
ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER, "yyyyMMdd")));
|
|
ioOrderEntity.setCorpOrderId(CustomUtil.getDate());
|
|
ioOrderEntity.setMainAction(ConstantType.TYPE_PUT);
|
|
ioOrderEntity.setAction(basicBusTypeChangeEntity.getTargetAction());
|
|
ioOrderEntity.setFromCorp(m.getKey());
|
|
ioOrderEntity.setFromType(ConstantStatus.FROM_PLAN);
|
|
ioOrderEntity.setStatus(1);
|
|
ioOrderEntity.setDealStatus(1);
|
|
ioOrderEntity.setOrderType(1);
|
|
ioOrderEntity.setCreateTime(new Date());
|
|
ioOrderEntity.setCreateUser(purApplyEntity.getCreateUser());
|
|
ioOrderEntity.setUpdateTime(new Date());
|
|
ioOrderEntity.setUpdateUser(purApplyEntity.getCreateUser());
|
|
ioOrderEntity.setCustomerId("110");
|
|
ioOrderEntity.setDeptCode(purApplyEntity.getInvCode());
|
|
ioOrderEntity.setInvCode(purApplyEntity.getDeptCode());
|
|
ioOrderService.insertOrder(ioOrderEntity);
|
|
billNo += ioOrderEntity.getBillNo() + ",";
|
|
//插入业务单表
|
|
for (PurPlanDetailEntity obj : m.getValue()) {
|
|
BasicProductsEntity basicProductsEntity = purPlanDetailService.selectIoOrderDetailBiz(obj.getId());
|
|
IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity();
|
|
ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getBillNo());
|
|
ioOrderDetailBizEntity.setBindRlFk(Long.valueOf(obj.getProductId()));
|
|
ioOrderDetailBizEntity.setCount(obj.getCount());
|
|
ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid());
|
|
ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode());
|
|
ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc());
|
|
ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh());
|
|
ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc());
|
|
ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory());
|
|
ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname());
|
|
ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh());
|
|
if (basicProductsEntity.getPrice() != null) {
|
|
ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice()));
|
|
}
|
|
ioOrderDetailBizEntity.setSupId(obj.getSupId());
|
|
ioOrderDetailBizService.insert(ioOrderDetailBizEntity);
|
|
}
|
|
}
|
|
PurPlanEntity purPlanEntity1 = new PurPlanEntity();
|
|
purPlanEntity1.setId(purPlanEntity.getId());
|
|
purPlanEntity1.setStockOrderNo(billNo.substring(0, billNo.length() - 1));
|
|
purPlanService.update(purPlanEntity1);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public Date timeProcess(Date date, Integer timeCount) {
|
|
Calendar rightNow = Calendar.getInstance();
|
|
rightNow.setTime(date);
|
|
rightNow.add(Calendar.HOUR, timeCount);
|
|
Date dt1 = rightNow.getTime();
|
|
return dt1;
|
|
}
|
|
|
|
/**
|
|
* 新增申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@PostMapping("/purchase/apply")
|
|
public BaseResponse add(@RequestBody PurApplyEntity purApplyRequest) {
|
|
|
|
purApplyService.insert(purApplyRequest);
|
|
return ResultVOUtils.success("新增成功!");
|
|
}
|
|
|
|
/**
|
|
* 修改申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@PutMapping("/purchase/apply")
|
|
public BaseResponse edit(@RequestBody PurApplyEntity purApplyRequest) {
|
|
purApplyService.update(purApplyRequest);
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
/**
|
|
* 删除申购单
|
|
*
|
|
* @param ids 主键串
|
|
*/
|
|
@DeleteMapping("/purchase/apply/{ids}")
|
|
public BaseResponse remove(@NotEmpty(message = "主键不能为空")
|
|
@PathVariable Long[] ids) {
|
|
List<Long> idArray = Arrays.asList(ids);
|
|
if (CollUtil.isNotEmpty(idArray)) {
|
|
purApplyService.deleteByIds(idArray);
|
|
for (Long id : idArray) {
|
|
purApplyDetailService.deleteByOrderId(id + "");
|
|
}
|
|
}
|
|
|
|
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
|
|
/**
|
|
* 查询申购单列表
|
|
*/
|
|
@GetMapping("/purchase/apply/list/detail")
|
|
public BaseResponse detailList(PurApplyDetailRequest purApplyDetailRequest) {
|
|
|
|
List<PurOrderDetailResponse> purApplyDetailEntities = purApplyDetailService.joinQueryList(purApplyDetailRequest);
|
|
PageInfo<PurOrderDetailResponse> pageInfo;
|
|
pageInfo = new PageInfo<>(purApplyDetailEntities);
|
|
PageSimpleResponse<PurOrderDetailResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
pageSimpleResponse.setList(purApplyDetailEntities);
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
|
}
|
|
|
|
/**
|
|
* 查询申购单明细列表
|
|
*
|
|
* @param purApplyDetailRequest
|
|
* @return
|
|
*/
|
|
@GetMapping("/purchase/apply/getDetailList")
|
|
public BaseResponse getDetailList(PurApplyDetailRequest purApplyDetailRequest) {
|
|
List<PurOrderDetailResponse> list = purApplyDetailService.getDetailList(purApplyDetailRequest);
|
|
PageInfo<PurOrderDetailResponse> pageInfo = new PageInfo<>(list);
|
|
return ResultVOUtils.page(pageInfo);
|
|
}
|
|
|
|
/**
|
|
* 新增申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@PostMapping("/purchase/apply/detail")
|
|
public BaseResponse detailAdd(@RequestBody PurApplyDetailEntity purApplyDetailEntity) {
|
|
|
|
purApplyDetailService.insert(purApplyDetailEntity);
|
|
return ResultVOUtils.success("新增成功");
|
|
}
|
|
|
|
/**
|
|
* 修改申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@PostMapping("/purchase/apply/updateDetail")
|
|
public BaseResponse detailEdit(@RequestBody PurApplyDetailEntity purApplyDetailRequest) {
|
|
purApplyDetailService.update(purApplyDetailRequest);
|
|
return ResultVOUtils.success("修改成功");
|
|
}
|
|
|
|
/**
|
|
* 删除申购单
|
|
*
|
|
* @param ids 主键串
|
|
*/
|
|
@DeleteMapping("/purchase/apply/detail/{ids}")
|
|
public BaseResponse detailRemove(@NotEmpty(message = "主键不能为空")
|
|
@PathVariable Long[] ids) {
|
|
|
|
purApplyDetailService.deleteByIds(Arrays.asList(ids));
|
|
return ResultVOUtils.success("删除成功");
|
|
}
|
|
|
|
/*** 插入申购单详情 */
|
|
/**
|
|
* 新增申购单
|
|
*/
|
|
@RepeatSubmit()
|
|
@PostMapping("/purchase/apply/addDetail")
|
|
public BaseResponse addDetail(@RequestBody List<PurApplyDetailEntity> list) {
|
|
|
|
if(list.size()!=0) {
|
|
for (PurApplyDetailEntity purApplyDetailEntity : list) {
|
|
purApplyDetailService.insert(purApplyDetailEntity);
|
|
}
|
|
return ResultVOUtils.success(list.get(0).getOrderIdFk());
|
|
}
|
|
return ResultVOUtils.error(555,"请选择数据!");
|
|
}
|
|
|
|
/**
|
|
* 新增申购单
|
|
*/
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/purchase/apply/add")
|
|
public BaseResponse add() {
|
|
|
|
Long userId = customerService.getUserId();
|
|
PurApplyEntity purApplyEntity = new PurApplyEntity();
|
|
purApplyEntity.setCreateUser(userId + "");
|
|
purApplyEntity.setCreateTime(new Date());
|
|
purApplyEntity.setUpdateTime(new Date());
|
|
purApplyEntity.setUpdateUser(userId + "");
|
|
purApplyService.insert(purApplyEntity);
|
|
Long id = purApplyEntity.getId();
|
|
return ResultVOUtils.success(id);
|
|
}
|
|
|
|
|
|
/**
|
|
* 删除申购单和详情
|
|
*/
|
|
@AuthRuleAnnotation("")
|
|
@PostMapping("/purchase/apply/delApplyDetailAll")
|
|
public BaseResponse delApplyDetailAll(@RequestBody PurApplyEntity purApplyEntity) {
|
|
|
|
if (purApplyEntity.getId() != null) {
|
|
purApplyService.deleteById(purApplyEntity.getId());
|
|
purApplyDetailService.deleteByOrderId(purApplyEntity.getId() + "");
|
|
} else {
|
|
return ResultVOUtils.error(999, "参数有误!");
|
|
}
|
|
return ResultVOUtils.success();
|
|
}
|
|
|
|
|
|
}
|