|
@@ -0,0 +1,239 @@
|
|
|
|
+package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import com.yh.saas.common.support.util.IdGenerator;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.mapper.FreightReceivingDispatchingMapper;
|
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.*;
|
|
|
|
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * <p>
|
|
|
|
+ * 货运收发信息 服务实现类
|
|
|
|
+ * </p>
|
|
|
|
+ *
|
|
|
|
+ * @author Gongdc
|
|
|
|
+ * @since 2021-08-19
|
|
|
|
+ */
|
|
|
|
+@Service
|
|
|
|
+public class FreightReceivingDispatchingServiceImpl extends ServiceImpl<FreightReceivingDispatchingMapper, FreightReceivingDispatching> implements IFreightReceivingDispatchingService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IFreightReceivingDispatchingCarService freightReceivingDispatchingCarService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IReceivingUserService receivingUserService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 货运收发列表
|
|
|
|
+ *
|
|
|
|
+ * @param freightReceivingDispatching
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Page<FreightReceivingDispatching> selectFreightReceivingDispatchingPage(FreightReceivingDispatching freightReceivingDispatching) {
|
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
|
+ pageView.put("startRecord", (freightReceivingDispatching.getCurrentPage() - 1)
|
|
|
|
+ * freightReceivingDispatching.getPageSize());
|
|
|
|
+ List<String> idList = new ArrayList<>();
|
|
|
|
+ List<ReceivingUser> receivingUsers = receivingUserService.selectList(new EntityWrapper<ReceivingUser>()
|
|
|
|
+ .eq("receive_phone", freightReceivingDispatching.getAccountNumber()));
|
|
|
|
+ for(ReceivingUser receivingUser : receivingUsers){
|
|
|
|
+ idList.add(receivingUser.getInfoId());
|
|
|
|
+ }
|
|
|
|
+ //公司id
|
|
|
|
+ pageView.put("compId", freightReceivingDispatching.getCompId());
|
|
|
|
+ pageView.put("searchType", freightReceivingDispatching.getSearchType());
|
|
|
|
+ pageView.put("searchKeyWord", freightReceivingDispatching.getSearchKeyWord());
|
|
|
|
+ pageView.put("accountNumber", freightReceivingDispatching.getAccountNumber());
|
|
|
|
+ pageView.put("idList", idList);
|
|
|
|
+ pageView.put("pageSize", freightReceivingDispatching.getPageSize());
|
|
|
|
+ pageView.put("currentPage", freightReceivingDispatching.getCurrentPage());
|
|
|
|
+ // 查询总数
|
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
|
+ List<FreightReceivingDispatching> dataList = baseMapper.getListByCondition(pageView);
|
|
|
|
+ Page<FreightReceivingDispatching> page = new Page<>();
|
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
|
+ page.setCurrent(freightReceivingDispatching.getCurrentPage());
|
|
|
|
+ page.setSize(freightReceivingDispatching.getPageSize());
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除信息
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void deleteFreightReceivingDispatching(String id) {
|
|
|
|
+ //删除司机信息
|
|
|
|
+ FreightReceivingDispatching freightReceivingDispatching = this.selectById(id);
|
|
|
|
+ this.deleteById(freightReceivingDispatching.getId());
|
|
|
|
+ //删除详细信息
|
|
|
|
+ List<FreightReceivingDispatchingCar> freightReceivingDispatchingCars = freightReceivingDispatchingCarService.selectList(new EntityWrapper<FreightReceivingDispatchingCar>()
|
|
|
|
+ .eq("info_id", id));
|
|
|
|
+ if (!CollectionUtils.isEmpty(freightReceivingDispatchingCars)) {
|
|
|
|
+ for (FreightReceivingDispatchingCar freightReceivingDispatchingCar : freightReceivingDispatchingCars) {
|
|
|
|
+ freightReceivingDispatchingCarService.deleteById(freightReceivingDispatchingCar.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //删除收货人信息
|
|
|
|
+ List<ReceivingUser> receivingUsers = receivingUserService.selectList(new EntityWrapper<ReceivingUser>()
|
|
|
|
+ .eq("info_id", id));
|
|
|
|
+ if (!CollectionUtils.isEmpty(receivingUsers)) {
|
|
|
|
+ for (ReceivingUser receivingUser : receivingUsers) {
|
|
|
|
+ receivingUserService.deleteById(receivingUser.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加
|
|
|
|
+ *
|
|
|
|
+ * @param freightReceivingDispatching
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String insertFreightReceivingDispatching(FreightReceivingDispatching freightReceivingDispatching) {
|
|
|
|
+ freightReceivingDispatching.setId(IdGenerator.generateUUID());
|
|
|
|
+ freightReceivingDispatching.setStatusFlag("1");
|
|
|
|
+ freightReceivingDispatching.setStatus("发货");
|
|
|
|
+ this.insert(freightReceivingDispatching);
|
|
|
|
+ return freightReceivingDispatching.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加发车信息
|
|
|
|
+ *
|
|
|
|
+ * @param freightReceivingDispatchingCar
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String insertFreightReceivingDispatchingCar(FreightReceivingDispatchingCar freightReceivingDispatchingCar) {
|
|
|
|
+ freightReceivingDispatchingCar.setId(IdGenerator.generateUUID());
|
|
|
|
+ freightReceivingDispatchingCar.setStatusFlag("1");
|
|
|
|
+ freightReceivingDispatchingCar.setStatus("待签收");
|
|
|
|
+ freightReceivingDispatchingCarService.insert(freightReceivingDispatchingCar);
|
|
|
|
+ FreightReceivingDispatching freightReceivingDispatching = this.selectById(freightReceivingDispatchingCar.getInfoId());
|
|
|
|
+ if (freightReceivingDispatching != null) {
|
|
|
|
+ freightReceivingDispatching.setSignedFor(String.valueOf(Integer.valueOf(freightReceivingDispatching.getSignedFor()) + 1));
|
|
|
|
+ this.updateById(freightReceivingDispatching);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return freightReceivingDispatchingCar.getInfoId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 付扣运费款
|
|
|
|
+ *
|
|
|
|
+ * @param freightReceivingDispatchingCar
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String paymentAndDeductionfreight(FreightReceivingDispatchingCar freightReceivingDispatchingCar) {
|
|
|
|
+ FreightReceivingDispatchingCar freightReceivingDispatchingCar1 = freightReceivingDispatchingCarService.selectById(freightReceivingDispatchingCar.getId());
|
|
|
|
+ freightReceivingDispatchingCar1.setFreightIngPayable(freightReceivingDispatchingCar.getFreightIngPayable());
|
|
|
|
+ // 付款金额 用已付这个字段 然后累加
|
|
|
|
+ freightReceivingDispatchingCar1.setFreightEdPayable(freightReceivingDispatchingCar1.getFreightEdPayable() + freightReceivingDispatchingCar.getFreightEdPayable());
|
|
|
|
+ freightReceivingDispatchingCar1.setFreightDeductionAmount(freightReceivingDispatchingCar.getFreightDeductionAmount());
|
|
|
|
+ freightReceivingDispatchingCarService.updateById(freightReceivingDispatchingCar1);
|
|
|
|
+ return freightReceivingDispatchingCar.getInfoId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 付扣货款
|
|
|
|
+ *
|
|
|
|
+ * @param freightReceivingDispatchingCar
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String PaymentDeduction(FreightReceivingDispatchingCar freightReceivingDispatchingCar) {
|
|
|
|
+ FreightReceivingDispatchingCar freightReceivingDispatchingCar1 = freightReceivingDispatchingCarService.selectById(freightReceivingDispatchingCar.getId());
|
|
|
|
+ freightReceivingDispatchingCar1.setGoodsIngPayable(freightReceivingDispatchingCar.getGoodsIngPayable());
|
|
|
|
+ // 付款金额 用已付这个字段 然后累加
|
|
|
|
+ freightReceivingDispatchingCar1.setFreightEdPayable(freightReceivingDispatchingCar1.getFreightEdPayable() + freightReceivingDispatchingCar.getFreightEdPayable());
|
|
|
|
+ freightReceivingDispatchingCar1.setGoodsDeductionAmount(freightReceivingDispatchingCar.getGoodsDeductionAmount());
|
|
|
|
+ if (freightReceivingDispatchingCar1.getGoodsIngPayable() == freightReceivingDispatchingCar1.getGoodsEdPayable()) {
|
|
|
|
+ freightReceivingDispatchingCar1.setStatusFlag("5");
|
|
|
|
+ freightReceivingDispatchingCar1.setStatus("已完成");
|
|
|
|
+ }
|
|
|
|
+ FreightReceivingDispatching freightReceivingDispatching = this.selectById(freightReceivingDispatchingCar.getInfoId());
|
|
|
|
+ if (freightReceivingDispatching != null) {
|
|
|
|
+ freightReceivingDispatching.setToSettled(String.valueOf(Integer.valueOf(freightReceivingDispatching.getToSettled()) - 1));
|
|
|
|
+ this.updateById(freightReceivingDispatching);
|
|
|
|
+ }
|
|
|
|
+ freightReceivingDispatchingCarService.updateById(freightReceivingDispatchingCar1);
|
|
|
|
+ return freightReceivingDispatchingCar.getInfoId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 确认收货
|
|
|
|
+ *
|
|
|
|
+ * @param freightReceivingDispatchingCar
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String confirmFreightReceivingDispatchingCar(FreightReceivingDispatchingCar freightReceivingDispatchingCar) {
|
|
|
|
+ freightReceivingDispatchingCar.setId(IdGenerator.generateUUID());
|
|
|
|
+ freightReceivingDispatchingCar.setStatusFlag("3");
|
|
|
|
+ freightReceivingDispatchingCar.setStatus("待结算");
|
|
|
|
+ freightReceivingDispatchingCarService.insert(freightReceivingDispatchingCar);
|
|
|
|
+ FreightReceivingDispatching freightReceivingDispatching = this.selectById(freightReceivingDispatchingCar.getInfoId());
|
|
|
|
+ if (freightReceivingDispatching != null) {
|
|
|
|
+ freightReceivingDispatching.setToSettled(String.valueOf(Integer.valueOf(freightReceivingDispatching.getToSettled()) + 1));
|
|
|
|
+ freightReceivingDispatching.setStatusFlag("2");
|
|
|
|
+ freightReceivingDispatching.setStatus("收货");
|
|
|
|
+ this.updateById(freightReceivingDispatching);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return freightReceivingDispatchingCar.getInfoId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加收货人
|
|
|
|
+ *
|
|
|
|
+ * @param receivingUser
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String insertReceivingUser(ReceivingUser receivingUser) {
|
|
|
|
+ receivingUser.setId(IdGenerator.generateUUID());
|
|
|
|
+ receivingUserService.insert(receivingUser);
|
|
|
|
+ return receivingUser.getInfoId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看详情
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public FreightReceivingDispatching getFreightReceivingDispatching(String id) {
|
|
|
|
+ //查看信息
|
|
|
|
+ FreightReceivingDispatching freightReceivingDispatching = this.selectById(id);
|
|
|
|
+ // 查看详情
|
|
|
|
+ List<FreightReceivingDispatchingCar> freightReceivingDispatchingCars = freightReceivingDispatchingCarService.selectList(new EntityWrapper<FreightReceivingDispatchingCar>()
|
|
|
|
+ .eq("info_id", id));
|
|
|
|
+ freightReceivingDispatching.setFreightReceivingDispatchingCars(freightReceivingDispatchingCars);
|
|
|
|
+ return freightReceivingDispatching;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|