|
@@ -13,6 +13,7 @@ import com.kexun.model.ro.*;
|
|
|
import com.kexun.model.vo.FieldVO;
|
|
|
import com.kexun.model.vo.FiledTemplateVO;
|
|
|
import com.kexun.service.CooperatorService;
|
|
|
+import com.kexun.service.FieldDefineService;
|
|
|
import com.kexun.service.FieldTemplateRefService;
|
|
|
import com.kexun.service.FieldTemplateService;
|
|
|
import com.kexun.utils.PageUtils;
|
|
@@ -33,12 +34,15 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, FieldTemplateEntity> implements FieldTemplateService {
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ FieldDefineService fieldDefineService;
|
|
|
@Autowired
|
|
|
FieldTemplateMapper fieldTemplateMapper;
|
|
|
@Autowired
|
|
|
FieldTemplateRefService fieldTemplateRefService;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询模板字段
|
|
|
* @param filedTemplateRO
|
|
@@ -60,6 +64,12 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
|
|
|
return pageList;
|
|
|
}
|
|
|
|
|
|
+ public List<FieldTemplateEntity> selectPage() {
|
|
|
+// System.out.println("aaa");
|
|
|
+ List<FieldTemplateEntity> l = fieldTemplateMapper.selectAll();
|
|
|
+ return l;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存模板字段
|
|
|
*
|
|
@@ -70,24 +80,82 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
|
|
|
if (null != filedTemplateCreateRO) {
|
|
|
FieldTemplateEntity fieldTemplateEntity = new FieldTemplateEntity();
|
|
|
fieldTemplateEntity.setStatus(BaseConsts.STATUS_ON);
|
|
|
+ long time1 = System.currentTimeMillis();
|
|
|
+ filedTemplateCreateRO.setTemplateNo(Long.toString(time1));
|
|
|
+
|
|
|
BeanUtils.copyProperties(filedTemplateCreateRO, fieldTemplateEntity);
|
|
|
fieldTemplateMapper.insert(fieldTemplateEntity);
|
|
|
Long id = fieldTemplateEntity.getId();
|
|
|
- //模板字段关系表
|
|
|
- List<FiledUpdateRO> filedList = filedTemplateCreateRO.getFiledList();
|
|
|
+ FieldTemplateEntity templateEntity = getById(id);
|
|
|
|
|
|
+
|
|
|
+ //模板字段关系表
|
|
|
+ List <String> fieldSelected = filedTemplateCreateRO.getFieldSelected();
|
|
|
+ List <String> fieldSelected2 = filedTemplateCreateRO.getFieldSelected2();
|
|
|
List<FieldTemplateRefEntity> fieldTemplateRefList = new ArrayList<>();
|
|
|
- for (FiledUpdateRO filedUpdateRO : filedList) {
|
|
|
+
|
|
|
+ for (int i=0;i<fieldSelected.size();i++){
|
|
|
+ Long fid = Long.parseLong(fieldSelected.get(i));
|
|
|
+ FieldDefineEntity fieldDefine = fieldDefineService.findByID(fid);
|
|
|
FieldTemplateRefEntity fieldTemplateRefEntity = new FieldTemplateRefEntity();
|
|
|
+ fieldTemplateRefEntity.setIsDeleted(false);
|
|
|
+ fieldTemplateRefEntity.setFieldDefineId(fieldDefine.getId());
|
|
|
+ fieldTemplateRefEntity.setFieldNo(fieldDefine.getFieldNo());
|
|
|
+ fieldTemplateRefEntity.setName(fieldDefine.getName());
|
|
|
fieldTemplateRefEntity.setFieldTemplateId(id);
|
|
|
- fieldTemplateRefEntity.setTemplateNo(filedTemplateCreateRO.getTemplateNo());
|
|
|
- fieldTemplateRefEntity.setFieldDefineId(filedUpdateRO.getId());
|
|
|
- fieldTemplateRefEntity.setFieldNo(filedUpdateRO.getFieldNo());
|
|
|
- fieldTemplateRefEntity.setName(filedUpdateRO.getName());
|
|
|
- fieldTemplateRefEntity.setType(filedUpdateRO.getType());
|
|
|
+ fieldTemplateRefEntity.setTemplateNo(fieldTemplateEntity.getTemplateNo());
|
|
|
+ fieldTemplateRefList.add(fieldTemplateRefEntity);
|
|
|
+ }
|
|
|
+ for (int i=0;i<fieldSelected2.size();i++){
|
|
|
+ Long fid = Long.parseLong(fieldSelected.get(i));
|
|
|
+ FieldDefineEntity fieldDefine = fieldDefineService.findByID(fid);
|
|
|
+ FieldTemplateRefEntity fieldTemplateRefEntity = new FieldTemplateRefEntity();
|
|
|
+ fieldTemplateRefEntity.setIsDeleted(false);
|
|
|
+ fieldTemplateRefEntity.setFieldDefineId(fieldDefine.getId());
|
|
|
+ fieldTemplateRefEntity.setFieldNo(fieldDefine.getFieldNo());
|
|
|
+ fieldTemplateRefEntity.setName(fieldDefine.getName());
|
|
|
+ fieldTemplateRefEntity.setFieldTemplateId(id);
|
|
|
+ fieldTemplateRefEntity.setTemplateNo(fieldTemplateEntity.getTemplateNo());
|
|
|
fieldTemplateRefList.add(fieldTemplateRefEntity);
|
|
|
}
|
|
|
fieldTemplateRefService.saveBatch(fieldTemplateRefList);
|
|
|
+
|
|
|
+// List<FieldTemplateRefEntity> fieldTemplateRefList = new ArrayList<>();
|
|
|
+
|
|
|
+// for (FiledUpdateRO filedUpdateRO : filedList) {
|
|
|
+// FieldTemplateRefEntity fieldTemplateRefEntity = new FieldTemplateRefEntity();
|
|
|
+// fieldTemplateRefEntity.setFieldTemplateId(id);
|
|
|
+// fieldTemplateRefEntity.setTemplateNo(filedTemplateCreateRO.getTemplateNo());
|
|
|
+// fieldTemplateRefEntity.setFieldDefineId(filedUpdateRO.getId());
|
|
|
+// fieldTemplateRefEntity.setFieldNo(filedUpdateRO.getFieldNo());
|
|
|
+// fieldTemplateRefEntity.setName(filedUpdateRO.getName());
|
|
|
+// fieldTemplateRefEntity.setType(filedUpdateRO.getType());
|
|
|
+// fieldTemplateRefList.add(fieldTemplateRefEntity);
|
|
|
+// }
|
|
|
+// fieldTemplateRefService.saveBatch(fieldTemplateRefList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存或者修改字段定义
|
|
|
+ * @param filedTemplateUpdateRO
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void saveOrUpdate(FiledTemplateUpdateRO filedTemplateUpdateRO) {
|
|
|
+ Long id = filedTemplateUpdateRO.getId();
|
|
|
+ FieldTemplateEntity templateEntity = getById(id);
|
|
|
+ FieldTemplateEntity FieldTemplateEntity = new FieldTemplateEntity();
|
|
|
+ List<FiledUpdateRO> filedList = filedTemplateUpdateRO.getFieldSelected();
|
|
|
+ System.out.println(filedList);
|
|
|
+ if (null != templateEntity) {
|
|
|
+ BeanUtils.copyProperties(filedTemplateUpdateRO,FieldTemplateEntity);
|
|
|
+
|
|
|
+ updateById(FieldTemplateEntity);
|
|
|
+ }else {
|
|
|
+ long time1 = System.currentTimeMillis();
|
|
|
+ filedTemplateUpdateRO.setTemplateNo(Long.toString(time1));
|
|
|
+ BeanUtils.copyProperties(filedTemplateUpdateRO,FieldTemplateEntity);
|
|
|
+ save(FieldTemplateEntity);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -101,7 +169,7 @@ public class FieldTemplateServiceImpl extends ServiceImpl<FieldTemplateMapper, F
|
|
|
Long id = filedTemplateUpdateRO.getId();
|
|
|
FieldTemplateEntity fieldTemplateSelect = fieldTemplateMapper.selectById(id);
|
|
|
if (null != fieldTemplateSelect) {
|
|
|
- List<FiledUpdateRO> filedList = filedTemplateUpdateRO.getFiledList();
|
|
|
+ List<FiledUpdateRO> filedList = filedTemplateUpdateRO.getFieldSelected();
|
|
|
//先删除,后insert
|
|
|
List<FieldTemplateRefEntity> filedTemplateList = new ArrayList<>();
|
|
|
for (FiledUpdateRO filedUpdateRO : filedList) {
|