package com.gk.firework.Service.ServiceImpl;
|
import com.gk.firework.Domain.ContractFile;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gk.firework.Domain.*;
|
import com.gk.firework.Domain.Enum.EnterpriseSafetySupervision;
|
import com.gk.firework.Domain.Exception.BusinessException;
|
import com.gk.firework.Domain.Utils.PageInfo;
|
import com.gk.firework.Domain.Utils.Properties;
|
import com.gk.firework.Domain.Utils.StringUtils;
|
import com.gk.firework.Domain.Utils.UploadUtil;
|
import com.gk.firework.Domain.Vo.*;
|
import com.gk.firework.Mapper.ContractDetailInfoMapper;
|
import com.gk.firework.Mapper.ContractOrderInfoMapper;
|
import com.gk.firework.Service.*;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.io.ByteArrayInputStream;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
@Service("ContractOrderService")
|
public class ContractOrderServiceImpl extends ServiceImpl<ContractOrderInfoMapper, ContractOrderInfo> implements ContractOrderService {
|
@Autowired
|
ContractOrderInfoMapper contractOrderInfoMapper;
|
@Autowired
|
ContractDetailInfoMapper contractDetailInfoMapper;
|
@Autowired
|
ContractFileService contractFileService;
|
@Autowired
|
ContractDetailService contractDetailService;
|
@Autowired
|
ContractLogService contractLogService;
|
@Autowired
|
UserService userService;
|
@Autowired
|
EnterpriseService enterpriseService;
|
@Autowired
|
ProductCodeService productCodeService;
|
@Autowired
|
ProductLocusService productLocusService;
|
@Autowired
|
ProductService productService;
|
@Autowired
|
ExcelExportService excelExportService;
|
@Autowired
|
ControlPrintParamService controlPrintParamService;
|
|
@Override
|
public void selectDataGrid(PageInfo pageInfo) {
|
Page<ContractOrderVo> page = new Page<>(pageInfo.getPageIndex(), pageInfo.getPageSize());
|
List<OrderItem> orderItems = new ArrayList<>();
|
OrderItem orderItem = new OrderItem();
|
if (StringUtils.isNotBlank(pageInfo.getSort()) && StringUtils.isNotBlank(pageInfo.getOrder())) {
|
orderItem.setAsc(pageInfo.getOrder().equalsIgnoreCase("ascending"));
|
orderItem.setColumn(pageInfo.getSort());
|
}else {
|
orderItem.setAsc(false);
|
orderItem.setColumn("createddate");
|
}
|
orderItems.add(orderItem);
|
page.setOrders(orderItems);
|
List<ContractOrderVo> list = contractOrderInfoMapper.selectDataGrid(page,pageInfo.getCondition());
|
for (ContractOrderVo contractOrderVo : list) {
|
List<ProductVo> productVoList = contractDetailInfoMapper.selectByOrder(contractOrderVo.getOrdercode());
|
ContractFile contractFile = contractFileService.selectByOrderCode(contractOrderVo.getOrdercode());
|
contractOrderVo.setProductInfoList(productVoList);
|
contractOrderVo.setContractFile(contractFile);
|
}
|
pageInfo.setResult(list);
|
pageInfo.setTotalCount(page.getTotal());
|
}
|
|
@Override
|
public List<ContractOrderInfo> selectByStatus(String status, String now) {
|
return contractOrderInfoMapper.selectByStatus(status,now);
|
}
|
|
@Override
|
public ContractOrderInfo selectByOrderCode(String ordercode) {
|
return contractOrderInfoMapper.selectByOrderCode(ordercode);
|
}
|
|
@Override
|
@Transactional
|
public void addApply(ContractOrderVo contractOrderVo, UserInfo user) {
|
|
|
UserInfo userInfo = userService.getById(user.getId());
|
if (StringUtils.isBlank(userInfo.getCompanynumber())) {
|
throw new BusinessException("没有权限新增");
|
}
|
Enterprise enterprise = enterpriseService.selectEnterpriseByNumber(userInfo.getCompanynumber());
|
assert enterprise.getSafetysupervision() != null;
|
if (enterprise.getSafetysupervision().equals(EnterpriseSafetySupervision.PRODUCE.getMsg())) {
|
throw new BusinessException("生产企业不可以申请合同");
|
}
|
//单号
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
String ordercode = "CT"+sdf.format(new Date());
|
String operator = user.getUsername();
|
//规律的单号
|
String regularCode = this.generateRegularCode();
|
|
|
JSONArray jsonArray = JSONArray.parseArray(contractOrderVo.getProductList());
|
List<ContractDetailInfo> contractDetails = jsonArray.toJavaList(ContractDetailInfo.class);
|
if (contractDetails.size() <1) throw new BusinessException("产品不能为空");
|
//上传附件
|
MultipartFile file = contractOrderVo.getFile();
|
if (file != null ) {
|
try {
|
ContractFile attachment = new ContractFile();
|
String name = UploadUtil.uploadFile(file, Properties.contractPath);
|
attachment.setValidflag(true);
|
attachment.setOrdercode(ordercode);
|
attachment.setFilename(file.getOriginalFilename());
|
attachment.setUrl(Properties.contract + name);
|
attachment.setCreateby(user.getId());
|
attachment.setCreatebyname(user.getUsername());
|
attachment.setCreatetime(new Date());
|
contractFileService.save(attachment);
|
} catch (Exception e) {
|
e.printStackTrace();
|
throw new BusinessException("上传文件失败");
|
}
|
}
|
//甲方单位编号
|
contractOrderVo.setPurchaseenterprisenumber(userInfo.getCompanynumber());
|
contractOrderVo.setRegularcode(regularCode);
|
contractOrderVo.setOrdercode(ordercode);
|
contractOrderVo.setStatus(ContractStatus.WAIT_SUBMIT);
|
contractOrderVo.setOperator(operator);
|
contractOrderVo.setCreatedby(operator);
|
contractOrderVo.setCreateddate(new Date());
|
contractOrderVo.setModifiedby(operator);
|
contractOrderVo.setModifieddate(new Date());
|
contractOrderVo.setIsdel((byte)0);
|
contractOrderVo.setManufacturer(contractOrderVo.getSupplyunitname());
|
this.save(contractOrderVo);
|
|
if (contractDetails.size() > 0) {
|
for (ContractDetailInfo contractDetail : contractDetails) {
|
ProductInfo productInfo = productService.selectByDirection(contractDetail.getDirectioncode());
|
if (productInfo == null) {
|
throw new BusinessException(String.format("产品不存在,流向码:%s", contractDetail.getName()));
|
}
|
if (contractDetail.getNum() == null) {
|
throw new BusinessException(String.format("请输入%s"+"的产品数量",contractDetail.getName()));
|
}
|
if (contractDetail.getPrice() == null) {
|
throw new BusinessException(String.format("请输入%s"+"的进货单价",contractDetail.getName()));
|
}
|
contractDetail.setOrdercode(ordercode);
|
contractDetailService.save(contractDetail);
|
}
|
}
|
ContractLogInfo contractLogInfo = new ContractLogInfo();
|
contractLogInfo.setOptlog("新增合同");
|
contractLogInfo.setOperator(operator);
|
contractLogInfo.setOrdercode(ordercode);
|
contractLogInfo.setOperatordate(new Date());
|
contractLogService.save(contractLogInfo);
|
}
|
|
@Override
|
@Transactional
|
public void putApply(ContractOrderVo contractOrderVo, UserInfo user) {
|
|
UserInfo userInfo = userService.getById(user.getId());
|
if (StringUtils.isBlank(userInfo.getCompanynumber())) {
|
throw new BusinessException("没有权限修改");
|
}
|
String operator = user.getUsername();
|
JSONArray jsonArray = JSONArray.parseArray(contractOrderVo.getProductList());
|
List<ContractDetailInfo> contractDetails = jsonArray.toJavaList(ContractDetailInfo.class);
|
if (contractDetails.size() <1) throw new BusinessException("产品不能为空");
|
|
ContractOrderInfo contractOrderInfo = this.getById(contractOrderVo.getId());
|
if (!contractOrderInfo.getStatus().equals(ContractStatus.WAIT_SUBMIT) &&
|
!contractOrderInfo.getStatus().equals(ContractStatus.Refuse_Product)){
|
throw new BusinessException("合同状态不为待提交、拒绝生产,无法修改");
|
}
|
//上传附件
|
MultipartFile file = contractOrderVo.getFile();
|
if (file != null ) {
|
try {
|
contractFileService.deleteAll(contractOrderVo.getOrdercode());
|
ContractFile attachment = new ContractFile();
|
String name = UploadUtil.uploadFile(file, Properties.contractPath);
|
attachment.setValidflag(true);
|
attachment.setOrdercode(contractOrderVo.getOrdercode());
|
attachment.setFilename(file.getOriginalFilename());
|
attachment.setUrl(Properties.contract + name);
|
attachment.setCreateby(user.getId());
|
attachment.setCreatebyname(user.getUsername());
|
attachment.setCreatetime(new Date());
|
contractFileService.save(attachment);
|
} catch (Exception e) {
|
e.printStackTrace();
|
throw new BusinessException("上传文件失败");
|
}
|
}
|
|
contractOrderVo.setManufacturer(contractOrderVo.getSupplyunitname());
|
this.updateById(contractOrderVo);
|
|
if (contractDetails != null && contractDetails.size() > 0) {
|
contractDetailService.deleteByOrder(contractOrderInfo.getOrdercode());
|
for (ContractDetailInfo contractDetail : contractDetails) {
|
if (contractDetail.getNum() == null) {
|
throw new BusinessException(String.format("请输入%s"+"的产品数量",contractDetail.getName()));
|
}
|
if (contractDetail.getPrice() == null) {
|
throw new BusinessException(String.format("请输入%s"+"的进货单价",contractDetail.getName()));
|
}
|
contractDetail.setOrdercode(contractOrderVo.getOrdercode());
|
contractDetailService.save(contractDetail);
|
}
|
}
|
|
ContractLogInfo contractLogInfo = new ContractLogInfo();
|
contractLogInfo.setOptlog("修改合同");
|
contractLogInfo.setOperator(operator);
|
contractLogInfo.setOrdercode(contractOrderInfo.getOrdercode());
|
contractLogInfo.setOperatordate(new Date());
|
contractLogService.save(contractLogInfo);
|
|
}
|
|
@Override
|
@Transactional
|
public void confirmProduct(ContractOrderVo contractOrderVo, UserInfo user) {
|
|
String operator = user.getUsername();
|
ContractOrderInfo contractOrderInfo = this.getById(contractOrderVo.getId());
|
//上传附件
|
MultipartFile file = contractOrderVo.getFile();
|
if (file != null ) {
|
try {
|
ContractFile attachment = new ContractFile();
|
String name = UploadUtil.uploadFile(file, Properties.contractPath);
|
attachment.setValidflag(true);
|
attachment.setFilename(file.getOriginalFilename());
|
attachment.setUrl(Properties.contract + name);
|
attachment.setCreateby(user.getId());
|
attachment.setCreatebyname(user.getUsername());
|
attachment.setCreatetime(new Date());
|
contractFileService.save(attachment);
|
} catch (Exception e) {
|
e.printStackTrace();
|
throw new BusinessException("上传文件失败");
|
}
|
}
|
|
if (!contractOrderInfo.getStatus().equals(ContractStatus.WAIT_CONFIRM)) {
|
throw new BusinessException("合同状态不为待确认,无法确认生产");
|
}
|
|
contractOrderInfo.setStatus(ContractStatus.Confirm_Product);
|
contractOrderInfo.setModifiedby(operator);
|
contractOrderInfo.setModifieddate(new Date());
|
contractOrderInfo.setReturnstatus("未退回");
|
contractOrderInfo.setSupplyunitaddress(contractOrderVo.getSupplyunitaddress());
|
contractOrderInfo.setSupplyrepresentative(contractOrderVo.getSupplyrepresentative());
|
contractOrderInfo.setSupplyrepresentativephone(contractOrderVo.getSupplyrepresentativephone());
|
contractOrderInfo.setSupplybank(contractOrderVo.getSupplybank());
|
contractOrderInfo.setSupplylicensenumber(contractOrderVo.getSupplylicensenumber());
|
contractOrderInfo.setSupplyzipcode(contractOrderVo.getSupplyzipcode());
|
contractOrderInfo.setSupplyagent(contractOrderVo.getSupplyagent());
|
contractOrderInfo.setSupplyagentphone(contractOrderVo.getSupplyagentphone());
|
contractOrderInfo.setSupplyagentemail(contractOrderVo.getSupplyagentemail());
|
contractOrderInfo.setSupplyaccount(contractOrderVo.getSupplyaccount());
|
this.updateById(contractOrderInfo);
|
|
ContractLogInfo contractLogInfo = new ContractLogInfo();
|
contractLogInfo.setOptlog("确认合同");
|
contractLogInfo.setOperator(operator);
|
contractLogInfo.setOrdercode(contractOrderInfo.getOrdercode());
|
contractLogInfo.setOperatordate(new Date());
|
contractLogService.save(contractLogInfo);
|
}
|
|
/**
|
* @Description: 申请校验
|
* @date 2021/5/11 13:55
|
*/
|
@Override
|
public void checkAdd(ContractOrderVo contractOrderVo) {
|
if (StringUtils.isBlank(contractOrderVo.getSignlocation())) {
|
throw new BusinessException("签订地点不能为空");
|
}
|
|
if (contractOrderVo.getSigntime() == null) {
|
throw new BusinessException("签订时间不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getProductList())) {
|
throw new BusinessException("产品列表不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyenterprisenumber())
|
|| StringUtils.isBlank(contractOrderVo.getSupplyunitname())) {
|
throw new BusinessException("生产企业不能为空");
|
}
|
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaseunitaddress())) {
|
throw new BusinessException("供货单位地址不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaserepresentative())) {
|
throw new BusinessException("供货单位法定代表人联系电话不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaserepresentativeemail())) {
|
throw new BusinessException("供货单位法定代表人电子邮箱不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchasebank())) {
|
throw new BusinessException("供货单位开户银行不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaselicensenumber())) {
|
throw new BusinessException("供货单位许可证编号不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchasezipcode())) {
|
throw new BusinessException("供货单位许可证编号不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaseagent())) {
|
throw new BusinessException("供货单位委托代理人不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaseagentphone())) {
|
throw new BusinessException("供货单位委托代理人联系电话不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPurchaseaccount())) {
|
throw new BusinessException("供货单位账户不能为空");
|
}
|
|
|
|
//合同内容:
|
if (StringUtils.isBlank(contractOrderVo.getQualitystandard())) {
|
throw new BusinessException("产品质量标准及要求不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getProhibiteddrug())) {
|
throw new BusinessException("禁(限)用药物要求不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getPackingstandard())) {
|
throw new BusinessException("产品包装标准及要求不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getTimeandlocation())) {
|
throw new BusinessException("提(交)货时间和地点不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getTransportandcost())) {
|
throw new BusinessException("运输方式及费用负担不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getAcceptstandard())) {
|
throw new BusinessException("验收标准与方法不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getObjectdeadline())) {
|
throw new BusinessException("提出异议期限不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSettlemethod())) {
|
throw new BusinessException("结算方式与期限不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getProductsafetyandquality())) {
|
throw new BusinessException("产品安全与质量责任不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getTransportsafety())) {
|
throw new BusinessException("运输安全责任不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getBreakcontract())) {
|
throw new BusinessException("违约责任不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getContractdisputesfelid())) {
|
throw new BusinessException("合同争议的解决方式不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getOtheragreedmatters())) {
|
throw new BusinessException("其他约定事项不能为空");
|
}
|
//有效期
|
if (contractOrderVo.getValidstarttime() == null || contractOrderVo.getValidendtime() == null) {
|
throw new BusinessException("合同有效期不能为空");
|
}
|
}
|
|
|
/**
|
* @Description: 确认校验
|
* @date 2021/5/11 13:55
|
*/
|
@Override
|
public void checkConfirm(ContractOrderVo contractOrderVo) {
|
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyunitaddress())) {
|
throw new BusinessException("生产单位地址不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyrepresentative())) {
|
throw new BusinessException("生产单位法定代表人联系电话不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyrepresentativeemail())) {
|
throw new BusinessException("生产单位法定代表人电子邮箱不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplybank())) {
|
throw new BusinessException("生产单位开户银行不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplylicensenumber())) {
|
throw new BusinessException("生产单位许可证编号不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyzipcode())) {
|
throw new BusinessException("生产单位邮政编码不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyagent())) {
|
throw new BusinessException("生产单位委托代理人不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyagentphone())) {
|
throw new BusinessException("生产单位委托代理人联系电话不能为空");
|
}
|
|
if (StringUtils.isBlank(contractOrderVo.getSupplyaccount())) {
|
throw new BusinessException("生产单位账户不能为空");
|
}
|
}
|
|
@Override
|
@Transactional
|
public void returnTag(String ordercode, MultipartFile file,UserInfo userInfo) {
|
if (StringUtils.isBlank(ordercode)) {
|
throw new BusinessException("参数传递错误");
|
}
|
List<ProductCodeInfo> productCodeInfos = productCodeService.selectByOrderCode(ordercode);
|
if (productCodeInfos.size() < 1) {
|
throw new BusinessException("订单编号或者产品出现问题");
|
}
|
byte [] byteArr;
|
try {
|
byteArr = file.getBytes();
|
String originalFilename = file.getOriginalFilename();
|
InputStream inputStream = new ByteArrayInputStream(byteArr);
|
assert originalFilename != null;
|
boolean isExcel2007 = originalFilename.substring(originalFilename.lastIndexOf(".") + 1).endsWith("xlsx");
|
//解析
|
List<String> parsedTags = excelExportService.parseProductCode(inputStream, userInfo, isExcel2007);
|
assert parsedTags.size() > 0;
|
Set<String> distinctSet = new HashSet<>(parsedTags);
|
if (distinctSet.size() != parsedTags.size()) {
|
throw new BusinessException("文件中有重复标签在不同行");
|
}
|
//更新电子标签isdel = 1
|
{
|
List<ProductCodeInfo> updatesTags = new ArrayList<>();
|
Date now = new Date();
|
for (String returnTag : parsedTags) {
|
boolean isError = true;
|
for (ProductCodeInfo realCode : productCodeInfos) {
|
if (realCode.getOriginalcode().equals(returnTag)) {
|
isError = false;
|
//开始更新计数
|
realCode.setIsdel((byte) 1);
|
updatesTags.add(realCode);
|
//流向
|
ProductLocusInfo flow = new ProductLocusInfo();
|
flow.setCreateddate(now);
|
flow.setModifieddate(now);
|
//流向内容为 退货人
|
flow.setContent(userInfo.getUsername());
|
flow.setDirectioncode(returnTag);
|
flow.setType(ProductLocusInfo.ELECTRONIC_LABEL_RETURN_STATUS);
|
flow.setBoxcode(Integer.valueOf(returnTag.substring(19,22)).toString());
|
productLocusService.insertProductLocus(flow);
|
}
|
}
|
//如果上传的标签不在合同编号的电子标签,则有问题
|
if (isError) {
|
throw new BusinessException(returnTag + ":上传的产品电子标签不是该订单的电子标签或者该标签已经退回");
|
}
|
}
|
//执行退回标签
|
productCodeService.updateBatchById(updatesTags);
|
}
|
//变更数量统计
|
{
|
Map<String, Integer> changeMap = new HashMap<>();
|
|
for (String parsedTag : parsedTags) {
|
String productCode = parsedTag.substring(0, 10);
|
if (changeMap.get(productCode) == null) {
|
changeMap.put(productCode, 1);
|
} else {
|
Integer count = changeMap.get(productCode);
|
changeMap.put(productCode, ++count);
|
}
|
}
|
|
for (Map.Entry<String, Integer> entry : changeMap.entrySet()) {
|
String productCode = entry.getKey();
|
Integer returnNum = entry.getValue();
|
//ordercode 和10位productCode 来更新一个变更数量
|
contractDetailService.updateChangNum(ordercode,productCode, returnNum);
|
}
|
}
|
|
//更新单子状态-》有退回
|
|
contractOrderInfoMapper.updateReturnStatus(ordercode,"有退回");
|
|
|
|
} catch (IOException e) {
|
e.printStackTrace();
|
throw new BusinessException("文件传输发生错误");
|
}
|
}
|
|
@Override
|
public String generateZplString(ProductCodePrint productPrint, UserInfo userInfo) {
|
List<ProductCodeVo>productCodeVos = productPrint.getProductCodeVos();
|
//ZplUtil zplUtil = new ZplUtil();
|
return generateInnerTag(productCodeVos, userInfo);
|
}
|
|
@Override
|
public String generateInnerTag(List<ProductCodeVo> productCodeVos, UserInfo userInfo){
|
StringBuilder builder = new StringBuilder();
|
byte type = 1;
|
ControlPrintParam controlPrintParam = controlPrintParamService.getParamsByUser(userInfo,type);
|
for (int i = 0; i < productCodeVos.size(); i++){
|
ProductCodeVo productCodeVo = productCodeVos.get(i);
|
if (productCodeVo == null || (StringUtils.isBlank(productCodeVo.getOrdercode())&& StringUtils.isBlank(productCodeVo.getItemcode()))){
|
if (i % 2 == 1){
|
if (!builder.toString().endsWith("^XZ")){
|
builder.append("^XZ");
|
}else {
|
builder.append("^XA^FD.").append("^XZ");
|
}
|
}
|
continue;
|
}
|
String code = productCodeVo.getItemcode();
|
String title = "新疆流向专用";
|
String date = DateFormatUtils.format(productCodeVo.getCreateddate(), "yyyy-MM-dd HH:mm:ss");
|
Integer baseX = controlPrintParam.getLeftBaseX();
|
Integer titleY = controlPrintParam.getTitleY();
|
Integer titleOffsetX = controlPrintParam.getTitleOffsetX();
|
Integer barCodeWidth = controlPrintParam.getBarcodeWidth();
|
Integer barCodeWidthRatio = controlPrintParam.getBarcodeWidthRadio();
|
Integer barCodeHeight = controlPrintParam.getBarcodeHeight();
|
Integer barCodeY = controlPrintParam.getBarcodeY();
|
Integer qrCodeModel = controlPrintParam.getQrCodeModel();
|
Integer qrCodeMagnification = controlPrintParam.getQrCodeMagnification();
|
Integer qrX = controlPrintParam.getLeftQrX();
|
Integer qrY = controlPrintParam.getQrY();
|
Integer fontSize = controlPrintParam.getFontsize1();
|
Integer fontSize2 = controlPrintParam.getFontsize2();
|
Integer fontSize3 = controlPrintParam.getFontsize3();
|
Integer barCodeTextY = controlPrintParam.getBarcodeTextY();
|
Integer itemNameY = controlPrintParam.getItemNameY();
|
Integer typeY = controlPrintParam.getTypeY();
|
Integer dateY = controlPrintParam.getDateY();
|
Integer manufacturerY = controlPrintParam.getManufacturerY();
|
Integer manufacturerY2 = controlPrintParam.getManufacturerY2();
|
Integer frameX = controlPrintParam.getLeftFrameX();
|
Integer frameY = controlPrintParam.getFrameY();
|
Integer frameWidth = controlPrintParam.getFrameWidth();
|
Integer frameHeight = controlPrintParam.getFrameHeight();
|
Integer darkness = controlPrintParam.getDarkness();
|
|
|
//左标签
|
if (i % 2 == 0){
|
//^XA 开始 ;^JMA 正常打印浓度 ;^SEE:GB18030.DAT^CW1,E:SIMSUN.FNT 支持中文编码
|
builder.append("^XA").append("^JMA").append("^MD").append(darkness).append("^CI28^SEE:GB18030.DAT^CW1,E:SIMSUN.TTF");
|
}else {
|
baseX = controlPrintParam.getRightBaseX();
|
qrX = controlPrintParam.getRightQrX();
|
frameX = controlPrintParam.getRightFrameX();
|
}
|
//标签头
|
//builder.append("^FO").append(baseX).append(",").append(titleY).append("^GFA,64896,64896,00156,").append(title);
|
builder.append("^FO").append(baseX+titleOffsetX).append(",").append(titleY).append("^A1N,").append(fontSize3)
|
.append(",").append(fontSize3).append("^FD").append(title).append("^FS");
|
//条形码
|
builder.append("^BY").append(barCodeWidth).append(",").append(barCodeWidthRatio).append(",")
|
.append(barCodeHeight).append("^FO").append(baseX).append(",").append(barCodeY)
|
.append("^BCN,,N,N^FD").append(code).append("^FS");
|
//二维码
|
builder.append("^BQN,").append(qrCodeModel).append(",").append(qrCodeMagnification).append("^FO")
|
.append(qrX).append(",").append(qrY).append("^FDLA,").append(code).append("^FS");
|
//条形码文字
|
builder.append("^FO").append(baseX).append(",").append(barCodeTextY).append("^A1N,")
|
.append(fontSize).append("^FD").append(code).append("^FS");
|
//其他信息
|
//文字转换图片打印,但转换后数据太大
|
// builder.append(zplUtil.getCharPicture(productCodeVo.getItemname(),baseX,itemNameY,30,34,1));
|
// builder.append(zplUtil.getCharPicture(productCodeVo.getType(),baseX,typeY,30,34,1));
|
// builder.append(zplUtil.getCharPicture(productCodeVo.getManufacturer(),baseX,manufacturerY,30,34,1));
|
// builder.append("^FO").append(baseX).append(",").append(dateY).append("^A,").append(fontSize).append(",")
|
// .append(fontSize).append("^FD").append(date).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(itemNameY).append("^A1N,").append(fontSize2)
|
.append(",").append(fontSize2).append("^FD").append(productCodeVo.getItemname()).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(typeY).append("^A1N,").append(fontSize2).append(",")
|
.append(fontSize2).append("^FD").append(productCodeVo.getType()).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(dateY).append("^A1N,").append(fontSize).append(",")
|
.append(fontSize).append("^FD").append(date).append("^FS");
|
String manufacturer = productCodeVo.getManufacturer();
|
if (StringUtils.isBlank(manufacturer)){
|
throw new BusinessException("错误:生产厂家为空");
|
}
|
builder.append("^FO").append(baseX).append(",").append(manufacturerY).append("^A1N,").append(fontSize2)
|
.append(",").append(fontSize2).append("^FD").append(manufacturer.length()>16?manufacturer.substring(0,16):manufacturer).append("^FS");
|
if (manufacturer.length()>16){
|
builder.append("^FO").append(baseX).append(",").append(manufacturerY2).append("^A1N,").append(fontSize2)
|
.append(",").append(fontSize2).append("^FD").append(manufacturer.substring(16)).append("^FS");
|
}
|
builder.append("^FO").append(frameX).append(",").append(frameY).append("^GB").append(frameWidth)
|
.append(",").append(frameHeight).append(",4,B,1^FS");
|
if (i % 2 != 0){
|
builder.append("^XZ");
|
}
|
|
}
|
|
return builder.toString();
|
}
|
|
@Override
|
public String generateOuterTag(List<ProductCodeVo> productCodeVos, UserInfo userInfo){
|
StringBuilder builder = new StringBuilder();
|
byte type = 2;
|
ControlPrintParam controlPrintParam = controlPrintParamService.getParamsByUser(userInfo,type);
|
for (int i = 0; i < productCodeVos.size(); i++){
|
ProductCodeVo productCodeVo = productCodeVos.get(i);
|
if (productCodeVo == null || (StringUtils.isBlank(productCodeVo.getOrdercode())&& StringUtils.isBlank(productCodeVo.getItemcode()))){
|
if (i % 2 == 1){
|
builder.append("^XZ");
|
}
|
builder.append("^XA").append("^XZ");
|
continue;
|
}
|
String code = productCodeVo.getOriginalcode();
|
if (code.length()!= 22){
|
continue;
|
}
|
String codePrefix = code.substring(0,19);
|
String codeSuffix = code.substring(19);
|
|
String title = "新疆专用:包装识别码";
|
String date = DateFormatUtils.format(productCodeVo.getCreateddate(), "yyyy/MM/dd");
|
int baseX = controlPrintParam.getLeftBaseX();
|
int titleY = controlPrintParam.getTitleY();
|
int barCodeWidth = controlPrintParam.getBarcodeWidth();
|
int barCodeWidthRatio = controlPrintParam.getBarcodeWidthRadio();
|
int barCodeHeight = controlPrintParam.getBarcodeHeight();
|
int barCodeY = controlPrintParam.getBarcodeY();
|
int qrCodeModel = controlPrintParam.getQrCodeModel();
|
int qrCodeMagnification = controlPrintParam.getQrCodeMagnification();
|
int qrX = controlPrintParam.getLeftQrX();
|
int qrY = controlPrintParam.getQrY();
|
int fontSize = controlPrintParam.getFontsize1();
|
int fontSize2 = controlPrintParam.getFontsize2();
|
int barCodeTextY = controlPrintParam.getBarcodeTextY();
|
int itemNameY = controlPrintParam.getItemNameY();
|
int typeY = controlPrintParam.getTypeY();
|
int dateY = controlPrintParam.getDateY();
|
int totalY = controlPrintParam.getTotalY();
|
int manufacturerY = controlPrintParam.getManufacturerY();
|
int manufacturerY2 = controlPrintParam.getManufacturerY2();
|
int darkness = controlPrintParam.getDarkness();
|
|
//左标签
|
if (i % 2 == 0){
|
//^XA 开始 ;^JMA 正常打印浓度 ;^SEE:GB18030.DAT^CW1,E:SIMSUN.FNT 支持中文编码
|
builder.append("^XA").append("^JMA").append("^MD").append(darkness).append("^CI28^SEE:GB18030.DAT^CW1,E:SIMSUN.TTF");
|
}else {
|
baseX = controlPrintParam.getRightBaseX();
|
qrX = controlPrintParam.getRightQrX();
|
}
|
//标签头
|
builder.append("^FO").append(baseX).append(",").append(titleY).append("^A1N,").append(fontSize2)
|
.append("^FD").append(title).append(productCodeVo.getBoxrange()).append("^FS");
|
//条形码
|
builder.append("^BY").append(barCodeWidth).append(",").append(barCodeWidthRatio).append(",")
|
.append(barCodeHeight).append("^FO").append(baseX-20).append(",").append(barCodeY)
|
.append("^BCN,,N,N^FD").append(code).append("^FS");
|
//二维码
|
builder.append("^BQN,").append(qrCodeModel).append(",").append(qrCodeMagnification).append("^FO")
|
.append(qrX).append(",").append(qrY).append("^FDLA,").append(code).append("^FS");
|
//条形码文字
|
builder.append("^FO").append(baseX).append(",").append(barCodeTextY).append("^A1,")
|
.append(fontSize).append("^FD").append(codePrefix).append(" ").append(codeSuffix).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(itemNameY).append("^A1N,").append(fontSize2)
|
.append(",").append(fontSize2).append("^FD").append(productCodeVo.getItemname()).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(typeY).append("^A1N,").append(fontSize2).append(",")
|
.append(fontSize2).append("^FD").append(productCodeVo.getType()).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(dateY).append("^A1N,").append(fontSize).append(",")
|
.append(fontSize).append("^FD").append(date).append("^FS");
|
builder.append("^FO").append(baseX).append(",").append(totalY).append("^A1N,").append(fontSize).append(",")
|
.append(fontSize).append("^FD").append("总装药量:").append(productCodeVo.getExplosivecontent()).append("^FS");
|
builder.append("^FO").append(qrX).append(",").append(totalY).append("^A1N,").append(fontSize).append(",")
|
.append(fontSize).append("^FD").append("箱含量:").append(productCodeVo.getBoxnumber()).append("^FS");
|
String manufacturer = productCodeVo.getManufacturer();
|
if (StringUtils.isBlank(manufacturer)){
|
throw new BusinessException("错误:生产厂家为空");
|
}
|
builder.append("^FO").append(baseX).append(",").append(manufacturerY).append("^A1N,").append(fontSize2)
|
.append(",").append(fontSize2).append("^FD").append(manufacturer.length()>16?manufacturer.substring(0,16):manufacturer).append("^FS");
|
if (manufacturer.length()>16){
|
builder.append("^FO").append(baseX).append(",").append(manufacturerY2).append("^A1N,").append(fontSize2)
|
.append(",").append(fontSize2).append("^FD").append(manufacturer.substring(16)).append("^FS");
|
}
|
if (i % 2 != 0){
|
builder.append("^XZ");
|
}
|
}
|
if (!builder.toString().endsWith("^XZ")){
|
builder.append("^XZ");
|
}
|
return builder.toString();
|
}
|
|
/**
|
* @Description: 生成规律单号
|
* @date 2021/5/10 10:11
|
*/
|
private String generateRegularCode() {
|
//查询当日合同总数
|
int num = contractOrderInfoMapper.selectCountToday();
|
String numStr = num + 1 + "";
|
//超过3位 显示原位数据 不需要补0
|
if (numStr.length() >= 3) {
|
return numStr;
|
}
|
//不超过则需要补0
|
//距离
|
int i = 3 - numStr.length();
|
return String.format("%03d", num + 1);
|
|
}
|
|
}
|