船期计划排布
This commit is contained in:
@ -1,36 +1,50 @@
|
||||
package com.xjrsoft.module.ship.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xjrsoft.common.constant.GlobalConstant;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.pictc.datalog.DataOperationContent;
|
||||
import com.pictc.datalog.DataOperationListener;
|
||||
import com.pictc.enums.ApproveCodeEnum;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.jdbc.JdbcTools;
|
||||
import com.pictc.jdbc.model.JdbcParam;
|
||||
import com.pictc.utils.StringUtils;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.page.ConventPage;
|
||||
import com.xjrsoft.common.page.PageOutput;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.utils.VoToColumnUtil;
|
||||
import com.xjrsoft.module.ship.dto.AddLngShipScheduleDto;
|
||||
import com.xjrsoft.module.ship.dto.UpdateLngShipScheduleDto;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.dayPlan.entity.LngPngDemand;
|
||||
import com.xjrsoft.module.ship.dto.LngShipSchedulePageDto;
|
||||
import com.xjrsoft.module.ship.dto.UpdateLngShipScheduleDto;
|
||||
import com.xjrsoft.module.ship.entity.LngShipSchedule;
|
||||
import com.xjrsoft.module.ship.service.IShipScheduleService;
|
||||
import com.xjrsoft.module.ship.vo.LngShipSchedulePageVo;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.ship.vo.LngShipScheduleVo;
|
||||
import com.xjrsoft.module.system.client.ICodeRuleClient;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @title: 船期计划排布
|
||||
@ -47,6 +61,10 @@ public class ShipScheduleController {
|
||||
|
||||
private final IShipScheduleService shipScheduleService;
|
||||
private final DatalogService dataService;
|
||||
|
||||
private final ICodeRuleClient codeRuleClient;
|
||||
|
||||
private final String SHIP_SCHEDULE_CODE = "shipScheduleCode";
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@ApiOperation(value="LngShipSchedule列表(分页)")
|
||||
@ -94,22 +112,115 @@ public class ShipScheduleController {
|
||||
@ApiOperation(value = "新增LngShipSchedule")
|
||||
@SaCheckPermission("shipSchedule:add")
|
||||
public R add(@Valid @RequestBody UpdateLngShipScheduleDto dto){
|
||||
UpdateLngShipScheduleDto res = dataService.insert(dto);
|
||||
return R.ok(res.getId());
|
||||
}
|
||||
String ssNo = codeRuleClient.genEncode(SHIP_SCHEDULE_CODE);
|
||||
dto.setSsNo(ssNo);
|
||||
UpdateLngShipScheduleDto res = dataService.insert(dto,new DataOperationListener<UpdateLngShipScheduleDto>() {
|
||||
|
||||
@Override
|
||||
public UpdateLngShipScheduleDto before(DataOperationContent<UpdateLngShipScheduleDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngShipScheduleDto after(DataOperationContent<UpdateLngShipScheduleDto> content) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_save(?,?)}",
|
||||
content.getTableName());
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(content.getIdValue()));
|
||||
if(dto.getId() == null) {
|
||||
params.add(JdbcParam.ofString("I"));
|
||||
}else {
|
||||
params.add(JdbcParam.ofString("U"));
|
||||
}
|
||||
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
codeRuleClient.useEncode(SHIP_SCHEDULE_CODE);
|
||||
return content.getObj();
|
||||
|
||||
}
|
||||
});
|
||||
return R.ok(res);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改LngShipSchedule")
|
||||
@SaCheckPermission("shipSchedule:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngShipScheduleDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
return R.ok(dataService.updateById(dto, new DataOperationListener<UpdateLngShipScheduleDto>() {
|
||||
@Override
|
||||
public UpdateLngShipScheduleDto before(DataOperationContent<UpdateLngShipScheduleDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngShipScheduleDto after(DataOperationContent<UpdateLngShipScheduleDto> content) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_save(?,?)}",
|
||||
content.getTableName());
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(content.getIdValue()));
|
||||
if(dto.getId() == null) {
|
||||
params.add(JdbcParam.ofString("I"));
|
||||
}else {
|
||||
params.add(JdbcParam.ofString("U"));
|
||||
}
|
||||
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
return content.getObj();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("shipSchedule:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.deleteByIds(UpdateLngShipScheduleDto.class, ids));
|
||||
for(Long id:ids) {
|
||||
LngShipSchedule lngShipSchedule = shipScheduleService.getById(id);
|
||||
if (lngShipSchedule == null) {
|
||||
throw new BusinessException(BusinessCode.of(10500,"找不到此数据!"));
|
||||
|
||||
}
|
||||
if(!(lngShipSchedule.getOpsPurId() == null) &&
|
||||
!(lngShipSchedule.getOpsSalesId() == null) ) {
|
||||
throw new BusinessException(BusinessCode.of(10500,"已进行销售执行或采购执行,不能删除"));
|
||||
}
|
||||
}
|
||||
return R.ok(dataService.deleteByIds(UpdateLngShipScheduleDto.class, ids, new DataOperationListener<UpdateLngShipScheduleDto>() {
|
||||
@Override
|
||||
public UpdateLngShipScheduleDto before(DataOperationContent<UpdateLngShipScheduleDto> content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateLngShipScheduleDto after(DataOperationContent<UpdateLngShipScheduleDto> content) {
|
||||
String sql = StringUtils.format("{? = call pc_{0}.f_before_delete(?)}",
|
||||
content.getTableName());
|
||||
List<JdbcParam> params = Lists.newArrayList();
|
||||
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
|
||||
params.add(outParam);
|
||||
params.add(JdbcParam.ofLong(content.getIdValue()));
|
||||
|
||||
JdbcTools.call(sql,params);
|
||||
String error = outParam.getStringValue();
|
||||
if (StringUtils.isNotEmpty(error)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
|
||||
}
|
||||
return content.getObj();
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package com.xjrsoft.module.ship.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xjrsoft.module.dayPlan.vo.LngPngDemandVo;
|
||||
import com.xjrsoft.module.ship.entity.LngShipSchedule;
|
||||
import com.xjrsoft.module.ship.vo.LngShipScheduleVo;
|
||||
|
||||
/**
|
||||
* @title: mapper
|
||||
@ -13,5 +17,19 @@ import com.xjrsoft.module.ship.entity.LngShipSchedule;
|
||||
*/
|
||||
@Mapper
|
||||
public interface LngShipScheduleMapper extends BaseMapper<LngShipSchedule> {
|
||||
|
||||
@Select("SELECT ss.*,k.k_name,"+
|
||||
" dd_l.name AS long_spot_name, sl.full_name AS sta_name, dd_st.name AS ss_type_name, " +
|
||||
" port.full_name AS port_unloading1_name" +
|
||||
" FROM lng_ship_schedule ss " +
|
||||
" LEFT JOIN lng_contract k ON k.id=ss.k_id " +
|
||||
" LEFT JOIN lng_b_port port ON port.code=ss.port_unloading1_code "+
|
||||
" LEFT JOIN xjr_dictionary_item di_l on di_l.code='LNG_LONG' " +
|
||||
" LEFT JOIN xjr_dictionary_detail dd_l on dd_l.item_id=di_l.id AND dd_l.code=ss.long_spot_code " +
|
||||
" LEFT JOIN lng_b_station_lng sl ON sl.code=ss.sta_code " +
|
||||
" LEFT JOIN xjr_dictionary_item di_st on di_st.code='LNG_SHP_S' " +
|
||||
" LEFT JOIN xjr_dictionary_detail dd_st on dd_st.item_id=di_st.id AND dd_st.code=ss.ss_type_code " +
|
||||
" WHERE ss.id = #{id}")
|
||||
LngShipScheduleVo getInfoBygId(@Param("id") Long id);
|
||||
|
||||
}
|
||||
|
||||
@ -38,8 +38,8 @@ public class MeaPurIntServiceImpl extends ServiceImpl<LngMeaPurIntMapper, LngMea
|
||||
throw new BusinessException(BusinessCode.of(10500, "找不到此数据!"));
|
||||
}
|
||||
LngMeaPurIntVo vo = BeanUtil.toBean(lngMeaPurInt, LngMeaPurIntVo.class);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_mea_pur_int", "fileList", vo.getId());
|
||||
vo.setFileList(fileList);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_mea_pur_int", "lngFileUploadList", vo.getId());
|
||||
vo.setLngFileUploadList(fileList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ public class OpsPurIntServiceImpl extends ServiceImpl<LngOpsPurIntMapper, LngOps
|
||||
throw new BusinessException(BusinessCode.of(10500, "找不到此数据!"));
|
||||
}
|
||||
LngOpsPurIntVo vo = BeanUtil.toBean(lngOpsPurInt, LngOpsPurIntVo.class);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_ops_pur_int", "fileList", vo.getId());
|
||||
vo.setFileList(fileList);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_ops_pur_int", "lngFileUploadList", vo.getId());
|
||||
vo.setLngFileUploadList(fileList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@ -38,8 +38,8 @@ public class OpsSalesIntServiceImpl extends ServiceImpl<LngOpsSalesIntMapper, Ln
|
||||
throw new BusinessException(BusinessCode.of(10500, "找不到此数据!"));
|
||||
}
|
||||
LngOpsSalesIntVo vo = BeanUtil.toBean(lngOpsSalesInt, LngOpsSalesIntVo.class);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_ops_sales_int", "fileList", vo.getId());
|
||||
vo.setFileList(fileList);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_ops_sales_int", "lngFileUploadList", vo.getId());
|
||||
vo.setLngFileUploadList(fileList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@ -31,13 +31,9 @@ public class ShipScheduleServiceImpl extends ServiceImpl<LngShipScheduleMapper,
|
||||
|
||||
@Override
|
||||
public LngShipScheduleVo getShipScheduleById(Long id) {
|
||||
LngShipSchedule lngShipSchedule = this.getById(id);
|
||||
if (lngShipSchedule == null) {
|
||||
throw new BusinessException(BusinessCode.of(10500, "找不到此数据!"));
|
||||
}
|
||||
LngShipScheduleVo vo = BeanUtil.toBean(lngShipSchedule, LngShipScheduleVo.class);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_ship_schedule", "fileList", vo.getId());
|
||||
vo.setFileList(fileList);
|
||||
LngShipScheduleVo vo = this.baseMapper.getInfoBygId(id);
|
||||
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_ship_schedule", "lngFileUploadList", vo.getId());
|
||||
vo.setLngFileUploadList(fileList);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user