|
@@ -60,23 +60,35 @@ public class OmsshipInstructionsCapacityServiceImpl implements IOmsshipInstructi
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public int insert(Map<String,Object> omsshipInstructionsCapacity) {
|
|
|
- String capacityNumber = (String) omsshipInstructionsCapacity.get("capacityName");
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("capacityNumber",capacityNumber);
|
|
|
- List<RmsCapacity> rmsCapacities = rmsCapacityMapper.selectByParameters(map);
|
|
|
+ // 插入装船指令
|
|
|
OmsshipInstructionsCapacity realOmsshipInstructionsCapacity = new OmsshipInstructionsCapacity();
|
|
|
- if (rmsCapacities.size() != 0 ) {
|
|
|
- RmsCapacity rmsCapacity = rmsCapacities.get(0);
|
|
|
- rmsCapacityMapper.updateByPrimaryKeySelective(rmsCapacity);
|
|
|
- realOmsshipInstructionsCapacity.setCapacityId(rmsCapacity.getCapacityId());
|
|
|
- }
|
|
|
- else {
|
|
|
- RmsCapacity rmsCapacity = new RmsCapacity();
|
|
|
- rmsCapacity.setCapacityId(rmsCapacityMapper.selectCapacityId());
|
|
|
- rmsCapacity.setCapacityNumber(capacityNumber);
|
|
|
- rmsCapacity.setCapacityTypeId(new BigDecimal(3));
|
|
|
- rmsCapacityMapper.insertSelective(rmsCapacity);
|
|
|
- realOmsshipInstructionsCapacity.setCapacityId(rmsCapacity.getCapacityId());
|
|
|
+ String omsship= (String) omsshipInstructionsCapacity.get("capacityIds");
|
|
|
+// 判断是否有id值传入,有则代表表中含有这个船名
|
|
|
+ if (omsship!=""){
|
|
|
+ Integer capacityNumber = (Integer) omsshipInstructionsCapacity.get("capacityIds");
|
|
|
+ realOmsshipInstructionsCapacity.setCapacityId(new BigDecimal(capacityNumber));
|
|
|
+ }else{
|
|
|
+// 判断用户输入的船名在数据库中是否存在
|
|
|
+ String capacityNumber=(String)omsshipInstructionsCapacity.get("capacityName");
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("capacityNumber",capacityNumber);
|
|
|
+// 查询运力表中是否含有对应的运力编号
|
|
|
+ List<RmsCapacity> rmsCapacities = rmsCapacityMapper.selectByParameters(map);
|
|
|
+ if (rmsCapacities.size() != 0 ) {
|
|
|
+// 当运力编号存在的时候,将获取到的运力编号的id插入进去
|
|
|
+ RmsCapacity rmsCapacity = rmsCapacities.get(0);
|
|
|
+ rmsCapacityMapper.updateByPrimaryKeySelective(rmsCapacity);
|
|
|
+ realOmsshipInstructionsCapacity.setCapacityId(rmsCapacity.getCapacityId());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+// 当运力编号不存在的时候,在运力表中新增一条运力信息,并将运力类型设置为3,也就是船类型
|
|
|
+ RmsCapacity rmsCapacity = new RmsCapacity();
|
|
|
+ rmsCapacity.setCapacityId(rmsCapacityMapper.selectCapacityId());
|
|
|
+ rmsCapacity.setCapacityNumber(capacityNumber);
|
|
|
+ rmsCapacity.setCapacityTypeId(new BigDecimal(3));
|
|
|
+ rmsCapacityMapper.insertSelective(rmsCapacity);
|
|
|
+ realOmsshipInstructionsCapacity.setCapacityId(rmsCapacity.getCapacityId());
|
|
|
+ }
|
|
|
}
|
|
|
String instructionPlannedLoading = (String) omsshipInstructionsCapacity.get("instructionPlannedLoading");
|
|
|
String instructionsShipPosition = (String) omsshipInstructionsCapacity.get("instructionsShipPosition");
|