|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.vincent.rsf.framework.common.R; | 
|---|
|  |  |  | import com.vincent.rsf.framework.common.SpringUtils; | 
|---|
|  |  |  | import com.vincent.rsf.framework.exception.CoolException; | 
|---|
|  |  |  | import com.vincent.rsf.server.common.domain.BaseParam; | 
|---|
|  |  |  | import com.vincent.rsf.server.common.domain.PageParam; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.service.MatnrGroupService; | 
|---|
|  |  |  | import com.vincent.rsf.server.manager.service.MatnrService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.vincent.rsf.server.system.entity.Fields; | 
|---|
|  |  |  | import com.vincent.rsf.server.system.service.FieldsService; | 
|---|
|  |  |  | import com.vincent.rsf.server.system.constant.SerialRuleCode; | 
|---|
|  |  |  | import com.vincent.rsf.server.system.utils.SerialRuleUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public IPage<Map<String, Object>> getMatnrPage(PageParam<Matnr, BaseParam> pageParam) { | 
|---|
|  |  |  | IPage<Map<String, Object>> reulst = this.baseMapper.selectMatnrs(pageParam, pageParam.buildWrapper(true)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /**获取物料分页信息 */ | 
|---|
|  |  |  | List<Map<String, Object>> mapList = reulst.getRecords(); | 
|---|
|  |  |  | if (!mapList.isEmpty()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | //        page.setRecords(records); | 
|---|
|  |  |  | return reulst; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @desc 更新扩展物料扩展字段值 | 
|---|
|  |  |  | * @param matnr | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public R saveMatnrs(Map<String, Object> matnr) { | 
|---|
|  |  |  | Matnr matnr1 = JSONObject.parseObject(JSONObject.toJSONString(matnr), Matnr.class); | 
|---|
|  |  |  | if (Objects.isNull(matnr1.getCode())) { | 
|---|
|  |  |  | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_MATNR_CODE, null); | 
|---|
|  |  |  | System.out.println("=========>"); | 
|---|
|  |  |  | System.out.println(ruleCode); | 
|---|
|  |  |  | matnr1.setCode(ruleCode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 扩展字段存入库 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | String uuid16 = CommonUtil.randomUUID16(); | 
|---|
|  |  |  | if (!FieldsUtils.getFieldsSta().isEmpty()) { | 
|---|
|  |  |  | FieldsUtils.saveFields(matnr, uuid16); | 
|---|
|  |  |  | matnr1.setFieldsIndex(uuid16); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!this.save(matnr1)) { | 
|---|
|  |  |  | return R.error("Save Fail"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("保存成功!!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|