package com.gk.firework.Controller;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gk.firework.Controller.Base.BaseController;
|
import com.gk.firework.Domain.EntryOrderInfo;
|
import com.gk.firework.Domain.Enum.ErrorCode;
|
import com.gk.firework.Domain.Log.JsonParams;
|
import com.gk.firework.Domain.SoldNoStockInfo;
|
import com.gk.firework.Domain.StockInfo;
|
import com.gk.firework.Domain.UserInfo;
|
import com.gk.firework.Domain.Utils.FilterObject;
|
import com.gk.firework.Domain.Utils.Msg;
|
import com.gk.firework.Domain.Utils.StringUtils;
|
import com.gk.firework.Domain.Vo.DirectionDetail;
|
import com.gk.firework.Domain.Vo.FireworkDeal;
|
import com.gk.firework.Domain.Vo.ProductVo;
|
import com.gk.firework.Service.EntryDetailService;
|
import com.gk.firework.Service.EntryService;
|
import com.gk.firework.Service.ProductService;
|
import com.gk.firework.Service.StockService;
|
import com.gk.firework.Service.*;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @author : jingjy
|
* @date : 2021/4/9 16:17
|
*/
|
@Api(tags = "入库接口")
|
@RestController
|
@RequestMapping("/entry")
|
public class EntryController extends BaseController {
|
@Autowired
|
private ProductService productService;
|
@Autowired
|
private EntryService entryService;
|
@Autowired
|
private EntryDetailService entryDetailService;
|
@Autowired
|
private StockService stockService;
|
@Autowired
|
private SoldNoStockService soldNoStockService;
|
@Autowired
|
private UserService userService;
|
|
@GetMapping(value = "/getEntryDetail/directionCode/{directionCode}")
|
public Msg getEntryDetail(@PathVariable String directionCode){
|
Msg msg = new Msg(true);
|
if (FireworkDeal.isNotDirectionCode(directionCode)){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
msg.setMessage("流向码不符合规则,请重新输入!");
|
return msg;
|
}
|
|
List<ProductVo>productVoList = new ArrayList<>();
|
if (FireworkDeal.is22Characters(directionCode)){
|
DirectionDetail detail = FireworkDeal.dealDirectionCode(directionCode);
|
ProductVo productVo = productService.selectVoByDirection(directionCode);
|
if (productVo == null){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
msg.setMessage("产品不存在,请重新输入!");
|
return msg;
|
}
|
FireworkDeal.getProductVos(directionCode,detail,detail,productVoList,productVo);
|
}else {
|
ProductVo productVo = productService.selectVoByDirection(directionCode);
|
if (productVo == null){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
msg.setMessage("产品不存在,请重新输入!");
|
return msg;
|
}
|
productVoList.add(productVo);
|
}
|
|
|
if (productVoList.size() == 0){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
msg.setMessage("流向码:"+directionCode+"未找到相应入库信息!");
|
return msg;
|
}
|
|
StringBuilder content = new StringBuilder();
|
|
List<ProductVo>productVos = new ArrayList<>();
|
for (ProductVo productVo1 : productVoList){
|
StockInfo stockInfo = stockService.selectStockByDireAndUser(getUser().getCompanyid(),productVo1.getDirectionCode());
|
if (stockInfo == null || stockInfo.getStatus().equals(StockInfo.STOCK_SOLD)){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
content.append(productVo1.getDirectionCode()).append(" 未入库或者已经销售了!");
|
}else {
|
productVos.add(productVo1);
|
}
|
}
|
|
msg.setMessage(content.toString());
|
msg.setResult(productVos);
|
|
return msg;
|
}
|
|
@PostMapping("entryPatch")
|
@JsonParams
|
public Msg entryPatch(@RequestBody JSONArray jsonArray){
|
Msg msg = new Msg(true);
|
if (jsonArray.size() == 0){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
msg.setMessage(ErrorCode.ERROR_999.getMsg());
|
return msg;
|
}
|
UserInfo userInfo = userService.getById(getUser().getId());
|
String auth = getAuth();
|
auth = StringUtils.isBlank(auth) ? "NOAUTH" : auth;
|
List<SoldNoStockInfo>soldNoStockInfos = new ArrayList<>();
|
for (int i = 0; i < jsonArray.size(); i++){
|
JSONObject object = jsonArray.getJSONObject(i);
|
String directionCode = object.getString("directioncode");
|
SoldNoStockInfo soldNoStockInfo = soldNoStockService.selectSoldNoStockByDire(directionCode);
|
if (soldNoStockInfo == null){
|
msg.setCode(ErrorCode.ERROR_999.getCode());
|
msg.setMessage(ErrorCode.ERROR_999.getMsg());
|
return msg;
|
}
|
soldNoStockInfos.add(soldNoStockInfo);
|
}
|
entryService.entryPatch(soldNoStockInfos,userInfo,auth);
|
|
return msg;
|
}
|
|
|
|
/**
|
* @Description: 入库查询
|
* @date 2021/4/14 16:35
|
*/
|
@PostMapping("/inbound-query")
|
@ApiOperation(value = "入库查询", httpMethod = "POST")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageIndex", value = "当前页码", required = true),
|
@ApiImplicitParam(name = "pageSize", value = "页大小", required = true),
|
@ApiImplicitParam(name = "filter.province", value = "省"),
|
@ApiImplicitParam(name = "filter.city", value = "市"),
|
@ApiImplicitParam(name = "filter.district", value = "区"),
|
@ApiImplicitParam(name = "filter.street", value = "街道"),
|
@ApiImplicitParam(name = "filter.committee", value = "委员会"),
|
@ApiImplicitParam(name = "filter.starttime", value = "开始时间"),
|
@ApiImplicitParam(name = "filter.endtime", value = "结束时间"),
|
@ApiImplicitParam(name = "filter.transportcert", value = "运输证号码"),
|
@ApiImplicitParam(name = "filter.enterprisename", value = "入库企业名称"),
|
@ApiImplicitParam(name = "filter.safetysupervision", value = "安全监管分类"),
|
@ApiImplicitParam(name = "filter.type", value = "入库类型"),
|
@ApiImplicitParam(name = "filter.code", value = "单号"),
|
})
|
Object getInboundInfo(@RequestBody FilterObject jsonFilter) {
|
Integer pageIndex = jsonFilter.getPageIndex();
|
Integer pageSize = jsonFilter.getPageSize();
|
IPage page = entryService.selectPage(new Page<>(pageIndex, pageSize), jsonFilter.getFilter(), getUser());
|
return success(page);
|
}
|
|
@PostMapping("/stock/inbound-query")
|
@ApiOperation(value = "入库查询", httpMethod = "POST")
|
Object getStockInboundInfo(@RequestBody FilterObject jsonFilter) {
|
Integer pageIndex = jsonFilter.getPageIndex();
|
Integer pageSize = jsonFilter.getPageSize();
|
IPage page = entryService.selectStockPage(new Page<>(pageIndex, pageSize), jsonFilter.getFilter(), getUser());
|
return success(page);
|
}
|
|
/**
|
* @Description: 入库导出
|
* @date 2021/4/19 17:11
|
*/
|
|
@PostMapping("/export/inbound")
|
@ApiOperation(value = "入库查询导出", httpMethod = "POST")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "filter.province", value = "省"),
|
@ApiImplicitParam(name = "filter.city", value = "市"),
|
@ApiImplicitParam(name = "filter.district", value = "区"),
|
@ApiImplicitParam(name = "filter.street", value = "街道"),
|
@ApiImplicitParam(name = "filter.committee", value = "委员会"),
|
@ApiImplicitParam(name = "filter.starttime", value = "开始时间"),
|
@ApiImplicitParam(name = "filter.endtime", value = "结束时间"),
|
@ApiImplicitParam(name = "filter.transportcert", value = "运输证号码"),
|
@ApiImplicitParam(name = "filter.enterprisename", value = "入库企业名称"),
|
})
|
Object exportInbound(@RequestBody FilterObject jsonFilter) {
|
List<EntryOrderInfo> list = entryService.selectExportInBound(jsonFilter.getFilter(), getUser());
|
return success(list);
|
}
|
|
/**
|
* @Description: 根据{入库单code}查询入库明细
|
* @date 2021/4/15 11:09
|
*/
|
@PostMapping("/inbound-detail")
|
@ApiOperation(value = "入库单明细", httpMethod = "POST")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "pageIndex", value = "当前页码", required = true),
|
@ApiImplicitParam(name = "pageSize", value = "页大小", required = true),
|
@ApiImplicitParam(name = "filter.code", value = "入库单号code"),
|
})
|
Object getInboundDetail(@RequestBody FilterObject jsonFilter) {
|
Integer pageIndex = jsonFilter.getPageIndex();
|
Integer pageSize = jsonFilter.getPageSize();
|
IPage page = entryService.selectDetailPage(new Page<>(pageIndex,pageSize),jsonFilter.getFilter());
|
return success(page);
|
}
|
|
|
/**
|
* @Description: 根据{入库单code}查询入库明细并导出
|
* @date 2021/4/15 11:09
|
*/
|
@GetMapping("/export/inbound-detail")
|
@ApiOperation(value = "入库单明细导出", httpMethod = "POST")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "code", value = "入库单号code"),
|
})
|
Object getInboundDetail(@RequestParam String code) {
|
List<Map> detailExport = entryDetailService.selectDetailExport(code);
|
return success(detailExport);
|
}
|
|
}
|