no message

sdInAndOutDetailRepotr
HUOJIN\92525 2024-11-27 13:30:23 +08:00
parent 846e37335b
commit 008534f14f
5 changed files with 186 additions and 113 deletions

View File

@ -265,4 +265,7 @@ public interface ASNManager extends BaseManager{
//芝华仕
@Transactional
void importCHEERSASN(File file);
//入库明细导入
void asnDetailImport(long asnId,File file);
}

View File

@ -22,6 +22,8 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.transaction.annotation.Transactional;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
@ -3582,6 +3584,162 @@ public class DefaultASNManager extends DefaultBaseManager implements
}
}
@Override
@Transactional
public void asnDetailImport(long asnId, File file) {
if(asnId<=0){
throw new BusinessException("请选中一条入库单据!");
}
Workbook workbook;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
ASN asn=commonDao.load(ASN.class, asnId);
StringBuffer locBuffer=new StringBuffer();//不存在的库位
StringBuffer itemBuffer=new StringBuffer();//不存在的物料
StringBuffer zlztBuffer=new StringBuffer();//不存在的质量状态
Map<String,Location> locMap=new HashMap<String, Location>();
Map<String,Item> itemMap=new HashMap<String, Item>();
Map<Item,PackageUnit> packageUnitMap=new HashMap<Item, PackageUnit>();
Map<String,CommonCode> zlztMap=new HashMap<String, CommonCode>();
workbook = Workbook.getWorkbook(file);
Sheet sheet = workbook.getSheet(0);// 得到excel第一页的内容
for (int i = 1; i <sheet.getRows(); i++) {
//物料编号、特殊备注、期待数量、质量状态、库位号
String itemCode=sheet.getCell(0,i).getContents().trim();//物料编号
String zlzt=sheet.getCell(3,i).getContents().trim();//质量等级
String loc_Code=sheet.getCell(4,i).getContents().trim();//库位
Location loc=null;
if(itemCode==null || itemCode.length() <=0){
break;
}
//物料
List<Item> Items = commonDao.findByQuery(" from Item l where l.code=:code and l.disabled=0 and l.company.id="+asn.getCompany().getId()+" ",
new String[] { "code"},new Object[] {itemCode});
if(Items.isEmpty()){
itemBuffer.append((i+1)+"行"+itemCode+";");
}else{
itemMap.put(itemCode, Items.get(0));
//单位
List<PackageUnit> PackageUnits = commonDao.findByQuery(" from PackageUnit pu where pu.item.id=:id ",
new String[] { "id"},new Object[] {Items.get(0).getId()});
if(PackageUnits.size()>0){
packageUnitMap.put(Items.get(0), PackageUnits.get(0));
}
}
//质量状态
List<CommonCode> CommonCodes = commonDao.findByQuery(" from CommonCode commonCode where commonCode.code=:code and commonCode.codeType='质量状态' ",
new String[] { "code"},new Object[] {zlzt});
if(CommonCodes.isEmpty()){
zlztBuffer.append((i+1)+"行"+zlzt+";");
}else{
zlztMap.put(zlzt, CommonCodes.get(0));
}
//库位
List<Location> Locations = commonDao.findByQuery(" from Location l where l.code=:code and l.warehouse.id="+WarehouseHolder.getWarehouse().getId()+" ",
new String[] { "code"},new Object[] {loc_Code});
if(Locations.isEmpty()){
locBuffer.append((i+1)+"行"+loc_Code+";");
}else{
locMap.put(loc_Code, Locations.get(0));
}
}
if(itemBuffer!=null&&!itemBuffer.toString().equals("")){
throw new BusinessException(itemBuffer.toString()+"货品不存在!");
}
if(zlztBuffer!=null&&!zlztBuffer.toString().equals("")){
throw new BusinessException(zlztBuffer.toString()+"质量状态不存在!");
}
if(locBuffer!=null&&!locBuffer.toString().equals("")){
throw new BusinessException(locBuffer.toString()+"库位不存在!");
}
for (int i = 1; i <sheet.getRows(); i++) {
//物料编号、特殊备注、期待数量、质量状态、库位号
String itemCode=sheet.getCell(0,i).getContents().trim();//货品编号
String tsbz=sheet.getCell(1,i).getContents().trim();//特殊备注
String quantity=sheet.getCell(2,i).getContents().trim();//数量
String zlzt=sheet.getCell(3,i).getContents().trim();//质量状态
String loc_Code=sheet.getCell(4,i).getContents().trim();//库位
Location loc=null;
if(itemCode==null || itemCode.length() <=0){
break;
}
//物料
Item item=itemMap.get(itemCode);
//单位
PackageUnit packageUnit=packageUnitMap.get(item);
//库位
Location dock =locMap.get(loc_Code);
List<ASNDetail> ASNDetails = commonDao.findByQuery(" from ASNDetail ad where ad.asn.id=:asnId and ad.item.id=:itemId and ad.dock.id=:dockId ",
new String[] { "asnId","itemId","dockId"},new Object[] {asnId,item.getId(),dock.getId()});
if(ASNDetails.size()>0){
ASNDetail asnDetail=ASNDetails.get(0);
asnDetail.setExpectedQuantity(Double.parseDouble(quantity));
asnDetail.setExpectedQtyOfMasterUnit(Double.parseDouble(quantity));
asnDetail.setQualityStatus(zlzt);
if(asnDetail.getLotInfo()!=null){
asnDetail.getLotInfo().setPropLC1(tsbz);
}
commonDao.store(asnDetail);
}else{
ASNDetail asnDetail=EntityFactory.getEntity(ASNDetail.class);
asnDetail.setAsn(asn);
asnDetail.setItem(item);
asnDetail.setExpectedQuantity(Double.parseDouble(quantity));
asnDetail.setExpectedQtyOfMasterUnit(Double.parseDouble(quantity));
asnDetail.setQualityStatus(zlzt);
LotInfo lotInfo=new LotInfo();
if(StringUtils.isEmpty(tsbz)){
lotInfo.setPropLC1(null);
}else{
lotInfo.setPropLC1(tsbz);
}
Date currentDate = new Date();
String propC1 = sdf.format(currentDate);
lotInfo.setPropC1(propC1);//到货日期
Date propD1=returnDate(propC1);
lotInfo.setPropD1(propD1);
asnDetail.setLotInfo(lotInfo);
asnDetail.setDock(dock);
Integer lineNo=getlineNo(asn);
if(lineNo==0){
asnDetail.setLineNo(1);
}else{
asnDetail.setLineNo(lineNo+1);
}
asnDetail.setPackageUnit(packageUnit);
commonDao.store(asnDetail);
}
System.out.println("新增"+(i+1)+"条");
}
//刷新订单
Refresh(asn.getId());
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<pages>
<editPage id="editAsnDetailImportPage" title="明细导入" entityClass="com.dev.swms.server.model.receiving.ASNDetail" width="270" height="130" onClose="refreshParent">
<inputUIs>
<hidden id="asnDetail.id" reserve="false"/>
<file id="imageFile" title="importFile" row="1" col="2" readOnly="false" required="false" reserve="false" forceOverride="true" inVisible="false" showImage="false" storeDir="IMAGE_FILE_DIR" />
</inputUIs>
<buttons>
<commit id="asnDetailImport" title="导入" enableType="single" invisible="false">
<mappings>
<mapping id="asn.id" className="long"/>
<mapping id="imageFile" className="file"/>
</mappings>
<actions>
<action managerName="asnManager" methodName="asnDetailImport" parameter="asn.id,imageFile"/>
</actions>
<forwards>
</forwards>
</commit>
</buttons>
</editPage>
</pages>

View File

@ -107,6 +107,8 @@
<forward name="refreshWindow" newEnabled="true" editEnabled="true"/>
</forwards>
</commit>
<popup id="asnDetailImport" title="明细导入" enableType="none" invisible="false" containId="true" pageId="editAsnDetailImportPage"/>
</buttons>
</detail>
</modifyDetailPage>

View File

@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<pages>
<modifyDetailPage id="editXingkanASNPage" title="editXingkanASNPage" entityClass="com.dev.swms.server.model.receiving.ASN" onClose="refreshParent" width="900" height="540">
<modify>
<inputUIs>
<hidden id="asn.status" reserve="false"/>
<hidden id="asn.version" reserve="false"/>
<hidden id="asn.id" reserve="false"/>
<list id="asn.company.id" title="asn.company" row="1" col="1" span="1" width="120" defaultValue="3" readOnly="false" required="true" reserve="false" forceOverride="true">
<hql><![CDATA[select company.id, company.name from Structure company
where company.beCompany = true
and company.disabled=false
and (company.id in (select u.organization.id from UserOrganize u where u.user=#{SESSION_USERS})
or 0=(select COALESCE(max(u.id),0) from UserOrganize u where u.user=#{SESSION_USERS})
)
]]></hql>
</list>
<text id="asn.code" title="asn.code" row="1" col="2" readOnly="true" required="false" reserve="false" forceOverride="false" inVisible="false" trimSpace="true"/>
<date id="asn.orderDate" title="asn.orderDate" row="1" col="3" readOnly="false" required="true" reserve="false" forceOverride="false" inVisible="false" showTime="false" manualEditable="true" defaultCurrentDate="true"/>
<list id="asn.billType.id" title="asn.billType" row="1" col="4" span="1" width="120" readOnly="false" required="true" reserve="false" forceOverride="true">
<hql><![CDATA[select billType.id,billType.name
from BillType billType
where 1=1
and billType.disabled=false
and billType.type='RECEIVE'
]]></hql>
</list>
<text id="asn.relatedBill1" title="入库通知单编号" row="2" col="1" readOnly="false" required="true" reserve="false" forceOverride="false" inVisible="false" trimSpace="true"/>
<text id="asn.fromContact.person" title="contact.person" row="2" col="2" readOnly="false" required="false" reserve="false" forceOverride="false" inVisible="false" trimSpace="true"/>
<text id="asn.fromContact.telephone" title="contact.telephone" row="2" col="3" readOnly="false" required="false" reserve="false" forceOverride="false" inVisible="false" trimSpace="true"/>
<text id="asn.relatedBill2" title="合同号" row="2" col="4" readOnly="false" required="false" reserve="false" forceOverride="false" inVisible="false" trimSpace="true"/>
<text id="asn.fromAddress.address" title="address.address" row="3" col="1" span="4" width="720" readOnly="false" required="false" reserve="false" forceOverride="false" inVisible="false" length="255" trimSpace="true"/>
<text id="asn.description" title="asn.description" row="4" col="1" span="4" width="720" readOnly="false" required="false" reserve="false" forceOverride="true" inVisible="false" trimSpace="true"/>
</inputUIs>
<buttons>
<commit id="save" title="save" enableType="none" invisible="false">
<enableExpression><![CDATA[${asn.status} == 'OPEN']]></enableExpression>
<mappings>
<mapping id="asn" className="com.dev.swms.server.model.receiving.asn"/>
</mappings>
<actions>
<action managerName="asnManager" methodName="storeASN" parameter="asn"/>
</actions>
<forwards>
<forward name="refreshParent" newEnabled="true" editEnabled="true"/>
<forward name="refreshWindow" newEnabled="true" editEnabled="true"/>
</forwards>
</commit>
</buttons>
</modify>
<detail autoQuery="false">
<datasource><![CDATA[SELECT
asnDetail.id,
asnDetail.lineNo,
asnDetail.dock.code,
asnDetail.item.code,
asnDetail.item.largeClass,
asnDetail.item.centerClass,
asnDetail.item.smallClass,
asnDetail.item.name,
asnDetail.item.specs,
asnDetail.qualityStatus,
asnDetail.lotInfo.propLC1,
asnDetail.expectedQuantity,
asnDetail.receivedQuantity,
asnDetail.lotInfo.propC1,
asnDetail.packageUnit.unit
FROM ASNDetail asnDetail
left join asnDetail.dock
WHERE 1=1
/~asn.id: AND asnDetail.asn.id = {asn.id} ~/
ORDER BY asnDetail.lineNo ASC]]></datasource>
<columns>
<column id="asnDetail.id" title="asnDetail.id" visible="false"/>
<column id="asnDetail.lineNo" title="行号" width="50" visible="true" horizonAlign="left"/>
<column id="asnDetail.dock.code" title="库位号" visible="true" horizonAlign="right"/>
<column id="asnDetail.item.code" title="item.code" visible="true" horizonAlign="left"/>
<column id="item.largeClass" title="item.largeClass" visible="true" horizonAlign="left"/>
<column id="item.centerClass" title="item.centerClass" visible="true" horizonAlign="left"/>
<column id="item.smallClass" title="item.smallClass" visible="true" horizonAlign="left"/>
<column id="asnDetail.item.name" title="item.name" visible="true" horizonAlign="left"/>
<column id="asnDetail.item.specs" title="item.specs" visible="true" horizonAlign="left"/>
<column id="asnDetail.qualityStatus" title="质量状态" width="80" visible="true" horizonAlign="left"/>
<column id="asnDetail.lotInfo.propLC1" title="特殊备注" visible="true" horizonAlign="left"/>
<column id="asnDetail.expectedQuantity" title="asnDetail.expectedQuantity" visible="true" horizonAlign="right"/>
<column id="asnDetail.receivedQuantity" title="收货数量" visible="true" horizonAlign="right"/>
<column id="asnDetail.PO" title="到货日期" visible="true" horizonAlign="left"/>
<column id="asnDetail.packageUnit.unit" title="packageUnit.unit" width="80" visible="true" horizonAlign="left"/>
</columns>
<buttons>
<popup id="newDetail" title="newDetail" enableType="none" invisible="false" containId="false" pageId="editASNDetailPage">
</popup>
<popup id="modify" title="modifyDetail" enableType="single" invisible="false" containId="true" pageId="editASNDetailPage">
<enableExpression><![CDATA[${asnDetail.expectedQuantity} > ${asnDetail.receivedQuantity} ]]></enableExpression>
</popup>
<commit id="deleteDetail" title="deleteDetail" enableType="multi" invisible="false" confirmMessage="editReceivingDocPage.confirm.delete">
<enableExpression><![CDATA[${asnDetail.expectedQuantity} > ${asnDetail.receivedQuantity} ]]></enableExpression>
<mappings>
<mapping id="asn.id" className="long"/>
<mapping id="ids" className="list"/>
</mappings>
<actions>
<action managerName="asnManager" methodName="removeASNDetail" parameter="asn.id,ids"/>
</actions>
<forwards>
<forward name="refreshWindow" newEnabled="true" editEnabled="true"/>
</forwards>
</commit>
</buttons>
</detail>
</modifyDetailPage>
</pages>