|
@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
|
|
import com.ruoyi.basicData.domain.TCustomerContact;
|
|
import com.ruoyi.basicData.domain.TCustomerContact;
|
|
import com.ruoyi.basicData.mapper.TCustomerContactMapper;
|
|
import com.ruoyi.basicData.mapper.TCustomerContactMapper;
|
|
import com.ruoyi.basicData.mapper.TWarehouseMapper;
|
|
import com.ruoyi.basicData.mapper.TWarehouseMapper;
|
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
import com.ruoyi.common.core.domain.entity.TWarehouse;
|
|
import com.ruoyi.common.core.domain.entity.TWarehouse;
|
|
@@ -30,6 +31,7 @@ import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -58,6 +60,219 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
|
|
@Autowired
|
|
@Autowired
|
|
private TWarehousebillsitemsMapper tWarehousebillsitemsMapper;
|
|
private TWarehousebillsitemsMapper tWarehousebillsitemsMapper;
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public AjaxResult superviseExport(TWhgenleg tWhgenleg) {
|
|
|
|
+ List<Map<String,Object>> list = tWhgenlegMapper.selectWhgenlegList(tWhgenleg);
|
|
|
|
+ Date nowDate = new Date();
|
|
|
|
+ String fileName = "LHHT_STOCKAPPLY_" + new SimpleDateFormat("yyyyMMdd").format(nowDate) + ".FLJGRX";
|
|
|
|
+ // 应用号
|
|
|
|
+ String APP_CODE = "SAS";
|
|
|
|
+ // 环节号
|
|
|
|
+ String APP_STEP_ID = "8910000438957";
|
|
|
|
+ // 序列化类名
|
|
|
|
+ String CLASS_NAME = "XMLOject";
|
|
|
|
+ // 版本号
|
|
|
|
+ String CLASS_VER = "1.0";
|
|
|
|
+ // 生成时间
|
|
|
|
+ String FILE_DATE_TIME = new SimpleDateFormat("yyyy-MM-dd").format(nowDate);
|
|
|
|
+ // 生成人
|
|
|
|
+ String FILE_GERATER = "青岛道合供应链";
|
|
|
|
+ // 顺序
|
|
|
|
+ String FILE_ORDER = "1";
|
|
|
|
+ // 文件名
|
|
|
|
+ String FILE_ORIGINAL_NAME = fileName;
|
|
|
|
+ // 大小
|
|
|
|
+ String FILE_SIZE = String.valueOf(getFileSize(fileName));
|
|
|
|
+ // 类型
|
|
|
|
+ String XML_TYPE = "W3C";
|
|
|
|
+ // 经营单位代码
|
|
|
|
+ String TRADE_CODE = "35034092-9";
|
|
|
|
+ // 经营单位名称
|
|
|
|
+ String TRADE_NAME = "青岛道合供应链管理有限公司";
|
|
|
|
+ // 报送日期
|
|
|
|
+ String APPLY_DATE = new SimpleDateFormat("yyyyMMdd").format(nowDate);
|
|
|
|
+ try {
|
|
|
|
+ FileWriter fw =new FileWriter(getAbsoluteFile(fileName));
|
|
|
|
+ BufferedWriter bw = new BufferedWriter(fw);
|
|
|
|
+ // 写入头部
|
|
|
|
+ bw.write(
|
|
|
|
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
|
|
|
|
+ "<XMLObject>\n" +
|
|
|
|
+ " <APP_CODE>"+ APP_CODE +"</APP_CODE>\n" +
|
|
|
|
+ " <APP_STEP_ID>"+ APP_STEP_ID +"</APP_STEP_ID>\n" +
|
|
|
|
+ " <CLASS_NAME>"+ CLASS_NAME +"</CLASS_NAME>\n" +
|
|
|
|
+ " <CLASS_VER>"+ CLASS_VER +"</CLASS_VER>\n" +
|
|
|
|
+ " <FILE_DATE_TIME>"+ FILE_DATE_TIME +"</FILE_DATE_TIME>\n" +
|
|
|
|
+ " <FILE_GERATER>"+ FILE_GERATER +"</FILE_GERATER>\n" +
|
|
|
|
+ " <FILE_ORDER>"+ FILE_ORDER +"</FILE_ORDER>\n" +
|
|
|
|
+ " <FILE_ORIGINAL_NAME>"+ FILE_ORIGINAL_NAME +"</FILE_ORIGINAL_NAME>\n" +
|
|
|
|
+ " <FILE_SIZE>"+ FILE_SIZE +"</FILE_SIZE>\n" +
|
|
|
|
+ " <XML_TYPE>"+ XML_TYPE +"</XML_TYPE>\n" +
|
|
|
|
+ " <SDEPORT_DATA>\n" +
|
|
|
|
+ " <StockRecordMessage>"
|
|
|
|
+ );bw.newLine();
|
|
|
|
+ // 注册号
|
|
|
|
+ String EMS_NO = "SJK1115";
|
|
|
|
+ // 注册序号
|
|
|
|
+ String EMS_SEQ_NO = "119000005430521";
|
|
|
|
+ // 仓储物料号
|
|
|
|
+ String WMS_MTS_NO = "TEMU9296408";
|
|
|
|
+ // 商品料号
|
|
|
|
+ String GOODS_MTS_NO = "TEMU9296408";
|
|
|
|
+ // 商品编码
|
|
|
|
+ String CODE_TS = "02032200";
|
|
|
|
+ // 商品名称
|
|
|
|
+ String GOODS_NAME = "冷冻带骨猪后腿0|3|冷冻|带骨|35.8千克/纸箱|P-20129";
|
|
|
|
+ // 商品规格型号
|
|
|
|
+ String GOODS_MODEL_DESC = "75CL";
|
|
|
|
+ // 申报计量单位
|
|
|
|
+ String WMS_DCL_UNIT = "吨";
|
|
|
|
+ // 申报数量
|
|
|
|
+ String WMS_DCL_QTY = "154";
|
|
|
|
+ // 法定单位
|
|
|
|
+ String WMS_LAW_UNIT = "吨";
|
|
|
|
+ // 法定数量
|
|
|
|
+ String WMS_LAW_QTY = "154";
|
|
|
|
+ // 库区号
|
|
|
|
+ String PLACE_IDS = "4";
|
|
|
|
+ // 库位号
|
|
|
|
+ String LOCATION_IDS = "4-01-01-1";
|
|
|
|
+ // 入库状态
|
|
|
|
+ String STOCK_STATUS = "0";
|
|
|
|
+ // 货物类型
|
|
|
|
+ String GOODS_TYPE = "1";
|
|
|
|
+ for (Map<String,Object> map : list) {
|
|
|
|
+ bw.write(" <StockInfo>\n" +
|
|
|
|
+ " <EmsNo>"+ EMS_NO +"</EmsNo>\n" +
|
|
|
|
+ " <EmsSeqNo>"+ EMS_SEQ_NO +"</EmsSeqNo>\n" +
|
|
|
|
+ " <WmsMtsNo>"+ map.get("fMblno") +"</WmsMtsNo>\n" +
|
|
|
|
+ " <GoodsMtsNo>"+ map.get("fMblno") +"</GoodsMtsNo>\n" +
|
|
|
|
+ " <CodeTs>"+ map.get("fGoodsno") +"</CodeTs>\n" +
|
|
|
|
+ " <GoodsName>"+ map.get("fGoodsids") +"</GoodsName>\n" +
|
|
|
|
+ " <GoodsModelDesc>"+ map.get("f_packagespecs") +"</GoodsModelDesc>\n" +
|
|
|
|
+ " <WmsDclUnit>"+ WMS_DCL_UNIT +"</WmsDclUnit>\n" +
|
|
|
|
+ " <WmsDclQty>"+ map.get("fQtyC") +"</WmsDclQty>\n" +
|
|
|
|
+ " <WmsLawUnit>"+ WMS_LAW_UNIT +"</WmsLawUnit>\n" +
|
|
|
|
+ " <WmsLawQty>"+ map.get("fQtyC") +"</WmsLawQty>\n" +
|
|
|
|
+ " <PlaceIds>"+ map.get("fWLID") +"</PlaceIds>\n" +
|
|
|
|
+ " <LocationIds>"+ map.get("fWarehouseids") +"</LocationIds>\n" +
|
|
|
|
+ " <StockStatus>"+ map.get("fLegStatus") +"</StockStatus>\n" +
|
|
|
|
+ " <GoodsType>"+ map.get("goodsPackageId") +"</GoodsType>\n" +
|
|
|
|
+ " </StockInfo>");
|
|
|
|
+ bw.newLine();
|
|
|
|
+ }
|
|
|
|
+ bw.write(
|
|
|
|
+ " <TradeCode>"+ TRADE_CODE +"</TradeCode>\n" +
|
|
|
|
+ " <TradeName>"+ TRADE_NAME +"</TradeName>\n" +
|
|
|
|
+ " <ApplyDate>"+ APPLY_DATE +"</ApplyDate>"
|
|
|
|
+ );bw.newLine();
|
|
|
|
+ // 理论申报单位
|
|
|
|
+ String DCL_UNIT = "035";
|
|
|
|
+ // 理论申报数量
|
|
|
|
+ String DCL_QTY = "154";
|
|
|
|
+ // 理论法定单位
|
|
|
|
+ String LAW_UNIT = "035";
|
|
|
|
+ // 理论法定数量
|
|
|
|
+ String LAW_QTY = "154";
|
|
|
|
+ for (Map<String,Object> map : list) {
|
|
|
|
+ bw.write(
|
|
|
|
+ " <SasStockInfo>\n" +
|
|
|
|
+ " <EmsNo>"+ EMS_NO +"</EmsNo>\n" +
|
|
|
|
+ " <EmsSeqNo>"+ EMS_SEQ_NO +"</EmsSeqNo>\n" +
|
|
|
|
+ " <CodeTs>"+ map.get("fGoodsno") +"</CodeTs>\n" +
|
|
|
|
+ " <GoodsName>"+ map.get("fGoodsids") +"</GoodsName>\n" +
|
|
|
|
+ " <GoodsModelDesc>"+ map.get("f_packagespecs") +"</GoodsModelDesc>\n" +
|
|
|
|
+ " <DclUnit>"+ DCL_UNIT +"</DclUnit>\n" +
|
|
|
|
+ " <DclQty>"+ map.get("fQtyC") +"</DclQty>\n" +
|
|
|
|
+ " <LawUnit>"+ map.get("fCorpid") +"</LawUnit>\n" +
|
|
|
|
+ " <LawQty>"+ map.get("fQtyC") +"</LawQty>\n" +
|
|
|
|
+ " </SasStockInfo>"
|
|
|
|
+ );
|
|
|
|
+ bw.newLine();
|
|
|
|
+ }
|
|
|
|
+ bw.write(
|
|
|
|
+ " </StockRecordMessage>\n" +
|
|
|
|
+ " </SDEPORT_DATA>\n" +
|
|
|
|
+ "</XMLObject>"
|
|
|
|
+ );bw.newLine();
|
|
|
|
+ bw.close();
|
|
|
|
+ fw.close();
|
|
|
|
+ return AjaxResult.success(fileName);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return AjaxResult.error("导出分类监管数据失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 任意位置插入数据
|
|
|
|
+ * @param path
|
|
|
|
+ * @param points 指定的位置
|
|
|
|
+ * @param insertContent 待插入的内容
|
|
|
|
+ */
|
|
|
|
+ public void randomInsert(String path, long points, String insertContent) {
|
|
|
|
+ RandomAccessFile rw = null;
|
|
|
|
+ BufferedReader reader = null;
|
|
|
|
+ BufferedWriter writer = null;
|
|
|
|
+ File temp = null;
|
|
|
|
+ try {
|
|
|
|
+ rw = new RandomAccessFile(path,"rw");
|
|
|
|
+ // 创建临时文件
|
|
|
|
+ // prefix -- 前缀字符串定义的文件名;必须至少有三个字符长
|
|
|
|
+ // suffix -- 后缀字符串定义文件的扩展名;如果为null后缀".tmp" 将被使用
|
|
|
|
+ temp = File.createTempFile("save","null");
|
|
|
|
+ // 临时文件的读取
|
|
|
|
+ reader = new BufferedReader(new FileReader(temp));
|
|
|
|
+ // 临时文件的写入
|
|
|
|
+ writer = new BufferedWriter(new FileWriter(temp));
|
|
|
|
+ // 定位到 points,把后面的数据写入临时文件
|
|
|
|
+ rw.seek(points);
|
|
|
|
+ byte[] bytes = new byte[100];
|
|
|
|
+ int num = 0;
|
|
|
|
+ while ((num = rw.read(bytes)) != -1) {
|
|
|
|
+ // 将 pos 后面的内容写入临时文件
|
|
|
|
+ writer.write(new String(bytes, 0, num));
|
|
|
|
+ }
|
|
|
|
+ writer.flush();
|
|
|
|
+ rw.seek(points); // 定位到 points,将插入的内容和临时文件写入 rw
|
|
|
|
+ rw.write(insertContent.getBytes());
|
|
|
|
+ String amp = null;
|
|
|
|
+ while ((amp = reader.readLine()) != null) {
|
|
|
|
+ // 临时文件已被读取
|
|
|
|
+ rw.write(amp.getBytes());
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ try {
|
|
|
|
+ writer.close();
|
|
|
|
+ reader.close();
|
|
|
|
+ rw.close();
|
|
|
|
+ temp.deleteOnExit();// 关闭流操作和删除临时文件
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 文件大小
|
|
|
|
+ public static long getFileSize(String filename) {
|
|
|
|
+ File file = new File(filename);
|
|
|
|
+ if (!file.exists() || !file.isFile()) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ return file.length();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getAbsoluteFile(String fileName) {
|
|
|
|
+ String downloadPath = RuoYiConfig.getDownloadPath() + fileName;
|
|
|
|
+ File desc = new File(downloadPath);
|
|
|
|
+ if (!desc.getParentFile().exists()) {
|
|
|
|
+ desc.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
|
|
+ return downloadPath;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询库存总账
|
|
* 查询库存总账
|
|
*
|
|
*
|