package com.sy.coinage.workshop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.sy.coinage.core.util.DateUtils;
import com.sy.coinage.workshop.req.WorkshopEntryReq;
import com.sy.coinage.workshop.req.vo.SerialNumberVO;
import org.springframework.stereotype.Service;

import com.sy.coinage.workshop.dao.WorkshopLogDao;
import com.sy.coinage.workshop.model.*;
import com.sy.coinage.workshop.service.IWorkshopLogService;

import java.text.ParseException;

/**
 * -记录每笔出入库流水表(车间出入库记录)ServiceImpl
 */
@Service
public class WorkshopLogServiceImpl extends ServiceImpl<WorkshopLogDao, WorkshopLog> implements IWorkshopLogService {


    @Override
    public void addWorkshopLog(BaseInfo info, String crownBetweenStr, Integer securitiesId,
                               String securities, String rfid,
                               String serialNumber, Integer deptId, String dept,
                               Integer operatorId, String operator, Integer checkId,
                               String checker, Integer locFrom, Integer locTo, Integer operType, Integer boxNum,
                               Integer piecesTotal) {
        WorkshopLog model = new WorkshopLog();
        if (info != null) {
            model.setGrossWeight(info.getGrossWeight());
            model.setTareWeight(info.getTareWeight());
            model.setWeightor(info.getWeightor());
            model.setWeightTime(info.getNewPrintTime());
//            String time = DateUtils.toString(info.getWeightDate()) + " " + info.getWeightTime();
//            try {
//                model.setWeightTime(DateUtils.toDate(time, DateUtils.TD_YY_MM_DD_HH_mm_ss));
//            } catch (ParseException e) {
//                throw new RuntimeException(e);
//            }
        }
        model.setBoxNum(boxNum);
        model.setPiecesTotal(piecesTotal);
        model.setOpType(operType);
        model.setCrownBetweenStr(crownBetweenStr);
        model.setSecuritiesId(securitiesId);
        model.setSecurities(securities);
        model.setRfid(rfid);
        model.setSerialNumber(serialNumber);
        model.setDeptId(deptId);
        model.setDept(dept);
        model.setOperatorId(operatorId);
        model.setOperatorCn(operator);
        model.setCheckId(checkId);
        model.setChecker(checker);
        model.setLocFrom(locFrom);
        model.setLocTo(locTo);
        this.save(model);
    }
}
