| | |
| | | package zy.cloud.wms.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import zy.cloud.wms.common.model.BillDto; |
| | | import zy.cloud.wms.common.service.erp.ErpR; |
| | | import zy.cloud.wms.common.service.erp.ErpService; |
| | | import zy.cloud.wms.common.web.BaseController; |
| | | import zy.cloud.wms.manager.entity.CustOrder; |
| | | import zy.cloud.wms.manager.entity.Pakout; |
| | | import zy.cloud.wms.manager.entity.WrkSts; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.entity.param.*; |
| | | import zy.cloud.wms.manager.service.CustOrderService; |
| | | import zy.cloud.wms.manager.service.PakoutService; |
| | | import zy.cloud.wms.manager.service.WorkService; |
| | | import zy.cloud.wms.manager.service.WrkStsService; |
| | | import zy.cloud.wms.manager.entity.result.KeyValueVo; |
| | | import zy.cloud.wms.manager.service.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/2/25 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/work") |
| | | public class WorkController extends BaseController { |
| | |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private CustOrderService custOrderService; |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private ErpService erpService; |
| | | |
| | | |
| | | @RequestMapping("/stock/pakin") |
| | | @ManagerAuth(memo = "入库") |
| | | public R stockPakin(@RequestBody PakinParam number) { |
| | | return workService.stockPakin(number, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/pakout") |
| | | @ManagerAuth(memo = "出库") |
| | | public R stockPakout(@RequestBody PakoutParam number) { |
| | | return workService.stockPakout(number, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/in") |
| | | @ManagerAuth(memo = "上架") |
| | |
| | | return workService.stockOutPreview(stockOutParam, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/out") |
| | | @ManagerAuth(memo = "拣货") |
| | | @RequestMapping("/stock/out/create") |
| | | @ManagerAuth(memo = "生成拣货单") |
| | | public R stockOut(@RequestBody StockOutParam stockOutParam) { |
| | | return workService.stockOut(stockOutParam, getUserId()); |
| | | return workService.stockOutCreate(stockOutParam, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/out/print") |
| | |
| | | @RequestMapping("/pakout/get") |
| | | @ManagerAuth(memo = "获取出库单") |
| | | public R getPakout(@RequestParam String docNumber) { |
| | | List<Pakout> pakouts = pakoutService.selectList(new EntityWrapper<Pakout>().eq("doc_num", docNumber).in("wrk_sts", 1,2)); |
| | | List<Pakout> pakouts = pakoutService.selectList(new EntityWrapper<Pakout>().eq("doc_num", docNumber).in("wrk_sts", 1, 2)); |
| | | if (Cools.isEmpty(pakouts)) { |
| | | return R.parse(BaseRes.EMPTY); |
| | | } |
| | | Long sts = pakouts.get(0).getWrkSts(); |
| | | if (sts == 1) { |
| | | sts =2L; |
| | | sts = 2L; |
| | | } |
| | | WrkSts wrkSts = wrkStsService.selectById(sts); |
| | | return R.ok().add(Cools |
| | | .add("number", pakouts.get(0).getDocNum()) |
| | | .add("wrkSts", pakouts.get(0).getWrkSts()) |
| | | .add("wrkSts$", wrkSts==null?"未知":wrkSts.getStsName()) |
| | | .add("custName", Cools.isEmpty(pakouts.get(0).getCustName())?"-":pakouts.get(0).getCustName()) |
| | | .add("wrkSts$", wrkSts == null ? "未知" : wrkSts.getStsName()) |
| | | .add("custName", Cools.isEmpty(pakouts.get(0).getCustName()) ? "-" : pakouts.get(0).getCustName()) |
| | | .add("pakouts", pakouts) |
| | | ); |
| | | } |
| | |
| | | |
| | | @RequestMapping("/hand/control/pakout") |
| | | @ManagerAuth(memo = "手动处理拣货单") |
| | | public R handControlWrkMast(@RequestParam String wrkNo, @RequestParam Integer type){ |
| | | public R handControlWrkMast(@RequestParam String wrkNo, @RequestParam Integer type) { |
| | | if (type == 1) { |
| | | return workService.completePakout(wrkNo, getUserId()); |
| | | } else if (type == 2) { |
| | |
| | | } |
| | | |
| | | @RequestMapping("/orderNo/init") |
| | | @ManagerAuth(memo = "生成销售订单编号") |
| | | @ManagerAuth(memo = "生成单据编号") |
| | | public R initOrderNo() { |
| | | long nextId = snowflakeIdWorker.nextId(); |
| | | if (custOrderService.selectCount(new EntityWrapper<CustOrder>().eq("number", String.valueOf(nextId))) > 0) { |
| | | return R.error("抱歉单号已存在,请再生成一次"); |
| | | String orderNo = "AT-" + String.valueOf(nextId).substring(0, 15); |
| | | if (orderService.selectByOrderNo(orderNo) != null) { |
| | | return R.error("抱歉,单据编号已存在"); |
| | | } |
| | | return R.ok().add(String.valueOf(nextId)); |
| | | return R.ok().add(orderNo); |
| | | } |
| | | |
| | | @RequestMapping("/order/init") |
| | | @ManagerAuth(memo = "生成销售订单") |
| | | @ManagerAuth(memo = "生成订单") |
| | | public R initOrder(@RequestBody InitOrderParam param) { |
| | | return workService.initOrder(param, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/transfer") |
| | | @ManagerAuth(memo = "库存调拨") |
| | | public R stockTransfer(@RequestParam String number) { |
| | | return workService.stockTransfer(number, getUserId()); |
| | | public R stockTransfer(@RequestBody AsrsTransferParam number) { |
| | | return workService.asrsStockTransfer(number, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/transfer/locMode") |
| | | @ManagerAuth(memo = "库存调拨-立库模式") |
| | | public R stockTransferLocMode(@RequestBody AsrsTransferParam number) { |
| | | return workService.asrsStockTransferLocMode(number, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/check") |
| | | @ManagerAuth(memo = "库存盘点") |
| | | public R stockCheck(@RequestBody StoCheckParam param) { |
| | | return workService.stockCheck(param, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/check/auditing") |
| | | @ManagerAuth(memo = "盘点记录审核") |
| | | public R checkAuditing(@RequestParam Long checkId) { |
| | | return workService.stockCheckAuditing(checkId, getUserId()); |
| | | } |
| | | |
| | | @RequestMapping("/stock/checks/auditing") |
| | | @ManagerAuth(memo = "盘点记录批量审核") |
| | | public R checksAuditing(@RequestParam(value = "checkIds[]") Long[] checkIds) { |
| | | int success = 0; |
| | | for (Long checkId : checkIds) { |
| | | R r = workService.stockCheckAuditing(checkId, getUserId()); |
| | | if (String.valueOf(r.get("code")).equals("200")) { |
| | | success++; |
| | | } |
| | | } |
| | | return R.ok("审核成功数量:" + success); |
| | | } |
| | | |
| | | // 盘点上传 |
| | | @RequestMapping("/check/upload") |
| | | @ManagerAuth(memo = "盘点上传") |
| | | public R checkUpload(@RequestBody CheckUploadParam params) { |
| | | List<BillDto> dtos = new ArrayList<>(); |
| | | if (params.getMats().size() > 0) { |
| | | for (Mat matList : params.getMats()) { |
| | | BillDto dto = new BillDto(); |
| | | dto.setMatnr(matList.getMatnr()); |
| | | dto.setQty(matList.getCount().doubleValue()); |
| | | dtos.add(dto); |
| | | } |
| | | } else { |
| | | throw new CoolException("数据异常"); |
| | | } |
| | | int docId; |
| | | String docNum; |
| | | if (params.getType().equals("1")) { // 盘盈 |
| | | docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 14; // 报溢单 |
| | | } else if (params.getType().equals("2")) { // 盘亏 |
| | | docNum = "CD-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 9; // 报损单 |
| | | } else { |
| | | throw new CoolException("数据异常"); |
| | | } |
| | | // erp上传盘盈盘亏 |
| | | ErpR erpR = erpService.uploadBill(dtos, docId, docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | String dotsStr = JSON.toJSONString(dtos); |
| | | log.info("盘点上传,类型:" + (docId == 14 ? "盘盈" : "盘亏") + ",单号:" + docNum + ",上传物料清单:" + dotsStr); |
| | | log.info("==============================================================================================="); |
| | | return R.ok().add("上报至erp成功"); |
| | | } |
| | | |
| | | /******************************************************************************************************/ |
| | | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private CstmrService cstmrService; |
| | | @Autowired |
| | | private ItemService itemService; |
| | | |
| | | // 获取所有单据类型 |
| | | @RequestMapping("/docType/all/get") |
| | | @ManagerAuth |
| | | public R getDocTypeData() { |
| | | List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("status", 1).orderBy("create_time", false)); |
| | | return R.ok().add(docTypes); |
| | | } |
| | | |
| | | // 获取所有客户 |
| | | @RequestMapping("/cstmr/all/get") |
| | | @ManagerAuth |
| | | public R getCstmrData() { |
| | | List<Cstmr> cstmrs = cstmrService.selectList(new EntityWrapper<Cstmr>().eq("status", 1).orderBy("create_time", false)); |
| | | return R.ok().add(cstmrs); |
| | | } |
| | | |
| | | // 获取所有客户 [键值对版] |
| | | @RequestMapping("/cstmr/all/get/kv") |
| | | @ManagerAuth |
| | | public R getCstmrDataKV() { |
| | | List<Cstmr> cstmrs = cstmrService.selectList(new EntityWrapper<Cstmr>().eq("status", 1).orderBy("create_time", false)); |
| | | List<KeyValueVo> valueVos = new ArrayList<>(); |
| | | for (Cstmr cstmr : cstmrs) { |
| | | KeyValueVo vo = new KeyValueVo(); |
| | | vo.setName(cstmr.getName()); |
| | | vo.setValue(cstmr.getId()); |
| | | valueVos.add(vo); |
| | | } |
| | | return R.ok().add(valueVos); |
| | | } |
| | | |
| | | // 获取所有项目 |
| | | @RequestMapping("/item/all/get") |
| | | @ManagerAuth |
| | | public R getItemData() { |
| | | List<Item> items = itemService.selectList(new EntityWrapper<Item>().eq("status", 1).orderBy("create_time", false)); |
| | | return R.ok().add(items); |
| | | } |
| | | |
| | | // 获取所有项目 |
| | | @RequestMapping("/item/all/get/kv") |
| | | @ManagerAuth |
| | | public R getItemDataKV() { |
| | | List<Item> items = itemService.selectList(new EntityWrapper<Item>().eq("status", 1).orderBy("create_time", false)); |
| | | List<KeyValueVo> valueVos = new ArrayList<>(); |
| | | for (Item item : items) { |
| | | KeyValueVo vo = new KeyValueVo(); |
| | | vo.setName(item.getName()); |
| | | vo.setValue(item.getId()); |
| | | valueVos.add(vo); |
| | | } |
| | | return R.ok().add(valueVos); |
| | | } |
| | | |
| | | } |