|
@@ -7,18 +7,30 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.pj.api.client.admin.AdminInterface;
|
|
|
+import com.pj.api.dto.AppUserDto;
|
|
|
+import com.pj.current.dto.APPLoginUserInfo;
|
|
|
+import com.pj.current.dto.PCLoginUserInfo;
|
|
|
+import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
+import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.enummj.AuditStatus;
|
|
|
import com.pj.enummj.DeleteStatus;
|
|
|
import com.pj.enummj.GoodsStatus;
|
|
|
import com.pj.tb_enterprise.TbEnterprise;
|
|
|
import com.pj.tb_goods.TbGoods;
|
|
|
+import com.pj.tb_goods.TbGoodsMapper;
|
|
|
import com.pj.tb_goods_transit.param.JudgeTransitParam;
|
|
|
+import com.pj.tb_goods_transit.param.TransactionGoodsParam;
|
|
|
+import com.pj.tb_trade_area.TbTradeArea;
|
|
|
+import com.pj.tb_trade_area.TbTradeAreaMapper;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
@@ -40,9 +52,17 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
/** 底层 Mapper 对象 */
|
|
|
@Autowired
|
|
|
TbGoodsTransitMapper tbGoodsTransitMapper;
|
|
|
-
|
|
|
+ /** 方法抽取,代码优化 */
|
|
|
@Autowired
|
|
|
private MethodGoodsTransitService methodGoodsTransitService;
|
|
|
+ /** 监管产品mapper */
|
|
|
+ @Autowired
|
|
|
+ private TbGoodsMapper tbGoodsMapper;
|
|
|
+ @Autowired
|
|
|
+ private AdminInterface adminInterface;
|
|
|
+ /** 互市区mapper */
|
|
|
+ @Autowired
|
|
|
+ private TbTradeAreaMapper tbTradeAreaMapper;
|
|
|
|
|
|
/** 增 */
|
|
|
void add(TbGoodsTransit t){
|
|
@@ -113,6 +133,69 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
return "已完成 " + count + "条 数据审核!";
|
|
|
}
|
|
|
|
|
|
+ /** app端 - 添加需要交易的商品 */
|
|
|
+ public boolean transactionGoods(TransactionGoodsParam transactionGoodsParam){
|
|
|
+ //判断商品的净重毛重
|
|
|
+ Double netWeight = transactionGoodsParam.getNetWeight();
|
|
|
+ Double grossWeight = transactionGoodsParam.getGrossWeight();
|
|
|
+ if(netWeight > grossWeight){
|
|
|
+ throw new RuntimeException("净重超过了毛重,请检查输入。");
|
|
|
+ }
|
|
|
+ //获取当前登录人 todo:生产阶段需打开该注释
|
|
|
+// StpUserUtil.checkLogin();
|
|
|
+// long loginIdAsLong = StpUserUtil.getLoginIdAsLong();
|
|
|
+ Long loginIdAsLong = 4L;//测试阶段,写死appUser的id
|
|
|
+ AppUserDto appUserById = adminInterface.getAppUserById(loginIdAsLong);
|
|
|
+ if(appUserById == null)throw new RuntimeException("账户登录信息已失效!请重新登录");
|
|
|
+ //取出申报商品ID
|
|
|
+ Long id = transactionGoodsParam.getId();
|
|
|
+ //查询监管产品
|
|
|
+ TbGoods tbGoods = tbGoodsMapper.selectById(id);
|
|
|
+ if(tbGoods == null)throw new RuntimeException("该产品暂未录入监管列表!");
|
|
|
+ //查询互市区
|
|
|
+ TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(transactionGoodsParam.getTradeAreaId());
|
|
|
+ if(tbTradeArea == null)throw new RuntimeException("互市区不存在!");
|
|
|
+ //执行保存
|
|
|
+ TbGoodsTransit tbGoodsTransit = new TbGoodsTransit();
|
|
|
+ BeanUtils.copyProperties(transactionGoodsParam,tbGoodsTransit);
|
|
|
+ //获取并保存当前商品基本信息
|
|
|
+ tbGoodsTransit.setTradeAreaName(tbTradeArea.getName());
|
|
|
+ tbGoodsTransit.setGoodsName(tbGoods.getName());
|
|
|
+ tbGoodsTransit.setDescription(tbGoods.getRemark());
|
|
|
+ tbGoodsTransit.setPlaceOrigin(tbGoods.getSource());
|
|
|
+ tbGoodsTransit.setGoodsUnits(tbGoods.getUnit());
|
|
|
+ tbGoodsTransit.setGoodsType(tbGoods.getTypeNames());
|
|
|
+ //设置默认信息
|
|
|
+ tbGoodsTransit.setAuditStatus(1);//默认已过审
|
|
|
+ tbGoodsTransit.setGoodsStatus(1);//默认已上架
|
|
|
+ //设置基本信息
|
|
|
+ tbGoodsTransit.setCreateTime(new Date());
|
|
|
+ tbGoodsTransit.setCreateBy(loginIdAsLong + "");
|
|
|
+ tbGoodsTransit.setCreateName(appUserById.getName());
|
|
|
+ tbGoodsTransit.setDeleteStatus(1);
|
|
|
+ //执行保存
|
|
|
+ int insert = tbGoodsTransitMapper.insert(tbGoodsTransit);
|
|
|
+ if(insert == 1)return true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** app端 - 商户自行选择上架/下架商品 */
|
|
|
+ boolean UpOrDownGoods(Long goodsTransitId , Integer goodsStatus){
|
|
|
+ //获取当前登陆人
|
|
|
+ APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
+ if(appLoginInfo == null)throw new RuntimeException("当前登陆人不存在!");
|
|
|
+ TbGoodsTransit tbGoodsTransit = tbGoodsTransitMapper.selectById(goodsTransitId);
|
|
|
+ if(tbGoodsTransit == null)throw new RuntimeException("该商品状态异常或不存在!");
|
|
|
+ tbGoodsTransit.setGoodsStatus(goodsStatus == null? 0 : goodsStatus);
|
|
|
+ //设置基本属性
|
|
|
+ tbGoodsTransit.setUpdateTime(new Date());
|
|
|
+ tbGoodsTransit.setUpdateBy(appLoginInfo.getLoginId() + "");
|
|
|
+ tbGoodsTransit.setUpdateName(appLoginInfo.getLoginName());
|
|
|
+ //执行保存
|
|
|
+ int updateById = tbGoodsTransitMapper.updateById(tbGoodsTransit);
|
|
|
+ if(updateById == 1)return true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 导入
|
|
@@ -169,22 +252,24 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
row.createCell(3).setCellValue("商品类型");
|
|
|
row.createCell(4).setCellValue("商品名称");
|
|
|
row.createCell(5).setCellValue("商品单位");
|
|
|
- row.createCell(6).setCellValue("商品价格");
|
|
|
- row.createCell(7).setCellValue("海关申报单号");
|
|
|
- row.createCell(8).setCellValue("产地(国家)");
|
|
|
- row.createCell(9).setCellValue("商品描述");
|
|
|
- row.createCell(10).setCellValue("库存数量");
|
|
|
- row.createCell(11).setCellValue("商品状态");
|
|
|
- row.createCell(12).setCellValue("审核状态");
|
|
|
- row.createCell(13).setCellValue("审核时间");
|
|
|
- row.createCell(14).setCellValue("审核意见");
|
|
|
- row.createCell(15).setCellValue("创建时间");
|
|
|
- row.createCell(16).setCellValue("创建人编号");
|
|
|
- row.createCell(17).setCellValue("创建人名称");
|
|
|
- row.createCell(18).setCellValue("更新时间");
|
|
|
- row.createCell(19).setCellValue("更新人编号");
|
|
|
- row.createCell(20).setCellValue("更新人名称");
|
|
|
- row.createCell(21).setCellValue("删除状态");
|
|
|
+ row.createCell(6).setCellValue("净重");
|
|
|
+ row.createCell(7).setCellValue("毛重");
|
|
|
+ row.createCell(8).setCellValue("商品价格");
|
|
|
+ row.createCell(9).setCellValue("海关申报单号");
|
|
|
+ row.createCell(10).setCellValue("产地(国家)");
|
|
|
+ row.createCell(11).setCellValue("商品描述");
|
|
|
+ row.createCell(12).setCellValue("库存数量");
|
|
|
+ row.createCell(13).setCellValue("商品状态");
|
|
|
+ row.createCell(14).setCellValue("审核状态");
|
|
|
+ row.createCell(15).setCellValue("审核时间");
|
|
|
+ row.createCell(16).setCellValue("审核意见");
|
|
|
+ row.createCell(17).setCellValue("创建时间");
|
|
|
+ row.createCell(18).setCellValue("创建人编号");
|
|
|
+ row.createCell(19).setCellValue("创建人名称");
|
|
|
+ row.createCell(20).setCellValue("更新时间");
|
|
|
+ row.createCell(21).setCellValue("更新人编号");
|
|
|
+ row.createCell(22).setCellValue("更新人名称");
|
|
|
+ row.createCell(23).setCellValue("删除状态");
|
|
|
|
|
|
//定义计数器
|
|
|
int count = 0;
|
|
@@ -197,6 +282,8 @@ public class TbGoodsTransitService extends ServiceImpl<TbGoodsTransitMapper, TbG
|
|
|
sheetRow.createCell(3).setCellValue((selectedList.get(i).getGoodsType() + "").equals("null")? "": selectedList.get(i).getGoodsType() + "");
|
|
|
sheetRow.createCell(4).setCellValue((selectedList.get(i).getGoodsName() + "").equals("null")? "": selectedList.get(i).getGoodsName() + "");
|
|
|
sheetRow.createCell(5).setCellValue((selectedList.get(i).getGoodsUnits() + "").equals("null")? "": selectedList.get(i).getGoodsUnits() + "");
|
|
|
+ sheetRow.createCell(5).setCellValue((selectedList.get(i).getNetWeight() + "").equals("null")? "": selectedList.get(i).getNetWeight() + "");
|
|
|
+ sheetRow.createCell(5).setCellValue((selectedList.get(i).getGrossWeight() + "").equals("null")? "": selectedList.get(i).getGrossWeight() + "");
|
|
|
sheetRow.createCell(6).setCellValue((selectedList.get(i).getPrice() + "").equals("null")? "": selectedList.get(i).getPrice() + "");
|
|
|
sheetRow.createCell(6).setCellValue((selectedList.get(i).getDeclareOdd() + "").equals("null")? "": selectedList.get(i).getDeclareOdd() + "");
|
|
|
sheetRow.createCell(7).setCellValue((selectedList.get(i).getPlaceOrigin() + "").equals("null")? "": selectedList.get(i).getPlaceOrigin() + "");
|