| | |
| | | import com.product.server.report.config.ReportCode; |
| | | import com.product.server.report.service.idel.IReportTypeService; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | import cn.hutool.core.lang.UUID; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class ReportTypeService extends AbstractBaseService implements IReportTypeService{ |
| | |
| | | @Override |
| | | public DataTableEntity getEChartsElementList(String uuid)throws BaseException{ |
| | | StringBuffer sql = new StringBuffer(); |
| | | sql.append("SELECT "); |
| | | sql.append(" a.uuid auuid,a.detail adetail,a.attribute_name aname,a.subordinate_element_type asubordinate_element_type,a.is_commonly ais_commonly,a.prompt_name,a.default_value, "); |
| | | sql.append(" b.uuid buuid,b.detail bdetail,b.attribute_name bname,b.subordinate_element_type bsubordinate_element_type,b.is_commonly bis_commonly, "); |
| | | sql.append(" c.uuid cuuid,c.detail cdetail,c.attribute_name cname,c.subordinate_element_type csubordinate_element_type,c.is_commonly cis_commonly, "); |
| | | sql.append(" d.uuid duuid,d.detail ddetail,d.attribute_name dname,d.subordinate_element_type dsubordinate_element_type,d.is_commonly dis_commonly, "); |
| | | sql.append(" e.uuid euuid,e.detail edetail,e.attribute_name ename,e.subordinate_element_type esubordinate_element_type,e.is_commonly eis_commonly, "); |
| | | sql.append(" f.uuid fuuid,f.detail fdetail,f.attribute_name fname,f.subordinate_element_type fsubordinate_element_type,f.is_commonly fis_commonly "); |
| | | sql.append("FROM product_sys_report_type_attribute a "); |
| | | sql.append("LEFT JOIN product_sys_report_type_attribute b on a.parent_attribute_uuid = b.uuid "); |
| | | sql.append("LEFT JOIN product_sys_report_type_attribute c on b.parent_attribute_uuid = c.uuid "); |
| | | sql.append("LEFT JOIN product_sys_report_type_attribute d on c.parent_attribute_uuid = d.uuid "); |
| | | sql.append("LEFT JOIN product_sys_report_type_attribute e on d.parent_attribute_uuid = e.uuid "); |
| | | sql.append("LEFT JOIN product_sys_report_type_attribute f on e.parent_attribute_uuid = f.uuid "); |
| | | sql.append("WHERE a.config_properties = 1 "); |
| | | sql.append("AND a.type_uuid = ? "); |
| | | sql.append("ORDER BY a.is_commonly DESC"); |
| | | sql.append("\nSELECT "); |
| | | sql.append("\n a.uuid auuid,a.detail adetail,a.attribute_name aname,a.subordinate_element_type asubordinate_element_type,a.is_commonly ais_commonly,a.prompt_name,a.default_value, "); |
| | | sql.append("\n b.uuid buuid,b.detail bdetail,b.attribute_name bname,b.subordinate_element_type bsubordinate_element_type,b.is_commonly bis_commonly, "); |
| | | sql.append("\n c.uuid cuuid,c.detail cdetail,c.attribute_name cname,c.subordinate_element_type csubordinate_element_type,c.is_commonly cis_commonly, "); |
| | | sql.append("\n d.uuid duuid,d.detail ddetail,d.attribute_name dname,d.subordinate_element_type dsubordinate_element_type,d.is_commonly dis_commonly, "); |
| | | sql.append("\n e.uuid euuid,e.detail edetail,e.attribute_name ename,e.subordinate_element_type esubordinate_element_type,e.is_commonly eis_commonly, "); |
| | | sql.append("\n f.uuid fuuid,f.detail fdetail,f.attribute_name fname,f.subordinate_element_type fsubordinate_element_type,f.is_commonly fis_commonly "); |
| | | sql.append("\nFROM product_sys_report_type_attribute a "); |
| | | sql.append("\nLEFT JOIN product_sys_report_type_attribute b on a.parent_attribute_uuid = b.uuid "); |
| | | sql.append("\nLEFT JOIN product_sys_report_type_attribute c on b.parent_attribute_uuid = c.uuid "); |
| | | sql.append("\nLEFT JOIN product_sys_report_type_attribute d on c.parent_attribute_uuid = d.uuid "); |
| | | sql.append("\nLEFT JOIN product_sys_report_type_attribute e on d.parent_attribute_uuid = e.uuid "); |
| | | sql.append("\nLEFT JOIN product_sys_report_type_attribute f on e.parent_attribute_uuid = f.uuid "); |
| | | sql.append("\nWHERE a.config_properties = 1 "); |
| | | sql.append("\nAND a.type_uuid = ? "); |
| | | sql.append("\nORDER BY a.is_commonly DESC"); |
| | | |
| | | return baseDao.listTable(sql.toString(), new String[]{uuid}); |
| | | } |
| | |
| | | } |
| | | return uuid; |
| | | }else { |
| | | if (fse.getSubData() != null) { |
| | | fse.getSubData().clear(); |
| | | } |
| | | baseDao.update(fse); |
| | | return fse.getUUID(); |
| | | } |
| | |
| | | if(BaseUtil.strIsNull(uuid)){ |
| | | uuid = baseDao.add(fse); |
| | | } |
| | | //创建人 |
| | | Integer userId = SpringMVCContextHolder.getCurrentUser().getUser_id(); |
| | | //创建时间 |
| | | Date date = new Date(); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(CmnConst.PRODUCT_SYS_REPORT_TYPE_ATTRIBUTE, " type_uuid = ? ",new String[]{referenced_uuid}); |
| | | for (int i = 0; i <dataTableEntity.getRows() ; i++) { |
| | | FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i); |
| | | fieldSetEntity.remove(CmnConst.ID); |
| | | fieldSetEntity.remove(CmnConst.UUID); |
| | | fieldSetEntity.setValue(CmnConst.TYPE_UUID,uuid); |
| | | fieldSetEntity.setValue(CmnConst.CREATED_BY,userId); |
| | | fieldSetEntity.setValue(CmnConst.CREATED_UTC_DATETIME,date); |
| | | DataTableEntity dtAttribute = baseDao.listTable(CmnConst.PRODUCT_SYS_REPORT_TYPE_ATTRIBUTE, " type_uuid = ? ",new String[]{referenced_uuid}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtAttribute)) { |
| | | //生成创建人和常见时间,UUID更新容器 |
| | | Integer createUser = SpringMVCContextHolder.getCurrentUser().getUser_id(); |
| | | Date createDate = new Date(); |
| | | Map<String, String> uuidMapping = new HashMap<>(); |
| | | for (int i = 0; i <dtAttribute.getRows() ; i++) { |
| | | FieldSetEntity fseAttribute = dtAttribute.getFieldSetEntity(i); |
| | | // 生成新UUID |
| | | String oldUUID = fseAttribute.getUUID(); |
| | | String newUUID = UUID.randomUUID().toString(); |
| | | uuidMapping.put(oldUUID, newUUID); |
| | | fseAttribute.remove(CmnConst.ID); |
| | | fseAttribute.setValue(CmnConst.UUID, newUUID); |
| | | fseAttribute.setValue(CmnConst.TYPE_UUID, uuid); |
| | | fseAttribute.setValue(CmnConst.CREATED_BY, createUser); |
| | | fseAttribute.setValue(CmnConst.CREATED_UTC_DATETIME, createDate); |
| | | } |
| | | baseDao.add(dataTableEntity); |
| | | JSONObject obj = this.getEChartsElement(fse.getUUID()); |
| | | return obj; |
| | | // 更新父级UUID |
| | | for (int i = 0; i < dtAttribute.getRows(); i++) { |
| | | FieldSetEntity fseAttribute = dtAttribute.getFieldSetEntity(i); |
| | | String parentUUID = fseAttribute.getString(CmnConst.PARENT_ATTRIBUTE_UUID); |
| | | if (uuidMapping.containsKey(parentUUID)) { |
| | | fseAttribute.setValue(CmnConst.PARENT_ATTRIBUTE_UUID, uuidMapping.get(parentUUID)); |
| | | } |
| | | } |
| | | baseDao.add(dtAttribute); |
| | | } |
| | | return this.getEChartsElement(fse.getUUID()); |
| | | } |
| | | } |