no message
parent
a13024aaa9
commit
1e4638c589
|
|
@ -2,6 +2,7 @@ package com.youchain.appupdate.service.impl;
|
||||||
|
|
||||||
import com.youchain.appupdate.request.*;
|
import com.youchain.appupdate.request.*;
|
||||||
import com.youchain.appupdate.service.NioF3AppService;
|
import com.youchain.appupdate.service.NioF3AppService;
|
||||||
|
import com.youchain.basicdata.constant.PointTypeEnum;
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.service.ItemService;
|
import com.youchain.basicdata.service.ItemService;
|
||||||
|
|
@ -81,7 +82,7 @@ public class NioF3AppServiceImpl implements NioF3AppService {
|
||||||
|
|
||||||
//验证起点
|
//验证起点
|
||||||
Point point = pointService.validatePoint(bindSmall.getSrcPositionCode());
|
Point point = pointService.validatePoint(bindSmall.getSrcPositionCode());
|
||||||
if (!BaseStatus.XJ_DFQ.equals(point.getType())) {
|
if (!PointTypeEnum.XJ_DFQ.getValue().equals(point.getType())) {
|
||||||
throw new BadRequestException(bindSmall.getSrcPositionCode() + "不属于小件待发区点位");
|
throw new BadRequestException(bindSmall.getSrcPositionCode() + "不属于小件待发区点位");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +175,7 @@ public class NioF3AppServiceImpl implements NioF3AppService {
|
||||||
|
|
||||||
//验证起点
|
//验证起点
|
||||||
Point point = pointService.validatePoint(bindLarge.getSrcPositionCode());
|
Point point = pointService.validatePoint(bindLarge.getSrcPositionCode());
|
||||||
if (!BaseStatus.DJ_DFQ.equals(point.getType())) {
|
if (!PointTypeEnum.DJ_DFQ.getValue().equals(point.getType())) {
|
||||||
throw new BadRequestException(bindLarge.getSrcPositionCode() + "不属于大件待发区点位");
|
throw new BadRequestException(bindLarge.getSrcPositionCode() + "不属于大件待发区点位");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +233,7 @@ public class NioF3AppServiceImpl implements NioF3AppService {
|
||||||
|
|
||||||
//验证起点
|
//验证起点
|
||||||
Point point = pointService.validatePoint(bindLargeZy.getSrcPositionCode());
|
Point point = pointService.validatePoint(bindLargeZy.getSrcPositionCode());
|
||||||
if (!BaseStatus.DJ_DFQ.equals(point.getType())) {
|
if (!PointTypeEnum.DJ_DFQ.getValue().equals(point.getType())) {
|
||||||
throw new BadRequestException(bindLargeZy.getSrcPositionCode() + "不属于大件待发区点位");
|
throw new BadRequestException(bindLargeZy.getSrcPositionCode() + "不属于大件待发区点位");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.youchain.basicdata.constant;
|
||||||
|
|
||||||
|
import com.youchain.enumeration.BaseEnum;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum PointTypeEnum implements BaseEnum {
|
||||||
|
|
||||||
|
STORAGE("STORAGE", "存储点"),
|
||||||
|
|
||||||
|
BOX("BOX", "线边点位"),
|
||||||
|
|
||||||
|
XJ_DFQ("XJ_DFQ", "小件待发区"),
|
||||||
|
|
||||||
|
DJ_DFQ("DJ_DFQ", "大件待发区"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 value 获取对应的 desc
|
||||||
|
* @param value 枚举值
|
||||||
|
* @return 对应的描述,如果未找到则返回 null
|
||||||
|
*/
|
||||||
|
public static String getDescByValue(String value) {
|
||||||
|
for (PointTypeEnum status : PointTypeEnum.values()) {
|
||||||
|
if (status.getValue().equals(value)) {
|
||||||
|
return status.getDesc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 desc 获取对应的 value
|
||||||
|
* @param desc 枚举值
|
||||||
|
* @return 对应的值,如果未找到则返回 null
|
||||||
|
*/
|
||||||
|
public static String getValueByDesc(String desc) {
|
||||||
|
for (PointTypeEnum status : PointTypeEnum.values()) {
|
||||||
|
if (status.getDesc().equals(desc)) {
|
||||||
|
return status.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ public class Point extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@Column(name = "`heat`")
|
@Column(name = "`heat`")
|
||||||
@ApiModelProperty(value = "热度")
|
@ApiModelProperty(value = "热度")
|
||||||
private Double heat;
|
private Double heat=0d;
|
||||||
|
|
||||||
@Column(name = "`line`")
|
@Column(name = "`line`")
|
||||||
@ApiModelProperty(value = "排")
|
@ApiModelProperty(value = "排")
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.service.impl;
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
import cn.idev.excel.FastExcel;
|
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.requset.ItemImportReq;
|
import com.youchain.basicdata.requset.ItemImportReq;
|
||||||
import com.youchain.exception.BadRequestException;
|
import com.youchain.exception.BadRequestException;
|
||||||
|
|
@ -27,7 +26,6 @@ import com.youchain.basicdata.service.ItemService;
|
||||||
import com.youchain.basicdata.service.dto.ItemDto;
|
import com.youchain.basicdata.service.dto.ItemDto;
|
||||||
import com.youchain.basicdata.service.dto.ItemQueryCriteria;
|
import com.youchain.basicdata.service.dto.ItemQueryCriteria;
|
||||||
import com.youchain.basicdata.service.mapstruct.ItemMapper;
|
import com.youchain.basicdata.service.mapstruct.ItemMapper;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
@ -51,6 +49,7 @@ public class ItemServiceImpl implements ItemService {
|
||||||
|
|
||||||
private final ItemRepository itemRepository;
|
private final ItemRepository itemRepository;
|
||||||
private final ItemMapper itemMapper;
|
private final ItemMapper itemMapper;
|
||||||
|
private final BatchUtils batchUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(ItemQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAll(ItemQueryCriteria criteria, Pageable pageable) {
|
||||||
|
|
@ -153,17 +152,10 @@ public class ItemServiceImpl implements ItemService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String importItem(MultipartFile multipartFile) {
|
public String importItem(MultipartFile multipartFile) {
|
||||||
List<ItemImportReq> dataList;
|
List<ItemImportReq> dataList=FastExcelUtils.readExcelData(multipartFile, ItemImportReq.class,0, 1);
|
||||||
try {
|
|
||||||
dataList = FastExcel.read(multipartFile.getInputStream()).head(ItemImportReq.class)
|
//去除掉重复数据
|
||||||
.sheet()
|
dataList = dataList.stream().distinct().collect(Collectors.toList());
|
||||||
.doReadSync();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new BadRequestException("数据格式存在问题,无法读取");
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(dataList)) {
|
|
||||||
throw new BadRequestException("数据为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取文件中所有物料编码
|
//获取文件中所有物料编码
|
||||||
List<String> codes = dataList.stream()
|
List<String> codes = dataList.stream()
|
||||||
|
|
@ -189,7 +181,7 @@ public class ItemServiceImpl implements ItemService {
|
||||||
Item item = existingItemMap.get(code);
|
Item item = existingItemMap.get(code);
|
||||||
itemsToUpdate.add(updateItem(item, specs));
|
itemsToUpdate.add(updateItem(item, specs));
|
||||||
} else {
|
} else {
|
||||||
//新增容器
|
//新增物料
|
||||||
Item item = createItem(code, specs, UserUtils.getDept());
|
Item item = createItem(code, specs, UserUtils.getDept());
|
||||||
itemsToCreate.add(item);
|
itemsToCreate.add(item);
|
||||||
existingItemMap.put(code, item);
|
existingItemMap.put(code, item);
|
||||||
|
|
@ -197,15 +189,17 @@ public class ItemServiceImpl implements ItemService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//批量新增物料
|
//批量新增物料
|
||||||
|
int[] resultCreate = new int[0];
|
||||||
if (!itemsToCreate.isEmpty()) {
|
if (!itemsToCreate.isEmpty()) {
|
||||||
itemRepository.saveAll(itemsToCreate);
|
resultCreate = batchUtils.batchInsertItems(itemsToCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//批量更新物料
|
//批量更新物料
|
||||||
|
int[] resultUpdate = new int[0];
|
||||||
if (!itemsToUpdate.isEmpty()) {
|
if (!itemsToUpdate.isEmpty()) {
|
||||||
itemRepository.saveAll(itemsToUpdate);
|
resultUpdate = batchUtils.batchUpdateItems(itemsToUpdate);
|
||||||
}
|
}
|
||||||
return ("导入成功:" + " 新增(" + itemsToCreate.size() + ")修改(" + itemsToUpdate.size() + ")");
|
return String.format("导入成功:新增(%d);修改(%d)", resultCreate.length, resultUpdate.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item createItem(String code, String specs, Dept dept) {
|
private Item createItem(String code, String specs, Dept dept) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.service.impl;
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
import cn.idev.excel.FastExcel;
|
import com.youchain.basicdata.constant.PointTypeEnum;
|
||||||
import com.youchain.basicdata.domain.Area;
|
import com.youchain.basicdata.domain.Area;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.repository.AreaRepository;
|
import com.youchain.basicdata.repository.AreaRepository;
|
||||||
|
|
@ -30,9 +30,7 @@ import com.youchain.basicdata.service.dto.PointDto;
|
||||||
import com.youchain.basicdata.service.dto.PointQueryCriteria;
|
import com.youchain.basicdata.service.dto.PointQueryCriteria;
|
||||||
import com.youchain.basicdata.service.mapstruct.PointMapper;
|
import com.youchain.basicdata.service.mapstruct.PointMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
@ -59,6 +57,7 @@ public class PointServiceImpl implements PointService {
|
||||||
private final PointRepository pointRepository;
|
private final PointRepository pointRepository;
|
||||||
private final AreaRepository areaRepository;
|
private final AreaRepository areaRepository;
|
||||||
private final PointMapper pointMapper;
|
private final PointMapper pointMapper;
|
||||||
|
private final BatchUtils batchUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(PointQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAll(PointQueryCriteria criteria, Pageable pageable) {
|
||||||
|
|
@ -133,17 +132,11 @@ public class PointServiceImpl implements PointService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String importPoint(MultipartFile multipartFile) {
|
public String importPoint(MultipartFile multipartFile) {
|
||||||
List<PointImportReq> dataList;
|
//读取数据
|
||||||
try {
|
List<PointImportReq> dataList = FastExcelUtils.readExcelData(multipartFile, PointImportReq.class,0, 1);
|
||||||
dataList = FastExcel.read(multipartFile.getInputStream()).head(PointImportReq.class)
|
|
||||||
.sheet()
|
//去除掉重复数据
|
||||||
.doReadSync();
|
dataList = dataList.stream().distinct().collect(Collectors.toList());
|
||||||
} catch (IOException e) {
|
|
||||||
throw new BadRequestException("数据格式存在问题,无法读取");
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(dataList)) {
|
|
||||||
throw new BadRequestException("数据为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取文件中所有库区名称
|
//获取文件中所有库区名称
|
||||||
List<String> names = dataList.stream()
|
List<String> names = dataList.stream()
|
||||||
|
|
@ -198,24 +191,31 @@ public class PointServiceImpl implements PointService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//批量新增容器
|
//批量新增点位
|
||||||
|
int[] resultCreate = new int[0];
|
||||||
if (!pointsToCreate.isEmpty()) {
|
if (!pointsToCreate.isEmpty()) {
|
||||||
pointRepository.saveAll(pointsToCreate);
|
resultCreate = batchUtils.batchInsertPoints(pointsToCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//批量更新容器
|
//批量更新点位
|
||||||
|
int[] resultUpdate = new int[0];
|
||||||
if (!pointsToUpdate.isEmpty()) {
|
if (!pointsToUpdate.isEmpty()) {
|
||||||
pointRepository.saveAll(pointsToUpdate);
|
resultUpdate = batchUtils.batchUpdatePoints(pointsToUpdate);
|
||||||
}
|
}
|
||||||
return ("导入成功:" + " 新增(" + pointsToCreate.size() + ")修改(" + pointsToUpdate.size() + ")");
|
return String.format("导入成功:新增(%d);修改(%d)", resultCreate.length, resultUpdate.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point createPoint(String code, String beatCode, String type, Area area, Dept dept) {
|
private Point createPoint(String code, String beatCode, String type, Area area, Dept dept) {
|
||||||
if ("缓存点".equals(type)) {
|
if ("存储点".equals(type)) {
|
||||||
type = BaseStatus.STORAGE;
|
type = PointTypeEnum.STORAGE.getValue();
|
||||||
|
|
||||||
} else if ("线边点位".equals(type)) {
|
} else if ("线边点位".equals(type)) {
|
||||||
type = BaseStatus.BOX;
|
type = PointTypeEnum.BOX.getValue();
|
||||||
|
} else if ("小件待发区".equals(type)) {
|
||||||
|
type = PointTypeEnum.XJ_DFQ.getValue();
|
||||||
|
} else if ("大件待发区".equals(type)) {
|
||||||
|
type = PointTypeEnum.DJ_DFQ.getValue();
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException(type + "类型不存在");
|
||||||
}
|
}
|
||||||
return Point.builder()
|
return Point.builder()
|
||||||
.code(code)
|
.code(code)
|
||||||
|
|
@ -226,16 +226,20 @@ public class PointServiceImpl implements PointService {
|
||||||
.enabled(true)
|
.enabled(true)
|
||||||
.dept(dept)
|
.dept(dept)
|
||||||
.type(type)
|
.type(type)
|
||||||
.heat(0.0)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point updatePoint(Point point, Area area, String beatCode, String type) {
|
private Point updatePoint(Point point, Area area, String beatCode, String type) {
|
||||||
if ("缓存点".equals(type)) {
|
if ("存储点".equals(type)) {
|
||||||
type = BaseStatus.STORAGE;
|
type = PointTypeEnum.STORAGE.getValue();
|
||||||
|
|
||||||
} else if ("线边点位".equals(type)) {
|
} else if ("线边点位".equals(type)) {
|
||||||
type = BaseStatus.BOX;
|
type = PointTypeEnum.BOX.getValue();
|
||||||
|
} else if ("小件待发区".equals(type)) {
|
||||||
|
type = PointTypeEnum.XJ_DFQ.getValue();
|
||||||
|
} else if ("大件待发区".equals(type)) {
|
||||||
|
type = PointTypeEnum.DJ_DFQ.getValue();
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException(type + "类型不存在");
|
||||||
}
|
}
|
||||||
point.setArea(area);
|
point.setArea(area);
|
||||||
point.setBeatCode(beatCode);
|
point.setBeatCode(beatCode);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.youchain.enumeration;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONAware;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public interface BaseEnum {
|
||||||
|
/**
|
||||||
|
* 获取枚举类的值
|
||||||
|
*
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
Object getValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取枚举类的说明
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
String getDesc();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较参数是否与枚举类的value相同
|
||||||
|
*
|
||||||
|
* @param value 枚举类的value
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
default boolean equalsValue(Object value) {
|
||||||
|
return Objects.equals(getValue(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比较枚举类是否相同
|
||||||
|
*
|
||||||
|
* @param baseEnum 枚举类对象
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
default boolean equals(BaseEnum baseEnum) {
|
||||||
|
return Objects.equals(getValue(), baseEnum.getValue()) && Objects.equals(getDesc(), baseEnum.getDesc());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class DeletedQuotationAware implements JSONAware {
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public DeletedQuotationAware(Object value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
this.value = "'" + value + "'";
|
||||||
|
} else {
|
||||||
|
this.value = value.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJSONString() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,26 +22,6 @@ public interface BaseStatus {
|
||||||
*/
|
*/
|
||||||
public static Boolean F =false;
|
public static Boolean F =false;
|
||||||
|
|
||||||
/**
|
|
||||||
* 点位类型-按钮盒点位
|
|
||||||
*/
|
|
||||||
public static String BOX = "BOX";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 点位类型-缓存点
|
|
||||||
*/
|
|
||||||
public static String STORAGE = "STORAGE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 点位类型-小件待发区
|
|
||||||
*/
|
|
||||||
public static String XJ_DFQ = "XJ_DFQ";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 点位类型-大件待发区
|
|
||||||
*/
|
|
||||||
public static String DJ_DFQ = "DJ_DFQ";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输送线
|
* 输送线
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.youchain.utils;
|
package com.youchain.utils;
|
||||||
|
|
||||||
import com.youchain.basicdata.domain.Area;
|
import com.youchain.basicdata.domain.Item;
|
||||||
|
import com.youchain.basicdata.domain.Point;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
@ -9,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -17,54 +19,120 @@ public class BatchUtils {
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcTemplate jdbcTemplate;
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入库区数据
|
* 批量插入物料数据
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public int[] batchInsertAreas(List<Area> areas) {
|
public int[] batchInsertItems(List<Item> items) {
|
||||||
String sql = "insert into base_area (code, name, enabled, dept_id,create_by,update_by,create_time,update_time) VALUES (?, ?, ?, ?,?,?,?,?)";
|
String sql = "insert into base_item (code,name,specs,enabled,good_type,unit,dept_id,create_by,update_by,create_time,update_time) values (?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
|
||||||
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||||
@Override
|
@Override
|
||||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||||
Area area = areas.get(i);
|
Item item = items.get(i);
|
||||||
ps.setString(1, area.getCode());
|
ps.setString(1, item.getCode());
|
||||||
ps.setString(2, area.getName());
|
ps.setString(2, item.getName());
|
||||||
ps.setBoolean(3, area.getEnabled());
|
ps.setString(3, item.getSpecs());
|
||||||
ps.setLong(4, area.getDept().getId());
|
ps.setBoolean(4, item.getEnabled());
|
||||||
ps.setString(5, area.getCreateBy());
|
ps.setString(5, item.getGoodType());
|
||||||
ps.setString(6, area.getUpdateBy());
|
ps.setString(6, item.getUnit());
|
||||||
ps.setTimestamp(7, area.getCreateTime());
|
ps.setLong(7, item.getDept().getId());
|
||||||
ps.setTimestamp(8, area.getUpdateTime());
|
ps.setString(8, SecurityUtils.getCurrentUsername());
|
||||||
|
ps.setString(9, SecurityUtils.getCurrentUsername());
|
||||||
|
ps.setTimestamp(10, new Timestamp(System.currentTimeMillis()));
|
||||||
|
ps.setTimestamp(11, new Timestamp(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatchSize() {
|
public int getBatchSize() {
|
||||||
return areas.size();
|
return items.size();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量更新库区域数据(根据ID)
|
* 批量更新物料
|
||||||
*/
|
*/
|
||||||
public int[] batchUpdateAreasById(List<Area> areas) {
|
@Transactional
|
||||||
String sql = "update base_area set name = ?, code = ?, enabled = ? WHERE id = ?";
|
public int[] batchUpdateItems(List<Item> items) {
|
||||||
|
String sql = "update base_item set code = ?, name = ?, specs = ?, enabled = ?, good_type = ?, unit = ? where id = ?";
|
||||||
|
|
||||||
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||||
@Override
|
@Override
|
||||||
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||||
Area area = areas.get(i);
|
Item item = items.get(i);
|
||||||
ps.setString(1, area.getName());
|
ps.setString(1, item.getCode());
|
||||||
ps.setString(2, area.getCode());
|
ps.setString(2, item.getName());
|
||||||
ps.setBoolean(3, area.getEnabled());
|
ps.setString(3, item.getSpecs());
|
||||||
ps.setLong(4, area.getId()); // WHERE条件
|
ps.setBoolean(4, item.getEnabled());
|
||||||
|
ps.setString(5, item.getGoodType());
|
||||||
|
ps.setString(6, item.getUnit());
|
||||||
|
ps.setLong(7, item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatchSize() {
|
public int getBatchSize() {
|
||||||
return areas.size();
|
return items.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入点位数据
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public int[] batchInsertPoints(List<Point> points) {
|
||||||
|
String sql = "insert into base_point (code,name,status,beat_code,area_id,enabled,dept_id,type,create_by,update_by,create_time,update_time) values (?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||||
|
|
||||||
|
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||||
|
@Override
|
||||||
|
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||||
|
Point point = points.get(i);
|
||||||
|
ps.setString(1, point.getCode());
|
||||||
|
ps.setString(2, point.getName());
|
||||||
|
ps.setString(3, point.getStatus());
|
||||||
|
ps.setString(4, point.getBeatCode());
|
||||||
|
ps.setLong(5, point.getArea().getId());
|
||||||
|
ps.setBoolean(6, point.getEnabled());
|
||||||
|
ps.setLong(7, point.getDept().getId());
|
||||||
|
ps.setString(8, point.getType());
|
||||||
|
ps.setString(9, SecurityUtils.getCurrentUsername());
|
||||||
|
ps.setString(10, SecurityUtils.getCurrentUsername());
|
||||||
|
ps.setTimestamp(11, new Timestamp(System.currentTimeMillis()));
|
||||||
|
ps.setTimestamp(12, new Timestamp(System.currentTimeMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBatchSize() {
|
||||||
|
return points.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量更新物料
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public int[] batchUpdatePoints(List<Point> points) {
|
||||||
|
String sql = "update base_point set code = ?, name = ?, status = ?, beat_code = ? , area_id = ? , enabled = ?, type = ? where id = ?";
|
||||||
|
|
||||||
|
return jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
|
||||||
|
@Override
|
||||||
|
public void setValues(PreparedStatement ps, int i) throws SQLException {
|
||||||
|
Point point = points.get(i);
|
||||||
|
ps.setString(1, point.getCode());
|
||||||
|
ps.setString(2, point.getName());
|
||||||
|
ps.setString(3, point.getStatus());
|
||||||
|
ps.setString(4, point.getBeatCode());
|
||||||
|
ps.setLong(5, point.getArea().getId());
|
||||||
|
ps.setBoolean(6, point.getEnabled());
|
||||||
|
ps.setString(7, point.getType());
|
||||||
|
ps.setLong(8, point.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBatchSize() {
|
||||||
|
return points.size();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue