package doumeemes.service.ext.impl;
|
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import doumeemes.biz.system.impl.SystemDictDataBizImpl;
|
import doumeemes.core.exception.BusinessException;
|
import doumeemes.core.model.ApiResponse;
|
import doumeemes.core.model.LoginUserInfo;
|
import doumeemes.core.model.PageData;
|
import doumeemes.core.model.PageWrap;
|
import doumeemes.core.utils.Constants;
|
import doumeemes.core.utils.excel.EasyExcelUtil;
|
import doumeemes.core.utils.redis.RedisUtil;
|
import doumeemes.dao.business.model.*;
|
import doumeemes.dao.ext.AppliancesExtMapper;
|
import doumeemes.dao.ext.dto.QueryAppliancesByManualDTO;
|
import doumeemes.dao.ext.dto.QueryAppliancesExtDTO;
|
import doumeemes.dao.ext.vo.AppliancesExtListVO;
|
import doumeemes.dao.ext.vo.CategoryExtListVO;
|
import doumeemes.dao.system.model.SystemDictData;
|
import doumeemes.service.business.AppliancesService;
|
import doumeemes.service.business.BarcodeParamService;
|
import doumeemes.service.business.impl.*;
|
import doumeemes.service.ext.AppliancesExtService;
|
import doumeemes.service.system.impl.SystemDictDataServiceImpl;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.shiro.SecurityUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* 工装器具信息Service实现
|
* @author 江蹄蹄
|
* @date 2022/04/20 11:01
|
*/
|
@Service
|
public class AppliancesExtServiceImpl implements AppliancesExtService {
|
|
|
@Autowired
|
private RedisTemplate<String, Object> redisTemplate;
|
@Autowired
|
private AppliancesExtMapper appliancesExtMapper;
|
|
|
@Autowired
|
private AppliancesService appliancesService;
|
|
@Autowired
|
private BarcodeParamService barcodeParamService;
|
@Autowired
|
private SystemDictDataBizImpl systemDictDataBizimpl;
|
@Autowired
|
private AppliancesServiceImpl appliancesServiceimpl;
|
@Autowired
|
private WorkorderServiceImpl workorderServiceimpl;
|
|
@Autowired
|
private WorkorderRecordServiceImpl workorderRecordServiceimpl;
|
@Autowired
|
private SystemDictDataServiceImpl systemDictDataServiceimpl;
|
@Autowired
|
private ApplianceChangeServiceImpl applianceChangeServiceimpl;
|
@Autowired
|
private ApplianceChangeDetialServiceImpl applianceChangeDetialServiceimpl;
|
|
@Override
|
public PageData<AppliancesExtListVO> findPage(PageWrap<QueryAppliancesExtDTO> pageWrap) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
pageWrap.getModel().setDeleted(Constants.ZERO);
|
pageWrap.getModel().setRootDepartId(user.getRootDepartment().getRootId());
|
pageWrap.getModel().setDepartId(user.getCurComDepartment().getId());
|
|
PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
|
List<AppliancesExtListVO> result = appliancesExtMapper.selectListByCondition(pageWrap.getModel());
|
List<CategoryExtListVO> clist = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_CATEGORY_KEY+user.getCompany().getId(), ArrayList.class);
|
|
for(int i=0;i<result.size();i++){
|
AppliancesExtListVO appliancesExtListVO=result.get(i);
|
for(int j=0;j<clist.size();j++){
|
CategoryExtListVO categoryExtListVO=clist.get(j);
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateBigId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateBigId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1BigName(categoryExtListVO.getName());
|
}
|
}
|
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateMiddleId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateMiddleId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1MiddleName(categoryExtListVO.getName());
|
}
|
}
|
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateSmallId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateSmallId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1SmallName(categoryExtListVO.getName());
|
}
|
}
|
|
}
|
}
|
|
return PageData.from(new PageInfo<>(result));
|
}
|
|
@Override
|
public AppliancesExtListVO findMaxSerial(QueryAppliancesExtDTO pageWrap) {
|
AppliancesExtListVO result = appliancesExtMapper.findMaxSerial(pageWrap);
|
return result;
|
}
|
|
|
@Override
|
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
|
public ApiResponse importExcel(MultipartFile file, String categoryId) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
//获取二维码规则
|
BarcodeParam queryparam=new BarcodeParam();
|
queryparam.setDepartId(user.getCurComDepartment().getId());
|
queryparam.setRootDepartId(user.getRootDepartment().getId());
|
queryparam.setType(Constants.BARCODEPARAM_TYPE.appliance);
|
BarcodeParam barcodeParam =barcodeParamService.findOne(queryparam);
|
if(barcodeParam==null){
|
return ApiResponse.failed("请先完善二维码篮筐配置");
|
}
|
|
List<Appliances> alllist = EasyExcelUtil.importExcel(file, 1, 1, Appliances.class);
|
// List<Appliances> alllist = ExcelExporter.build(Appliances.class).readExcel(null, Appliances.class, file);
|
if(StringUtils.isEmpty(categoryId)){
|
return ApiResponse.failed("工装类型不能为空");
|
}
|
//查询编码是否存在
|
try{
|
for(int i=0;i<alllist.size();i++){
|
Appliances chriApp=alllist.get(i);
|
if(StringUtils.isEmpty(chriApp.getCode())){
|
throw new RuntimeException("编码不能为空");
|
}
|
|
if(StringUtils.isEmpty(chriApp.getTypeName())){
|
throw new RuntimeException("工装属性不能为空");
|
}
|
|
List<SystemDictData> dicList= systemDictDataBizimpl.queryDataByCode("SYSTEM_APPLIANCE_TYPE",chriApp.getTypeName());
|
|
if(dicList==null||dicList.size()<=0){
|
throw new RuntimeException("工装属性不存在");
|
}
|
|
Appliances query1=new Appliances();
|
query1.setDeleted(Constants.ZERO);
|
// query1.setCategoryId(Integer.valueOf(categoryId));
|
query1.setDepartId(user.getCurComDepartment().getId());
|
query1.setRootDepartId(user.getRootDepartment().getId());
|
query1.setCode(chriApp.getCode());
|
List<Appliances> queryData1= appliancesService.findList(query1);
|
if(queryData1.size()>0){
|
throw new RuntimeException(chriApp.getCode()+"编码已存在,不允许插入");
|
}
|
|
//获取工装属性
|
Appliances appliances=new Appliances();
|
appliances.setBrcode(barcodeParam.getId());
|
appliances.setDeleted(Constants.ZERO);
|
appliances.setDepartId(user.getCurComDepartment().getId());
|
appliances.setRootDepartId(user.getRootDepartment().getId());
|
appliances.setCreateUser(user.getId());
|
appliances.setCreateTime(new Date());
|
appliances.setStatus(Constants.APPLIANCES_STATUS.empty);
|
appliances.setCategoryId(Integer.valueOf(categoryId));
|
appliances.setType(dicList.get(0).getId());
|
appliances.setCode(chriApp.getCode());
|
// appliances.setCategoryId(Integer.valueOf(categoryId));
|
appliancesService.insertDate(appliances);
|
}
|
}catch (Exception e){
|
e.printStackTrace();
|
return ApiResponse.failed(e.getMessage());
|
}
|
return ApiResponse.success(null);
|
}
|
|
@Override
|
public List<AppliancesExtListVO> selectListByCondition(QueryAppliancesExtDTO pageWrap) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
pageWrap.setDeleted(Constants.ZERO);
|
pageWrap.setRootDepartId(user.getRootDepartment().getRootId());
|
pageWrap.setDepartId(user.getCurComDepartment().getId());
|
List<AppliancesExtListVO> result = appliancesExtMapper.selectListByCondition(pageWrap);
|
List<CategoryExtListVO> clist = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_CATEGORY_KEY+user.getCompany().getId(), ArrayList.class);
|
|
for(int i=0;i<result.size();i++){
|
AppliancesExtListVO appliancesExtListVO=result.get(i);
|
for(int j=0;j<clist.size();j++){
|
CategoryExtListVO categoryExtListVO=clist.get(j);
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateBigId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateBigId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1BigName(categoryExtListVO.getName());
|
}
|
}
|
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateMiddleId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateMiddleId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1MiddleName(categoryExtListVO.getName());
|
}
|
}
|
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateSmallId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateSmallId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1SmallName(categoryExtListVO.getName());
|
}
|
}
|
|
}
|
}
|
|
return result;
|
}
|
|
|
|
@Override
|
public ApiResponse<List<AppliancesExtListVO>> getApplianceListByCondition(QueryAppliancesExtDTO pageWrap) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
pageWrap.setDeleted(Constants.ZERO);
|
pageWrap.setRootDepartId(user.getRootDepartment().getRootId());
|
pageWrap.setDepartId(user.getCurComDepartment().getId());
|
List<AppliancesExtListVO> result = appliancesExtMapper.selectListByCondition(pageWrap);//第一个旧篮筐
|
|
List<CategoryExtListVO> clist = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_CATEGORY_KEY+user.getCompany().getId(), ArrayList.class);
|
|
for(int i=0;i<result.size();i++){
|
AppliancesExtListVO appliancesExtListVO=result.get(i);
|
for(int j=0;j<clist.size();j++){
|
CategoryExtListVO categoryExtListVO=clist.get(j);
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateBigId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateBigId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1BigName(categoryExtListVO.getName());
|
}
|
}
|
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateMiddleId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateMiddleId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1MiddleName(categoryExtListVO.getName());
|
}
|
}
|
|
if(StringUtils.isNotEmpty(appliancesExtListVO.getCumodelCateSmallId())){
|
if(Constants.equalsInteger(Integer.valueOf(appliancesExtListVO.getCumodelCateSmallId()),categoryExtListVO.getId())){
|
appliancesExtListVO.setCmodel1SmallName(categoryExtListVO.getName());
|
}
|
}
|
|
}
|
}
|
|
|
|
return ApiResponse.success(result);
|
}
|
|
|
@Override
|
@Transactional
|
public ApiResponse chageApplicance(Integer oldId, Integer newId) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
Appliances result = appliancesServiceimpl.findById(oldId);//旧篮筐
|
if(result!=null&&result.getStatus()!=0&&result.getStatus()!=1){
|
Appliances result1 = appliancesServiceimpl.findById(newId);//新篮筐
|
if(result1!=null&&result1.getStatus()==1){
|
if(result.getType()!=result1.getType()){
|
return ApiResponse.failed("工装属性不相同,请检查后再试");
|
}
|
result1.setValidTime(result.getValidTime());
|
result1.setStatus(result.getStatus());
|
result1.setWorkorderId(result.getWorkorderId());
|
result1.setMaterialId(result.getMaterialId());
|
result1.setNum(result.getNum());
|
result1.setPositionType(result.getPositionType());
|
result1.setWarehouseId(result.getWarehouseId());
|
result1.setLocationId(result.getLocationId());
|
result1.setProcedureId(result.getProcedureId());
|
result1.setCurObjId(result.getCurObjId());
|
result1.setCurObjType(result.getCurObjType());
|
appliancesServiceimpl.updateById(result1);
|
|
result1.setValidTime(null);
|
result.setStatus(Constants.ONE);
|
result.setWorkorderId(null);
|
result.setMaterialId(null);
|
result.setNum(new BigDecimal(Constants.ZERO));
|
result.setPositionType(null);
|
result.setWarehouseId(null);
|
result.setLocationId(null);
|
result.setProcedureId(null);
|
result.setCurObjId(null);
|
result.setCurObjType(null);
|
appliancesServiceimpl.updateById(result);
|
}else{
|
return ApiResponse.failed("工装不为空,请从新扫描");
|
}
|
}else{
|
return ApiResponse.failed("旧工装不可用");
|
}
|
return ApiResponse.success(null);
|
}
|
|
|
|
@Override
|
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
|
public ApiResponse chageApplicance(QueryAppliancesExtDTO query) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
BigDecimal oldnum= new BigDecimal(0);
|
BigDecimal newnum= new BigDecimal(0);
|
Integer type=null;
|
Integer workorderId=null;
|
Boolean workorderBoo=true;//标识旧篮筐是否是同一工单
|
if(query.getOldList()!=null&&query.getOldList().size()>0){
|
for(int i=0;i<query.getOldList().size();i++){
|
Appliances data=query.getOldList().get(i);
|
Appliances app= appliancesService.findById(data.getId());
|
if(i==0){
|
type=app.getType();
|
workorderId=app.getWorkorderId();
|
}
|
if(!Constants.equalsInteger(app.getType(),type)){
|
return ApiResponse.failed(app.getCode()+":新旧篮筐篮筐属性不相同,不允许更换");
|
}
|
if(app.getWarehouseId()==null){
|
return ApiResponse.failed(app.getCode()+":旧工装不在仓库不允许更换");
|
}
|
if(Constants.equalsInteger(app.getStatus(),0)||Constants.equalsInteger(app.getStatus(),1)){
|
return ApiResponse.failed(app.getCode()+":旧篮筐报废或空时,不允许更换");
|
}
|
if(!Constants.equalsInteger(app.getRootDepartId(),user.getRootDepartment().getId())){
|
return ApiResponse.failed(app.getCode()+":非当前组织下篮筐不允许更换");
|
}
|
if(!Constants.equalsInteger(app.getDepartId(),user.getCurComDepartment().getId())){
|
return ApiResponse.failed(app.getCode()+":非当前组织下篮筐不允许更换");
|
}
|
oldnum=oldnum.add(app.getNum());
|
|
if( !pdworkorder(app.getWorkorderId(),app.getId(),user)){
|
return ApiResponse.failed("工装["+app.getCode()+"]有生产记录,当前无法进行更换;");
|
}
|
|
SystemDictData systemDictData= systemDictDataServiceimpl.findById(app.getType());
|
if(StringUtils.equals(systemDictData.getLabel(),"APPLIANCE_USELESS")){
|
//报废
|
if(!oldlkBF(query.getOldList())){
|
return ApiResponse.failed("旧工装["+app.getCode()+"]属性为报废,更换时,需要旧篮筐的物料编码、最近加工工序、批次号、仓库、库位都相同,才能一起更换");
|
}
|
}else{
|
//非报废
|
if(!oldlkFBF(query.getOldList())){
|
return ApiResponse.failed("旧工装["+app.getCode()+"]属性为非报废,更换时,需要旧篮筐的物料编码、批次号、质量属性、最近加工工序、返工返修工序、申请单编号(返工返修/报废申请)、客返单号、仓库、库位都相同,才能一起更换");
|
}
|
}
|
|
if(!Constants.equalsInteger(workorderId,app.getWorkorderId())){
|
workorderBoo=false;
|
}
|
}
|
}else{
|
return ApiResponse.failed("旧工装不能为空");
|
}
|
|
|
if(query.getNewList()!=null&&query.getNewList().size()>0){
|
for(int j=0;j<query.getNewList().size();j++){
|
Appliances data=query.getNewList().get(j);
|
Appliances app1= appliancesService.findById(data.getId());
|
|
|
Boolean compareNewOrOld=true;
|
//新篮筐里面可以包含旧篮筐
|
for(int o=0;o<query.getOldList().size();o++) {
|
Appliances comparolddata = query.getOldList().get(o);
|
Appliances comparoldapp1= appliancesService.findById(comparolddata.getId());
|
if(Constants.equalsInteger(comparoldapp1.getId(),app1.getId())){
|
compareNewOrOld=false;
|
}
|
}
|
if(compareNewOrOld){
|
if(!Constants.equalsInteger(app1.getStatus(),1)){
|
return ApiResponse.failed(app1.getCode()+":新篮筐为非空篮筐不允许更换");
|
}
|
}
|
|
if(!Constants.equalsInteger(app1.getRootDepartId(),user.getRootDepartment().getId())){
|
return ApiResponse.failed(app1.getCode()+":非当前组织下篮筐不允许更换");
|
}
|
if(!Constants.equalsInteger(app1.getDepartId(),user.getCurComDepartment().getId())){
|
return ApiResponse.failed(app1.getCode()+":非当前组织下篮筐不允许更换");
|
}
|
newnum=newnum.add(data.getNum());
|
|
if( !pdworkorder(app1.getWorkorderId(),app1.getId(),user)){
|
return ApiResponse.failed("工装["+app1.getCode()+"]有生产记录,当前无法进行更换;");
|
}
|
|
if(!Constants.equalsInteger(app1.getType(),type)){
|
return ApiResponse.failed(app1.getCode()+":新旧篮筐篮筐属性不相同,不允许更换");
|
}
|
}
|
}else{
|
return ApiResponse.failed("新工装不能为空");
|
}
|
|
if(newnum.compareTo(oldnum)!=0){
|
return ApiResponse.failed("新篮筐中物料总数量不等于旧篮筐中物料总数量");
|
}
|
|
|
Appliances olddata= appliancesService.findById(query.getOldList().get(0).getId());
|
//添加更换单记录表
|
Integer acid= insertApplianceChange(olddata,user);
|
|
|
List<Appliances> newappliancelist=new ArrayList<>();
|
List<Appliances> oldappliancelist=new ArrayList<>();
|
|
//查询新篮筐中的数据是否重复
|
Boolean newappliancerepeat=checkRepeatNewApplianceOrNo(query.getNewList());
|
if(newappliancerepeat){
|
return ApiResponse.failed("新工装重复扫描,更换失败!");
|
}
|
for(int z=0;z<query.getNewList().size();z++){
|
Appliances data=query.getNewList().get(z);
|
Appliances app= appliancesService.findById(data.getId());
|
app.setStatus(Constants.APPLIANCES_STATUS.full);
|
app.setUpdateTime(new Date());
|
app.setUpdateUser(user.getId());
|
SystemDictData systemDictData= systemDictDataServiceimpl.findById(olddata.getType());
|
if(StringUtils.equals(systemDictData.getLabel(),"APPLIANCE_USELESS")){
|
//报废
|
|
|
}else{
|
//非报废
|
app.setNextProcedureId(olddata.getNextProcedureId());
|
app.setBackProcedureId(olddata.getBackProcedureId());
|
app.setBackorderId(olddata.getBackorderId());
|
app.setSaleorderId(olddata.getSaleorderId());
|
}
|
|
if(workorderBoo){
|
//相同的workorderid
|
app.setWorkorderId(olddata.getWorkorderId());
|
app.setRelobjType(0);
|
}else{
|
//不相同的workorderid
|
app.setWorkorderId(acid);
|
app.setRelobjType(1);
|
|
}
|
|
if(query.getOldList()!=null&&query.getOldList().size()==1){
|
app.setWorkorderId(olddata.getWorkorderId());
|
app.setRelobjType(olddata.getRelobjType());
|
}
|
|
app.setMaterialId(olddata.getMaterialId());
|
app.setNum(data.getNum());
|
app.setPositionType(olddata.getPositionType());
|
app.setWarehouseId(olddata.getWarehouseId());
|
app.setLocationId(olddata.getLocationId());
|
app.setProcedureId(olddata.getProcedureId());
|
app.setBatch(olddata.getBatch());
|
app.setQualityType(olddata.getQualityType());
|
newappliancelist.add(app);
|
// appliancesService.updateById(app);
|
//更换单详情记录表
|
insertApplianceChangedetail( app, user, 1, acid );
|
}
|
|
|
for(int h=0;h<query.getOldList().size();h++){
|
Appliances data=query.getOldList().get(h);
|
Appliances result= appliancesService.findById(data.getId());
|
|
Boolean cmpar=true;
|
insertApplianceChangedetail( result, user, 0, acid );
|
if(query.getNewList().size()>0){
|
for(int newi=0;newi<query.getNewList().size();newi++){
|
Appliances newcom=query.getNewList().get(newi);
|
//新篮筐包含旧篮筐,旧篮筐中的数据不需要清空
|
if(Constants.equalsInteger(newcom.getId(),result.getId())){
|
cmpar =false;
|
break;
|
}
|
|
}
|
}
|
if(cmpar){
|
result.setStatus(Constants.ONE);
|
result.setWorkorderId(null);
|
result.setMaterialId(null);
|
result.setNum(new BigDecimal(Constants.ZERO));
|
result.setPositionType(null);
|
result.setWarehouseId(null);
|
result.setLocationId(null);
|
result.setProcedureId(null);
|
result.setCurObjId(null);
|
result.setCurObjType(null);
|
// result.setCategoryId(null);
|
result.setBatch(null);
|
result.setQualityType(null);
|
result.setBackorderId(null);
|
result.setSaleorderId(null);
|
result.setBackProcedureId(null);
|
result.setNextProcedureId(null);
|
result.setRelobjType(null);
|
oldappliancelist.add(result);
|
// appliancesExtMapper.editById(result);
|
}
|
|
|
}
|
|
|
|
if(oldappliancelist.size()>0){
|
for(int n=0;n<oldappliancelist.size();n++){
|
Appliances app=oldappliancelist.get(n);
|
appliancesExtMapper.editById(app);
|
}
|
}
|
|
if(newappliancelist.size()>0){
|
for(int n=0;n<newappliancelist.size();n++){
|
Appliances app=newappliancelist.get(n);
|
appliancesService.updateById(app);
|
}
|
|
}
|
|
|
|
|
|
|
|
return ApiResponse.success(null);
|
}
|
|
/**
|
* 如果新篮筐/旧篮筐在工单(未报工状态,包括:已创建、已备料、已检验、已完工)上有投料或报工记录,
|
* 无法更换;需要提示:工装[LK0001]有生产记录,当前无法进行更换;
|
* @param workorderId
|
* @return
|
*/
|
public boolean pdworkorder(Integer workorderId,Integer appliancesId,LoginUserInfo user){
|
|
/* WorkorderRecord workorderRecord=new WorkorderRecord();
|
workorderRecord.setDeleted(Constants.ZERO);
|
workorderRecord.setWorkorderId(workorderId);
|
workorderRecord.setRootDepartId(user.getRootDepartment().getId());
|
workorderRecord.setDepartId(user.getCurComDepartment().getId());
|
List<WorkorderRecord> workrecordList= workorderRecordServiceimpl.findList(workorderRecord);
|
|
Workorder workorder= workorderServiceimpl.findById(workorderId);
|
if(workorder!=null&&(Constants.equalsInteger(workorder.getStatus(),Constants.WORKORDER_STATUS.create)
|
||Constants.equalsInteger(workorder.getStatus(),Constants.WORKORDER_STATUS.material)
|
||Constants.equalsInteger(workorder.getStatus(),Constants.WORKORDER_STATUS.done)
|
||Constants.equalsInteger(workorder.getStatus(),Constants.WORKORDER_STATUS.check))){
|
if(workrecordList!=null&&workrecordList.size()>0){
|
return false;
|
}
|
}else{
|
return true ;//工单不存在直接跳过判断逻辑
|
}
|
*/
|
|
//根据appliance id 查询当前声生产记录里面包含的工单workorderid 的状态是否包含已创建、已备料、已检验、已完工
|
WorkorderRecord wr=new WorkorderRecord();
|
wr.setDeleted(Constants.ZERO);
|
wr.setAppliancesId(appliancesId);
|
wr.setRootDepartId(user.getRootDepartment().getId());
|
wr.setDepartId(user.getCurComDepartment().getId());
|
// wr.setType(1);//产出
|
List<WorkorderRecord> worList= workorderRecordServiceimpl.findList(wr);
|
if(worList!=null&&worList.size()>0){
|
for(int i=0;i<worList.size();i++){
|
WorkorderRecord wrresult=worList.get(i);
|
Workorder woresult= workorderServiceimpl.findById(wrresult.getWorkorderId());
|
if(woresult!=null){
|
if(Constants.equalsInteger(woresult.getStatus(),Constants.WORKORDER_STATUS.create)
|
||Constants.equalsInteger(woresult.getStatus(),Constants.WORKORDER_STATUS.material)
|
||Constants.equalsInteger(woresult.getStatus(),Constants.WORKORDER_STATUS.done)
|
||Constants.equalsInteger(woresult.getStatus(),Constants.WORKORDER_STATUS.check)){
|
return false;
|
}
|
}
|
}
|
}
|
return true ;
|
}
|
|
|
/**
|
* 旧篮筐属性为报废,更换时,需要旧篮筐的物料编码、最近加工工序、批次号、仓库、库位都相同,才能一起更换;
|
* @param oldlist
|
* @return
|
*/
|
public boolean oldlkBF(List<Appliances> oldlist){
|
if(oldlist!=null&&oldlist.size()>0) {
|
Integer materialId=null;
|
Integer nextProcedureId=null;
|
String batch="";
|
Integer warehouseId=null;
|
Integer locationId=null;
|
for (int i = 0; i < oldlist.size(); i++) {
|
Appliances data = oldlist.get(i);
|
Appliances app = appliancesService.findById(data.getId());
|
if(i==0){
|
materialId= app.getMaterialId();
|
nextProcedureId=app.getNextProcedureId();
|
batch=app.getBatch();
|
warehouseId=app.getWarehouseId();
|
locationId=app.getLocationId();
|
}else{
|
if(Constants.equalsInteger(app.getMaterialId(),materialId)
|
&&Constants.equalsInteger(app.getNextProcedureId(),nextProcedureId)
|
&&StringUtils.equals(app.getBatch(),batch)
|
&&Constants.equalsInteger(app.getWarehouseId(),warehouseId)
|
&&Constants.equalsInteger(app.getLocationId(),locationId)){
|
|
}else{
|
return false;
|
}
|
}
|
}
|
}
|
return true;
|
}
|
|
/**
|
* 如果旧篮筐属性非报废,更换时,需要旧篮筐的物料编码、批次号、质量属性、最近加工工序、返工返修工序、申请单编号(返工返修/报废申请)、客返单号、仓库、库位都相同,才能一起更换;
|
* @param oldlist
|
* @return
|
*/
|
public boolean oldlkFBF(List<Appliances> oldlist){
|
if(oldlist!=null&&oldlist.size()>0) {
|
Integer materialId=null;
|
String batch="";
|
Integer qualityType=null;
|
Integer nextProcedureId=null;
|
|
Integer backProcedureId=null;
|
Integer backorderId=null;
|
Integer saleOrderId=null;
|
Integer warehouseId=null;
|
Integer locationId=null;
|
for (int i = 0; i < oldlist.size(); i++) {
|
Appliances data = oldlist.get(i);
|
Appliances app = appliancesService.findById(data.getId());
|
if(i==0){
|
materialId= app.getMaterialId();
|
nextProcedureId=app.getNextProcedureId();
|
batch=app.getBatch();
|
warehouseId=app.getWarehouseId();
|
locationId=app.getLocationId();
|
qualityType=app.getQualityType();
|
backProcedureId= app.getBackProcedureId();
|
backorderId=app.getBackorderId();
|
saleOrderId=app.getSaleorderId();
|
}else{
|
if(Constants.equalsInteger(app.getMaterialId(),materialId)
|
&&Constants.equalsInteger(app.getNextProcedureId(),nextProcedureId)
|
&&StringUtils.equals(app.getBatch(),batch)
|
&&Constants.equalsInteger(app.getWarehouseId(),warehouseId)
|
&&Constants.equalsInteger(app.getLocationId(),locationId)
|
&&Constants.equalsInteger(app.getQualityType(),qualityType)
|
&&Constants.equalsInteger(app.getBackProcedureId(),backProcedureId)
|
&&Constants.equalsInteger(app.getBackorderId(),backorderId)
|
&&Constants.equalsInteger(app.getSaleorderId(),saleOrderId)){
|
|
}else{
|
return false;
|
}
|
}
|
}
|
}
|
return true;
|
}
|
|
|
//查詢新籃筐中的数据是否重复
|
private Boolean checkRepeatNewApplianceOrNo(List<Appliances> list ) {
|
if(list!=null&&list.size()>1){
|
List<Integer> collect1 = list.stream().map(Appliances::getId).distinct().collect(Collectors.toList());
|
if(collect1.size()!=list.size()){
|
return true;
|
}else{
|
return false;
|
}
|
}else {
|
return false;
|
}
|
}
|
|
|
|
/**
|
* 新增更换单记录
|
* @param olddata
|
* @param user
|
* @return
|
*/
|
public Integer insertApplianceChange(Appliances olddata,LoginUserInfo user){
|
ApplianceChange applianceChange=new ApplianceChange();
|
applianceChange.setDeleted(Constants.ZERO);
|
applianceChange.setCreateTime(new Date());
|
applianceChange.setCreateUser(user.getId());
|
applianceChange.setRootDepartId(user.getRootDepartment().getId());
|
applianceChange.setDepartId(user.getCurComDepartment().getId());
|
applianceChange.setType(olddata.getType());
|
applianceChange.setWarehouseId(olddata.getWarehouseId());
|
applianceChange.setLocationId(olddata.getLocationId());
|
applianceChange.setProcedureId(olddata.getProcedureId());
|
applianceChange.setSaleorderId(olddata.getSaleorderId());
|
applianceChange.setBackProcedureId(olddata.getBackProcedureId());
|
applianceChange.setMaterialId(olddata.getMaterialId()+"");
|
applianceChange.setBatch(olddata.getBatch());
|
String code=applianceChangeServiceimpl.getNextCode(user.getCompany().getId());
|
applianceChange.setCode(code);
|
return applianceChangeServiceimpl.create(applianceChange);
|
}
|
|
|
/**
|
* 工单记录详情添加
|
* mark 标记新篮筐1,0旧篮筐
|
* @param appliances
|
* @param user
|
* @param mark
|
* @return
|
*/
|
|
public Integer insertApplianceChangedetail(Appliances appliances,LoginUserInfo user,Integer mark,Integer changeid ){
|
ApplianceChangeDetial applianceChangedetail=new ApplianceChangeDetial();
|
applianceChangedetail.setDeleted(Constants.ZERO);
|
applianceChangedetail.setCreateTime(new Date());
|
applianceChangedetail.setCreateUser(user.getId());
|
applianceChangedetail.setRootDepartId(user.getRootDepartment().getId());
|
applianceChangedetail.setDepartId(user.getCurComDepartment().getId());
|
applianceChangedetail.setApplianceId(appliances.getId());
|
applianceChangedetail.setType(mark);
|
applianceChangedetail.setMaterialId(appliances.getMaterialId()+"");
|
applianceChangedetail.setBatch(appliances.getBatch());
|
applianceChangedetail.setNum(appliances.getNum().intValue());
|
applianceChangedetail.setWorkorderId(appliances.getWorkorderId());
|
applianceChangedetail.setRelobjType(appliances.getRelobjType());
|
applianceChangedetail.setChaneId(changeid);
|
return applianceChangeDetialServiceimpl.create(applianceChangedetail);
|
}
|
|
|
|
@Override
|
public PageData<AppliancesExtListVO> findListPageForManual(PageWrap<QueryAppliancesByManualDTO> pageWrap) {
|
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
|
pageWrap.getModel().setRootDepartId(user.getRootDepartment().getRootId());
|
pageWrap.getModel().setDepartId(user.getCurComDepartment().getId());
|
PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
|
List<AppliancesExtListVO> result = appliancesExtMapper.findListPageForManual(pageWrap.getModel());
|
return PageData.from(new PageInfo<>(result));
|
}
|
|
|
}
|