no message
parent
eb01078c9b
commit
ba540b3f4c
|
|
@ -1,6 +1,21 @@
|
||||||
package org.cpte.modules.constant;
|
package org.cpte.modules.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用常量
|
||||||
|
*/
|
||||||
public interface CommonConstant {
|
public interface CommonConstant {
|
||||||
//入库输送线任务均衡索引
|
/**
|
||||||
|
* 入库输送线任务均衡索引
|
||||||
|
*/
|
||||||
String RK_DOCK_TASK_INDEX = "rk_dock_task_index";
|
String RK_DOCK_TASK_INDEX = "rk_dock_task_index";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库单规则编码
|
||||||
|
*/
|
||||||
|
String ASN_ORDER_NO = "asn_order_no";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库单规则编码
|
||||||
|
*/
|
||||||
|
String PICK_ORDER_NO = "pick_order_no";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.cpte.modules.constant.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库单状态
|
||||||
|
*
|
||||||
|
* @author: cpte
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum PickStatusEnum {
|
||||||
|
|
||||||
|
CREATED(1, "已创建"),
|
||||||
|
|
||||||
|
PARTIAL(2, "部分分配"),
|
||||||
|
|
||||||
|
ASSIGNED(3, "已分配"),
|
||||||
|
|
||||||
|
PICKING(4, "拣货中"),
|
||||||
|
|
||||||
|
PICKED(5, "拣货完成"),
|
||||||
|
|
||||||
|
CLOSED(6, "已关闭"),
|
||||||
|
|
||||||
|
CANCELED(7, "已取消"),
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
PickStatusEnum(Integer value, String desc) {
|
||||||
|
this.value = value;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
|
final Integer value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
final String desc;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
package org.cpte.modules.receive.controller;
|
package org.cpte.modules.receive.controller;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLDecoder;
|
|
||||||
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.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.cpte.modules.utils.CodeGeneratorUtil;
|
import org.cpte.modules.constant.CommonConstant;
|
||||||
|
import org.cpte.modules.serialNumber.AsnSerialNumberRule;
|
||||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
|
@ -23,7 +19,6 @@ import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
import org.cpte.modules.receive.entity.AsnDetail;
|
import org.cpte.modules.receive.entity.AsnDetail;
|
||||||
import org.cpte.modules.receive.entity.Asn;
|
import org.cpte.modules.receive.entity.Asn;
|
||||||
|
|
@ -40,235 +35,234 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 入库单
|
* @Description: 入库单
|
||||||
* @author: cpte
|
* @author: cpte
|
||||||
* @Date: 2025-11-03
|
* @Date: 2025-11-03
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Tag(name="入库单")
|
@Tag(name = "入库单")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/receive/asn")
|
@RequestMapping("/receive/asn")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AsnController {
|
public class AsnController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAsnService asnService;
|
private IAsnService asnService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAsnDetailService asnDetailService;
|
private IAsnDetailService asnDetailService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CodeGeneratorUtil codeGeneratorUtil;
|
private AsnSerialNumberRule asnSerialNumberRule;
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页列表查询
|
|
||||||
*
|
|
||||||
* @param asn
|
|
||||||
* @param pageNo
|
|
||||||
* @param pageSize
|
|
||||||
* @param req
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
//@AutoLog(value = "入库单-分页列表查询")
|
|
||||||
@Operation(summary="入库单-分页列表查询")
|
|
||||||
@GetMapping(value = "/list")
|
|
||||||
public Result<IPage<Asn>> queryPageList(Asn asn,
|
|
||||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
||||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
||||||
HttpServletRequest req) {
|
|
||||||
QueryWrapper<Asn> queryWrapper = QueryGenerator.initQueryWrapper(asn, req.getParameterMap());
|
|
||||||
Page<Asn> page = new Page<Asn>(pageNo, pageSize);
|
|
||||||
IPage<Asn> pageList = asnService.page(page, queryWrapper);
|
|
||||||
return Result.OK(pageList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加
|
|
||||||
*
|
|
||||||
* @param asnPage
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@AutoLog(value = "入库单-添加")
|
|
||||||
@Operation(summary="入库单-添加")
|
|
||||||
@RequiresPermissions("receive:data_asn:add")
|
|
||||||
@PostMapping(value = "/add")
|
|
||||||
public Result<String> add(@RequestBody AsnPage asnPage) {
|
|
||||||
Asn asn = new Asn();
|
|
||||||
asn.setOrderNo(codeGeneratorUtil.generateSerialNumber("RK"));
|
|
||||||
BeanUtils.copyProperties(asnPage, asn);
|
|
||||||
asnService.saveMain(asn, asnPage.getAsnDetailList());
|
|
||||||
return Result.OK("添加成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑
|
|
||||||
*
|
|
||||||
* @param asnPage
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@AutoLog(value = "入库单-编辑")
|
|
||||||
@Operation(summary="入库单-编辑")
|
|
||||||
@RequiresPermissions("receive:data_asn:edit")
|
|
||||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
||||||
public Result<String> edit(@RequestBody AsnPage asnPage) {
|
|
||||||
Asn existingAsn = asnService.getById(asnPage.getId());
|
|
||||||
if(existingAsn==null) {
|
|
||||||
return Result.error("未找到对应数据");
|
|
||||||
}
|
|
||||||
// 将更新数据从 asnPage 复制到 existingAsn
|
|
||||||
BeanUtils.copyProperties(asnPage, existingAsn);
|
|
||||||
asnService.updateMain(existingAsn, asnPage.getAsnDetailList());
|
|
||||||
return Result.OK("编辑成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过id删除
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@AutoLog(value = "入库单-通过id删除")
|
|
||||||
@Operation(summary="入库单-通过id删除")
|
|
||||||
@RequiresPermissions("receive:data_asn:delete")
|
|
||||||
@DeleteMapping(value = "/delete")
|
|
||||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
||||||
asnService.delMain(id);
|
|
||||||
return Result.OK("删除成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@AutoLog(value = "入库单-批量删除")
|
|
||||||
@Operation(summary="入库单-批量删除")
|
|
||||||
@RequiresPermissions("receive:data_asn:deleteBatch")
|
|
||||||
@DeleteMapping(value = "/deleteBatch")
|
|
||||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
||||||
this.asnService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
||||||
return Result.OK("批量删除成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过id查询
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
//@AutoLog(value = "入库单-通过id查询")
|
|
||||||
@Operation(summary="入库单-通过id查询")
|
|
||||||
@GetMapping(value = "/queryById")
|
|
||||||
public Result<Asn> queryById(@RequestParam(name="id",required=true) String id) {
|
|
||||||
Asn asn = asnService.getById(id);
|
|
||||||
if(asn==null) {
|
|
||||||
return Result.error("未找到对应数据");
|
|
||||||
}
|
|
||||||
return Result.OK(asn);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过id查询
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
//@AutoLog(value = "入库明细通过主表ID查询")
|
|
||||||
@Operation(summary="入库明细主表ID查询")
|
|
||||||
@GetMapping(value = "/queryAsnDetailByMainId")
|
|
||||||
public Result<List<AsnDetail>> queryAsnDetailListByMainId(@RequestParam(name="id",required=true) Long id) {
|
|
||||||
List<AsnDetail> asnDetailList = asnDetailService.selectByMainId(id);
|
|
||||||
return Result.OK(asnDetailList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出excel
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
* @param request
|
* @param asn
|
||||||
* @param asn
|
* @param pageNo
|
||||||
*/
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Operation(summary = "入库单-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<Asn>> queryPageList(Asn asn,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<Asn> queryWrapper = QueryGenerator.initQueryWrapper(asn, req.getParameterMap());
|
||||||
|
Page<Asn> page = new Page<Asn>(pageNo, pageSize);
|
||||||
|
IPage<Asn> pageList = asnService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param asnPage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "入库单-添加")
|
||||||
|
@Operation(summary = "入库单-添加")
|
||||||
|
@RequiresPermissions("receive:data_asn:add")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody AsnPage asnPage) {
|
||||||
|
Asn asn = new Asn();
|
||||||
|
String orderNo = asnSerialNumberRule.generateSerialNumber(CommonConstant.ASN_ORDER_NO);
|
||||||
|
asn.setOrderNo(orderNo);
|
||||||
|
BeanUtils.copyProperties(asnPage, asn);
|
||||||
|
asnService.saveMain(asn, asnPage.getAsnDetailList());
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param asnPage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "入库单-编辑")
|
||||||
|
@Operation(summary = "入库单-编辑")
|
||||||
|
@RequiresPermissions("receive:data_asn:edit")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody AsnPage asnPage) {
|
||||||
|
Asn existingAsn = asnService.getById(asnPage.getId());
|
||||||
|
if (existingAsn == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
// 将更新数据从 asnPage 复制到 existingAsn
|
||||||
|
BeanUtils.copyProperties(asnPage, existingAsn);
|
||||||
|
asnService.updateMain(existingAsn, asnPage.getAsnDetailList());
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "入库单-通过id删除")
|
||||||
|
@Operation(summary = "入库单-通过id删除")
|
||||||
|
@RequiresPermissions("receive:data_asn:delete")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name = "id", required = true) Long id) {
|
||||||
|
asnService.delMain(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "入库单-批量删除")
|
||||||
|
@Operation(summary = "入库单-批量删除")
|
||||||
|
@RequiresPermissions("receive:data_asn:deleteBatch")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||||
|
this.asnService.delBatchMain(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "入库单-通过id查询")
|
||||||
|
@Operation(summary = "入库单-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<Asn> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
Asn asn = asnService.getById(id);
|
||||||
|
if (asn == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(asn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "入库明细通过主表ID查询")
|
||||||
|
@Operation(summary = "入库明细主表ID查询")
|
||||||
|
@GetMapping(value = "/queryAsnDetailByMainId")
|
||||||
|
public Result<List<AsnDetail>> queryAsnDetailListByMainId(@RequestParam(name = "id", required = true) Long id) {
|
||||||
|
List<AsnDetail> asnDetailList = asnDetailService.selectByMainId(id);
|
||||||
|
return Result.OK(asnDetailList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param asn
|
||||||
|
*/
|
||||||
@RequiresPermissions("receive:data_asn:exportXls")
|
@RequiresPermissions("receive:data_asn:exportXls")
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, Asn asn) {
|
public ModelAndView exportXls(HttpServletRequest request, Asn asn) {
|
||||||
|
|
||||||
// Step.1 组装查询条件查询数据
|
// Step.1 组装查询条件查询数据
|
||||||
QueryWrapper<Asn> queryWrapper = QueryGenerator.initQueryWrapper(asn, request.getParameterMap());
|
QueryWrapper<Asn> queryWrapper = QueryGenerator.initQueryWrapper(asn, request.getParameterMap());
|
||||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
|
||||||
//配置选中数据查询条件
|
//配置选中数据查询条件
|
||||||
String selections = request.getParameter("selections");
|
String selections = request.getParameter("selections");
|
||||||
if(oConvertUtils.isNotEmpty(selections)) {
|
if (oConvertUtils.isNotEmpty(selections)) {
|
||||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||||
queryWrapper.in("id",selectionList);
|
queryWrapper.in("id", selectionList);
|
||||||
}
|
}
|
||||||
//Step.2 获取导出数据
|
//Step.2 获取导出数据
|
||||||
List<Asn> asnList = asnService.list(queryWrapper);
|
List<Asn> asnList = asnService.list(queryWrapper);
|
||||||
|
|
||||||
// Step.3 组装pageList
|
// Step.3 组装pageList
|
||||||
List<AsnPage> pageList = new ArrayList<AsnPage>();
|
List<AsnPage> pageList = new ArrayList<AsnPage>();
|
||||||
for (Asn main : asnList) {
|
for (Asn main : asnList) {
|
||||||
AsnPage vo = new AsnPage();
|
AsnPage vo = new AsnPage();
|
||||||
BeanUtils.copyProperties(main, vo);
|
BeanUtils.copyProperties(main, vo);
|
||||||
List<AsnDetail> asnDetailList = asnDetailService.selectByMainId(main.getId());
|
List<AsnDetail> asnDetailList = asnDetailService.selectByMainId(main.getId());
|
||||||
vo.setAsnDetailList(asnDetailList);
|
vo.setAsnDetailList(asnDetailList);
|
||||||
pageList.add(vo);
|
pageList.add(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step.4 AutoPoi 导出Excel
|
// Step.4 AutoPoi 导出Excel
|
||||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||||
mv.addObject(NormalExcelConstants.FILE_NAME, "入库单列表");
|
mv.addObject(NormalExcelConstants.FILE_NAME, "入库单列表");
|
||||||
mv.addObject(NormalExcelConstants.CLASS, AsnPage.class);
|
mv.addObject(NormalExcelConstants.CLASS, AsnPage.class);
|
||||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("入库单数据", "导出人:"+sysUser.getRealname(), "入库单"));
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("入库单数据", "导出人:" + sysUser.getRealname(), "入库单"));
|
||||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过excel导入数据
|
* 通过excel导入数据
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param response
|
* @param response
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("receive:data_asn:importExcel")
|
@RequiresPermissions("receive:data_asn:importExcel")
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||||
// 获取上传文件对象
|
// 获取上传文件对象
|
||||||
MultipartFile file = entity.getValue();
|
MultipartFile file = entity.getValue();
|
||||||
ImportParams params = new ImportParams();
|
ImportParams params = new ImportParams();
|
||||||
params.setTitleRows(2);
|
params.setTitleRows(2);
|
||||||
params.setHeadRows(1);
|
params.setHeadRows(1);
|
||||||
params.setNeedSave(true);
|
params.setNeedSave(true);
|
||||||
try {
|
try {
|
||||||
List<AsnPage> list = ExcelImportUtil.importExcel(file.getInputStream(), AsnPage.class, params);
|
List<AsnPage> list = ExcelImportUtil.importExcel(file.getInputStream(), AsnPage.class, params);
|
||||||
for (AsnPage page : list) {
|
for (AsnPage page : list) {
|
||||||
Asn po = new Asn();
|
Asn po = new Asn();
|
||||||
BeanUtils.copyProperties(page, po);
|
BeanUtils.copyProperties(page, po);
|
||||||
asnService.saveMain(po, page.getAsnDetailList());
|
asnService.saveMain(po, page.getAsnDetailList());
|
||||||
}
|
}
|
||||||
return Result.OK("文件导入成功!数据行数:" + list.size());
|
return Result.OK("文件导入成功!数据行数:" + list.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(), e);
|
||||||
return Result.error("文件导入失败:"+e.getMessage());
|
return Result.error("文件导入失败:" + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
file.getInputStream().close();
|
file.getInputStream().close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Result.OK("文件导入失败!");
|
return Result.OK("文件导入失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public interface AsnDetailMapper extends BaseMapper<AsnDetail> {
|
||||||
* @param mainId 主表id
|
* @param mainId 主表id
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean deleteByMainId(@Param("mainId") String mainId);
|
public boolean deleteByMainId(@Param("mainId") Long mainId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过主表id查询子表数据
|
* 通过主表id查询子表数据
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,17 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="org.cpte.modules.receive.mapper.AsnDetailMapper">
|
<mapper namespace="org.cpte.modules.receive.mapper.AsnDetailMapper">
|
||||||
|
|
||||||
<delete id="deleteByMainId" parameterType="java.lang.String">
|
<delete id="deleteByMainId">
|
||||||
DELETE
|
DELETE
|
||||||
FROM data_asn_detail
|
FROM data_asn_detail
|
||||||
WHERE
|
WHERE
|
||||||
asn_id = #{mainId} </delete>
|
asn_id = #{mainId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.cpte.modules.receive.entity.AsnDetail">
|
<select id="selectByMainId" resultType="org.cpte.modules.receive.entity.AsnDetail">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM data_asn_detail
|
FROM data_asn_detail
|
||||||
WHERE
|
WHERE
|
||||||
asn_id = #{mainId} </select>
|
asn_id = #{mainId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public interface IAsnService extends IService<Asn> {
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public void delMain(String id);
|
public void delMain(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除一对多
|
* 批量删除一对多
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ public class AsnServiceImpl extends ServiceImpl<AsnMapper, Asn> implements IAsnS
|
||||||
@Autowired
|
@Autowired
|
||||||
private ReceiveRecordMapper receiveRecordMapper;
|
private ReceiveRecordMapper receiveRecordMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryMapper inventoryMapper;
|
|
||||||
@Autowired
|
|
||||||
private IInventoryService iInventoryService;
|
private IInventoryService iInventoryService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IInventoryLogService iInventoryLogService;
|
private IInventoryLogService iInventoryLogService;
|
||||||
|
|
@ -78,7 +76,7 @@ public class AsnServiceImpl extends ServiceImpl<AsnMapper, Asn> implements IAsnS
|
||||||
refreshAsn(asn, asnDetailList);
|
refreshAsn(asn, asnDetailList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshAsn(Asn asn, List<AsnDetail> asnDetails) {
|
public synchronized void refreshAsn(Asn asn, List<AsnDetail> asnDetails) {
|
||||||
|
|
||||||
if (asnDetails == null) {
|
if (asnDetails == null) {
|
||||||
asnDetails = new ArrayList<>();
|
asnDetails = new ArrayList<>();
|
||||||
|
|
@ -93,12 +91,18 @@ public class AsnServiceImpl extends ServiceImpl<AsnMapper, Asn> implements IAsnS
|
||||||
//当前状态
|
//当前状态
|
||||||
Integer status = asn.getStatus();
|
Integer status = asn.getStatus();
|
||||||
|
|
||||||
if (orderQty.compareTo(BigDecimal.ZERO) >= 0 && receivedQty.compareTo(BigDecimal.ZERO) == 0) {
|
if (orderQty.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
// 无需求量时设为创建状态
|
||||||
status = AsnStatusEnum.CREATED.getValue();
|
status = AsnStatusEnum.CREATED.getValue();
|
||||||
} else if (BigDecimalUtil.subtract(orderQty, receivedQty, 0).compareTo(BigDecimal.ZERO) > 0 && receivedQty.compareTo(BigDecimal.ZERO) > 0) {
|
} else if (receivedQty.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
status = AsnStatusEnum.RECEIVING.getValue();
|
// 未收货时为创建状态
|
||||||
} else if (BigDecimalUtil.subtract(orderQty, receivedQty, 0).compareTo(BigDecimal.ZERO) == 0 && receivedQty.compareTo(BigDecimal.ZERO) > 0) {
|
status = AsnStatusEnum.CREATED.getValue();
|
||||||
|
} else if (receivedQty.compareTo(orderQty) >= 0) {
|
||||||
|
// 已完全收货
|
||||||
status = AsnStatusEnum.RECEIVED.getValue();
|
status = AsnStatusEnum.RECEIVED.getValue();
|
||||||
|
} else {
|
||||||
|
// 部分收货
|
||||||
|
status = AsnStatusEnum.RECEIVING.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
asn.setOrderQty(orderQty);
|
asn.setOrderQty(orderQty);
|
||||||
|
|
@ -131,7 +135,7 @@ public class AsnServiceImpl extends ServiceImpl<AsnMapper, Asn> implements IAsnS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delMain(String id) {
|
public void delMain(Long id) {
|
||||||
Asn asn = this.getById(id);
|
Asn asn = this.getById(id);
|
||||||
if (!AsnStatusEnum.CREATED.getValue().equals(asn.getStatus())) {
|
if (!AsnStatusEnum.CREATED.getValue().equals(asn.getStatus())) {
|
||||||
throw new RuntimeException("操作失败:【" + asn.getOrderNo() + "】入库单,非创建状态不允许删除");
|
throw new RuntimeException("操作失败:【" + asn.getOrderNo() + "】入库单,非创建状态不允许删除");
|
||||||
|
|
@ -150,7 +154,7 @@ public class AsnServiceImpl extends ServiceImpl<AsnMapper, Asn> implements IAsnS
|
||||||
orderNoList.add(asn.getOrderNo());
|
orderNoList.add(asn.getOrderNo());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
asnDetailMapper.deleteByMainId(id.toString());
|
asnDetailMapper.deleteByMainId(Long.parseLong(id.toString()));
|
||||||
asnMapper.deleteById(id);
|
asnMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
if (!orderNoList.isEmpty()) {
|
if (!orderNoList.isEmpty()) {
|
||||||
|
|
@ -176,13 +180,6 @@ public class AsnServiceImpl extends ServiceImpl<AsnMapper, Asn> implements IAsnS
|
||||||
//容器
|
//容器
|
||||||
Stock stock = stockMapper.selectById(asnDetail.getStockId());
|
Stock stock = stockMapper.selectById(asnDetail.getStockId());
|
||||||
|
|
||||||
//验证当前托盘是否有库存
|
|
||||||
/* Stock stock = stockMapper.selectById(asnDetail.getStockId());
|
|
||||||
Inventory existingInventory = inventoryMapper.selectByStockId(stock.getId());
|
|
||||||
if (existingInventory != null) {
|
|
||||||
throw new RuntimeException("【" + stock.getStockCode() + "】托盘已入库");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//更新收货数量
|
//更新收货数量
|
||||||
BigDecimal receivedQty = BigDecimalUtil.add(asnDetail.getReceivedQty(), asnDetail.getOrderQty(), 0);
|
BigDecimal receivedQty = BigDecimalUtil.add(asnDetail.getReceivedQty(), asnDetail.getOrderQty(), 0);
|
||||||
asnDetail.setReceivedQty(receivedQty);
|
asnDetail.setReceivedQty(receivedQty);
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ public class AsnPage {
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@Schema(description = "主键")
|
@Schema(description = "主键")
|
||||||
private java.lang.String id;
|
private java.lang.Long id;
|
||||||
|
|
||||||
@Excel(name = "外部单号", width = 15)
|
@Excel(name = "外部单号", width = 15)
|
||||||
@Schema(description = "外部单号")
|
@Schema(description = "外部单号")
|
||||||
private java.lang.String thirdPartyOrderNo;
|
private java.lang.String thirdOrderNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务号
|
* 任务号
|
||||||
|
|
@ -73,7 +73,7 @@ public class AsnPage {
|
||||||
*/
|
*/
|
||||||
@Excel(name = "订单状态", width = 15)
|
@Excel(name = "订单状态", width = 15)
|
||||||
@Schema(description = "订单状态")
|
@Schema(description = "订单状态")
|
||||||
private java.lang.String status;
|
private java.lang.Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 需求数量
|
* 需求数量
|
||||||
|
|
@ -105,7 +105,7 @@ public class AsnPage {
|
||||||
*/
|
*/
|
||||||
@Excel(name = "仓库ID", width = 15)
|
@Excel(name = "仓库ID", width = 15)
|
||||||
@Schema(description = "仓库ID")
|
@Schema(description = "仓库ID")
|
||||||
private java.lang.String tenantId;
|
private java.lang.Long tenantId;
|
||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.cpte.modules.saiWms.request.InboundRequest;
|
import org.cpte.modules.saiWms.request.InboundRequest;
|
||||||
|
import org.cpte.modules.saiWms.request.OutboundRequest;
|
||||||
import org.cpte.modules.saiWms.service.ISaiWmsService;
|
import org.cpte.modules.saiWms.service.ISaiWmsService;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
|
@ -17,12 +18,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Tag(name = "赛意WMS")
|
@Tag(name = "赛意WMS")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/saiWms/inBound")
|
@RequestMapping("/saiWms")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SaiWmsController {
|
public class SaiWmsController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISaiWmsService iInBoundService;
|
private ISaiWmsService iSaiWmsService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库任务下发
|
* 入库任务下发
|
||||||
|
|
@ -31,10 +32,24 @@ public class SaiWmsController {
|
||||||
*/
|
*/
|
||||||
@AutoLog(value = "入库任务下发")
|
@AutoLog(value = "入库任务下发")
|
||||||
@Operation(summary = "赛意WMS-入库任务下发")
|
@Operation(summary = "赛意WMS-入库任务下发")
|
||||||
@PostMapping(value = "/inBoundTask")
|
@PostMapping(value = "/inBound/inBoundTask")
|
||||||
@IgnoreAuth
|
@IgnoreAuth
|
||||||
public Result<String> inBoundTask(@RequestBody @Valid InboundRequest inboundRequest) {
|
public Result<String> inBoundTask(@RequestBody @Valid InboundRequest inboundRequest) {
|
||||||
iInBoundService.inBoundTask(inboundRequest);
|
iSaiWmsService.inBoundTask(inboundRequest);
|
||||||
|
return Result.OK("下发成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库任务下发
|
||||||
|
*
|
||||||
|
* @param outboundRequest 请求参数
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "出库任务下发")
|
||||||
|
@Operation(summary = "赛意WMS-出库任务下发")
|
||||||
|
@PostMapping(value = "/outBound/outBoundTask")
|
||||||
|
@IgnoreAuth
|
||||||
|
public Result<String> outBoundTask(@RequestBody @Valid OutboundRequest outboundRequest) {
|
||||||
|
iSaiWmsService.outBoundTask(outboundRequest);
|
||||||
return Result.OK("下发成功!");
|
return Result.OK("下发成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
package org.cpte.modules.saiWms.request;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 赛意WMS-任务下发请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OutboundRequest {
|
||||||
|
// 任务号
|
||||||
|
@NotBlank(message = "任务号不能为空")
|
||||||
|
@JsonProperty("No")
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
// 单号
|
||||||
|
@NotBlank(message = "单号不能为空")
|
||||||
|
@JsonProperty("OrderNo")
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
|
// 仓库
|
||||||
|
@NotBlank(message = "仓库不能为空")
|
||||||
|
@JsonProperty("WhCode")
|
||||||
|
private String whCode;
|
||||||
|
|
||||||
|
// 供应商编码
|
||||||
|
@JsonProperty("CustomerCode")
|
||||||
|
private String customerCode;
|
||||||
|
|
||||||
|
// 单据类型:0.成品入库;1.配件入库;2.成品拆托入库;3.配件拆托入库;4.成品出库;5.配件出库;6.返工出库;7.检验出库;8.其他出库
|
||||||
|
@NotNull(message = "单据类型不能为空")
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
// 生产车间
|
||||||
|
@NotBlank(message = "生产车间")
|
||||||
|
@JsonProperty("Enterprise")
|
||||||
|
private String enterprise;
|
||||||
|
|
||||||
|
// 出库明细列表
|
||||||
|
@NotNull(message = "入库明细不能为空")
|
||||||
|
@JsonProperty("details")
|
||||||
|
@Valid
|
||||||
|
private List<OutboundDetail> details;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class OutboundDetail {
|
||||||
|
// 行号
|
||||||
|
@NotBlank(message = "行号不能为空")
|
||||||
|
@JsonProperty("LineNo")
|
||||||
|
private String lineNo;
|
||||||
|
|
||||||
|
// 物料
|
||||||
|
@NotBlank(message = "物料不能为空")
|
||||||
|
@JsonProperty("Item")
|
||||||
|
private String item;
|
||||||
|
|
||||||
|
// 单位
|
||||||
|
@NotBlank(message = "单位不能为空")
|
||||||
|
@JsonProperty("Unit")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
// 数量
|
||||||
|
@NotNull(message = "数量不能为空")
|
||||||
|
@JsonProperty("Qty")
|
||||||
|
private BigDecimal qty;
|
||||||
|
|
||||||
|
// 项目号
|
||||||
|
@JsonProperty("Project")
|
||||||
|
private String project;
|
||||||
|
|
||||||
|
// 任务号
|
||||||
|
@JsonProperty("TaskNo")
|
||||||
|
private String taskNo;
|
||||||
|
|
||||||
|
// 批次号
|
||||||
|
@JsonProperty("LotAtt04")
|
||||||
|
private String lotAtt04;
|
||||||
|
|
||||||
|
// 库存状态
|
||||||
|
@JsonProperty("LotAtt010")
|
||||||
|
private String lotAtt010;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.cpte.modules.saiWms.service;
|
package org.cpte.modules.saiWms.service;
|
||||||
|
|
||||||
import org.cpte.modules.saiWms.request.InboundRequest;
|
import org.cpte.modules.saiWms.request.InboundRequest;
|
||||||
|
import org.cpte.modules.saiWms.request.OutboundRequest;
|
||||||
|
|
||||||
public interface ISaiWmsService {
|
public interface ISaiWmsService {
|
||||||
/**
|
/**
|
||||||
|
|
@ -9,4 +10,11 @@ public interface ISaiWmsService {
|
||||||
* @param inboundRequest 请求参数
|
* @param inboundRequest 请求参数
|
||||||
*/
|
*/
|
||||||
void inBoundTask(InboundRequest inboundRequest);
|
void inBoundTask(InboundRequest inboundRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出库任务下发
|
||||||
|
*
|
||||||
|
* @param outboundRequest 请求参数
|
||||||
|
*/
|
||||||
|
void outBoundTask(OutboundRequest outboundRequest);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,15 @@ import org.cpte.modules.receive.entity.AsnDetail;
|
||||||
import org.cpte.modules.receive.mapper.AsnMapper;
|
import org.cpte.modules.receive.mapper.AsnMapper;
|
||||||
import org.cpte.modules.receive.service.IAsnService;
|
import org.cpte.modules.receive.service.IAsnService;
|
||||||
import org.cpte.modules.saiWms.request.InboundRequest;
|
import org.cpte.modules.saiWms.request.InboundRequest;
|
||||||
|
import org.cpte.modules.saiWms.request.OutboundRequest;
|
||||||
import org.cpte.modules.saiWms.service.ISaiWmsService;
|
import org.cpte.modules.saiWms.service.ISaiWmsService;
|
||||||
import org.cpte.modules.utils.CodeGeneratorUtil;
|
import org.cpte.modules.serialNumber.AsnSerialNumberRule;
|
||||||
import org.jeecg.common.config.TenantContext;
|
import org.cpte.modules.serialNumber.PickSerialNumberRule;
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import org.cpte.modules.shipping.mapper.PickMapper;
|
||||||
|
import org.cpte.modules.shipping.service.IPickService;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
|
||||||
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 org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -32,11 +36,15 @@ import java.util.*;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ISaiWmsServiceImpl implements ISaiWmsService {
|
public class ISaiWmsServiceImpl implements ISaiWmsService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PointMapper pointMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsnMapper asnMapper;
|
private AsnMapper asnMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PointMapper pointMapper;
|
private PickMapper pickMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IItemService itemService;
|
private IItemService itemService;
|
||||||
|
|
@ -50,11 +58,18 @@ public class ISaiWmsServiceImpl implements ISaiWmsService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAsnService asnService;
|
private IAsnService asnService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPickService pickService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAgvTaskService iAgvTaskService;
|
private IAgvTaskService iAgvTaskService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CodeGeneratorUtil codeGeneratorUtil;
|
private AsnSerialNumberRule asnSerialNumberRule;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PickSerialNumberRule pickSerialNumberRule;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
@ -106,11 +121,42 @@ public class ISaiWmsServiceImpl implements ISaiWmsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void outBoundTask(OutboundRequest outboundRequest) {
|
||||||
|
//验证任务号
|
||||||
|
String no = outboundRequest.getNo();
|
||||||
|
Pick pick = pickMapper.queryByNo(no);
|
||||||
|
if (pick != null) {
|
||||||
|
throw new RuntimeException("【" + no + "】任务号已接收,请勿重复下发");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取集合中所有的物料
|
||||||
|
List<String> itemCodes = outboundRequest.getDetails().stream().map(OutboundRequest.OutboundDetail::getItem).distinct().toList();
|
||||||
|
|
||||||
|
//获取数据库已存在物料
|
||||||
|
Map<String, Item> exitItemMap = itemService.queryByItemCodesToMap(itemCodes);
|
||||||
|
|
||||||
|
//获取不存在的物料
|
||||||
|
List<String> notExitItemCodes = itemCodes.stream().filter(itemCode -> !exitItemMap.containsKey(itemCode)).toList();
|
||||||
|
if (!notExitItemCodes.isEmpty()) {
|
||||||
|
throw new RuntimeException("系统无【" + notExitItemCodes + "】物料,请维护");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建出库单和明细
|
||||||
|
Pick createPick = buildPick(outboundRequest);
|
||||||
|
List<PickDetail> pickDetails = buildPickDetail(outboundRequest.getDetails(), exitItemMap);
|
||||||
|
|
||||||
|
// 保存出库单和出库明细
|
||||||
|
pickService.saveMain(createPick, pickDetails);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建入库单
|
* 构建入库单
|
||||||
*/
|
*/
|
||||||
private Asn buildAsn(InboundRequest inboundRequest) {
|
private Asn buildAsn(InboundRequest inboundRequest) {
|
||||||
String orderNo = (codeGeneratorUtil.generateSerialNumber("RK"));
|
String orderNo = asnSerialNumberRule.generateSerialNumber(CommonConstant.ASN_ORDER_NO);
|
||||||
return Asn.builder()
|
return Asn.builder()
|
||||||
.orderNo(orderNo)
|
.orderNo(orderNo)
|
||||||
.thirdOrderNo(inboundRequest.getOrderNo())
|
.thirdOrderNo(inboundRequest.getOrderNo())
|
||||||
|
|
@ -136,16 +182,61 @@ public class ISaiWmsServiceImpl implements ISaiWmsService {
|
||||||
.itemId(item.getId())
|
.itemId(item.getId())
|
||||||
.unit(detail.getUnit())
|
.unit(detail.getUnit())
|
||||||
.orderQty(detail.getQty())
|
.orderQty(detail.getQty())
|
||||||
|
.receivedQty(BigDecimal.ZERO)
|
||||||
.stockId(stock.getId())
|
.stockId(stock.getId())
|
||||||
.pointId(srcPoint.getId())
|
.pointId(srcPoint.getId())
|
||||||
.status(AsnStatusEnum.CREATED.getValue())
|
.status(AsnStatusEnum.CREATED.getValue())
|
||||||
.project(detail.getProject())
|
.project(detail.getProject())
|
||||||
.taskNo(detail.getTaskNo())
|
.taskNo(detail.getTaskNo())
|
||||||
.propC1(detail.getLotAtt04())
|
.propC1(detail.getLotAtt04())
|
||||||
.propC2(detail.getLotAtt010())
|
.propC3(detail.getLotAtt010())
|
||||||
.receivedQty(BigDecimal.ZERO)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建出库单
|
||||||
|
*/
|
||||||
|
private Pick buildPick(OutboundRequest outboundRequest) {
|
||||||
|
String orderNo = pickSerialNumberRule.generateSerialNumber(CommonConstant.PICK_ORDER_NO);
|
||||||
|
return Pick.builder()
|
||||||
|
.orderNo(orderNo)
|
||||||
|
.thirdOrderNo(outboundRequest.getOrderNo())
|
||||||
|
.no(outboundRequest.getNo())
|
||||||
|
.whCode(outboundRequest.getWhCode())
|
||||||
|
.customerCode(outboundRequest.getCustomerCode())
|
||||||
|
.orderType(outboundRequest.getType())
|
||||||
|
.status(PickStatusEnum.CREATED.getValue())
|
||||||
|
.orderDate(new Date())
|
||||||
|
.sysOrgCode("A05")
|
||||||
|
.tenantId(1000L)
|
||||||
|
.createBy("赛意")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建出库明细
|
||||||
|
*/
|
||||||
|
private List<PickDetail> buildPickDetail(List<OutboundRequest.OutboundDetail> details, Map<String, Item> exitItemMap) {
|
||||||
|
List<PickDetail> newDetailList = new ArrayList<>();
|
||||||
|
for (OutboundRequest.OutboundDetail detail : details) {
|
||||||
|
PickDetail pickDetail = PickDetail.builder()
|
||||||
|
.lineNo(Integer.parseInt(detail.getLineNo()))
|
||||||
|
.itemId(exitItemMap.get(detail.getItem()).getId())
|
||||||
|
.unit(detail.getUnit())
|
||||||
|
.orderQty(detail.getQty())
|
||||||
|
.allocatedQty(BigDecimal.ZERO)
|
||||||
|
.pickedQty(BigDecimal.ZERO)
|
||||||
|
.status(PickStatusEnum.CREATED.getValue())
|
||||||
|
.project(detail.getProject())
|
||||||
|
.taskNo(detail.getTaskNo())
|
||||||
|
.propC1(detail.getLotAtt04())
|
||||||
|
.propC3(detail.getLotAtt010())
|
||||||
|
.build();
|
||||||
|
newDetailList.add(pickDetail);
|
||||||
|
}
|
||||||
|
return newDetailList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.cpte.modules.serialNumber;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.handler.IFillRuleHandler;
|
||||||
|
import org.jeecg.modules.system.mapper.SysFillRuleMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.cpte.modules.utils.CodeGeneratorUtil;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class AsnSerialNumberRule implements IFillRuleHandler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CodeGeneratorUtil codeGeneratorUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFillRuleMapper sysFillRuleMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(JSONObject params, JSONObject formData) {
|
||||||
|
String prefix = params.getString("code");
|
||||||
|
String code = codeGeneratorUtil.generateSerialNumber(prefix);
|
||||||
|
log.info("生成业务编号:{}", code);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateSerialNumber(String ruleCode) {
|
||||||
|
String ruleParams = sysFillRuleMapper.queryByRuleCode(ruleCode);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(ruleParams);
|
||||||
|
String prefix = null;
|
||||||
|
if (jsonObject != null) {
|
||||||
|
prefix = jsonObject.getString("code");
|
||||||
|
} else {
|
||||||
|
prefix = "RK";
|
||||||
|
}
|
||||||
|
return codeGeneratorUtil.generateSerialNumber(prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.cpte.modules.serialNumber;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.cpte.modules.utils.CodeGeneratorUtil;
|
||||||
|
import org.jeecg.common.handler.IFillRuleHandler;
|
||||||
|
import org.jeecg.modules.system.mapper.SysFillRuleMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class PickSerialNumberRule implements IFillRuleHandler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CodeGeneratorUtil codeGeneratorUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFillRuleMapper sysFillRuleMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(JSONObject params, JSONObject formData) {
|
||||||
|
String prefix = params.getString("code");
|
||||||
|
String code = codeGeneratorUtil.generateSerialNumber(prefix);
|
||||||
|
log.info("生成业务编号:{}", code);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateSerialNumber(String ruleCode) {
|
||||||
|
String ruleParams = sysFillRuleMapper.queryByRuleCode(ruleCode);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(ruleParams);
|
||||||
|
String prefix = null;
|
||||||
|
if (jsonObject != null) {
|
||||||
|
prefix = jsonObject.getString("code");
|
||||||
|
} else {
|
||||||
|
prefix = "CK";
|
||||||
|
}
|
||||||
|
return codeGeneratorUtil.generateSerialNumber(prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,270 @@
|
||||||
|
package org.cpte.modules.shipping.controller;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.cpte.modules.constant.CommonConstant;
|
||||||
|
import org.cpte.modules.serialNumber.PickSerialNumberRule;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
|
import org.cpte.modules.shipping.vo.PickPage;
|
||||||
|
import org.cpte.modules.shipping.service.IPickService;
|
||||||
|
import org.cpte.modules.shipping.service.IPickDetailService;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库单
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Tag(name = "出库单")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/shipping/pick")
|
||||||
|
@Slf4j
|
||||||
|
public class PickController {
|
||||||
|
@Autowired
|
||||||
|
private IPickService pickService;
|
||||||
|
@Autowired
|
||||||
|
private IPickDetailService pickDetailService;
|
||||||
|
@Autowired
|
||||||
|
private PickSerialNumberRule pickSerialNumberRule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @param pick
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @param req
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "出库单-分页列表查询")
|
||||||
|
@Operation(summary = "出库单-分页列表查询")
|
||||||
|
@GetMapping(value = "/list")
|
||||||
|
public Result<IPage<Pick>> queryPageList(Pick pick,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
HttpServletRequest req) {
|
||||||
|
QueryWrapper<Pick> queryWrapper = QueryGenerator.initQueryWrapper(pick, req.getParameterMap());
|
||||||
|
Page<Pick> page = new Page<Pick>(pageNo, pageSize);
|
||||||
|
IPage<Pick> pageList = pickService.page(page, queryWrapper);
|
||||||
|
return Result.OK(pageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*
|
||||||
|
* @param pickPage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "出库单-添加")
|
||||||
|
@Operation(summary = "出库单-添加")
|
||||||
|
@RequiresPermissions("shipping:data_pick:add")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public Result<String> add(@RequestBody PickPage pickPage) {
|
||||||
|
Pick pick = new Pick();
|
||||||
|
String orderNo = pickSerialNumberRule.generateSerialNumber(CommonConstant.PICK_ORDER_NO);
|
||||||
|
pick.setOrderNo(orderNo);
|
||||||
|
BeanUtils.copyProperties(pickPage, pick);
|
||||||
|
pickService.saveMain(pick, pickPage.getPickDetailList());
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*
|
||||||
|
* @param pickPage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "出库单-编辑")
|
||||||
|
@Operation(summary = "出库单-编辑")
|
||||||
|
@RequiresPermissions("shipping:data_pick:edit")
|
||||||
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||||
|
public Result<String> edit(@RequestBody PickPage pickPage) {
|
||||||
|
Pick existingPick = pickService.getById(pickPage.getId());
|
||||||
|
if (existingPick == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
// 将更新数据从 pickPage 复制到 existingPick
|
||||||
|
BeanUtils.copyProperties(pickPage, existingPick);
|
||||||
|
pickService.updateMain(existingPick, pickPage.getPickDetailList());
|
||||||
|
return Result.OK("编辑成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "出库单-通过id删除")
|
||||||
|
@Operation(summary = "出库单-通过id删除")
|
||||||
|
@RequiresPermissions("shipping:data_pick:delete")
|
||||||
|
@DeleteMapping(value = "/delete")
|
||||||
|
public Result<String> delete(@RequestParam(name = "id", required = true) Long id) {
|
||||||
|
pickService.delMain(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "出库单-批量删除")
|
||||||
|
@Operation(summary = "出库单-批量删除")
|
||||||
|
@RequiresPermissions("shipping:data_pick:deleteBatch")
|
||||||
|
@DeleteMapping(value = "/deleteBatch")
|
||||||
|
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||||
|
this.pickService.delBatchMain(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "出库单-通过id查询")
|
||||||
|
@Operation(summary = "出库单-通过id查询")
|
||||||
|
@GetMapping(value = "/queryById")
|
||||||
|
public Result<Pick> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||||
|
Pick pick = pickService.getById(id);
|
||||||
|
if (pick == null) {
|
||||||
|
return Result.error("未找到对应数据");
|
||||||
|
}
|
||||||
|
return Result.OK(pick);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id查询
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
//@AutoLog(value = "出库明细通过主表ID查询")
|
||||||
|
@Operation(summary = "出库明细主表ID查询")
|
||||||
|
@GetMapping(value = "/queryPickDetailByMainId")
|
||||||
|
public Result<List<PickDetail>> queryPickDetailListByMainId(@RequestParam(name = "id", required = true) Long id) {
|
||||||
|
List<PickDetail> pickDetailList = pickDetailService.selectByMainId(id);
|
||||||
|
return Result.OK(pickDetailList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出excel
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param pick
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("shipping:data_pick:exportXls")
|
||||||
|
@RequestMapping(value = "/exportXls")
|
||||||
|
public ModelAndView exportXls(HttpServletRequest request, Pick pick) {
|
||||||
|
|
||||||
|
// Step.1 组装查询条件查询数据
|
||||||
|
QueryWrapper<Pick> queryWrapper = QueryGenerator.initQueryWrapper(pick, request.getParameterMap());
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
|
||||||
|
//配置选中数据查询条件
|
||||||
|
String selections = request.getParameter("selections");
|
||||||
|
if (oConvertUtils.isNotEmpty(selections)) {
|
||||||
|
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||||
|
queryWrapper.in("id", selectionList);
|
||||||
|
}
|
||||||
|
//Step.2 获取导出数据
|
||||||
|
List<Pick> pickList = pickService.list(queryWrapper);
|
||||||
|
|
||||||
|
// Step.3 组装pageList
|
||||||
|
List<PickPage> pageList = new ArrayList<PickPage>();
|
||||||
|
for (Pick main : pickList) {
|
||||||
|
PickPage vo = new PickPage();
|
||||||
|
BeanUtils.copyProperties(main, vo);
|
||||||
|
List<PickDetail> pickDetailList = pickDetailService.selectByMainId(main.getId());
|
||||||
|
vo.setPickDetailList(pickDetailList);
|
||||||
|
pageList.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step.4 AutoPoi 导出Excel
|
||||||
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||||
|
mv.addObject(NormalExcelConstants.FILE_NAME, "出库单列表");
|
||||||
|
mv.addObject(NormalExcelConstants.CLASS, PickPage.class);
|
||||||
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("出库单数据", "导出人:" + sysUser.getRealname(), "出库单"));
|
||||||
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过excel导入数据
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("shipping:data_pick:importExcel")
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||||
|
// 获取上传文件对象
|
||||||
|
MultipartFile file = entity.getValue();
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(2);
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
try {
|
||||||
|
List<PickPage> list = ExcelImportUtil.importExcel(file.getInputStream(), PickPage.class, params);
|
||||||
|
for (PickPage page : list) {
|
||||||
|
Pick po = new Pick();
|
||||||
|
BeanUtils.copyProperties(page, po);
|
||||||
|
pickService.saveMain(po, page.getPickDetailList());
|
||||||
|
}
|
||||||
|
return Result.OK("文件导入成功!数据行数:" + list.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return Result.error("文件导入失败:" + e.getMessage());
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.OK("文件导入失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
package org.cpte.modules.shipping.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.jeecg.common.constant.ProvinceCityArea;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库单
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Schema(description = "出库单")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("data_pick")
|
||||||
|
public class Pick implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description = "id")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private java.lang.Long id;
|
||||||
|
/**
|
||||||
|
* 出库单号
|
||||||
|
*/
|
||||||
|
@Excel(name = "出库单号", width = 15)
|
||||||
|
@Schema(description = "出库单号")
|
||||||
|
private java.lang.String orderNo;
|
||||||
|
/**
|
||||||
|
* 外部单号
|
||||||
|
*/
|
||||||
|
@Excel(name = "外部单号", width = 15)
|
||||||
|
@Schema(description = "外部单号")
|
||||||
|
private java.lang.String thirdOrderNo;
|
||||||
|
/**
|
||||||
|
* 任务号
|
||||||
|
*/
|
||||||
|
@Excel(name = "任务号", width = 15)
|
||||||
|
@Schema(description = "任务号")
|
||||||
|
private java.lang.String no;
|
||||||
|
/**
|
||||||
|
* 外部仓库
|
||||||
|
*/
|
||||||
|
@Excel(name = "外部仓库", width = 15)
|
||||||
|
@Schema(description = "外部仓库")
|
||||||
|
private java.lang.String whCode;
|
||||||
|
/**
|
||||||
|
* 客户代码
|
||||||
|
*/
|
||||||
|
@Excel(name = "客户代码", width = 15)
|
||||||
|
@Schema(description = "客户代码")
|
||||||
|
private java.lang.String customerCode;
|
||||||
|
/**
|
||||||
|
* 单据类型;0.成品入库;1.配件入库;2.成品拆托入库;3.配件拆托入库;4.成品出库;5.配件出库;6.返工出库;7.检验出库;8.其他出库
|
||||||
|
*/
|
||||||
|
@Excel(name = "单据类型", width = 15)
|
||||||
|
@Schema(description = "单据类型")
|
||||||
|
@Dict(dicCode = "pick_order_type")
|
||||||
|
private java.lang.Integer orderType;
|
||||||
|
/**
|
||||||
|
* 订单状态:1.已创建;2.部分分配;3.已分配;4.拣货中;5.拣货完成;6.已关闭;7.已取消
|
||||||
|
*/
|
||||||
|
@Excel(name = "订单状态", width = 15)
|
||||||
|
@Schema(description = "订单状态")
|
||||||
|
@Dict(dicCode = "pick_status")
|
||||||
|
private java.lang.Integer status;
|
||||||
|
/**
|
||||||
|
* 需求数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "需求数量", width = 15)
|
||||||
|
@Schema(description = "需求数量")
|
||||||
|
private java.math.BigDecimal orderQty;
|
||||||
|
/**
|
||||||
|
* 分配数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "分配数量", width = 15)
|
||||||
|
@Schema(description = "分配数量")
|
||||||
|
private java.math.BigDecimal allocatedQty;
|
||||||
|
/**
|
||||||
|
* 拣货数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "拣货数量", width = 15)
|
||||||
|
@Schema(description = "拣货数量")
|
||||||
|
private java.math.BigDecimal pickedQty;
|
||||||
|
/**
|
||||||
|
* 订单日期
|
||||||
|
*/
|
||||||
|
@Excel(name = "订单日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "订单日期")
|
||||||
|
private java.util.Date orderDate;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
@Schema(description = "所属部门")
|
||||||
|
private java.lang.String sysOrgCode;
|
||||||
|
/**
|
||||||
|
* 仓库ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "仓库ID", width = 15)
|
||||||
|
@Schema(description = "仓库ID")
|
||||||
|
private java.lang.Long tenantId;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
private java.lang.String createBy;
|
||||||
|
/**
|
||||||
|
* 创建日期
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建日期")
|
||||||
|
private java.util.Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
@Schema(description = "更新人")
|
||||||
|
private java.lang.String updateBy;
|
||||||
|
/**
|
||||||
|
* 更新日期
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "更新日期")
|
||||||
|
private java.util.Date updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,197 @@
|
||||||
|
package org.cpte.modules.shipping.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import org.jeecg.common.constant.ProvinceCityArea;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库明细
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Schema(description = "出库明细")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("data_pick_detail")
|
||||||
|
public class PickDetail implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@Schema(description = "id")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private java.lang.Long id;
|
||||||
|
/**
|
||||||
|
* 出库单ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "出库单ID")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private java.lang.Long pickId;
|
||||||
|
/**
|
||||||
|
* 物料ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "物料ID", width = 15)
|
||||||
|
@Schema(description = "物料ID")
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private java.lang.Long itemId;
|
||||||
|
/**
|
||||||
|
* 行号
|
||||||
|
*/
|
||||||
|
@Excel(name = "行号", width = 15)
|
||||||
|
@Schema(description = "行号")
|
||||||
|
private java.lang.Integer lineNo;
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*/
|
||||||
|
@Excel(name = "单位", width = 15)
|
||||||
|
@Schema(description = "单位")
|
||||||
|
private java.lang.String unit;
|
||||||
|
/**
|
||||||
|
* 项目号
|
||||||
|
*/
|
||||||
|
@Excel(name = "项目号", width = 15)
|
||||||
|
@Schema(description = "项目号")
|
||||||
|
private java.lang.String project;
|
||||||
|
/**
|
||||||
|
* 任务号
|
||||||
|
*/
|
||||||
|
@Excel(name = "任务号", width = 15)
|
||||||
|
@Schema(description = "任务号")
|
||||||
|
private java.lang.String taskNo;
|
||||||
|
/**
|
||||||
|
* 需求数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "需求数量", width = 15)
|
||||||
|
@Schema(description = "需求数量")
|
||||||
|
private java.math.BigDecimal orderQty;
|
||||||
|
/**
|
||||||
|
* 分配数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "分配数量", width = 15)
|
||||||
|
@Schema(description = "分配数量")
|
||||||
|
private java.math.BigDecimal allocatedQty;
|
||||||
|
/**
|
||||||
|
* 拣货数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "拣货数量", width = 15)
|
||||||
|
@Schema(description = "拣货数量")
|
||||||
|
private java.math.BigDecimal pickedQty;
|
||||||
|
/**
|
||||||
|
* 订单状态:1.已创建;2.部分分配;3.已分配;4.拣货中;5.拣货完成;6.已关闭;7.已取消
|
||||||
|
*/
|
||||||
|
@Excel(name = "订单状态", width = 15)
|
||||||
|
@Schema(description = "订单状态")
|
||||||
|
@Dict(dicCode = "pick_status")
|
||||||
|
private java.lang.Integer status;
|
||||||
|
/**
|
||||||
|
* 批次号
|
||||||
|
*/
|
||||||
|
@Excel(name = "批次号", width = 15)
|
||||||
|
@Schema(description = "批次号")
|
||||||
|
private java.lang.String propC1;
|
||||||
|
/**
|
||||||
|
* 序列号
|
||||||
|
*/
|
||||||
|
@Excel(name = "序列号", width = 15)
|
||||||
|
@Schema(description = "序列号")
|
||||||
|
private java.lang.String propC2;
|
||||||
|
/**
|
||||||
|
* 外部库存状态
|
||||||
|
*/
|
||||||
|
@Excel(name = "外部库存状态", width = 15)
|
||||||
|
@Schema(description = "外部库存状态")
|
||||||
|
private java.lang.String propC3;
|
||||||
|
/**
|
||||||
|
* 扩展字段
|
||||||
|
*/
|
||||||
|
@Excel(name = "扩展字段", width = 15)
|
||||||
|
@Schema(description = "扩展字段")
|
||||||
|
private java.lang.String propC4;
|
||||||
|
/**
|
||||||
|
* 生产日期
|
||||||
|
*/
|
||||||
|
@Excel(name = "生产日期", width = 15, format = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Schema(description = "生产日期")
|
||||||
|
private java.util.Date propD1;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@Excel(name = "备注", width = 15)
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private java.lang.String description;
|
||||||
|
/**
|
||||||
|
* 来源ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "来源ID", width = 15)
|
||||||
|
@Schema(description = "来源ID")
|
||||||
|
private java.lang.Long sourceId;
|
||||||
|
/**
|
||||||
|
* 来源
|
||||||
|
*/
|
||||||
|
@Excel(name = "来源", width = 15)
|
||||||
|
@Schema(description = "来源")
|
||||||
|
private java.lang.String sourceName;
|
||||||
|
/**
|
||||||
|
* 仓库ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "仓库ID", width = 15)
|
||||||
|
@Schema(description = "仓库ID")
|
||||||
|
private java.lang.Long tenantId;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
@Schema(description = "所属部门")
|
||||||
|
private java.lang.String sysOrgCode;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
private java.lang.String createBy;
|
||||||
|
/**
|
||||||
|
* 创建日期
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建日期")
|
||||||
|
private java.util.Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
@Schema(description = "更新人")
|
||||||
|
private java.lang.String updateBy;
|
||||||
|
/**
|
||||||
|
* 更新日期
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "更新日期")
|
||||||
|
private java.util.Date updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.cpte.modules.shipping.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库明细
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface PickDetailMapper extends BaseMapper<PickDetail> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主表id删除子表数据
|
||||||
|
*
|
||||||
|
* @param mainId 主表id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean deleteByMainId(@Param("mainId") Long mainId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主表id查询子表数据
|
||||||
|
*
|
||||||
|
* @param mainId 主表id
|
||||||
|
* @return List<PickDetail>
|
||||||
|
*/
|
||||||
|
public List<PickDetail> selectByMainId(@Param("mainId") Long mainId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.cpte.modules.shipping.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库单
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface PickMapper extends BaseMapper<Pick> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务号查询出库单
|
||||||
|
*
|
||||||
|
* @param no 任务号
|
||||||
|
* @return Pick
|
||||||
|
*/
|
||||||
|
@Select("select * from data_pick where no = #{no} for update ")
|
||||||
|
Pick queryByNo(@Param("no") String no);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?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="org.cpte.modules.shipping.mapper.PickDetailMapper">
|
||||||
|
|
||||||
|
<delete id="deleteByMainId">
|
||||||
|
DELETE
|
||||||
|
FROM data_pick_detail
|
||||||
|
WHERE
|
||||||
|
pick_id = #{mainId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectByMainId" resultType="org.cpte.modules.shipping.entity.PickDetail">
|
||||||
|
SELECT *
|
||||||
|
FROM data_pick_detail
|
||||||
|
WHERE
|
||||||
|
pick_id = #{mainId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?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="org.cpte.modules.shipping.mapper.PickMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.cpte.modules.shipping.service;
|
||||||
|
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库明细
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IPickDetailService extends IService<PickDetail> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主表id查询子表数据
|
||||||
|
*
|
||||||
|
* @param mainId 主表id
|
||||||
|
* @return List<PickDetail>
|
||||||
|
*/
|
||||||
|
public List<PickDetail> selectByMainId(Long mainId);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.cpte.modules.shipping.service;
|
||||||
|
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库单
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
public interface IPickService extends IService<Pick> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加一对多
|
||||||
|
*
|
||||||
|
* @param pick
|
||||||
|
* @param pickDetailList
|
||||||
|
*/
|
||||||
|
public void saveMain(Pick pick,List<PickDetail> pickDetailList) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改一对多
|
||||||
|
*
|
||||||
|
* @param pick
|
||||||
|
* @param pickDetailList
|
||||||
|
*/
|
||||||
|
public void updateMain(Pick pick,List<PickDetail> pickDetailList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一对多
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public void delMain (Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除一对多
|
||||||
|
*
|
||||||
|
* @param idList
|
||||||
|
*/
|
||||||
|
public void delBatchMain (Collection<? extends Serializable> idList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.cpte.modules.shipping.service.impl;
|
||||||
|
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import org.cpte.modules.shipping.mapper.PickDetailMapper;
|
||||||
|
import org.cpte.modules.shipping.service.IPickDetailService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.List;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库明细
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PickDetailServiceImpl extends ServiceImpl<PickDetailMapper, PickDetail> implements IPickDetailService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PickDetailMapper pickDetailMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PickDetail> selectByMainId(Long mainId) {
|
||||||
|
return pickDetailMapper.selectByMainId(mainId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
package org.cpte.modules.shipping.service.impl;
|
||||||
|
|
||||||
|
import org.cpte.modules.constant.enums.AsnStatusEnum;
|
||||||
|
import org.cpte.modules.constant.enums.PickStatusEnum;
|
||||||
|
import org.cpte.modules.receive.entity.Asn;
|
||||||
|
import org.cpte.modules.receive.entity.AsnDetail;
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import org.cpte.modules.shipping.mapper.PickDetailMapper;
|
||||||
|
import org.cpte.modules.shipping.mapper.PickMapper;
|
||||||
|
import org.cpte.modules.shipping.service.IPickService;
|
||||||
|
import org.cpte.modules.utils.BigDecimalUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库单
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PickServiceImpl extends ServiceImpl<PickMapper, Pick> implements IPickService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PickMapper pickMapper;
|
||||||
|
@Autowired
|
||||||
|
private PickDetailMapper pickDetailMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void saveMain(Pick pick, List<PickDetail> pickDetailList) {
|
||||||
|
pickMapper.insert(pick);
|
||||||
|
if (pickDetailList != null && !pickDetailList.isEmpty()) {
|
||||||
|
AtomicInteger lineNoCounter = new AtomicInteger(1);
|
||||||
|
for (PickDetail entity : pickDetailList) {
|
||||||
|
if (entity.getLineNo() == null || entity.getLineNo() == 0) {
|
||||||
|
entity.setLineNo(lineNoCounter.getAndIncrement());
|
||||||
|
}
|
||||||
|
entity.setPickId(pick.getId());
|
||||||
|
pickDetailMapper.insert(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//刷新出库单
|
||||||
|
refreshPick(pick, pickDetailList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void refreshPick(Pick pick, List<PickDetail> pickDetails) {
|
||||||
|
if (pickDetails == null) {
|
||||||
|
pickDetails = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算各种数量
|
||||||
|
BigDecimal orderQty = pickDetails.stream().map(PickDetail::getOrderQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal allocatedQty = pickDetails.stream().map(PickDetail::getAllocatedQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal pickedQty = pickDetails.stream().map(PickDetail::getPickedQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
|
// 当前状态
|
||||||
|
Integer status = pick.getStatus();
|
||||||
|
|
||||||
|
// 如果没有任何需求,则为创建状态
|
||||||
|
if (orderQty.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
status = PickStatusEnum.CREATED.getValue();
|
||||||
|
}
|
||||||
|
// 如果分配数量为0,但有需求数量,则为创建状态
|
||||||
|
else if (allocatedQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
status = PickStatusEnum.CREATED.getValue();
|
||||||
|
}
|
||||||
|
// 如果已全部分配但未开始拣货
|
||||||
|
else if (allocatedQty.compareTo(orderQty) >= 0 && pickedQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
status = PickStatusEnum.ASSIGNED.getValue();
|
||||||
|
}
|
||||||
|
// 如果部分分配且未开始拣货
|
||||||
|
else if (allocatedQty.compareTo(orderQty) < 0 && pickedQty.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
status = PickStatusEnum.PARTIAL.getValue();
|
||||||
|
}
|
||||||
|
// 如果开始拣货但未完成
|
||||||
|
else if (pickedQty.compareTo(BigDecimal.ZERO) > 0 && pickedQty.compareTo(allocatedQty) < 0) {
|
||||||
|
status = PickStatusEnum.PICKING.getValue();
|
||||||
|
}
|
||||||
|
// 如果已完成拣货
|
||||||
|
else if (pickedQty.compareTo(allocatedQty) >= 0 && allocatedQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
status = PickStatusEnum.PICKED.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新实体属性
|
||||||
|
pick.setOrderQty(orderQty);
|
||||||
|
pick.setAllocatedQty(allocatedQty);
|
||||||
|
pick.setPickedQty(pickedQty);
|
||||||
|
pick.setStatus(status);
|
||||||
|
pickMapper.updateById(pick);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateMain(Pick pick, List<PickDetail> pickDetailList) {
|
||||||
|
// 直接更新主表
|
||||||
|
pickMapper.updateById(pick);
|
||||||
|
|
||||||
|
// 更新明细表 - 只更新传入的明细数据
|
||||||
|
if (pickDetailList != null && !pickDetailList.isEmpty()) {
|
||||||
|
for (PickDetail entity : pickDetailList) {
|
||||||
|
entity.setPickId(pick.getId());
|
||||||
|
// 直接更新,而不是删除后重新插入
|
||||||
|
if (entity.getId() != null) {
|
||||||
|
pickDetailMapper.updateById(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新出库单状态
|
||||||
|
refreshPick(pick, pickDetailList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delMain(Long id) {
|
||||||
|
Pick pick = this.getById(id);
|
||||||
|
if (!AsnStatusEnum.CREATED.getValue().equals(pick.getStatus())) {
|
||||||
|
throw new RuntimeException("操作失败:【" + pick.getOrderNo() + "】出库单,非创建状态不允许删除");
|
||||||
|
}
|
||||||
|
pickDetailMapper.deleteByMainId(id);
|
||||||
|
pickMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delBatchMain(Collection<? extends Serializable> idList) {
|
||||||
|
List<String> orderNoList = new ArrayList<>();
|
||||||
|
for (Serializable id : idList) {
|
||||||
|
Pick pick = this.getById(id);
|
||||||
|
if (!AsnStatusEnum.CREATED.getValue().equals(pick.getStatus())) {
|
||||||
|
orderNoList.add(pick.getOrderNo());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pickDetailMapper.deleteByMainId(Long.parseLong(id.toString()));
|
||||||
|
pickMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
if (!orderNoList.isEmpty()) {
|
||||||
|
throw new RuntimeException("操作失败:【" + orderNoList + "】出库单,非创建状态不允许删除");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
package org.cpte.modules.shipping.vo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.cpte.modules.shipping.entity.Pick;
|
||||||
|
import org.cpte.modules.shipping.entity.PickDetail;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.ExcelEntity;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jeecg.common.aspect.annotation.Dict;
|
||||||
|
import org.jeecg.common.constant.ProvinceCityArea;
|
||||||
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 出库单
|
||||||
|
* @author: cpte
|
||||||
|
* @Date: 2025-11-14
|
||||||
|
* @Version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "出库单")
|
||||||
|
public class PickPage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@Schema(description = "id")
|
||||||
|
private java.lang.Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外部单号
|
||||||
|
*/
|
||||||
|
@Excel(name = "外部单号", width = 15)
|
||||||
|
@Schema(description = "外部单号")
|
||||||
|
private java.lang.String thirdOrderNo;
|
||||||
|
/**
|
||||||
|
* 任务号
|
||||||
|
*/
|
||||||
|
@Excel(name = "任务号", width = 15)
|
||||||
|
@Schema(description = "任务号")
|
||||||
|
private java.lang.String no;
|
||||||
|
/**
|
||||||
|
* 外部仓库
|
||||||
|
*/
|
||||||
|
@Excel(name = "外部仓库", width = 15)
|
||||||
|
@Schema(description = "外部仓库")
|
||||||
|
private java.lang.String whCode;
|
||||||
|
/**
|
||||||
|
* 客户代码
|
||||||
|
*/
|
||||||
|
@Excel(name = "客户代码", width = 15)
|
||||||
|
@Schema(description = "客户代码")
|
||||||
|
private java.lang.String customerCode;
|
||||||
|
/**
|
||||||
|
* 单据类型;0.成品入库;1.配件入库;2.成品拆托入库;3.配件拆托入库;4.成品出库;5.配件出库;6.返工出库;7.检验出库;8.其他出库
|
||||||
|
*/
|
||||||
|
@Excel(name = "单据类型", width = 15)
|
||||||
|
@Schema(description = "单据类型")
|
||||||
|
private java.lang.Integer orderType;
|
||||||
|
/**
|
||||||
|
* 订单状态:1.已创建;2.部分分配;3.已分配;4.拣货中;5.拣货完成;6.已关闭;7.已取消
|
||||||
|
*/
|
||||||
|
@Excel(name = "订单状态", width = 15)
|
||||||
|
@Schema(description = "订单状态")
|
||||||
|
private java.lang.Integer status;
|
||||||
|
/**
|
||||||
|
* 需求数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "需求数量", width = 15)
|
||||||
|
@Schema(description = "需求数量")
|
||||||
|
private java.math.BigDecimal orderQty;
|
||||||
|
/**
|
||||||
|
* 分配数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "分配数量", width = 15)
|
||||||
|
@Schema(description = "分配数量")
|
||||||
|
private java.math.BigDecimal allocatedQty;
|
||||||
|
/**
|
||||||
|
* 拣货数量
|
||||||
|
*/
|
||||||
|
@Excel(name = "拣货数量", width = 15)
|
||||||
|
@Schema(description = "拣货数量")
|
||||||
|
private java.math.BigDecimal pickedQty;
|
||||||
|
/**
|
||||||
|
* 订单日期
|
||||||
|
*/
|
||||||
|
@Excel(name = "订单日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "订单日期")
|
||||||
|
private java.util.Date orderDate;
|
||||||
|
/**
|
||||||
|
* 所属部门
|
||||||
|
*/
|
||||||
|
@Schema(description = "所属部门")
|
||||||
|
private java.lang.String sysOrgCode;
|
||||||
|
/**
|
||||||
|
* 仓库ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "仓库ID", width = 15)
|
||||||
|
@Schema(description = "仓库ID")
|
||||||
|
private java.lang.Long tenantId;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建人")
|
||||||
|
private java.lang.String createBy;
|
||||||
|
/**
|
||||||
|
* 创建日期
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建日期")
|
||||||
|
private java.util.Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
@Schema(description = "更新人")
|
||||||
|
private java.lang.String updateBy;
|
||||||
|
/**
|
||||||
|
* 更新日期
|
||||||
|
*/
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "更新日期")
|
||||||
|
private java.util.Date updateTime;
|
||||||
|
|
||||||
|
@ExcelCollection(name = "出库明细")
|
||||||
|
@Schema(description = "出库明细")
|
||||||
|
private List<PickDetail> pickDetailList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
package org.cpte.modules.utils;
|
package org.cpte.modules.utils;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.jeecg.weibo.exception.BusinessException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.handler.IFillRuleHandler;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.CannotAcquireLockException;
|
import org.springframework.dao.CannotAcquireLockException;
|
||||||
import org.springframework.dao.DeadlockLoserDataAccessException;
|
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -18,7 +14,7 @@ import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CodeGeneratorUtil implements IFillRuleHandler {
|
public class CodeGeneratorUtil {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public JdbcTemplate jdbcTemplate;
|
public JdbcTemplate jdbcTemplate;
|
||||||
|
|
@ -61,13 +57,7 @@ public class CodeGeneratorUtil implements IFillRuleHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object execute(JSONObject params, JSONObject formData) {
|
|
||||||
String prefix = params.getString("prefix");
|
|
||||||
Object code = generateSerialNumber(prefix);
|
|
||||||
log.info("生成业务编号:{}", code);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
package org.cpte.modules.utils;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.cpte.modules.constant.enums.BaseEnum;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 枚举工具类
|
|
||||||
*
|
|
||||||
* @Author YouChain: 胡克
|
|
||||||
* @Date 2017/10/10 18:17
|
|
||||||
* @Email huoj@youchain56.com
|
|
||||||
*/
|
|
||||||
public class SmartEnumUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验参数与枚举类比较是否合法
|
|
||||||
*
|
|
||||||
* @param value 参数
|
|
||||||
* @param enumClass 枚举类必须实现BaseEnum接口
|
|
||||||
* @return boolean
|
|
||||||
* @Author 胡克
|
|
||||||
*/
|
|
||||||
public static boolean checkEnum(Object value, Class<? extends BaseEnum> enumClass) {
|
|
||||||
if (null == value) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Stream.of(enumClass.getEnumConstants()).anyMatch(e -> e.equalsValue(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建一个具有唯一array值的数组,每个值不包含在其他给定的数组中。
|
|
||||||
*
|
|
||||||
* @param enumClass
|
|
||||||
* @param exclude
|
|
||||||
* @param <T>
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static <T extends BaseEnum> List<Object> differenceValueList(Class<? extends BaseEnum> enumClass, T... exclude) {
|
|
||||||
HashSet<Object> valueSet = new HashSet<>();
|
|
||||||
if (exclude != null) {
|
|
||||||
valueSet.addAll(Stream.of(exclude).map(BaseEnum::getValue).collect(Collectors.toSet()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Stream.of(enumClass.getEnumConstants())
|
|
||||||
.filter(e -> !valueSet.contains(e.getValue()))
|
|
||||||
.map(BaseEnum::getValue)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取枚举类的说明 value : info 的形式
|
|
||||||
*
|
|
||||||
* @param enumClass
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
public static String getEnumDesc(Class<? extends BaseEnum> enumClass) {
|
|
||||||
BaseEnum[] enums = enumClass.getEnumConstants();
|
|
||||||
// value : info 的形式
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (BaseEnum baseEnum : enums) {
|
|
||||||
sb.append(baseEnum.getValue()).append(":").append(baseEnum.getDesc()).append(",");
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取与参数相匹配的枚举类实例的 说明
|
|
||||||
*
|
|
||||||
* @param value 参数
|
|
||||||
* @param enumClass 枚举类必须实现BaseEnum接口
|
|
||||||
* @return String 如无匹配枚举则返回null
|
|
||||||
*/
|
|
||||||
public static String getEnumDescByValue(Object value, Class<? extends BaseEnum> enumClass) {
|
|
||||||
if (null == value) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Stream.of(enumClass.getEnumConstants())
|
|
||||||
.filter(e -> e.equalsValue(value))
|
|
||||||
.findFirst()
|
|
||||||
.map(BaseEnum::getDesc)
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> String getEnumDescByValueList(Collection<T> values, Class<? extends BaseEnum> enumClass) {
|
|
||||||
if (CollectionUtils.isEmpty(values)) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return Stream.of(enumClass.getEnumConstants()).filter(e -> values.contains(e.getValue())).map(BaseEnum::getDesc).collect(Collectors.joining(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据参数获取枚举类的实例
|
|
||||||
*
|
|
||||||
* @param value 参数
|
|
||||||
* @param enumClass 枚举类必须实现BaseEnum接口
|
|
||||||
* @return BaseEnum 无匹配值返回null
|
|
||||||
* @Author 胡克
|
|
||||||
*/
|
|
||||||
public static <T extends BaseEnum> T getEnumByValue(Object value, Class<T> enumClass) {
|
|
||||||
if (null == value) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Stream.of(enumClass.getEnumConstants())
|
|
||||||
.filter(e -> e.equalsValue(value))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据实例描述与获取枚举类的实例
|
|
||||||
*
|
|
||||||
* @param desc 参数描述
|
|
||||||
* @param enumClass 枚举类必须实现BaseEnum接口
|
|
||||||
* @return BaseEnum 无匹配值返回null
|
|
||||||
* @Author 胡克
|
|
||||||
*/
|
|
||||||
public static <T extends BaseEnum> T getEnumByDesc(String desc, Class<T> enumClass) {
|
|
||||||
return Stream.of(enumClass.getEnumConstants())
|
|
||||||
.filter(e -> Objects.equals(e.getDesc(), desc))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static <T extends BaseEnum> T getEnumByName(String name, Class<T> enumClass) {
|
|
||||||
return Stream.of(enumClass.getEnumConstants())
|
|
||||||
.filter(e -> StringUtils.equalsIgnoreCase(e.toString(), name))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据lambda getter/setter 注入
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* @param getter
|
|
||||||
* @param setter
|
|
||||||
* @param enumClass
|
|
||||||
* @param <T>
|
|
||||||
*/
|
|
||||||
public static <T> void inject(List<T> list, Function<T, Integer> getter, BiConsumer<T, String> setter, Class<? extends BaseEnum> enumClass) {
|
|
||||||
if (list == null || list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (T t : list) {
|
|
||||||
Integer enumValue = getter.apply(t);
|
|
||||||
if (enumValue != null) {
|
|
||||||
setter.accept(t, getEnumDescByValue(enumValue, enumClass));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.system.mapper;
|
package org.jeecg.modules.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.jeecg.modules.system.entity.SysFillRule;
|
import org.jeecg.modules.system.entity.SysFillRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -10,5 +11,12 @@ import org.jeecg.modules.system.entity.SysFillRule;
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface SysFillRuleMapper extends BaseMapper<SysFillRule> {
|
public interface SysFillRuleMapper extends BaseMapper<SysFillRule> {
|
||||||
|
/**
|
||||||
|
* 根据规则编码查询规则
|
||||||
|
*
|
||||||
|
* @param ruleCode 编码规则
|
||||||
|
* @return 返回规则
|
||||||
|
*/
|
||||||
|
@Select("select rule_params from sys_fill_rule where rule_code = #{ruleCode}")
|
||||||
|
String queryByRuleCode(String ruleCode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue