Commit ee58df50 by XiaHou

万科接口修复

parent 38361b63
......@@ -42,9 +42,8 @@ public class Swagger2Config {
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("haihaigo后台系统")
.description("haihaigo后台系统")
.contact("chenwf")
.title("万科后台管理系统")
.description("万科后台管理系统")
.version("1.0")
.build();
}
......
......@@ -66,7 +66,7 @@ public class UmsAdminController {
//获取session 中的验证码 然后传给Sevice校验
HttpSession session = request.getSession();
Object sessionAuthCode = session.getAttribute("RANDOMKEY");
return adminService.login(umsAdminLoginParam.getUsername(), umsAdminLoginParam.getPassword(),umsAdminLoginParam.getAuthCode(),(String)sessionAuthCode,1);
return adminService.login(umsAdminLoginParam.getUsername(), umsAdminLoginParam.getPassword(),umsAdminLoginParam.getAuthCode(),umsAdminLoginParam.getUuid(),1);
}
@ApiOperation(value = "刷新token")
......
......@@ -3,6 +3,7 @@ package com.macro.mall.controller;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.UmsAdmin;
import com.macro.mall.model.UmsMember;
import com.macro.mall.model.VankeSupplier;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.UmsAdminDto;
......@@ -88,5 +89,16 @@ public class UmsMemberController {
return CommonResult.success(this.umsMemberService.selectOneByMemberId(memberId));
}
@ApiOperation("万科后台_根据id修改一条会员数据")
@RequestMapping(value = "/updateById", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateById(@ApiParam(value="会员对象") @RequestBody UmsMember umsMember){
ResultMsg res = this.umsMemberService.updateById(umsMember);
if(res.isFlag()){
return CommonResult.success(null,res.getMsg());
}
return CommonResult.failed(res.getMsg());
}
}
package com.macro.mall.dto.Vo;
package com.macro.mall.controller.system;
import com.macro.mall.service.system.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.Base64;
import java.util.Random;
import java.awt.*;
@Component
public class ValidateCode {
private static Random random = new Random();
......@@ -23,6 +28,13 @@ public class ValidateCode {
private final String sessionKey = "RANDOMKEY";
private static RedisService redisService;
@Autowired
public void setRedisService(RedisService redisService) {
ValidateCode.redisService = redisService;
}
/*
* 获取字体
*/
......@@ -81,7 +93,7 @@ public class ValidateCode {
/*
* 生成随机图片
*/
public void getRandomCodeImage(HttpServletRequest request, HttpServletResponse response) {
public void getRandomCodeImage(HttpServletRequest request, HttpServletResponse response,String uuid) {
HttpSession session = request.getSession();
// BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
......@@ -105,8 +117,11 @@ public class ValidateCode {
g.dispose();
session.removeAttribute(sessionKey);
session.setAttribute(sessionKey, random_string);
//session.removeAttribute(sessionKey);
//session.setAttribute(sessionKey, random_string);
//将验证码 set到redis里,并且设置60秒有效期
this.redisService.set(uuid,random_string,60);
String base64String = "";
try {
......@@ -121,7 +136,7 @@ public class ValidateCode {
/*
* 生成随机图片,返回 base64 字符串
*/
public String getRandomCodeBase64(HttpServletRequest request, HttpServletResponse response) {
public String getRandomCodeBase64(HttpServletRequest request, HttpServletResponse response,String uuid) {
HttpSession session = request.getSession();
// BufferedImage类是具有缓冲区的Image类,Image类是用于描述图像信息的类
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
......@@ -145,8 +160,11 @@ public class ValidateCode {
g.dispose();
session.removeAttribute(sessionKey);
session.setAttribute(sessionKey, random_string);
//session.removeAttribute(sessionKey);
//session.setAttribute(sessionKey, random_string);
//将验证码 set到redis里,并且设置60秒有效期
redisService.set(uuid,random_string,60);
String base64String = "";
try {
......
package com.macro.mall.controller.system;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.Vo.ValidateCode;
import com.macro.mall.service.system.RedisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -14,16 +15,23 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Controller
@Api(tags = "万科物资_验证码相关接口", description = "验证码控制器")
@RequestMapping("/validateCode")
public class ValidateCodeController {
@Autowired
private RedisService redisService;
@ApiOperation(value = "生成验证码,返回的是图片")
@RequestMapping(value="/getCaptchaImage", method = RequestMethod.GET)
@ResponseBody
public void getCaptcha(HttpServletRequest request, HttpServletResponse response) {
public String getCaptcha(HttpServletRequest request, HttpServletResponse response) {
//生成uuid
String uuid = UUID.randomUUID().toString().replace("-","");
try {
response.setContentType("image/png");
response.setHeader("Cache-Control", "no-cache");
......@@ -31,13 +39,14 @@ public class ValidateCodeController {
response.setHeader("Pragma", "no-cache");
ValidateCode validateCode = new ValidateCode();
this.redisService.get("");
// 直接返回图片
validateCode.getRandomCodeImage(request, response);
validateCode.getRandomCodeImage(request, response,uuid);
} catch (Exception e) {
System.out.println(e);
}
return uuid;
}
@ApiOperation(value = "生成验证码,返回的是 base64")
......@@ -46,6 +55,9 @@ public class ValidateCodeController {
public CommonResult getCaptchaBase64(HttpServletRequest request, HttpServletResponse response) {
Map result = new HashMap();
//生成uuid
String uuid = UUID.randomUUID().toString().replace("-","");
result.put("uuid",uuid);
try {
response.setContentType("image/png");
......@@ -59,9 +71,10 @@ public class ValidateCodeController {
// validateCode.getRandomCode(request, response);
// 返回base64
String base64String = validateCode.getRandomCodeBase64(request, response);
String base64String = validateCode.getRandomCodeBase64(request, response,uuid);
result.put("url", "data:image/png;base64," + base64String);
result.put("message", "created successfull");
System.out.println("test=" + result.get("url"));
} catch (Exception e) {
System.out.println(e);
......@@ -69,15 +82,11 @@ public class ValidateCodeController {
return CommonResult.success(result,"获取成功");
}
@ApiOperation(value = "测试sessionKey,后续不用需要删除")
@RequestMapping(value="/testSessionKey",method = RequestMethod.GET)
@ApiOperation(value = "测试redis,后续不用需要删除")
@RequestMapping(value="/testRedis",method = RequestMethod.GET)
@ResponseBody
public CommonResult testSessionKey(HttpServletRequest request, HttpServletResponse response) {
//获取session
HttpSession session = request.getSession();
Object obj = session.getAttribute("RANDOMKEY");
return CommonResult.success(null, (String)obj);
public CommonResult testRedis(String uuid) {
return CommonResult.success(this.redisService.get(uuid), (String)"操作成功");
}
}
......@@ -5,6 +5,7 @@ import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.VankeGoodsCategory;
import com.macro.mall.model.VankeStockRoom;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto;
import com.macro.mall.service.vanke.IVankeGoodsCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -27,7 +28,7 @@ public class VankeGoodsCategoryController {
@ApiOperation("万科后台_物品类别分页操作")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<VankeGoodsCategory>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
public CommonResult<CommonPage<VankeGoodsCategoryDto>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@ApiParam(value="分页页数") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
return CommonResult.success(CommonPage.restPage(this.vankeGoodsCategoryService.getPageList(pageNum, pageSize)));
}
......
package com.macro.mall.controller.vanke;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.VankeInboundOrder;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeInboundOrderDto;
import com.macro.mall.model.dto.vanke.VankeOutboundOrderDto;
import com.macro.mall.service.vanke.IVankeInboundOrderService;
......@@ -10,10 +12,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
@Controller
@Api(tags = "万科后台_入库单相关接口", description = "入库单控制器")
......@@ -31,7 +30,26 @@ public class VankeInboundOrderController {
return CommonResult.success(this.vankeInboundOrderService.getPageList(pageNum,pageSize,vankeInboundOrderDto));
}
@ApiOperation("万科后台_根据id修改订单数据")
@ResponseBody
@RequestMapping(value = "/updateById", method = RequestMethod.POST)
public CommonResult updateById(@ApiParam(value="入库对象") @RequestBody VankeInboundOrder vankeInboundOrder){
ResultMsg res = this.vankeInboundOrderService.updateById(vankeInboundOrder);
if(!res.isFlag()){
return CommonResult.failed(res.getMsg());
}
return CommonResult.success(res.getMsg());
}
@ApiOperation("万科后台_传入入库单详情集合(只需要传vorList即可)")
@ResponseBody
@RequestMapping(value = "/updateInboundNum", method = RequestMethod.POST)
public CommonResult updateInboundNum(@ApiParam(value="入库对象") @RequestBody VankeInboundOrderDto vankeInboundOrderdto){
ResultMsg res = this.vankeInboundOrderService.updateInboundNum(vankeInboundOrderdto);
if(!res.isFlag()){
return CommonResult.failed(res.getMsg());
}
return CommonResult.success(res.getMsg());
}
}
......@@ -3,7 +3,10 @@ package com.macro.mall.controller.vanke;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.VankeOutboundRecord;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsDto;
import com.macro.mall.model.dto.vanke.VankeInboundOrderDto;
import com.macro.mall.model.dto.vanke.VankeOutboundRecordDto;
import com.macro.mall.service.vanke.IVankeOutboundRecordService;
import io.swagger.annotations.Api;
......@@ -11,10 +14,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
@Controller
@Api(tags = "万科后台_出库管理相关接口", description = "出库管理控制器")
......@@ -30,12 +30,26 @@ public class VankeOutboundRecordController {
@ResponseBody
public CommonResult<CommonPage<VankeOutboundRecordDto>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@ApiParam(value="分页页数") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@ApiParam(value="物品分类id") @RequestParam(value = "goodsCategoryId") Long goodsCategoryId,
@ApiParam(value="部门id") @RequestParam(value = "departId") Long departId,
@ApiParam(value="部门id") @RequestParam(value = "stockRoomId") Long stockRoomId,
@ApiParam(value="会员昵称") @RequestParam(value = "memberName") String memberName,
@ApiParam(value="物品名称") @RequestParam(value = "goodsMame") String goodsName
@ApiParam(value="物品分类id") @RequestParam(value = "goodsCategoryId", required = false) Long goodsCategoryId,
@ApiParam(value="部门id") @RequestParam(value = "departId", required = false) Long departId,
@ApiParam(value="部门id") @RequestParam(value = "stockRoomId", required = false) Long stockRoomId,
@ApiParam(value="会员昵称") @RequestParam(value = "memberName", required = false) String memberName,
@ApiParam(value="物品名称") @RequestParam(value = "goodsMame", required = false) String goodsName,
@ApiParam(value="起始时间") @RequestParam(value = "startTime", required = false) String startTime,
@ApiParam(value="结束时间") @RequestParam(value = "endTime", required = false) String endTime
){
return CommonResult.success(CommonPage.restPage(this.vankeOutboundRecordService.getPageList(pageNum,pageSize,goodsCategoryId,departId,stockRoomId ,memberName,goodsName)));
return CommonResult.success(CommonPage.restPage(this.vankeOutboundRecordService.getPageList(pageNum,pageSize,goodsCategoryId,departId,stockRoomId ,memberName,goodsName,startTime,endTime)));
}
@ApiOperation("万科后台_根据id修改一条出库数据")
@ResponseBody
@RequestMapping(value = "/updateById", method = RequestMethod.POST)
public CommonResult updateById(@ApiParam(value="出库对象") @RequestBody VankeOutboundRecord vankeOutboundRecord){
ResultMsg res = this.vankeOutboundRecordService.updateById(vankeOutboundRecord);
if(!res.isFlag()){
return CommonResult.failed(res.getMsg());
}
return CommonResult.success(res.getMsg());
}
}
......@@ -19,6 +19,9 @@ public class UmsAdminLoginParam {
@ApiModelProperty(value = "验证码", required = true)
@NotEmpty(message = "验证码不能传入为空")
private String authCode;
@ApiModelProperty(value = "uuid", required = true)
@NotEmpty(message = "uuid不能传入为空")
private String uuid;
public void setAuthCode(String authCode) {
......@@ -44,4 +47,12 @@ public class UmsAdminLoginParam {
public void setPassword(String password) {
this.password = password;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
}
......@@ -2,9 +2,9 @@ server:
port: 8180
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://115.29.198.90:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
password: 123
password: root
druid:
initial-size: 5 #连接池初始化大小
min-idle: 10 #最小空闲连接数
......
......@@ -12,9 +12,9 @@ aliyun:
prefix: mall/images/ # 上传文件夹路径前缀
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://115.29.198.90:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
password: 123
password: root
logging:
level:
root: info #日志配置DEBUG,INFO,WARN,ERROR
......
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://115.29.198.90:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
password: 123
password: root
redis:
host: 127.0.0.1 # Redis服务器地址
database: 0 # Redis数据库索引(默认为0)
......
......@@ -4,8 +4,8 @@ spring:
username: root
password: 2017gzMM
redis:
host: 10.27.33.4 # Redis服务器地址
host: 127.0.0.1 # Redis服务器地址
database: 0 # Redis数据库索引(默认为0)
port: 6380 # Redis服务器连接端口
port: 6379 # Redis服务器连接端口
password: #不设置密码
......@@ -27,7 +27,7 @@ public class VankeGoods implements Serializable {
private String barCode;
@ApiModelProperty(value = "物品价格")
private BigDecimal prict;
private BigDecimal price;
@ApiModelProperty(value = "供应商id")
private Long supplierId;
......@@ -103,12 +103,12 @@ public class VankeGoods implements Serializable {
this.barCode = barCode;
}
public BigDecimal getPrict() {
return prict;
public BigDecimal getPrice() {
return price;
}
public void setPrict(BigDecimal prict) {
this.prict = prict;
public void setPrice(BigDecimal price) {
this.price = price;
}
public Long getSupplierId() {
......@@ -202,7 +202,7 @@ public class VankeGoods implements Serializable {
sb.append(", goodsNo=").append(goodsNo);
sb.append(", goodsNum=").append(goodsNum);
sb.append(", barCode=").append(barCode);
sb.append(", prict=").append(prict);
sb.append(", price=").append(price);
sb.append(", supplierId=").append(supplierId);
sb.append(", stockRoomId=").append(stockRoomId);
sb.append(", goodsCategoryId=").append(goodsCategoryId);
......
......@@ -436,63 +436,63 @@ public class VankeGoodsExample {
return (Criteria) this;
}
public Criteria andPrictIsNull() {
addCriterion("prict is null");
public Criteria andPriceIsNull() {
addCriterion("price is null");
return (Criteria) this;
}
public Criteria andPrictIsNotNull() {
addCriterion("prict is not null");
public Criteria andPriceIsNotNull() {
addCriterion("price is not null");
return (Criteria) this;
}
public Criteria andPrictEqualTo(BigDecimal value) {
addCriterion("prict =", value, "prict");
public Criteria andPriceEqualTo(BigDecimal value) {
addCriterion("price =", value, "price");
return (Criteria) this;
}
public Criteria andPrictNotEqualTo(BigDecimal value) {
addCriterion("prict <>", value, "prict");
public Criteria andPriceNotEqualTo(BigDecimal value) {
addCriterion("price <>", value, "price");
return (Criteria) this;
}
public Criteria andPrictGreaterThan(BigDecimal value) {
addCriterion("prict >", value, "prict");
public Criteria andPriceGreaterThan(BigDecimal value) {
addCriterion("price >", value, "price");
return (Criteria) this;
}
public Criteria andPrictGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("prict >=", value, "prict");
public Criteria andPriceGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("price >=", value, "price");
return (Criteria) this;
}
public Criteria andPrictLessThan(BigDecimal value) {
addCriterion("prict <", value, "prict");
public Criteria andPriceLessThan(BigDecimal value) {
addCriterion("price <", value, "price");
return (Criteria) this;
}
public Criteria andPrictLessThanOrEqualTo(BigDecimal value) {
addCriterion("prict <=", value, "prict");
public Criteria andPriceLessThanOrEqualTo(BigDecimal value) {
addCriterion("price <=", value, "price");
return (Criteria) this;
}
public Criteria andPrictIn(List<BigDecimal> values) {
addCriterion("prict in", values, "prict");
public Criteria andPriceIn(List<BigDecimal> values) {
addCriterion("price in", values, "price");
return (Criteria) this;
}
public Criteria andPrictNotIn(List<BigDecimal> values) {
addCriterion("prict not in", values, "prict");
public Criteria andPriceNotIn(List<BigDecimal> values) {
addCriterion("price not in", values, "price");
return (Criteria) this;
}
public Criteria andPrictBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("prict between", value1, value2, "prict");
public Criteria andPriceBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("price between", value1, value2, "price");
return (Criteria) this;
}
public Criteria andPrictNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("prict not between", value1, value2, "prict");
public Criteria andPriceNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("price not between", value1, value2, "price");
return (Criteria) this;
}
......
......@@ -18,4 +18,6 @@ public class UmsMemberDto extends UmsMember implements Serializable {
private String stockRoomName;
@ApiModelProperty(value = "分类名称")
private String categoryName;
@ApiModelProperty(value = "后台管理员id")
private Long adminId;
}
package com.macro.mall.model.dto.vanke;
import com.macro.mall.model.VankeGoodsCategory;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class VankeGoodsCategoryDto extends VankeGoodsCategory implements Serializable {
@ApiModelProperty(value = "创建人名称")
private String createName;
}
......@@ -4,6 +4,8 @@ import com.macro.mall.model.VankeInboundRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class VankeInboundRecordDto extends VankeInboundRecord {
......@@ -19,4 +21,10 @@ public class VankeInboundRecordDto extends VankeInboundRecord {
private String categoryName;
@ApiModelProperty(value = "总数")
private Integer totalNum;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "供应商名称")
private String supplierName;
@ApiModelProperty(value = "货号")
private String goodsNo;
}
......@@ -4,6 +4,8 @@ import com.macro.mall.model.VankeOutboundRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class VankeOutboundRecordDto extends VankeOutboundRecord {
......@@ -25,4 +27,10 @@ public class VankeOutboundRecordDto extends VankeOutboundRecord {
private String categoryName;
@ApiModelProperty(value = "总数")
private Integer totalNum;
@ApiModelProperty(value = "出库详情集合")
private List<VankeOutboundRecord> vorList;
@ApiModelProperty(value = "起始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
}
......@@ -7,7 +7,7 @@
<result column="goods_no" jdbcType="VARCHAR" property="goodsNo" />
<result column="goods_num" jdbcType="INTEGER" property="goodsNum" />
<result column="bar_code" jdbcType="VARCHAR" property="barCode" />
<result column="prict" jdbcType="DECIMAL" property="prict" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="supplier_id" jdbcType="BIGINT" property="supplierId" />
<result column="stock_room_id" jdbcType="BIGINT" property="stockRoomId" />
<result column="goods_category_id" jdbcType="BIGINT" property="goodsCategoryId" />
......@@ -78,7 +78,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, name, goods_no, goods_num, bar_code, prict, supplier_id, stock_room_id, goods_category_id,
id, name, goods_no, goods_num, bar_code, price, supplier_id, stock_room_id, goods_category_id,
remarks, delete_status, status, create_by, update_by, createtime, updatetime
</sql>
<select id="selectByExample" parameterType="com.macro.mall.model.VankeGoodsExample" resultMap="BaseResultMap">
......@@ -116,13 +116,13 @@
SELECT LAST_INSERT_ID()
</selectKey>
insert into vanke_goods (name, goods_no, goods_num,
bar_code, prict, supplier_id,
bar_code, price, supplier_id,
stock_room_id, goods_category_id, remarks,
delete_status, status, create_by,
update_by, createtime, updatetime
)
values (#{name,jdbcType=VARCHAR}, #{goodsNo,jdbcType=VARCHAR}, #{goodsNum,jdbcType=INTEGER},
#{barCode,jdbcType=VARCHAR}, #{prict,jdbcType=DECIMAL}, #{supplierId,jdbcType=BIGINT},
#{barCode,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{supplierId,jdbcType=BIGINT},
#{stockRoomId,jdbcType=BIGINT}, #{goodsCategoryId,jdbcType=BIGINT}, #{remarks,jdbcType=VARCHAR},
#{deleteStatus,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{createBy,jdbcType=BIGINT},
#{updateBy,jdbcType=BIGINT}, #{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP}
......@@ -146,8 +146,8 @@
<if test="barCode != null">
bar_code,
</if>
<if test="prict != null">
prict,
<if test="price != null">
price,
</if>
<if test="supplierId != null">
supplier_id,
......@@ -193,8 +193,8 @@
<if test="barCode != null">
#{barCode,jdbcType=VARCHAR},
</if>
<if test="prict != null">
#{prict,jdbcType=DECIMAL},
<if test="price != null">
#{price,jdbcType=DECIMAL},
</if>
<if test="supplierId != null">
#{supplierId,jdbcType=BIGINT},
......@@ -252,8 +252,8 @@
<if test="record.barCode != null">
bar_code = #{record.barCode,jdbcType=VARCHAR},
</if>
<if test="record.prict != null">
prict = #{record.prict,jdbcType=DECIMAL},
<if test="record.price != null">
price = #{record.price,jdbcType=DECIMAL},
</if>
<if test="record.supplierId != null">
supplier_id = #{record.supplierId,jdbcType=BIGINT},
......@@ -297,7 +297,7 @@
goods_no = #{record.goodsNo,jdbcType=VARCHAR},
goods_num = #{record.goodsNum,jdbcType=INTEGER},
bar_code = #{record.barCode,jdbcType=VARCHAR},
prict = #{record.prict,jdbcType=DECIMAL},
price = #{record.price,jdbcType=DECIMAL},
supplier_id = #{record.supplierId,jdbcType=BIGINT},
stock_room_id = #{record.stockRoomId,jdbcType=BIGINT},
goods_category_id = #{record.goodsCategoryId,jdbcType=BIGINT},
......@@ -327,8 +327,8 @@
<if test="barCode != null">
bar_code = #{barCode,jdbcType=VARCHAR},
</if>
<if test="prict != null">
prict = #{prict,jdbcType=DECIMAL},
<if test="price != null">
price = #{price,jdbcType=DECIMAL},
</if>
<if test="supplierId != null">
supplier_id = #{supplierId,jdbcType=BIGINT},
......@@ -369,7 +369,7 @@
goods_no = #{goodsNo,jdbcType=VARCHAR},
goods_num = #{goodsNum,jdbcType=INTEGER},
bar_code = #{barCode,jdbcType=VARCHAR},
prict = #{prict,jdbcType=DECIMAL},
price = #{price,jdbcType=DECIMAL},
supplier_id = #{supplierId,jdbcType=BIGINT},
stock_room_id = #{stockRoomId,jdbcType=BIGINT},
goods_category_id = #{goodsCategoryId,jdbcType=BIGINT},
......
......@@ -4,6 +4,7 @@ import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.VankeGoodsCategory;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto;
import com.macro.mall.service.vanke.IVankeGoodsCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -26,7 +27,7 @@ public class VankeGoodsCategoryController {
@ApiOperation("万科h5_物品类别分页操作")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<VankeGoodsCategory>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", required = false) Integer pageSize,
public CommonResult<CommonPage<VankeGoodsCategoryDto>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", required = false) Integer pageSize,
@ApiParam(value="分页页数") @RequestParam(value = "pageNum", required = false) Integer pageNum) {
return CommonResult.success(CommonPage.restPage(this.vankeGoodsCategoryService.getPageList(pageNum, pageSize)));
}
......
......@@ -2,9 +2,9 @@ server:
port: 8085
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://115.29.198.90:3306/vanke?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
password: 123
password: root
druid:
initial-size: 5 #连接池初始化大小
min-idle: 10 #最小空闲连接数
......
package com.macro.mall.dao.vanke;
import com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto;
import java.util.List;
public interface VankeGoodsCategoryDao {
/**
* 查询多条数据
* @param vankeGoodsCategoryDto
* @return
*/
List<VankeGoodsCategoryDto> selectList(VankeGoodsCategoryDto vankeGoodsCategoryDto);
}
......@@ -221,4 +221,11 @@ public interface UmsMemberService {
* @return
*/
ResultMsg batchImportMember(List<VankeImportMemberDto> vimdList);
/**
* 根据id修改一条 会员数据
* @param umsMember
* @return
*/
ResultMsg updateById(UmsMember umsMember);
}
......@@ -850,4 +850,18 @@ public class UmsMemberServiceImpl implements UmsMemberService {
return new ResultMsg(true,"操作成功");
}
/**
* 根据id修改一条 会员数据
* @param umsMember
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg updateById(UmsMember umsMember){
if(umsMember.getId() == null){
return new ResultMsg(false,"传入id为空");
}
this.umsMemberMapper.updateByPrimaryKeySelective(umsMember);
return new ResultMsg(true,"操作成功");
}
}
......@@ -61,7 +61,7 @@ public interface UmsAdminService {
* @param type
* @return 生成的JWT的token
*/
CommonResult login(String username, String password,String authCode,String sessionAuthCode, Integer type);
CommonResult login(String username, String password,String authCode,String uuid, Integer type);
/**
* 刷新token的功能
......
......@@ -19,9 +19,12 @@ import com.macro.mall.security.admin.DgbSecurityUserHelper;
import com.macro.mall.security.util.JwtTokenUtil;
import com.macro.mall.service.mcht.PmsMchtShopInfoService;
import com.macro.mall.service.member.UmsMemberService;
import com.macro.mall.service.system.RedisService;
import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IADService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
......@@ -74,6 +77,10 @@ public class UmsAdminServiceImpl implements UmsAdminService {
private UmsMemberMapper umsMemberMapper;
@Resource
private UmsMemberService memberService;
@Resource
private RedisService redisService;
@Autowired
private IADService aDService;
@Value("${jwt.tokenHead}")
private String tokenHead;
......@@ -141,7 +148,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
}
@Override
public CommonResult login(String username, String password, String authCode,String sessionAuthCode, Integer type) {
public CommonResult login(String username, String password, String authCode,String uuid, Integer type) {
String token = null;
//密码需要客户端加密后传递
boolean isMcht = false;
......@@ -150,26 +157,31 @@ public class UmsAdminServiceImpl implements UmsAdminService {
UmsAdmin admin = getAdminByUsername(username);
if (admin == null) {
return CommonResult.failed("用户不存在");
}
if (admin.getDeleteStatus().equals(1)) {
}else if (admin.getDeleteStatus().equals(1)) {
return CommonResult.failed("用户不存在");
}else if (admin.getStatus() == 0) {
return CommonResult.failed("您已被禁用请联系平台管理员!");
}
UserDetails userDetails = loadUserByUsername(username, type);
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
return CommonResult.failed("密码不正确");
}
//校验验证码
if(authCode == null || "".equals(authCode)){
return CommonResult.failed("验证码为空");
}
if ( !authCode.toLowerCase().equals(sessionAuthCode)) {
if ( !authCode.toLowerCase().equals(this.redisService.get(uuid))) {
return CommonResult.failed("输入验证码错误");
}
Integer status = admin.getStatus();
if (status == 0) {
return CommonResult.failed("您已被禁用请联系平台管理员!");
//如果是admin 登录 则默认为超管登录 判断账号密码即可 其他账号登录均为域登录
//if("admin".equals(username)){
if (!passwordEncoder.matches(password, userDetails.getPassword())) {
return CommonResult.failed("密码不正确");
}
/*}else{ //否则通过域登录判断
ResultMsg res = this.aDService.loginAd(username,password);
if(!res.isFlag()){
return CommonResult.failed(res.getMsg());
}
}*/
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
token = jwtTokenUtil.generateToken(userDetails);
......@@ -400,7 +412,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
List<UmsResource> resourceList = getResourceList(admin.getId());
return new AdminUserDetails(admin, resourceList);
}
throw new UsernameNotFoundException("用户名或密码错误");
throw new UsernameNotFoundException("用户名不存在");
}
@Override
......@@ -705,7 +717,6 @@ public class UmsAdminServiceImpl implements UmsAdminService {
umsAdmin.setIcon(umsAdminDto.getIcon());
umsAdmin.setPhone(umsAdminDto.getPhone());
umsAdmin.setUsername(umsAdminDto.getUsername());
umsAdmin.setPassword(passwordEncoder.encode(umsAdminDto.getPassword()));
umsAdmin.setName(umsAdminDto.getName());
umsAdmin.setMemberId(umsAdminDto.getMemberId());
umsAdmin.setDepartId(umsAdminDto.getDepartId());
......@@ -744,9 +755,6 @@ public class UmsAdminServiceImpl implements UmsAdminService {
if(umsAdmin.getUsername() == null || "".equals(umsAdmin.getUsername())){
return new ResultMsg(false,"传入用户名为空");
}
if(umsAdmin.getPassword() == null || "".equals(umsAdmin.getPassword())){
return new ResultMsg(false,"传入密码为空");
}
if(umsAdmin.getMemberId() == null ){
return new ResultMsg(false,"传入会员id为空");
}
......
package com.macro.mall.service.vanke;
import com.macro.mall.model.common.ResultMsg;
public interface IADService {
/**
* 登录ad域
* @param username
* @param password
* @return
*/
ResultMsg loginAd(String username, String password);
}
......@@ -2,6 +2,7 @@ package com.macro.mall.service.vanke;
import com.macro.mall.model.VankeGoodsCategory;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto;
import java.util.List;
......@@ -27,5 +28,5 @@ public interface IVankeGoodsCategoryService {
* @param pageSize
* @return
*/
List<VankeGoodsCategory> getPageList(Integer pageNum,Integer pageSize);
List<VankeGoodsCategoryDto> getPageList(Integer pageNum, Integer pageSize);
}
package com.macro.mall.service.vanke;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.model.VankeInboundOrder;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeInboundOrderDto;
public interface IVankeInboundOrderService {
......@@ -13,4 +15,18 @@ public interface IVankeInboundOrderService {
* @return
*/
CommonPage<VankeInboundOrderDto> getPageList(Integer pageNum, Integer pageSize, VankeInboundOrderDto vankeInboundOrderDto);
/**
* 根据id 修改一条数据
* @param vankeInboundOrder
* @return
*/
ResultMsg updateById(VankeInboundOrder vankeInboundOrder);
/**
* 修改入库单内的入库数量
* @param vankeInboundOrderDto
* @return
*/
ResultMsg updateInboundNum(VankeInboundOrderDto vankeInboundOrderDto);
}
package com.macro.mall.service.vanke;
import com.macro.mall.model.VankeOutboundRecord;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeOutboundRecordDto;
import java.util.List;
......@@ -17,5 +19,14 @@ public interface IVankeOutboundRecordService {
* @param goodsMame
* @return
*/
List<VankeOutboundRecordDto> getPageList(Integer pageNum, Integer pageSize, Long goodsCategoryId, Long departId,Long stockRoomId, String memberName, String goodsMame );
List<VankeOutboundRecordDto> getPageList(Integer pageNum, Integer pageSize, Long goodsCategoryId, Long departId,
Long stockRoomId, String memberName, String goodsMame, String startTime, String endTime);
/**
* 根据id修改一条数据
* @param vankeOutboundRecord
* @return
*/
ResultMsg updateById(VankeOutboundRecord vankeOutboundRecord);
}
package com.macro.mall.service.vanke.impl;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.service.vanke.IADService;
import org.junit.Test;
import org.springframework.stereotype.Service;
import javax.naming.AuthenticationException;
import javax.naming.Context;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import java.util.Hashtable;
@Service
public class ADServiceImpl implements IADService {
private static String host = "182.61.50.234";//AD域IP,必须填写正确
private static String domain = "@tengfeikeji.club";//域名后缀,例.@noker.cn.com
private static String port = "389"; //端口,一般默认389
/**
* 登录ad域
* @param username
* @param password
* @return
*/
@Override
public ResultMsg loginAd(String username , String password){
String url = new String("ldap://" + host + ":" + port);//固定写法
String user = username.indexOf(domain) > 0 ? username : username
+ domain;//网上有别的方法,但是在我这儿都不好使,建议这么使用
Hashtable env = new Hashtable();//实例化一个Env
DirContext ctx = null;
env.put(Context.SECURITY_AUTHENTICATION, "simple");//LDAP访问安全级别(none,simple,strong),一种模式,这么写就行
env.put(Context.SECURITY_PRINCIPAL, user); //用户名
env.put(Context.SECURITY_CREDENTIALS, password);//密码
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");// LDAP工厂类
env.put(Context.PROVIDER_URL, url);//Url
try {
ctx = new InitialDirContext(env);// 初始化上下文
return new ResultMsg(true,"登录验证成功!");
} catch (AuthenticationException e) {
e.printStackTrace();
return new ResultMsg(false,"登录验证失败!账户或密码有误!");
} catch (javax.naming.CommunicationException e) {
e.printStackTrace();
return new ResultMsg(false,"AD域连接失败!请检查IP与端口正确性,是否能连上!");
} catch (Exception e) {
e.printStackTrace();
return new ResultMsg(false,"身份验证未知异常!");
} finally{
if(null!=ctx){
try {
ctx.close();
ctx=null;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@Test
public void test(){
ResultMsg res = this.loginAd("admin","root123!!");
System.out.println( res.getMsg());
}
}
......@@ -10,6 +10,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
......@@ -61,5 +62,4 @@ public class StaffServiceImpl implements IStaffService {
}
return new ResultMsg(true,"二维码校验成功");
}
}
package com.macro.mall.service.vanke.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.vanke.VankeGoodsCategoryDao;
import com.macro.mall.mapper.VankeGoodsCategoryMapper;
import com.macro.mall.model.*;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto;
import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IVankeBackLogService;
import com.macro.mall.service.vanke.IVankeGoodsCategoryService;
......@@ -24,6 +26,8 @@ public class VankeGoodsCategoryServiceImpl implements IVankeGoodsCategoryService
private UmsAdminService umsAdminService;
@Autowired
private IVankeBackLogService vankeBackLogService;
@Resource
private VankeGoodsCategoryDao vankeGoodsCategoryDao;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -76,13 +80,11 @@ public class VankeGoodsCategoryServiceImpl implements IVankeGoodsCategoryService
* @return
*/
@Override
public List<VankeGoodsCategory> getPageList(Integer pageNum, Integer pageSize) {
public List<VankeGoodsCategoryDto> getPageList(Integer pageNum, Integer pageSize) {
if(pageNum != null && pageSize != null){
PageHelper.startPage(pageNum, pageSize);
}
VankeGoodsCategoryExample example = new VankeGoodsCategoryExample();
VankeGoodsCategoryExample.Criteria criteria = example.createCriteria();
criteria.andDeleteStatusEqualTo(1);//1未删除 0已删除
return this.vankeGoodsCategoryMapper.selectByExample(example);
VankeGoodsCategoryDto vankeGoodsCategoryDto = new VankeGoodsCategoryDto();
return this.vankeGoodsCategoryDao.selectList(vankeGoodsCategoryDto);
}
}
......@@ -106,16 +106,25 @@ public class VankeGoodsServiceImpl implements IVankeGoodsService {
if(vankeGoods.getId() == null){
return new ResultMsg(false,"传入id为空");
}
if(vankeGoods.getDeleteStatus() == 0){//如果传入的状态为删除
//通过id获得之前名称
//通过id获得之前数据
VankeGoods vg = this.vankeGoodsMapper.selectByPrimaryKey(vankeGoods.getId());
String msg = "将物品名称:" + vg.getName() + "删除";
if(vankeGoods.getGoodsNum() != null){ //如果传入库存数量不为空
//插入日志表
this.vankeBackLogService.insertVankeBackLog("将物品名称为:" + vg.getName() +"库存数量由:"+vg.getGoodsNum()
+"改为:"+vankeGoods.getGoodsNum());
}
if(vankeGoods.getName() != null && !vankeGoods.getName().isEmpty()){ //如果名字不为空
//插入日志表
this.vankeBackLogService.insertVankeBackLog("将物品名称为:" + vg.getName()+"改为:"+vankeGoods.getName());
}
if(vankeGoods.getDeleteStatus() != null && vankeGoods.getDeleteStatus() == 0){//如果传入的状态为删除
String msg = "将物品名称:" + vg.getName() + "删除";
//插入日志表
this.vankeBackLogService.insertVankeBackLog(msg);
}
UmsAdmin admin = umsAdminService.getCurrentUmsAdmin();
vankeGoods.setUpdateBy(admin.getId());
this.vankeGoodsMapper.insertSelective(vankeGoods);
this.vankeGoodsMapper.updateByPrimaryKeySelective(vankeGoods);
return new ResultMsg(true,"操作成功");
}
......@@ -135,7 +144,7 @@ public class VankeGoodsServiceImpl implements IVankeGoodsService {
if(vankeGoods.getStockRoomId() == null){
return new ResultMsg(false,"传入库房Id为空");
}
if(vankeGoods.getPrict() == null){
if(vankeGoods.getPrice() == null){
return new ResultMsg(false,"传入价格为空");
}
if(vankeGoods.getBarCode() == null){
......
......@@ -5,14 +5,21 @@ import com.github.pagehelper.PageInfo;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.dao.vanke.VankeInboundOrderDao;
import com.macro.mall.dao.vanke.VankeInboundRecordDao;
import com.macro.mall.model.UmsAdmin;
import com.macro.mall.model.UmsMember;
import com.macro.mall.mapper.VankeGoodsMapper;
import com.macro.mall.mapper.VankeInboundOrderMapper;
import com.macro.mall.mapper.VankeInboundRecordMapper;
import com.macro.mall.model.*;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeInboundOrderDto;
import com.macro.mall.model.dto.vanke.VankeInboundRecordDto;
import com.macro.mall.model.dto.vanke.VankeOutboundOrderDto;
import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IVankeBackLogService;
import com.macro.mall.service.vanke.IVankeInboundOrderService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -26,6 +33,15 @@ public class VankeInboundOrderServiceImpl implements IVankeInboundOrderService {
private VankeInboundRecordDao vankeInboundRecordDao;
@Autowired
private UmsAdminService umsAdminService;
@Resource
private VankeInboundOrderMapper vankeInboundOrderMapper;
@Resource
private VankeGoodsMapper vankeGoodsMapper;
@Resource
private VankeInboundRecordMapper vankeInboundRecordMapper;
@Autowired
private IVankeBackLogService vankeBackLogService;
/**
* 分页查询入记录
......@@ -59,4 +75,98 @@ public class VankeInboundOrderServiceImpl implements IVankeInboundOrderService {
return result;
}
/**
* 根据id 修改一条数据
* @param vankeInboundOrder
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg updateById(VankeInboundOrder vankeInboundOrder){
if(vankeInboundOrder.getId() == null){
return new ResultMsg(false,"传入id为空");
}
if(vankeInboundOrder.getDeleteStatus() == 0 ){//如果是删除操作 同时也要将商品的对应数量扣除
VankeInboundOrder vio = this.vankeInboundOrderMapper.selectByPrimaryKey(vankeInboundOrder.getId());
//初始化 VankeInboundRecordExample对象
VankeInboundRecord vir = new VankeInboundRecord();
VankeInboundRecordExample example = new VankeInboundRecordExample();
VankeInboundRecordExample.Criteria criteria = example.createCriteria();
//通过入库单号 查询子订单
criteria.andInboundNoEqualTo(vio.getInboundNo());//设置入库单号
List<VankeInboundRecord> virList = this.vankeInboundRecordMapper.selectByExample(example);
//如果得到集合不为空 继续下面业务
if(virList != null && virList.size() >0){
virList.forEach(item ->{
//根据物品id 查询物品 扣除物品的入库库存
VankeGoods vg = this.vankeGoodsMapper.selectByPrimaryKey(item.getGoodsId());
if(vg != null){
vg.setGoodsNum(vg.getGoodsNum() - item.getInboundNum()); //现有库存 扣除入库库存
this.vankeGoodsMapper.updateByPrimaryKeySelective(vg);
//记录删除入库记录
this.vankeBackLogService.insertVankeBackLog("删除入库记录单,单号为: "+item.getInboundNo()
+"--物品名为:"+vg.getName()+"--扣除库存:"+item.getInboundNum());
}
});
//将入库详情对应的数据也改为删除
vir.setDeleteStatus(0); //将删除标记设为0
this.vankeInboundRecordMapper.updateByExampleSelective(vir,example);
}
}
//根据传入的id修改一条数据
this.vankeInboundOrderMapper.updateByPrimaryKey(vankeInboundOrder);
return new ResultMsg(true,"操作成功");
}
/**
* 修改入库单内的入库数量
* @param vankeInboundOrderDto
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg updateInboundNum(VankeInboundOrderDto vankeInboundOrderDto){
//判断是否有传入 入库单集合
if(vankeInboundOrderDto.getVorList() == null || vankeInboundOrderDto.getVorList().size() <= 0 ){
return new ResultMsg(false,"传入入库单详情集合为空");
}
//初始化入库单记录表
VankeInboundRecord vankeInboundRecord ;
//初始化入库单记录表
VankeInboundRecord vir = new VankeInboundRecord(); ;
//初始化物品
VankeGoods vankeGoods;
//初始化差额
Integer difference = 0;
//遍历传入的集合 判断修改后的值 是增加还是减少 并且记录下来
for (VankeInboundRecordDto vor : vankeInboundOrderDto.getVorList()){
//判断当前传入的值 和数据库里的值 比对
vankeInboundRecord = this.vankeInboundRecordMapper.selectByPrimaryKey(vor.getId());
if(vankeInboundRecord == null){
return new ResultMsg(false,"不存在此入库单物品,id为:"+ vor.getId());
}
if(vor.getInboundNum() == null){
//如果传入的修改入库数为空 则返回
return new ResultMsg(false,"传入入库数为空,id为:" + vor.getId());
}
//计算修改后的差额 之前入库数 减去 修改入库数
difference = vankeInboundRecord.getInboundNum() - vor.getInboundNum();
//否则 通过物品id去 查询物品 修改库存
vankeGoods = this.vankeGoodsMapper.selectByPrimaryKey(vankeInboundRecord.getGoodsId());
//修改物品库存
vankeGoods.setGoodsNum(vankeGoods.getGoodsNum() - difference);
this.vankeGoodsMapper.updateByPrimaryKeySelective(vankeGoods);
//修改入库数量
vir.setId(vor.getId());
vir.setInboundNum(vor.getInboundNum());
this.vankeInboundRecordMapper.updateByPrimaryKeySelective(vir);
//记录修改入库记录
this.vankeBackLogService.insertVankeBackLog("入库单号:"+vankeInboundRecord.getInboundNo()+"物品名为:"
+vankeGoods.getName() +"--由之前入库数量:"+vankeInboundRecord.getInboundNum()+"改为:"+vor.getInboundNum());
}
return new ResultMsg(true,"操作成功");
}
}
......@@ -2,12 +2,19 @@ package com.macro.mall.service.vanke.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.VankeOutBoundRecordDao;
import com.macro.mall.mapper.VankeGoodsMapper;
import com.macro.mall.mapper.VankeOutboundRecordMapper;
import com.macro.mall.model.UmsAdmin;
import com.macro.mall.model.VankeGoods;
import com.macro.mall.model.VankeOutboundRecord;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeOutboundRecordDto;
import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IVankeBackLogService;
import com.macro.mall.service.vanke.IVankeOutboundRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -19,6 +26,12 @@ public class VankeOutboundRecordServiceImpl implements IVankeOutboundRecordServi
private VankeOutBoundRecordDao vankeOutBoundRecordDao;
@Autowired
private UmsAdminService umsAdminService;
@Resource
private VankeOutboundRecordMapper vankeOutboundRecordMapper;
@Resource
private VankeGoodsMapper vankeGoodsMapper;
@Autowired
private IVankeBackLogService vankeBackLogService;
/**
* 出库记录分页操作
......@@ -29,7 +42,8 @@ public class VankeOutboundRecordServiceImpl implements IVankeOutboundRecordServi
* @return
*/
@Override
public List<VankeOutboundRecordDto> getPageList(Integer pageNum, Integer pageSize, Long goodsCategoryId, Long departId,Long stockRoomId, String memberName, String goodsMame){
public List<VankeOutboundRecordDto> getPageList(Integer pageNum, Integer pageSize, Long goodsCategoryId,
Long departId,Long stockRoomId, String memberName, String goodsMame, String startTime, String endTime){
//获取管理员对象
UmsAdmin ua = umsAdminService.getCurrentUmsAdmin();
PageHelper.startPage(pageNum, pageSize);
......@@ -39,10 +53,53 @@ public class VankeOutboundRecordServiceImpl implements IVankeOutboundRecordServi
vord.setMemberName(memberName);
vord.setGoodsName(goodsMame);
vord.setStockRoomId(stockRoomId);
vord.setStartTime(startTime);
vord.setEndTime(endTime);
if(ua.getMemberId() != null){//如果管理的会员id不为空说明是普通会员 只能查看自己的入库
vord.setReceptOutboundMemberId(ua.getMemberId());
}
return this.vankeOutBoundRecordDao.getPageList(vord);
}
/**
* 根据id修改一条数据
* @param vankeOutboundRecord
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg updateById(VankeOutboundRecord vankeOutboundRecord){ //
if(vankeOutboundRecord.getId() == null){
return new ResultMsg(false,"传入id为空");
}
//查询之前的数据
VankeOutboundRecord vor = this.vankeOutboundRecordMapper.selectByPrimaryKey(vankeOutboundRecord.getId());
if(vankeOutboundRecord.getOutboundNum() != null ){ //如果是修改出库数量
Integer updateNum = vor.getOutboundNum() - vankeOutboundRecord.getOutboundNum() ;//之前出库记录 减去现在修改数量
//修改出库记录的数量后 需要更改对应的 库存数量
VankeGoods vg = this.vankeGoodsMapper.selectByPrimaryKey(vor.getGoodsId());
if(vg != null){
vg.setGoodsNum(vg.getGoodsNum() + updateNum ); //现有库存 + 回之前的出库数
this.vankeGoodsMapper.updateByPrimaryKeySelective(vg);
//记录删除出库记录
this.vankeBackLogService.insertVankeBackLog("出库单号:"+vor.getOutboundNo()+"物品名为:"
+vg.getName() +"--由之前出库数量:"+vor.getOutboundNum()+"改为:"+vankeOutboundRecord.getOutboundNum());
}
}
if( vankeOutboundRecord.getDeleteStatus() != null && vankeOutboundRecord.getDeleteStatus() == 0){ //如果是删除状态
//根据物品id 查询物品 扣除物品的入库库存
VankeGoods vg = this.vankeGoodsMapper.selectByPrimaryKey(vor.getGoodsId());
if(vg != null){
vg.setGoodsNum(vg.getGoodsNum() + vor.getOutboundNum() ); //现有库存 + 回之前的出库数
this.vankeGoodsMapper.updateByPrimaryKeySelective(vg);
//记录删除出库记录
this.vankeBackLogService.insertVankeBackLog("删除出库记录单,单号为: "+vor.getOutboundNum()
+"--物品名为:"+vg.getName()+"--增加库存:"+vor.getOutboundNum());
}
}
this.vankeOutboundRecordMapper.updateByPrimaryKeySelective(vankeOutboundRecord);
return new ResultMsg(true,"操作成功");
}
}
......@@ -46,6 +46,7 @@
<result column="departName" jdbcType="VARCHAR" property="departName"/>
<result column="categoryName" jdbcType="VARCHAR" property="categoryName"/>
<result column="stockRoomName" jdbcType="VARCHAR" property="stockRoomName"/>
<result column="adminId" jdbcType="BIGINT" property="adminId" />
</resultMap>
<sql id="Example_Where_Clause">
......@@ -852,9 +853,10 @@
</select>
<select id="selectUmsMember" parameterType="com.macro.mall.model.dto.quanxing.UmsMemberDto" resultMap="BaseResultMap2">
select a.* ,b.name departName,c.name stockRoomName from ums_member a
select a.* ,b.name departName,c.name stockRoomName,d.id adminId from ums_member a
left join vanke_department b ON a.depart_id = b.id
left join vanke_stock_room c ON a.stock_room_id = c.id
left join ums_admin d ON a.id = d.member_id
where a.delete_status = 0
<if test="accouuntType != null">
and a.accouunt_type = #{accouuntType}
......
......@@ -43,6 +43,12 @@
<if test="receptOutboundMemberId != null">
and a.recept_outbound_member_id = #{receptOutboundMemberId}
</if>
<if test="startTime != null and startTime != ''">
and #{startTime} &lt;= date_format( a.createtime, '%Y-%m-%d' )
</if>
<if test="endTime != null and endTime != ''">
and date_format( a.createtime, '%Y-%m-%d' ) &lt;= #{endTime}
</if>
order by a.createtime desc
</select>
......
<?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="com.macro.mall.dao.vanke.VankeGoodsCategoryDao">
<resultMap id="BaseResultMap" type="com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto" extends="com.macro.mall.mapper.VankeGoodsCategoryMapper.BaseResultMap">
<result column="createName" jdbcType="VARCHAR" property="createName" />
</resultMap>
<select id="selectList" parameterType="com.macro.mall.model.dto.vanke.VankeGoodsCategoryDto" resultMap="BaseResultMap">
select a.* ,b.nick_name createName from vanke_goods_category a
left join ums_admin b ON a.create_by = b.id
where a.delete_status = 1
</select>
</mapper>
\ No newline at end of file
......@@ -29,6 +29,7 @@
<if test="stockWarning != null">
and a.goods_num &lt;= #{stockWarning}
</if>
order by a.createtime desc
</select>
<select id="selectSupplierCategory" parameterType="com.macro.mall.model.dto.vanke.VankeGoodsDto" resultMap="BaseResultMap">
......
......@@ -8,6 +8,9 @@
<result column="stockRoomName" jdbcType="VARCHAR" property="stockRoomName" />
<result column="categoryName" jdbcType="VARCHAR" property="categoryName" />
<result column="totalNum" jdbcType="INTEGER" property="totalNum" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="supplierName" jdbcType="VARCHAR" property="supplierName" />
<result column="goodsNo" jdbcType="VARCHAR" property="goodsNo" />
</resultMap>
<select id="getPageList" parameterType="com.macro.mall.model.dto.vanke.VankeInboundRecordDto" resultMap="BaseResultMap">
......@@ -55,8 +58,10 @@
</select>
<select id="selectListByInboundNo" parameterType="java.lang.String" resultMap="BaseResultMap">
select a.*,b.name goodsName,b.goods_no goodsNo from vanke_inbound_record a
select a.*,b.name goodsName,b.goods_no goodsNo,b.price,c.name categoryName ,d.name supplierName from vanke_inbound_record a
left join vanke_goods b ON a.goods_id = b.id
left join vanke_goods_category c ON b.goods_category_id = c.id
left join vanke_supplier d ON d.id = b.supplier_id
where a.inbound_no =#{inboundNo}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment