This commit is contained in:
15066119699 2025-03-13 09:17:25 +08:00
parent 9fb6020167
commit c0d1e380e5
6 changed files with 132 additions and 20 deletions

View File

@ -100,6 +100,28 @@ public class AppPmsController extends BaseController {
return AjaxResult.success("success");
}
/**
* 更新手动入库单请求
*/
@ApiOperation("更新手动入库单请求")
@Log(title = "更新手动入库单请求", skipAuth = true)
@PostMapping("/updateOrderIn")
public AjaxResult updateOrderIn(@RequestBody AppPmsOrderIn appPmsOrderIn) {
logger.info("更新手动入库单请求:{}", JSONObject.toJSONString(appPmsOrderIn));
// 判断数据是否缺失
if (StringUtils.isEmpty(appPmsOrderIn.getGoodsId())
|| StringUtils.isEmpty(appPmsOrderIn.getGoodsDesc())
|| appPmsOrderIn.getGoodsNum() == null) {
return error("缺少请求数据。");
}
appPmsOrderIn.setUpdateTime(new Date());
appPmsOrderInService.updateAppPmsOrderIn(appPmsOrderIn);
return AjaxResult.success("success");
}
/**
* Pms入库单请求
*/

View File

@ -25,6 +25,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 请填写功能名称Controller
@ -65,6 +66,22 @@ public class AppPmsOrderInController extends BaseController
util.exportExcel(response, list, "【请填写功能名称】数据");
}
@Log(title = "入库单导入", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:out:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<AppPmsOrderIn> util = new ExcelUtil<AppPmsOrderIn>(AppPmsOrderIn.class);
List<AppPmsOrderIn> appPmsOrderInList = util.importExcel(file.getInputStream());
String message = appPmsOrderInService.importPmsOrderOut(appPmsOrderInList);
return success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
ExcelUtil<AppPmsOrderIn> util = new ExcelUtil<AppPmsOrderIn>(AppPmsOrderIn.class);
util.importTemplateExcel(response, "入库订单数据");
}
/**
* 获取请填写功能名称详细信息
*/

View File

@ -22,15 +22,15 @@ public class AppPmsOrderIn extends BaseEntity
private String listId;
/** 订单类型 */
@Excel(name = "订单类型")
@Excel(name = "订单类型",type = Excel.Type.EXPORT)
private Integer orderType;
/** 客户ID */
@Excel(name = "客户ID")
@Excel(name = "客户ID",type = Excel.Type.EXPORT)
private String customerId;
/** 订单号 */
@Excel(name = "订单号")
@Excel(name = "订单号",type = Excel.Type.EXPORT)
private String orderId;
/** 物料号 */
@ -38,15 +38,15 @@ public class AppPmsOrderIn extends BaseEntity
private String goodsId;
/** 数量 */
@Excel(name = "数量")
@Excel(name = "入库数量")
private BigDecimal goodsNum;
/** 使用数量(已入库数量) */
@Excel(name = "使用数量", readConverterExp = "已=入库数量")
@Excel(name = "使用数量", readConverterExp = "已=入库数量",type = Excel.Type.EXPORT)
private BigDecimal usedNum;
/** 剩余数量 */
@Excel(name = "剩余数量")
@Excel(name = "剩余数量",type = Excel.Type.EXPORT)
private BigDecimal remainingNum;
/** 物料条码 */
@ -58,19 +58,19 @@ public class AppPmsOrderIn extends BaseEntity
private String goodsDesc;
/** 物料单位 */
@Excel(name = "物料单位")
@Excel(name = "物料单位",type = Excel.Type.EXPORT)
private String unit;
/** 预留1 */
@Excel(name = "预留1")
// @Excel(name = "预留1")
private String spare1;
/** 预留2 */
@Excel(name = "预留2")
// @Excel(name = "预留2")
private String spare2;
/** 订单状态 */
@Excel(name = "订单状态")
@Excel(name = "订单状态",type = Excel.Type.EXPORT)
private Integer orderStatus;
public void setListId(String listId)

View File

@ -65,4 +65,10 @@ public interface IAppPmsOrderInService
public int pmsStockInComplete(PmsStockInCompleteReq request);
/**
* 导入入库单数据
* @param appPmsOrderInList
* @return
*/
String importPmsOrderOut(List<AppPmsOrderIn> appPmsOrderInList);
}

View File

@ -1,24 +1,37 @@
package com.ruoyi.app.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import cn.hutool.core.collection.CollectionUtil;
import com.ruoyi.app.domain.AppGoods;
import com.ruoyi.app.domain.AppPendingStorage;
import com.ruoyi.app.domain.AppPmsOrderIn;
import com.ruoyi.app.domain.AppPmsOrderOut;
import com.ruoyi.app.domain.DTO.PmsInData;
import com.ruoyi.app.domain.DTO.PmsStockInCompleteReq;
import com.ruoyi.app.mapper.AppGoodsMapper;
import com.ruoyi.app.mapper.AppPendingStorageMapper;
import com.ruoyi.app.mapper.AppPmsOrderInMapper;
import com.ruoyi.app.service.IAppPmsOrderInService;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.OrderCodeFactory;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.javassist.compiler.ast.Variable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
/**
* 请填写功能名称Service业务层处理
*
@ -28,15 +41,18 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class AppPmsOrderInServiceImpl implements IAppPmsOrderInService
{
private static final Logger log = LoggerFactory.getLogger(AppPmsOrderInServiceImpl.class);
@Autowired
private AppPmsOrderInMapper appPmsOrderInMapper;
@Autowired
private AppPendingStorageMapper appPendingStorageMapper;
@Autowired
private AppGoodsMapper appGoodsMapper;
/**
* 查询请填写功能名称
*
* @param listId 请填写功能名称主键
* @param id 请填写功能名称主键
* @return 请填写功能名称
*/
@Override
@ -151,4 +167,56 @@ public class AppPmsOrderInServiceImpl implements IAppPmsOrderInService
}
return insertNum;
}
@Override
@Transactional
public String importPmsOrderOut(List<AppPmsOrderIn> appPmsOrderInList) {
if (CollectionUtil.isEmpty(appPmsOrderInList)) {
throw new ServiceException("导入入库订单数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (AppPmsOrderIn appPmsOrderIn : appPmsOrderInList) {
try {
String orderId= OrderCodeFactory.getOrderCode("RK", "");
appPmsOrderIn.setId(OrderCodeFactory.getOrderCode("",""));
appPmsOrderIn.setListId(orderId);
appPmsOrderIn.setOrderType(9);
appPmsOrderIn.setOrderId(UUID.randomUUID().toString());
appPmsOrderIn.setUsedNum(BigDecimal.ZERO);
appPmsOrderIn.setRemainingNum(appPmsOrderIn.getGoodsNum());
appPmsOrderIn.setOrderStatus(0);
appPmsOrderIn.setCreateTime(new Date());
appPmsOrderIn.setUpdateTime(new Date());
appPmsOrderIn.setCreateBy(getUsername());
appPmsOrderIn.setRemark("导入入库通知");
// 校验物料是否存在
AppGoods oldAppGoods = appGoodsMapper.selectAppGoodsByGoodsId(appPmsOrderIn.getGoodsId());
if (ObjectUtils.isEmpty(oldAppGoods)) {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、物料 " + appPmsOrderIn.getGoodsId() + " 不存在");
}
appPmsOrderInMapper.insertAppPmsOrderIn(appPmsOrderIn);
successNum++;
successMsg.append("<br/>" + successNum + "、入库订单 " + appPmsOrderIn.getGoodsId() + " 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、入库订单 " + appPmsOrderIn.getGoodsId() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}

View File

@ -19,6 +19,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
@ -118,9 +119,10 @@ public class AppPmsOrderOutServiceImpl implements IAppPmsOrderOutService
}
@Override
@Transactional
public String importPmsOrderOut(String id,String orderId,List<AppPmsOrderOut> appPmsOrderOutList, boolean isUpdateSupport) {
if (CollectionUtil.isEmpty(appPmsOrderOutList)) {
throw new ServiceException("导入库位数据不能为空!");
throw new ServiceException("导入出库订单数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
@ -139,23 +141,20 @@ public class AppPmsOrderOutServiceImpl implements IAppPmsOrderOutService
appPmsOrderOut.setTrNum(BigDecimal.ZERO);
appPmsOrderOut.setCreateBy(getUsername());
// 校验同一个订单号中的物料
AppPmsOrderOut query = new AppPmsOrderOut();
query.setOrderId(appPmsOrderOut.getOrderId());
AppGoods oldAppGoods = appGoodsMapper.selectAppGoodsById(appPmsOrderOut.getGoodsId());
// 校验物料是否存在
AppGoods oldAppGoods = appGoodsMapper.selectAppGoodsByGoodsId(appPmsOrderOut.getGoodsId());
if (ObjectUtils.isEmpty(oldAppGoods)) {
failureNum++;
failureMsg.append("<br/>" + failureNum + "、物料 " + appPmsOrderOut.getGoodsId() + " 不存在");
}
appPmsOrderOutMapper.insertAppPmsOrderOut(appPmsOrderOut);
successNum++;
successMsg.append("<br/>" + successNum + "库位 " + appPmsOrderOut.getGoodsId() + " 导入成功");
successMsg.append("<br/>" + successNum + "出库订单 " + appPmsOrderOut.getGoodsId() + " 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "库位 " + appPmsOrderOut.getGoodsId() + " 导入失败:";
String msg = "<br/>" + failureNum + "出库订单 " + appPmsOrderOut.getGoodsId() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}