发票箱单格式导入

main
FOAM 2025-09-10 10:33:46 +08:00
parent 0f1069cac3
commit e2d7da9938
15 changed files with 310 additions and 19 deletions

View File

@ -59,6 +59,6 @@ public interface AreaRepository extends JpaRepository<Area, Long>, JpaSpecificat
@Query(value = "SELECT * FROM base_area t where t.code in ('A仓','S仓')", nativeQuery = true) @Query(value = "SELECT * FROM base_area t where t.code in ('A仓','S仓')", nativeQuery = true)
List<Area> getBomOutAreas(); List<Area> getBomOutAreas();
@Query("from Area i where i.name in (:codes) and i.enabled=true ") @Query("from Area i where (i.name in (:codes) or i.code in (:codes) ) and i.enabled=true ")
List<Area> queryByAreaCodes(List<String> codes); List<Area> queryByAreaCodes(List<String> codes);
} }

View File

@ -59,9 +59,7 @@ public interface ProductionPlanRepository extends JpaRepository<ProductionPlan,
int existsHyIdno( @Param("make_line") String make_line, @Param("IDNO") String IDNO); int existsHyIdno( @Param("make_line") String make_line, @Param("IDNO") String IDNO);
/**
*
*/
@Query(value = "SELECT * FROM `base_production_plan` bpp where bpp.working_station = :workingStation and bpp.statue='UN_CONSUME' AND bpp.`IDNO`>= :IDNO order by bpp.`IDNO` ASC", nativeQuery = true) @Query(value = "SELECT * FROM `base_production_plan` bpp where bpp.working_station = :workingStation and bpp.statue='UN_CONSUME' AND bpp.`IDNO`>= :IDNO order by bpp.`IDNO` ASC", nativeQuery = true)
List<ProductionPlan> getAllData(@Param("workingStation") String workingStation, @Param("IDNO")String IDNO); List<ProductionPlan> getAllData(@Param("workingStation") String workingStation, @Param("IDNO")String IDNO);
@ -80,4 +78,12 @@ public interface ProductionPlanRepository extends JpaRepository<ProductionPlan,
@Query(value = "SELECT max(bpp.IDNO) FROM `base_production_plan` bpp where bpp.working_station = :workingStation and bpp.statue='UN_CONSUME'", nativeQuery = true) @Query(value = "SELECT max(bpp.IDNO) FROM `base_production_plan` bpp where bpp.working_station = :workingStation and bpp.statue='UN_CONSUME'", nativeQuery = true)
String getIdNoWhyScGw( @Param("workingStation") String workingStation); String getIdNoWhyScGw( @Param("workingStation") String workingStation);
@Query(value = "SELECT count(id) FROM base_production_plan p WHERE p.IDNO >= :IDNO and p.working_station =:workingStation and p.statue!='UN_CONSUME'", nativeQuery = true)
int existsGwHyIdno( @Param("IDNO") String IDNO,@Param("workingStation") String workingStation);
@Query(value = "SELECT * FROM base_production_plan p WHERE p.idno >= :idno and p.working_station =:workingStation", nativeQuery = true)
List<ProductionPlan> findByGwIdnoList(@Param("idno") String idno,@Param("workingStation") String workingStation);
} }

View File

@ -0,0 +1,11 @@
package com.youchain.basicdata.service;
import org.springframework.web.multipart.MultipartFile;
public interface ImportProductionPlanService {
/**
*
* @param file
*/
void importData(MultipartFile file);
}

View File

@ -37,5 +37,6 @@ public class BomAccountPointDto implements Serializable {
private String gw_name; private String gw_name;
private Long zzkw_id; private Long zzkw_id;
private String zzkw_code; private String zzkw_code;
private String bonded;
} }

View File

@ -216,12 +216,12 @@ public class BomAccountServiceImpl implements BomAccountService {
public List<BomAccountPointDto> queryBomAccountPoints() { public List<BomAccountPointDto> queryBomAccountPoints() {
String sql = "select max(ba.id) bom_account_id,max(rk.id) rk_id,max(rk.code) gw_code,max(rk.name) gw_name," + String sql = "select max(ba.id) bom_account_id,max(rk.id) rk_id,max(rk.code) gw_code,max(rk.name) gw_name," +
"max(it.id) item_id,max(it.code) item_code,max(it.name) item_name,max(p.id) zzkw_id,max(p.code) zzkw_code,\n" + "max(it.id) item_id,max(it.code) item_code,max(it.name) item_name,max(p.id) zzkw_id,max(p.code) zzkw_code,\n" +
"max(it.extend_d3) srs \n" + "max(it.extend_d3) srs,max(ba.bonded) bonded \n" +
"from base_bom_account ba \n" + "from base_bom_account ba \n" +
"LEFT JOIN base_item it on it.id=ba.item_id\n" + "LEFT JOIN base_item it on it.id=ba.item_id\n" +
"LEFT JOIN base_area rk on rk.id=ba.r_area_id\n" + "LEFT JOIN base_area rk on rk.id=ba.r_area_id\n" +
"left join base_point p on p.id=ba.z_point_id\n" + "left join base_point p on p.id=ba.z_point_id\n" +
"GROUP BY ba.r_area_id,ba.item_id,ba.z_point_id"; "GROUP BY ba.r_area_id,ba.item_id,ba.z_point_id,ba.bonded";
log.info("sql==="+sql); log.info("sql==="+sql);
List ts = entityManager.createNativeQuery(sql) List ts = entityManager.createNativeQuery(sql)
.unwrap(SQLQuery.class) .unwrap(SQLQuery.class)

View File

@ -155,7 +155,8 @@ public class ImportAsnServiceImpl implements ImportAsnService {
String po = data.getPoNo();//订单号 String po = data.getPoNo();//订单号
String itemCode = data.getPartNo();//品番 String itemCode = data.getPartNo();//品番
String remark = data.getDescription();//描述 String remark = data.getDescription();//描述
String orderQty = data.getQty();//数量 String orderQty = data.getQty().replace(",","");//数量,去掉逗号格式
String code = data.getCNo();//托盘号 String code = data.getCNo();//托盘号
//品番 //品番
Item item = exitItemMap.get(itemCode.replace("-", "")); Item item = exitItemMap.get(itemCode.replace("-", ""));

View File

@ -0,0 +1,153 @@
package com.youchain.basicdata.service.impl;
import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.BigItem;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.ProductionPlan;
import com.youchain.basicdata.repository.AreaRepository;
import com.youchain.basicdata.repository.BigItemRepository;
import com.youchain.basicdata.repository.ItemRepository;
import com.youchain.basicdata.repository.ProductionPlanRepository;
import com.youchain.basicdata.service.*;
import com.youchain.businessdata.inputJson.imports.ItemImport;
import com.youchain.businessdata.inputJson.imports.ProductionPlanImport;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
@Slf4j
public class ImportProductionPlanServiceImpl implements ImportProductionPlanService {
private final BigItemRepository bigItemRepository;
private final ProductionPlanRepository productionPlanRepository;
private final AreaRepository areaRepository;
private final ProductionPlanService productionPlanService;
private final BigItemService bigItemService;
private final AreaService areaService;
@Override
@Transactional(rollbackFor = Exception.class)
public void importData(MultipartFile file) {
// 验证模板类型是否正确
isValidTemplateType(file);
// 根据模板类型进行不同的处理
baseImportTemplate(file);
}
// 处理标准模板
@Transactional
public void baseImportTemplate(MultipartFile file) {
// 读取sheet数据
List<ProductionPlanImport> dataList = FastExcelUtil.readExcelData(file, ProductionPlanImport.class, 0, 1);
//批量导入
importProductionPlanData(dataList);
}
/**
*
*/
private void importProductionPlanData(List<ProductionPlanImport> dataList) {
// TODO: 实现批量导入逻辑
log.info("处理批量导入,数据条数: {}", dataList.size());
//获取文件中所有的库位编码
List<String> bigitemcodes = dataList.stream().map(ProductionPlanImport::getBigItemCode).collect(Collectors.toList());
bigitemcodes = bigitemcodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
Map<String, BigItem> exitBigItemMap = bigItemService.queryByBigItemCodesToMap(bigitemcodes);
List<String> areaNames = dataList.stream().map(ProductionPlanImport::getZcdx).collect(Collectors.toList());
areaNames = areaNames.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
Map<String, Area> exitAreaMap = areaService.queryByAreaCodesToMap(areaNames);
//得到每个工位最小序号查找最小序号IDNO是否有已消耗数据有则异常没有则删除导入新数据
HashMap<String,String> maps=new HashMap<>();
for (ProductionPlanImport data : dataList) {
String zcdx=data.getZcdx();
String IDNO=data.getKyh();
String makeLine=data.getMakeLine();
if(!maps.containsKey(zcdx+makeLine)){
maps.put(zcdx+makeLine,IDNO);
int hyCount = productionPlanRepository.existsGwHyIdno(IDNO,zcdx);
if (hyCount > 0) {
throw new BadRequestException( "大于" + IDNO + "存在已耗用数据");
} else {
List<ProductionPlan> productionPlans = productionPlanRepository.findByGwIdnoList(IDNO ,zcdx);
productionPlanRepository.deleteAll(productionPlans);
}
}
}
Map<String, Long> map = new HashMap<String, Long>();//制造线,序号
for (ProductionPlanImport data : dataList) {
String zcdx=data.getZcdx();
String IDNO=data.getKyh();
String makeLine=data.getMakeLine();
Area area=exitAreaMap.get(zcdx);
Long orderNo =1L;
List<ProductionPlan> idnoList = productionPlanRepository.findByIDNO(IDNO);
if (!idnoList.isEmpty()) {
orderNo = idnoList.get(0).getOrderNo();
} else {
orderNo = productionPlanRepository.getMaxOrderNo();
if (orderNo==null) {
map.put(makeLine, 1L);
}else{
orderNo=orderNo+1;
}
}
BigItem bigItem = exitBigItemMap.get(data.getBigItemCode());
ProductionPlan productionPlan = new ProductionPlan();
productionPlan.setBigItem(bigItem);
productionPlan.setType(bigItem.getOutboundType());
productionPlan.setWorkingStation(zcdx);
productionPlan.setRkArea(area);
productionPlan.setDept(UserUtils.getDept());
productionPlan.setEnabled(true);
productionPlan.setNo(Integer.valueOf(data.getXh()));
productionPlan.setMakeLine(makeLine);
productionPlan.setDownlineDate( new Timestamp(DateUtil.ymd_date(data.getHjOut()).getTime()));
productionPlan.setIdno(IDNO);
productionPlan.setImportDate(new Timestamp (new Date ().getTime()));
productionPlan.setStatue(BizStatus.UN_CONSUME);
productionPlan.setOrderNo(orderNo);
productionPlanRepository.save(productionPlan);
}
}
//验证模板是否使用正确
private void isValidTemplateType(MultipartFile file) {
// 根据模板类型进行不同的处理
List<String> requiredColumns = Arrays.asList(
"ライン№",
"序号",
"ID NO.\n" + "/刻印号",
"机型代码",
"机型名称",
"工件",
"焊接OUT",
"对象职场"
);
List<String> headers = FastExcelUtil.readHeadContent(file, 0, 0);
if (!SmartStringUtil.containsAllIgnoreCase(requiredColumns, headers)) {
throw new BadRequestException("标准导入模板不正确,请确认模板信息");
}
}
}

View File

@ -192,7 +192,7 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
} }
public void scsxHaoyong(List<ProductionPlan> productionPlans,String gw,String des){ public void scsxHaoyong(List<ProductionPlan> productionPlans,String gw,String des){
for (ProductionPlan productionPlan: productionPlans){ for (ProductionPlan productionPlan: productionPlans){
productionPlan.setStatue("CONSUME"); productionPlan.setStatue(BizStatus.CONSUME);
productionPlan.setTakeUpTime(new Timestamp(new Date().getTime())); productionPlan.setTakeUpTime(new Timestamp(new Date().getTime()));
this.update(productionPlan); this.update(productionPlan);
} }

View File

@ -0,0 +1,44 @@
package com.youchain.businessdata.inputJson.imports;
import cn.idev.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description:
* @author: youzhi.gao
* @date: 2020-04-01 15:01
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProductionPlanImport {
@ExcelProperty("ライン№")
private String makeLine;
@ExcelProperty("序号")
private String xh;
@ExcelProperty("ID NO.\n" + "/刻印号")
private String kyh;
@ExcelProperty("机型代码")
private String bigItemCode;
@ExcelProperty("机型名称")
private String bigItemName;
@ExcelProperty("工件")
private String gj;
@ExcelProperty("焊接OUT")
private String hjOut;
@ExcelProperty("对象职场")
private String zcdx;
}

View File

@ -39,6 +39,10 @@ public interface PickDetailRepository extends JpaRepository<PickDetail, Long>, J
@Query(value = "SELECT * FROM `data_pick_detail` a WHERE prop_c3 = :propC3 ", nativeQuery = true) @Query(value = "SELECT * FROM `data_pick_detail` a WHERE prop_c3 = :propC3 ", nativeQuery = true)
PickDetail queryByPropC3(@Param("propC3")String propC3); PickDetail queryByPropC3(@Param("propC3")String propC3);
@Query(value = "SELECT * FROM `data_pick_detail` d WHERE d.type='ZZJL' and d.picked_qty=0", nativeQuery = true)
List<PickDetail> notPickList();
/** /**
* 0 * 0
* @param id * @param id

View File

@ -284,14 +284,32 @@ public class PickDetailController {
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@PostMapping("/zzjlCountList")
@Log("制造叫料拣货列表汇总")
@ApiOperation("制造叫料拣货列表汇总")
@AnonymousAccess
public ResponseEntity<Object> zzjlCountList(@RequestBody HashMap map) throws Exception {
List<PickDetail> ds=pickDetailRepository.notPickList();
for(PickDetail pickDetail:ds) {
//无库存数据分配
if (pickDetail.getAllocatedQty() < pickDetail.getOrderQty()) {
pickDetailService.allocate(pickDetail.getId(), pickDetail.getOrderQty() - pickDetail.getAllocatedQty(), pickDetail.getPo(), BaseStatus.ZZJL);
}
}
//查询叫料返回数据
List<ZzjlPickCountList> list=pickDetailService.queryZzjlPickCountList();
return new ResponseEntity<>(list,HttpStatus.OK);
}
@PostMapping("/zzjlList") @PostMapping("/zzjlList")
@Log("制造叫料拣货列表") @Log("制造叫料拣货列表")
@ApiOperation("制造叫料拣货列表") @ApiOperation("制造叫料拣货列表")
@AnonymousAccess @AnonymousAccess
public ResponseEntity<Object> zzjlList(@RequestBody HashMap map) throws Exception { public ResponseEntity<Object> zzjlList(@RequestBody HashMap map) throws Exception {
String itemCode=map.get("itemCode")==null?null:map.get("itemCode").toString(); String itemCode=map.get("itemCode")==null?null:map.get("itemCode").toString();
String areaName=map.get("area_name")==null?null:map.get("area_name").toString();
//查询叫料返回数据 //查询叫料返回数据
List<ZzjlPickList> list=pickDetailService.queryZzjlPickList(itemCode); List<ZzjlPickList> list=pickDetailService.queryZzjlPickList(itemCode,areaName);
return new ResponseEntity<>(list,HttpStatus.OK); return new ResponseEntity<>(list,HttpStatus.OK);
} }

View File

@ -0,0 +1,17 @@
package com.youchain.businessdata.returnJson;
import lombok.Data;
@Data
public class ZzjlPickCountList {
/**库区*/
String area_name;
/**数量*/
int order_qty;
/**分配数量*/
int allocated_qty;
/**任务数*/
String count_qty;
}

View File

@ -2,12 +2,16 @@ package com.youchain.businessdata.returnJson;
import lombok.Data; import lombok.Data;
import java.sql.Timestamp;
@Data @Data
public class ZzjlPickList { public class ZzjlPickList {
/**序号*/ /**序号*/
Long detail_id; Long detail_id;
/**库区*/ /**库区*/
String area_name; String area_name;
/**叫料库区*/
String s_area_name;
/**品番*/ /**品番*/
String item_code; String item_code;
/**品名*/ /**品名*/
@ -17,15 +21,15 @@ public class ZzjlPickList {
/**税别*/ /**税别*/
String bonded; String bonded;
/**数量*/ /**数量*/
String order_qty; int order_qty;
/**分配数量*/ /**分配数量*/
String allocated_qty; int allocated_qty;
/**拣货数量*/ /**拣货数量*/
String picked_qty; int picked_qty;
/**创建人*/ /**创建人*/
String create_by; String create_by;
/**创建时间*/ /**创建时间*/
String create_time; Timestamp create_time;
} }

View File

@ -22,6 +22,7 @@ import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.service.dto.BoxDto; import com.youchain.basicdata.service.dto.BoxDto;
import com.youchain.businessdata.domain.PickDetail; import com.youchain.businessdata.domain.PickDetail;
import com.youchain.businessdata.domain.PickTicket; import com.youchain.businessdata.domain.PickTicket;
import com.youchain.businessdata.returnJson.ZzjlPickCountList;
import com.youchain.businessdata.returnJson.ZzjlPickList; import com.youchain.businessdata.returnJson.ZzjlPickList;
import com.youchain.businessdata.service.dto.PickDetailDto; import com.youchain.businessdata.service.dto.PickDetailDto;
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria; import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
@ -170,5 +171,7 @@ public interface PickDetailService {
*/ */
List<PickDetail> getBomList(long picktickId,String largeClass); List<PickDetail> getBomList(long picktickId,String largeClass);
/**查询制造叫料列表*/ /**查询制造叫料列表*/
List<ZzjlPickList> queryZzjlPickList(String itemCode); List<ZzjlPickList> queryZzjlPickList(String itemCode,String areaName);
/**查询制造叫料汇总列表*/
List<ZzjlPickCountList> queryZzjlPickCountList();
} }

View File

@ -28,6 +28,7 @@ import com.youchain.businessdata.repository.InventoryRepository;
import com.youchain.businessdata.repository.PickTicketRepository; import com.youchain.businessdata.repository.PickTicketRepository;
import com.youchain.businessdata.repository.TaskRepository; import com.youchain.businessdata.repository.TaskRepository;
import com.youchain.businessdata.returnJson.RPTaskList; import com.youchain.businessdata.returnJson.RPTaskList;
import com.youchain.businessdata.returnJson.ZzjlPickCountList;
import com.youchain.businessdata.returnJson.ZzjlPickList; import com.youchain.businessdata.returnJson.ZzjlPickList;
import com.youchain.businessdata.service.*; import com.youchain.businessdata.service.*;
import com.youchain.businessdata.service.dto.PickDetailZscDto; import com.youchain.businessdata.service.dto.PickDetailZscDto;
@ -287,7 +288,6 @@ public class PickDetailServiceImpl implements PickDetailService {
if(map!=null&&pickTicket==null){ if(map!=null&&pickTicket==null){
pd.setRemark(map.values().stream() pd.setRemark(map.values().stream()
.collect(Collectors.joining("\n"))); .collect(Collectors.joining("\n")));
log.info(pd.getRemark()+"===="+pd.getType());
pickDetailRepository.save(pd); pickDetailRepository.save(pd);
} }
}else{ }else{
@ -405,13 +405,24 @@ public class PickDetailServiceImpl implements PickDetailService {
return list; return list;
} }
public List<ZzjlPickList> queryZzjlPickList(String itemCode) { public List<ZzjlPickList> queryZzjlPickList(String itemCode,String areaName) {
String sql="SELECT d.id detail_id,a.`name` area_name,it.code item_code,it.name item_name, p.code point_code,d.prop_c2 bonded,d.order_qty,d.allocated_qty,d.picked_qty,d.create_by,d.create_time\n" + String sql="SELECT d.id detail_id,IFNULL(a.name,\"\") area_name,s.`name` s_area_name,it.code item_code,it.name item_name, p.code point_code,d.prop_c2 bonded,d.order_qty,d.allocated_qty,d.picked_qty,d.create_by,d.create_time\n" +
" from data_pick_detail d\n" + " from data_pick_detail d\n" +
" LEFT JOIN base_item it on it.id=d.item_id\n" + " LEFT JOIN base_item it on it.id=d.item_id\n" +
" left JOIN base_point p on p.id=d.point_id\n" + " left JOIN base_point p on p.id=d.point_id\n" +
" left join base_area a on a.id=p.area_id\n" + " left join base_area a on a.id=d.area_id\n" +
" where d.type='ZZJL' and d.picked_qty=0;\n"; " left join base_area s on s.id=d.sh_area_id\n" +
" where 1=1 and d.type='ZZJL' and d.picked_qty=0 ";
if(areaName!=null&&!areaName.equals("")){
sql+= " and a.`name`='"+areaName+"'";
}else{
sql+= " and a.`name` is null";
}
if(itemCode!=null&&!itemCode.equals("")){
sql+= " and it.`code`='"+itemCode+"'";
}
Query query = entityManager.createNativeQuery(sql); Query query = entityManager.createNativeQuery(sql);
List ts= query List ts= query
.unwrap(SQLQuery.class) .unwrap(SQLQuery.class)
@ -423,6 +434,24 @@ public class PickDetailServiceImpl implements PickDetailService {
return list; return list;
} }
public List<ZzjlPickCountList> queryZzjlPickCountList() {
String sql="SELECT IFNULL(ck_area.name,\"\") area_name,sum(d.order_qty) order_qty,sum(d.allocated_qty) allocated_qty ,count(d.id) count_qty\n" +
"from data_pick_detail d\n" +
"left join base_area ck_area on ck_Area.id=d.area_id\n" +
"where d.picked_qty<d.order_qty and d.type='ZZJL' " +
"GROUP BY ck_area.name \n" +
"ORDER BY ck_area.name desc";
Query query = entityManager.createNativeQuery(sql);
List ts= query
.unwrap(SQLQuery.class)
.setResultTransformer(
AliasToEntityMapResultTransformer.INSTANCE
)
.list();
List<ZzjlPickCountList> list = JSON.parseArray(JSON.toJSONString(ts),ZzjlPickCountList.class);
return list;
}
public Map<String,Object> queryPickDetailAll(PickDetailQueryCriteria criteria, Pageable pageable) { public Map<String,Object> queryPickDetailAll(PickDetailQueryCriteria criteria, Pageable pageable) {
int pageNum=pageable.getPageNumber();//当前页 int pageNum=pageable.getPageNumber();//当前页