|
@ -1,18 +1,35 @@ |
|
|
package org.nl.b_lms.sch.point.service.impl; |
|
|
package org.nl.b_lms.sch.point.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import org.nl.b_lms.sch.point.dao.SchBasePoint; |
|
|
import org.nl.b_lms.sch.point.dao.SchBasePoint; |
|
|
import org.nl.b_lms.sch.point.dao.mapper.SchBasePointMapper; |
|
|
import org.nl.b_lms.sch.point.dao.mapper.SchBasePointMapper; |
|
|
|
|
|
import org.nl.b_lms.sch.point.dto.SchBasePointQuery; |
|
|
import org.nl.b_lms.sch.point.service.IschBasePointService; |
|
|
import org.nl.b_lms.sch.point.service.IschBasePointService; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
import org.nl.b_lms.sch.region.dao.SchBaseRegion; |
|
|
|
|
|
import org.nl.b_lms.sch.region.dao.mapper.SchBaseRegionMapper; |
|
|
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
|
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
|
|
|
import org.nl.wms.basedata.st.structattr.service.StructattrService; |
|
|
|
|
|
import org.nl.wms.basedata.st.structattr.service.dto.PointToStructattrDto; |
|
|
|
|
|
import org.nl.wms.sch.PointUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import org.nl.common.domain.query.PageQuery; |
|
|
import org.nl.common.domain.query.PageQuery; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.util.Map; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.Set; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -27,6 +44,10 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private SchBasePointMapper schBasePointMapper; |
|
|
private SchBasePointMapper schBasePointMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SchBaseRegionMapper regionMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private StructattrService structattrService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -36,9 +57,31 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
* @param page 分页参数 |
|
|
* @param page 分页参数 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public IPage<SchBasePoint> queryAll(Map whereJson, PageQuery page) { |
|
|
public IPage<SchBasePoint> queryAll(SchBasePointQuery whereJson, PageQuery page) { |
|
|
return schBasePointMapper.selectPage(new Page<>(page.getPage() + 1, page.getSize()), new QueryWrapper<SchBasePoint>() |
|
|
IPage<SchBasePoint> pages = new Page<>(page.getPage() + 1, page.getSize()); |
|
|
.lambda()); |
|
|
pages = schBasePointMapper.selectPageLeftJoin(pages, whereJson); |
|
|
|
|
|
// 可以存放的载具类型
|
|
|
|
|
|
pages.getRecords().forEach(point -> { |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(point.getCan_vehicle_type())) { |
|
|
|
|
|
point.setCan_vehicle_types(Arrays.asList(point.getCan_vehicle_type().split(","))); |
|
|
|
|
|
} |
|
|
|
|
|
String pointStatus = point.getPoint_status(); // 点位状态
|
|
|
|
|
|
String pointType = point.getPoint_type(); // 点位类型
|
|
|
|
|
|
SchBaseRegion regionObj = regionMapper.selectById(point.getRegion_id()); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(regionObj)) { |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pointStatus) && ObjectUtil.isNotEmpty(regionObj.getPoint_status_explain())) { |
|
|
|
|
|
// 设置
|
|
|
|
|
|
point.setPoint_status_name(PointUtils.getStatusOrTypeName( |
|
|
|
|
|
regionObj.getPoint_status_explain(), pointStatus)); |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pointType) && ObjectUtil.isNotEmpty(regionObj.getPoint_type_explain())) { |
|
|
|
|
|
// 设置
|
|
|
|
|
|
point.setPoint_type_name(PointUtils.getStatusOrTypeName( |
|
|
|
|
|
regionObj.getPoint_type_explain(), pointType)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
return pages; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -60,10 +103,17 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public void update(SchBasePoint entity) { |
|
|
public void update(SchBasePoint entity) { |
|
|
// SchBasePoint dto = schBasePointMapper.selectById(entity.getId);
|
|
|
SchBasePoint dto = schBasePointMapper.selectById(entity.getPoint_id()); |
|
|
// if (dto == null) {
|
|
|
if (dto == null) { |
|
|
// throw new BadRequestException("不存在该数据!");
|
|
|
throw new BadRequestException("不存在该数据!"); |
|
|
// }
|
|
|
} |
|
|
|
|
|
String pointStatus = dto.getPoint_status(); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pointStatus) && "1".equals(pointStatus)) { |
|
|
|
|
|
entity.setMaterial_id(""); |
|
|
|
|
|
entity.setVehicle_type(""); |
|
|
|
|
|
entity.setVehicle_code(""); |
|
|
|
|
|
entity.setVehicle_qty(0); |
|
|
|
|
|
} |
|
|
schBasePointMapper.updateById(getBasicInfo(entity, false)); |
|
|
schBasePointMapper.updateById(getBasicInfo(entity, false)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -79,6 +129,88 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
schBasePointMapper.deleteBatchIds(ids); |
|
|
schBasePointMapper.deleteBatchIds(ids); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void changeActive(JSONObject json) { |
|
|
|
|
|
//如果是仓位点位,更新状态前,先去查询仓位点位所对应的库区是否启用,如果禁用抛出异常
|
|
|
|
|
|
String structCode = json.getString("point_code"); |
|
|
|
|
|
String pointType = json.getString("point_type"); |
|
|
|
|
|
String isUsed = json.getString("is_used"); |
|
|
|
|
|
// todo: 未修改mp
|
|
|
|
|
|
if ("01".equals(pointType)) { |
|
|
|
|
|
JSONObject st_ivt_bsRealStorAttr = WQLObject.getWQLObject("ST_IVT_StructAttr").query(" struct_code = '" + structCode + "'").uniqueResult(0); |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(st_ivt_bsRealStorAttr)) { |
|
|
|
|
|
String sect_id = st_ivt_bsRealStorAttr.getString("sect_id"); |
|
|
|
|
|
JSONObject st_ivt_sectAttr = WQLObject.getWQLObject("ST_IVT_SectAttr").query(" sect_id = '" + sect_id + "' and is_used = '1'").uniqueResult(0); |
|
|
|
|
|
if (ObjectUtil.isEmpty(st_ivt_sectAttr)) { |
|
|
|
|
|
throw new BadRequestException("启用失败,请检查仓位点位所属库区是否启用!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
LambdaUpdateWrapper<SchBasePoint> lam = new LambdaUpdateWrapper<>(); |
|
|
|
|
|
lam.set(SchBasePoint::getIs_used, "1".equals(isUsed) ? "0" : "1") |
|
|
|
|
|
.set(SchBasePoint::getUpdate_id, SecurityUtils.getCurrentUserId()) |
|
|
|
|
|
.set(SchBasePoint::getUpdate_name, SecurityUtils.getCurrentNickName()) |
|
|
|
|
|
.set(SchBasePoint::getUpdate_time, DateUtil.now()) |
|
|
|
|
|
.eq(SchBasePoint::getPoint_code, pointType); |
|
|
|
|
|
update(lam); |
|
|
|
|
|
// 如果启用,则同步更新仓位的状态
|
|
|
|
|
|
// todo: 未修改mp
|
|
|
|
|
|
json = new JSONObject(); |
|
|
|
|
|
json.put("is_used", "1".equals(isUsed) ? "0" : "1"); |
|
|
|
|
|
json.put("update_optid", SecurityUtils.getCurrentUserId()); |
|
|
|
|
|
json.put("update_optname", SecurityUtils.getCurrentNickName()); |
|
|
|
|
|
json.put("update_time", DateUtil.now()); |
|
|
|
|
|
json.put("struct_code", structCode); |
|
|
|
|
|
WQLObject.getWQLObject("ST_IVT_StructAttr").update(json, " struct_code = '" + structCode + "'"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<SchBasePoint> getPoint(List<String> areas) { |
|
|
|
|
|
LambdaQueryWrapper<SchBasePoint> lam = new QueryWrapper<SchBasePoint>().lambda(); |
|
|
|
|
|
lam.eq(SchBasePoint::getIs_used, "1") |
|
|
|
|
|
.eq(SchBasePoint::getIs_delete, "0") |
|
|
|
|
|
.in(SchBasePoint::getRegion_id, areas); |
|
|
|
|
|
return schBasePointMapper.selectList(lam); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void sync() { |
|
|
|
|
|
// 先删除所有点位类型为仓位的点位
|
|
|
|
|
|
schBasePointMapper.delete(new LambdaQueryWrapper<SchBasePoint>() |
|
|
|
|
|
.eq(SchBasePoint::getPoint_type, "2")); |
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
List<PointToStructattrDto> structattrDtos = structattrService.getAllPointToShippingSpace(); |
|
|
|
|
|
List<SchBasePoint> waitAddList = new ArrayList<>(); |
|
|
|
|
|
for (PointToStructattrDto dto : structattrDtos) { |
|
|
|
|
|
SchBasePoint point = new SchBasePoint(); |
|
|
|
|
|
point.setPoint_id(IdUtil.getSnowflake(1,1).nextIdStr()); |
|
|
|
|
|
point.setPoint_code(dto.getStruct_code()); |
|
|
|
|
|
point.setPoint_name(dto.getStruct_name()); |
|
|
|
|
|
point.setRegion_id(String.valueOf(dto.getSect_id())); |
|
|
|
|
|
point.setRegion_code(dto.getSect_code()); |
|
|
|
|
|
point.setRegion_name(dto.getSect_name()); |
|
|
|
|
|
point.setPoint_type("2"); |
|
|
|
|
|
point.setPoint_status("1"); |
|
|
|
|
|
point.setLock_type(dto.getLock_type()); |
|
|
|
|
|
point.setBlock_num(new BigDecimal(dto.getBlock_num())); |
|
|
|
|
|
point.setRow_num(new BigDecimal(dto.getRow_num())); |
|
|
|
|
|
point.setCol_num(new BigDecimal(dto.getCol_num())); |
|
|
|
|
|
point.setLayer_num(new BigDecimal(dto.getLayer_num())); |
|
|
|
|
|
point.setSource_id(String.valueOf(dto.getStruct_id())); |
|
|
|
|
|
point.setCreate_id(currentUserId); |
|
|
|
|
|
point.setCreate_name(nickName); |
|
|
|
|
|
point.setCreate_time(now); |
|
|
|
|
|
point.setUpdate_id(currentUserId); |
|
|
|
|
|
point.setUpdate_name(nickName); |
|
|
|
|
|
point.setUpdate_time(now); |
|
|
|
|
|
waitAddList.add(point); |
|
|
|
|
|
} |
|
|
|
|
|
this.saveBatch(waitAddList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取实体基础信息 |
|
|
* 获取实体基础信息 |
|
@ -87,14 +219,18 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
* @param isCreate 是否创建 |
|
|
* @param isCreate 是否创建 |
|
|
*/ |
|
|
*/ |
|
|
private SchBasePoint getBasicInfo(SchBasePoint entity, boolean isCreate) { |
|
|
private SchBasePoint getBasicInfo(SchBasePoint entity, boolean isCreate) { |
|
|
// if (isCreate) {
|
|
|
if (isCreate) { |
|
|
// entity.setCreate_id(Long.valueOf(SecurityUtils.getCurrentUserId()));
|
|
|
entity.setPoint_id(IdUtil.getSnowflake(1,1).nextIdStr()); |
|
|
// entity.setCreate_name(SecurityUtils.getCurrentNickName());
|
|
|
entity.setCreate_id(SecurityUtils.getCurrentUserId()); |
|
|
// entity.setCreate_time(DateUtil.now());
|
|
|
entity.setCreate_name(SecurityUtils.getCurrentNickName()); |
|
|
// }
|
|
|
entity.setCreate_time(DateUtil.now()); |
|
|
// entity.setUpdate_optid(Long.valueOf(SecurityUtils.getCurrentUserId()));
|
|
|
} |
|
|
// entity.setUpdate_optname(SecurityUtils.getCurrentNickName());
|
|
|
entity.setUpdate_id(SecurityUtils.getCurrentUserId()); |
|
|
// entity.setUpdate_time(DateUtil.now());
|
|
|
entity.setUpdate_name(SecurityUtils.getCurrentNickName()); |
|
|
|
|
|
entity.setUpdate_time(DateUtil.now()); |
|
|
|
|
|
SchBaseRegion regionDto = regionMapper.selectById(entity.getRegion_id()); |
|
|
|
|
|
entity.setRegion_code(regionDto.getRegion_code()); |
|
|
|
|
|
entity.setRegion_name(regionDto.getRegion_name()); |
|
|
return entity; |
|
|
return entity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|