From f65443d8abeaedc9d102324565e8368e7c9d90c8 Mon Sep 17 00:00:00 2001 From: 郑永安 <zyazyz250@sina.com> Date: 星期一, 19 六月 2023 14:41:54 +0800 Subject: [PATCH] commit --- src/main/java/com/gk/firework/Domain/Vo/FireworkDeal.java | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 288 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/gk/firework/Domain/Vo/FireworkDeal.java b/src/main/java/com/gk/firework/Domain/Vo/FireworkDeal.java new file mode 100644 index 0000000..ccf3e3c --- /dev/null +++ b/src/main/java/com/gk/firework/Domain/Vo/FireworkDeal.java @@ -0,0 +1,288 @@ +package com.gk.firework.Domain.Vo; + +import com.gk.firework.Domain.SaleOrderInfo; +import com.gk.firework.Domain.UserInfo; +import com.gk.firework.Domain.Utils.BeanUtils; +import com.gk.firework.Domain.Utils.StringUtils; + +import java.math.BigDecimal; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +import static com.gk.firework.Domain.Vo.EntryUtils.RK_ENTRY; +import static com.gk.firework.Domain.Vo.EntryUtils.TH_ENTRY; + +/** + * @author : jingjy + * @date : 2021/3/19 8:48 + * 公共处理方法 + */ +public class FireworkDeal { + public static final int DIRECTION_ITEM = 10; + public static final int DIRECTION_INSIDE = 19; + public static final int DIRECTION_OUTSIDE = 22; + private static final String RETAIL_ORDER = "1"; + private static final String GROUP_ORDER = "2"; + private static final String NORMAL_DELIVERY = "1"; + public static final String OTHER_DELIVERY = "2"; + public static final String MODULE_ENTRY = "入库"; + public static final String MODULE_DELIVERY = "出库"; + private static final String MODULE_SALE = "销售"; + + + public static DirectionDetail dealDirectionCode(String direction){ + + DirectionDetail directionDetail = new DirectionDetail(); + + if (StringUtils.isBlank(direction)){ + return directionDetail; + } + int length = direction.length(); + if (length != DIRECTION_INSIDE && length != DIRECTION_OUTSIDE ){ + return directionDetail; + } + + directionDetail.setOriginalCode(direction); + directionDetail.setLength(length); + String itemCode = direction.substring(0,10); + String dateCode = direction.substring(10,14); + String serialNo = direction.substring(14,19); + if (length == DIRECTION_OUTSIDE){ + String boxNo = direction.substring(19,22); + directionDetail.setBoxNo(boxNo); + } + + directionDetail.setItemCode(itemCode); + directionDetail.setDateCode(dateCode); + directionDetail.setSerialNo(serialNo); + + return directionDetail; + } + + public static boolean is22Characters(String direction){ + return !StringUtils.isBlank(direction) && direction.length() == 22; + } + + public static boolean is19Characters(String direction){ + return !StringUtils.isBlank(direction) && direction.length() == 19; + } + + /** + * 判断字符串是否流向码 + * @param direction 流向码 + * @return true:不是流向码 + */ + public static boolean isNotDirectionCode(String direction){ + return !is19Characters(direction) && !is22Characters(direction); + } + + /** + * 通过22位流向码获取一批19位流向码 + * @param dire 流向码 + * @param detailFirst 首个流向码详情 + * @param detailLast 尾个流向码详情 + * @param productVos 获取的一批19位码详情 + * @param productVo 产品详情 + */ + public static void getProductVos(String dire, DirectionDetail detailFirst, DirectionDetail detailLast, List<ProductVo> productVos, ProductVo productVo) { + for (int i = Integer.parseInt(detailFirst.getSerialNo());i < Integer.parseInt(detailLast.getSerialNo())+Integer.parseInt(detailLast.getBoxNo());i++){ + ProductVo productVoCopy = BeanUtils.copy(productVo, ProductVo.class); + productVoCopy.setDirectionCode(dire.substring(0, 14) + String.format("%05d", i)); + productVos.add(productVoCopy); + } + } + + public static Map<String,List<ProductCodeVo>> getProductCodeVoList(ProductCodeVo productCodeVo) { + List<ProductCodeVo> productCodeVoList = new ArrayList<>(); + List<ProductCodeVo> printCodeVoList = new ArrayList<>(); + DirectionDetail detailDetail = dealDirectionCode(productCodeVo.getOriginalcode()); + for (int i = Integer.parseInt(detailDetail.getSerialNo());i < Integer.parseInt(detailDetail.getSerialNo())+Integer.parseInt(detailDetail.getBoxNo());i++){ + ProductCodeVo productVoCopy = BeanUtils.copy(productCodeVo, ProductCodeVo.class); + productVoCopy.setItemcode(productCodeVo.getOriginalcode().substring(0, 14) + String.format("%05d", i)); + productCodeVoList.add(productVoCopy); + } + + ProductCodeVo productVoCopy = new ProductCodeVo(); + printCodeVoList.addAll(productCodeVoList); + if (productCodeVoList.size() > 0 && productCodeVoList.size() % 2 == 0) { + //2个空行 + printCodeVoList.add(productVoCopy); + printCodeVoList.add(productVoCopy); + } else if (productCodeVoList.size() > 0 && productCodeVoList.size() % 2 == 1) { + //3个空行 + printCodeVoList.add(productVoCopy); + printCodeVoList.add(productVoCopy); + printCodeVoList.add(productVoCopy); + } + + productCodeVoList.add(productVoCopy); + + + HashMap<String,List<ProductCodeVo>> result = new HashMap<>(); + result.put("productCodeVoList", productCodeVoList); + result.put("printCodeVoList", printCodeVoList); + return result; + } + + public static List<ProductCodeVo> getBatchProductCodeList(ProductCodeVo productCodeVo,Integer needBlank) { + List<ProductCodeVo> productCodeVoList = new ArrayList<>(); + List<ProductCodeVo> printCodeVoList = new ArrayList<>(); + DirectionDetail detailDetail = dealDirectionCode(productCodeVo.getOriginalcode()); + for (int i = Integer.parseInt(detailDetail.getSerialNo());i < Integer.parseInt(detailDetail.getSerialNo())+Integer.parseInt(detailDetail.getBoxNo());i++){ + ProductCodeVo productVoCopy = BeanUtils.copy(productCodeVo, ProductCodeVo.class); + productVoCopy.setItemcode(productCodeVo.getOriginalcode().substring(0, 14) + String.format("%05d", i)); + productCodeVoList.add(productVoCopy); + } + + ProductCodeVo productVoCopy = new ProductCodeVo(); + printCodeVoList.addAll(productCodeVoList); + + if (productCodeVoList.size() > 0 && productCodeVoList.size() % 2 == 0 && needBlank == 1) { + //2个空行 + printCodeVoList.add(productVoCopy); + printCodeVoList.add(productVoCopy); + } else if (productCodeVoList.size() > 0 && productCodeVoList.size() % 2 == 1) { + //1个空行 + printCodeVoList.add(productVoCopy); + } + + productCodeVoList.add(productVoCopy); + + return printCodeVoList; + } + + public static void setProductVosAttribute(ProductVo productVo){ + if (productVo != null){ + DirectionDetail directionDetail = dealDirectionCode(productVo.getDirectionCode()); + productVo.setItemCode(directionDetail.getItemCode()); + productVo.setBoxNo(directionDetail.getBoxNo()); + productVo.setSerialNo(directionDetail.getSerialNo()); + productVo.setDateCode(directionDetail.getDateCode()); + } + } + + /** + * 生成OrderCode + */ + /*public static String generateOrderCode(String module, String type, Date date){ + DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + String orderCode = dateFormat.format(date); + orderCode += (int)(Math.random()*1000); + switch (module) { + case MODULE_ENTRY: + if (type.equals(RK_ENTRY)) { + orderCode = "RK-" + orderCode; + } else if (type.equals(TH_ENTRY)) { + orderCode = "TH-" + orderCode; + } + break; + case MODULE_DELIVERY: + if (type.equals(NORMAL_DELIVERY)) { + orderCode = "ND-" + orderCode; + } else { + orderCode = "OD-" + orderCode; + } + break; + case MODULE_SALE: + if (type.equals(RETAIL_ORDER)) { + orderCode = "RO-" + orderCode; + } else if (type.equals(GROUP_ORDER)) { + orderCode = "GO-" + orderCode; + } + break; + default: + } + + return orderCode; + }*/ + + /** + * 身份证中间数字加密 + * @param idCardNum 身份证号 + * @return 加密后的身份证号 + */ + public static String hideIdCardNum(String idCardNum){ + if (StringUtils.isBlank(idCardNum)){ + return idCardNum; + } + String begin = idCardNum.substring(0,6); + String end = idCardNum.substring(idCardNum.length()-6); + String mid = "******"; + return begin+mid+end; + } + + /** + * 根据单个含药量,返回一位编码 + * 0 x<1 + * 1 1≤x<2 + * 2 2≤x<3 + * 3 3≤x<4 + * 4 4≤x<5 + * 5 5≤x<6 + * 6 6≤x<7 + * 7 7≤x<8 + * 8 8≤x<9 + * 9 9≤x<10 + * A 10≤x<20 + * B 20≤x<30 + * C 30≤x<40 + * D 40≤x≤50 + * E 50<x<100 + * F 100≤x<200 + * G 200≤x<500 + * H 500≤x<1000 + * I 定义中不含I + * J 1000≤x≤1200 + * K 1200<x≤3000 + * L 3000<x≤8000 + */ + public static String getBitCode(float x){ + + String bitCode = ""; + if (x < 1){ + bitCode = "0"; + }else if (1<=x && x<2){ + bitCode = "1"; + }else if (x>=2 && x<3){ + bitCode = "2"; + }else if (x>=3 && x<4){ + bitCode = "3"; + }else if (x>=4 && x<5){ + bitCode = "4"; + }else if (x>=5 && x<6){ + bitCode = "5"; + }else if (x>=6 && x<7){ + bitCode = "6"; + }else if (x>=7 && x<8){ + bitCode = "7"; + }else if (x>=8 && x<9){ + bitCode = "8"; + }else if (x>=9 && x<10){ + bitCode = "9"; + }else if (x>=10 && x<20){ + bitCode = "A"; + }else if (x>=20 && x<30){ + bitCode = "B"; + }else if (x>=30 && x<40){ + bitCode = "C"; + }else if (x>=40 && x<=50){ + bitCode = "D"; + }else if (x>50 && x<100){ + bitCode = "E"; + }else if (x>=100 && x<200){ + bitCode = "F"; + }else if (x>=200 && x<500){ + bitCode = "G"; + }else if (x>=500 && x<1000){ + bitCode = "H"; + }else if (x>=1000 && x<=1200){ + bitCode = "J"; + }else if (x>1200 && x<=3000){ + bitCode = "K"; + }else if (x>3000 && x<=8000){ + bitCode = "L"; + } + return bitCode; + } +} -- Gitblit v1.9.2