Commit 0b0208a9 by XiaHou

万科接口修复

parent b589c60f
......@@ -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.core.annotion.BussinessLog;
import com.macro.mall.domain.dto.AdminManageParam;
import com.macro.mall.dto.AdminUpdateParam;
import com.macro.mall.dto.UmsAdminLoginParam;
import com.macro.mall.domain.dto.UmsAdminParam;
......@@ -86,21 +87,16 @@ public class UmsAdminController {
@ApiOperation(value = "获取当前登录用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ResponseBody
public CommonResult getAdminInfo(Principal principal) {
public CommonResult<AdminManageParam> getAdminInfo(Principal principal) {
if(principal==null){
return CommonResult.unauthorized(null);
}
String username = principal.getName();
UmsAdmin umsAdmin = adminService.getAdminByUsername(username);
Map<String, Object> data = new HashMap<>();
data.put("username", umsAdmin.getUsername());
data.put("userId", umsAdmin.getId());
data.put("roles", roleService.getAllRoleById(umsAdmin.getId()));
data.put("menus", roleService.getMenuList(umsAdmin.getId()));
data.put("icon", umsAdmin.getIcon());
data.put("parentId",umsAdmin.getParentId());
data.put("applyCode",umsAdmin.getApplyCode());
return CommonResult.success(data);
AdminManageParam adminManageParam = adminService.getVankeAdminByUsername(username);
adminManageParam.setUserId(adminManageParam.getId());
adminManageParam.setRoles(roleService.getAllRoleById(adminManageParam.getId()));
adminManageParam.setMenus( roleService.getMenuList(adminManageParam.getId()));
return CommonResult.success(adminManageParam);
}
@ApiOperation(value = "登出功能")
......
......@@ -6,16 +6,14 @@ import com.macro.mall.model.VankeGoods;
import com.macro.mall.model.VankeSupplier;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsDto;
import com.macro.mall.model.dto.vanke.VankeGoodsRequestParam;
import com.macro.mall.service.vanke.IVankeGoodsService;
import io.swagger.annotations.Api;
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.*;
import java.util.List;
......@@ -30,12 +28,12 @@ public class VankeGoodsController {
@ApiOperation("万科后台_物品分页操作")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<VankeGoodsDto>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@ApiParam(value="分页页数") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@ApiParam(value="物品名称") @RequestParam(value = "name") String name,
@ApiParam(value="物品分类id") @RequestParam(value = "goodsCategoryId") Long goodsCategoryId,
@ApiParam(value="供应商id") @RequestParam(value = "supplierId") Long supplierId,
@ApiParam(value="库房id") @RequestParam(value = "stockRoomId") Long stockRoomId
public CommonResult<CommonPage<VankeGoodsDto>> list(@ApiParam(value="分页大小") @RequestParam(value = "pageSize", required = false) Integer pageSize,
@ApiParam(value="分页页数") @RequestParam(value = "pageNum", required = false) Integer pageNum,
@ApiParam(value="物品名称") @RequestParam(value = "name",required = false) String name,
@ApiParam(value="物品分类id") @RequestParam(value = "goodsCategoryId",required = false) Long goodsCategoryId,
@ApiParam(value="供应商id") @RequestParam(value = "supplierId",required = false) Long supplierId,
@ApiParam(value="库房id") @RequestParam(value = "stockRoomId",required = false) Long stockRoomId
) {
return CommonResult.success(CommonPage.restPage(this.vankeGoodsService.selectList(pageNum,pageSize,name,goodsCategoryId,supplierId,stockRoomId)));
}
......@@ -54,7 +52,7 @@ public class VankeGoodsController {
@ApiOperation("万科后台_根据物品id修改一条数据")
@RequestMapping(value = "/updateGoods", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateGoods(VankeGoods vankeGoods){
public CommonResult updateGoods(@ApiParam(value="物品对象") @RequestBody VankeGoods vankeGoods){
ResultMsg res = this.vankeGoodsService.updateGoods(vankeGoods);
if(res.isFlag()){
return CommonResult.success(null,res.getMsg());
......@@ -83,7 +81,26 @@ public class VankeGoodsController {
}
@ApiOperation("万科后台_插入多条物品信息")
@RequestMapping(value = "/insertVankeGoodsList", method = RequestMethod.POST)
@ResponseBody
public CommonResult insertVankeGoodsList(@ApiParam(value="请求封装对象") @RequestBody VankeGoodsRequestParam vankeGoodsRequestParam){
ResultMsg res = this.vankeGoodsService.insertVankeGoodsList(vankeGoodsRequestParam);
if(res.isFlag()){
return CommonResult.success(null,res.getMsg());
}
return CommonResult.failed(res.getMsg());
}
@ApiOperation("万科后台_出库多条物品")
@RequestMapping(value = "/OutVankeGoodsList", method = RequestMethod.POST)
@ResponseBody
public CommonResult OutVankeGoodsList(@ApiParam(value="请求封装对象") @RequestBody VankeGoodsRequestParam vankeGoodsRequestParam){
ResultMsg res = this.vankeGoodsService.outVankeGoodsList(vankeGoodsRequestParam);
if(res.isFlag()){
return CommonResult.success(null,res.getMsg());
}
return CommonResult.failed(res.getMsg());
}
}
package com.macro.mall.controller.vanke;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsRequestParam;
import com.macro.mall.service.vanke.IVankeGoodsStockService;
import io.swagger.annotations.Api;
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.*;
import java.util.List;
@Controller
@Api(tags = "万科后台_统计图表相关接口", description = "统计图表控制器")
@RequestMapping("/vankeStatisticalChart")
public class VankeStatisticalChartController {
@Autowired
private IVankeGoodsStockService vankeGoodsStockService;
@ApiOperation("万科后台_根据物品id 以及时间list 查询这个时间段内每天的库存信息")
@RequestMapping(value = "/OutVankeGoodsStockChange", method = RequestMethod.GET)
@ResponseBody
public CommonResult selectGoodsStock(@ApiParam(value="查询时间集合 时间格式例如:dateList:[2020-06-24,2020-06-25,...]") @RequestParam(name = "dateList") List<String> dateList,
@ApiParam(value="物品id") @RequestParam(name = "goodsId") Long goodsId){
return CommonResult.success(this.vankeGoodsStockService.selectStockByGoodsIdAndTime(dateList,goodsId));
}
@ApiOperation("万科后台_根据物品id 以及时间list 查询这个时间段内每天的领用情况")
@RequestMapping(value = "/selectGoodsCollection", method = RequestMethod.GET)
@ResponseBody
public CommonResult selectGoodsCollection(@ApiParam(value="查询时间集合 时间格式例如:dateList:[2020-06-24,2020-06-25,...]") @RequestParam(name = "dateList") List<String> dateList,
@ApiParam(value="物品id") @RequestParam(name = "goodsId") Long goodsId){
return CommonResult.success(this.vankeGoodsStockService.selectGoodsCollection(dateList,goodsId));
}
}
......@@ -27,8 +27,9 @@ public class VankeSupplierController {
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<VankeSupplier>> 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.vankeSupplierService.getPageList(pageNum, pageSize)));
@ApiParam(value="分页页数") @RequestParam(value = "pageNum", required = false) Integer pageNum,
@ApiParam(value="供应商名称") @RequestParam(value = "name", required = false) String name) {
return CommonResult.success(CommonPage.restPage(this.vankeSupplierService.getPageList(pageNum, pageSize,name)));
}
@ApiOperation("万科后台_供应商插入操作")
......@@ -53,6 +54,11 @@ public class VankeSupplierController {
return CommonResult.failed(res.getMsg());
}
@ApiOperation("万科后台_根据供应商id查询一条数据")
@RequestMapping(value = "/selectById", method = RequestMethod.GET)
@ResponseBody
public CommonResult selectById( @ApiParam(value="供应商id") @RequestParam(value = "id") Long id){
return CommonResult.success(this.vankeSupplierService.selectOntById(id));
}
}
package com.macro.mall.common.utils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
public class TimeUtils {
......@@ -43,4 +40,13 @@ public class TimeUtils {
}
return daysStrList;
}
/**
* 根据时间返回唯一id
* @return
*/
public static String getOrderNo(){
String dateStr = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
return dateStr +(new Random().nextInt(9000)+1000);
}
}
......@@ -19,7 +19,7 @@ public class GlobalCorsConfig {
public CorsWebFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.addAllowedMethod("*");
// config.setAllowCredentials(true);
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
......
......@@ -74,6 +74,9 @@ public class UmsAdmin implements Serializable {
@ApiModelProperty(value = "部门id")
private Long departId;
@ApiModelProperty(value = "库房id")
private Long stockRoomId;
@ApiModelProperty(value = "供应商申请标识(0未申请1已申请)")
private Integer applyCode;
......@@ -247,6 +250,14 @@ public class UmsAdmin implements Serializable {
this.departId = departId;
}
public Long getStockRoomId() {
return stockRoomId;
}
public void setStockRoomId(Long stockRoomId) {
this.stockRoomId = stockRoomId;
}
public Integer getApplyCode() {
return applyCode;
}
......@@ -282,6 +293,7 @@ public class UmsAdmin implements Serializable {
sb.append(", parentId=").append(parentId);
sb.append(", memberId=").append(memberId);
sb.append(", departId=").append(departId);
sb.append(", stockRoomId=").append(stockRoomId);
sb.append(", applyCode=").append(applyCode);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
......
......@@ -1445,6 +1445,66 @@ public class UmsAdminExample {
return (Criteria) this;
}
public Criteria andStockRoomIdIsNull() {
addCriterion("stock_room_id is null");
return (Criteria) this;
}
public Criteria andStockRoomIdIsNotNull() {
addCriterion("stock_room_id is not null");
return (Criteria) this;
}
public Criteria andStockRoomIdEqualTo(Long value) {
addCriterion("stock_room_id =", value, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdNotEqualTo(Long value) {
addCriterion("stock_room_id <>", value, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdGreaterThan(Long value) {
addCriterion("stock_room_id >", value, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdGreaterThanOrEqualTo(Long value) {
addCriterion("stock_room_id >=", value, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdLessThan(Long value) {
addCriterion("stock_room_id <", value, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdLessThanOrEqualTo(Long value) {
addCriterion("stock_room_id <=", value, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdIn(List<Long> values) {
addCriterion("stock_room_id in", values, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdNotIn(List<Long> values) {
addCriterion("stock_room_id not in", values, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdBetween(Long value1, Long value2) {
addCriterion("stock_room_id between", value1, value2, "stockRoomId");
return (Criteria) this;
}
public Criteria andStockRoomIdNotBetween(Long value1, Long value2) {
addCriterion("stock_room_id not between", value1, value2, "stockRoomId");
return (Criteria) this;
}
public Criteria andApplyCodeIsNull() {
addCriterion("apply_code is null");
return (Criteria) this;
......
package com.macro.mall.model.dto;
import com.macro.mall.model.UmsAdmin;
import com.macro.mall.model.UmsMenu;
import lombok.Data;
import java.util.List;
@Data
public class UmsAdminDto extends UmsAdmin {
}
......@@ -14,10 +14,6 @@ public class VankeGoodsDto extends VankeGoods {
private String stockRoomName;
@ApiModelProperty("物品分类名称")
private String goodsCategoryName;
@ApiModelProperty("物品分类Id")
private Long goodsCategoryId;
@ApiModelProperty("供应商id")
private Long supplierId;
@ApiModelProperty("库房id")
private Long stockRoomId;
@ApiModelProperty("出库会员id")
private Long memberId;
}
package com.macro.mall.model.dto.vanke;
import com.macro.mall.model.VankeGoods;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class VankeGoodsRequestParam {
@ApiModelProperty("物品集合")
private List<VankeGoods> vankeGoodsList;
@ApiModelProperty("物品出库集合")
private List<VankeGoodsDto> vankeGoodsDtoList;
}
package com.macro.mall.model.dto.vanke;
import com.macro.mall.model.VankeGoodsStock;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class VankeGoodsStockDto extends VankeGoodsStock {
@ApiModelProperty("查询时间")
private String queryTime;
}
......@@ -23,6 +23,7 @@
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
<result column="member_id" jdbcType="BIGINT" property="memberId" />
<result column="depart_id" jdbcType="BIGINT" property="departId" />
<result column="stock_room_id" jdbcType="BIGINT" property="stockRoomId" />
<result column="apply_code" jdbcType="INTEGER" property="applyCode" />
</resultMap>
<sql id="Example_Where_Clause">
......@@ -86,7 +87,7 @@
<sql id="Base_Column_List">
id, type, username, phone, password, icon, email, nick_name, note, create_time, login_time,
status, create_date, create_by, update_date, update_by, delete_status, name, parent_id,
member_id, depart_id, apply_code
member_id, depart_id, stock_room_id, apply_code
</sql>
<select id="selectByExample" parameterType="com.macro.mall.model.UmsAdminExample" resultMap="BaseResultMap">
select
......@@ -128,16 +129,16 @@
login_time, status, create_date,
create_by, update_date, update_by,
delete_status, name, parent_id,
member_id, depart_id, apply_code
)
member_id, depart_id, stock_room_id,
apply_code)
values (#{type,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR},
#{nickName,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{loginTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP},
#{createBy,jdbcType=BIGINT}, #{updateDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=BIGINT},
#{deleteStatus,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{parentId,jdbcType=BIGINT},
#{memberId,jdbcType=BIGINT}, #{departId,jdbcType=BIGINT}, #{applyCode,jdbcType=INTEGER}
)
#{memberId,jdbcType=BIGINT}, #{departId,jdbcType=BIGINT}, #{stockRoomId,jdbcType=BIGINT},
#{applyCode,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.macro.mall.model.UmsAdmin">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -205,6 +206,9 @@
<if test="departId != null">
depart_id,
</if>
<if test="stockRoomId != null">
stock_room_id,
</if>
<if test="applyCode != null">
apply_code,
</if>
......@@ -270,6 +274,9 @@
<if test="departId != null">
#{departId,jdbcType=BIGINT},
</if>
<if test="stockRoomId != null">
#{stockRoomId,jdbcType=BIGINT},
</if>
<if test="applyCode != null">
#{applyCode,jdbcType=INTEGER},
</if>
......@@ -347,6 +354,9 @@
<if test="record.departId != null">
depart_id = #{record.departId,jdbcType=BIGINT},
</if>
<if test="record.stockRoomId != null">
stock_room_id = #{record.stockRoomId,jdbcType=BIGINT},
</if>
<if test="record.applyCode != null">
apply_code = #{record.applyCode,jdbcType=INTEGER},
</if>
......@@ -378,6 +388,7 @@
parent_id = #{record.parentId,jdbcType=BIGINT},
member_id = #{record.memberId,jdbcType=BIGINT},
depart_id = #{record.departId,jdbcType=BIGINT},
stock_room_id = #{record.stockRoomId,jdbcType=BIGINT},
apply_code = #{record.applyCode,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -446,6 +457,9 @@
<if test="departId != null">
depart_id = #{departId,jdbcType=BIGINT},
</if>
<if test="stockRoomId != null">
stock_room_id = #{stockRoomId,jdbcType=BIGINT},
</if>
<if test="applyCode != null">
apply_code = #{applyCode,jdbcType=INTEGER},
</if>
......@@ -474,6 +488,7 @@
parent_id = #{parentId,jdbcType=BIGINT},
member_id = #{memberId,jdbcType=BIGINT},
depart_id = #{departId,jdbcType=BIGINT},
stock_room_id = #{stockRoomId,jdbcType=BIGINT},
apply_code = #{applyCode,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
......
......@@ -22,6 +22,7 @@ public class RestfulAccessDeniedHandler implements AccessDeniedHandler{
AccessDeniedException e) throws IOException, ServletException {
//权限控制,新增
// response.setHeader("Access-Control-Allow-Origin", "*");
// response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Cache-Control","no-cache");
//------------
response.setCharacterEncoding("UTF-8");
......
......@@ -2,6 +2,7 @@ package com.macro.mall.dao;
import com.macro.mall.domain.dto.AdminManageParam;
import com.macro.mall.domain.dto.UmsAdminQueryParam;
import com.macro.mall.model.UmsAdmin;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -26,4 +27,11 @@ public interface UmsAdminDao {
* @return
*/
List<AdminManageParam> getOne(@Param("id") Long id);
/**
* 根据登录名查询一条数据
* @param username
* @return
*/
AdminManageParam selectByUserName(String username);
}
package com.macro.mall.dao.vanke;
import com.macro.mall.model.VankeGoodsStock;
import com.macro.mall.model.dto.vanke.VankeGoodsStockDto;
public interface VankeGoodsStockDao {
/**
* 根据时间和物品id 得到传入时间当天最后一个库存值
* @param vankeGoodsStockDto
* @return
*/
Integer selectOneByGoodsIdAndCreatetime(VankeGoodsStockDto vankeGoodsStockDto);
/**
* 根据时间和物品id 得到传入时间当天内库存变化总值
* @param vankeGoodsStockDto
* @return
*/
Integer selectGoodsCollection(VankeGoodsStockDto vankeGoodsStockDto);
}
......@@ -9,6 +9,7 @@ import com.macro.mall.model.UmsAdmin;
import com.macro.mall.model.UmsPermission;
import com.macro.mall.model.UmsResource;
import com.macro.mall.model.UmsRole;
import com.macro.mall.model.dto.UmsAdminDto;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.transaction.annotation.Transactional;
......@@ -26,6 +27,12 @@ public interface UmsAdminService {
UmsAdmin getAdminByUsername(String username);
/**
* 根据名称 查询一个后台管理员
* @param name
* @return
*/
AdminManageParam getVankeAdminByUsername(String name);
/**
* 添加管理员账户
*/
void addAdmin(UmsAdmin umsAdmin);
......
......@@ -94,6 +94,16 @@ public class UmsAdminServiceImpl implements UmsAdminService {
adminMapper.insertSelective(umsAdmin);
}
/**
* 根据账号 查询一个后台管理员
* @param username
* @return
*/
@Override
public AdminManageParam getVankeAdminByUsername(String username){
return this.adminDao.selectByUserName(username);
}
@Override
public int update(UmsAdmin admin) {
return adminMapper.updateByPrimaryKey(admin);
......
......@@ -3,6 +3,7 @@ package com.macro.mall.service.vanke;
import com.macro.mall.model.VankeGoods;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsDto;
import com.macro.mall.model.dto.vanke.VankeGoodsRequestParam;
import java.util.List;
......@@ -44,4 +45,18 @@ public interface IVankeGoodsService {
* @return
*/
List<VankeGoodsDto> selectGoodsByCategotyAndSupplier(VankeGoodsDto vankeGoodsDto);
/**
* 插入物品集合 入库操作
* @param vankeGoodsRequestParam
* @return
*/
ResultMsg insertVankeGoodsList(VankeGoodsRequestParam vankeGoodsRequestParam);
/**
* 物品出库操作
* @param vankeGoodsRequestParam
* @return
*/
ResultMsg outVankeGoodsList(VankeGoodsRequestParam vankeGoodsRequestParam);
}
package com.macro.mall.service.vanke;
import com.macro.mall.model.VankeGoodsStock;
import com.macro.mall.model.common.ResultMsg;
import java.util.List;
import java.util.Map;
public interface IVankeGoodsStockService {
/**
* 插入商品库存变化信息
* @param goodsId
* @param goodsNum
* @param stockNum
* @return
*/
ResultMsg insertGoodsStockService(Long goodsId,Integer goodsNum,Integer stockNum);
/**
* 根据时间和物品id查询库存变化趋势
* @param dateList
* @param goodsId
* @return
*/
Map<String ,Object> selectStockByGoodsIdAndTime(List<String> dateList , Long goodsId);
/**
* 根据时间和物品id查询物品领用情况
* @param dateList
* @param goodsId
* @return
*/
Map<String ,Object> selectGoodsCollection(List<String> dateList , Long goodsId);
}
......@@ -27,5 +27,12 @@ public interface IVankeSupplierService {
* @param pageSize
* @return
*/
List<VankeSupplier> getPageList(Integer pageNum,Integer pageSize);
List<VankeSupplier> getPageList(Integer pageNum,Integer pageSize,String name);
/**
* 根据id查询一个供应商
* @param id
* @return
*/
VankeSupplier selectOntById(Long id);
}
......@@ -3,14 +3,19 @@ package com.macro.mall.service.vanke.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.common.utils.TimeUtils;
import com.macro.mall.dao.vanke.VankeGoodsDao;
import com.macro.mall.mapper.UmsMemberMapper;
import com.macro.mall.mapper.VankeGoodsMapper;
import com.macro.mall.model.UmsAdmin;
import com.macro.mall.model.VankeGoods;
import com.macro.mall.mapper.VankeInboundRecordMapper;
import com.macro.mall.mapper.VankeOutboundRecordMapper;
import com.macro.mall.model.*;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsDto;
import com.macro.mall.model.dto.vanke.VankeGoodsRequestParam;
import com.macro.mall.service.system.UmsAdminService;
import com.macro.mall.service.vanke.IVankeBackLogService;
import com.macro.mall.service.vanke.IVankeGoodsService;
import com.macro.mall.service.vanke.IVankeGoodsStockService;
import com.macro.mall.service.vanke.IVankeInboundRecordService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -34,8 +39,14 @@ public class VankeGoodsServiceImpl implements IVankeGoodsService {
private UmsAdminService umsAdminService;
@Autowired
private IVankeBackLogService vankeBackLogService;
@Autowired
private IVankeGoodsStockService vankeGoodsStockService;
@Resource
private VankeInboundRecordMapper vankeInboundRecordMapper;
@Resource
private UmsMemberMapper umsMemberMapper;
@Resource
private VankeOutboundRecordMapper vankeOutboundRecordMapper;
/**
*
* @param pageNum 页数
......@@ -46,7 +57,9 @@ public class VankeGoodsServiceImpl implements IVankeGoodsService {
@Override
public List<VankeGoodsDto> selectList(Integer pageNum, Integer pageSize, String name, Long goodsCategoryId, Long supplierId, Long stockRoomId){
//分页操作
if(pageNum != null && pageSize!= null){
PageHelper.startPage(pageNum, pageSize);
}
VankeGoodsDto vankeGoodsDto = new VankeGoodsDto();
vankeGoodsDto.setName(name);
vankeGoodsDto.setGoodsCategoryId(goodsCategoryId);
......@@ -147,14 +160,109 @@ public class VankeGoodsServiceImpl implements IVankeGoodsService {
return this.vankeGoodsDao.selectGoodsByCategotyAndSupplier(vankeGoodsDto);
}
/**
* 插入物品集合
* @param vankeGoodsRequestParam
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg insertVankeGoodsList(VankeGoodsRequestParam vankeGoodsRequestParam){
if(vankeGoodsRequestParam.getVankeGoodsList() == null || vankeGoodsRequestParam.getVankeGoodsList().size()==0){
return new ResultMsg(false,"传入物品集合为空");
}
//用来存取 根据id查询得到的物品对象
VankeGoods vankeGoods;
//用来建立入库记录对象
VankeInboundRecord vankeInboundRecord = new VankeInboundRecord();
//获取管理员对象
UmsAdmin ua = umsAdminService.getCurrentUmsAdmin();
//遍历传入物品集合
for(VankeGoods vg : vankeGoodsRequestParam.getVankeGoodsList()){
int stockNum = 0;
//插入入库记录表
vankeInboundRecord.setGoodsId(vg.getId());
vankeInboundRecord.setInboundNo(TimeUtils.getOrderNo());
vankeInboundRecord.setStockRoomId(vg.getStockRoomId());
vankeInboundRecord.setInboundNum(vg.getGoodsNum());
if(ua!= null && ua.getMemberId()!=null){ //如果不为空则是普通管理员
vankeInboundRecord.setReceptInboundMemberId(ua.getMemberId());
}else {//否则是超管
vankeInboundRecord.setBackInboundMemberId(ua.getId());
}
if(vg.getId() != null){ // 物品id不为空 说明已存在 进行更新操作
vankeGoods = this.vankeGoodsMapper.selectByPrimaryKey(vg.getId());
stockNum = vankeGoods.getGoodsNum()+vg.getGoodsNum();
//插入库存变化表
this.vankeGoodsStockService.insertGoodsStockService(vg.getId(),vg.getGoodsNum(),stockNum);
//更新物品的库存数量
vankeGoods.setGoodsNum(stockNum);
this.vankeGoodsMapper.updateByPrimaryKeySelective(vankeGoods);
}else{//否则新增操作
this.vankeGoodsMapper.insertSelective(vg);
//插入库存变化表
this.vankeGoodsStockService.insertGoodsStockService(vg.getId(),vg.getGoodsNum(),vg.getGoodsNum());
}
//插入进入库记录表
this.vankeInboundRecordMapper.insertSelective(vankeInboundRecord);
}
return new ResultMsg(true,"操作成功");
}
@Test
public void test1(){
List<String> dataList = TimeUtils.getDaysByStartTimeAndEndTime("2019-2-25","2019-3-02");
dataList.forEach(data ->{
System.out.println(data);
//SELECT * FROM vanke_outbound_record where date_format(createtime,'%Y-%m-%d') = '2020-06-21'
});
/**
* 物品出库操作
* @param vankeGoodsRequestParam
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg outVankeGoodsList(VankeGoodsRequestParam vankeGoodsRequestParam){
if(vankeGoodsRequestParam.getVankeGoodsDtoList() == null || vankeGoodsRequestParam.getVankeGoodsDtoList().size()==0){
return new ResultMsg(false,"传入物品集合为空");
}
//用来存取 根据id查询得到的物品对象
VankeGoods vankeGoods;
//用来建立入库记录对象
VankeOutboundRecord vankeOutboundRecord = new VankeOutboundRecord();
//获取管理员对象
UmsAdmin ua = umsAdminService.getCurrentUmsAdmin();
//建立会员对象
UmsMember umsMember;
//遍历传入物品集合
for(VankeGoodsDto vg : vankeGoodsRequestParam.getVankeGoodsDtoList()){
int stockNum = 0;
vankeGoods = this.vankeGoodsMapper.selectByPrimaryKey(vg.getId());
if(vankeGoods == null){
return new ResultMsg(false,"不存在id为"+vg.getId()+"的物品");
}
if(vankeGoods.getGoodsNum() < vg.getGoodsNum()){
return new ResultMsg(false,"物品"+vankeGoods.getName() +"出库数量不能大于库存数量!!");
}
stockNum = vankeGoods.getGoodsNum()- vg.getGoodsNum();
//插入库存变化表
this.vankeGoodsStockService.insertGoodsStockService(vg.getId(),vg.getGoodsNum()* -1,stockNum);
//更新物品的库存数量
vankeGoods.setGoodsNum(stockNum);
this.vankeGoodsMapper.updateByPrimaryKeySelective(vankeGoods);
//查询会员
umsMember = this.umsMemberMapper.selectByPrimaryKey(vg.getMemberId());
if(umsMember == null){
return new ResultMsg(false,"传入会员id"+vg.getMemberId()+"不存在");
}
vankeOutboundRecord.setOutboundNo(TimeUtils.getOrderNo());
vankeOutboundRecord.setMemberId(vg.getMemberId());
vankeOutboundRecord.setDepartId(umsMember.getDepartId());
vankeOutboundRecord.setGoodsId(vg.getId());
vankeOutboundRecord.setStockRoomId(vg.getStockRoomId());
vankeOutboundRecord.setOutboundNum(vg.getGoodsNum());
if(ua!= null && ua.getMemberId()!=null){ //如果不为空则是普通管理员
vankeOutboundRecord.setReceptOutboundMemberId(ua.getMemberId());
}else {//否则是超管
vankeOutboundRecord.setBackOutboundMemberId(ua.getId());
}
this.vankeOutboundRecordMapper.insertSelective(vankeOutboundRecord);
}
return new ResultMsg(true,"操作成功");
}
}
package com.macro.mall.service.vanke.impl;
import com.macro.mall.dao.vanke.VankeGoodsStockDao;
import com.macro.mall.mapper.VankeGoodsStockMapper;
import com.macro.mall.model.VankeGoodsStock;
import com.macro.mall.model.common.ResultMsg;
import com.macro.mall.model.dto.vanke.VankeGoodsStockDto;
import com.macro.mall.service.vanke.IVankeGoodsStockService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class VankeGoodsStockServiceImpl implements IVankeGoodsStockService {
@Resource
private VankeGoodsStockMapper vankeGoodsStockMapper;
@Resource
private VankeGoodsStockDao vankeGoodsStockDao;
/**
* 插入商品库存变化信息
* @param goodsId
* @param goodsNum 物品库存变化量
* @param stockNum 物品库存变化后库存
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultMsg insertGoodsStockService(Long goodsId,Integer goodsNum,Integer stockNum){
VankeGoodsStock vgs = new VankeGoodsStock();
vgs.setGoodsId(goodsId);
vgs.setGoodsNum(goodsNum);
vgs.setStockNum(stockNum);
this.vankeGoodsStockMapper.insertSelective(vgs);
return new ResultMsg(true,"操作成功");
}
/**
* 根据时间和物品id查询库存变化趋势
* @param dateList
* @param goodsId
* @return
*/
@Override
public Map<String ,Object> selectStockByGoodsIdAndTime(List<String> dateList , Long goodsId){
//初始化结果map
Map<String,Object> map = new HashMap<>();
//初始化查询对象
VankeGoodsStockDto vankeGoodsStockDto = new VankeGoodsStockDto();
vankeGoodsStockDto.setGoodsId(goodsId);
//初始化查询结果对象
for(String date : dateList) {
vankeGoodsStockDto.setQueryTime(date);
map.put(date,this.vankeGoodsStockDao.selectOneByGoodsIdAndCreatetime(vankeGoodsStockDto));
}
return map;
}
/**
* 根据时间和物品id查询物品领用情况
* @param dateList
* @param goodsId
* @return
*/
@Override
public Map<String ,Object> selectGoodsCollection(List<String> dateList , Long goodsId){
//初始化结果map
Map<String,Object> map = new HashMap<>();
//初始化查询对象
VankeGoodsStockDto vankeGoodsStockDto = new VankeGoodsStockDto();
vankeGoodsStockDto.setGoodsId(goodsId);
for(String date : dateList) {
vankeGoodsStockDto.setQueryTime(date);
map.put(date,this.vankeGoodsStockDao.selectGoodsCollection(vankeGoodsStockDto));
}
return map;
}
}
......@@ -4,7 +4,6 @@ import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.vanke.VankeOutBoundRecordDao;
import com.macro.mall.model.dto.vanke.VankeOutboundRecordDto;
import com.macro.mall.service.vanke.IVankeOutboundRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -34,4 +33,5 @@ public class VankeOutboundRecordServiceImpl implements IVankeOutboundRecordServi
vord.setGoodsName(goodsMame);
return this.vankeOutBoundRecordDao.getPageList(vord);
}
}
......@@ -21,6 +21,8 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
......@@ -88,18 +90,8 @@ public class VankeStockRoomServiceImpl implements IVankeStockRoomService {
}
VankeStockRoomExample example = new VankeStockRoomExample();
VankeStockRoomExample.Criteria criteria = example.createCriteria();
criteria.andDeleteStatusEqualTo(0);//1未删除 0已删除
criteria.andDeleteStatusEqualTo(1);//1未删除 0已删除
return this.vankeStockRoomMapper.selectByExample(example);
}
@Test
public void testHttps() throws Exception {
long timeNew = System.currentTimeMillis(); // 13位数的时间戳
// String uri = "https://vvtest.vanke.com/gateway/oauth2/token/getAccessToken?appid=111&secret=222&timestamp="+timeNew+"&scope=app";
String uri = "https://vvtest.vanke.com/gateway/oauth2/token/getAccessToken?appid=111&secret=222&timestamp="+timeNew+"&scope=app";
String data="";
byte[] bytes = HttpsUtil.doPost(uri,data);
System.out.println(new String(bytes));
}
}
\ No newline at end of file
......@@ -31,16 +31,19 @@ public class VankeSupplierServiceImpl implements IVankeSupplierService {
* 分页操作
* @param pageNum
* @param pageSize
* @return
* @returnpms
*/
@Override
public List<VankeSupplier> getPageList(Integer pageNum, Integer pageSize){
public List<VankeSupplier> getPageList(Integer pageNum, Integer pageSize,String name){
if(pageNum != null && pageSize != null){
PageHelper.startPage(pageNum, pageSize);
}
VankeSupplierExample example = new VankeSupplierExample();
VankeSupplierExample.Criteria criteria = example.createCriteria();
criteria.andDeleteStatusEqualTo(1);//1未删除 0已删除
if(name != null && ! "".equals(name)) {//如果名字不为空 则添加模糊搜索
criteria.andSupplierNameLike( name + "%");
}
return this.vankeSupplierMapper.selectByExample(example);
}
......@@ -101,6 +104,14 @@ public class VankeSupplierServiceImpl implements IVankeSupplierService {
return new ResultMsg(true,"校验成功");
}
/**
* 根据id查询一个供应商
* @param id
* @return
*/
@Override
public VankeSupplier selectOntById(Long id){
return this.vankeSupplierMapper.selectByPrimaryKey(id);
}
}
......@@ -2,7 +2,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.UmsAdminDao">
<resultMap id="resultMap" type="com.macro.mall.domain.dto.AdminManageParam" extends="com.macro.mall.mapper.UmsAdminMapper.BaseResultMap">
<result column="departName" jdbcType="VARCHAR" property="departName" />
<result column="stockRoomName" jdbcType="VARCHAR" property="stockRoomName" />
</resultMap>
<select id="getListByUmsAdmin" parameterType="com.macro.mall.domain.dto.UmsAdminQueryParam" resultMap="resultMap">
select a.*,r.name as roleName ,r.id as roleId ,d.depart_name as departName
......@@ -59,4 +60,15 @@
</if>
</where>
</select>
<select id="selectByUserName" parameterType="java.lang.String" resultMap="resultMap">
select
a.*,
b.name departName,c.name stockRoomName
from ums_admin 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
where a.username = #{username}
and a.delete_status = 0
</select>
</mapper>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<select id="selectList" resultMap="BaseResultMap" parameterType="com.macro.mall.model.dto.vanke.VankeGoodsDto">
select a.*,b.name goodsCategoryName,c.name stockRoomName,d.name supplierName from vanke_goods a
select a.*,b.name goodsCategoryName,c.name stockRoomName,d.supplier_name supplierName from vanke_goods a
left join vanke_goods_category b ON a.goods_category_id = b.id
left join vanke_stock_room c ON a.stock_room_id = c.id
left join vanke_supplier d ON a.supplier_id = d.id
......
<?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.VankeGoodsStockDao">
<resultMap id="BaseResultMap" type="com.macro.mall.model.VankeGoodsStock" extends="com.macro.mall.mapper.VankeGoodsStockMapper.BaseResultMap">
</resultMap>
<select id="selectOneByGoodsIdAndCreatetime" parameterType="com.macro.mall.model.dto.vanke.VankeGoodsStockDto" resultType="java.lang.Integer">
select IFNULL(stock_num,0) from vanke_goods_stock
where goods_id = #{goodsId}
and date_format(createtime,'%Y-%m-%d') = #{queryTime}
ORDER BY createtime DESC LIMIT 0,1
</select>
<select id="selectGoodsCollection" parameterType="com.macro.mall.model.dto.vanke.VankeGoodsStockDto" resultType="java.lang.Integer">
SELECT IFNULL(SUM(goods_num),0) FROM vanke_goods_stock
where goods_id = #{goodsId}
and date_format(createtime,'%Y-%m-%d') = #{queryTime}
</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