#
修改
1. 任务列表修改
2. ASN执行状态修改
3. ASN扩展字段优化
4. 确认收货扩展字段优化
| | |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.task"} |
| | | empty={<EmptyData onClick={() => { }} />} |
| | | empty={false} |
| | | filters={filters} |
| | | sort={{ field: "sort", order: "desc" }} |
| | | actions={( |
| | |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | | </List> |
| | | {/* <TaskCreate |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | /> */} |
| | | <PageDrawer |
| | | title='Task Detail' |
| | | drawerVal={drawerVal} |
| | |
| | | const translate = useTranslate(); |
| | | return ( |
| | | <> |
| | | <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}> |
| | | <CardContent> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}> |
| | | <Typography variant="h6" gutterBottom align="left" sx={{ |
| | | maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' }, |
| | | whiteSpace: 'nowrap', |
| | | overflow: 'hidden', |
| | | textOverflow: 'ellipsis', |
| | | }}> |
| | | {Common.camelToPascalWithSpaces(translate('table.field.task.id'))}: {record.id} |
| | | </Typography> |
| | | {/* inherit, primary, secondary, textPrimary, textSecondary, error */} |
| | | <Typography variant="h6" gutterBottom align="right" > |
| | | ID: {record.id} |
| | | </Typography> |
| | | </Grid> |
| | | </Grid> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12} container alignContent="flex-end"> |
| | | <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}> |
| | | {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo} |
| | | </Typography> |
| | | </Grid> |
| | | </Grid> |
| | | <Box height={20}> </Box> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.taskCode" |
| | | property={record.taskCode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.taskStatus" |
| | | property={record.taskStatus} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.taskType" |
| | | property={record.taskType} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.orgLoc" |
| | | property={record.orgLoc} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.orgSite" |
| | | property={record.orgSite} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.targLoc" |
| | | property={record.targLoc} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.targSite" |
| | | property={record.targSite} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.barcode" |
| | | property={record.barcode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.robotCode" |
| | | property={record.robotCode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.exceStatus" |
| | | property={record.exceStatus} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.expDesc" |
| | | property={record.expDesc} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.sort" |
| | | property={record.sort} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.expCode" |
| | | property={record.expCode} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.startTime" |
| | | property={record.startTime$} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.task.endTime" |
| | | property={record.endTime$} |
| | | /> |
| | | </Grid> |
| | | <Box display="flex"> |
| | | <List |
| | | sx={{ |
| | | flexGrow: 1, |
| | | transition: (theme) => |
| | | theme.transitions.create(['all'], { |
| | | duration: theme.transitions.duration.enteringScreen, |
| | | }), |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.taskItem"} |
| | | empty={false} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */} |
| | | <SelectColumnsButton preferenceKey='taskItem' /> |
| | | {/* <MyExportButton /> */} |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='taskItem' |
| | | // bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | rowClick={(id, resource, record) => false} |
| | | // expand={() => <TaskItemPanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'taskId', 'orderId', 'orderItemId', 'matnrId']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <NumberField source="taskId" label="table.field.taskItem.taskId" /> |
| | | <NumberField source="orderId" label="table.field.taskItem.orderId" /> |
| | | <NumberField source="orderType$" label="table.field.taskItem.orderType" /> |
| | | <NumberField source="orderItemId" label="table.field.taskItem.orderItemId" /> |
| | | <NumberField source="matnrId" label="table.field.taskItem.matnrId" /> |
| | | <TextField source="maktx" label="table.field.taskItem.maktx" /> |
| | | <TextField source="matnrCode" label="table.field.taskItem.matnrCode" /> |
| | | <TextField source="unit" label="table.field.taskItem.unit" /> |
| | | <NumberField source="anfme" label="table.field.taskItem.anfme" /> |
| | | <TextField source="batch" label="table.field.taskItem.batch" /> |
| | | <TextField source="spec" label="table.field.taskItem.spec" /> |
| | | <TextField source="model" label="table.field.taskItem.model" /> |
| | | |
| | | </Grid> |
| | | </CardContent> |
| | | </Card > |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime /> |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="createTime" label="common.field.createTime" showTime /> |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | </StyledDatagrid> |
| | | </List> |
| | | <PageDrawer |
| | | title='TaskItem Detail' |
| | | drawerVal={drawerVal} |
| | | setDrawerVal={setDrawerVal} |
| | | > |
| | | </PageDrawer> |
| | | </Box> |
| | | </> |
| | | ); |
| | | }; |
| | |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.taskItem"} |
| | | empty={false} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("hasAuthority('manager:warehouseAreas:save')") |
| | | @PostMapping("/orders/confirm") |
| | | @ApiOperation("确认收货") |
| | | public R confirmReceipt(@RequestBody ReceiptParams params) { |
| | | public R confirmReceipt(@RequestBody Map<String, Object> params) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("请求参数不能为空!!"); |
| | | } |
| | |
| | | @ApiModelProperty("供应商编码") |
| | | private String splrCode; |
| | | |
| | | @ApiModelProperty("扩展字段索引") |
| | | private String fieldsIndex; |
| | | |
| | | @ApiModelProperty("扩展字段") |
| | | private Map<String, Object> extendFields; |
| | | |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | |
| | | R getOrderByCode(String barcode); |
| | | |
| | | R receiptToWarehouse(ReceiptParams orders); |
| | | R receiptToWarehouse(Map<String, Object> orders); |
| | | |
| | | R otherReceipt(OtherReceiptParams params); |
| | | |
| | |
| | | package com.vincent.rsf.server.api.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | |
| | | import com.vincent.rsf.server.common.enums.WarehouseAreaType; |
| | | import com.vincent.rsf.server.common.security.JwtSubject; |
| | | import com.vincent.rsf.server.common.utils.CommonUtil; |
| | | import com.vincent.rsf.server.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.common.utils.JSONUtil; |
| | | import com.vincent.rsf.server.common.utils.JwtUtil; |
| | | import com.vincent.rsf.server.manager.controller.params.IsptItemsParams; |
| | | import com.vincent.rsf.server.manager.controller.params.WaitPakinParam; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.mapper.*; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.system.constant.CodeRes; |
| | |
| | | import com.vincent.rsf.server.system.mapper.UserMapper; |
| | | import com.vincent.rsf.server.system.service.FieldsItemService; |
| | | import com.vincent.rsf.server.system.service.UserLoginService; |
| | | import com.vincent.rsf.server.system.utils.ExtendFieldsUtils; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R receiptToWarehouse(ReceiptParams params) { |
| | | if (params.getReceipts().isEmpty()) { |
| | | public R receiptToWarehouse(Map<String, Object> params) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | ReceiptParams receiptParam = JSONObject.parseObject(JSONObject.toJSONString(params), ReceiptParams.class); |
| | | if (receiptParam.getReceipts().isEmpty()) { |
| | | throw new CoolException("收货明细不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getWhAreaId())) { |
| | | if (Objects.isNull(receiptParam.getWhAreaId())) { |
| | | throw new CoolException("库区标识不能为空!!"); |
| | | } |
| | | |
| | | WarehouseAreas areasItem = warehouseAreasService.getOne(new LambdaQueryWrapper<WarehouseAreas>() |
| | | .eq(WarehouseAreas::getId, params.getWhAreaId())); |
| | | .eq(WarehouseAreas::getId, receiptParam.getWhAreaId())); |
| | | if (Objects.isNull(areasItem)) { |
| | | throw new CoolException("数据错误:当前库区不存在!!"); |
| | | } |
| | | //获取已启用的动态扩展字 |
| | | List<Fields> fields = fieldsMapper.selectList(new LambdaQueryWrapper<Fields>() |
| | | .eq(Fields::getFlagEnable, 1) |
| | | .eq(Fields::getStatus, 1)); |
| | | |
| | | List<ReceiptDetlsDto> receipts = params.getReceipts(); |
| | | List<ReceiptDetlsDto> receipts = receiptParam.getReceipts(); |
| | | List<WarehouseAreasItem> allOrders = new ArrayList<>(); |
| | | |
| | | Double receiptQty = receipts.stream().mapToDouble(ReceiptDetlsDto::getReceiptQty).sum(); |
| | |
| | | if (Objects.isNull(asnOrder)) { |
| | | throw new CoolException("数据错误:主单不存在!!"); |
| | | } |
| | | /**收货数量累加,1. 会出超收情况 2. 会有收货不足情况*/ |
| | | //TODO /**收货数量累加,1. 会出超收情况 2. 会有收货不足情况*/ |
| | | Double rcptedQty = asnOrder.getQty() + receiptQty; |
| | | asnOrder.setQty(rcptedQty); |
| | | asnOrder.setQty(rcptedQty).setExceStatus(Short.parseShort(AsnExceStatus.ASN_EXCE_STATUS_EXCE_ING.val)); |
| | | |
| | | if (!asnOrderMapper.updateById(asnOrder)) { |
| | | throw new CoolException("已收货数量修改失败!!"); |
| | | } |
| | | |
| | | receipts.forEach(dto -> { |
| | | List<Map<String, Object>> receipts1 = (List<Map<String, Object>>) params.get("receipts"); |
| | | for (Map<String, Object> rcpt : receipts1) { |
| | | if (Objects.isNull(rcpt)) {continue;} |
| | | ReceiptDetlsDto dto = JSONObject.parseObject(JSONObject.toJSONString(rcpt), ReceiptDetlsDto.class); |
| | | Matnr matnr = matnrMapper.selectById(dto.getMatnrId()); |
| | | if (Objects.isNull(matnr)) { |
| | | throw new CoolException("数据错误:当前物料不存在!!"); |
| | |
| | | if (Objects.isNull(dto.getReceiptQty())) { |
| | | throw new CoolException("收货数据不能为空!!"); |
| | | } |
| | | if (dto.getReceiptQty().compareTo(dto.getAnfme()) > 0) { |
| | | throw new CoolException("收货数量不能大于采购数量!!"); |
| | | } |
| | | |
| | | // if (dto.getReceiptQty().compareTo(dto.getAnfme()) > 0) { |
| | | // throw new CoolException("收货数量不能大于采购数量!!"); |
| | | // } |
| | | AsnOrderItem orderItem = asnOrderItemMapper.selectOne(new LambdaQueryWrapper<AsnOrderItem>() |
| | | .eq(AsnOrderItem::getAsnCode, asnCode) |
| | | .eq(AsnOrderItem::getMatnrId, dto.getMatnrId())); |
| | | if (Objects.isNull(orderItem)) { |
| | | throw new CoolException("通知单明细不存在!!"); |
| | | } |
| | | // if (Objects.isNull(dto.getReceiptQty()) || Double.compare(dto.getReceiptQty(), 0.0) == 0) { |
| | | // throw new CoolException("收货数量不能为零!!"); |
| | | // } |
| | | if (Objects.isNull(dto.getReceiptQty()) || Double.compare(dto.getReceiptQty(), 0.0) == 0) { |
| | | throw new CoolException("收货数量不能为零!!"); |
| | | } |
| | | Double itemRcptQty = dto.getReceiptQty() + orderItem.getQty(); |
| | | orderItem.setQty(itemRcptQty) |
| | | .setSplrBatch(dto.getSplrBatch()) |
| | | .setStockUnit(dto.getStockUnit()) |
| | | .setProdTime(dto.getProdTime()); |
| | | |
| | | if (!Objects.isNull(fields)) { |
| | | if (!Objects.isNull(dto.getExtendFields())) { |
| | | //获取16位uuid |
| | | String uuid16 = CommonUtil.randomUUID16(); |
| | | Map<String, Object> extendFields = dto.getExtendFields(); |
| | | //字段集合申明 |
| | | List<FieldsItem> fieldsItems = new ArrayList<>(); |
| | | extendFields.keySet().forEach(key -> { |
| | | fields.forEach(obj -> { |
| | | //判断key值与fields表字段是否相同 |
| | | if (obj.getFields().equals(key)) { |
| | | FieldsItem fieldsItem = new FieldsItem(); |
| | | fieldsItem.setMatnrId(matnr.getId()).setFieldsId(obj.getId()) |
| | | .setShiperId(matnr.getShipperId()) |
| | | .setValue(extendFields.get(key).toString()) |
| | | .setUuid(uuid16); |
| | | fieldsItems.add(fieldsItem); |
| | | } |
| | | }); |
| | | }); |
| | | if (!fieldsItemService.saveBatch(fieldsItems)) { |
| | | throw new CoolException("扩展字段保存失败!!"); |
| | | if (!Objects.isNull(rcpt)) { |
| | | try { |
| | | if (Objects.isNull(rcpt.get("fieldsindex")) || StringUtils.isBlank(rcpt.get("fieldsindex").toString())) { |
| | | //获取16位uuid |
| | | String uuid16 = CommonUtil.randomUUID16(); |
| | | rcpt.put("index", uuid16); |
| | | orderItem.setFieldsIndex(uuid16); |
| | | } |
| | | orderItem.setFieldsIndex(uuid16); |
| | | //保存或更新扩展字段 |
| | | FieldsUtils.updateFieldsValue(rcpt); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | // if (Objects.isNull(dto.getProdTime())) { |
| | | // format = dateFormat.format(dto.getProdTime()); |
| | | // } |
| | | item.setBarcode(dto.getBarcode()) |
| | | item.setTrackCode(dto.getBarcode()) |
| | | .setAreaName(areasItem.getName()) |
| | | .setAreaId(areasItem.getId()) |
| | | .setAsnItemId(orderItem.getId()) |
| | | .setAsnCode(asnOrder.getCode()) |
| | | .setAsnId(asnOrder.getId()) |
| | | .setProdTime(dto.getProdTime()) |
| | | .setWeight(dto.getWeigth()) |
| | | .setStockUnit(dto.getStockUnit()) |
| | | .setBatch(SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_RECEIPT_BATCH, dto)) |
| | | .setAnfme(itemRcptQty) |
| | | .setSplrBtch(dto.getSplrBatch()) |
| | | .setSplrBatch(dto.getSplrBatch()) |
| | | .setMatnrCode(matnr.getCode()) |
| | | .setMatnrId(matnr.getId()) |
| | | .setMatnrName(matnr.getName()) |
| | |
| | | .setWeight(matnr.getWeight()) |
| | | .setFieldsIndex(orderItem.getFieldsIndex()) |
| | | .setShipperId(matnr.getShipperId()); |
| | | //TODO 供应商标识未设置,标识由PO单供应商编码转换 |
| | | |
| | | //TODO 供应商标识未设置,标识由PO单供应商编码转换 |
| | | |
| | | allOrders.add(item); |
| | | }); |
| | | } |
| | | |
| | | if (!warehouseAreasItemService.saveBatch(allOrders)) { |
| | | throw new CoolException("收货失败!!"); |
| | |
| | | |
| | | @Override |
| | | public R getDeltByCode(String code) { |
| | | return R.ok(asnOrderItemMapper.selectOne(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getTrackCode, code))); |
| | | return R.ok(warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>().eq(WarehouseAreasItem::getTrackCode, code))); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | detlsDto.setAsnCode(asnOrderItem.getAsnCode()) |
| | | .setMaktx(asnOrderItem.getMaktx()) |
| | | .setFieldsIndex(asnOrderItem.getFieldsIndex()) |
| | | .setBarcode(asnOrderItem.getTrackCode()) |
| | | .setQty(asnOrderItem.getQty()) |
| | | .setPoCode(asnOrderItem.getPoCode()) |
| | |
| | | detlsDto.setPlatformId(purchaseItem.getPlatItemId()); |
| | | } |
| | | } |
| | | |
| | | detlsDtos.add(detlsDto); |
| | | }); |
| | | |
| | |
| | | import com.vincent.rsf.server.system.entity.FieldsItem; |
| | | import com.vincent.rsf.server.system.service.FieldsItemService; |
| | | import com.vincent.rsf.server.system.service.FieldsService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | * @author Ryan |
| | | * @description 通过字段唯一标识获取动态字段对象key-value |
| | | * @param |
| | | * @return |
| | | * @return 扩展字段对象 |
| | | * @time 2025/3/12 12:50 |
| | | */ |
| | | public static Map<String, String> getFields(String uuid) { |
| | |
| | | return fieldsMap; |
| | | } |
| | | |
| | | public static void mergeFields(Map<String, Object> fileds ,String uuid) { |
| | | /** |
| | | * @author Ryan |
| | | * @description 获取集合扩展字段key-value值 |
| | | * @param |
| | | * @return 包含扩展字段的集合对象 |
| | | * @time 2025/3/15 15:05 |
| | | */ |
| | | public static List<Map<String, Object>> getExtendFields(List<Map<String, Object>> params) { |
| | | FieldsService fieldsService = SpringUtils.getBean(FieldsService.class); |
| | | List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getFlagEnable, 1).eq(Fields::getStatus, 1)); |
| | | if (fields.isEmpty()) { |
| | | return; |
| | | } |
| | | List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>() |
| | | .eq(Fields::getStatus, 1) |
| | | .eq(Fields::getFlagEnable, 1)); |
| | | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | List<FieldsItem> fieldsItems = fieldsItemService.list(new LambdaQueryWrapper<FieldsItem>().eq(FieldsItem::getUuid, uuid)); |
| | | for (Fields field : fields ) { |
| | | if (fieldsItems.isEmpty()) { |
| | | fileds.put(field.getFields(), null); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Map<String, Object> param : params) { |
| | | result.add(param); |
| | | if (Objects.isNull(param.get("fieldsIndex"))) { |
| | | continue; |
| | | } |
| | | fieldsItems.forEach(fieldsItem -> { |
| | | if (fieldsItem.getFieldsId().equals(field.getId())) { |
| | | fileds.put(field.getFields(), fieldsItem.getValue()); |
| | | List<FieldsItem> itemList = fieldsItemService |
| | | .list(new LambdaQueryWrapper<FieldsItem>() |
| | | .eq(FieldsItem::getUuid, param.get("fieldsIndex"))); |
| | | if (itemList.isEmpty()) { |
| | | continue; |
| | | } |
| | | fields.forEach(fds -> { |
| | | for (FieldsItem fieldsItem : itemList) { |
| | | if (!Objects.isNull(fieldsItem.getFieldsId()) && fieldsItem.getFieldsId().equals(fds.getId())) { |
| | | param.put(fds.getFields(), fieldsItem.getValue()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param template |
| | | * @return |
| | |
| | | * @description 动态字段value保存 |
| | | * @time 2025/3/18 15:00 |
| | | */ |
| | | public static void saveFields(Map<String, ?> template, String uuid) throws Exception{ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public static boolean saveFields(Map<String, ?> template, String uuid) throws Exception{ |
| | | List<Fields> fields = getFieldsSta(); |
| | | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | if (fields.isEmpty()) { |
| | | throw new CoolException("扩展字段不存在!!"); |
| | | } |
| | | List<FieldsItem> fieldsItems = new ArrayList<>(); |
| | | for (Fields field : fields) { |
| | | if (!Objects.isNull(template.get(field.getFields()))) { |
| | | FieldsItem item = new FieldsItem(); |
| | | item.setFieldsId(field.getId()) |
| | | .setUuid(uuid) |
| | | .setValue(template.get(field.getFields()).toString()); |
| | | fieldsItems.add(item); |
| | | if (!fields.isEmpty()) { |
| | | for (Fields obj : fields) { |
| | | if (!Objects.isNull(template.get(obj.getFields())) && StringUtils.isNotBlank(template.get(obj.getFields()).toString())) { |
| | | FieldsItem item = new FieldsItem(); |
| | | item.setUuid(uuid) |
| | | .setValue(template.get(obj.getFields()).toString()) |
| | | .setMatnrId(Long.parseLong(template.get("matnrId").toString())) |
| | | .setFieldsId(obj.getId()); |
| | | fieldsItems.add(item); |
| | | } |
| | | } |
| | | if (fieldsItems.isEmpty()) { |
| | | return false; |
| | | } |
| | | if (!fieldsItemService.saveBatch(fieldsItems)) { |
| | | throw new CoolException("扩展字段保存失败!!"); |
| | | } |
| | | return true; |
| | | } |
| | | if (!fieldsItemService.saveBatch(fieldsItems)) { |
| | | throw new CoolException("动态字段值保存失败!!"); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | return fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getStatus, 1).eq(Fields::getFlagEnable, 1)); |
| | | } |
| | | |
| | | public static void updateFieldsValue(Map<String, Object> params) throws Exception{ |
| | | /** |
| | | * @author Ryan |
| | | * @description 动态字段修改 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/7 15:28 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public static void updateFieldsValue(Map<String, Object> params) throws Exception { |
| | | List<Fields> fields = getFieldsSta(); |
| | | if (fields.isEmpty()) { return; } |
| | | Object fieldsIndex = params.get("fieldsIndex"); |
| | | if (!Objects.isNull(fieldsIndex)) { |
| | | if (!Objects.isNull(fieldsIndex) && StringUtils.isNotBlank(fieldsIndex.toString())) { |
| | | String index = fieldsIndex.toString(); |
| | | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | for (Fields field : fields) { |
| | |
| | | FieldsItem item = new FieldsItem(); |
| | | item.setUuid(index) |
| | | .setFieldsId(field.getId()) |
| | | .setMatnrId(Long.parseLong(params.get("matnrId").toString())) |
| | | .setValue(params.get(field.getFields()).toString()); |
| | | if (!fieldsItemService.save(item)) { |
| | | throw new CoolException("扩展字段修改失败!!"); |
| | |
| | | package com.vincent.rsf.server.common.utils; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.ObjectWriter; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * JSON解析工具类 |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | @PostMapping("/asnOrder/items/save") |
| | | @ApiOperation("保存主单及明细") |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:save')") |
| | | public R orderAndItem(@RequestBody AsnOrderAndItemsParams params) { |
| | | public R orderAndItem(@RequestBody AsnOrderAndItemsParams params) throws Exception { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | |
| | | return asnOrderService.saveOrderAndItems(params, getLoginUserId()); |
| | | } |
| | | |
| | | @ApiOperation("单据信息修改") |
| | | @PostMapping("/asnOrder/items/update") |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:update')") |
| | | public R orderAndrItemUpdate(@RequestBody AsnOrderAndItemsParams params) { |
| | | public R orderAndrItemUpdate(@RequestBody AsnOrderAndItemsParams params) throws Exception { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | |
| | | @ApiModelProperty(value= "仓库区域") |
| | | private Long areaId; |
| | | |
| | | @ApiModelProperty("单据ID") |
| | | private Long asnId; |
| | | |
| | | @ApiModelProperty("单据编码") |
| | | private String asnCode; |
| | | |
| | | @ApiModelProperty("单据明细ID") |
| | | private Long asnItemId; |
| | | |
| | | /** |
| | | * 区域名称 |
| | | */ |
| | |
| | | /** |
| | | * 条形码 |
| | | */ |
| | | @ApiModelProperty(value= "条形码") |
| | | private String barcode; |
| | | @ApiModelProperty(value= "物料跟踪码") |
| | | private String trackCode; |
| | | |
| | | /** |
| | | * 数量 |
| | |
| | | * 供应商批次 |
| | | */ |
| | | @ApiModelProperty(value= "供应商批次") |
| | | private String splrBtch; |
| | | private String splrBatch; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 冻结 |
| | |
| | | |
| | | public WarehouseAreasItem() {} |
| | | |
| | | public WarehouseAreasItem(Long areaId,String areaName,Long matnrId,String matnrName,String matnrCode,String barcode,Double anfme,String batch,String unit,String stockUnit,String brand,Long shipperId,String splrId,Double weight,String prodTime,String splrBtch,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | public WarehouseAreasItem(Long areaId,String areaName,Long matnrId,String matnrName,String matnrCode,String trackCode,Double anfme,String batch,String unit,String stockUnit,String brand,Long shipperId,String splrId,Double weight,String prodTime,String splrBtch,Integer status,Integer deleted,Integer tenantId,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | | this.areaId = areaId; |
| | | this.areaName = areaName; |
| | | this.matnrId = matnrId; |
| | | this.matnrName = matnrName; |
| | | this.matnrCode = matnrCode; |
| | | this.barcode = barcode; |
| | | this.trackCode = trackCode; |
| | | this.anfme = anfme; |
| | | this.batch = batch; |
| | | this.unit = unit; |
| | |
| | | this.splrId = splrId; |
| | | this.weight = weight; |
| | | this.prodTime = prodTime; |
| | | this.splrBtch = splrBtch; |
| | | this.splrBatch = splrBtch; |
| | | this.status = status; |
| | | this.deleted = deleted; |
| | | this.tenantId = tenantId; |
New file |
| | |
| | | package com.vincent.rsf.server.manager.enums; |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @version 1.0 |
| | | * @title PakinIOStatus |
| | | * @description |
| | | * @create 2025/4/7 08:48 |
| | | */ |
| | | public enum AsnExceStatus { |
| | | |
| | | //质检状态 |
| | | ASN_EXCE_STATUS_UN_EXCE("0", "未执行"), |
| | | ASN_EXCE_STATUS_EXCE_ING("1", "执行中"), |
| | | ASN_EXCE_STATUS_TASK_DONE("2", "已完成"), |
| | | ASN_EXCE_STATUS_TASK_CANCEL("3", "取消"), |
| | | ASN_EXCE_STATUS_TASK_CLOSE("4", "已关闭") |
| | | ; |
| | | AsnExceStatus(String val, String desc) { |
| | | this.val = val; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public String val; |
| | | public String desc; |
| | | |
| | | } |
| | |
| | | //质检状态 |
| | | PAKIN_IO_STATUS_HOLD("0", "待入库"), |
| | | QLY_ISPT_STAS_DONE("1", "组拖完成"), |
| | | QLY_ISPT_STAS_TASK_EXCE("2", "任务执行中"), |
| | | QLY_ISPT_STAS_TASK_DONE("3", "任务完成") |
| | | PAKIN_IO_STATUS_TASK_EXCE("2", "任务执行中"), |
| | | PAKIN_IO_STATUS_TASK_DONE("3", "任务完成") |
| | | ; |
| | | |
| | | PakinIOStatus(String val, String desc) { |
| | |
| | | |
| | | List<AsnOrder> getListByMatnr(Map<String, String> params); |
| | | |
| | | R saveOrderAndItems(AsnOrderAndItemsParams params, Long loginUserId); |
| | | R saveOrderAndItems(AsnOrderAndItemsParams params, Long loginUserId) throws Exception; |
| | | |
| | | R updateOrderItem(AsnOrderAndItemsParams params, Long loginUserId); |
| | | R updateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) throws Exception; |
| | | |
| | | boolean batchUpdate(BatchUpdateParam params, Long loginUserId); |
| | | |
| | |
| | | import com.vincent.rsf.server.api.service.ReportMsgService; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.common.utils.CommonUtil; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.utils.FieldsUtils; |
| | | import com.vincent.rsf.server.manager.controller.params.BatchUpdateParam; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; |
| | |
| | | return R.ok("操作成功!!"); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description ASN明细单据保存,及扩展字段保存 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/7 09:59 |
| | | */ |
| | | @Override |
| | | public boolean fieldsSave(Map<String, Object> params) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean fieldsSave(Map<String, Object> params){ |
| | | AsnOrderItem asnOrderItem = JSONObject.parseObject(JSONObject.toJSONString(params), AsnOrderItem.class); |
| | | if (StringUtils.isBlank(asnOrderItem.getTrackCode())) { |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_LABEL_CODE, asnOrderItem); |
| | | asnOrderItem.setTrackCode(ruleCode); |
| | | } |
| | | if (!this.saveOrUpdate(asnOrderItem)) { |
| | | throw new CoolException("收货通知单明细保存失败!!"); |
| | | if (Objects.isNull(asnOrderItem.getAnfme()) || Double.compare(asnOrderItem.getAnfme(), 0.0) <= 0) { |
| | | throw new CoolException("计划收货数不能为空!!"); |
| | | } |
| | | //保存扩展字段 |
| | | try { |
| | | ExtendFieldsUtils.saveFields(params); |
| | | String uuid16 = CommonUtil.randomUUID16(); |
| | | Boolean fields = FieldsUtils.saveFields(params, uuid16); |
| | | if (fields) { |
| | | asnOrderItem.setFieldsIndex(uuid16); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (!this.saveOrUpdate(asnOrderItem)) { |
| | | throw new CoolException("收货通知单明细保存失败!!"); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | if (hsahMap.getRecords().isEmpty()) { |
| | | return hsahMap.setRecords(new ArrayList<>()); |
| | | } |
| | | hsahMap.setRecords(ExtendFieldsUtils.getExtendFields(hsahMap.getRecords())); |
| | | hsahMap.setRecords(FieldsUtils.getExtendFields(hsahMap.getRecords())); |
| | | return hsahMap; |
| | | |
| | | } |
| | |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItemLog; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderLog; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.mapper.AsnOrderMapper; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.mapper.PurchaseMapper; |
| | |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.mapper.SerialRuleMapper; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R saveOrderAndItems(AsnOrderAndItemsParams params, Long loginUserId) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R saveOrderAndItems(AsnOrderAndItemsParams params, Long loginUserId) throws Exception { |
| | | if (Objects.isNull(params.getOrders())) { |
| | | throw new CoolException("主单信息不能为空"); |
| | | } |
| | |
| | | if (params.getItems().isEmpty()) { |
| | | throw new CoolException("收货通知单明细不能为寒食节!!"); |
| | | } |
| | | params.getItems().forEach(item -> { |
| | | item.put("asnId", orders.getId()); |
| | | item.put("asnCode", orders.getCode()); |
| | | item.put("poCode", orders.getPoCode()); |
| | | item.put("createBy", loginUserId); |
| | | item.put("updateBy", loginUserId); |
| | | if (!asnOrderItemService.fieldsSave(item)) { |
| | | throw new CoolException("明细保存失败!!"); |
| | | } |
| | | }); |
| | | |
| | | svaeOrUpdateOrderItem(params,loginUserId); |
| | | |
| | | return R.ok("保存成功!!"); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public R updateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) { |
| | | if (Objects.isNull(params.getOrders())) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R updateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) throws Exception { |
| | | AsnOrder orders = params.getOrders(); |
| | | if (Objects.isNull(orders)) { |
| | | throw new CoolException("主单信息不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getOrders().getId())) { |
| | | if (Objects.isNull(orders.getId())) { |
| | | throw new CoolException("数据错误:单据ID不能为空!!"); |
| | | } |
| | | if (!this.updateById(params.getOrders())) { |
| | | if (!this.updateById(orders)) { |
| | | throw new CoolException("主单修改失败!!"); |
| | | } |
| | | if (Objects.isNull(params.getItems()) || params.getItems().isEmpty()) { |
| | | return R.ok("修改完成!!"); |
| | | return R.ok("明细参数不能为空!!"); |
| | | } |
| | | List<Map<String, Object>> items = params.getItems(); |
| | | List<AsnOrderItem> asnOrderItems = JSONArray.parseArray(JSONArray.toJSONString(items), AsnOrderItem.class); |
| | | if (!asnOrderItemService.saveOrUpdateBatch(asnOrderItems)) { |
| | | throw new CoolException("明细修改失败!!"); |
| | | } |
| | | |
| | | svaeOrUpdateOrderItem(params,loginUserId); |
| | | |
| | | return R.ok("修改完成!!"); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 更新或保存明细 |
| | | * @param |
| | | * @return |
| | | * @time 2025/4/7 13:28 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | private void svaeOrUpdateOrderItem(AsnOrderAndItemsParams params, Long loginUserId) throws Exception{ |
| | | AsnOrder orders = params.getOrders(); |
| | | |
| | | params.getItems().forEach(item -> { |
| | | item.put("asnId", orders.getId()); |
| | | item.put("asnCode", orders.getCode()); |
| | | item.put("poCode", orders.getPoCode()); |
| | | item.put("createBy", loginUserId); |
| | | item.put("updateBy", loginUserId); |
| | | if (!asnOrderItemService.fieldsSave(item)) { |
| | | throw new CoolException("明细保存失败!!"); |
| | | } |
| | | }); |
| | | List<AsnOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>() |
| | | .eq(AsnOrderItem::getAsnId, params.getOrders().getId())); |
| | | double sum = orderItems.stream().mapToDouble(AsnOrderItem::getAnfme).sum(); |
| | | orders.setAnfme(sum); |
| | | if (!this.updateById(orders)) { |
| | | throw new CoolException("计划收货数量修改失败!!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | if (Objects.isNull(asrder) || Objects.isNull(asrder.getId())) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(asrder.getAnfme()) || asrder.getAnfme().compareTo(0.00) == 0) { |
| | | throw new CoolException("收货数量不能为零!!"); |
| | | } |
| | | AsnOrder order = this.getById(asrder.getId()); |
| | | AsnOrderLog orderLog = new AsnOrderLog(); |
| | | order.setExceStatus(Short.valueOf("2")); |
| | | order.setExceStatus(Short.parseShort(AsnExceStatus.ASN_EXCE_STATUS_TASK_DONE.val)); |
| | | BeanUtils.copyProperties(order, orderLog); |
| | | orderLog.setId(null); |
| | | orderLog.setAsnId(order.getId()); |
| | |
| | | if (!this.saveOrUpdate(order)) { |
| | | throw new CoolException("状态修改失败!!"); |
| | | } |
| | | orderLog.setExceStatus(Short.parseShort(AsnExceStatus.ASN_EXCE_STATUS_TASK_CLOSE.val)); |
| | | if (!asnOrderLogService.save(orderLog)) { |
| | | throw new CoolException("主单历史档添加失败!!"); |
| | | } |
| | |
| | | } |
| | | //获取动态字段,并保存明细内容 |
| | | if (!FieldsUtils.getFieldsSta().isEmpty()) { |
| | | String uuid = CommonUtil.randomUUID16(); |
| | | matnr.setFieldsIndex(uuid); |
| | | //保存物料扩展属性值 |
| | | try { |
| | | FieldsUtils.saveFields(template, uuid); |
| | | String uuid = CommonUtil.randomUUID16(); |
| | | boolean b = FieldsUtils.saveFields(template, uuid); |
| | | if (b) { |
| | | matnr.setFieldsIndex(uuid); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | .in(WaitPakin::getId, ids) |
| | | .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.QLY_ISPT_STAS_DONE.val))); |
| | | if (waitPakins.isEmpty()) { |
| | | throw new CoolException("组拖信息不存在!!"); |
| | | throw new CoolException("请检查组拖状态是否完成!!"); |
| | | } |
| | | waitPakins.forEach(pakin -> { |
| | | List<TaskItem> taskItems = new ArrayList<>(); |
| | |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) { |
| | | throw new CoolException("库位预约失败!!"); |
| | | } |
| | | |
| | | /**获取组拖明细**/ |
| | | List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId())); |
| | | if (waitPakinItems.isEmpty()) { |
| | |
| | | } |
| | | }); |
| | | |
| | | waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() |
| | | .in(WaitPakin::getId, ids) |
| | | .set(WaitPakin::getIoStatus, PakinIOStatus.QLY_ISPT_STAS_TASK_EXCE.val)); |
| | | if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() |
| | | .in(WaitPakin::getId, ids) |
| | | .set(WaitPakin::getUpdateBy, loginUserId) |
| | | .set(WaitPakin::getCreateBy, loginUserId) |
| | | .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) { |
| | | throw new CoolException("组拖状态修改失败!!"); |
| | | } |
| | | return R.ok("任务生成完毕!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 完成任务 |
| | |
| | | import com.vincent.rsf.server.system.entity.FieldsItem; |
| | | import com.vincent.rsf.server.system.service.FieldsItemService; |
| | | import com.vincent.rsf.server.system.service.FieldsService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | */ |
| | | public class ExtendFieldsUtils { |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 明细单据保存扩展字段 |
| | | * @param |
| | | * @return |
| | | * @time 2025/3/15 13:36 |
| | | */ |
| | | public static Boolean saveFields(Map<String, Object> params) throws Exception{ |
| | | FieldsService fieldsService = SpringUtils.getBean(FieldsService.class); |
| | | List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>() |
| | | .eq(Fields::getStatus, 1) |
| | | .eq(Fields::getFlagEnable, 1)); |
| | | List<FieldsItem> fieldsItems = new ArrayList<>(); |
| | | if (!fields.isEmpty()) { |
| | | String uuid16 = CommonUtil.randomUUID16(); |
| | | for (Fields obj : fields) { |
| | | if (!Objects.isNull(params.get(obj.getFields()))) { |
| | | FieldsItem item = new FieldsItem(); |
| | | item.setUuid(uuid16) |
| | | .setValue(params.get(obj.getFields()).toString()) |
| | | .setMatnrId(Long.parseLong(params.get("matnrId").toString())) |
| | | .setFieldsId(obj.getId()); |
| | | fieldsItems.add(item); |
| | | } |
| | | params.put("fieldsIndex", uuid16); |
| | | } |
| | | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | if (!fieldsItemService.saveBatch(fieldsItems)) { |
| | | throw new CoolException("单据明细扩展字段保存失败!!"); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | // /** |
| | | // * @author Ryan |
| | | // * @description 明细单据保存扩展字段 |
| | | // * @param |
| | | // * @return |
| | | // * @time 2025/3/15 13:36 |
| | | // */ |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | // public static Boolean saveFields(Map<String, Object> params, String uuid) throws Exception{ |
| | | // FieldsService fieldsService = SpringUtils.getBean(FieldsService.class); |
| | | // List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>() |
| | | // .eq(Fields::getStatus, 1) |
| | | // .eq(Fields::getFlagEnable, 1)); |
| | | // List<FieldsItem> fieldsItems = new ArrayList<>(); |
| | | // if (!fields.isEmpty()) { |
| | | // for (Fields obj : fields) { |
| | | // if (!Objects.isNull(params.get(obj.getFields())) && StringUtils.isNotBlank(params.get(obj.getFields()).toString())) { |
| | | // FieldsItem item = new FieldsItem(); |
| | | // item.setUuid(uuid) |
| | | // .setValue(params.get(obj.getFields()).toString()) |
| | | // .setMatnrId(Long.parseLong(params.get("matnrId").toString())) |
| | | // .setFieldsId(obj.getId()); |
| | | // fieldsItems.add(item); |
| | | // } |
| | | // } |
| | | // if (fieldsItems.isEmpty()) { |
| | | // return false; |
| | | // } |
| | | // FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | // if (!fieldsItemService.saveBatch(fieldsItems)) { |
| | | // throw new CoolException("扩展字段保存失败!!"); |
| | | // } |
| | | // return true; |
| | | // } |
| | | // return false; |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @description 获取扩展字段key-value值 |
| | | * @param |
| | | * @return |
| | | * @time 2025/3/15 15:05 |
| | | */ |
| | | public static List<Map<String, Object>> getExtendFields(List<Map<String, Object>> params) { |
| | | FieldsService fieldsService = SpringUtils.getBean(FieldsService.class); |
| | | List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>() |
| | | .eq(Fields::getStatus, 1) |
| | | .eq(Fields::getFlagEnable, 1)); |
| | | FieldsItemService fieldsItemService = SpringUtils.getBean(FieldsItemService.class); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Map<String, Object> param : params) { |
| | | result.add(param); |
| | | if (Objects.isNull(param.get("fieldsIndex"))) { |
| | | continue; |
| | | } |
| | | List<FieldsItem> itemList = fieldsItemService |
| | | .list(new LambdaQueryWrapper<FieldsItem>() |
| | | .eq(FieldsItem::getUuid, param.get("fieldsIndex"))); |
| | | if (itemList.isEmpty()) { |
| | | continue; |
| | | } |
| | | fields.forEach(fds -> { |
| | | for (FieldsItem fieldsItem : itemList) { |
| | | if (!Objects.isNull(fieldsItem.getFieldsId()) && fieldsItem.getFieldsId().equals(fds.getId())) { |
| | | param.put(fds.getFields(), fieldsItem.getValue()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | } |