7 changed files with 513 additions and 0 deletions
-
35src/main/java/com/heai/modules/production/controller/BoxLabelController.java
-
20src/main/java/com/heai/modules/production/dao/PrintLabelRecordMapper.java
-
95src/main/java/com/heai/modules/production/entity/CoHeader.java
-
41src/main/java/com/heai/modules/production/entity/PrintBoxLabel.java
-
11src/main/java/com/heai/modules/production/service/PrintLabelRecordService.java
-
110src/main/java/com/heai/modules/production/service/impl/PrintLabelRecordServiceImpl.java
-
201src/main/resources/mapper/production/PrintLabelRecordMapper.xml
@ -0,0 +1,35 @@ |
|||
package com.heai.modules.production.controller; |
|||
|
|||
import com.heai.common.utils.R; |
|||
import com.heai.modules.production.entity.PrintBoxLabel; |
|||
import com.heai.modules.production.service.PrintLabelRecordService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/delivery/box/label") |
|||
public class BoxLabelController { |
|||
|
|||
@Autowired |
|||
private PrintLabelRecordService printLabelRecordService; |
|||
@PostMapping |
|||
public R getPrintBoxLabel(@RequestBody PrintBoxLabel boxLabel){ |
|||
Map<String, Object> maps = printLabelRecordService.getPrintBoxLabel(boxLabel); |
|||
return R.ok().put("row", maps); |
|||
} |
|||
|
|||
@PostMapping("/handle") |
|||
public R handlerPrintBoxLabel(@RequestBody PrintBoxLabel boxLabel){ |
|||
List<Map<String, Object>> maps = printLabelRecordService.handlerPrintBoxLabel(boxLabel); |
|||
return R.ok().put("rows", maps); |
|||
} |
|||
|
|||
@PostMapping("/finally") |
|||
public R finallyPrintBoxLabel(@RequestBody PrintBoxLabel boxLabel){ |
|||
printLabelRecordService.finallyPrintBoxLabel(boxLabel); |
|||
return R.ok(); |
|||
} |
|||
} |
|||
@ -1,9 +1,29 @@ |
|||
package com.heai.modules.production.dao; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.heai.modules.pad.entity.PartData; |
|||
import com.heai.modules.production.entity.CoHeader; |
|||
import com.heai.modules.production.entity.PrintBoxLabel; |
|||
import com.heai.modules.production.entity.PrintLabelRecord; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Mapper |
|||
public interface PrintLabelRecordMapper extends BaseMapper<PrintLabelRecord> { |
|||
List<Map<String, Object>> handlerPrintBoxLabel(PrintBoxLabel boxLabel); |
|||
|
|||
String getPrintFileType(PrintBoxLabel boxLabel); |
|||
|
|||
int finallyPrintBoxLabel(@Param("site") String site,@Param("delNotifyNo") String delNotifyNo,@Param("total") int total,@Param("seqNo") int seqNo); |
|||
|
|||
PartData getPartData(PrintBoxLabel boxLabel); |
|||
|
|||
CoHeader getCoHeaderData(PrintBoxLabel boxLabel); |
|||
|
|||
String getPartRevNo(PartData part); |
|||
|
|||
String getPartAttr(@Param("partNo") String partNo,@Param("site") String site,@Param("type") String type); |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
package com.heai.modules.production.entity; |
|||
|
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class CoHeader { |
|||
|
|||
private String orderNo; |
|||
|
|||
private String site; |
|||
|
|||
private String customerId; |
|||
|
|||
private Date orderDate; |
|||
|
|||
private Date enterDate; |
|||
|
|||
private String customerPoNo; |
|||
|
|||
private Date wantDeliveryDate; |
|||
|
|||
private String username; |
|||
|
|||
private String intSales; |
|||
|
|||
private String extSales; |
|||
|
|||
private String status; |
|||
|
|||
private String sourceFlag; |
|||
|
|||
private String printed; |
|||
|
|||
private String orderType; |
|||
|
|||
private String remark; |
|||
|
|||
private String paymentTerm; |
|||
|
|||
private String currency; |
|||
|
|||
private BigDecimal currencyRate; |
|||
|
|||
private String deliveryTerm; |
|||
|
|||
private String authorizeFlag; |
|||
|
|||
private String approvedFlag; |
|||
|
|||
private String approveResult; |
|||
|
|||
private String authorizator; |
|||
|
|||
private Date authorizeDate; |
|||
|
|||
private String taxCode; |
|||
|
|||
private String delAddId; |
|||
|
|||
private String invAddId; |
|||
|
|||
private BigDecimal leadTime; |
|||
|
|||
private String codeNo; |
|||
|
|||
private String packMethod; |
|||
|
|||
private String batchType; |
|||
|
|||
private String shipVia; |
|||
|
|||
private String sortFlag; |
|||
|
|||
private String subOrderType; |
|||
|
|||
private String soRemark; |
|||
|
|||
private String authRuleId; |
|||
|
|||
private String soCreateFlag; |
|||
|
|||
private String payerCustomerId; |
|||
|
|||
private String contractNo; |
|||
|
|||
private String firstStepApprovedFlag; |
|||
|
|||
private String headerPrePayFlag; |
|||
|
|||
private BigDecimal headerPrePayAmount; |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package com.heai.modules.production.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Data |
|||
public class PrintBoxLabel { |
|||
private String site; |
|||
|
|||
private String delNotifyNo; |
|||
|
|||
private String delNotifyItemNo; |
|||
|
|||
private String partNo; |
|||
|
|||
private String partSpec; |
|||
|
|||
private int printTotalBoxCount; |
|||
|
|||
private int printBoxSeqNo; |
|||
|
|||
private BigDecimal qtyPerBox; |
|||
|
|||
private BigDecimal qtyPerBag; |
|||
|
|||
private BigDecimal shipQty; |
|||
|
|||
private BigDecimal boxNum; |
|||
|
|||
private BigDecimal endBoxQty; |
|||
|
|||
private BigDecimal scatteredBoxNo; |
|||
|
|||
private BigDecimal boxLabelTotalQty; |
|||
|
|||
private String userId; |
|||
|
|||
private String printFileType; |
|||
|
|||
} |
|||
@ -1,7 +1,18 @@ |
|||
package com.heai.modules.production.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.heai.modules.production.entity.PrintBoxLabel; |
|||
import com.heai.modules.production.entity.PrintLabelRecord; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface PrintLabelRecordService extends IService<PrintLabelRecord> { |
|||
Map<String, Object> getPrintBoxLabel(PrintBoxLabel boxLabel); |
|||
|
|||
List<Map<String, Object>> handlerPrintBoxLabel(PrintBoxLabel boxLabel); |
|||
|
|||
String getPrintFileType(PrintBoxLabel boxLabel); |
|||
|
|||
void finallyPrintBoxLabel(PrintBoxLabel boxLabel); |
|||
} |
|||
@ -1,11 +1,121 @@ |
|||
package com.heai.modules.production.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.heai.modules.pad.entity.PartData; |
|||
import com.heai.modules.production.dao.PrintLabelRecordMapper; |
|||
import com.heai.modules.production.dao.ProcedureMapper; |
|||
import com.heai.modules.production.entity.CoHeader; |
|||
import com.heai.modules.production.entity.PrintBoxLabel; |
|||
import com.heai.modules.production.entity.PrintLabelRecord; |
|||
import com.heai.modules.production.service.PrintLabelRecordService; |
|||
import com.heai.modules.sys.entity.SysUserEntity; |
|||
import org.apache.shiro.SecurityUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Objects; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class PrintLabelRecordServiceImpl extends ServiceImpl<PrintLabelRecordMapper, PrintLabelRecord> implements PrintLabelRecordService { |
|||
@Autowired |
|||
private ProcedureMapper procedureMapper; |
|||
|
|||
@Override |
|||
public Map<String, Object> getPrintBoxLabel(PrintBoxLabel boxLabel) { |
|||
List<Object> list = new ArrayList<>(); |
|||
list.add(boxLabel.getSite()); |
|||
list.add(boxLabel.getDelNotifyNo()); |
|||
list.add(boxLabel.getDelNotifyItemNo()); |
|||
list.add(boxLabel.getPartNo()); |
|||
List<Map<String, Object>> maps = procedureMapper.getProcedureData("Get_PrintBoxLabel_Initial_Info", list); |
|||
return maps.stream().findFirst().orElse(null); |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> handlerPrintBoxLabel(PrintBoxLabel boxLabel) { |
|||
SysUserEntity user = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); |
|||
boxLabel.setUserId(user.getUsername()); |
|||
|
|||
boxLabel.setPrintFileType(getPrintFileType(boxLabel)); |
|||
// 获取物料信息 |
|||
PartData part = baseMapper.getPartData(boxLabel); |
|||
if (Objects.isNull(part)){ |
|||
throw new RuntimeException("Site"+boxLabel.getSite()+"未维护物料"+boxLabel.getPartNo()); |
|||
} |
|||
// 获得PartRevNo |
|||
String partRevNo = baseMapper.getPartRevNo(part); |
|||
// 获取采购订单信息 |
|||
CoHeader coHeader = baseMapper.getCoHeaderData(boxLabel); |
|||
if (Objects.isNull(coHeader)){ |
|||
coHeader = new CoHeader(); |
|||
coHeader.setContractNo(""); |
|||
coHeader.setCustomerPoNo(""); |
|||
} |
|||
// 获取Part属性信息 |
|||
String hardness = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"HARDNESS"); |
|||
String color = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"COLOR"); |
|||
String iconInfo = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"CARTON ICON"); |
|||
String materialType = baseMapper.getPartAttr(part.getPartNo(),part.getSite(),"MATERIAL TYPE"); |
|||
List<Map<String, Object>> list = baseMapper.handlerPrintBoxLabel(boxLabel); |
|||
CoHeader finalCoHeader = coHeader; |
|||
return list.stream().map(item->{ |
|||
item.put("receiveDate",item.get("createDate")); |
|||
item.put("partSpec",part.getSpec()); |
|||
item.put("partDesc",part.getPartDescription()); |
|||
item.put("code",genPrintTypeCode(String.valueOf(item.get("labelType")))); |
|||
item.put("code",genPrintTypeCode(String.valueOf(item.get("labelType")))); |
|||
item.put("code",genPrintTypeCode(String.valueOf(item.get("labelType")))); |
|||
item.put("contractNo", finalCoHeader.getContractNo()); |
|||
item.put("customerPONo",finalCoHeader.getCustomerPoNo()); |
|||
item.put("partRevNo",partRevNo); |
|||
item.put("cOLOR",color); |
|||
item.put("hARDNESS",hardness); |
|||
item.put("iconInfo",iconInfo); |
|||
item.put("mATERIALTYPE",materialType); |
|||
return item; |
|||
}).collect(Collectors.toList()); |
|||
} |
|||
|
|||
private String genPrintTypeCode(String type){ |
|||
if (StringUtils.isEmpty(type)){ |
|||
return "CODEXX"; |
|||
} |
|||
if ("A".equals(type)){ |
|||
return "CODE128"; |
|||
}else if ("B".equals(type)){ |
|||
return "CODE128"; |
|||
}else if (type.equals("C")){ |
|||
return "CODE128"; |
|||
}else { |
|||
return "CODEXX"; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public String getPrintFileType(PrintBoxLabel boxLabel) { |
|||
return baseMapper.getPrintFileType(boxLabel); |
|||
} |
|||
|
|||
@Override |
|||
public void finallyPrintBoxLabel(PrintBoxLabel boxLabel) { |
|||
int total = 0; |
|||
int seqNo = 0; |
|||
if (boxLabel.getScatteredBoxNo().compareTo(BigDecimal.ZERO) == 0){ |
|||
total = boxLabel.getPrintTotalBoxCount(); |
|||
seqNo = new BigDecimal(boxLabel.getPrintBoxSeqNo()).add(boxLabel.getBoxNum()).intValue(); |
|||
}else if (new BigDecimal(boxLabel.getPrintBoxSeqNo()).add(boxLabel.getBoxNum()).compareTo(boxLabel.getScatteredBoxNo()) >= 0){ |
|||
total = boxLabel.getBoxNum().intValue(); |
|||
seqNo = new BigDecimal(boxLabel.getPrintBoxSeqNo()).add(boxLabel.getBoxNum()).intValue(); |
|||
}else { |
|||
total = boxLabel.getBoxNum().intValue(); |
|||
seqNo = boxLabel.getPrintBoxSeqNo(); |
|||
} |
|||
baseMapper.finallyPrintBoxLabel(boxLabel.getSite(),boxLabel.getDelNotifyNo(),total,seqNo); |
|||
} |
|||
} |
|||
@ -0,0 +1,201 @@ |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.heai.modules.production.dao.PrintLabelRecordMapper"> |
|||
<select id="handlerPrintBoxLabel" resultType="java.util.Map"> |
|||
Select '*' as batchNo |
|||
, '' as printerName |
|||
, 'N' as status |
|||
, D.DelnotifyNo as orderRef1 |
|||
, convert(varchar(50), D.delNotifyItemNo) as orderRef2 |
|||
, convert(varchar(50), '*') as orderRef3 |
|||
, '' as remark |
|||
, D.Site as site |
|||
, #{userId} as createdBy |
|||
, getdate() as createDate |
|||
, '' as computerName |
|||
, #{printFileType} as labelType |
|||
, Convert(float, #{boxLabelTotalQty}) as unitQty |
|||
, Convert(Integer, #{printTotalBoxCount}) as keyInfoInt1 |
|||
, Convert(Integer, H.SeqNo - 1 + #{printBoxSeqNo}) as keyInfoInt2 |
|||
, 'N/A' as keyInfoStr1 |
|||
, '' as keyInfoStr2 |
|||
, -1 as keyInfoFloat1 |
|||
, -1 as keyInfoFloat2 |
|||
, 1 as printQty |
|||
, REPLACE(Address_E + ' Phone:' + S.PhoneNo + ' Email:' + S.Email, CHAR(13) + CHAR(10), |
|||
'') as siteDetail |
|||
, SiteName as siteName |
|||
, (case |
|||
when C.CustomerGroup = 'TBC' then CA.EndCustOurVendorCode |
|||
else C.OurVendorCode end) as endCustVendorCode |
|||
from CODelNotifyHeader as T |
|||
Left Join CustomerAddress as CA |
|||
On T.Site = CA.Site and T.CustomerID = CA.CustomerID and T.DelAddID = CA.AddressID |
|||
Left join Customer as C on C.Site = T.Site and C.CustomerID = T.CustomerID |
|||
, CODelNotifyDetail as D |
|||
, Dual as H |
|||
, Site as S |
|||
Where T.Site = D.Site |
|||
and T.DelnotifyNo = D.DelnotifyNo |
|||
and T.Site = S.SiteID |
|||
and T.Site = #{site} |
|||
and T.DelnotifyNo = #{delNotifyNo} |
|||
and D.delNotifyItemNo = #{delNotifyItemNo} |
|||
and H.SeqNo <= #{boxNum} |
|||
and H.SeqNo <= #{boxNum} |
|||
and #{boxNum} > 0 |
|||
Union all |
|||
Select '*' as batchNo |
|||
, '' as printerName |
|||
, 'N' as status |
|||
, D.DelnotifyNo as orderRef1 |
|||
, convert(varchar(50), D.delNotifyItemNo) as orderRef2 |
|||
, convert(varchar(50), '*') as orderRef3 |
|||
, '' as remark |
|||
, D.Site as site |
|||
, #{userId} as createdBy |
|||
, getdate() as createDate |
|||
, '' as computerName |
|||
, #{printFileType} as labelType |
|||
, Convert(float, #{endBoxQty}) as unitQty |
|||
, Convert(Integer, #{printTotalBoxCount}) as keyInfoInt1 |
|||
, Convert(Integer, H.SeqNo - 1 + #{scatteredBoxNo}) as keyInfoInt2 |
|||
, 'N/A' as keyInfoStr1 |
|||
, '' as keyInfoStr2 |
|||
, -1 as keyInfoFloat1 |
|||
, -1 as keyInfoFloat2 |
|||
, 1 as printQty |
|||
, REPLACE(Address_E + ' Phone:' + S.PhoneNo + ' Email:' + S.Email, CHAR(13) + CHAR(10), |
|||
'') as siteDetail |
|||
, SiteName as siteName |
|||
, (case |
|||
when C.CustomerGroup = 'TBC' then CA.EndCustOurVendorCode |
|||
else C.OurVendorCode end) as endCustVendorCode |
|||
from CODelNotifyHeader as T |
|||
Left Join CustomerAddress as CA |
|||
On T.Site = CA.Site and T.CustomerID = CA.CustomerID and T.DelAddID = CA.AddressID |
|||
Left join Customer as C on C.Site = T.Site and C.CustomerID = T.CustomerID |
|||
, CODelNotifyDetail |
|||
as D |
|||
, Dual as H |
|||
, Site as S |
|||
Where T.Site = D.Site |
|||
and T.DelnotifyNo = D.DelnotifyNo |
|||
and T.Site = S.SiteID |
|||
and T.Site = #{site} |
|||
and T.DelnotifyNo = #{delNotifyNo} |
|||
and D.delNotifyItemNo = #{delNotifyItemNo} |
|||
and #{endBoxQty} > 0 |
|||
</select> |
|||
|
|||
<select id="getPrintFileType" resultType="java.lang.String"> |
|||
Select C.ABC |
|||
from CODelNotifyHeader as T |
|||
Left Join Customer as C On C.Site = T.Site and C.CustomerID = T.CustomerID |
|||
Where T.Site = #{site,jdbcType=VARCHAR} |
|||
and T.DelnotifyNo = #{delNotifyNo} |
|||
</select> |
|||
|
|||
<update id="finallyPrintBoxLabel"> |
|||
update CODelNotifyHeader |
|||
set PrintTotalBoxCount = #{total}, |
|||
PrintBoxSeqNo = #{seqNo} |
|||
where Site = #{site} |
|||
and DelNotifyNo = #{delNotifyNo} |
|||
</update> |
|||
|
|||
<select id="getPartData" resultType="com.heai.modules.pad.entity.PartData"> |
|||
select top 1 PartNo, |
|||
Site, |
|||
PartDescription, |
|||
Spec, |
|||
PartType_DB, |
|||
PartType, |
|||
FamilyID, |
|||
GroupID, |
|||
UMID, |
|||
Active, |
|||
Remark, |
|||
Stock, |
|||
StockInArrive, |
|||
StockInQuality, |
|||
StockInConsignment, |
|||
StockInPicking, |
|||
StockinActive, |
|||
QtyonPO, |
|||
MinStock, |
|||
MaxStock, |
|||
SafetyStockManage, |
|||
SafetyStock, |
|||
StandardOrderQty, |
|||
SupplierID, |
|||
AccountFamilyID, |
|||
LatestPrice, |
|||
AveragePrice, |
|||
ActualCost, |
|||
StandardCost, |
|||
StandardCost_BasePrice, |
|||
LatestSalesPrice, |
|||
AverageSalesPrice, |
|||
FinanceCheck, |
|||
MRPCode, |
|||
ManuLeadtime, |
|||
DefaultWarehouseID, |
|||
CodeNo, |
|||
SubCodeNo, |
|||
StandardLotSize, |
|||
ExpireDateControlFlag, |
|||
ToExpireDays, |
|||
CreateDate, |
|||
LastUpdateBy, |
|||
NeedApproveFlag, |
|||
ApprovedFlag, |
|||
NetWeight, |
|||
OtherGroup1, |
|||
OtherGroup2, |
|||
OtherGroup3, |
|||
OtherGroup4, |
|||
DefaultDepartmentID, |
|||
DefaultLocationID, |
|||
ConfigurationFlag, |
|||
ConfigurationTemplateID, |
|||
BOMLatestRevNo, |
|||
UMID_New, |
|||
PartNo_Base, |
|||
UMID_ConvertFactor |
|||
from Part |
|||
where Site = #{site} |
|||
and PartNo = #{partNo} |
|||
</select> |
|||
|
|||
<select id="getCoHeaderData" resultType="com.heai.modules.production.entity.CoHeader"> |
|||
select top 1 ch.ContractNo as contractNo, |
|||
ch.CustomerPONo as customerPoNo |
|||
from CODelNotifyDetail dnd |
|||
left join COHeader ch on ch.Site = dnd.Site and dnd.OrderNo = ch.OrderNo |
|||
where dnd.Site = #{site} |
|||
and DelnotifyNo = #{delNotifyNo} |
|||
and DelNotifyItemNo = #{delNotifyItemNo} |
|||
</select> |
|||
|
|||
<select id="getPartRevNo" resultType="java.lang.String"> |
|||
select Case |
|||
when charindex('REV', dbo.Get_Part_Spec(Site, PartNo)) > 0 then |
|||
substring(dbo.Get_Part_Spec(Site, PartNo), |
|||
charindex('REV', dbo.Get_Part_Spec(Site, PartNo)) + 3, 20) |
|||
else '' end as partRevNo |
|||
from Part |
|||
where Site = #{site} |
|||
and PartNo = #{partNo} |
|||
</select> |
|||
|
|||
<select id="getPartAttr" resultType="java.lang.String"> |
|||
Select top 1 TextValue |
|||
from PartSubPropertiesValue |
|||
Where Site = #{site} |
|||
and PartNo = #{partNo} |
|||
and CodeNo = 'PACKAGE' |
|||
and RecordType = 'P' |
|||
and PropertiesItemNo = #{type} |
|||
</select> |
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue