
53 changed files with 2498 additions and 242 deletions
@ -0,0 +1,27 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.List; |
|||
@Data |
|||
public class InStoreHouseMainDto { |
|||
@NotBlank(message = "编号不能为空") |
|||
private String no; //varchar 50 编号
|
|||
@NotBlank(message = "制单日期不能为空") |
|||
private String applicationDate; //date 50 制单日期
|
|||
private String creatorSid; //varchar 64 制单人Sid
|
|||
private String creatorName; /// varchar 50 制单人姓名
|
|||
@NotBlank(message = "客户Sid不能为空") |
|||
private String custerSid; //varchar 64 客户Sid(企业)
|
|||
@NotBlank(message = "客户名称不能为空") |
|||
private String custerName; // varchar 100 客户名称(企业)
|
|||
private String storeHouseSid; // varchar 64 仓库Sid
|
|||
private String storeHouseName; // varchar 100 仓库名称
|
|||
private String auditorSid; //varchar 64 审核人Sid
|
|||
private String auditorName; // varchar 50 审核人姓名
|
|||
private String state; // varchar 50 审核状态
|
|||
private String approvedDate; // varchar 50 审核日期
|
|||
private String approvedRemark; // varchar 50
|
|||
private List<InStorehouseListing> list; |
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotEmpty; |
|||
import javax.validation.constraints.Positive; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
@TableName("in_storehouse_listing") |
|||
public class InStorehouseListing extends BaseEntity { |
|||
private String custerSid;// varchar 64 客户Sid(企业)
|
|||
private String custerName ;//varchar 100 客户名称(企业)
|
|||
private String storeHouseSid ;//varchar 64 仓库Sid
|
|||
private String storeHouseName ;//varchar 100 仓库名称
|
|||
@NotBlank(message = "质物名称不能为空") |
|||
private String proName;// varchar 50 质物名称
|
|||
@NotBlank(message = "规格(型号)不能为空") |
|||
private String proModel ;//varchar 50 规格(型号)
|
|||
private String proUnit ;//varchar 50 规格单位
|
|||
private String manufacturer;// varchar 50 生成厂家(产地)
|
|||
@Positive(message ="数量必须为一个正数" ) |
|||
private String num ;//varchar 10 数量
|
|||
private String weight ;//varchar 50 重量
|
|||
@NotBlank(message = "质权人确认的单价不能为空") |
|||
private String confirmedPrice;// decime 50 2 质权人确认的单价
|
|||
@NotBlank(message = "核算的价值不能为空") |
|||
private String calculatedValue ;//decime 50 2 核算的价值
|
|||
private String locationNumber ;//varchar 10 货位号
|
|||
private String mainSid ;//varchar 50 申请单的sid
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
@TableName("in_storehouse_main") |
|||
public class InStorehouseMain extends BaseEntity { |
|||
private String no; //varchar 50 编号
|
|||
private String applicationDate; //date 50 制单日期
|
|||
private String creatorSid; //varchar 64 制单人Sid
|
|||
private String creatorName; /// varchar 50 制单人姓名
|
|||
private String custerSid; //varchar 64 客户Sid(企业)
|
|||
private String custerName; // varchar 100 客户名称(企业)
|
|||
private String storeHouseSid; // varchar 64 仓库Sid
|
|||
private String storeHouseName; // varchar 100 仓库名称
|
|||
private String auditorSid; //varchar 64 审核人Sid
|
|||
private String auditorName; // varchar 50 审核人姓名
|
|||
private String approvedDate; // varchar 50 审核日期
|
|||
private String approvedRemark; // varchar 50 审核备注
|
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.Positive; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
@TableName("out_storehouse_listing") |
|||
public class OutStorehouseListing extends BaseEntity { |
|||
private String custerSid;// varchar 64 客户Sid(企业)
|
|||
private String custerName ;//varchar 100 客户名称(企业)
|
|||
private String storeHouseSid ;//varchar 64 仓库Sid
|
|||
private String storeHouseName ;//varchar 100 仓库名称
|
|||
@NotBlank(message = "质物名称不能为空") |
|||
private String proName;// varchar 50 质物名称
|
|||
@NotBlank(message = "规格(型号)不能为空") |
|||
private String proModel ;//varchar 50 规格(型号)
|
|||
private String proUnit ;//varchar 50 规格单位
|
|||
private String manufacturer;// varchar 50 生成厂家(产地)
|
|||
@Positive(message ="数量必须为一个正数" ) |
|||
private String estimateNum ;//varchar 10 预计数量
|
|||
private String estimateWeight ;//varchar 50 预计重量
|
|||
@NotBlank(message = "预计质权人确认的单价不能空") |
|||
private String estimateConfirmedPrice;// decime 50 2 质权人确认的单价
|
|||
@NotBlank(message = "预计核算的价值不能空") |
|||
private String estimateCalculatedValue ;//decime 50 2 核算的价值
|
|||
@Positive(message ="数量必须为一个正数" ) |
|||
private String realityNum ;//varchar 10 实际数量
|
|||
private String realityWeight ;//varchar 50 实际重量
|
|||
@NotBlank(message = "实际质权人确认的单价不能空") |
|||
private String realityConfirmedPrice;// decime 50 2 实际质权人确认
|
|||
@NotBlank(message = "实际核算的价值不能空") |
|||
private String realityCalculatedValue ;//decime 50 2 实际核算的价值
|
|||
private String locationNumber ;//varchar 10 货位号
|
|||
private String mainSid ;//varchar 50 申请单的sid
|
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
@TableName("out_storehouse_main") |
|||
public class OutStorehouseMain extends BaseEntity { |
|||
private String no; //varchar 50 编号
|
|||
private String applicationDate; //date 50 制单日期
|
|||
private String creatorSid; //varchar 64 制单人Sid
|
|||
private String creatorName; /// varchar 50 制单人姓名
|
|||
private String custerSid; //varchar 64 客户Sid(企业)
|
|||
private String custerName; // varchar 100 客户名称(企业)
|
|||
private String storeHouseSid; // varchar 64 仓库Sid
|
|||
private String storeHouseName; // varchar 100 仓库名称
|
|||
private String auditorSid; //varchar 64 审核人Sid
|
|||
private String auditorName; // varchar 50 审核人姓名
|
|||
private String approvedDate; // varchar 50 审核日期
|
|||
private String approvedRemark; // varchar 50 审核备注
|
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
public class OutStorehouseMainDto { |
|||
private String no; //varchar 50 编号
|
|||
private String applicationDate; //date 50 制单日期
|
|||
private String creatorSid; //varchar 64 制单人Sid
|
|||
private String creatorName; /// varchar 50 制单人姓名
|
|||
private String custerSid; //varchar 64 客户Sid(企业)
|
|||
private String custerName; // varchar 100 客户名称(企业)
|
|||
private String storeHouseSid; // varchar 64 仓库Sid
|
|||
private String storeHouseName; // varchar 100 仓库名称
|
|||
private String auditorSid; //varchar 64 审核人Sid
|
|||
private String auditorName; // varchar 50 审核人姓名
|
|||
private String approvedDate; // varchar 50 审核日期
|
|||
private String approvedRemark; // varchar 50 审核备注
|
|||
private List<OutStorehouseListing> list; |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
@TableName("prod_stock") |
|||
public class ProdStock extends BaseEntity { |
|||
private String proName;// varchar 50 质物名称
|
|||
private String proModel;// varchar 50 规格(型号)
|
|||
private String manufacturer;// varchar 50 生成厂家(产地)
|
|||
private String num;// varchar 10 数量
|
|||
private String weight;// varchar 50 重量
|
|||
private String confirmedPrice;// decime 50 2 质权人确认的单价
|
|||
private String calculatedValue;// decime 50 2 核算的价值
|
|||
private String locationNumber;// varchar 10 货位号
|
|||
private String custerName;// varchar 50 客户名称(企业)
|
|||
private String proUnit;// varchar 50 规格单位
|
|||
private String custerSid;// varchar 64 客户Sid(企业)
|
|||
private String storeHouseSid;// varchar 64 仓库Sid
|
|||
private String storeHouseName;// varchar 100 仓库名称
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
@Data |
|||
@Accessors(chain = true) |
|||
public class ProdStockDto extends BaseEntity { |
|||
private String proName;// varchar 50 质物名称
|
|||
private String proModel;// varchar 50 规格(型号)
|
|||
private String manufacturer;// varchar 50 生成厂家(产地)
|
|||
private String num;// varchar 10 数量
|
|||
private String weight;// varchar 50 重量
|
|||
private String confirmedPrice;// decime 50 2 质权人确认的单价
|
|||
private String calculatedValue;// decime 50 2 核算的价值
|
|||
private String locationNumber;// varchar 10 货位号
|
|||
private String custerName;// varchar 50 客户名称(企业)
|
|||
private String proUnit;// varchar 50 规格单位
|
|||
private String custerSid;// varchar 64 客户Sid(企业)
|
|||
private String storeHouseSid;// varchar 64 仓库Sid
|
|||
private String storeHouseName;// varchar 100 仓库名称
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
@Data |
|||
public class ProdStockQuery implements Query { |
|||
private String proName;// varchar 50 质物名称
|
|||
private String proModel;// varchar 50 规格(型号)
|
|||
private String manufacturer;// varchar 50 生成厂家(产地)
|
|||
private String num;// varchar 10 数量
|
|||
private String weight;// varchar 50 重量
|
|||
private String confirmedPrice;// decime 50 2 质权人确认的单价
|
|||
private String calculatedValue;// decime 50 2 核算的价值
|
|||
private String locationNumber;// varchar 10 货位号
|
|||
private String custerName;// varchar 50 客户名称(企业)
|
|||
private String proUnit;// varchar 50 规格单位
|
|||
private String custerSid;// varchar 64 客户Sid(企业)
|
|||
private String storeHouseSid;// varchar 64 仓库Sid
|
|||
private String storeHouseName;// varchar 100 仓库名称
|
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.wh.pojo.api; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class ProdStockVo implements Vo { |
|||
private String proName;// varchar 50 质物名称
|
|||
private String proModel;// varchar 50 规格(型号)
|
|||
private String manufacturer;// varchar 50 生成厂家(产地)
|
|||
private String num;// varchar 10 数量
|
|||
private String weight;// varchar 50 重量
|
|||
private String confirmedPrice;// decime 50 2 质权人确认的单价
|
|||
private String calculatedValue;// decime 50 2 核算的价值
|
|||
private String locationNumber;// varchar 10 货位号
|
|||
private String custerName;// varchar 50 客户名称(企业)
|
|||
private String proUnit;// varchar 50 规格单位
|
|||
private String custerSid;// varchar 64 客户Sid(企业)
|
|||
private String storeHouseSid;// varchar 64 仓库Sid
|
|||
private String storeHouseName;// varchar 100 仓库名称
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.wh.controller.api.input; |
|||
|
|||
|
|||
import com.wh.pojo.api.InStoreHouseMainDto; |
|||
import com.wh.service.api.instorehouse.InStorehouseMainService; |
|||
import com.wh.vo.SysResult; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@RestController |
|||
@CrossOrigin |
|||
@RequestMapping("/input/") |
|||
public class InStoreHouseMainController { |
|||
|
|||
@Autowired |
|||
private InStorehouseMainService inStorehouseMainService; |
|||
|
|||
@PostMapping("addInStorehouse") |
|||
public ResultBean addInStorehouse(@RequestBody InStoreHouseMainDto inStoreHouseMainDto){ |
|||
ResultBean resultBean = inStorehouseMainService.addInStorehouse(inStoreHouseMainDto); |
|||
return resultBean; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.wh.controller.api.output; |
|||
|
|||
import com.wh.pojo.api.OutStorehouseMain; |
|||
import com.wh.pojo.api.OutStorehouseMainDto; |
|||
import com.wh.service.api.outstorehouse.OutStorehouseMainService; |
|||
import com.wh.vo.SysResult; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@RestController |
|||
@CrossOrigin |
|||
@RequestMapping("/output/") |
|||
public class OutStorehouseMainController { |
|||
|
|||
@Autowired |
|||
private OutStorehouseMainService outStorehouseMainService; |
|||
|
|||
@PostMapping("addOutStorehouse") |
|||
public ResultBean addOutStorehouse(@RequestBody OutStorehouseMainDto outStorehouseMainDto){ |
|||
ResultBean resultBean = outStorehouseMainService.addOutStorehouse(outStorehouseMainDto); |
|||
return resultBean; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.wh.controller.api.prodstock; |
|||
|
|||
import org.springframework.web.bind.annotation.CrossOrigin; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@CrossOrigin |
|||
@RequestMapping("/stock/") |
|||
public class ProdStockController { |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.wh.mapper.api.instorehouse; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.wh.pojo.api.InStorehouseListing; |
|||
import com.wh.pojo.api.InStorehouseMain; |
|||
|
|||
|
|||
public interface InStorehouseListingMapper extends BaseMapper<InStorehouseListing> { |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.wh.mapper.api.instorehouse; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.wh.pojo.InStorehouse; |
|||
import com.wh.pojo.api.InStorehouseMain; |
|||
|
|||
|
|||
public interface InStorehouseMainMapper extends BaseMapper<InStorehouseMain> { |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.wh.mapper.api.outstorehouse; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.wh.pojo.api.InStorehouseListing; |
|||
import com.wh.pojo.api.OutStorehouseListing; |
|||
|
|||
|
|||
public interface OutStorehouseListingMapper extends BaseMapper<OutStorehouseListing> { |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.wh.mapper.api.outstorehouse; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.wh.pojo.api.InStorehouseMain; |
|||
import com.wh.pojo.api.OutStorehouseMain; |
|||
|
|||
|
|||
public interface OutStorehouseMainMapper extends BaseMapper<OutStorehouseMain> { |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.wh.mapper.api.prodstock; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.wh.pojo.api.InStorehouseMain; |
|||
import com.wh.pojo.api.ProdStock; |
|||
|
|||
|
|||
public interface ProdStockMapper extends BaseMapper<ProdStock> { |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.wh.service.api.instorehouse; |
|||
|
|||
|
|||
import com.wh.mapper.api.instorehouse.InStorehouseListingMapper; |
|||
import com.wh.pojo.*; |
|||
import com.wh.pojo.api.InStorehouseListing; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class InStorehouseListingService extends MybatisBaseService<InStorehouseListingMapper, InStorehouseListing> { |
|||
|
|||
public Map<String, Object> getQuery(InStorehouse inStorehouse) { |
|||
|
|||
Map<String,Object> map = new HashMap<>(); |
|||
|
|||
return map; |
|||
} |
|||
} |
@ -0,0 +1,140 @@ |
|||
package com.wh.service.api.instorehouse; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|||
import com.wh.mapper.api.instorehouse.InStorehouseMainMapper; |
|||
import com.wh.pojo.api.*; |
|||
import com.wh.service.api.prodstock.ProdStockService; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
@Slf4j |
|||
@Service |
|||
public class InStorehouseMainService extends MybatisBaseService<InStorehouseMainMapper, InStorehouseMain> { |
|||
|
|||
@Autowired |
|||
private InStorehouseListingService inStorehouseListingService; |
|||
@Autowired |
|||
private ProdStockService prodStockService; |
|||
@Transactional |
|||
public ResultBean addInStorehouse(InStoreHouseMainDto inStoreHouseMainDto) { |
|||
ResultBean<Object> r = ResultBean.fireFail(); |
|||
if(inStoreHouseMainDto==null){ |
|||
return r.setMsg("数据不能为空"); |
|||
} |
|||
if(StringUtils.isBlank(inStoreHouseMainDto.getNo())){ |
|||
return r.setMsg("申请单编号不能为空"); |
|||
} |
|||
QueryWrapper<InStorehouseMain> queryWrapper = new QueryWrapper<>(); |
|||
queryWrapper.eq("no",inStoreHouseMainDto.getNo()); |
|||
if(baseMapper.selectCount(queryWrapper) != 0){ |
|||
return r.setMsg("申请单编号已经存在"); |
|||
} |
|||
InStorehouseMain in=new InStorehouseMain(); |
|||
BeanUtils.copyProperties(inStoreHouseMainDto,in); |
|||
List<InStorehouseListing> list = inStoreHouseMainDto.getList(); |
|||
if(list==null||list.size()==0){ |
|||
return r.setMsg("商品不能为空"); |
|||
} |
|||
//申请单主表信息
|
|||
baseMapper.insert(in); |
|||
addListing(in, list); |
|||
return ResultBean.fireSuccess().setMsg("添加成功"); |
|||
} |
|||
|
|||
/** |
|||
* 新增商品信息 |
|||
* @param in |
|||
* @param list |
|||
*/ |
|||
@Transactional |
|||
public void addListing(InStorehouseMain in, List<InStorehouseListing> list) { |
|||
list.forEach(l->{ |
|||
l.setCusterSid(in.getCusterSid()); |
|||
l.setCusterName(in.getCusterName()); |
|||
l.setMainSid(in.getSid()); |
|||
inStorehouseListingService.insert(l); |
|||
saveOrUpdateProdStock(l); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 新增或者修改商品库存信息 |
|||
* @param l |
|||
*/ |
|||
private void saveOrUpdateProdStock(InStorehouseListing l) { |
|||
PagerVo<ProdStock> proStocks = getProdStock(l); |
|||
long total = proStocks.getTotal(); |
|||
if(total==0){ |
|||
addProdStock(l); |
|||
}else{ |
|||
updateProdStock(l, proStocks); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 修改商品库存信息 |
|||
* @param l |
|||
* @param proStocks |
|||
*/ |
|||
private void updateProdStock(InStorehouseListing l, PagerVo<ProdStock> proStocks) { |
|||
ResultBean<Object> r = ResultBean.fireFail(); |
|||
ProdStock prodStock = proStocks.getRecords().get(0); |
|||
String num = prodStock.getNum(); |
|||
if(com.yxt.common.base.utils.StringUtils.isBlank(num)){ |
|||
log.info("{}",l.getProName()+"商品数量不能为空"); |
|||
} |
|||
int i=Integer.valueOf(num)+Integer.valueOf(l.getNum()); |
|||
prodStock.setNum(i+""); |
|||
prodStockService.updateById(prodStock); |
|||
} |
|||
|
|||
/** |
|||
* 新增商品库存信息 |
|||
* @param l |
|||
*/ |
|||
private void addProdStock(InStorehouseListing l) { |
|||
ProdStock prodStock=new ProdStock(); |
|||
prodStock.setProName(l.getProName());// varchar 50 质物名称
|
|||
prodStock.setProModel(l.getProModel());// varchar 50 规格(型号)
|
|||
prodStock.setManufacturer(l.getManufacturer());// varchar 50 生成厂家(产地)
|
|||
prodStock.setNum(l.getNum());// varchar 10 数量
|
|||
prodStock.setWeight(l.getWeight());// varchar 50 重量
|
|||
prodStock.setConfirmedPrice(l.getConfirmedPrice());// decime 50 2 质权人确认的单价
|
|||
prodStock.setCalculatedValue(l.getCalculatedValue());// decime 50 2 核算的价值
|
|||
prodStock.setLocationNumber(l.getLocationNumber());// varchar 10 货位号
|
|||
prodStock.setCusterName(l.getCusterName());// varchar 50 客户名称(企业)
|
|||
prodStock.setProUnit(l.getProUnit());// varchar 50 规格单位
|
|||
prodStock.setCusterSid(l.getCusterSid());// varchar 64 客户Sid(企业)
|
|||
prodStock.setStoreHouseSid(l.getStoreHouseSid());// varchar 64 仓库Sid
|
|||
prodStock.setStoreHouseName(l.getStoreHouseName());// varchar 100 仓库名称
|
|||
prodStockService.insert(prodStock); |
|||
} |
|||
|
|||
/** |
|||
* 根据商品的名称 规格 客户查询库存信息 |
|||
* @param l |
|||
* @return |
|||
*/ |
|||
private PagerVo<ProdStock> getProdStock(InStorehouseListing l) { |
|||
PagerQuery<ProdStockQuery> pq=new PagerQuery<>(); |
|||
pq.setCurrent(0); |
|||
pq.setSize(10); |
|||
ProdStockQuery stockQuery = new ProdStockQuery(); |
|||
stockQuery.setCusterSid(l.getCusterSid()); |
|||
stockQuery.setProModel(l.getProModel()); |
|||
stockQuery.setProName(l.getProName()); |
|||
pq.setParams(stockQuery); |
|||
PagerVo<ProdStock> proStocks = prodStockService.getProStocks(pq); |
|||
return proStocks; |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.wh.service.api.outstorehouse; |
|||
|
|||
|
|||
import com.wh.mapper.api.instorehouse.InStorehouseMainMapper; |
|||
import com.wh.mapper.api.outstorehouse.OutStorehouseListingMapper; |
|||
import com.wh.mapper.api.outstorehouse.OutStorehouseMainMapper; |
|||
import com.wh.pojo.api.InStorehouseMain; |
|||
import com.wh.pojo.api.OutStorehouseListing; |
|||
import com.wh.pojo.api.OutStorehouseMain; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class OutStorehouseListingService extends MybatisBaseService<OutStorehouseListingMapper, OutStorehouseListing> { |
|||
|
|||
|
|||
} |
@ -0,0 +1,171 @@ |
|||
package com.wh.service.api.outstorehouse; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.wh.api.Api; |
|||
import com.wh.mapper.api.instorehouse.InStorehouseMainMapper; |
|||
import com.wh.mapper.api.outstorehouse.OutStorehouseMainMapper; |
|||
import com.wh.mapper.initial.LocationMapper; |
|||
import com.wh.mapper.initial.ProductMapper; |
|||
import com.wh.mapper.instorehouse.PurchaseMapper; |
|||
import com.wh.mapper.instorehouse.PutInMapper; |
|||
import com.wh.mapper.instorehouse.ReceivingMapper; |
|||
import com.wh.mapper.stock.StockMapper; |
|||
import com.wh.mapper.storehousemanage.RemoveMapper; |
|||
import com.wh.pojo.*; |
|||
import com.wh.pojo.api.*; |
|||
import com.wh.service.api.instorehouse.InStorehouseListingService; |
|||
import com.wh.service.api.prodstock.ProdStockService; |
|||
import com.wh.vo.PageResult; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
@Slf4j |
|||
@Service |
|||
public class OutStorehouseMainService extends MybatisBaseService<OutStorehouseMainMapper, OutStorehouseMain> { |
|||
@Autowired |
|||
private OutStorehouseListingService outStorehouseListingService; |
|||
@Autowired |
|||
private ProdStockService prodStockService; |
|||
@Transactional |
|||
public ResultBean addOutStorehouse(OutStorehouseMainDto outStorehouseMainDto) { |
|||
ResultBean<Object> r = ResultBean.fireFail(); |
|||
if(outStorehouseMainDto==null){ |
|||
return r.setMsg("数据不能为空"); |
|||
} |
|||
String no = outStorehouseMainDto.getNo(); |
|||
if(StringUtils.isBlank(no)){ |
|||
return r.setMsg("编码不能为空"); |
|||
} |
|||
List<OutStorehouseListing> list = outStorehouseMainDto.getList(); |
|||
if(list==null||list.size()==0){ |
|||
return r.setMsg("商品信息不能为空"); |
|||
} |
|||
|
|||
|
|||
QueryWrapper<OutStorehouseMain> queryWrapper = new QueryWrapper<>(); |
|||
queryWrapper.eq("no",outStorehouseMainDto.getNo()); |
|||
if(baseMapper.selectCount(queryWrapper) != 0){ |
|||
return r.setMsg("申请单编号已经存在"); |
|||
} |
|||
|
|||
OutStorehouseMain out=new OutStorehouseMain(); |
|||
BeanUtils.copyProperties(outStorehouseMainDto,out); |
|||
try{ |
|||
boolean b = validaProStock(list); |
|||
if(!b){ |
|||
return r.setMsg("出库数量大于库存数量"); |
|||
} |
|||
}catch (Exception e){ |
|||
return r.setMsg(e.getMessage()); |
|||
} |
|||
//申请单主表信息
|
|||
baseMapper.insert(out); |
|||
addListing(out, list); |
|||
return ResultBean.fireSuccess().setMsg("添加成功"); |
|||
} |
|||
/** |
|||
* 新增商品信息 |
|||
* @param out |
|||
* @param list |
|||
*/ |
|||
@Transactional |
|||
public void addListing(OutStorehouseMain out, List<OutStorehouseListing> list) throws RuntimeException{ |
|||
list.forEach(l->{ |
|||
l.setCusterSid(out.getCusterSid()); |
|||
l.setCusterName(out.getCusterName()); |
|||
l.setMainSid(out.getSid()); |
|||
outStorehouseListingService.insert(l); |
|||
saveOrUpdateProdStock(l); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 新增或者修改商品库存信息 |
|||
* @param l |
|||
*/ |
|||
private void saveOrUpdateProdStock(OutStorehouseListing l) { |
|||
PagerVo<ProdStock> proStocks = getProdStock(l); |
|||
long total = proStocks.getTotal(); |
|||
if(total==0){ |
|||
return; |
|||
}else{ |
|||
updateProdStock(l, proStocks); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 修改商品库存信息 |
|||
* @param l |
|||
* @param proStocks |
|||
*/ |
|||
private void updateProdStock(OutStorehouseListing l, PagerVo<ProdStock> proStocks) { |
|||
ResultBean<Object> r = ResultBean.fireFail(); |
|||
ProdStock prodStock = proStocks.getRecords().get(0); |
|||
String num = prodStock.getNum(); |
|||
if(com.yxt.common.base.utils.StringUtils.isBlank(num)){ |
|||
log.info("{}",l.getProName()+"商品数量不能为空"); |
|||
} |
|||
if(Integer.valueOf(l.getRealityNum())>Integer.valueOf(num)){ |
|||
return; |
|||
} |
|||
int i=Integer.valueOf(num)-Integer.valueOf(l.getRealityNum()); |
|||
prodStock.setNum(i+""); |
|||
prodStockService.updateById(prodStock); |
|||
} |
|||
|
|||
/** |
|||
* 验证库存信息 |
|||
* @param list |
|||
* @return |
|||
* @throws RuntimeException |
|||
*/ |
|||
private boolean validaProStock(List<OutStorehouseListing> list) throws RuntimeException{ |
|||
list.forEach(l->{ |
|||
PagerVo<ProdStock> prodStock = getProdStock(l); |
|||
long total = prodStock.getTotal(); |
|||
if(total==0){ |
|||
throw new RuntimeException(l.getProName()+"不存在库存"); // 抛出异常,事务回滚,
|
|||
} |
|||
ProdStock prodStock1 = prodStock.getRecords().get(0); |
|||
String num = prodStock1.getNum(); |
|||
int r=Integer.valueOf(num)-Integer.valueOf(l.getRealityNum()); |
|||
if(r<0){ |
|||
throw new RuntimeException(l.getProName()+"出库数量超出库存"); // 抛出异常,事务回滚,
|
|||
} |
|||
}); |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 根据商品的名称 规格 客户查询库存信息 |
|||
* @param l |
|||
* @return |
|||
*/ |
|||
private PagerVo<ProdStock> getProdStock(OutStorehouseListing l) { |
|||
PagerQuery<ProdStockQuery> pq=new PagerQuery<>(); |
|||
pq.setCurrent(0); |
|||
pq.setSize(10); |
|||
ProdStockQuery stockQuery = new ProdStockQuery(); |
|||
stockQuery.setCusterSid(l.getCusterSid()); |
|||
stockQuery.setProModel(l.getProModel()); |
|||
stockQuery.setProName(l.getProName()); |
|||
pq.setParams(stockQuery); |
|||
PagerVo<ProdStock> proStocks = prodStockService.getProStocks(pq); |
|||
return proStocks; |
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.wh.service.api.prodstock; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.wh.mapper.api.prodstock.ProdStockMapper; |
|||
import com.wh.pojo.api.*; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.PagerUtil; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.vo.PagerVo; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class ProdStockService extends MybatisBaseService<ProdStockMapper, ProdStock> { |
|||
|
|||
public PagerVo<ProdStock> getProStocks(PagerQuery<ProdStockQuery> pq ) { |
|||
ProdStockQuery params = pq.getParams(); |
|||
QueryWrapper<ProdStock> qw = createQueryWrapper(params); |
|||
IPage<ProdStock> page = PagerUtil.queryToPage(pq); |
|||
IPage<ProdStock> pagging = baseMapper.selectPage(page, qw); |
|||
PagerVo<ProdStock> p = PagerUtil.pageToVo(pagging, null); |
|||
Integer integer = baseMapper.selectCount(qw); |
|||
p.setTotal(integer); |
|||
return p; |
|||
} |
|||
|
|||
|
|||
private QueryWrapper<ProdStock> createQueryWrapper(ProdStockQuery query) { |
|||
// todo: 这里根据具体业务调整查询条件
|
|||
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|||
QueryWrapper<ProdStock> qw = new QueryWrapper<>(); |
|||
|
|||
if (StringUtils.isNotBlank(query.getCusterSid())) { |
|||
qw.eq("custer_sid", query.getCusterSid()); |
|||
} |
|||
if (StringUtils.isNotBlank(query.getProName())) { |
|||
qw.eq("pro_name", query.getProName()); |
|||
} |
|||
if (StringUtils.isNotBlank(query.getProModel())) { |
|||
qw.eq("pro_model", query.getProModel()); |
|||
} |
|||
return qw; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.yxt.supervise.cyf.api.appversion; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* Created with IntelliJ IDEA. |
|||
* |
|||
* @Auther: dimengzhe |
|||
* @Date: 2020/06/15/11:08 |
|||
* @Description: |
|||
*/ |
|||
@Data |
|||
@TableName("app_version") |
|||
public class AppVersion extends BaseEntity { |
|||
private static final long serialVersionUID = -1024009882612883351L; |
|||
|
|||
|
|||
private String appName;//应用名称
|
|||
private Integer versionCode;//版本编码
|
|||
private String versionName;//版本号
|
|||
private String downloadUrl;//下载地址
|
|||
private String versionInfo;//版本描述
|
|||
private Integer isAlpha;//是否内测:0否,1是
|
|||
private String fileName; |
|||
private boolean forceUpdate; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.yxt.supervise.cyf.api.appversion; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/5/19 9:55 |
|||
*/ |
|||
@Data |
|||
public class AppVersionDetailsVo implements Vo { |
|||
private String id; |
|||
private String appName;//应用名称
|
|||
private Integer versionCode;//版本编码
|
|||
private String versionName;//版本号
|
|||
private String downloadUrl;//下载地址
|
|||
private String versionInfo;//版本描述
|
|||
private Integer isAlpha;//是否内测:0否,1是
|
|||
private String fileName; |
|||
private boolean forceUpdate; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.yxt.supervise.cyf.api.appversion; |
|||
|
|||
import com.yxt.common.core.dto.Dto; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/5/19 9:55 |
|||
*/ |
|||
@Data |
|||
public class AppVersionDto implements Dto { |
|||
private String id; |
|||
private String appName;//应用名称
|
|||
private Integer versionCode;//版本编码
|
|||
private String versionName;//版本号
|
|||
private String downloadUrl;//下载地址
|
|||
private String versionInfo;//版本描述
|
|||
private Integer isAlpha;//是否内测:0否,1是
|
|||
private String fileName; |
|||
private boolean forceUpdate; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.yxt.supervise.cyf.api.appversion; |
|||
|
|||
import com.yxt.common.core.vo.Vo; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/5/19 9:55 |
|||
*/ |
|||
@Data |
|||
public class AppVersionVo implements Vo { |
|||
private String id; |
|||
private String appName;//应用名称
|
|||
private Integer versionCode;//版本编码
|
|||
private String versionName;//版本号
|
|||
private String downloadUrl;//下载地址
|
|||
private String versionInfo;//版本描述
|
|||
private Integer isAlpha;//是否内测:0否,1是
|
|||
private String fileName; |
|||
private boolean forceUpdate; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.yxt.supervise.cyf.app.appversion; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersion; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersionVo; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* Created with IntelliJ IDEA. |
|||
* |
|||
* @Auther: dimengzhe |
|||
* @Date: 2020/06/15/11:24 |
|||
* @Description: |
|||
*/ |
|||
@Mapper |
|||
public interface AppVersionMapper extends BaseMapper<AppVersion> { |
|||
|
|||
AppVersionVo getAll(); |
|||
|
|||
AppVersionVo selectAppVersion(); |
|||
} |
@ -0,0 +1,19 @@ |
|||
<?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.yxt.supervise.cyf.app.appversion.AppVersionMapper"> |
|||
|
|||
|
|||
<select id="getAll" resultType="com.yxt.supervise.cyf.api.appversion.AppVersionVo"> |
|||
select * from app_version where isAlpha=0 order by versionCode desc limit 1 |
|||
</select> |
|||
|
|||
|
|||
<select id="selectAppVersion" resultType="com.yxt.supervise.cyf.api.appversion.AppVersionVo"> |
|||
select * from app_version where isAlpha=1 order by versionCode desc limit 1 |
|||
|
|||
</select> |
|||
|
|||
|
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,249 @@ |
|||
package com.yxt.supervise.cyf.app.appversion; |
|||
|
|||
|
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersion; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersionDto; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersionVo; |
|||
import com.yxt.supervise.cyf.util.JsonUtils; |
|||
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.ResponseBody; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import javax.servlet.http.HttpSession; |
|||
import java.io.*; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Created with IntelliJ IDEA. |
|||
* |
|||
* @Auther: dimengzhe |
|||
* @Date: 2020/06/15/10:43 |
|||
* @Description: 更新apk |
|||
*/ |
|||
@Controller |
|||
@RequestMapping("cyf/appVersion") |
|||
public class AppVersionRest { |
|||
|
|||
private String uploadUrl = "http://www.yyundong.com:8083/api/appVersion/download"; |
|||
// private String uploadUrl = "http://26077a35f5.wicp.vip:43609/api/appVersion/download";
|
|||
|
|||
@Autowired |
|||
private AppVersionService appVersionService; |
|||
|
|||
public ResultBean save(AppVersionDto dto){ |
|||
//dto.setDownloadUrl();
|
|||
return appVersionService.save(dto); |
|||
} |
|||
|
|||
// 文件下载相关代码
|
|||
@RequestMapping("/download") |
|||
public Object downloadFile(HttpServletRequest request, HttpServletResponse response) |
|||
throws UnsupportedEncodingException { |
|||
String fileName = request.getParameter("fileName"); |
|||
if (fileName != null) { |
|||
// 设置文件路径
|
|||
String realPath = "D:/mallplus_project/upload/apks"; |
|||
File file = new File(realPath, fileName); |
|||
if (file.exists()) { |
|||
response.setContentType("application/octet-stream"); |
|||
response.addHeader("Content-Disposition", |
|||
"attachment;fileName=" + java.net.URLEncoder.encode(fileName, "UTF-8"));// 设置文件名
|
|||
byte[] buffer = new byte[1024];// 创建数据缓冲区
|
|||
FileInputStream fis = null;// 文件输入流
|
|||
BufferedInputStream bis = null; |
|||
OutputStream os = null; // 输出流
|
|||
byte[] bytes = null; |
|||
ByteArrayOutputStream baos = null; |
|||
try { |
|||
os = response.getOutputStream(); |
|||
fis = new FileInputStream(file); |
|||
bis = new BufferedInputStream(fis); |
|||
baos = new ByteArrayOutputStream(); |
|||
int len; |
|||
while ((len = fis.read(buffer)) != -1) { |
|||
baos.write(buffer, 0, len); |
|||
} |
|||
bytes = baos.toByteArray(); |
|||
response.setContentLength(bytes.length); |
|||
os.write(bytes, 0, bytes.length); |
|||
os.flush(); |
|||
System.out.println("success"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} finally { |
|||
if (bis != null) { |
|||
try { |
|||
bis.close(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
if (fis != null) { |
|||
try { |
|||
fis.close(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
// @RequestMapping(value = "/versioninfo1")
|
|||
// @ResponseBody
|
|||
// public Object appVersion1(HttpServletRequest request) {
|
|||
// Map<String, Object> map = new HashMap<String, Object>();
|
|||
// int versionCode = 1;// 版本编码
|
|||
// String defUrl = "";
|
|||
// String downloadUrl = "";// apk下载地址
|
|||
// String versionName = "";// 版本号
|
|||
// String versionInfo = "";// 版本的更新描述
|
|||
// String fileName = "";// apk名称
|
|||
// int isAlpha = 0;//是否内测,0否,1是
|
|||
// String userName = request.getParameter("userName");//会员账号
|
|||
// // 根据会员账号查询账号信息
|
|||
// UmsMember umsMember = iUmsMemberService.getByUsername(userName);
|
|||
// HttpSession session = request.getSession();
|
|||
// if (umsMember == null) {
|
|||
// // 查询版本记录未删除及为正式版的版本记录
|
|||
// AppVersion av = appVersionService.getAll();
|
|||
// if (null == av) {// 如果没有正式版的版本记录
|
|||
// defUrl = uploadUrl;
|
|||
// av = new AppVersion();
|
|||
// av.setVersionCode(1);
|
|||
// av.setDownloadUrl(defUrl);
|
|||
// versionCode = av.getVersionCode();
|
|||
// downloadUrl = defUrl;
|
|||
// isAlpha = 0;
|
|||
// } else {
|
|||
// versionCode = av.getVersionCode();// 版本编码
|
|||
// versionName = av.getVersionName();// 版本名称即版本号
|
|||
// fileName = av.getFileName();
|
|||
// session.setAttribute("fileName", fileName);
|
|||
// versionInfo = av.getVersionInfo();// 版本的更新描述
|
|||
// defUrl = av.getDownloadUrl();// apk下载地址
|
|||
// downloadUrl = uploadUrl+"?fileName=" + fileName;
|
|||
// isAlpha = av.getIsAlpha();// 是否为内测版本
|
|||
// }
|
|||
// } else {// 若member不为null,则版本可以分为内测人员和非内测人员
|
|||
// int isAlphaUser = umsMember.getIsAlphaUser();
|
|||
// if (isAlphaUser != 0) {//若人员是内测人员,则查询是否有内测版本
|
|||
// AppVersion av = appVersionService.selectAppVersion();// 内测版本
|
|||
// AppVersion av2 = appVersionService.getAll();// 正式版本
|
|||
// if (null == av) {// 若内测版本为null
|
|||
// defUrl = uploadUrl;
|
|||
// // defUrl默认地址需要改config配置文件
|
|||
// av = new AppVersion();
|
|||
// av.setVersionCode(2);
|
|||
// av.setDownloadUrl(defUrl);
|
|||
// versionCode = av.getVersionCode();
|
|||
// downloadUrl = defUrl;
|
|||
// isAlpha = 0;
|
|||
// } else {// 若有内测版本
|
|||
// if (av2 != null) {// 若有正式版本
|
|||
// if (av2.getVersionCode() > av.getVersionCode()) {// 若正式版本编码>内测版本的版本编码
|
|||
// versionCode = av2.getVersionCode();// 正式版本的编码
|
|||
// versionName = av2.getVersionName();
|
|||
// versionInfo = av2.getVersionInfo();
|
|||
// defUrl = av2.getDownloadUrl();
|
|||
// fileName = av.getFileName();
|
|||
// session.setAttribute("fileName", fileName);
|
|||
// downloadUrl = uploadUrl+"?fileName=" + fileName;
|
|||
// isAlpha = av2.getIsAlpha();
|
|||
// } else {
|
|||
// versionCode = av.getVersionCode();// 内测版本编码
|
|||
// versionName = av.getVersionName();// 版本号
|
|||
// versionInfo = av.getVersionInfo();// 版本的更新描述
|
|||
// defUrl = av.getDownloadUrl();// apk下载地址
|
|||
// fileName = av.getFileName();
|
|||
// session.setAttribute("fileName", fileName);
|
|||
// downloadUrl = uploadUrl+"?fileName=" + fileName;
|
|||
// isAlpha = av.getIsAlpha();
|
|||
// }
|
|||
// } else {
|
|||
// versionCode = av.getVersionCode();// 内测版本编码
|
|||
// versionName = av.getVersionName();// 版本号
|
|||
// versionInfo = av.getVersionInfo();// 版本的更新描述
|
|||
// defUrl = av.getDownloadUrl();// apk下载地址
|
|||
// fileName = av.getFileName();
|
|||
// session.setAttribute("fileName", fileName);
|
|||
// downloadUrl = uploadUrl+"?fileName=" + fileName;
|
|||
// isAlpha = av.getIsAlpha();
|
|||
// }
|
|||
// }
|
|||
// } else {// 如果不是内测人员
|
|||
// AppVersion av = appVersionService.getAll();// 正式版本倒序第一个
|
|||
// if (null == av) {//正式版本为null
|
|||
// defUrl = uploadUrl;
|
|||
// av = new AppVersion();
|
|||
// av.setVersionCode(1);// 将版本编码设置为2
|
|||
// av.setDownloadUrl(defUrl);// 将下载地址设置为默认地址
|
|||
// versionCode = av.getVersionCode();
|
|||
// downloadUrl = defUrl;
|
|||
// isAlpha = 0;
|
|||
// } else {
|
|||
// versionCode = av.getVersionCode();
|
|||
// versionName = av.getVersionName();
|
|||
// versionInfo = av.getVersionInfo();
|
|||
// defUrl = av.getDownloadUrl();
|
|||
// fileName = av.getFileName();
|
|||
// session.setAttribute("fileName", fileName);
|
|||
// downloadUrl = uploadUrl+"?fileName=" + fileName;
|
|||
// isAlpha = av.getIsAlpha();
|
|||
// }
|
|||
//
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// AppVersion appVersion = new AppVersion();
|
|||
// appVersion.setDownloadUrl(downloadUrl); //apk下载地址新
|
|||
// appVersion.setVersionCode(versionCode);//版本编码
|
|||
// appVersion.setVersionInfo(versionInfo);//版本的更新的描述
|
|||
// appVersion.setVersionName(versionName);//版本号
|
|||
// appVersion.setFileName(fileName);//应用名称
|
|||
// appVersion.setForceUpdate(false);
|
|||
// String appVersionNew = JsonUtils.objectToJson(appVersion);
|
|||
// return new ResultBean().success().setData(appVersionNew);
|
|||
// }
|
|||
|
|||
@RequestMapping(value = "/versioninfo") |
|||
@ResponseBody |
|||
public Object appVersion(HttpServletRequest request) { |
|||
Map<String, Object> map = new HashMap<String, Object>(); |
|||
int versionCode = 101;// 版本编码
|
|||
String versionName = "101";// 版本号
|
|||
String downloadUrl = "";// apk下载地址
|
|||
String versionInfo = "";// 版本的更新描述
|
|||
String fileName = "";// apk名称
|
|||
int isAlpha = 0;//是否内测,0否,1是
|
|||
|
|||
AppVersion appVersion = new AppVersion(); |
|||
appVersion.setVersionCode(versionCode);//版本编码
|
|||
appVersion.setVersionName(versionName);//版本号
|
|||
appVersion.setDownloadUrl(downloadUrl); //apk下载地址新
|
|||
appVersion.setVersionInfo(versionInfo);//版本的更新的描述
|
|||
appVersion.setFileName(fileName);//应用名称
|
|||
appVersion.setForceUpdate(false); |
|||
|
|||
// 查询版本记录未删除及为正式版的版本记录
|
|||
AppVersionVo av = appVersionService.getAll(); |
|||
if (null != av) {// 如果有正式版的版本记录
|
|||
appVersion.setVersionCode(av.getVersionCode());//版本编码
|
|||
appVersion.setVersionName(av.getVersionName());//版本号
|
|||
appVersion.setDownloadUrl(av.getDownloadUrl()); //apk下载地址新
|
|||
appVersion.setVersionInfo(av.getVersionInfo());//版本的更新的描述
|
|||
appVersion.setFileName(av.getFileName());//应用名称
|
|||
} |
|||
|
|||
String appVersionNew = JsonUtils.objectToJson(appVersion); |
|||
|
|||
return new ResultBean().success().setData(appVersionNew); |
|||
} |
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.yxt.supervise.cyf.app.appversion; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersion; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersionDto; |
|||
import com.yxt.supervise.cyf.api.appversion.AppVersionVo; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* Created with IntelliJ IDEA. |
|||
* |
|||
* @Auther: dimengzhe |
|||
* @Date: 2020/06/15/11:17 |
|||
* @Description: 版本更新 |
|||
*/ |
|||
@Service |
|||
public class AppVersionService extends MybatisBaseService<AppVersionMapper,AppVersion> { |
|||
|
|||
public ResultBean save(AppVersionDto dto){ |
|||
AppVersion entity=new AppVersion(); |
|||
BeanUtil.copyProperties(dto, entity); |
|||
return new ResultBean().success().setMsg("新增成功"); |
|||
}; |
|||
/** |
|||
* 查询apk版本中正式版本按版本编码倒叙排序 |
|||
* @return |
|||
*/ |
|||
public AppVersionVo getAll(){ |
|||
return baseMapper.getAll(); |
|||
}; |
|||
|
|||
public AppVersionVo selectAppVersion(){ |
|||
return baseMapper.selectAppVersion(); |
|||
} |
|||
} |
@ -0,0 +1,418 @@ |
|||
package com.yxt.supervise.cyf.util; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFilter; |
|||
import com.fasterxml.jackson.core.JsonParseException; |
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.*; |
|||
import com.fasterxml.jackson.databind.ser.FilterProvider; |
|||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; |
|||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; |
|||
import com.google.common.collect.Lists; |
|||
import com.google.common.collect.Maps; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import net.sf.json.JsonConfig; |
|||
import net.sf.json.util.PropertyFilter; |
|||
import org.springframework.core.annotation.AnnotationUtils; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.OutputStream; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* json对象映射工具类之jackson封装 |
|||
*/ |
|||
@Slf4j |
|||
public class JsonUtils { |
|||
|
|||
private static ObjectMapper objectMapper = null; |
|||
|
|||
static { |
|||
objectMapper = new ObjectMapper(); |
|||
// 设置默认日期格式
|
|||
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); |
|||
// 提供其它默认设置
|
|||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); |
|||
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); |
|||
objectMapper.setFilters(new SimpleFilterProvider() |
|||
.setFailOnUnknownId(false)); |
|||
objectMapper.registerModule(new MyModule()); |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式(默认将转换所有的属性) |
|||
* |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
public static String toJsonStr(Object value) { |
|||
try { |
|||
return objectMapper.writeValueAsString(value); |
|||
} catch (JsonProcessingException e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式 |
|||
* |
|||
* @param value 需要转换的对象 |
|||
* @param properties 需要转换的属性 |
|||
*/ |
|||
public static String toJsonStr(Object value, String[] properties) { |
|||
try { |
|||
SimpleBeanPropertyFilter sbp = SimpleBeanPropertyFilter |
|||
.filterOutAllExcept(properties); |
|||
FilterProvider filterProvider = new SimpleFilterProvider() |
|||
.addFilter("propertyFilterMixIn", sbp); |
|||
return objectMapper.writer(filterProvider) |
|||
.writeValueAsString(value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式 |
|||
* |
|||
* @param value 需要转换的对象 |
|||
* @param properties2Exclude 需要排除的属性 |
|||
*/ |
|||
public static String toJsonStrWithExcludeProperties(Object value, |
|||
String[] properties2Exclude) { |
|||
try { |
|||
SimpleBeanPropertyFilter sbp = SimpleBeanPropertyFilter |
|||
.serializeAllExcept(properties2Exclude); |
|||
FilterProvider filterProvider = new SimpleFilterProvider() |
|||
.addFilter("propertyFilterMixIn", sbp); |
|||
return objectMapper.writer(filterProvider) |
|||
.writeValueAsString(value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将对象json格式直接写出到流对象中(默认将转换所有的属性) |
|||
* |
|||
* @param out |
|||
* @return |
|||
*/ |
|||
public static void writeJsonStr(OutputStream out, Object value) { |
|||
try { |
|||
objectMapper.writeValue(out, value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将对象json格式直接写出到流对象中 |
|||
* |
|||
* @param value 需要转换的对象(注意,需要在要转换的对象中定义JsonFilter注解) |
|||
* @param properties 需要转换的属性 |
|||
*/ |
|||
public static void writeJsonStr(OutputStream out, Object value, |
|||
String[] properties) { |
|||
|
|||
try { |
|||
objectMapper.writer( |
|||
new SimpleFilterProvider().addFilter( |
|||
AnnotationUtils |
|||
.getValue( |
|||
AnnotationUtils.findAnnotation( |
|||
value.getClass(), |
|||
JsonFilter.class)) |
|||
.toString(), SimpleBeanPropertyFilter |
|||
.filterOutAllExcept(properties))) |
|||
.writeValue(out, value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串格式 |
|||
* |
|||
* @param value 需要转换的对象 |
|||
* @param properties2Exclude 需要排除的属性(注意,需要在要转换的对象中定义JsonFilter注解) |
|||
*/ |
|||
public static void writeJsonStrWithExcludeProperties(OutputStream out, |
|||
Object value, String[] properties2Exclude) { |
|||
try { |
|||
objectMapper.writer( |
|||
new SimpleFilterProvider().addFilter( |
|||
AnnotationUtils |
|||
.getValue( |
|||
AnnotationUtils.findAnnotation( |
|||
value.getClass(), |
|||
JsonFilter.class)) |
|||
.toString(), SimpleBeanPropertyFilter |
|||
.serializeAllExcept(properties2Exclude))) |
|||
.writeValue(out, value); |
|||
} catch (Exception e) { |
|||
log.error("Json转换失败", e); |
|||
throw new RuntimeException(e); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 反序列化POJO或简单Collection如List<String>. |
|||
* <p> |
|||
* 如果JSON字符串为Null或"null"字符串, 返回Null. 如果JSON字符串为"[]", 返回空集合. |
|||
* <p> |
|||
* 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String, JavaType) |
|||
*/ |
|||
public static <T> T fromJson(String jsonString, Class<T> clazz) { |
|||
if (StringUtils.isEmpty(jsonString)) { |
|||
return null; |
|||
} |
|||
|
|||
try { |
|||
return objectMapper.readValue(jsonString, clazz); |
|||
} catch (IOException e) { |
|||
log.warn("parse json string error:" + jsonString, e); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
@SuppressWarnings({"unchecked", "unused"}) |
|||
public static List<Object> readJsonList(String jsondata, Object object) { |
|||
try { |
|||
List<LinkedHashMap<String, Object>> list = objectMapper.readValue( |
|||
jsondata, List.class); |
|||
|
|||
List<Object> objects = Lists.newArrayList(); |
|||
System.out.println(list.size()); |
|||
for (int i = 0; i < list.size(); i++) { |
|||
Map<String, Object> map = list.get(i); |
|||
Set<String> set = map.keySet(); |
|||
for (Iterator<String> it = set.iterator(); it.hasNext(); ) { |
|||
String key = it.next(); |
|||
System.out.println(key + ":" + map.get(key)); |
|||
} |
|||
} |
|||
} catch (JsonParseException e) { |
|||
e.printStackTrace(); |
|||
} catch (JsonMappingException e) { |
|||
e.printStackTrace(); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 单独解析某一个json的key值 |
|||
* |
|||
* @param @param jsonText |
|||
* @param @param key |
|||
* @param @return 设定文件 |
|||
* @return JsonNode 返回类型 |
|||
* @throws |
|||
* @Title: getjsonvalue |
|||
* @Description: TODO(这里用一句话描述这个方法的作用) |
|||
*/ |
|||
public static JsonNode getjsonvalue(String jsonText, String key) { |
|||
|
|||
try { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JsonNode rootNode = mapper.readTree(jsonText); // 读取Json
|
|||
|
|||
return rootNode.path(key); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses); |
|||
} |
|||
|
|||
public static <T> List<T> json2list(String jsonArrayStr, Class<T> clazz) throws Exception { |
|||
List<Map<String, Object>> list = (List) objectMapper.readValue(jsonArrayStr, new TypeReference<List<T>>() { |
|||
}); |
|||
List<T> result = new ArrayList(); |
|||
Iterator var4 = list.iterator(); |
|||
|
|||
while (var4.hasNext()) { |
|||
Map<String, Object> map = (Map) var4.next(); |
|||
result.add(map2pojo(map, clazz)); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
public static <T> T map2pojo(Map map, Class<T> clazz) { |
|||
return objectMapper.convertValue(map, clazz); |
|||
} |
|||
|
|||
/** |
|||
* 解析json属性,放到实体里面去 |
|||
* |
|||
* @param @param jsondata |
|||
* @param @param collectionClass |
|||
* @param @return 设定文件 |
|||
* @return List<SpecVO> 返回类型 |
|||
* @throws |
|||
* @Title: readJsonList |
|||
* @Description: TODO(这里用一句话描述这个方法的作用) |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static List<Object> readJsonList(String jsondata, Class<?> collectionClass) { |
|||
try { |
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
JavaType javaType = getCollectionType(ArrayList.class, collectionClass); |
|||
List<Object> lst = (List<Object>) mapper.readValue(jsondata, javaType); |
|||
|
|||
return lst; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* json 转map |
|||
* |
|||
* @param @param jsondata |
|||
* @param @return 设定文件 |
|||
* @return Map<String, Map < String, Object>> 返回类型 |
|||
* @throws |
|||
* @Title: readJsonMap |
|||
* @Description: TODO(这里用一句话描述这个方法的作用) |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static Map<String, Object> readJsonToMap(String jsondata) { |
|||
try { |
|||
Map<String, Object> maps = objectMapper.readValue(jsondata, Map.class); |
|||
//System.out.println(maps);
|
|||
return maps; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
public static Map<String, Object> readJsonToMap1(String jsondata) { |
|||
try { |
|||
Map<String, Object> maps = objectMapper.readValue(jsondata, Map.class); |
|||
//System.out.println(maps);
|
|||
return maps; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 设置过滤值为空的属性,使得生成的 json 字符串只包含非空的值 |
|||
* |
|||
* @return |
|||
*/ |
|||
public static JsonConfig getJsonConfig() { |
|||
JsonConfig jsonConfig = new JsonConfig(); |
|||
jsonConfig.registerJsonValueProcessor(java.sql.Timestamp.class, new JsonValueProcessorImpl()); |
|||
jsonConfig.setJsonPropertyFilter(new PropertyFilter() { |
|||
@Override |
|||
public boolean apply(Object source, String name, Object value) { |
|||
return value == null; |
|||
} |
|||
}); |
|||
|
|||
jsonConfig.setIgnoreDefaultExcludes(false); // 设置默认忽略
|
|||
jsonConfig.setExcludes(new String[]{"dbName", "isDel"}); // 此处是亮点,只要将所需忽略字段加到数组中即可,在实际测试中,我发现在所返回数组中,存在大量无用属性,
|
|||
|
|||
return jsonConfig; |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串。 |
|||
*/ |
|||
public static String objectToJson(Object data) { |
|||
try { |
|||
String string = objectMapper.writeValueAsString(data); |
|||
return string; |
|||
} catch (JsonProcessingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 将json结果集转化为对象 |
|||
* |
|||
* @param jsonData json数据 |
|||
* @param beanType 对象中的object类型 |
|||
*/ |
|||
public static <T> T jsonToPojo(String jsonData, Class<T> beanType) { |
|||
try { |
|||
if (ValidatorUtils.notEmpty(jsonData)) { |
|||
T t = objectMapper.readValue(jsonData, beanType); |
|||
return t; |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 将json数据转换成pojo对象list |
|||
*/ |
|||
public static <T> List<T> jsonToList(String jsonData, Class<T> beanType) { |
|||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, beanType); |
|||
try { |
|||
List<T> list = objectMapper.readValue(jsonData, javaType); |
|||
return list; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
Map<String, Object> userData = Maps.newHashMap(); |
|||
Map<String, Object> nameStruct = Maps.newHashMap(); |
|||
nameStruct.put("firstName", "张三"); |
|||
nameStruct.put("lastName", "你大爷"); |
|||
|
|||
System.out.println(JsonUtils.toJsonStr(nameStruct)); |
|||
userData.put("name", nameStruct); |
|||
userData.put("age", 20); |
|||
List<String> stringList = Lists.newArrayList("A", "B", "C"); |
|||
System.out.println(JsonUtils.toJsonStr(userData)); |
|||
System.out.println(JsonUtils.toJsonStr(stringList)); |
|||
// String[] arr = {"37","38","41","42","43","44","45","1693","1694","1695","1696"};
|
|||
// System.out.println(toJsonStr(arr));
|
|||
|
|||
String ss = "{\"address\": \"address2\",\"name\":\"haha2\"}"; |
|||
|
|||
Map<String, Object> map = readJsonToMap(ss); |
|||
|
|||
if (map != null) { |
|||
System.out.println(map.get("address")); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
/** |
|||
* |
|||
*/ |
|||
package com.yxt.supervise.cyf.util; |
|||
|
|||
|
|||
import net.sf.json.JsonConfig; |
|||
import net.sf.json.processors.JsonValueProcessor; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* <p>Title: JsonValueProcessorImpl.java</p> |
|||
* <p>Description: net.js.json 特殊值处理</p> |
|||
* <p>Copyright: Copyright (c) 2014-2018</p> |
|||
* <p>Company: leimingtech.com</p> |
|||
* |
|||
* @author linjm |
|||
* @version 1.0 |
|||
* @date 2015年7月17日 |
|||
*/ |
|||
public class JsonValueProcessorImpl implements JsonValueProcessor { |
|||
|
|||
private String format = "yyyy-MM-dd HH:mm:ss"; |
|||
|
|||
@Override |
|||
public Object processArrayValue(Object value, JsonConfig jsonConfig) { |
|||
String[] obj = {}; |
|||
if (value instanceof Date[]) { |
|||
SimpleDateFormat sdf = new SimpleDateFormat(format); |
|||
Date[] date = (Date[]) value; |
|||
for (int i = 0; i < date.length; i++) { |
|||
obj[i] = sdf.format(date[i]); |
|||
} |
|||
} |
|||
return obj; |
|||
} |
|||
|
|||
@Override |
|||
public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) { |
|||
if (value instanceof Date) { |
|||
String str = new SimpleDateFormat(format).format(value); |
|||
return str; |
|||
} |
|||
return value.toString(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.yxt.supervise.cyf.util; |
|||
|
|||
import com.fasterxml.jackson.databind.module.SimpleModule; |
|||
|
|||
public class MyModule extends SimpleModule { |
|||
@Override |
|||
public void setupModule(SetupContext context) { |
|||
context.setMixInAnnotations(Object.class, PropertyFilterMixIn.class); |
|||
} |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.supervise.cyf.util; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFilter; |
|||
|
|||
@JsonFilter("propertyFilterMixIn") |
|||
public class PropertyFilterMixIn { |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.yxt.supervise.cyf.util; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class TimeSecound implements Serializable { |
|||
long days;//天
|
|||
long hours; //小时
|
|||
long mins; //分钟
|
|||
long sc; //秒
|
|||
|
|||
public TimeSecound() { |
|||
} |
|||
|
|||
public TimeSecound(long days, long hours, long mins, long sc) { |
|||
this.days = days; |
|||
this.hours = hours; |
|||
this.mins = mins; |
|||
this.sc = sc; |
|||
} |
|||
} |
@ -0,0 +1,200 @@ |
|||
package com.yxt.supervise.cyf.util; |
|||
|
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Collection; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
public class ValidatorUtils { |
|||
|
|||
/** |
|||
* 判断内容不为空 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean notEmpty(Object str) { |
|||
if (str != null && str.toString().trim().length() > 0) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 判断内容不为空(包含数组) |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static boolean notEmptyIncludeArray(Object str) { |
|||
if (str != null && String.valueOf(str).trim().length() > 0) { |
|||
if (str instanceof Object[]) {// 增加了数组长度判断
|
|||
Object[] array = (Object[]) str; |
|||
if (array.length > 0) |
|||
return true; |
|||
|
|||
return false; |
|||
} else if (str instanceof List<?>) {// 增加了数组长度判断
|
|||
List<Object> list = (List<Object>) str; |
|||
if (list.size() > 0) |
|||
return true; |
|||
|
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 判断内容是空 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean isEmpty(Object str) { |
|||
if (str == null || str.toString().trim().length() == 0) { |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 检查对象是否为空 |
|||
* |
|||
* @param obj 要检查的数据(数据类型: String、Number、Boolean、Collection、Map、Object[]) |
|||
* @return true: 为空; false: 不为空 <li>String:值为 null、""、"0" 时返回 true <li> |
|||
* Number:值为 null、0 时返回 true <li>Boolean:值为 null、false 时返回 true <li> |
|||
* Collection:值为 null、size=0 时返回 true <li>Map:值为 null、size=0 时返回 |
|||
* true <li>Object[]:值为 null、length=0 时返回 true |
|||
*/ |
|||
@SuppressWarnings("unchecked") |
|||
public static boolean empty(Object obj) { |
|||
if (obj == null) { |
|||
return true; |
|||
} else if (obj instanceof String && (obj.equals(""))) { |
|||
return true; |
|||
} else if (obj instanceof Number && ((Number) obj).doubleValue() == 0) { |
|||
return true; |
|||
} else if (obj instanceof Boolean && !((Boolean) obj)) { |
|||
return true; |
|||
} else if (obj instanceof Collection && ((Collection) obj).isEmpty()) { |
|||
return true; |
|||
} else if (obj instanceof Map && ((Map) obj).isEmpty()) { |
|||
return true; |
|||
} else if (obj instanceof Object[] && ((Object[]) obj).length == 0) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* 判断是否是合法邮箱地址 |
|||
* |
|||
* @param email |
|||
* @return |
|||
*/ |
|||
public static boolean isEmail(String email) { |
|||
Pattern p = Pattern |
|||
.compile("^\\w+([\\-+.]\\w+)*@\\w+([-.]\\w+)*\\.[a-z]{2,3}"); |
|||
Matcher m = p.matcher(email); |
|||
return m.matches(); |
|||
} |
|||
|
|||
/** |
|||
* 只包含英文字母和数字、下划线 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean onlyNumAndChar(String str) { |
|||
String regex = "^[a-zA-Z0-9_]+$"; |
|||
Pattern pattern = Pattern.compile(regex); |
|||
return pattern.matcher(str).matches(); |
|||
} |
|||
|
|||
/** |
|||
* 必须包含字母 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean hasLetterAndNum(String str) { |
|||
Pattern pattern = Pattern.compile("^(?=.*[a-zA-Z].*).{6,}$"); |
|||
return pattern.matcher(str).matches(); |
|||
} |
|||
|
|||
/** |
|||
* 是否长度符合 |
|||
* |
|||
* @param str |
|||
* @param min 最小 |
|||
* @param max 最大 |
|||
* @return |
|||
*/ |
|||
public static boolean lengthBetween(String str, int min, int max) { |
|||
return str.length() >= min && str.length() <= max; |
|||
} |
|||
|
|||
/** |
|||
* 判断字符串是否是数字 |
|||
* |
|||
* @param str |
|||
* @return |
|||
*/ |
|||
public static boolean isNumeric(String str) { |
|||
Pattern pattern = Pattern.compile("[0-9]*"); |
|||
Matcher isNum = pattern.matcher(str); |
|||
if (!isNum.matches()) { |
|||
return false; |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
public static Double rountTwo(Double num) { |
|||
if (num != null) { |
|||
BigDecimal b = new BigDecimal(num); |
|||
Double d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|||
return d; |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static String doubleTrans(double d) { |
|||
if (Math.round(d) - d == 0) { |
|||
return String.valueOf((long) d); |
|||
} |
|||
return String.valueOf(d); |
|||
} |
|||
|
|||
/** |
|||
* 获取结束时间与当前的时间差 |
|||
* |
|||
* @param endTime |
|||
* @return |
|||
*/ |
|||
public static TimeSecound getTimeSecound(Date endTime) { |
|||
|
|||
long diff = endTime.getTime() - System.currentTimeMillis();// 这样得到的差值是微秒级别
|
|||
|
|||
long days = diff / (1000 * 60 * 60 * 24);//天
|
|||
|
|||
long hours = (diff - days * (1000 * 60 * 60 * 24)) |
|||
/ (1000 * 60 * 60); //小时
|
|||
long mins = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60); //小时
|
|||
long sc = (diff - days * (1000 * 60 * 60 * 24) - hours |
|||
* (1000 * 60 * 60) - mins * (1000 * 60)) / (1000); // 秒
|
|||
|
|||
return new TimeSecound(days, hours, mins, sc); |
|||
} |
|||
} |
@ -0,0 +1,167 @@ |
|||
<template> |
|||
<div class="app-container"> |
|||
<div v-show="viewState ==1"> |
|||
<button-bar view-title="油罐信息" ref="btnbar" :btndisabled="btndisabled" @btnhandle="btnHandle" /> |
|||
<div class="main-content"> |
|||
<div class="listtop"> |
|||
<div class="tit">油罐列表</div> |
|||
</div> |
|||
<div > |
|||
<el-table ref="looktable" v-loading="listLoading" height="585" :data="list" border :summary-method="getSummaries" show-summary style="width: 100%;" > |
|||
<!-- <el-table-column type="selection" align="center" width="50"/> --> |
|||
<el-table-column label="序号" type="index" width="80" :index="indexMethod" align="center" /> |
|||
<el-table-column label="油罐编号" prop="number" align="center" /> |
|||
<el-table-column label="原油名称" prop="crudeName" align="center" /> |
|||
<el-table-column label="原油编号" prop="crudeNumber" align="center" /> |
|||
<el-table-column label="油罐容量" prop="capacity" align="center" /> |
|||
<el-table-column label="油罐库存(吨)" prop="inventory" align="center" /> |
|||
<el-table-column label="油罐现有库存(吨)" prop="existingInventory" align="center" /> |
|||
<el-table-column label="油罐总价值(元)" prop="totalValue" align="center" /> |
|||
</el-table> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import req from '@/api/oilTank/oilTank' |
|||
import pageye from '@/components/pagination/pageye' |
|||
import ButtonBar from '@/components/ButtonBar' |
|||
// import oilTypeInfo from './oilTypeInfo.vue' |
|||
export default { |
|||
name: 'CustomerManagement', |
|||
components: { |
|||
pageye, |
|||
ButtonBar |
|||
}, |
|||
data() { |
|||
return { |
|||
listLoading: false, |
|||
btndisabled: false, |
|||
editDialog: false, |
|||
form: {}, |
|||
btnList: [{ |
|||
type: 'info', |
|||
size: 'small', |
|||
icon: 'cross', |
|||
btnKey: 'doClose', |
|||
btnLabel: '关闭' |
|||
} |
|||
], |
|||
isSearchShow: false, |
|||
searchxianshitit: '显示查询条件', |
|||
list: [], |
|||
listQuery: { |
|||
current: 1, |
|||
size: 50, |
|||
params: { |
|||
entryName: '', |
|||
}, |
|||
total: 0 |
|||
}, |
|||
viewState: 1 |
|||
} |
|||
}, |
|||
mounted() { |
|||
this.$refs['btnbar'].setButtonList(this.btnList) |
|||
}, |
|||
created() { |
|||
this.init() |
|||
// 加载列表 |
|||
}, |
|||
methods: { |
|||
btnHandle(btnKey) { |
|||
switch (btnKey) { |
|||
case 'doClose': |
|||
this.doClose() |
|||
break |
|||
default: |
|||
break |
|||
} |
|||
}, |
|||
// 初始化 |
|||
init() { |
|||
this.getList() |
|||
}, |
|||
// 序号 |
|||
indexMethod(index) { |
|||
var pagestart = (this.listQuery.current - 1) * this.listQuery.size |
|||
var pageindex = index + 1 + pagestart |
|||
return pageindex |
|||
}, |
|||
// 查询列表信息 |
|||
getList() { |
|||
this.listLoading = true |
|||
req.selectTankInformation().then((response) => { |
|||
this.listLoading = false |
|||
if (response.success) { |
|||
this.list = response.data |
|||
this.$nextTick(() => {this.$refs.looktable.doLayout()}) // 初始化显示合计 |
|||
} else { |
|||
this.list = [] |
|||
} |
|||
}) |
|||
}, |
|||
// 打开添加 |
|||
toAdd() { |
|||
this.viewState = 2 |
|||
}, |
|||
reset() { |
|||
this.form = {}; |
|||
}, |
|||
resetState() { |
|||
this.viewState = 1 |
|||
}, |
|||
doClose() { |
|||
this.$store.dispatch('tagsView/delView', this.$route) |
|||
this.$router.go(-1) |
|||
}, |
|||
// 处理数据 |
|||
accAdd(arg1, arg2) { |
|||
var r1, r2, m; |
|||
try { |
|||
r1 = arg1.toString().split(".")[1].length; |
|||
} catch(e) { |
|||
r1 = 0; |
|||
} |
|||
try { |
|||
r2 = arg2.toString().split(".")[1].length; |
|||
}catch(e){ |
|||
r2 = 0; |
|||
} |
|||
//解决JS浮点数精度问题 |
|||
m = Math.pow(10, Math.max(r1, r2)); |
|||
//保留两位小数 |
|||
return parseFloat((arg1 * m + arg2 * m) / m).toFixed(2); |
|||
}, |
|||
getSummaries(param) { |
|||
const { columns, data } = param |
|||
const sums = [] |
|||
columns.forEach((column, index) => { |
|||
if (index === 0) { |
|||
sums[index] = '合计'; |
|||
return; |
|||
} |
|||
const values = data.map(item => Number(item[column.property])); |
|||
if (column.property === 'inventory' || column.property === 'existingInventory' || column.property === 'totalValue') { |
|||
sums[index] = values.reduce((prev, curr) => { |
|||
const value = Number(curr); |
|||
if (!isNaN(value)) { |
|||
return this.accAdd(prev,curr); |
|||
} else { |
|||
return prev; |
|||
} |
|||
}, 0); |
|||
sums[index]; |
|||
} |
|||
}); |
|||
|
|||
return sums |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped> |
|||
</style> |
Loading…
Reference in new issue