From 67273fc4b73a4abf62c4c01269d358cf933ca52e Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Thu, 19 May 2022 08:47:23 +0800
Subject: [PATCH] 农资管理

---
 src/main/java/org/springblade/modules/soldrecord/vo/SoldrecordVO.java                    |   38 ++++
 src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.java            |   44 ++++
 src/main/java/sql/soldrecord.menu.sql                                                    |   10 +
 src/main/java/org/springblade/modules/stockrecord/controller/StockrecordController.java  |   12 +
 src/main/java/org/springblade/modules/soldrecord/entity/Soldrecord.java                  |   64 +++++++
 src/main/java/org/springblade/modules/stockrecord/mapper/StockrecordMapper.xml           |   38 ++-
 src/main/java/org/springblade/modules/soldrecord/controller/SoldrecordController.java    |  136 +++++++++++++++
 src/main/java/org/springblade/modules/soldrecord/service/ISoldrecordService.java         |   42 ++++
 src/main/java/org/springblade/modules/soldrecord/dto/SoldrecordDTO.java                  |   34 +++
 src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml             |   54 ++++++
 src/main/java/org/springblade/modules/soldrecord/service/impl/SoldrecordServiceImpl.java |   46 +++++
 src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml                       |    2 
 12 files changed, 502 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/springblade/modules/soldrecord/controller/SoldrecordController.java b/src/main/java/org/springblade/modules/soldrecord/controller/SoldrecordController.java
new file mode 100644
index 0000000..3282b6b
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/controller/SoldrecordController.java
@@ -0,0 +1,136 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.stock.vo.StockVO;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import org.springblade.modules.soldrecord.vo.SoldrecordVO;
+import org.springblade.modules.soldrecord.service.ISoldrecordService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 已出库存记录表 控制器
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/soldrecord/soldrecord")
+@Api(value = "已出库存记录表", tags = "已出库存记录表接口")
+public class SoldrecordController extends BladeController {
+
+	private final ISoldrecordService soldrecordService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入soldrecord")
+	public R<Soldrecord> detail(Soldrecord soldrecord) {
+		Soldrecord detail = soldrecordService.getOne(Condition.getQueryWrapper(soldrecord));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页 已出库存记录表
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入soldrecord")
+	public R<IPage<Soldrecord>> list(Soldrecord soldrecord, Query query) {
+		IPage<Soldrecord> pages = soldrecordService.page(Condition.getPage(query), Condition.getQueryWrapper(soldrecord));
+		return R.data(pages);
+	}
+
+	/**
+	 * 自定义分页 已出库存记录表
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入soldrecord")
+	public R<IPage<SoldrecordVO>> page(SoldrecordVO soldrecord, Query query) {
+		IPage<SoldrecordVO> pages = soldrecordService.selectLists(Condition.getPage(query), soldrecord);
+		for (int i=0;i<pages.getRecords().size();i++){
+			String specs = pages.getRecords().get(i).getSpecs1();
+			String dic1 = pages.getRecords().get(i).getDic1();
+			String dic2 = pages.getRecords().get(i).getDic2();
+			String s = specs+dic1 +"/"+ dic2;
+			pages.getRecords().get(i).setSpn(s);
+
+		}
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 已出库存记录表
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入soldrecord")
+	public R save(@Valid @RequestBody Soldrecord soldrecord) {
+		return R.status(soldrecordService.save(soldrecord));
+	}
+
+	/**
+	 * 修改 已出库存记录表
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入soldrecord")
+	public R update(@Valid @RequestBody Soldrecord soldrecord) {
+		return R.status(soldrecordService.updateById(soldrecord));
+	}
+
+	/**
+	 * 新增或修改 已出库存记录表
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入soldrecord")
+	public R submit(@Valid @RequestBody Soldrecord soldrecord) {
+		return R.status(soldrecordService.saveOrUpdate(soldrecord));
+	}
+
+
+	/**
+	 * 删除 已出库存记录表
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(soldrecordService.deleteLogic(Func.toLongList(ids)));
+	}
+
+
+}
diff --git a/src/main/java/org/springblade/modules/soldrecord/dto/SoldrecordDTO.java b/src/main/java/org/springblade/modules/soldrecord/dto/SoldrecordDTO.java
new file mode 100644
index 0000000..db4cd67
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/dto/SoldrecordDTO.java
@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.dto;
+
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 已出库存记录表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SoldrecordDTO extends Soldrecord {
+	private static final long serialVersionUID = 1L;
+
+}
diff --git a/src/main/java/org/springblade/modules/soldrecord/entity/Soldrecord.java b/src/main/java/org/springblade/modules/soldrecord/entity/Soldrecord.java
new file mode 100644
index 0000000..7072b1a
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/entity/Soldrecord.java
@@ -0,0 +1,64 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 已出库存记录表实体类
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@Data
+@TableName("sys_soldrecord")
+@EqualsAndHashCode(callSuper = true)
+public class Soldrecord extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 农资id
+	 */
+	private String stockId1;
+	/**
+	 * 数量
+	 */
+	private Integer amount1;
+	private Integer tenantId1;
+	/**
+	 * 规格
+	 */
+	private String specs1;
+	/**
+	 * 规格值(0:克 1:斤 2:公斤 3:吨 4:毫升 5:升 )
+	 */
+	private Integer specsVal1;
+	/**
+	 * 规格值2( 0:袋 1:包 2:瓶 3:盒 4:箱 5:桶 6:支)
+	 */
+	private Integer specsVal2;
+
+
+}
diff --git a/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.java b/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.java
new file mode 100644
index 0000000..217044d
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.java
@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.mapper;
+
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import org.springblade.modules.soldrecord.vo.SoldrecordVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.stock.vo.StockVO;
+
+import java.util.List;
+
+/**
+ * 已出库存记录表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+public interface SoldrecordMapper extends BaseMapper<Soldrecord> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param soldrecord
+	 * @return
+	 */
+	List<SoldrecordVO> selectSoldrecordPage(IPage page, SoldrecordVO soldrecord);
+	List<SoldrecordVO> selectLists(IPage page, SoldrecordVO soldrecord);
+}
diff --git a/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml b/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml
new file mode 100644
index 0000000..04871ec
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/mapper/SoldrecordMapper.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.modules.soldrecord.mapper.SoldrecordMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="soldrecordResultMap" type="org.springblade.modules.soldrecord.entity.Soldrecord">
+        <result column="id" property="id"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="stock_id1" property="stockId1"/>
+        <result column="amount1" property="amount1"/>
+        <result column="time1" property="time1"/>
+        <result column="tenant_id1" property="tenantId1"/>
+        <result column="picture1" property="picture1"/>
+        <result column="remarks1" property="remarks1"/>
+        <result column="specs1" property="specs1"/>
+        <result column="specs_val1" property="specsVal1"/>
+        <result column="specs_val2" property="specsVal2"/>
+    </resultMap>
+
+
+    <select id="selectSoldrecordPage" resultMap="soldrecordResultMap">
+        select * from sys_soldrecord where is_deleted = 0
+    </select>
+
+    <select id="selectLists" resultType="org.springblade.modules.soldrecord.vo.SoldrecordVO">
+        SELECT st.*,
+               stf.factory_name AS factoryName,
+               stf.type AS stype,
+               d.dict_value AS dic1,
+               c.dict_value AS dic2
+        FROM sys_soldrecord st
+                 LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
+                 LEFT JOIN (SELECT dict_key, dict_value
+                            FROM blade_dict_biz
+                            WHERE CODE = 'stockSpecs1' AND is_deleted = 0) d ON d.dict_key = st.specs_val1
+                 LEFT JOIN (SELECT dict_key, dict_value
+                            FROM blade_dict_biz
+                            WHERE CODE = 'stockSpecs2' AND is_deleted = 0) c ON c.dict_key = st.specs_val2
+        WHERE st.is_deleted = 0
+        <if test="soldrecord.stype!=null and soldrecord.stype != ''">
+            and stf.type = #{soldrecord.stype}
+        </if>
+        <if test="soldrecord.stockId1!=null and soldrecord.stockId1 != ''">
+            and st.stock_id1 = #{soldrecord.stockId1}
+        </if>
+    </select>
+
+</mapper>
diff --git a/src/main/java/org/springblade/modules/soldrecord/service/ISoldrecordService.java b/src/main/java/org/springblade/modules/soldrecord/service/ISoldrecordService.java
new file mode 100644
index 0000000..cd9d822
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/service/ISoldrecordService.java
@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.service;
+
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import org.springblade.modules.soldrecord.vo.SoldrecordVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.stock.vo.StockVO;
+
+/**
+ * 已出库存记录表 服务类
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+public interface ISoldrecordService extends BaseService<Soldrecord> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param soldrecord
+	 * @return
+	 */
+	IPage<SoldrecordVO> selectSoldrecordPage(IPage<SoldrecordVO> page, SoldrecordVO soldrecord);
+	IPage<SoldrecordVO> selectLists(IPage<SoldrecordVO> page, SoldrecordVO soldrecord);
+}
diff --git a/src/main/java/org/springblade/modules/soldrecord/service/impl/SoldrecordServiceImpl.java b/src/main/java/org/springblade/modules/soldrecord/service/impl/SoldrecordServiceImpl.java
new file mode 100644
index 0000000..1b55af1
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/service/impl/SoldrecordServiceImpl.java
@@ -0,0 +1,46 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.service.impl;
+
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import org.springblade.modules.soldrecord.vo.SoldrecordVO;
+import org.springblade.modules.soldrecord.mapper.SoldrecordMapper;
+import org.springblade.modules.soldrecord.service.ISoldrecordService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 已出库存记录表 服务实现类
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@Service
+public class SoldrecordServiceImpl extends BaseServiceImpl<SoldrecordMapper, Soldrecord> implements ISoldrecordService {
+
+	@Override
+	public IPage<SoldrecordVO> selectSoldrecordPage(IPage<SoldrecordVO> page, SoldrecordVO soldrecord) {
+		return page.setRecords(baseMapper.selectSoldrecordPage(page, soldrecord));
+	}
+
+	@Override
+	public IPage<SoldrecordVO> selectLists(IPage<SoldrecordVO> page, SoldrecordVO soldrecord) {
+		return page.setRecords(baseMapper.selectLists(page,soldrecord));
+	}
+
+}
diff --git a/src/main/java/org/springblade/modules/soldrecord/vo/SoldrecordVO.java b/src/main/java/org/springblade/modules/soldrecord/vo/SoldrecordVO.java
new file mode 100644
index 0000000..c54900e
--- /dev/null
+++ b/src/main/java/org/springblade/modules/soldrecord/vo/SoldrecordVO.java
@@ -0,0 +1,38 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.soldrecord.vo;
+
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 已出库存记录表视图实体类
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class SoldrecordVO extends Soldrecord {
+	private static final long serialVersionUID = 1L;
+	String stype;
+	String factoryName;
+	String dic1;
+	String dic2;
+	String spn;
+}
diff --git a/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml b/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml
index 0892b61..09909f5 100644
--- a/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml
+++ b/src/main/java/org/springblade/modules/stock/mapper/StockMapper.xml
@@ -44,7 +44,7 @@
         WHERE CODE = 'stockSpecs1' AND is_deleted = 0) d ON d.dict_key = st.specs_value1
         LEFT JOIN (SELECT dict_key, dict_value
         FROM blade_dict_biz
-        WHERE CODE = 'stockSpecs2' AND is_deleted = 0) c ON c.dict_key = st.specs_value1
+        WHERE CODE = 'stockSpecs2' AND is_deleted = 0) c ON c.dict_key = st.specs_value2
         WHERE st.is_deleted = 0
         <if test="stock.stype!=null and stock.stype != ''">
             and stf.type = #{stock.stype}
diff --git a/src/main/java/org/springblade/modules/stockrecord/controller/StockrecordController.java b/src/main/java/org/springblade/modules/stockrecord/controller/StockrecordController.java
index be66516..4f4c7e9 100644
--- a/src/main/java/org/springblade/modules/stockrecord/controller/StockrecordController.java
+++ b/src/main/java/org/springblade/modules/stockrecord/controller/StockrecordController.java
@@ -28,6 +28,8 @@
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.modules.soldrecord.entity.Soldrecord;
+import org.springblade.modules.soldrecord.service.ISoldrecordService;
 import org.springblade.modules.stock.entity.Stock;
 import org.springblade.modules.stock.service.IStockService;
 import org.springblade.modules.system.entity.DictBiz;
@@ -57,7 +59,7 @@
 	private final IStockrecordService stockrecordService;
 	private final IStockService stockService;
 	private final IDictBizService dictService;
-
+	private final ISoldrecordService soldrecordService;
 	/**
 	 * 详情
 	 */
@@ -152,6 +154,14 @@
 				stock.setState("0");
 				stockService.UpdaeAmountc(stock);
 			}
+			//已出库农资记录
+			Soldrecord soldrecord = new Soldrecord();
+			soldrecord.setStockId1(stockrecord.getStockId1());
+			soldrecord.setAmount1(amount1);
+			soldrecord.setSpecs1(stockrecord.getSpecs1());
+			soldrecord.setSpecsVal1(stockrecord.getSpecsVal1());
+			soldrecord.setSpecsVal2(stockrecord.getSpecsVal2());
+			soldrecordService.save(soldrecord);
 		}
 		//入库
 		else {
diff --git a/src/main/java/org/springblade/modules/stockrecord/mapper/StockrecordMapper.xml b/src/main/java/org/springblade/modules/stockrecord/mapper/StockrecordMapper.xml
index 65f2569..b8ca1c9 100644
--- a/src/main/java/org/springblade/modules/stockrecord/mapper/StockrecordMapper.xml
+++ b/src/main/java/org/springblade/modules/stockrecord/mapper/StockrecordMapper.xml
@@ -56,23 +56,29 @@
     <!--农资记录查询-->
     <select id="seletStockRecordList" resultType="org.springblade.modules.stockrecord.vo.StockrecordVO">
         SELECT st.*,
-               stf.type         AS stype,
-               stf.factory_name AS factoryName,
-               d.dict_value     AS dic1,
-               c.dict_value     AS dic2,
-               a.name           as czr
+        stf.type AS stype,
+        stf.factory_name AS factoryName,
+        d.dict_value AS dic1,
+        c.dict_value AS dic2,
+        a.name as czr
         FROM `sys_stockrecord` st
-                 LEFT JOIN sys_stockfactory stf
-                           ON st.stock_id1 = stf.id
-                 LEFT JOIN (SELECT dict_key, dict_value
-                            FROM blade_dict_biz
-                            WHERE `code` = 'stockSpecs1'
-                              AND is_deleted = 0) d ON d.dict_key = st.specs_val1
-                 LEFT JOIN (SELECT dict_key, dict_value
-                            FROM blade_dict_biz
-                            WHERE `code` = 'stockSpecs2'
-                              AND is_deleted = 0) c ON c.dict_key = st.specs_val2
-                 LEFT JOIN (SELECT name, id FROM blade_user WHERE is_deleted = 0) a ON a.id = st.create_user
+        LEFT JOIN sys_stockfactory stf
+        ON st.stock_id1 = stf.id
+        LEFT JOIN (SELECT dict_key, dict_value
+        FROM blade_dict_biz
+        WHERE `code` = 'stockSpecs1'
+        AND is_deleted = 0) d ON d.dict_key = st.specs_val1
+        LEFT JOIN (SELECT dict_key, dict_value
+        FROM blade_dict_biz
+        WHERE `code` = 'stockSpecs2'
+        AND is_deleted = 0) c ON c.dict_key = st.specs_val2
+        LEFT JOIN (SELECT name, id FROM blade_user WHERE is_deleted = 0) a ON a.id = st.create_user
         WHERE st.is_deleted = 0
+        <if test="stockrecord.stype!=null and stockrecord.stype != ''">
+            and stf.type = #{stockrecord.stype}
+        </if>
+        <if test="stockrecord.stockId1!=null and stockrecord.stockId1 != ''">
+            and st.stock_id1 = #{stockrecord.stockId1}
+        </if>
     </select>
 </mapper>
diff --git a/src/main/java/sql/soldrecord.menu.sql b/src/main/java/sql/soldrecord.menu.sql
new file mode 100644
index 0000000..d19bcf8
--- /dev/null
+++ b/src/main/java/sql/soldrecord.menu.sql
@@ -0,0 +1,10 @@
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1526723636591865858', 1123598815738675201, 'soldrecord', '已出库存农资', 'menu', '/soldrecord/soldrecord', NULL, 1, 1, 0, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1526723636591865859', '1526723636591865858', 'soldrecord_add', '新增', 'add', '/soldrecord/soldrecord/add', 'plus', 1, 2, 1, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1526723636591865860', '1526723636591865858', 'soldrecord_edit', '修改', 'edit', '/soldrecord/soldrecord/edit', 'form', 2, 2, 2, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1526723636591865861', '1526723636591865858', 'soldrecord_delete', '删除', 'delete', '/api/soldrecord/soldrecord/remove', 'delete', 3, 2, 3, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1526723636591865862', '1526723636591865858', 'soldrecord_view', '查看', 'view', '/soldrecord/soldrecord/view', 'file-text', 4, 2, 2, 1, NULL, 0);

--
Gitblit v1.9.3