盘点入库
This commit is contained in:
parent
191d5d3e00
commit
db9e2eba2b
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.bonus.sgzb.material.config;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回异常枚举类
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/3/29 14:43
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum ExceptionEnum {
|
||||||
|
|
||||||
|
SAVE_TO_DATABASE(500, "盘点入库新增保存失败,请联系管理员!!!");
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.bonus.sgzb.material.config;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后端生产随机编码通用方法(格式:今日年月日日期-随机4位编码 20240328-0001)
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/3/28 17:42
|
||||||
|
*/
|
||||||
|
public class FieldGenerator {
|
||||||
|
|
||||||
|
public static String generateField() {
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
String currentDate = today.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||||
|
// 生成UUID并取后4位,转换为纯数字类型
|
||||||
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
String uuidLast4Digits = uuid.substring(uuid.length() - 4);
|
||||||
|
int uuidLast4DigitsNumeric = Integer.parseInt(uuidLast4Digits, 16);
|
||||||
|
return currentDate + "-" + String.format("%04d", uuidLast4DigitsNumeric % 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.bonus.sgzb.material.controller;
|
package com.bonus.sgzb.material.controller;
|
||||||
|
|
||||||
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
import com.bonus.sgzb.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
|
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
|
||||||
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||||
|
import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
||||||
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
@ -33,4 +35,16 @@ public class InventoryAndWarehousingController extends BaseController {
|
||||||
List<PutInStorageBean> list = inventoryAndWarehousingService.getList(bean);
|
List<PutInStorageBean> list = inventoryAndWarehousingService.getList(bean);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增入库盘点
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增入库盘点")
|
||||||
|
@PostMapping("/addList")
|
||||||
|
public AjaxResult savePutInfo(@RequestBody SavePutInfoDto dto) {
|
||||||
|
return inventoryAndWarehousingService.savePutInfo(dto);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.bonus.sgzb.material.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/3/28 17:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MachIneDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/** 机具ID */
|
||||||
|
@ApiModelProperty(value = "机具ID")
|
||||||
|
private Long maId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型id
|
||||||
|
*/
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
/** 设备编号 */
|
||||||
|
@ApiModelProperty(value = "设备编号")
|
||||||
|
private String maCode;
|
||||||
|
|
||||||
|
/** 出厂编码 */
|
||||||
|
@ApiModelProperty(value = "出厂编码")
|
||||||
|
private String outFacCode;
|
||||||
|
|
||||||
|
/** 生产厂家 */
|
||||||
|
@ApiModelProperty(value = "生产厂家")
|
||||||
|
private String maVender;
|
||||||
|
|
||||||
|
/** 本次检修日期 */
|
||||||
|
@ApiModelProperty(value = "本次检修日期")
|
||||||
|
private String thisCheckTime;
|
||||||
|
|
||||||
|
/** 下次检修日期 */
|
||||||
|
@ApiModelProperty(value = "下次检修日期")
|
||||||
|
private String nextCheckTime;
|
||||||
|
|
||||||
|
/** 单价 */
|
||||||
|
@ApiModelProperty(value = "单价")
|
||||||
|
private String buyPrice;
|
||||||
|
|
||||||
|
/** 编码 */
|
||||||
|
@ApiModelProperty(value = "编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "创建者")
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库形式
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "入库形式")
|
||||||
|
private String putInType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remarks;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
package com.bonus.sgzb.material.domain;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增盘点入库接口实体类dto
|
||||||
|
* @Author ma_sh
|
||||||
|
* @create 2024/3/28 14:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SavePutInfoDto extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断为数量还是编号,true为编号
|
||||||
|
*/
|
||||||
|
private Boolean isCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型id
|
||||||
|
*/
|
||||||
|
private String typeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主信息
|
||||||
|
*/
|
||||||
|
private Integer info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数量
|
||||||
|
*/
|
||||||
|
private Double num;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 库房
|
||||||
|
*/
|
||||||
|
private Integer ram;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备工器具类型
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备主键
|
||||||
|
*/
|
||||||
|
private Integer machine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 入库形式
|
||||||
|
*/
|
||||||
|
private String putInType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盘点入库单号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位名称
|
||||||
|
*/
|
||||||
|
private String unitId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程名称
|
||||||
|
*/
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private String createDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单类型集合
|
||||||
|
*/
|
||||||
|
private List<MachIneDto> machIneDtoList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.bonus.sgzb.material.mapper;
|
package com.bonus.sgzb.material.mapper;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.material.domain.MachIneDto;
|
||||||
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -20,4 +22,41 @@ public interface InventoryAndWarehousingMapper {
|
||||||
*/
|
*/
|
||||||
List<PutInStorageBean> getList(PutInStorageBean bean);
|
List<PutInStorageBean> getList(PutInStorageBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ma_type_put_in_storage_details表
|
||||||
|
* @param machIneDto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer saveDetails(MachIneDto machIneDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入ma_type_put_in_storage_info表
|
||||||
|
* @param machIneDto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int saveInfo(MachIneDto machIneDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新matype表中num数量
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
int updateMaType(@Param("typeId") String typeId, @Param("num") Double num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增ma_machine表
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insertMachine(MachIneDto machIneDtoy);
|
||||||
|
|
||||||
|
int insertMachineLabel(MachIneDto machIneDto);
|
||||||
|
|
||||||
|
int insertLabelBind(MachIneDto machIneDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据code从ma_machine表查询是否有数据,去重
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int selectById(String code);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.bonus.sgzb.material.service;
|
package com.bonus.sgzb.material.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||||
|
import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -18,4 +20,11 @@ public interface InventoryAndWarehousingService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
List<PutInStorageBean> getList(PutInStorageBean bean);
|
List<PutInStorageBean> getList(PutInStorageBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增入库盘点
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult savePutInfo(SavePutInfoDto dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,189 @@
|
||||||
package com.bonus.sgzb.material.service.impl;
|
package com.bonus.sgzb.material.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
|
import com.bonus.sgzb.material.config.ExceptionEnum;
|
||||||
|
import com.bonus.sgzb.material.domain.MachIneDto;
|
||||||
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
import com.bonus.sgzb.material.domain.PutInStorageBean;
|
||||||
|
import com.bonus.sgzb.material.domain.SavePutInfoDto;
|
||||||
import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper;
|
import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper;
|
||||||
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
||||||
|
import com.bonus.sgzb.material.config.FieldGenerator;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
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.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 入库盘点
|
* @author hay
|
||||||
* @author hay
|
* @description 入库盘点
|
||||||
* @date 2024/3/27 13:32
|
* @date 2024/3/27 13:32
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousingService {
|
public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousingService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryAndWarehousingMapper inventoryAndWarehousingMapper;
|
private InventoryAndWarehousingMapper inventoryAndWarehousingMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询入库盘点列表
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PutInStorageBean> getList(PutInStorageBean bean) {
|
public List<PutInStorageBean> getList(PutInStorageBean bean) {
|
||||||
return inventoryAndWarehousingMapper.getList(bean);
|
return inventoryAndWarehousingMapper.getList(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增入库盘点
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult savePutInfo(SavePutInfoDto dto) {
|
||||||
|
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||||
|
dto.setCreator(userId.toString());
|
||||||
|
List<String> codeList = new ArrayList<>();
|
||||||
|
while (codeList.size() < dto.getNum()) {
|
||||||
|
String code = FieldGenerator.generateField();
|
||||||
|
int count = selectById(code);
|
||||||
|
if (count == 0) {
|
||||||
|
codeList.add(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int res = 0;
|
||||||
|
try {
|
||||||
|
//1. 判断是数量还是编号,保存到不同表
|
||||||
|
//1.1 如果是编号
|
||||||
|
if (dto.getIsCode()) {
|
||||||
|
/*插入ma_machine、ma_machine_label和ma_label_bind以及
|
||||||
|
ma_type_put_in_storage_info表和ma_type_put_in_storage_details表*/
|
||||||
|
res = insertMaMachineInfo(dto, codeList);
|
||||||
|
if (res == 0) {
|
||||||
|
log.error("insertMaMachineInfo方法插入异常");
|
||||||
|
throw new RuntimeException("insertMaMachineInfo方法插入异常");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表
|
||||||
|
res = insertPutInfo(dto, codeList);
|
||||||
|
if (res == 0) {
|
||||||
|
log.error("insertPutInfo方法插入异常");
|
||||||
|
throw new RuntimeException("insertPutInfo方法插入异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//去修改ma_type里面的库存num,根据前端传的数量追加
|
||||||
|
res = updateMaTypeInfo(dto.getTypeId(), dto.getNum());
|
||||||
|
if (res == 0) {
|
||||||
|
log.error("updateMaTypeInfo方法修改异常");
|
||||||
|
throw new RuntimeException("updateMaTypeInfo方法修改异常");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
// 添加事务回滚逻辑
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
}
|
||||||
|
if (res == 0) {
|
||||||
|
return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
|
||||||
|
}
|
||||||
|
return AjaxResult.success(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据code从ma_machine表查询是否有数据,去重
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int selectById(String code) {
|
||||||
|
return inventoryAndWarehousingMapper.selectById(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号新增,插入ma_machine、ma_machine_label和ma_label_bind
|
||||||
|
* @param dto
|
||||||
|
* @param codeList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int insertMaMachineInfo(SavePutInfoDto dto, List<String> codeList) {
|
||||||
|
int num = 0;
|
||||||
|
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||||
|
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||||
|
String code = codeList.get(i);
|
||||||
|
machIneDto.setCode(code);
|
||||||
|
machIneDto.setTypeId(dto.getTypeId());
|
||||||
|
machIneDto.setCreator(dto.getCreator());
|
||||||
|
machIneDto.setRemarks(dto.getRemarks());
|
||||||
|
machIneDto.setPutInType(dto.getPutInType());
|
||||||
|
num = inventoryAndWarehousingMapper.insertMachine(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_machine表失败");
|
||||||
|
}
|
||||||
|
num = inventoryAndWarehousingMapper.insertMachineLabel(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_machine_label表失败");
|
||||||
|
}
|
||||||
|
num = inventoryAndWarehousingMapper.insertLabelBind(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_label_bind表失败");
|
||||||
|
}
|
||||||
|
//ma_type_put_in_storage_details表,返回主键id
|
||||||
|
num = inventoryAndWarehousingMapper.saveDetails(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_type_put_in_storage_details表失败");
|
||||||
|
}
|
||||||
|
//插入ma_type_put_in_storage_info表
|
||||||
|
num = inventoryAndWarehousingMapper.saveInfo(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_type_put_in_storage_info表失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 方法抽取,追加ma_type表里面的num
|
||||||
|
*
|
||||||
|
* @param typeId
|
||||||
|
* @param num
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int updateMaTypeInfo(String typeId, Double num) {
|
||||||
|
return inventoryAndWarehousingMapper.updateMaType(typeId, num);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入表方法
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int insertPutInfo(SavePutInfoDto dto, List<String> codeList) {
|
||||||
|
int num = 0;
|
||||||
|
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||||
|
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||||
|
String code = codeList.get(i);
|
||||||
|
machIneDto.setCode(code);
|
||||||
|
machIneDto.setTypeId(dto.getTypeId());
|
||||||
|
machIneDto.setCreator(dto.getCreator());
|
||||||
|
machIneDto.setRemarks(dto.getRemarks());
|
||||||
|
machIneDto.setPutInType(dto.getPutInType());
|
||||||
|
//ma_type_put_in_storage_details表,返回主键id
|
||||||
|
num = inventoryAndWarehousingMapper.saveDetails(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_type_put_in_storage_details表失败");
|
||||||
|
}
|
||||||
|
//插入ma_type_put_in_storage_info表
|
||||||
|
num = inventoryAndWarehousingMapper.saveInfo(machIneDto);
|
||||||
|
if (num == 0) {
|
||||||
|
throw new RuntimeException("新增到ma_type_put_in_storage_info表失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,124 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper">
|
<mapper namespace="com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper">
|
||||||
|
<insert id="saveDetails" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO ma_type_put_in_storage_details (NUM,
|
||||||
|
<trim prefix="" suffixOverrides=",">
|
||||||
|
<if test="maId != null and maId != ''">
|
||||||
|
MACHINE,
|
||||||
|
</if>
|
||||||
|
<if test="remarks != null and remarks != ''">
|
||||||
|
REMARKS,
|
||||||
|
</if>
|
||||||
|
<if test="maCode != null and maCode != ''">
|
||||||
|
MA_CODE,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
)
|
||||||
|
VALUES (1,
|
||||||
|
<trim prefix="" suffixOverrides=",">
|
||||||
|
<if test="maId != null and maId != ''">
|
||||||
|
#{maId},
|
||||||
|
</if>
|
||||||
|
<if test="remarks != null and remarks != ''">
|
||||||
|
#{remarks},
|
||||||
|
</if>
|
||||||
|
<if test="maCode != null and maCode != ''">
|
||||||
|
#{maCode},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<insert id="saveInfo">
|
||||||
|
INSERT INTO ma_type_put_in_storage_info
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null and id != 0">ID,</if>
|
||||||
|
<if test="putInType != null and putInType != ''">PUT_IN_TYPE,</if>
|
||||||
|
NUM,
|
||||||
|
<if test="creator != null and creator != ''">CREATOR,</if>
|
||||||
|
CREATE_DATE,
|
||||||
|
<if test="remarks != null and remarks != ''">REMARKS</if>
|
||||||
|
</trim>
|
||||||
|
VALUES
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="id != null and id != 0">#{id},</if>
|
||||||
|
<if test="putInType != null and putInType != ''">#{putInType},</if>
|
||||||
|
1,
|
||||||
|
<if test="creator != null and creator != ''">#{creator},</if>
|
||||||
|
sysdate(),
|
||||||
|
<if test="remarks != null and remarks != ''">#{remarks}</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<insert id="insertMachine" useGeneratedKeys="true" keyProperty="maId">
|
||||||
|
insert into ma_machine (
|
||||||
|
<if test="typeId != null and typeId != '' ">type_id,</if>
|
||||||
|
<if test="maCode != null and maCode != '' ">ma_code,</if>
|
||||||
|
ma_status,
|
||||||
|
<if test="code != null and code != ''">qr_code,</if>
|
||||||
|
<if test="buyPrice != null and buyPrice != ''">buy_price,</if>
|
||||||
|
<if test="maVender != null and maVender != ''">ma_vender,</if>
|
||||||
|
<if test="outFacCode != null and outFacCode != ''">out_fac_code,</if>
|
||||||
|
<if test="thisCheckTime != null and thisCheckTime != ''">this_check_time,</if>
|
||||||
|
<if test="nextCheckTime != null and nextCheckTime != ''">next_check_time,</if>
|
||||||
|
create_time
|
||||||
|
)values(
|
||||||
|
<if test="typeId != null and typeId != ''">#{typeId},</if>
|
||||||
|
<if test="maCode != null and maCode != ''">#{maCode},</if>
|
||||||
|
15,
|
||||||
|
<if test="code != null and code != ''">#{code},</if>
|
||||||
|
<if test="buyPrice != null and buyPrice != ''">#{buyPrice},</if>
|
||||||
|
<if test="maVender != null and maVender != ''">#{maVender},</if>
|
||||||
|
<if test="outFacCode != null and outFacCode != ''">#{outFacCode},</if>
|
||||||
|
<if test="thisCheckTime != null and thisCheckTime != ''">#{thisCheckTime},</if>
|
||||||
|
<if test="nextCheckTime != null and nextCheckTime != ''">#{nextCheckTime},</if>
|
||||||
|
sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<insert id="insertMachineLabel">
|
||||||
|
insert into ma_machine_label
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="maId != null">label_id,</if>
|
||||||
|
<if test="code != null">label_code,</if>
|
||||||
|
<if test="maId != null">ma_id,</if>
|
||||||
|
is_bind,
|
||||||
|
label_type,
|
||||||
|
create_time
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="maId != null">#{maId},</if>
|
||||||
|
<if test="code != null">#{code},</if>
|
||||||
|
<if test="maId != null">#{maId},</if>
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
now()
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<insert id="insertLabelBind">
|
||||||
|
insert into ma_label_bind
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="maId != null">ma_id,</if>
|
||||||
|
<if test="code != null">label_code,</if>
|
||||||
|
<if test="typeId != null">type_id,</if>
|
||||||
|
label_type,
|
||||||
|
bind_time,
|
||||||
|
status
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="maId != null">#{maId},</if>
|
||||||
|
<if test="code != null">#{code},</if>
|
||||||
|
<if test="typeId != null">#{typeId},</if>
|
||||||
|
9,
|
||||||
|
now(),
|
||||||
|
1
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<update id="updateMaType">
|
||||||
|
UPDATE ma_type
|
||||||
|
SET num = num + #{num}
|
||||||
|
<where>
|
||||||
|
<if test="typeId != null "> and type_id = #{typeId}</if>
|
||||||
|
</where>
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="getList" resultType="com.bonus.sgzb.material.domain.PutInStorageBean">
|
<select id="getList" resultType="com.bonus.sgzb.material.domain.PutInStorageBean">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
@ -22,4 +140,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
|
||||||
LEFT JOIN sys_user su on su.user_id=pisi.CREATOR
|
LEFT JOIN sys_user su on su.user_id=pisi.CREATOR
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectById" resultType="java.lang.Integer">
|
||||||
|
select count(*)
|
||||||
|
from ma_machine
|
||||||
|
<where>
|
||||||
|
<if test="code != null "> and qr_code = #{code}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue