| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.Task.SyncOrder; |
| | | import com.yuanchu.mom.mapper.*; |
| | | import com.yuanchu.mom.pojo.*; |
| | | import com.yuanchu.mom.pojo.vo.RawInsProductVo; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Resource |
| | | UserMapper userMapper; |
| | | |
| | | //新增原材料检验单-->根据原材料编码得到ifs中的报检数据 |
| | | @Override |
| | | public RawInspectVo chooseIFS(String code) { |
| | | RawInspectVo rawInspectVo = new RawInspectVo(); |
| | | List<Map<String, Object>> mapList = SyncOrder.ifsInterfaces(); |
| | | for (Map<String, Object> map : mapList) { |
| | | //todo: 后续需要将状态改成待检验 |
| | | if (map.get("STATE").equals("已接收")) { |
| | | if (map.get("PART_NO").toString().equals(code)) { |
| | | rawInspectVo.setCode(map.get("PART_NO").toString()); //原材料编码 |
| | | String[] split = map.get("PART_DESC").toString().split(","); |
| | | rawInspectVo.setName(split[0]); //原材料名称 |
| | | rawInspectVo.setSpecifications(split[1]); //型号规格 |
| | | rawInspectVo.setUnit(map.get("BUY_UNIT_MEAS").toString()); //单位 |
| | | rawInspectVo.setNumber(Integer.parseInt(String.valueOf(map.get("QTY_TO_INSPECT")))); //数量 |
| | | rawInspectVo.setFormTime(DateUtil.parse(map.get("APPROVED_DATE").toString())); //来料日期 |
| | | rawInspectVo.setSupplier(map.get("SUPPLIER_NAME").toString()); //供应商 |
| | | } |
| | | } |
| | | } |
| | | //查询该原材料是否有检验项目记录 |
| | | RawInspect rawInspect = rawInspectMapper.selOneByCode(code); |
| | | if (ObjectUtils.isNotEmpty(rawInspect)){ |
| | | List<RawInsProduct> rawInsProductList = rawInsProductMapper.selectList(Wrappers.<RawInsProduct>query().eq("raw_inspect_id", rawInspect.getId())); |
| | | List<RawInsProductVo> rawInsProductVos = rawInsProductList.stream().map(rawInsProduct -> { |
| | | RawInsProductVo rawInsProductVo = new RawInsProductVo(); |
| | | rawInsProductVo.setName(rawInsProduct.getName()); |
| | | rawInsProductVo.setUnit(rawInsProduct.getUnit()); |
| | | rawInsProductVo.setRequired(rawInsProduct.getRequired()); |
| | | rawInsProductVo.setInternal(rawInsProduct.getInternal()); |
| | | return rawInsProductVo; |
| | | }).collect(Collectors.toList()); |
| | | rawInspectVo.setRawInsProducts(rawInsProductVos); |
| | | } |
| | | return rawInspectVo; |
| | | } |
| | | |
| | | //新增原材料检验单 |
| | | @Override |
| | |
| | | String testValue = rawInsProduct.getTestValue();//检测值 |
| | | char req = required.charAt(0); |
| | | List<Integer> list = Arrays.stream(testValue.split(",")).map(s -> { |
| | | int values=2; |
| | | int values = 2; |
| | | if (req == '>' || req == '<' || req == '=') { |
| | | values = checkValues(required, internal, s); |
| | | }else { |
| | | } else { |
| | | values = conValues(required, internal, s); |
| | | } |
| | | return values; |
| | |
| | | //更新检验状态(上报) |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String updateRawInspectsById(Integer id) { |
| | | public String updateRawInspectsById(Integer id,Integer number) { |
| | | /*更新检验单里面的检验结论*/ |
| | | //先判断检验结果 |
| | | List<Integer> results = rawInsProductMapper.getresult(id); |
| | |
| | | if (rawInspect.getJudgeState() == 0) { |
| | | InspectUnaccepted rawUnaccepted = InspectUnaccepted.builder() |
| | | .reason(rawInspectMapper.selectById(id).getName() + "不合格") //暂且定义为原材料不合格 |
| | | .number(number) |
| | | .rawInspectId(id) |
| | | .type(0) //类型为原材料 |
| | | .build(); |
| | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //如果是> , < ,=的操作 |
| | | private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) { |
| | | boolean isStandardValueSatisfied = isValueSatisfied(standardValueStr, detectionValueStr); |