parent
21b5784829
commit
4ed4a68608
|
|
@ -34,6 +34,8 @@ public class DateUtil {
|
|||
public static final DateTimeFormatter DFY_MD_HMS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
public static final DateTimeFormatter DFY_MD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/**
|
||||
* LocalDateTime 转时间戳
|
||||
*
|
||||
|
|
@ -44,6 +46,9 @@ public class DateUtil {
|
|||
return localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
|
||||
}
|
||||
|
||||
public static String getStrTime(Date date) {
|
||||
return sdfTime.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将Date对象转换为时间戳(毫秒)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
package cn.ysk.cashier.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
|
|
@ -70,84 +68,6 @@ public class JSONUtil {
|
|||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", false, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串。
|
||||
* 日期转为特别的格式,不忽略null值的字段,不格式化JSON字符串
|
||||
*
|
||||
* @param obj 被转换的对象
|
||||
* @return JSON字符串,发送异常时抛出
|
||||
*/
|
||||
public static String toJSONString(Object obj,boolean ignoreNull) {
|
||||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", ignoreNull, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为JSON字符串。不抛出异常,专用于日志打印
|
||||
*
|
||||
* @param obj 被转换的对象
|
||||
* @return JSON字符串,出异常时返回null
|
||||
*/
|
||||
public static String toJSONStringNoThrows(Object obj) {
|
||||
try {
|
||||
return toJSONString0(obj, "yyyy-MM-dd HH:mm:ss", false, true, false);
|
||||
} catch (Exception e) {
|
||||
logError(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析JSON字符串成为一个Object,结果可能是JSONArray(多个)或JSONObject(单个)
|
||||
* (该方法可用于对json字符串不知道是对象还是列表的时候之用)
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,显然转换成JSONEntity会有这个字段)
|
||||
*
|
||||
* @param jsonStr 要解析的JSON字符串
|
||||
* @return 返回JSONEntity,当jsonArrayFlag 为true,表示它是 JSONArray,否则是JSONObject
|
||||
*/
|
||||
public static JSONEntity parseJSONStr2JSONEntity(String jsonStr) {
|
||||
try {
|
||||
Object value = JSON.parse(jsonStr);
|
||||
boolean jsonArrayFlag = false;
|
||||
if (value instanceof JSONArray) {
|
||||
jsonArrayFlag = true;
|
||||
}
|
||||
return new JSONEntity(jsonArrayFlag, value);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转为JSON对象,注意数组类型会抛异常[{name:"Stone"}]
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,显然转换成JSONObject时会有这个字段,因为JSONObject就相当于map)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @return 返回转换结果。传入的JSON字串必须是对象而非数组,否则会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static JSONObject parseJSONStr2JSONObject(String jsonStr) {
|
||||
try {
|
||||
return (JSONObject) JSONObject.parse(jsonStr);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转为JSON数组,注意对象类型,非数组的会抛异常{name:"Stone"}
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,显然转换成JSONArray时,其元素会有这个字段,因为JSONArray的元素JSONObject就相当于map)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @return 返回转换结果。当传入的JSON字串是非数组形式时,会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static JSONArray parseJSONStr2JSONArray(String jsonStr) {
|
||||
try {
|
||||
return (JSONArray) JSONArray.parse(jsonStr);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转为某个类
|
||||
|
|
@ -166,14 +86,6 @@ public class JSONUtil {
|
|||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
public static <T> T jsonStrToObject(String jsonStr, Class<T> clazz) {
|
||||
Object obj = JSONArray.parseObject(jsonStr, clazz);
|
||||
return (T) obj;
|
||||
}
|
||||
|
||||
public static <T> T jsonstrtoObject(String str,TypeReference<T> tTypeReference ){
|
||||
return JSON.parseObject(str, tTypeReference);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String sss = "{\"bizData\":{\"amount\":1,\"currency\":\"cny\",\"ifCode\":\"sxfpay\",\"mchOrderNo\":\"CZ1715744291232\",\"mercNo\":\"B240510702030\",\"note\":\"等待用户付款\",\"payOrderId\":\"O1790587460614225921\",\"payType\":\"WECHAT\",\"settlementType\":\"D1\",\"state\":\"TRADE_AWAIT\",\"storeId\":\"S2405103298\",\"subject\":\"测试支付\",\"tradeFee\":0},\"code\":\"000000\",\"msg\":\"请求成功\",\"sign\":\"40710a3c293eeac3c7f4a1b0696a2bf6\",\"signType\":\"MD5\",\"timestamp\":\"20240515113813\"}";
|
||||
|
|
@ -181,56 +93,6 @@ public class JSONUtil {
|
|||
// PublicResp<MainScanResp> response = JSON.parseObject(sss, typeRef);
|
||||
System.out.println("pm");
|
||||
}
|
||||
/**
|
||||
* 字符串转为某个类的列表
|
||||
* (日期字段不管是时间戳形式还是yyyy-MM-dd HH:mm:ss的形式都能成功转换)
|
||||
* (假设json字符串多了某个字段,可能是新加上去的,T类没有,转换成T对象的时候,不会抛出异常)
|
||||
*
|
||||
* @param jsonStr 传入的JSON字串
|
||||
* @param clazz List里装的元素的类型
|
||||
* @return 返回转换结果。当传入的JSON字串是非数组的形式时会抛出异常
|
||||
* @author Stone
|
||||
*/
|
||||
public static <T> List<T> parseJSONStr2TList(String jsonStr, Class<T> clazz) {
|
||||
try {
|
||||
return JSONObject.parseArray(jsonStr, clazz);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid jsonStr,parse error:" + jsonStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class JSONEntity {
|
||||
public JSONEntity() {
|
||||
}
|
||||
|
||||
public JSONEntity(boolean jsonArrayFlag, Object value) {
|
||||
this.jsonArrayFlag = jsonArrayFlag;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private boolean jsonArrayFlag;
|
||||
private Object value;
|
||||
|
||||
public boolean getJsonArrayFlag() {
|
||||
return jsonArrayFlag;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JSONEntity{" +
|
||||
"jsonArrayFlag=" + jsonArrayFlag +
|
||||
", value=" + value +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
private static void logError(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,3 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.controller.product;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
|
|
@ -37,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/product/StockOperate管理")
|
||||
@Api(tags = "出入库操作记录管理")
|
||||
@RequestMapping("/api/tbProductStockOperate")
|
||||
public class TbProductStockOperateController {
|
||||
|
||||
|
|
@ -45,7 +30,6 @@ public class TbProductStockOperateController {
|
|||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbProductStockOperate:list')")
|
||||
public void exportTbProductStockOperate(HttpServletResponse response, TbProductStockOperateQueryCriteria criteria) throws IOException {
|
||||
tbProductStockOperateService.download(tbProductStockOperateService.queryAll(criteria), response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class OutAndOnDto {
|
|||
@NonNull
|
||||
private String shopId;
|
||||
|
||||
private String isImport;
|
||||
private String isImport="";
|
||||
|
||||
|
||||
public String getBatchNumber() {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
|||
"LEFT JOIN TbShopUnit unit ON pro.unitId = unit.id " +
|
||||
"WHERE " +
|
||||
"pro.shopId = :shopId " +
|
||||
"AND pro.status = 1 " +
|
||||
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
|
||||
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
|
||||
"ORDER BY " +
|
||||
|
|
|
|||
|
|
@ -1,18 +1,3 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.pojo.BotConfig;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,3 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.pojo.product.TbProductStockOperate;
|
||||
|
|
@ -46,7 +31,7 @@ public interface TbProductStockOperateService {
|
|||
* @param criteria 条件参数
|
||||
* @return List<TbProductStockOperateDto>
|
||||
*/
|
||||
List<TbProductStockOperateDto> queryAll(TbProductStockOperateQueryCriteria criteria);
|
||||
List<TbProductStockOperate> queryAll(TbProductStockOperateQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 作废
|
||||
|
|
@ -88,5 +73,5 @@ public interface TbProductStockOperateService {
|
|||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbProductStockOperateDto> all, HttpServletResponse response) throws IOException;
|
||||
void download(List<TbProductStockOperate> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.service.impl.productimpl;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyor;
|
||||
import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
|
@ -84,8 +85,8 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TbProductStockOperateDto> queryAll(TbProductStockOperateQueryCriteria criteria){
|
||||
return tbProductStockOperateMapper.toDto(tbProductStockOperateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
public List<TbProductStockOperate> queryAll(TbProductStockOperateQueryCriteria criteria){
|
||||
return tbProductStockOperateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -160,11 +161,20 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
|||
stockOperate.setCreatedAt(times);
|
||||
stockOperate.setUpdatedAt(times);
|
||||
stockOperate.setStatus("normal");
|
||||
stockOperate.setPurveyorId(resources.getPurveyorId());
|
||||
stockOperate.setPurveyorName(resources.getPurveyorName());
|
||||
TbProductStockOperate saveStockOperate = tbProductStockOperateRepository.save(stockOperate);
|
||||
if (StringUtils.isNotBlank(resources.getIsImport()) && resources.getIsImport().equals("true")) {
|
||||
if (!resources.getIsImport().equals("true")) {
|
||||
//供应商退货 reject
|
||||
//供应商入库 purveyor
|
||||
if ("reject".equals(resources.getType()) || "purveyor".equals(resources.getType())) {
|
||||
if(StringUtils.isNotBlank(resources.getPurveyorId())){
|
||||
Optional<TbShopPurveyor> byId1 = purveyorRepository.findById(Integer.valueOf(resources.getPurveyorId()));
|
||||
if(byId1.isPresent()){
|
||||
TbShopPurveyor tbShopPurveyor = byId1.get();
|
||||
resources.setPurveyorName(tbShopPurveyor.getPurveyorName());
|
||||
}
|
||||
}
|
||||
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
|
||||
purveyorTransact.setShopId(resources.getShopId());
|
||||
purveyorTransact.setPurveyorName(resources.getPurveyorName());
|
||||
|
|
@ -265,24 +275,38 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbProductStockOperateDto> all, HttpServletResponse response) throws IOException {
|
||||
public void download(List<TbProductStockOperate> all, HttpServletResponse response) throws IOException {
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbProductStockOperateDto tbProductStockOperate : all) {
|
||||
for (TbProductStockOperate stockOperate :all) {
|
||||
ProductStockOperateVO stockOperateVO = new ProductStockOperateVO();
|
||||
BeanUtils.copyProperties(stockOperate,stockOperateVO);
|
||||
stockOperateVO.setType();
|
||||
stockOperateVO.setStockSnap(ListUtil.stringChangeList(stockOperate.getStockSnap()));
|
||||
stockOperateVO.setOperatorSnap(StringUtils.stringChangeMap(stockOperate.getOperatorSnap()));
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("店铺Id", tbProductStockOperate.getShopId());
|
||||
map.put("操作镜像", tbProductStockOperate.getStockSnap());
|
||||
map.put(" type", tbProductStockOperate.getType());
|
||||
map.put(" subType", tbProductStockOperate.getSubType());
|
||||
map.put("批次", tbProductStockOperate.getBatchNumber());
|
||||
map.put(" remark", tbProductStockOperate.getRemark());
|
||||
map.put("操作时间", tbProductStockOperate.getStockTime());
|
||||
map.put("操作人", tbProductStockOperate.getOperatorSnap());
|
||||
map.put(" createdAt", tbProductStockOperate.getCreatedAt());
|
||||
map.put(" updatedAt", tbProductStockOperate.getUpdatedAt());
|
||||
map.put("供应商Id", tbProductStockOperate.getPurveyorId());
|
||||
map.put("供应商名称", tbProductStockOperate.getPurveyorName());
|
||||
map.put("nullify作废normal正常", tbProductStockOperate.getStatus());
|
||||
list.add(map);
|
||||
for (int i = 0; i < stockOperateVO.getStockSnap().size(); i++) {
|
||||
if(i==0){
|
||||
map.put("操作类型 ", stockOperateVO.getType());
|
||||
map.put("供应商名称", stockOperateVO.getPurveyorName());
|
||||
map.put("商品数量 ", stockOperateVO.getStockSnap().size());
|
||||
map.put(" 备 注 ", stockOperateVO.getRemark());
|
||||
map.put("操作人 ", stockOperateVO.getOperatorSnap().get("account"));
|
||||
map.put("创建时间", DateUtil.getStrTime(new Date(stockOperateVO.getStockTime())));
|
||||
}else {
|
||||
map.put("操作类型 ", "");
|
||||
map.put("供应商名称", "");
|
||||
map.put("商品数量 ", "");
|
||||
map.put(" 备 注 ", "");
|
||||
map.put("操 作 人", "");
|
||||
map.put("创建时间", "");
|
||||
}
|
||||
JSONObject jsonObject = stockOperateVO.getStockSnap().getJSONObject(0);
|
||||
map.put("商品名称", jsonObject.getString("name"));
|
||||
map.put("商品规格", jsonObject.getString("specSnap"));
|
||||
map.put("变动数量", jsonObject.getString("number"));
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ public class StockVo {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"\"name\":\"" + name + "\""+
|
||||
"\"unitName\":\"" + unitName +"\""+
|
||||
"\"specSnap\":\"" + specSnap + "\"" +
|
||||
"\"name\":\"" + name + "\","+
|
||||
"\"unitName\":\"" + unitName +"\","+
|
||||
"\"specSnap\":\"" + specSnap + "\"," +
|
||||
"\"number\":\"" + number + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue