|
@@ -0,0 +1,340 @@
|
|
|
+/*
|
|
|
+ * Copyright [2022] [https://www.xiaonuo.vip]
|
|
|
+ *
|
|
|
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
|
|
+ *
|
|
|
+ * 1.请不要删除和修改根目录下的LICENSE文件。
|
|
|
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
|
|
|
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
|
|
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
|
|
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
|
|
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
|
|
+ */
|
|
|
+package vip.xiaonuo.biz.modular.bizloadarrive.service.impl;
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollStreamUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fhs.trans.service.impl.TransService;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
+import vip.xiaonuo.biz.modular.bizauditlog.entity.BizAuditLog;
|
|
|
+import vip.xiaonuo.biz.modular.bizauditlog.service.BizAuditLogService;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadappoint.entity.BizLoadAppoint;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadappoint.param.BizLoadAppointExportResult;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadappoint.service.BizLoadAppointService;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadarrive.param.*;
|
|
|
+import vip.xiaonuo.biz.modular.bizsettle.entity.BizSettle;
|
|
|
+import vip.xiaonuo.biz.modular.bizsupplier.entity.BizSupplierTransport;
|
|
|
+import vip.xiaonuo.biz.modular.bizsupplier.service.BizSupplierTransportService;
|
|
|
+import vip.xiaonuo.biz.modular.utils.CommonExportUtil;
|
|
|
+import vip.xiaonuo.common.enums.CommonSortOrderEnum;
|
|
|
+import vip.xiaonuo.common.exception.CommonException;
|
|
|
+import vip.xiaonuo.common.page.CommonPageRequest;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadarrive.entity.BizLoadArrive;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadarrive.mapper.BizLoadArriveMapper;
|
|
|
+import vip.xiaonuo.biz.modular.bizloadarrive.service.BizLoadArriveService;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 报港预约Service接口实现类
|
|
|
+ *
|
|
|
+ * @author fanzherong
|
|
|
+ * @date 2025/06/26 14:12
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+public class BizLoadArriveServiceImpl extends ServiceImpl<BizLoadArriveMapper, BizLoadArrive> implements BizLoadArriveService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BizLoadAppointService bizLoadAppointService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BizSupplierTransportService bizSupplierTransportService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BizAuditLogService bizAuditLogService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TransService transService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<BizLoadArrive> page(BizLoadArrivePageParam bizLoadArrivePageParam) {
|
|
|
+ QueryWrapper<BizLoadArrive> queryWrapper = getQueryWrapper(bizLoadArrivePageParam);
|
|
|
+ Page<BizLoadArrive> page = this.getBaseMapper().getPage(CommonPageRequest.defaultPage(), queryWrapper);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ public QueryWrapper<BizLoadArrive> getQueryWrapper(BizLoadArrivePageParam bizLoadArrivePageParam){
|
|
|
+ QueryWrapper<BizLoadArrive> queryWrapper = new QueryWrapper<BizLoadArrive>().checkSqlInjection();
|
|
|
+ //客户名称
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getCustomerName())){
|
|
|
+ queryWrapper.like("bsc.`name`",bizLoadArrivePageParam.getCustomerName());
|
|
|
+ }
|
|
|
+ //联系人
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getCustomerContact())){
|
|
|
+ queryWrapper.like("bsc.contact",bizLoadArrivePageParam.getCustomerContact());
|
|
|
+ }
|
|
|
+ //联系方式
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getCustomerPhone())){
|
|
|
+ queryWrapper.like("bsc.phone",bizLoadArrivePageParam.getCustomerPhone());
|
|
|
+ }
|
|
|
+ //客户i地址
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getCustomerAddress())){
|
|
|
+ queryWrapper.like("bsc.address",bizLoadArrivePageParam.getCustomerAddress());
|
|
|
+ }
|
|
|
+ //货品名称
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getGoodsName())){
|
|
|
+ queryWrapper.like("bg.GOODS_NAME",bizLoadArrivePageParam.getGoodsName());
|
|
|
+ }
|
|
|
+ //船号
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getShipNo())){
|
|
|
+ queryWrapper.like("blv.ship_no",bizLoadArrivePageParam.getShipNo());
|
|
|
+ }
|
|
|
+ //到港时间
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getArriveTimeBegin()) &&
|
|
|
+ ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getArriveTimeEnd())){
|
|
|
+ queryWrapper.between("blv.arrive_time",bizLoadArrivePageParam.getArriveTimeBegin()+" 00:00:00",
|
|
|
+ bizLoadArrivePageParam.getArriveTimeEnd()+ " 23:59:59");
|
|
|
+ }
|
|
|
+ //起卸预约单号
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getLoadNumber())){
|
|
|
+ queryWrapper.like("bla.load_number",bizLoadArrivePageParam.getLoadNumber());
|
|
|
+ }
|
|
|
+ //状态查询
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArrivePageParam.getStatus())){
|
|
|
+ queryWrapper.eq("blv.status",bizLoadArrivePageParam.getStatus());
|
|
|
+ }
|
|
|
+ // 校验数据范围
|
|
|
+ List<String> loginUserDataScope = StpLoginUserUtil.getLoginUserDataScope();
|
|
|
+ if(ObjectUtil.isEmpty(loginUserDataScope)) {
|
|
|
+ queryWrapper.eq("blv.create_user", StpUtil.getLoginIdAsString());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("blv.delete_flag","NOT_DELETE");
|
|
|
+ queryWrapper.orderByDesc("blv.create_time");
|
|
|
+ return queryWrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void add(BizLoadArriveAddParam bizLoadArriveAddParam) {
|
|
|
+ checkParam(bizLoadArriveAddParam);
|
|
|
+ BizLoadArrive bizLoadArrive = BeanUtil.toBean(bizLoadArriveAddParam, BizLoadArrive.class);
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveAddParam.getFileNameList())){
|
|
|
+ StringBuffer nameBuffer = new StringBuffer();
|
|
|
+ for(String name : bizLoadArriveAddParam.getFileNameList()){
|
|
|
+ nameBuffer.append(name+",");
|
|
|
+ }
|
|
|
+ bizLoadArrive.setSailFileName(nameBuffer.substring(0,nameBuffer.length()-1));
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveAddParam.getFilePathList())){
|
|
|
+ StringBuffer pathBuffer = new StringBuffer();
|
|
|
+ for(String path : bizLoadArriveAddParam.getFilePathList()){
|
|
|
+ pathBuffer.append(path+",");
|
|
|
+ }
|
|
|
+ bizLoadArrive.setSailFilePath(pathBuffer.substring(0,pathBuffer.length()-1));
|
|
|
+ }
|
|
|
+ bizLoadArrive.setArriveNumber(bizLoadArrive.getArriveNumber().multiply(new BigDecimal(1000)));
|
|
|
+ this.save(bizLoadArrive);
|
|
|
+
|
|
|
+ //修改状态
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveAddParam.getAppointId())){
|
|
|
+ BizLoadAppoint loadAppoint = bizLoadAppointService.getById(bizLoadArriveAddParam.getAppointId());
|
|
|
+ if(ObjectUtil.isNotNull(loadAppoint)){
|
|
|
+ loadAppoint.setStatus("3");
|
|
|
+ bizLoadAppointService.updateById(loadAppoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkParam(BizLoadArriveAddParam bizLoadArriveAddParam){
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveAddParam.getShipNo())){
|
|
|
+ bizLoadArriveAddParam.setShipNo(bizLoadArriveAddParam.getShipNo().toUpperCase().trim());
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveAddParam.getAppointId())){
|
|
|
+ //查询起卸预约信息
|
|
|
+ BizLoadAppoint bizLoadAppoint = bizLoadAppointService.getById(bizLoadArriveAddParam.getAppointId());
|
|
|
+ if(ObjectUtil.isNotNull(bizLoadAppoint)){
|
|
|
+ //查询船号是否在船运供应商下
|
|
|
+ BizSupplierTransport transport = bizSupplierTransportService.getOne(new QueryWrapper<BizSupplierTransport>().lambda().
|
|
|
+ eq(BizSupplierTransport::getSupplierId, bizLoadAppoint.getSupplierId()).
|
|
|
+ eq(BizSupplierTransport::getTransportNo, bizLoadArriveAddParam.getShipNo()).
|
|
|
+ eq(BizSupplierTransport::getAuditStatus,"2").
|
|
|
+ last("limit 1"));
|
|
|
+ if(ObjectUtil.isNull(transport)){
|
|
|
+ throw new CommonException("该船号没有绑定供应商!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断起卸预约是否添加过
|
|
|
+ long count = this.count(new QueryWrapper<BizLoadArrive>().lambda().eq(BizLoadArrive::getAppointId, bizLoadArriveAddParam.getAppointId()));
|
|
|
+ if(count>0){
|
|
|
+ throw new CommonException("起卸预约已经添加过!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void edit(BizLoadArriveEditParam bizLoadArriveEditParam) {
|
|
|
+ BizLoadArrive bizLoadArrive = this.queryEntity(bizLoadArriveEditParam.getId());
|
|
|
+ checkParam(bizLoadArriveEditParam,bizLoadArrive);
|
|
|
+ if(!StringUtils.equals(bizLoadArrive.getAppointId(),bizLoadArriveEditParam.getAppointId())){
|
|
|
+ //修改原起卸预约单状态
|
|
|
+ BizLoadAppoint loadAppoint = bizLoadAppointService.getById(bizLoadArrive.getAppointId());
|
|
|
+ if(ObjectUtil.isNotNull(loadAppoint)){
|
|
|
+ loadAppoint.setStatus("2");
|
|
|
+ bizLoadAppointService.updateById(loadAppoint);
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改现起卸预约单状态
|
|
|
+ BizLoadAppoint loadAppointNew = bizLoadAppointService.getById(bizLoadArriveEditParam.getAppointId());
|
|
|
+ if(ObjectUtil.isNotNull(loadAppointNew)){
|
|
|
+ loadAppointNew.setStatus("3");
|
|
|
+ bizLoadAppointService.updateById(loadAppointNew);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(bizLoadArriveEditParam, bizLoadArrive);
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveEditParam.getFileNameList())){
|
|
|
+ StringBuffer nameBuffer = new StringBuffer();
|
|
|
+ for(String name : bizLoadArriveEditParam.getFileNameList()){
|
|
|
+ nameBuffer.append(name+",");
|
|
|
+ }
|
|
|
+ bizLoadArrive.setSailFileName(nameBuffer.substring(0,nameBuffer.length()-1));
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveEditParam.getFilePathList())){
|
|
|
+ StringBuffer pathBuffer = new StringBuffer();
|
|
|
+ for(String path : bizLoadArriveEditParam.getFilePathList()){
|
|
|
+ pathBuffer.append(path+",");
|
|
|
+ }
|
|
|
+ bizLoadArrive.setSailFilePath(pathBuffer.substring(0,pathBuffer.length()-1));
|
|
|
+ }
|
|
|
+ bizLoadArrive.setArriveNumber(bizLoadArrive.getArriveNumber().multiply(new BigDecimal(1000)));
|
|
|
+ if(StringUtils.equals(bizLoadArrive.getStatus(),"3")){
|
|
|
+ bizLoadArrive.setStatus("1");
|
|
|
+ }
|
|
|
+ this.updateById(bizLoadArrive);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkParam(BizLoadArriveEditParam bizLoadArriveEditParam,BizLoadArrive bizLoadArrive){
|
|
|
+ if(ObjectUtil.isNotEmpty(bizLoadArriveEditParam.getShipNo())){
|
|
|
+ bizLoadArriveEditParam.setShipNo(bizLoadArriveEditParam.getShipNo().toUpperCase().trim());
|
|
|
+ }
|
|
|
+ if(!StringUtils.equals(bizLoadArrive.getAppointId(),bizLoadArriveEditParam.getAppointId()) ||
|
|
|
+ !StringUtils.equals(bizLoadArrive.getShipNo(),bizLoadArriveEditParam.getShipNo())){
|
|
|
+ //如果船号和起卸预约订单有变化,判断船号是否绑定供应商
|
|
|
+ //查询起卸预约信息
|
|
|
+ BizLoadAppoint bizLoadAppoint = bizLoadAppointService.getById(bizLoadArriveEditParam.getAppointId());
|
|
|
+ if(ObjectUtil.isNotNull(bizLoadAppoint)){
|
|
|
+ //查询船号是否在船运供应商下
|
|
|
+ BizSupplierTransport transport = bizSupplierTransportService.getOne(new QueryWrapper<BizSupplierTransport>().lambda().
|
|
|
+ eq(BizSupplierTransport::getSupplierId, bizLoadAppoint.getSupplierId()).
|
|
|
+ eq(BizSupplierTransport::getTransportNo, bizLoadArriveEditParam.getShipNo()).
|
|
|
+ eq(BizSupplierTransport::getAuditStatus,"2").
|
|
|
+ last("limit 1"));
|
|
|
+ if(ObjectUtil.isNull(transport)){
|
|
|
+ throw new CommonException("该船号没有绑定供应商!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!StringUtils.equals(bizLoadArrive.getAppointId(),bizLoadArriveEditParam.getAppointId())){
|
|
|
+ //判断起卸预约是否添加过
|
|
|
+ long count = this.count(new QueryWrapper<BizLoadArrive>().lambda().eq(BizLoadArrive::getAppointId, bizLoadArriveEditParam.getAppointId()));
|
|
|
+ if(count>0){
|
|
|
+ throw new CommonException("起卸预约已经添加过!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void delete(List<BizLoadArriveIdParam> bizLoadArriveIdParamList) {
|
|
|
+ //修改起卸预约状态
|
|
|
+ for(BizLoadArriveIdParam bizLoadArriveIdParam : bizLoadArriveIdParamList){
|
|
|
+ BizLoadArrive bizLoadArrive = this.queryEntity(bizLoadArriveIdParam.getId());
|
|
|
+ BizLoadAppoint loadAppoint = bizLoadAppointService.getById(bizLoadArrive.getAppointId());
|
|
|
+ if(ObjectUtil.isNotNull(loadAppoint)){
|
|
|
+ loadAppoint.setStatus("2");
|
|
|
+ bizLoadAppointService.updateById(loadAppoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 执行删除
|
|
|
+ this.removeByIds(CollStreamUtil.toList(bizLoadArriveIdParamList, BizLoadArriveIdParam::getId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BizLoadArrive detail(BizLoadArriveIdParam bizLoadArriveIdParam) {
|
|
|
+ return this.queryEntity(bizLoadArriveIdParam.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BizLoadArrive queryEntity(String id) {
|
|
|
+ BizLoadArrive bizLoadArrive = this.getById(id);
|
|
|
+ if(ObjectUtil.isEmpty(bizLoadArrive)) {
|
|
|
+ throw new CommonException("报港预约不存在,id值为:{}", id);
|
|
|
+ }
|
|
|
+ return bizLoadArrive;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void auditArrive(BizLoadArriveEditParam bizLoadArriveEditParam) {
|
|
|
+ BizLoadArrive bizLoadArrive = this.queryEntity(bizLoadArriveEditParam.getId());
|
|
|
+ String status = "";
|
|
|
+ String auditStatus = "";
|
|
|
+ if(StringUtils.equals(bizLoadArriveEditParam.getAuditFlag(),"true")){
|
|
|
+ //审核通过
|
|
|
+ status="2";
|
|
|
+ auditStatus = "1";
|
|
|
+ }else{
|
|
|
+ status = "3";
|
|
|
+ auditStatus = "2";
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改状态
|
|
|
+ UpdateWrapper<BizLoadArrive> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.set("status",status).eq("id",bizLoadArrive.getId());
|
|
|
+ this.update(updateWrapper);
|
|
|
+
|
|
|
+ //插入审核记录
|
|
|
+ BizAuditLog bizAuditLog = new BizAuditLog();
|
|
|
+ bizAuditLog.setType("BGYY");
|
|
|
+ bizAuditLog.setDataId(bizLoadArrive.getId());
|
|
|
+ bizAuditLog.setStatus(auditStatus);
|
|
|
+ bizAuditLog.setRemark(bizLoadArriveEditParam.getArriveReason());
|
|
|
+ bizAuditLogService.save(bizAuditLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportRecord(BizLoadArrivePageParam bizLoadArrivePageParam, HttpServletResponse response) {
|
|
|
+ QueryWrapper<BizLoadArrive> queryWrapper = getQueryWrapper(bizLoadArrivePageParam);
|
|
|
+ List<BizLoadArrive> arriveList = this.getBaseMapper().getPage(queryWrapper);
|
|
|
+ if(ObjectUtil.isEmpty(arriveList)){
|
|
|
+ throw new CommonException("无数据可导出!");
|
|
|
+ }
|
|
|
+ String fileName = "报港预约报表.xlsx";
|
|
|
+ List<BizLoadArriveExportResult> list = Lists.newArrayList();
|
|
|
+ transService.transBatch(arriveList);
|
|
|
+ for(BizLoadArrive bizLoadArrive : arriveList){
|
|
|
+ BizLoadArriveExportResult bizLoadArriveExportResult = new BizLoadArriveExportResult();
|
|
|
+ BeanUtil.copyProperties(bizLoadArrive, bizLoadArriveExportResult);
|
|
|
+ bizLoadArriveExportResult.setStatus((String) bizLoadArrive.getTransMap().get("statusName"));
|
|
|
+ list.add(bizLoadArriveExportResult);
|
|
|
+ }
|
|
|
+ CommonExportUtil.export(fileName, BizLoadArriveExportResult.class,list,response,"报港预约报表");
|
|
|
+ }
|
|
|
+}
|